2023-04-30 18:16:13 +02:00
|
|
|
# Makefile to build x48ng without autotools
|
2024-08-12 16:42:43 +02:00
|
|
|
#
|
|
|
|
# The cc-option function and the C{,PP}FLAGS logic were copied from the
|
|
|
|
# fsverity-utils project.
|
|
|
|
# https://git.kernel.org/pub/scm/fs/fsverity/fsverity-utils.git/
|
|
|
|
# The governing license can be found in the LICENSE file or at
|
|
|
|
# https://opensource.org/license/MIT.
|
2024-08-29 13:03:44 +02:00
|
|
|
|
|
|
|
TARGETS = dist/x48ng dist/x48ng-checkrom dist/x48ng-dump2rom
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-10-30 10:33:28 +01:00
|
|
|
PREFIX = /usr
|
|
|
|
DOCDIR = $(PREFIX)/doc/x48ng
|
|
|
|
MANDIR = $(PREFIX)/man
|
|
|
|
|
2024-08-12 16:42:43 +02:00
|
|
|
CFLAGS ?= -g -O2
|
|
|
|
FULL_WARNINGS = no
|
2024-08-16 03:03:37 +02:00
|
|
|
LUA_VERSION ?= lua
|
2024-08-12 17:02:15 +02:00
|
|
|
PKG_CONFIG ?= pkg-config
|
2024-08-12 16:42:43 +02:00
|
|
|
WITH_X11 ?= yes
|
2024-09-04 23:03:49 +02:00
|
|
|
WITH_SDL2 ?= yes
|
|
|
|
WITH_SDL ?= no
|
2024-08-12 16:42:43 +02:00
|
|
|
|
2023-05-04 15:53:39 +02:00
|
|
|
VERSION_MAJOR = 0
|
2024-09-07 21:14:43 +02:00
|
|
|
VERSION_MINOR = 40
|
2024-09-08 15:21:17 +02:00
|
|
|
PATCHLEVEL = 1
|
2023-05-04 15:53:39 +02:00
|
|
|
|
2024-05-21 08:22:37 +02:00
|
|
|
DOTOS = src/emu_serial.o \
|
|
|
|
src/emu_emulate.o \
|
|
|
|
src/emu_init.o \
|
|
|
|
src/emu_keyboard.o \
|
|
|
|
src/emu_memory.o \
|
|
|
|
src/emu_register.o \
|
|
|
|
src/emu_timer.o \
|
|
|
|
src/debugger.o \
|
|
|
|
src/config.o \
|
|
|
|
src/romio.o \
|
|
|
|
src/ui_text.o \
|
|
|
|
src/ui.o \
|
|
|
|
src/main.o
|
|
|
|
|
2023-09-01 21:22:19 +02:00
|
|
|
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
|
|
|
|
|
2024-08-12 16:42:43 +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
|
2023-09-27 16:26:27 +02:00
|
|
|
|
2024-08-12 16:42:43 +02:00
|
|
|
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) \
|
|
|
|
$(CFLAGS)
|
2023-09-13 16:27:59 +02:00
|
|
|
|
2024-08-12 16:56:00 +02:00
|
|
|
override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \
|
|
|
|
-DVERSION_MAJOR=$(VERSION_MAJOR) \
|
|
|
|
-DVERSION_MINOR=$(VERSION_MINOR) \
|
|
|
|
-DPATCHLEVEL=$(PATCHLEVEL) \
|
|
|
|
$(CPPFLAGS)
|
|
|
|
|
2023-05-21 11:31:10 +02:00
|
|
|
LIBS = -lm
|
2023-04-30 16:34:53 +02:00
|
|
|
|
2024-05-21 08:22:37 +02:00
|
|
|
### lua
|
2024-08-16 03:03:37 +02:00
|
|
|
override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags $(LUA_VERSION))
|
|
|
|
LIBS += $(shell "$(PKG_CONFIG)" --libs $(LUA_VERSION))
|
2024-05-21 08:22:37 +02:00
|
|
|
|
|
|
|
### debugger
|
2024-08-12 17:02:15 +02:00
|
|
|
override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags readline)
|
|
|
|
LIBS += $(shell "$(PKG_CONFIG)" --libs readline)
|
2024-05-21 08:22:37 +02:00
|
|
|
|
|
|
|
### Text UI
|
2024-08-12 17:02:15 +02:00
|
|
|
override CFLAGS += $(shell "$(PKG_CONFIG)" --cflags ncursesw) -DNCURSES_WIDECHAR=1
|
|
|
|
LIBS += $(shell "$(PKG_CONFIG)" --libs ncursesw)
|
2024-05-21 08:22:37 +02:00
|
|
|
|
2023-09-27 16:26:27 +02:00
|
|
|
### X11 UI
|
|
|
|
ifeq ($(WITH_X11), yes)
|
2024-08-12 17:02:15 +02:00
|
|
|
X11CFLAGS = $(shell "$(PKG_CONFIG)" --cflags x11 xext) -D_GNU_SOURCE=1
|
|
|
|
X11LIBS = $(shell "$(PKG_CONFIG)" --libs x11 xext)
|
2023-09-28 09:46:29 +02:00
|
|
|
|
2024-08-12 16:42:43 +02:00
|
|
|
override CFLAGS += $(X11CFLAGS) -DHAS_X11=1
|
2024-05-21 08:22:37 +02:00
|
|
|
LIBS += $(X11LIBS)
|
|
|
|
DOTOS += src/ui_x11.o
|
2023-09-27 16:26:27 +02:00
|
|
|
endif
|
|
|
|
|
2024-09-04 15:19:16 +02:00
|
|
|
### SDL2 UI
|
|
|
|
ifeq ($(WITH_SDL2), yes)
|
|
|
|
WITH_SDL = no
|
2024-09-04 16:14:20 +02:00
|
|
|
SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags sdl2 SDL2_gfx)
|
|
|
|
SDLLIBS = $(shell "$(PKG_CONFIG)" --libs sdl2 SDL2_gfx)
|
2024-09-04 15:19:16 +02:00
|
|
|
|
|
|
|
override CFLAGS += $(SDLCFLAGS) -DHAS_SDL2=1
|
|
|
|
LIBS += $(SDLLIBS)
|
|
|
|
DOTOS += src/ui_sdl2.o
|
|
|
|
endif
|
|
|
|
|
2023-09-27 16:26:27 +02:00
|
|
|
### SDL UI
|
|
|
|
ifeq ($(WITH_SDL), yes)
|
2024-08-12 17:02:15 +02:00
|
|
|
SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags SDL_gfx sdl12_compat)
|
|
|
|
SDLLIBS = $(shell "$(PKG_CONFIG)" --libs SDL_gfx sdl12_compat)
|
2023-09-28 09:46:29 +02:00
|
|
|
|
2024-08-12 16:42:43 +02:00
|
|
|
override CFLAGS += $(SDLCFLAGS) -DHAS_SDL=1
|
2024-05-21 08:22:37 +02:00
|
|
|
LIBS += $(SDLLIBS)
|
|
|
|
DOTOS += src/ui_sdl.o
|
2023-09-27 16:26:27 +02:00
|
|
|
endif
|
|
|
|
|
2024-05-21 08:22:37 +02:00
|
|
|
# depfiles = $(objects:.o=.d)
|
|
|
|
|
|
|
|
# # Have the compiler output dependency files with make targets for each
|
|
|
|
# # of the object files. The `MT` option specifies the dependency file
|
|
|
|
# # itself as a target, so that it's regenerated when it should be.
|
|
|
|
# %.dep.mk: %.c
|
|
|
|
# $(CC) -M -MP -MT '$(<:.c=.o) $@' $(CPPFLAGS) $< > $@
|
|
|
|
|
|
|
|
# # Include each of those dependency files; Make will run the rule above
|
|
|
|
# # to generate each dependency file (if it needs to).
|
|
|
|
# -include $(depfiles)
|
2023-09-27 16:26:27 +02:00
|
|
|
|
2023-10-04 09:33:52 +02:00
|
|
|
.PHONY: all clean clean-all pretty-code install mrproper
|
2023-04-30 18:16:13 +02:00
|
|
|
|
2024-08-12 16:56:00 +02:00
|
|
|
all: $(TARGETS)
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2024-08-29 11:14:24 +02:00
|
|
|
dist/x48ng-dump2rom: src/legacy_tools/dump2rom.o
|
|
|
|
dist/x48ng-checkrom: src/legacy_tools/checkrom.o src/romio.o
|
2023-05-18 23:11:40 +02:00
|
|
|
dist/x48ng: $(DOTOS)
|
2024-08-12 16:56:00 +02:00
|
|
|
|
|
|
|
# Binaries
|
|
|
|
$(TARGETS):
|
2024-08-12 16:57:52 +02:00
|
|
|
$(CC) $^ -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS)
|
2023-04-26 16:42:55 +02:00
|
|
|
|
|
|
|
# Cleaning
|
|
|
|
clean:
|
2024-08-29 11:14:24 +02:00
|
|
|
rm -f src/*.o src/legacy_tools/*.o src/*.dep.mk src/legacy_tools/*.dep.mk
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-09-06 16:32:56 +02:00
|
|
|
mrproper: clean
|
2024-08-12 16:56:00 +02:00
|
|
|
rm -f $(TARGETS)
|
2024-08-11 13:44:40 +02:00
|
|
|
make -C dist/ROMs mrproper
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-09-06 16:32:56 +02:00
|
|
|
clean-all: mrproper
|
|
|
|
|
2023-04-26 16:42:55 +02:00
|
|
|
# Formatting
|
|
|
|
pretty-code:
|
2024-08-29 11:14:24 +02:00
|
|
|
clang-format -i src/*.c src/*.h src/legacy_tools/*.c
|
2023-04-26 19:46:45 +02:00
|
|
|
|
|
|
|
# Installing
|
2024-04-02 16:59:36 +02:00
|
|
|
get-roms:
|
|
|
|
make -C dist/ROMs
|
2023-10-30 10:33:28 +01:00
|
|
|
|
2024-04-11 21:14:15 +02:00
|
|
|
dist/config.lua: dist/x48ng
|
|
|
|
$^ --print-config > $@
|
|
|
|
|
2024-08-11 13:44:40 +02:00
|
|
|
install: all dist/config.lua
|
2023-04-26 19:46:45 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin
|
2023-05-10 15:50:51 +02:00
|
|
|
install -c -m 755 dist/x48ng $(DESTDIR)$(PREFIX)/bin/x48ng
|
2023-04-30 18:16:13 +02:00
|
|
|
|
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/x48ng
|
2023-05-10 15:50:51 +02:00
|
|
|
install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/x48ng/hplogo.png
|
|
|
|
cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/x48ng/
|
2024-08-29 11:04:01 +02:00
|
|
|
install -c -m 755 dist/setup-x48ng-home.sh $(DESTDIR)$(PREFIX)/share/x48ng/setup-x48ng-home.sh
|
2023-04-30 18:16:13 +02:00
|
|
|
chmod 755 $(DESTDIR)$(PREFIX)/share/x48ng/setup-x48ng-home.sh
|
|
|
|
|
2024-08-29 11:14:24 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/libexec
|
|
|
|
install -c -m 755 dist/x48ng-dump2rom $(DESTDIR)$(PREFIX)/libexec/x48ng-dump2rom
|
|
|
|
install -c -m 755 dist/x48ng-checkrom $(DESTDIR)$(PREFIX)/libexec/x48ng-checkrom
|
|
|
|
|
2023-04-30 18:16:13 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(MANDIR)/man1
|
2023-05-10 15:50:51 +02:00
|
|
|
sed "s|@VERSION@|$(VERSION_MAJOR).$(VERSION_MINOR).$(PATCHLEVEL)|g" dist/x48ng.man.1 > $(DESTDIR)$(MANDIR)/man1/x48ng.1
|
2023-04-26 22:49:47 +02:00
|
|
|
|
2023-04-26 19:46:45 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(DOCDIR)
|
2023-10-01 13:17:57 +02:00
|
|
|
cp -R AUTHORS LICENSE README* doc* romdump/ $(DESTDIR)$(DOCDIR)
|
|
|
|
install -c -m 644 dist/config.lua $(DESTDIR)$(DOCDIR)/config.lua
|
2023-04-26 19:46:45 +02:00
|
|
|
|
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications
|
2023-05-10 15:50:51 +02:00
|
|
|
sed "s|@PREFIX@|$(PREFIX)|g" dist/x48ng.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48ng.desktop
|