From 4dc382c63f4219cdbf5dd784f0d8025f6af68629 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 26 Sep 2017 15:08:42 +0200 Subject: Simplify and improve the build system - CFLAGS are now set in the config.m4 file (and not in the Makefile anymore) - `make release` is added - `make debug` and `make coverage` are now simpler - hardening flags are added --- Makefile | 12 ++++++++++-- src/config.m4 | 16 ++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 29cd02a..a6d9a90 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,23 @@ clean: make -C src clean cd src; phpize --clean +release: + cd src; phpize + cd src; ./configure --enable-snuffleupagus + make -C src + +install: release + make -C install + debug: cd src; phpize - export CFLAGS="-Wall -Wextra -g3 -ggdb -O1 -g -Wno-unused-function"; cd src; ./configure --enable-snuffleupagus --enable-debug + export CFLAGS="-g3 -ggdb -O1 -g"; cd src; ./configure --enable-snuffleupagus --enable-debug make -C src TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test coverage: cd src; phpize - export CFLAGS="--coverage"; cd src; ./configure --enable-snuffleupagus --enable-coverage + cd src; ./configure --enable-snuffleupagus --enable-coverage make -C src rm -Rf src/COV.html TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test diff --git a/src/config.m4 b/src/config.m4 index 4f70871..bf5523a 100644 --- a/src/config.m4 +++ b/src/config.m4 @@ -16,12 +16,13 @@ PHP_ARG_ENABLE(coverage, whether to enable coverage support, PHP_ARG_ENABLE(debug, whether to enable debug messages, [ --enable-debug Enable debug messages]) -CFLAGS="$CFLAGS -lpcre" +CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -D_DEFAULT_SOURCE=1 -std=c99" CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter" -CFLAGS="$CFLAGS --coverage" +CFLAGS="$CFLAGS -Wformat=2 -Wformat-security -D_FORTIFY_SOURCE=2" +CFLAGS="$CFLAGS -fstack-protector" -LDFLAGS="$LDFLAGS -lpcre --coverage" +LDFLAGS="$LDFLAGS -lpcre" if test "$PHP_DEBUG" = "yes"; then AC_DEFINE(SP_DEBUG, 1, [Wether you want to enable debug messages]) @@ -31,12 +32,7 @@ AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre])) if test "$PHP_SNUFFLEUPAGUS" = "yes"; then if test "$PHP_COVERAGE" = "yes"; then - CFLAGS="$CFLAGS --coverage" - LDFLAGS="$LDFLAGS --coverage" - PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -g --coverage -lgcov) - else - CFLAGS="$CFLAGS --coverage" - LDFLAGS="$LDFLAGS --coverage" - PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) + CFLAGS="$CFLAGS -g --coverage -lgcov -O1 -g" fi + PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) fi -- cgit v1.3