50 lines
1.7 KiB
Makefile
50 lines
1.7 KiB
Makefile
# CC=gcc or clang or gcc-14 (on OSX)
|
|
CC=gcc
|
|
|
|
# Math, big numbers and SDL2 fonts
|
|
LDLIBS=-lm
|
|
|
|
# The DEBUG_LEVEL (OFF, CRITICAL, ERROR, WARNING, INFO, TRACE)
|
|
# is set by default to WARNING in error.h.
|
|
# To set it on the command line, force compilation and set it.
|
|
# Example: make -B CFLAGS="-DDEBUG_LEVEL=INFO" to see all debug messages
|
|
# above the 'INFO' level.
|
|
|
|
# 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).
|
|
ifeq ($(shell uname -s), Darwin)
|
|
override CFLAGS += -std=gnu2x -MMD -Wall -pedantic -Wextra -Wshadow -Wpointer-arith \
|
|
-Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wno-gnu-zero-variadic-macro-arguments
|
|
endif
|
|
|
|
ifeq ($(shell uname -s), Linux)
|
|
override CFLAGS += -std=gnu2x -MMD -Wall -pedantic -Wextra -Wshadow -Wpointer-arith \
|
|
-Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
|
|
endif
|
|
|
|
SOURCES := $(wildcard *.c)
|
|
OBJECTS := $(SOURCES:%.c=%.o)
|
|
DEPS := $(SOURCES:%.c=%.d)
|
|
OBJECTS_NO_SOURCE = dequeue.o
|
|
|
|
# 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
|
|
all: tp
|
|
|
|
# Once the program works, optimized mode (and no error in case of warning).
|
|
nowerror: CFLAGS += -O3 -Wunused-parameter
|
|
nowerror: tp
|
|
|
|
# Add parser.o scan.o if bison/flex interface.
|
|
tp: $(OBJECTS) $(OBJECTS_NO_SOURCE)
|
|
$(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ $(LDLIBS)
|
|
|
|
# Include dependancies generated by gcc -MMD.
|
|
-include $(DEPS)
|
|
|
|
# Clean all.
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f $(OBJECTS) $(DEPS) tp TAGS core
|