Skip to content

Commit 6fc3662

Browse files
committed
Refactor config.m4
1 parent f3ce866 commit 6fc3662

File tree

2 files changed

+101
-73
lines changed

2 files changed

+101
-73
lines changed

.editorconfig

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,19 @@
22

33
# top-most EditorConfig file
44
root = true
5+
charset = utf-8
6+
trim_trailing_whitespace = true
57

68
[*]
79
end_of_line = lf
810
insert_final_newline = true
911
indent_style = tab
1012
indent_size = 4
11-
charset = utf-8
12-
trim_trailing_whitespace = true
13-
14-
[Makefile,Makefile.*]
15-
indent_style = tab
16-
17-
[*.{awk,w32,bat,mk,frag,psm1}]
18-
indent_style = tab
1913

2014
[*.{php,phpt,xml,json,w32}]
2115
indent_style = space
2216

23-
[*.yml]
17+
[*.{yml,m4}]
2418
indent_size = 2
2519
indent_style = space
2620

config.m4

Lines changed: 98 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,124 @@
11
dnl config.m4 for extension zephir_parser
22

3+
dnl Functions -----------------------------------------------------------------
4+
AC_DEFUN([PHP_ZEPHIR_PARSER_ADD_SOURCES], [
5+
PHP_ZEPHIR_PARSER_SOURCES="$PHP_ZEPHIR_PARSER_SOURCES $1"
6+
])
7+
8+
AC_DEFUN([PHP_ZEPHIR_PARSER_ADD_HEADERS], [
9+
PHP_ZEPHIR_PARSER_HEADERS="$PHP_ZEPHIR_PARSER_HEADERS $1"
10+
])
11+
12+
AC_DEFUN([PHP_ZEPHIR_PARSER_ADD_FLAGS], [
13+
PHP_ZEPHIR_PARSER_FLAGS="$PHP_ZEPHIR_PARSER_FLAGS $1"
14+
])
15+
16+
dnl Zephir Parser -------------------------------------------------------------
317
PHP_ARG_ENABLE(zephir-parser, whether to enable Zephir Parser,
18+
dnl Make sure that the comment is aligned:
419
[ --enable-zephir-parser Enable Zephir Parser], yes)
520

6-
PHP_ARG_ENABLE(zephir-parser-debug, whether to enable debugging support in Zephir Parser,
7-
[ --enable-zephir-parser-debug Enable debugging support in Zephir Parser], no, no)
21+
dnl Debug Mode ----------------------------------------------------------------
22+
PHP_ARG_ENABLE(zephir-parser-debug,
23+
whether to enable debugging support in Zephir Parser,
24+
dnl Make sure that the comment is aligned:
25+
[ --enable-zephir-parser-debug
26+
Enable debugging support in Zephir Parser], no, no)
827

28+
dnl Main ----------------------------------------------------------------------
929
if test "$PHP_ZEPHIR_PARSER" = "yes"; then
10-
AC_MSG_CHECKING([for PHP version])
11-
PHP_ZEPHIR_PARSER_FOUND_VERSION=`${PHP_CONFIG} --version`
12-
PHP_ZEPHIR_PARSER_FOUND_VERNUM=`${PHP_CONFIG} --vernum`
13-
if test "$PHP_ZEPHIR_PARSER_FOUND_VERNUM" -lt "70000"; then
14-
AC_MSG_ERROR([not supported. Need a PHP version >= 7.0.0 (found $PHP_ZEPHIR_PARSER_FOUND_VERSION)])
15-
else
16-
AC_MSG_RESULT([$PHP_ZEPHIR_PARSER_FOUND_VERSION (ok)])
17-
fi
18-
19-
AC_DEFINE(HAVE_ZEPHIR_PARSER, 1, [Whether you have Zephir Parser])
20-
21-
if test "$PHP_ZEPHIR_PARSER_DEBUG" != "no"; then
22-
AC_DEFINE(USE_ZEPHIR_PARSER_DEBUG, 1, [Include debugging support in Zephir Parser])
23-
fi
24-
25-
PHP_ZEPHIR_PARSER_CFLAGS="-I@ext_srcdir@/parser"
26-
27-
EXT_ZEPHIR_PARSER_SOURCES="zephir_parser.c parser/parser.c parser/scanner.c"
28-
EXT_ZEPHIR_PARSER_HEADERS="zephir_parser.h parser/parser.h parser/parser.php5.inc.h \
29-
parser/parser.php7.inc.h parser/parser.php5.h \
30-
parser/parser.php7.h parser/scanner.h parser/xx.h"
31-
32-
PHP_NEW_EXTENSION(zephir_parser, $EXT_ZEPHIR_PARSER_SOURCES, $ext_shared,, \\$(PHP_ZEPHIR_PARSER_CFLAGS))
33-
ifdef([PHP_INSTALL_HEADERS], [
34-
PHP_INSTALL_HEADERS([ext/zephir_parser], $EXT_ZEPHIR_PARSER_HEADERS)
35-
])
36-
37-
PHP_ADD_MAKEFILE_FRAGMENT([parser.mk])
30+
AC_MSG_CHECKING([for PHP version])
31+
_found_version=`${PHP_CONFIG} --version`
32+
_found_vernum=`${PHP_CONFIG} --vernum`
33+
34+
if test "$_found_vernum" -lt "70000"; then
35+
AC_MSG_ERROR(
36+
[not supported. Need a PHP version >= 7.0.0 (found $_found_version)]
37+
)
38+
else
39+
AC_MSG_RESULT([$_found_version (ok)])
40+
fi
41+
42+
AC_DEFINE(HAVE_ZEPHIR_PARSER, 1, [Whether you have Zephir Parser])
43+
44+
if test "$PHP_ZEPHIR_PARSER_DEBUG" != "no"; then
45+
AC_DEFINE(USE_ZEPHIR_PARSER_DEBUG, 1,
46+
[Include debugging support in Zephir Parser])
47+
fi
48+
49+
PHP_ZEPHIR_PARSER_ADD_FLAGS([-I@ext_srcdir@/parser])
50+
51+
PHP_ZEPHIR_PARSER_ADD_SOURCES([
52+
zephir_parser.c
53+
parser/parser.c
54+
parser/scanner.c
55+
])
56+
57+
PHP_ZEPHIR_PARSER_ADD_HEADERS([
58+
zephir_parser.h
59+
parser/parser.h
60+
parser/scanner.h
61+
parser/xx.h
62+
parser/zephir.h
63+
])
64+
65+
PHP_NEW_EXTENSION(zephir_parser, $PHP_ZEPHIR_PARSER_SOURCES, $ext_shared,, $PHP_ZEPHIR_PARSER_FLAGS)
66+
67+
ifdef([PHP_INSTALL_HEADERS],
68+
[PHP_INSTALL_HEADERS([ext/zephir_parser], $PHP_ZEPHIR_PARSER_FLAGS)])
69+
70+
PHP_ADD_MAKEFILE_FRAGMENT([parser.mk])
3871
fi
3972

