5 INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
6 #OFLAGS = -O4 -ffast-math -finline-functions
7 OFLAGS = -O4 -finline-functions
8 #OFLAGS += -mtune=pentium3 -mmmx -msse -msse2 -m3dnow
9 OFLAGS += -minline-all-stringops -fsingle-precision-constant
10 OFLAGS += -malign-double
11 CFLAGS += -Wall -Wextra -g
12 CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
13 CFLAGS += $(OFLAGS) $(INCLUDES)
29 TITLE = echo -en "\033[0;1m$(strip $(1))\033[0;0m:\t"
30 PASS = echo -e "\033[1;32m$(strip $(1))\033[0;0m"
31 WARN = echo -e "\033[1;33m$(strip $(1))\033[0;0m"
32 FAIL = echo -e "\033[1;31m$(strip $(1))\033[0;0m"
34 MKDIR = mkdir -p $(1) && chmod a+rx,go-w $(1)
36 INSTALL = test -d `dirname $(2)` || $(call MKDIR, `dirname $(2)`) && cp -pa $(1) $(2) && chmod a+rX,go-w $(2)
38 VALID = $(call TITLE, $(1)) && $(2) && $(call PASS, SUCCESS) || { $(call FAIL, FAILED); test; }
43 $(MAKE) $(ALLEXE:%=%.exe)
46 $(MAKE) $(addprefix test_,$(ALLEXE:%.exe=%))
48 depends: $(patsubst %.c, %.d, $(wildcard *.c))
51 wc $(wildcard *.c *.h) $(MAKEFILE_LIST)
54 $(call TITLE, "Cleaning")
56 rm -f clean $(wildcard *.d *.log *.o *.test *~ .exec_*)
60 $(call TITLE, "Purging")
62 rm -f purge $(ALLEXE) $(shell [ -f .targets ] && { cat .targets | sort | uniq; echo .targets; })
67 include $(wildcard *.d)
70 $(call TITLE, "Building $@")
71 # awk '/\/\* *test:.*\*\// { sub(/^.*\/\* *test: */, ""); sub(/ *\*\/.*$$/, ""); print }' $< > $@
72 ./getcomments.pl -p='test:\s' -f='%' $< > $@
77 for test in `cat $< | sed 's,${<:.test=.exe},./${<:.test=.exe},g'`; do \
78 echo "=== $$test ==="; \
79 eval $(VALGRIND) $$test; \
80 [ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \
81 || { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \
86 VALGRIND="valgrind -v --leak-check=full --show-reachable=yes --log-fd=2"; \
91 $(call TITLE, "Building $@")
92 $(CC) $(INCLUDES) -MM $< -o $@~
93 echo ${<:.c=.o}: $(shell ./getcomments.pl -p='depend:\s' -f='%' $<) >> $@~
98 $(call TITLE, "Building $@")
99 $(CC) $(CFLAGS) $(INCLUDES) $(shell ./getcomments.pl -p='cflags:\s' -f='%' $<) -c $< -o $@
100 $(call PASS, SUCCESS)
104 $(call TITLE, "Building $@")
105 $(CC) $(LDFLAGS) $(shell ./getcomments.pl -p='linker:\s' -f='%' ${<:.o=.c}) $< -o ${<:.o=}
106 echo ${<:.o=} >> .targets
108 $(call PASS, SUCCESS)
112 .PHONY: clean count purge