2023-04-30 18:16:13 +02:00
|
|
|
# Makefile to build x48ng without autotools
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-05-19 09:15:10 +02:00
|
|
|
# possible values: x11, sdl1
|
2023-06-05 18:34:06 +02:00
|
|
|
GUI ?= x11
|
2023-05-19 09:15:10 +02:00
|
|
|
|
|
|
|
# possible values: yes, no
|
2023-06-05 18:34:06 +02:00
|
|
|
WITH_DEBUGGER ?= yes
|
2023-05-19 09:15:10 +02:00
|
|
|
|
2023-05-04 15:53:39 +02:00
|
|
|
VERSION_MAJOR = 0
|
2023-05-20 09:06:14 +02:00
|
|
|
VERSION_MINOR = 12
|
2023-06-17 08:08:56 +02:00
|
|
|
PATCHLEVEL = 1
|
2023-05-04 15:53:39 +02:00
|
|
|
COMPILE_VERSION = 0
|
|
|
|
|
2023-04-26 16:42:55 +02:00
|
|
|
CC = gcc
|
|
|
|
|
2023-05-09 16:50:01 +02:00
|
|
|
CFLAGS = -g -O2 -I./src/ -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DPATCHLEVEL=$(PATCHLEVEL) -DCOMPILE_VERSION=$(COMPILE_VERSION)
|
2023-05-21 11:31:10 +02:00
|
|
|
LIBS = -lm
|
2023-04-30 16:34:53 +02:00
|
|
|
|
2023-04-30 18:16:13 +02:00
|
|
|
ifeq ($(GUI), x11)
|
2023-05-21 11:31:10 +02:00
|
|
|
CFLAGS += $(shell pkg-config --cflags x11 xext) -D_GNU_SOURCE=1 -DGUI_IS_X11=1
|
|
|
|
LIBS += $(shell pkg-config --libs x11 xext)
|
2023-04-30 16:34:53 +02:00
|
|
|
endif
|
2023-04-30 18:16:13 +02:00
|
|
|
ifeq ($(GUI), sdl1)
|
2023-05-21 11:31:10 +02:00
|
|
|
CFLAGS += $(shell pkg-config --cflags SDL_gfx sdl12_compat) -DGUI_IS_SDL1=1
|
|
|
|
LIBS += $(shell pkg-config --libs SDL_gfx sdl12_compat)
|
2023-04-30 16:34:53 +02:00
|
|
|
endif
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-04-30 18:16:13 +02:00
|
|
|
FULL_WARNINGS = no
|
|
|
|
ifeq ($(FULL_WARNINGS), yes)
|
2023-05-03 13:31:51 +02:00
|
|
|
CFLAGS += -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-unused-function -Wconversion -Wdouble-promotion -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap
|
2023-04-30 18:16:13 +02:00
|
|
|
endif
|
|
|
|
|
2023-05-18 23:11:40 +02:00
|
|
|
DOTOS = src/main.o \
|
|
|
|
src/hp48_device.o \
|
|
|
|
src/hp48_emulate.o \
|
|
|
|
src/hp48_init.o \
|
|
|
|
src/hp48_serial.o \
|
|
|
|
src/hp48emu_actions.o \
|
|
|
|
src/hp48emu_memory.o \
|
|
|
|
src/hp48emu_register.o \
|
|
|
|
src/romio.o \
|
|
|
|
src/timer.o \
|
|
|
|
src/x48_errors.o \
|
|
|
|
src/x48_resources.o \
|
|
|
|
src/x48.o
|
|
|
|
|
|
|
|
ifeq ($(WITH_DEBUGGER), yes)
|
|
|
|
DOTOS += src/x48_debugger.o \
|
|
|
|
src/x48_debugger_disasm.o \
|
|
|
|
src/x48_debugger_rpl.o
|
2023-05-21 11:31:10 +02:00
|
|
|
CFLAGS += $(shell pkg-config --cflags readline) -DWITH_DEBUGGER=1
|
2023-06-02 22:30:55 +02:00
|
|
|
LIBS += $(shell pkg-config --libs readline)
|
2023-05-18 23:11:40 +02:00
|
|
|
endif
|
|
|
|
|
2023-04-30 18:16:13 +02:00
|
|
|
.PHONY: all clean clean-all pretty-code install
|
|
|
|
|
2023-05-10 15:50:51 +02:00
|
|
|
all: dist/mkcard dist/checkrom dist/dump2rom dist/x48ng
|
2023-04-26 16:42:55 +02:00
|
|
|
|
|
|
|
# Binaries
|
2023-05-10 15:50:51 +02:00
|
|
|
dist/mkcard: src/tools/mkcard.o
|
2023-06-02 22:05:56 +02:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) $(LIBS)
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-05-10 15:50:51 +02:00
|
|
|
dist/dump2rom: src/tools/dump2rom.o
|
2023-06-02 22:05:56 +02:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) $(LIBS)
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-05-10 15:50:51 +02:00
|
|
|
dist/checkrom: src/tools/checkrom.o src/romio.o
|
2023-06-02 22:05:56 +02:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) $(LIBS)
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-05-18 23:11:40 +02:00
|
|
|
dist/x48ng: $(DOTOS)
|
2023-06-02 22:05:56 +02:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) $(LIBS)
|
2023-04-26 16:42:55 +02:00
|
|
|
|
|
|
|
# Cleaning
|
|
|
|
clean:
|
2023-05-09 16:50:01 +02:00
|
|
|
rm -f src/*.o src/tools/*.o
|
2023-04-26 16:42:55 +02:00
|
|
|
|
|
|
|
clean-all: clean
|
2023-05-10 15:50:51 +02:00
|
|
|
rm -f dist/mkcard dist/checkrom dist/dump2rom dist/x48ng
|
2023-04-26 16:42:55 +02:00
|
|
|
|
|
|
|
# Formatting
|
|
|
|
pretty-code:
|
2023-04-26 16:48:46 +02:00
|
|
|
clang-format -i src/*.c src/*.h
|
2023-04-26 19:46:45 +02:00
|
|
|
|
|
|
|
# Installing
|
|
|
|
PREFIX = /usr
|
2023-04-30 18:16:13 +02:00
|
|
|
DOCDIR = $(PREFIX)/doc/x48ng
|
|
|
|
MANDIR = $(PREFIX)/man
|
2023-04-26 19:46:45 +02:00
|
|
|
install: all
|
|
|
|
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 755 dist/mkcard $(DESTDIR)$(PREFIX)/share/x48ng/mkcard
|
|
|
|
install -c -m 755 dist/dump2rom $(DESTDIR)$(PREFIX)/share/x48ng/dump2rom
|
|
|
|
install -c -m 755 dist/checkrom $(DESTDIR)$(PREFIX)/share/x48ng/checkrom
|
|
|
|
install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/x48ng/hplogo.png
|
|
|
|
cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/x48ng/
|
2023-04-30 18:16:13 +02:00
|
|
|
find $(DESTDIR)$(PREFIX)/share/x48ng/ROMs/ -name "*.bz2" -exec bunzip2 {} \;
|
2023-05-10 15:50:51 +02:00
|
|
|
sed "s|@PREFIX@|$(PREFIX)|g" 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
|
|
|
|
|
|
|
|
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-30 18:16:13 +02:00
|
|
|
gzip -9 $(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-05-10 15:39:24 +02:00
|
|
|
cp -R AUTHORS LICENSE README* doc* romdump/ $(DESTDIR)$(DOCDIR)
|
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
|
2023-04-26 22:49:47 +02:00
|
|
|
|
2023-04-30 18:16:13 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)/etc/X11/app-defaults
|
2023-05-10 15:50:51 +02:00
|
|
|
install -c -m 644 dist/X48NG.ad $(DESTDIR)/etc/X11/app-defaults/X48NG
|