missing x bit
[compress.git] / makefile
index dcc7a58098a738d4cd4d3b5c0c683146cb3e80a1..997c6d7fa56281800ee0b62f1d0251141c4af1bc 100644 (file)
--- a/makefile
+++ b/makefile
@@ -3,12 +3,13 @@
 CC = gcc
 
 INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
+OFLAGS  = -O4 -Os
 #OFLAGS  = -O4 -ffast-math -finline-functions
-OFLAGS  = -O4 -finline-functions
+#OFLAGS  = -O4 -finline-functions
 #OFLAGS += -mtune=pentium3 -mmmx -msse -msse2 -m3dnow
-OFLAGS += -minline-all-stringops -fsingle-precision-constant
-OFLAGS += -malign-double
-CFLAGS += -Wall -Wextra -g
+#OFLAGS += -minline-all-stringops -fsingle-precision-constant
+#OFLAGS += -malign-double
+CFLAGS += -W -Wall -Wextra -g
 CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
 CFLAGS += $(OFLAGS) $(INCLUDES)
 LDFLAGS += -g
@@ -16,7 +17,7 @@ LDFLAGS += -g
 # Targets
 
 ALLEXE  =
-
+ALLEXE += compress
 ALLEXE += skel
 
 SHELL = bash
@@ -45,7 +46,7 @@ all: depends
 alltests: all
        $(MAKE) $(addprefix test_,$(ALLEXE:%.exe=%))
 
-depends: $(patsubst %.c, %.d, $(wildcard *.c))
+depends: $(patsubst %.c, %.d, $(wildcard *.c)) $(patsubst %, %.ld, $(ALLEXE))
 
 count:
        wc $(wildcard *.c *.h) $(MAKEFILE_LIST)
@@ -53,7 +54,7 @@ count:
 clean:
        $(call TITLE, "Cleaning")
        touch clean
-       rm -f clean $(wildcard *.d *.log *.o *.test *~ .exec_*)
+       rm -f clean $(wildcard *.d *.ld *.log *.o *.test *~ .exec_*)
        $(call PASS, SUCCESS)
 
 purge: clean
@@ -65,6 +66,7 @@ purge: clean
 ## Main rules
 
 include $(wildcard *.d)
+include $(wildcard *.ld)
 
 %.test: %.c
        $(call TITLE, "Building $@")
@@ -73,14 +75,10 @@ include $(wildcard *.d)
        $(call PASS, SUCCESS)
 
 test_%: %.test %.exe
-       PATH=$$PATH:.; \
-       IFS=$$'\n'; \
-       LOGFILE=${<:.test=.log}; \
-       rm -f $$LOGFILE; \
-       RC=0; \
-       for test in `cat $<`; do \
-         echo "=== $$test ===" | tee -a $$LOGFILE; \
-         ( eval $(VALGRIND) $$test ) 2>&1 | tee -a $$LOGFILE; \
+       IFS=$$'\n'; RC=0; \
+       for test in `cat $< | sed 's,${<:.test=.exe},./${<:.test=.exe},g'`; do \
+         echo "=== $$test ==="; \
+         eval $(VALGRIND) $$test; \
          [ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \
                        || { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \
        done; \
@@ -98,6 +96,11 @@ valgrind_%: %
        mv $@~ $@
        $(call PASS, SUCCESS)
 
+%.ld: %.c
+       $(call TITLE, "Building $@")
+       echo ${<:.c=.exe}: $(shell ./getcomments.pl -p='linker:\s' -f='%' $< | awk '{for (i=1;i<=NF;i++) if ($$(i) ~ /.o$$/) printf " %s", $$(i)}') > $@
+       $(call PASS, SUCCESS)
+
 %.o: %.c
        $(call TITLE, "Building $@")
        $(CC) $(CFLAGS) $(INCLUDES) $(shell ./getcomments.pl -p='cflags:\s' -f='%' $<) -c $< -o $@
@@ -106,9 +109,7 @@ valgrind_%: %
 
 %.exe: %.o %.d
        $(call TITLE, "Building $@")
-       $(CC) $(LDFLAGS) $(shell ./getcomments.pl -p='linker:\s' -f='%' ${<:.o=.c}) $< -o ${<:.o=}
-       echo ${<:.o=} >> .targets
-       #ln -sf ${<:.o=} $@
+       $(CC) $(LDFLAGS) $(shell ./getcomments.pl -p='linker:\s' -f='%' ${<:.o=.c}) $< -o $@
        $(call PASS, SUCCESS)
 
 ## Phony