CC=gcc # clang 14.0.3 does implement the C23 feature __VA_OPTS__ but issues a spurious # warning. The -Wno-gnu-zero-variadic-macro-arguments disables this warning. # This flag is ignored by gcc (which implements __VA_OPTS__ without any warning). override CFLAGS += -std=gnu2x -MMD -Wall -pedantic -Wextra -Wshadow -Wpointer-arith \ -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes # For MacOS (assuming recent homebrew) ifeq ($(shell uname -s), Darwin) CPPFLAGS+=-I/opt/homebrew/include LDFLAGS+=-L/opt/homebrew/lib override CFLAGS += -Wno-gnu-zero-variadic-macro-arguments endif SOURCES := $(wildcard *.c) OBJECTS := $(SOURCES:%.c=%.o) DEPS := $(SOURCES:%.c=%.d) # Compilation in debug mode by default, to use gdb and valgrind. Warnings produce an error. all: CFLAGS += -g -O0 -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable all: stackqueue # Once the program works, optimized mode (and no error in case of warning). nowerror: CFLAGS += -O3 nowerror: stackqueue stackqueue: $(OBJECTS) $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ $(LDLIBS) # Include dependancies generated by gcc -MMD. -include $(DEPS) # Clean all. .PHONY: clean clean: rm -rf stackqueue *.o *.d TAGS core a.out