From 5180b703b474bad563b32b76530b69792d4dbb22 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Sun, 13 Apr 2025 14:08:45 +0200 Subject: [PATCH] generic makefile --- makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/makefile b/makefile index 2f126ba..09ecb8b 100644 --- a/makefile +++ b/makefile @@ -5,6 +5,7 @@ CC = gcc #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 @@ -21,9 +22,11 @@ ifneq (, $(findstring linux, $(MAKE_HOST))) # Linux else ifneq (, $(findstring mingw, $(MAKE_HOST))) # Windows MinGw +CFLAGS += -DWIN32 #LDLIBS += -lws2_32 LDOPT = winlnk else ifneq (, $(findstring cygwin, $(MAKE_HOST))) +CFLAGS += -DWIN32 # Windows CygWin LDOPT = winlnk else ifneq (, $(findstring msdos, $(MAKE_HOST))) @@ -34,8 +37,7 @@ endif # Targets -ALLEXE = -ALLEXE += tetris +ALLEXE = $(shell for f in *.c; do grep -q '/\*\slinker:' $$f && echo $${f/.c}; done) SHELL = bash @@ -64,6 +66,11 @@ GETCOMMENTS = awk '/\/\*\s*$(1):/,/\*\// { sub(/.*\/\*\s*$(1):/, ""); sub (/\s*\ all: depends $(MAKE) $(ALLEXE:%=%.exe) +analyze: + make purge + scan-build make + #scan-build -stats make + count: wc $(wildcard *.c *.h) $(MAKEFILE_LIST) @@ -116,7 +123,7 @@ gcov_%: touch gcov rm -f gcov $(wildcard *.gcda *.gcno) $(MAKE) purge - grep '#####' *.c.gcov || true + grep '^ *#####' *.c.gcov || true gprof_%: $(MAKE) purge @@ -150,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; }; \ + test "$$RC" = 1 -a "$(STOP)" = 1 && break; \ done; \ test "$$RC" -ne 1 @@ -183,7 +191,7 @@ valgrind_%: %.exe ## Phony -.PHONY: all clean count depends gcovs purge tests +.PHONY: all analyze clean count depends gcovs purge tests ## Precious -- 2.30.2