Skip to content

Commit 18a99a4

Browse files
authored
Autotools: Refactor debug checks (php#15215)
- Added help text for ZEND_DEBUG preprocessor macro - CS synced
1 parent 97eb89a commit 18a99a4

File tree

3 files changed

+20
-30
lines changed

3 files changed

+20
-30
lines changed

Zend/Zend.m4

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,15 @@ AC_MSG_RESULT([$ZEND_ZTS])
168168
169169
AC_MSG_CHECKING([whether to enable Zend debugging])
170170
AC_MSG_RESULT([$ZEND_DEBUG])
171-
172-
if test "$ZEND_DEBUG" = "yes"; then
173-
AC_DEFINE(ZEND_DEBUG,1,[ ])
171+
AH_TEMPLATE([ZEND_DEBUG],
172+
[Define to 1 if debugging is enabled, and to 0 if not.])
173+
AS_VAR_IF([ZEND_DEBUG], [yes], [
174+
AC_DEFINE([ZEND_DEBUG], [1])
174175
echo " $CFLAGS" | grep ' -g' >/dev/null || DEBUG_CFLAGS="-g"
175176
if test "$CFLAGS" = "-g -O2"; then
176177
CFLAGS=-g
177178
fi
178-
else
179-
AC_DEFINE(ZEND_DEBUG,0,[ ])
180-
fi
179+
], [AC_DEFINE([ZEND_DEBUG], [0])])
181180
182181
test -n "$GCC" && CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare $CFLAGS"
183182
dnl Check if compiler supports -Wno-clobbered (only GCC)

configure.ac

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ PHP_ARG_ENABLE([debug],
802802
[no],
803803
[no])
804804

805-
if test "$PHP_DEBUG" = "yes"; then
805+
AS_VAR_IF([PHP_DEBUG], [yes], [
806806
PHP_DEBUG=1
807807
ZEND_DEBUG=yes
808808
changequote({,})
@@ -824,10 +824,10 @@ if test "$PHP_DEBUG" = "yes"; then
824824
CXXFLAGS="$CFLAGS -g"
825825
fi
826826
fi
827-
else
827+
], [
828828
PHP_DEBUG=0
829829
ZEND_DEBUG=no
830-
fi
830+
])
831831

832832
PHP_ARG_ENABLE([debug-assertions],
833833
[whether to enable debug assertions in release mode],
@@ -836,10 +836,10 @@ PHP_ARG_ENABLE([debug-assertions],
836836
[no],
837837
[no])
838838

839-
if test "$PHP_DEBUG_ASSERTIONS" = "yes"; then
839+
AS_VAR_IF([PHP_DEBUG_ASSERTIONS], [yes], [
840840
PHP_DEBUG=1
841841
ZEND_DEBUG=yes
842-
fi
842+
])
843843

844844
AC_ARG_ENABLE([zts],
845845
[AS_HELP_STRING([--enable-zts],
@@ -1367,11 +1367,7 @@ ZEND_MODULE_API_NO=`$EGREP '#define ZEND_MODULE_API_NO ' $srcdir/Zend/zend_modul
13671367
if test -z "$EXTENSION_DIR"; then
13681368
extbasedir=$ZEND_MODULE_API_NO
13691369
if test "$oldstyleextdir" = "yes"; then
1370-
if test "$PHP_DEBUG" = "1"; then
1371-
part1=debug
1372-
else
1373-
part1=no-debug
1374-
fi
1370+
AS_VAR_IF([PHP_DEBUG], [1], [part1=debug], [part1=no-debug])
13751371
if test "$enable_zts" = "yes"; then
13761372
part2=zts
13771373
else
@@ -1383,10 +1379,7 @@ if test -z "$EXTENSION_DIR"; then
13831379
if test "$enable_zts" = "yes"; then
13841380
extbasedir=$extbasedir-zts
13851381
fi
1386-
1387-
if test "$PHP_DEBUG" = "1"; then
1388-
extbasedir=$extbasedir-debug
1389-
fi
1382+
AS_VAR_IF([PHP_DEBUG], [1], [extbasedir=$extbasedir-debug])
13901383
EXTENSION_DIR=$libdir/$extbasedir
13911384
fi
13921385
fi

scripts/phpize.m4

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,17 @@ AC_MSG_CHECKING([for PHP installed headers prefix])
7777
AC_MSG_RESULT([$phpincludedir])
7878

7979
dnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS.
80-
AC_MSG_CHECKING([if debug is enabled])
80+
AC_MSG_CHECKING([if debugging is enabled])
8181
old_CPPFLAGS=$CPPFLAGS
8282
CPPFLAGS="-I$phpincludedir"
83-
AC_EGREP_CPP(php_debug_is_enabled,[
83+
AC_EGREP_CPP([php_debug_is_enabled], [
8484
#include <main/php_config.h>
8585
#if ZEND_DEBUG
8686
php_debug_is_enabled
8787
#endif
88-
],[
89-
PHP_DEBUG=yes
90-
],[
91-
PHP_DEBUG=no
92-
])
88+
],
89+
[PHP_DEBUG=yes],
90+
[PHP_DEBUG=no])
9391
CPPFLAGS=$old_CPPFLAGS
9492
AC_MSG_RESULT([$PHP_DEBUG])
9593

@@ -110,7 +108,7 @@ CPPFLAGS=$old_CPPFLAGS
110108
AC_MSG_RESULT([$PHP_THREAD_SAFETY])
111109

112110
dnl Discard optimization flags when debugging is enabled.
113-
if test "$PHP_DEBUG" = "yes"; then
111+
AS_VAR_IF([PHP_DEBUG], [yes], [
114112
PHP_DEBUG=1
115113
ZEND_DEBUG=yes
116114
changequote({,})
@@ -132,10 +130,10 @@ if test "$PHP_DEBUG" = "yes"; then
132130
CXXFLAGS="$CFLAGS -g"
133131
fi
134132
fi
135-
else
133+
], [
136134
PHP_DEBUG=0
137135
ZEND_DEBUG=no
138-
fi
136+
])
139137

140138
dnl Always shared.
141139
PHP_BUILD_SHARED

0 commit comments

Comments
 (0)