# Makefile TARGETS = ui4x VERSION_MAJOR = 0 VERSION_MINOR = 0 PATCHLEVEL = 0 PKG_CONFIG ?= pkg-config MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES) 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 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) ui4x: $(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