# Makefile TARGETS = hp48-sdl2 PKG_CONFIG ?= pkg-config MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES) DOTOS = src/ui.o \ src/config.o \ src/emulator.o \ src/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) \ $(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) # SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags sdl2) # SDLLIBS = $(shell "$(PKG_CONFIG)" --libs sdl2) # override CFLAGS += $(SDLCFLAGS) -DHAS_SDL2=1 # LIBS += $(SDLLIBS) .PHONY: all clean clean-all pretty-code install mrproper all: $(TARGETS) hp48-sdl2: $(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