73+
dnl Code Coverage -------------------------------------------------------------
4074
PHP_ARG_ENABLE(coverage, whether to include code coverage symbols,
4175
[ --enable-coverage Enable code coverage], no, no)
4276

4377
if test "$PHP_COVERAGE" != "no"; then
44-
dnl Check if ccache is being used
45-
case `$php_shtool path $CC` in
46-
*ccache*[)] ccache=yes;;
47-
*[)] ccache=no;;
48-
esac
49-
50-
if test "$ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
51-
err_msg=$(cat | tr '\012' ' ' <<ΕΟF
78+
dnl Check if ccache is being used
79+
case `$php_shtool path $CC` in
80+
*ccache*[)] ccache=yes;;
81+
*[)] ccache=no;;
82+
esac
83+
84+
if test "$ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
85+
err_msg=$(cat | tr '\012' ' ' <<ΕΟF
5286
ccache must be disabled when --enable-coverage option is used.
5387
You can disable ccache by setting environment variable CCACHE_DISABLE=1.
5488
ΕΟF
55-
)
89+
)
5690

57-
AC_MSG_ERROR([$err_msg])
58-
fi
91+
AC_MSG_ERROR([$err_msg])
92+
fi
5993

60-
AC_CHECK_PROG(LCOV, lcov, lcov)
61-
PHP_SUBST(LCOV)
94+
AC_CHECK_PROG(LCOV, lcov, lcov)
95+
PHP_SUBST(LCOV)
6296

63-
if test -z "$LCOV"; then
64-
AC_MSG_ERROR([lcov testing requested but lcov not found])
65-
fi
97+
if test -z "$LCOV"; then
98+
AC_MSG_ERROR([lcov testing requested but lcov not found])
99+
fi
66100

67-
AC_CHECK_PROG(GENHTML, genhtml, genhtml)
68-
PHP_SUBST(GENHTML)
101+
AC_CHECK_PROG(GENHTML, genhtml, genhtml)
102+
PHP_SUBST(GENHTML)
69103

70-
if test -z "$GENHTML"; then
71-
AC_MSG_ERROR([Could not find genhtml from the LCOV package])
72-
fi
104+
if test -z "$GENHTML"; then
105+
AC_MSG_ERROR([Could not find genhtml from the LCOV package])
106+
fi
73107

74-
changequote({,})
75-
dnl Remove all optimization flags from CFLAGS
76-
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
77-
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
78-
dnl Remove --coverage flag from LDFLAGS
79-
LDFLAGS=`echo "$LDFLAGS" | $SED -e 's/--coverage//g'`
80-
changequote([,])
108+
changequote({,})
109+
dnl Remove all optimization flags from CFLAGS
110+
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
111+
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
112+
dnl Remove --coverage flag from LDFLAGS
113+
LDFLAGS=`echo "$LDFLAGS" | $SED -e 's/--coverage//g'`
114+
changequote([,])
81115

82-
dnl Add the special flags
83-
LDFLAGS="$LDFLAGS --coverage"
84-
CFLAGS="$CFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage"
85-
CXXFLAGS="$CXXFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage"
116+
dnl Add the special flags
117+
LDFLAGS="$LDFLAGS --coverage"
118+
CFLAGS="$CFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage"
119+
CXXFLAGS="$CXXFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage"
86120

87-
PHP_ADD_MAKEFILE_FRAGMENT([coverage.mk])
121+
PHP_ADD_MAKEFILE_FRAGMENT([coverage.mk])
88122

89-
AC_DEFINE(USE_COVERAGE, 1, [Whether coverage is enabled])
123+
AC_DEFINE(USE_COVERAGE, 1, [Whether coverage is enabled])
90124
fi

0 commit comments

Comments
 (0)