2024-09-12 01:00:29 +02:00
|
|
|
# Makefile
|
|
|
|
|
2024-09-25 10:29:29 +02:00
|
|
|
TARGETS = ui4x
|
2024-09-12 15:15:10 +02:00
|
|
|
VERSION_MAJOR = 0
|
|
|
|
VERSION_MINOR = 0
|
|
|
|
PATCHLEVEL = 0
|
2024-09-12 01:00:29 +02:00
|
|
|
|
|
|
|
PKG_CONFIG ?= pkg-config
|
|
|
|
|
|
|
|
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
|
|
|
|
|
2024-09-25 10:29:29 +02:00
|
|
|
DOTOS = src/ui4x_config.o \
|
|
|
|
src/ui4x_emulator.o \
|
|
|
|
src/ui4x_sdl2.o \
|
|
|
|
src/ui4x_ncurses.o \
|
|
|
|
src/ui4x_common.o \
|
|
|
|
src/ui4x_main.o
|
2024-09-12 01:00:29 +02:00
|
|
|
|
|
|
|
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) \
|
2024-09-12 15:05:48 +02:00
|
|
|
$(shell "$(PKG_CONFIG)" --cflags ncursesw) -DNCURSES_WIDECHAR=1 \
|
2024-09-12 01:00:29 +02:00
|
|
|
$(CFLAGS)
|
|
|
|
|
|
|
|
override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \
|
|
|
|
-DVERSION_MAJOR=$(VERSION_MAJOR) \
|
|
|
|
-DVERSION_MINOR=$(VERSION_MINOR) \
|
|
|
|
-DPATCHLEVEL=$(PATCHLEVEL) \
|
|
|
|
$(CPPFLAGS)
|
|
|
|
|
2024-09-12 15:05:48 +02:00
|
|
|
LIBS = -lm \
|
|
|
|
$(shell "$(PKG_CONFIG)" --libs sdl2) \
|
|
|
|
$(shell "$(PKG_CONFIG)" --libs ncursesw)
|
2024-09-12 01:00:29 +02:00
|
|
|
|
|
|
|
.PHONY: all clean clean-all pretty-code install mrproper
|
|
|
|
|
|
|
|
all: $(TARGETS)
|
|
|
|
|
2024-09-25 10:29:29 +02:00
|
|
|
ui4x: $(DOTOS)
|
2024-09-12 01:00:29 +02:00
|
|
|
|
|
|
|
# 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
|