summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile69
1 files changed, 43 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index b8236fb..51c6cc9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,44 +1,61 @@
1.DEFAULT_GOAL=help 1.DEFAULT_GOAL=help
2.PHONY=help 2.PHONY=help
3SHELL = /bin/bash
4
5SRC := src
3 6
4clean: ## clean everything 7clean: ## clean everything
5 make -C src clean 8 make -C $(SRC) clean
6 cd src; phpize --clean 9 cd $(SRC); phpize --clean
7 10
8release: ## compile with releases flags 11release: ## compile with releases flags
9 cd src; phpize 12 cd $(SRC); phpize
10 cd src; ./configure --enable-snuffleupagus 13 cd $(SRC); ./configure --enable-snuffleupagus
11 make -C src 14 make -C $(SRC)
12 15
13install: release ## compile and install snuffleupagus 16install: release ## compile and install snuffleupagus
14 make -C src install 17 make -C $(SRC) install
15 18
16compile_debug: ## compile a debug build 19compile_debug: ## compile a debug build
17 cd src; phpize 20 cd $(SRC); if [[ ! -f configure ]]; then phpize; fi; \
18 export CFLAGS="-g3 -ggdb -O1 -g"; cd src; ./configure --enable-snuffleupagus --enable-debug 21 ./configure --enable-snuffleupagus --enable-debug --enable-debug-stderr && \
19 make -C src 22 make clean ; make -j4
23
24DOCKER_IMAGE := php:latest
25docker: ## start docker container with current PHP
26 @echo "Starting new docker container with snuffleupagus bind-mounted to /sp"
27 docker run -it -v "$$(pwd)":/sp $(DOCKER_IMAGE) /bin/bash
28
29linked-clone:
30 @if [[ "$(CLONE)" == "" ]]; then echo -e "==> Please provide clone name, e.g.\n make linked-clone CLONE=php8.1\n"; exit 1; fi
31 @if [[ -d "src-$(CLONE)" ]]; then echo -e "==> Clone '$(CLONE)' already exists.\n"; exit 1; fi
32 @echo "==> CREATING LINKED CLONE IN 'src-$(CLONE)' <=="
33 mkdir "src-$(CLONE)"; cd "src-$(CLONE)"; \
34 SRCDIR=../src; ln -s $$SRCDIR/*.[hc] $$SRCDIR/config.m4 $$SRCDIR/snuffleupagus.php $$SRCDIR/Makefile.frag $$SRCDIR/*.re .; \
35 cp -r $$SRCDIR/tests .
36 @echo -e "==> DONE. <==\nCompile a debug build with\n make compile_debug SRC=src-$(CLONE)"
20 37
21tests: release ## compile a release build and run the testsuite 38tests: release ## compile a release build and run the testsuite
22 TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test 39 TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 SP_SKIP_OLD_PHP_CHECK=1 make -C $(SRC) test
23 40
24coverage: ## compile snuffleugpaus, and run the testsuite with coverage 41coverage: ## compile snuffleugpaus, and run the testsuite with coverage
25 cd src; phpize 42 cd $(SRC); phpize
26ifeq ($(CC),clang) 43ifeq ($(CC),clang)
27 cd src; CFLAGS="-fprofile-instr-generate -fcoverage-mapping" ./configure --enable-snuffleupagus 44 cd $(SRC); CFLAGS="-fprofile-instr-generate -fcoverage-mapping" ./configure --enable-snuffleupagus
28 make -C src 45 make -C $(SRC)
29 sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" src/run-tests.php 46 sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" $(SRC)/run-tests.php
30 LLVM_PROFILE_FILE="sp_%p_%m.profraw" TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test 47 LLVM_PROFILE_FILE="sp_%p_%m.profraw" TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C $(SRC) test
31 llvm-profdata-4.0 merge ./src/*.profraw -o ./src/sp.profdata 48 llvm-profdata-4.0 merge ./$(SRC)/*.profraw -o ./$(SRC)/sp.profdata
32 llvm-cov report -instr-profile=./src/sp.profdata ./src/modules/snuffleupagus.so 49 llvm-cov report -instr-profile=./$(SRC)/sp.profdata ./$(SRC)/modules/snuffleupagus.so
33else 50else
34 cd src; ./configure --enable-snuffleupagus --enable-coverage 51 cd $(SRC); ./configure --enable-snuffleupagus --enable-coverage
35 make -C src 52 make -C $(SRC)
36 rm -Rf src/COV.html 53 rm -Rf $(SRC)/COV.html
37 sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" src/run-tests.php 54 sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" $(SRC)/run-tests.php
38 TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test 55 TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C $(SRC) test
39 lcov --base-directory ./src --directory ./src -c -o ./src/COV.info --rc lcov_branch_coverage=1 56 lcov --base-directory ./$(SRC) --directory ./$(SRC) -c -o ./$(SRC)/COV.info --rc lcov_branch_coverage=1
40 lcov --remove src/COV.info '/usr/*' --remove src/COV.info '*tweetnacl.c' -o src/COV.info --rc lcov_branch_coverage=1 57 lcov --remove $(SRC)/COV.info '/usr/*' --remove $(SRC)/COV.info '*tweetnacl.c' -o $(SRC)/COV.info --rc lcov_branch_coverage=1
41 genhtml --show-details -o src/COV.html ./src/COV.info --branch-coverage 58 genhtml --show-details -o $(SRC)/COV.html ./$(SRC)/COV.info --branch-coverage
42endif 59endif
43 60
44bench: joomla ## run the benchmark 61bench: joomla ## run the benchmark
@@ -49,7 +66,7 @@ joomla:
49 fi 66 fi
50 cd joomla-cms; composer install >/dev/null 2>/dev/null 67 cd joomla-cms; composer install >/dev/null 2>/dev/null
51 echo "\nWith snuffleupagus:" 68 echo "\nWith snuffleupagus:"
52 cd joomla-cms; time php -d "extension=../src/modules/snuffleupagus.so" -d "sp.configuration_file=../config/default.rules" libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null 69 cd joomla-cms; time php -d "extension=../$(SRC)/modules/snuffleupagus.so" -d "sp.configuration_file=../config/default.rules" libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null
53 echo "\nWithout snuffleupagus:" 70 echo "\nWithout snuffleupagus:"
54 cd joomla-cms; time php libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null 71 cd joomla-cms; time php libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null
55 72