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
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)
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
## Main rules
include $(wildcard *.d)
+include $(wildcard *.ld)
%.test: %.c
$(call TITLE, "Building $@")
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 $@
%.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