42 lines
1.2 KiB
Makefile
42 lines
1.2 KiB
Makefile
# CC=gcc or clang or gcc-14 (on OSX)
|
|
CC=gcc
|
|
|
|
# Math, big numbers and SDL2 fonts
|
|
# LDLIBS=
|
|
|
|
# clang 14.x.x on Darwin does implement the C23 feature __VA_OPTS__ but issues
|
|
# a spurious warning. The -Wno-gnu-zero-variadic-macro-arguments disables it.
|
|
# 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 # -Wno-gnu-zero-variadic-macro-arguments
|
|
|
|
# For MacOS (assuming recent homebrew)
|
|
ifeq ($(shell uname -s), Darwin)
|
|
CPPFLAGS+=-I/opt/homebrew/include
|
|
LDFLAGS+=-L/opt/homebrew/lib
|
|
endif
|
|
|
|
SOURCES := $(wildcard *.c)
|
|
OBJECTS := $(SOURCES:%.c=%.o)
|
|
DEPS := $(SOURCES:%.c=%.d)
|
|
|
|
# Compilation in debug mode by default, to use gdb and valgrind.
|
|
all: CFLAGS += -g -O0 -Werror -Wno-unused-parameter
|
|
all: mysort
|
|
|
|
# Once the program works, optimized mode (and no error in case of warning).
|
|
nowerror: CFLAGS += -O3
|
|
nowerror: mysort
|
|
|
|
# Add parser.o scan.o if bison/flex interface.
|
|
mysort: $(OBJECTS)
|
|
$(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ $(LDLIBS)
|
|
|
|
# Include dependancies generated by gcc -MMD.
|
|
-include $(DEPS)
|
|
|
|
# Clean all.
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f mysort *.o *.d TAGS core
|