flush
[m6w6/btr] / lib / btr / build / php.mk
1 BUILD_CLEAN=false
2 BUILD_ARGS= --enable-debug
3 TEST_ARGS= -q
4
5 .PHONY: all clean
6 .SUFFIXES:
7
8 CONFIGS=$(wildcard $(BRANCH_DIR)/ext/*/config*.m4)
9
10 all: clean $(REPORT)
11 $(SAY) "Result: $$(cat $(REPORT))"
12
13 clean: $(CONFIG_REPORT)
14 if $(BUILD_CLEAN); \
15 then \
16 cd $(BUILD_DIR) && \
17 make $(SILENT_FLAG) clean; \
18 fi;
19
20 $(REPORT): $(TEST_REPORT)
21 @(\
22 TESTS_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(TEST_REPORT)); \
23 TESTS_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(TEST_REPORT)); \
24 printf "%d/%d" $$TESTS_PASSED $$TESTS_FAILED >$@; \
25 if test -s "$(LAST_REPORT)"; then \
26 LAST_PASSED=$$(awk '/^Tests passed/{print $$4}' < $(LAST_REPORT)); \
27 LAST_FAILED=$$(awk '/^Tests failed/{print $$4}' < $(LAST_REPORT)); \
28 DIFF_PASSED=$$(bc <<<"$$TESTS_PASSED - $$LAST_PASSED"); \
29 DIFF_FAILED=$$(bc <<<"$$TESTS_FAILED - $$LAST_FAILED"); \
30 printf " %+d/%+d" $$DIFF_PASSED $$DIFF_FAILED >>$@; \
31 fi; \
32 printf "\n" >>$@; \
33 )
34
35 $(TEST_REPORT): $(BUILD_REPORT)
36 $(SAY) "Running tests... "
37 cd $(BUILD_DIR) && \
38 make test TESTS="$(TEST_ARGS) -s ../$@"
39
40 $(BUILD_REPORT): $(CONFIG_REPORT)
41 $(SAY) "Making build..."
42 cd $(BUILD_DIR) && \
43 make -j $(CPUS) >../$@ 2>&1
44
45 $(CONFIG_REPORT): $(BRANCH_DIR)/configure $(BUILD_DIR)
46 $(SAY) "Running 'configure'..."
47 cd $(BUILD_DIR) && \
48 ../$(BRANCH_DIR)/configure -C $(BUILD_ARGS) >../$@ 2>&1
49
50 $(BUILD_DIR):
51 mkdir -p $@
52
53 $(BRANCH_DIR)/configure: $(BRANCH_DIR)/buildconf $(CONFIGS)
54 $(SAY) "Building configure..."
55 cd $(BRANCH_DIR) && \
56 ./buildconf >/dev/null
57
58 # vim: noet