Soft'N'Design Software
/
projects
/
compress.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
43215c4
)
best makefile
author
Laurent Mazet
<mazet@softndesign.org>
Fri, 29 Dec 2023 23:11:43 +0000
(
00:11
+0100)
committer
Laurent Mazet
<mazet@softndesign.org>
Fri, 29 Dec 2023 23:11:43 +0000
(
00:11
+0100)
makefile
patch
|
blob
|
blame
|
history
diff --git
a/makefile
b/makefile
index 7080f6859ae4edbb89359fdfe7ac62f18697645b..529e0bf25c2193e9669978849d46478784d74eaa 100644
(file)
--- a/
makefile
+++ b/
makefile
@@
-2,7
+2,8
@@
CC = gcc
CC = gcc
-INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
+#INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
+INCLUDES =
OFLAGS = -O4 -Os
#OFLAGS = -O4 -ffast-math -finline-functions
#OFLAGS = -O4 -finline-functions
OFLAGS = -O4 -Os
#OFLAGS = -O4 -ffast-math -finline-functions
#OFLAGS = -O4 -finline-functions
@@
-10,15
+11,19
@@
OFLAGS = -O4 -Os
#OFLAGS += -minline-all-stringops -fsingle-precision-constant
#OFLAGS += -malign-double
CFLAGS += -W -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) $(OPTION)
-LDFLAGS += -g $(OPTION)
+#CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
+CFLAGS += $(OFLAGS) $(INCLUDES) $(OPTIONS)
+LDFLAGS += -g $(OPTIONS)
+
+ifeq ($(OS),Windows_NT)
+#LDLIBS += -lws2_32
+endif
+
# Targets
ALLEXE =
ALLEXE += compress
# Targets
ALLEXE =
ALLEXE += compress
-#ALLEXE += skel
SHELL = bash
SHELL = bash
@@
-50,7
+55,7
@@
count:
clean:
$(call TITLE, "Cleaning")
touch clean
clean:
$(call TITLE, "Cleaning")
touch clean
- rm -f clean $(wildcard *.d *.ld *.o *.test *~ .exec_* gmon.out)
+ rm -f clean $(wildcard *.d *.ld *.
log *.
o *.test *~ .exec_* gmon.out)
$(call PASS, SUCCESS)
depends: $(patsubst %.c, %.d, $(wildcard *.c)) $(patsubst %, %.ld, $(ALLEXE))
$(call PASS, SUCCESS)
depends: $(patsubst %.c, %.d, $(wildcard *.c)) $(patsubst %, %.ld, $(ALLEXE))
@@
-67,13
+72,13
@@
purge: clean
rm -f purge $(ALLEXE:%=%.exe)
$(call PASS, SUCCESS)
rm -f purge $(ALLEXE:%=%.exe)
$(call PASS, SUCCESS)
-valgrinds:
+valgrinds:
all
$(MAKE) $(addprefix valgrind_,$(ALLEXE))
wipe: purge
$(call TITLE, "Wiping")
touch wipe
$(MAKE) $(addprefix valgrind_,$(ALLEXE))
wipe: purge
$(call TITLE, "Wiping")
touch wipe
- rm -f wipe $(wildcard *.gcda *.gcno *.gcov *.log)
+ rm -f wipe $(wildcard *.gcda *.gcno *.gcov *.
g
log)
$(call PASS, SUCCESS)
tests: all
$(call PASS, SUCCESS)
tests: all
@@
-86,21
+91,22
@@
include $(wildcard *.ld)
gcov_%:
$(MAKE) purge
gcov_%:
$(MAKE) purge
- OPTION
="-fprofile-arcs -ftest
-coverage -O0" $(MAKE)
+ OPTION
S="
-coverage -O0" $(MAKE)
$(MAKE) test_$(@:gcov_%=%)
gcov `sed -e 's/\.exe:/.c/;s/\.o/.c/g' $(@:gcov_%=%.ld)`
touch gcov
rm -f gcov $(wildcard *.gcda *.gcno)
$(MAKE) purge
$(MAKE) test_$(@:gcov_%=%)
gcov `sed -e 's/\.exe:/.c/;s/\.o/.c/g' $(@:gcov_%=%.ld)`
touch gcov
rm -f gcov $(wildcard *.gcda *.gcno)
$(MAKE) purge
+ grep '#####' *.c.gcov || true
gprof_%:
$(MAKE) purge
$(MAKE) depends
gprof_%:
$(MAKE) purge
$(MAKE) depends
- OPTION="-pg" $(MAKE) ${@:gprof_%=%}.exe
+ OPTION
S
="-pg" $(MAKE) ${@:gprof_%=%}.exe
$(MAKE) ${@:gprof_%=%}.test
IFS=$$'\n'; id=1; \
for test in `cat ${@:gprof_%=%}.test | sed 's,${@:gprof_%=%}.exe,./${@:gprof_%=%}.exe,g'`; do \
$(MAKE) ${@:gprof_%=%}.test
IFS=$$'\n'; id=1; \
for test in `cat ${@:gprof_%=%}.test | sed 's,${@:gprof_%=%}.exe,./${@:gprof_%=%}.exe,g'`; do \
- log=${@:gprof_%=%}.prof-$$id.log; \
+ log=${@:gprof_%=%}.prof-$$id.
g
log; \
$(call TITLE, test: $$test); \
echo $$test > $$log; \
eval $$test >> $$log; \
$(call TITLE, test: $$test); \
echo $$test > $$log; \
eval $$test >> $$log; \
@@
-115,45
+121,45
@@
gprof_%:
%.test: %.c
$(call TITLE, "Building $@")
# awk '/\/\* *test:.*\*\// { sub(/^.*\/\* *test: */, ""); sub(/ *\*\/.*$$/, ""); print }' $< > $@
%.test: %.c
$(call TITLE, "Building $@")
# awk '/\/\* *test:.*\*\// { sub(/^.*\/\* *test: */, ""); sub(/ *\*\/.*$$/, ""); print }' $< > $@
-
./
getcomments.pl -p='test:\s' -f='%' $< > $@
+
perl --
getcomments.pl -p='test:\s' -f='%' $< > $@
$(call PASS, SUCCESS)
test_%: %.test %.exe
IFS=$$'\n'; RC=0; \
$(call PASS, SUCCESS)
test_%: %.test %.exe
IFS=$$'\n'; RC=0; \
- for test in `cat $< | sed 's,${<:.test=.exe},./${<:.test=.exe},g'`; do \
+ for test in `cat $< | sed 's,${<:.test=.exe},
$(VALGRIND)
./${<:.test=.exe},g'`; do \
echo "=== $$test ==="; \
echo "=== $$test ==="; \
- eval $
(VALGRIND) $
$test; \
+ eval $$test; \
[ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \
|| { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \
done; \
test "$$RC" -ne 1
valgrind_%: %.exe
[ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \
|| { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \
done; \
test "$$RC" -ne 1
valgrind_%: %.exe
- VALGRIND="valgrind -v --leak-check=full --
show-reachable=yes --log-fd=2
"; \
+ VALGRIND="valgrind -v --leak-check=full --
log-fd=3
"; \
export VALGRIND; \
export VALGRIND; \
- $(MAKE) $(@:valgrind_%=test_%)
+ $(MAKE) $(@:valgrind_%=test_%)
3>$@.log
%.d: %.c
$(call TITLE, "Building $@")
$(CC) $(INCLUDES) -MM $< -o $@~
%.d: %.c
$(call TITLE, "Building $@")
$(CC) $(INCLUDES) -MM $< -o $@~
- echo ${<:.c=.o}: $(shell
./
getcomments.pl -p='depend:\s' -f='%' $<) >> $@~
+ echo ${<:.c=.o}: $(shell
perl --
getcomments.pl -p='depend:\s' -f='%' $<) >> $@~
mv $@~ $@
$(call PASS, SUCCESS)
%.ld: %.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)}') > $@
+ echo ${<:.c=.exe}: $(shell
perl --
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 $@")
$(call PASS, SUCCESS)
%.o: %.c
$(call TITLE, "Building $@")
- $(CC) $(CFLAGS) $(INCLUDES) $(shell
./
getcomments.pl -p='cflags:\s' -f='%' $<) -c $< -o $@
+ $(CC) $(CFLAGS) $(INCLUDES) $(shell
perl --
getcomments.pl -p='cflags:\s' -f='%' $<) -c $< -o $@
$(call PASS, SUCCESS)
%.exe: %.o %.d
$(call TITLE, "Building $@")
$(call PASS, SUCCESS)
%.exe: %.o %.d
$(call TITLE, "Building $@")
- $(CC) $(LDFLAGS) $
(shell ./getcomments.pl -p='linker:\s' -f='%' ${<:.o=.c}) $<
-o $@
+ $(CC) $(LDFLAGS) $
< $(shell perl -- getcomments.pl -p='linker:\s' -f='%' ${<:.o=.c}) $(LDLIBS)
-o $@
$(call PASS, SUCCESS)
## Phony
$(call PASS, SUCCESS)
## Phony