Soft'N'Design Software
/
projects
/
scrabble.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
76589e6
)
generic makefile
master
author
Laurent Mazet
<mazet@softndesign.org>
Sun, 13 Apr 2025 11:35:41 +0000
(13:35 +0200)
committer
Laurent Mazet
<mazet@softndesign.org>
Sun, 13 Apr 2025 11:35:41 +0000
(13:35 +0200)
makefile
patch
|
blob
|
blame
|
history
diff --git
a/makefile
b/makefile
index dcc3a3b5ae40255a300c0659dd3c405fe35c9767..09ecb8bc309abe5c9bba31812b7dfecc3743bcb9 100644
(file)
--- a/
makefile
+++ b/
makefile
@@
-5,6
+5,7
@@
CC = gcc
#INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
INCLUDES =
OFLAGS = -O4 -Os
#INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
INCLUDES =
OFLAGS = -O4 -Os
+#OFLAGS = -O0
#OFLAGS = -O4 -ffast-math -finline-functions
#OFLAGS = -O4 -finline-functions
#OFLAGS += -mtune=pentium3 -mmmx -msse -msse2 -m3dnow
#OFLAGS = -O4 -ffast-math -finline-functions
#OFLAGS = -O4 -finline-functions
#OFLAGS += -mtune=pentium3 -mmmx -msse -msse2 -m3dnow
@@
-13,21
+14,30
@@
OFLAGS = -O4 -Os
CFLAGS += -W -Wall -Wextra -g
#CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
CFLAGS += $(OFLAGS) $(INCLUDES) $(OPTIONS)
CFLAGS += -W -Wall -Wextra -g
#CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
CFLAGS += $(OFLAGS) $(INCLUDES) $(OPTIONS)
-LDFLAGS += -g $(OPTIONS)
+LDFLAGS += -g $(
LDOPTS) $(
OPTIONS)
LDOPT = linker
LDOPT = linker
-ifeq ($(OS),Windows_NT)
+MV = mv
+ifneq (, $(findstring linux, $(MAKE_HOST)))
+# Linux
+else ifneq (, $(findstring mingw, $(MAKE_HOST)))
+# Windows MinGw
+CFLAGS += -DWIN32
#LDLIBS += -lws2_32
LDOPT = winlnk
#LDLIBS += -lws2_32
LDOPT = winlnk
-endif
-ifeq ($(OS),Dos)
+else ifneq (, $(findstring cygwin, $(MAKE_HOST)))
+CFLAGS += -DWIN32
+# Windows CygWin
+LDOPT = winlnk
+else ifneq (, $(findstring msdos, $(MAKE_HOST)))
+# MSDOS
LDOPT = doslnk
LDOPT = doslnk
+MV = move
endif
# Targets
endif
# Targets
-ALLEXE =
-ALLEXE += scrabble
+ALLEXE = $(shell for f in *.c; do grep -q '/\*\slinker:' $$f && echo $${f/.c}; done)
SHELL = bash
SHELL = bash
@@
-59,6
+69,7
@@
all: depends
analyze:
make purge
scan-build make
analyze:
make purge
scan-build make
+ #scan-build -stats make
count:
wc $(wildcard *.c *.h) $(MAKEFILE_LIST)
count:
wc $(wildcard *.c *.h) $(MAKEFILE_LIST)
@@
-66,7
+77,7
@@
count:
clean:
$(call TITLE, "Cleaning")
touch clean
clean:
$(call TITLE, "Cleaning")
touch clean
- rm -f clean $(wildcard *.d *.ld *.log *.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))
@@
-83,7
+94,8
@@
purge: clean
rm -f purge $(ALLEXE:%=%.exe)
$(call PASS, SUCCESS)
rm -f purge $(ALLEXE:%=%.exe)
$(call PASS, SUCCESS)
-valgrinds: all
+valgrinds:
+ $(MAKE) all
$(MAKE) $(addprefix valgrind_,$(ALLEXE))
wipe: purge
$(MAKE) $(addprefix valgrind_,$(ALLEXE))
wipe: purge
@@
-92,7
+104,9
@@
wipe: purge
rm -f wipe $(wildcard *.gcda *.gcno *.gcov *.glog)
$(call PASS, SUCCESS)
rm -f wipe $(wildcard *.gcda *.gcno *.gcov *.glog)
$(call PASS, SUCCESS)
-tests: all
+tests:
+ -rm -f $(ALLEXE)
+ $(MAKE) all
$(MAKE) $(addprefix test_,$(ALLEXE))
## Main rules
$(MAKE) $(addprefix test_,$(ALLEXE))
## Main rules
@@
-102,13
+116,14
@@
include $(wildcard *.ld)
gcov_%:
$(MAKE) purge
gcov_%:
$(MAKE) purge
- OPTIONS="-coverage -O0" $(MAKE)
+ $(MAKE) depends
+ OPTIONS="-coverage -O0" $(MAKE) ${@:gcov_%=%}.exe
$(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
+ grep '
^ *
#####' *.c.gcov || true
gprof_%:
$(MAKE) purge
gprof_%:
$(MAKE) purge
@@
-133,6
+148,7
@@
gprof_%:
$(call TITLE, "Building $@")
$(call GETCOMMENTS,test, $<) > $@
$(call PASS, SUCCESS)
$(call TITLE, "Building $@")
$(call GETCOMMENTS,test, $<) > $@
$(call PASS, SUCCESS)
+ -rm -f _
test_%: %.test %.exe
IFS=$$'\n'; RC=0; \
test_%: %.test %.exe
IFS=$$'\n'; RC=0; \
@@
-141,6
+157,7
@@
test_%: %.test %.exe
eval $$test; \
[ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \
|| { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \
eval $$test; \
[ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \
|| { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \
+ test "$$RC" = 1 -a "$(STOP)" = 1 && break; \
done; \
test "$$RC" -ne 1
done; \
test "$$RC" -ne 1
@@
-153,7
+170,7
@@
valgrind_%: %.exe
$(call TITLE, "Building $@")
$(CC) $(INCLUDES) -MM $< -o $@~
echo ${<:.c=.o}: $(shell $(call GETCOMMENTS,depends, $<)) >> $@~
$(call TITLE, "Building $@")
$(CC) $(INCLUDES) -MM $< -o $@~
echo ${<:.c=.o}: $(shell $(call GETCOMMENTS,depends, $<)) >> $@~
-
mv
$@~ $@
+
$(MV)
$@~ $@
$(call PASS, SUCCESS)
%.ld: %.c
$(call PASS, SUCCESS)
%.ld: %.c