2023-04-30 18:16:13 +02:00
|
|
|
# Makefile to build x48ng without autotools
|
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
|
|
|
|
|
2023-05-04 15:53:39 +02:00
|
|
|
VERSION_MAJOR = 0
|
2023-10-22 18:31:58 +02:00
|
|
|
VERSION_MINOR = 33
|
2023-10-19 11:14:16 +02:00
|
|
|
PATCHLEVEL = 0
|
2023-05-04 15:53:39 +02:00
|
|
|
|
2023-09-01 21:22:19 +02:00
|
|
|
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
|
|
|
|
|
2023-09-26 11:28:15 +02:00
|
|
|
CC ?= gcc
|
2023-04-26 16:42:55 +02:00
|
|
|
|
2023-09-27 16:26:27 +02:00
|
|
|
WITH_X11 ?= yes
|
|
|
|
WITH_SDL ?= yes
|
|
|
|
|
2023-09-13 16:27:59 +02:00
|
|
|
OPTIM ?= 2
|
|
|
|
|
|
|
|
CFLAGS = -g -O$(OPTIM) -I./src/ -D_GNU_SOURCE=1 -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DPATCHLEVEL=$(PATCHLEVEL)
|
2023-05-21 11:31:10 +02:00
|
|
|
LIBS = -lm
|
2023-04-30 16:34:53 +02:00
|
|
|
|
2023-09-30 10:52:40 +02:00
|
|
|
### lua
|
|
|
|
CFLAGS += $(shell pkg-config --cflags lua)
|
|
|
|
LIBS += $(shell pkg-config --libs lua)
|
|
|
|
|
2023-09-19 14:03:41 +02:00
|
|
|
### debugger
|
|
|
|
CFLAGS += $(shell pkg-config --cflags readline)
|
|
|
|
LIBS += $(shell pkg-config --libs readline)
|
|
|
|
|
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-10-22 18:28:43 +02:00
|
|
|
DONT_SHADOW_SHIFTS = no
|
|
|
|
ifeq ($(DONT_SHADOW_SHIFTS), yes)
|
|
|
|
CFLAGS += -DDONT_SHADOW_SHIFTS=1
|
|
|
|
endif
|
|
|
|
|
2023-09-15 17:42:29 +02:00
|
|
|
DOTOS = src/emu_serial.o \
|
|
|
|
src/emu_emulate.o \
|
|
|
|
src/emu_init.o \
|
|
|
|
src/emu_actions.o \
|
|
|
|
src/emu_memory.o \
|
|
|
|
src/emu_register.o \
|
|
|
|
src/emu_timer.o \
|
2023-09-19 14:03:41 +02:00
|
|
|
src/debugger.o \
|
2023-09-16 09:18:51 +02:00
|
|
|
src/runtime_options.o \
|
2023-05-18 23:11:40 +02:00
|
|
|
src/romio.o \
|
2023-09-19 19:21:55 +02:00
|
|
|
src/ui_text.o \
|
2023-09-18 15:25:35 +02:00
|
|
|
src/ui.o \
|
2023-09-15 17:42:29 +02:00
|
|
|
src/main.o
|
2023-05-18 23:11:40 +02:00
|
|
|
|
2023-09-27 16:26:27 +02:00
|
|
|
### X11 UI
|
|
|
|
ifeq ($(WITH_X11), yes)
|
2023-09-28 09:46:29 +02:00
|
|
|
X11CFLAGS = $(shell pkg-config --cflags x11 xext) -D_GNU_SOURCE=1
|
|
|
|
X11LIBS = $(shell pkg-config --libs x11 xext)
|
|
|
|
|
|
|
|
CFLAGS += $(X11CFLAGS) -DHAS_X11=1
|
|
|
|
LIBS += $(X11LIBS)
|
|
|
|
DOTOS += src/ui_x11.o
|
2023-09-27 16:26:27 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
### SDL UI
|
|
|
|
ifeq ($(WITH_SDL), yes)
|
|
|
|
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
|
|
|
|
|
|
|
CFLAGS += $(SDLCFLAGS) -DHAS_SDL=1
|
|
|
|
LIBS += $(SDLLIBS)
|
|
|
|
DOTOS += src/ui_sdl.o
|
2023-09-27 16:26:27 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
### Text UI
|
|
|
|
CFLAGS += $(shell pkg-config --cflags ncursesw) -DNCURSES_WIDECHAR=1
|
|
|
|
LIBS += $(shell pkg-config --libs ncursesw)
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2023-09-06 16:32:56 +02:00
|
|
|
mrproper: 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
|
|
|
|
2023-09-06 16:32:56 +02:00
|
|
|
clean-all: mrproper
|
|
|
|
|
2023-04-26 16:42:55 +02:00
|
|
|
# Formatting
|
|
|
|
pretty-code:
|
2023-09-07 16:36:44 +02:00
|
|
|
clang-format -i src/*.c src/*.h src/tools/*.c
|
2023-04-26 19:46:45 +02:00
|
|
|
|
|
|
|
# Installing
|
2023-10-30 10:33:28 +01:00
|
|
|
dist/ROMs/sxrom-a:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/sxrom-a.zip" --output - | funzip > "dist/ROMs/sxrom-a"
|
|
|
|
dist/ROMs/sxrom-b:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/sxrom-b.zip" --output - | funzip > "dist/ROMs/sxrom-b"
|
|
|
|
dist/ROMs/sxrom-c:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/sxrom-c.zip" --output - | funzip > "dist/ROMs/sxrom-c"
|
|
|
|
dist/ROMs/sxrom-d:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/sxrom-d.zip" --output - | funzip > "dist/ROMs/sxrom-d"
|
|
|
|
dist/ROMs/sxrom-e:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/sxrom-e.zip" --output - | funzip > "dist/ROMs/sxrom-e"
|
|
|
|
dist/ROMs/sxrom-j:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/sxrom-j.zip" --output - | funzip > "dist/ROMs/sxrom-j"
|
|
|
|
dist/ROMs/gxrom-l:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/gxrom-l.zip" --output - | funzip > "dist/ROMs/gxrom-l"
|
|
|
|
dist/ROMs/gxrom-m:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/gxrom-m.zip" --output - | funzip > "dist/ROMs/gxrom-m"
|
|
|
|
dist/ROMs/gxrom-p:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/gxrom-p.zip" --output - | funzip > "dist/ROMs/gxrom-p"
|
|
|
|
dist/ROMs/gxrom-r:
|
|
|
|
curl "https://www.hpcalc.org/hp48/pc/emulators/gxrom-r.zip" --output - | funzip > "dist/ROMs/gxrom-r"
|
|
|
|
|
|
|
|
get-roms: dist/ROMs/sxrom-a dist/ROMs/sxrom-b dist/ROMs/sxrom-c dist/ROMs/sxrom-d dist/ROMs/sxrom-e dist/ROMs/sxrom-j dist/ROMs/gxrom-l dist/ROMs/gxrom-m dist/ROMs/gxrom-p dist/ROMs/gxrom-r
|
|
|
|
|
|
|
|
install: all get-roms
|
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 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/
|
|
|
|
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-10-01 13:17:57 +02:00
|
|
|
cp -R AUTHORS LICENSE README* doc* romdump/ $(DESTDIR)$(DOCDIR)
|
2023-10-30 10:33:28 +01:00
|
|
|
dist/x48ng --print-config > dist/config.lua
|
2023-10-01 13:17:57 +02:00
|
|
|
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
|