diff options
| author | Ben Fuhrmannek | 2022-01-11 17:46:40 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2022-01-11 17:46:40 +0100 |
| commit | f6dba50f57a5e8de6d75b8168f988104991ebaeb (patch) | |
| tree | d704023660cac32d7cac9eddf9192318b351f67a /Makefile | |
| parent | dab03c5c0df03c4cfda4e0b8a7da62b2feb4e2ac (diff) | |
make src-dir variable in makefile and use bash as default shell
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 69 |
1 files changed, 36 insertions, 33 deletions
| @@ -1,58 +1,61 @@ | |||
| 1 | .DEFAULT_GOAL=help | 1 | .DEFAULT_GOAL=help |
| 2 | .PHONY=help | 2 | .PHONY=help |
| 3 | SHELL = /bin/bash | ||
| 4 | |||
| 5 | SRC := src | ||
| 3 | 6 | ||
| 4 | clean: ## clean everything | 7 | clean: ## clean everything |
| 5 | make -C src clean | 8 | make -C $(SRC) clean |
| 6 | cd src; phpize --clean | 9 | cd $(SRC); phpize --clean |
| 7 | 10 | ||
| 8 | release: ## compile with releases flags | 11 | release: ## 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 -j4 clean all | 14 | make -C $(SRC) -j4 clean all |
| 12 | 15 | ||
| 13 | install: release ## compile and install snuffleupagus | 16 | install: release ## compile and install snuffleupagus |
| 14 | make -C src install | 17 | make -C $(SRC) install |
| 15 | 18 | ||
| 16 | compile_debug: ## compile a debug build | 19 | compile_debug: ## compile a debug build |
| 17 | cd src; if [[ ! -f configure ]]; then phpize; fi; \ | 20 | cd $(SRC); if [[ ! -f configure ]]; then phpize; fi; \ |
| 18 | ./configure --enable-snuffleupagus --enable-debug --enable-debug-stderr | 21 | ./configure --enable-snuffleupagus --enable-debug --enable-debug-stderr && \ |
| 19 | make -C src -j4 clean all | 22 | make clean ; make -j4 |
| 20 | 23 | ||
| 21 | DOCKER_IMAGE := php:latest | 24 | DOCKER_IMAGE := php:latest |
| 22 | docker: ## start docker container with current PHP | 25 | docker: ## start docker container with current PHP |
| 23 | @echo "starting new docker container with snuffleupagus bind-mounted to /sp" | 26 | @echo "Starting new docker container with snuffleupagus bind-mounted to /sp" |
| 24 | docker run -it -v "$$(pwd)":/sp $(DOCKER_IMAGE) /bin/bash | 27 | docker run -it -v "$$(pwd)":/sp $(DOCKER_IMAGE) /bin/bash |
| 25 | 28 | ||
| 26 | linked-clone: | 29 | linked-clone: |
| 27 | @if [[ "$(CLONE)" == "" ]]; then echo "Please provide clone name, e.g.\n make linked-clone CLONE=php8.1"; exit 1; fi | 30 | @if [[ "$(CLONE)" == "" ]]; then echo "==> Please provide clone name, e.g.\n make linked-clone CLONE=php8.1"; exit 1; fi |
| 28 | @if [[ -d "src-$(CLONE)" ]]; then echo "Clone '$(CLONE)' already exists."; exit 1; fi | 31 | @if [[ -d "src-$(CLONE)" ]]; then echo "==> Clone '$(CLONE)' already exists."; exit 1; fi |
| 29 | @echo "creating linked clone in 'src-$(CLONE)'..." | 32 | @echo "==> CREATING LINKED CLONE IN 'src-$(CLONE)' <==" |
| 30 | mkdir "src-$(CLONE)"; cd "src-$(CLONE)"; \ | 33 | mkdir "src-$(CLONE)"; cd "src-$(CLONE)"; \ |
| 31 | SRC=../src; ln -s $$SRC/*.[hc] $$SRC/config.m4 $$SRC/snuffleupagus.php $$SRC/Makefile.frag $$SRC/*.re .; \ | 34 | SRCDIR=../src; ln -s $$SRC/*.[hc] $$SRCDIR/config.m4 $$SRCDIR/snuffleupagus.php $$SRCDIR/Makefile.frag $$SRCDIR/*.re .; \ |
| 32 | cp -r $$SRC/tests . | 35 | cp -r $$SRCDIR/tests . |
| 33 | @echo "done. go ahead and do phpize/configure/make" | 36 | @echo "==> DONE. <==\nCompile a debug build with\n make compile_debug SRC=src-$(CLONE)" |
| 34 | 37 | ||
| 35 | tests: release ## compile a release build and run the testsuite | 38 | tests: release ## compile a release build and run the testsuite |
| 36 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 SP_SKIP_OLD_PHP_CHECK=1 make -C src test | 39 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 SP_SKIP_OLD_PHP_CHECK=1 make -C $(SRC) test |
| 37 | 40 | ||
| 38 | coverage: ## compile snuffleugpaus, and run the testsuite with coverage | 41 | coverage: ## compile snuffleugpaus, and run the testsuite with coverage |
| 39 | cd src; phpize | 42 | cd $(SRC); phpize |
| 40 | ifeq ($(CC),clang) | 43 | ifeq ($(CC),clang) |
| 41 | cd src; CFLAGS="-fprofile-instr-generate -fcoverage-mapping" ./configure --enable-snuffleupagus | 44 | cd $(SRC); CFLAGS="-fprofile-instr-generate -fcoverage-mapping" ./configure --enable-snuffleupagus |
| 42 | make -C src | 45 | make -C $(SRC) |
| 43 | 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 |
| 44 | 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 |
| 45 | llvm-profdata-4.0 merge ./src/*.profraw -o ./src/sp.profdata | 48 | llvm-profdata-4.0 merge ./$(SRC)/*.profraw -o ./$(SRC)/sp.profdata |
| 46 | 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 |
| 47 | else | 50 | else |
| 48 | cd src; ./configure --enable-snuffleupagus --enable-coverage | 51 | cd $(SRC); ./configure --enable-snuffleupagus --enable-coverage |
| 49 | make -C src | 52 | make -C $(SRC) |
| 50 | rm -Rf src/COV.html | 53 | rm -Rf $(SRC)/COV.html |
| 51 | 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 |
| 52 | 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 |
| 53 | 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 |
| 54 | 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 |
| 55 | 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 |
| 56 | endif | 59 | endif |
| 57 | 60 | ||
| 58 | bench: joomla ## run the benchmark | 61 | bench: joomla ## run the benchmark |
| @@ -63,7 +66,7 @@ joomla: | |||
| 63 | fi | 66 | fi |
| 64 | cd joomla-cms; composer install >/dev/null 2>/dev/null | 67 | cd joomla-cms; composer install >/dev/null 2>/dev/null |
| 65 | echo "\nWith snuffleupagus:" | 68 | echo "\nWith snuffleupagus:" |
| 66 | 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 |
| 67 | echo "\nWithout snuffleupagus:" | 70 | echo "\nWithout snuffleupagus:" |
| 68 | 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 |
| 69 | 72 | ||
