2026-10-31 22:27:55 -04:00
|
|
|
CC=clang
|
2026-10-20 22:48:22 -04:00
|
|
|
DEBUG=yes
|
|
|
|
|
EXEC=test
|
|
|
|
|
|
|
|
|
|
# all c files in this directory
|
|
|
|
|
SRC = $(wildcard *.c)
|
|
|
|
|
# otherwise
|
|
|
|
|
#SRC = $(wildcard src_dir1/*.c) \
|
|
|
|
|
# $(wildcard src_dir2/*.c)
|
|
|
|
|
|
|
|
|
|
# -g for debug
|
|
|
|
|
# -Wall to get all the possible warnings
|
|
|
|
|
# -ansi -pendantic to get portable code
|
|
|
|
|
ifeq ($(DEBUG),yes)
|
2026-10-31 22:27:55 -04:00
|
|
|
CFLAGS=-Wall -Wpedantic -g3 -Wextra -Wconversion -Wshadow -fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
2026-10-22 23:04:56 -04:00
|
|
|
LDFLAGS= -Wall -lm -fsanitize=address,undefined
|
2026-10-20 22:48:22 -04:00
|
|
|
else
|
2026-10-22 23:04:56 -04:00
|
|
|
CFLAGS=-W -Wall -pedantic -std=c23 -O3
|
2026-10-20 22:48:22 -04:00
|
|
|
LDFLAGS= -Wall -lm
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
###############################################
|
|
|
|
|
# end of the configuration
|
|
|
|
|
###############################################
|
|
|
|
|
|
|
|
|
|
all: $(EXEC)
|
|
|
|
|
|
|
|
|
|
obj = $(SRC:.c=.o)
|
|
|
|
|
dep = $(obj:.o=.d)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(EXEC): $(obj)
|
|
|
|
|
$(CC) -o $@ $^ $(LDFLAGS)
|
|
|
|
|
|
|
|
|
|
.PHONY: tests
|
|
|
|
|
tests: $(EXEC)
|
|
|
|
|
./test
|
|
|
|
|
|
|
|
|
|
-include $(dep)
|
|
|
|
|
|
|
|
|
|
%.d: %.c
|
|
|
|
|
@$(CC) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
|
|
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
clean:
|
|
|
|
|
rm -f $(obj) $(EXEC) $(dep)
|