ui4x/Makefile
2024-09-25 10:15:21 +02:00

88 lines
2 KiB
Makefile

# Makefile
TARGETS = ui48
VERSION_MAJOR = 0
VERSION_MINOR = 0
PATCHLEVEL = 0
PKG_CONFIG ?= pkg-config
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
DOTOS = src/ui48_config.o \
src/ui48_emulator.o \
src/ui48_sdl2.o \
src/ui48_ncurses.o \
src/ui48_common.o \
src/ui48_main.o
cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null > /dev/null 2>&1; \
then echo $(1); fi)
ifeq ($(FULL_WARNINGS), no)
EXTRA_WARNING_FLAGS := -Wno-unused-function \
-Wno-redundant-decls \
$(call cc-option,-Wno-maybe-uninitialized) \
$(call cc-option,-Wno-discarded-qualifiers) \
$(call cc-option,-Wno-uninitialized) \
$(call cc-option,-Wno-ignored-qualifiers)
endif
ifeq ($(FULL_WARNINGS), yes)
EXTRA_WARNING_FLAGS := -Wunused-function \
-Wredundant-decls \
-fsanitize-trap \
$(call cc-option,-Wunused-variable)
endif
override CFLAGS := -std=c11 \
-Wall -Wextra -Wpedantic \
-Wformat=2 -Wshadow \
-Wwrite-strings -Wstrict-prototypes -Wold-style-definition \
-Wnested-externs -Wmissing-include-dirs \
-Wdouble-promotion \
-Wno-sign-conversion \
-Wno-unused-variable \
-Wno-unused-parameter \
-Wno-conversion \
-Wno-format-nonliteral \
$(call cc-option,-Wjump-misses-init) \
$(call cc-option,-Wlogical-op) \
$(call cc-option,-Wno-unknown-warning-option) \
$(EXTRA_WARNING_FLAGS) \
$(shell "$(PKG_CONFIG)" --cflags sdl2) \
$(shell "$(PKG_CONFIG)" --cflags ncursesw) -DNCURSES_WIDECHAR=1 \
$(CFLAGS)
override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \
-DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DPATCHLEVEL=$(PATCHLEVEL) \
$(CPPFLAGS)
LIBS = -lm \
$(shell "$(PKG_CONFIG)" --libs sdl2) \
$(shell "$(PKG_CONFIG)" --libs ncursesw)
.PHONY: all clean clean-all pretty-code install mrproper
all: $(TARGETS)
ui48: $(DOTOS)
# Binaries
$(TARGETS):
$(CC) $^ -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS)
# Cleaning
clean:
rm -f src/*.o
mrproper: clean
rm -f $(TARGETS)
clean-all: mrproper
# Formatting
pretty-code:
clang-format -i src/*.c src/*.h