2024-03-20 18:54:37 +01:00
|
|
|
# Simple Makefile to build saturn_bertolotti
|
2024-08-25 15:30:44 +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-03-20 18:54:37 +01:00
|
|
|
|
2024-08-25 16:52:42 +02:00
|
|
|
PREFIX = /usr
|
2024-08-25 18:37:05 +02:00
|
|
|
DOCDIR = $(PREFIX)/doc/saturn
|
2024-08-25 16:52:42 +02:00
|
|
|
|
2024-03-20 18:54:37 +01:00
|
|
|
OPTIM ?= 2
|
|
|
|
|
2024-09-19 13:33:59 +02:00
|
|
|
CFLAGS ?= -g -O$(OPTIM) -D_GNU_SOURCE=1 -I./src/ -I./libChf -L./libChf/mt_build
|
|
|
|
LIBS = -lm -lChf_r -lXm -lutil
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-08-25 18:37:05 +02:00
|
|
|
X11CFLAGS = $(shell pkg-config --cflags x11 xext)
|
2024-03-20 18:54:37 +01:00
|
|
|
X11LIBS = $(shell pkg-config --libs x11 xext xt)
|
|
|
|
|
|
|
|
FULL_WARNINGS = no
|
|
|
|
|
|
|
|
DOTOS = src/cpu.o \
|
|
|
|
src/debug.o \
|
|
|
|
src/dis.o \
|
|
|
|
src/disk_io.o \
|
|
|
|
src/disk_io_obj.o \
|
|
|
|
src/emulator.o \
|
|
|
|
src/flash49.o \
|
|
|
|
src/hdw.o \
|
|
|
|
src/hw_config.o \
|
|
|
|
src/keyb.o \
|
|
|
|
src/modules.o \
|
|
|
|
src/monitor.o \
|
|
|
|
src/romram.o \
|
|
|
|
src/romram49.o \
|
|
|
|
src/serial.o \
|
2024-09-19 13:27:04 +02:00
|
|
|
src/x11_lcd.o \
|
2024-03-20 18:54:37 +01:00
|
|
|
src/x11.o \
|
2024-09-19 13:27:04 +02:00
|
|
|
src/x_func.o \
|
|
|
|
src/main.o
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-08-27 15:10:15 +02:00
|
|
|
MSFS = src/MSFs/cpu.msf \
|
|
|
|
src/MSFs/debug.msf \
|
2024-03-26 15:51:15 +01:00
|
|
|
src/MSFs/disk_io.msf \
|
|
|
|
src/MSFs/flash49.msf \
|
2024-08-27 15:10:15 +02:00
|
|
|
src/MSFs/modules.msf \
|
2024-03-26 15:51:15 +01:00
|
|
|
src/MSFs/saturn.msf \
|
2024-08-27 15:10:15 +02:00
|
|
|
src/MSFs/serial.msf \
|
2024-03-26 15:51:15 +01:00
|
|
|
src/MSFs/util.msf \
|
2024-08-27 15:10:15 +02:00
|
|
|
src/MSFs/x11.msf \
|
|
|
|
src/MSFs/x_func.msf \
|
2024-03-26 15:51:15 +01:00
|
|
|
libChf/chf.msf
|
2024-03-20 20:36:02 +01:00
|
|
|
|
2024-08-25 15:30:44 +02:00
|
|
|
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
|
|
|
|
|
|
|
|
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) \
|
2024-08-25 18:37:05 +02:00
|
|
|
$(X11CFLAGS) \
|
2024-08-25 15:30:44 +02:00
|
|
|
$(CFLAGS)
|
|
|
|
|
|
|
|
override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \
|
|
|
|
$(CPPFLAGS)
|
|
|
|
|
2024-08-25 16:52:42 +02:00
|
|
|
.PHONY: all clean clean-all pretty-code install mrproper get-roms install
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-09-19 13:33:59 +02:00
|
|
|
all: libChf/mt_build/libChf_r.a dist/saturn dist/saturn.cat manual
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-03-21 11:25:58 +01:00
|
|
|
# Building
|
2024-09-18 14:39:36 +02:00
|
|
|
libChf/mt_build/libChf_r.a:
|
|
|
|
make -C libChf ./mt_build/libChf_r.a CC=$(CC)
|
|
|
|
|
|
|
|
dist/saturn: $(DOTOS) libChf/mt_build/libChf_r.a
|
2024-08-25 18:37:05 +02:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) $(LIBS) $(X11LIBS)
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-09-19 13:33:59 +02:00
|
|
|
libChf/st_build/libChf.a:
|
|
|
|
# UNUSED
|
|
|
|
make -C libChf ./st_build/libChf.a CC=$(CC)
|
|
|
|
|
2024-09-18 14:39:36 +02:00
|
|
|
dist/pack: src/pack.o src/disk_io.o src/debug.o libChf/mt_build/libChf_r.a
|
2024-09-19 13:33:59 +02:00
|
|
|
# UNUSED
|
2024-03-20 18:54:37 +01:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) $(LIBS)
|
|
|
|
|
2024-03-20 20:36:02 +01:00
|
|
|
dist/saturn.cat: $(MSFS)
|
|
|
|
for msf in $? ; \
|
|
|
|
do gencat $@ $$msf ; \
|
|
|
|
done
|
|
|
|
|
2024-03-21 11:19:55 +01:00
|
|
|
manual:
|
|
|
|
make -C manual
|
2024-03-20 20:36:02 +01:00
|
|
|
|
2024-03-20 18:54:37 +01:00
|
|
|
# Cleaning
|
|
|
|
clean:
|
|
|
|
rm -f src/*.o
|
2024-09-18 14:11:37 +02:00
|
|
|
rm -f libChf/*_build/*.o
|
2024-03-20 18:54:37 +01:00
|
|
|
|
|
|
|
mrproper: clean
|
2024-09-19 13:33:59 +02:00
|
|
|
rm -f dist/saturn dist/saturn.cat dist/pack
|
2024-08-25 16:52:42 +02:00
|
|
|
make -C dist/ROMs mrproper
|
2024-09-18 14:11:37 +02:00
|
|
|
make -C libChf clean
|
|
|
|
make -C manual clean
|
2024-03-20 18:54:37 +01:00
|
|
|
|
|
|
|
clean-all: mrproper
|
|
|
|
|
|
|
|
# Formatting
|
|
|
|
pretty-code:
|
2024-03-26 15:51:15 +01:00
|
|
|
clang-format -i src/*.c src/*.h libChf/*.c libChf/*.h
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-03-21 11:25:58 +01:00
|
|
|
# Dependencies
|
|
|
|
get-roms:
|
2024-08-25 16:52:42 +02:00
|
|
|
make -C dist/ROMs get-roms
|
|
|
|
|
|
|
|
# Installation
|
2024-09-19 13:33:59 +02:00
|
|
|
install: dist/saturn dist/saturn.cat dist/Saturn.ad manual
|
2024-08-25 16:52:42 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin
|
|
|
|
install -c -m 755 dist/saturn $(DESTDIR)$(PREFIX)/bin/saturn
|
2024-08-29 09:46:34 +02:00
|
|
|
install -c -m 755 dist/saturn48gx $(DESTDIR)$(PREFIX)/bin/saturn48gx
|
|
|
|
install -c -m 755 dist/saturn40g $(DESTDIR)$(PREFIX)/bin/saturn40g
|
|
|
|
install -c -m 755 dist/saturn49g $(DESTDIR)$(PREFIX)/bin/saturn49g
|
2024-08-25 17:26:24 +02:00
|
|
|
|
|
|
|
install -c -m 644 dist/saturn.cat $(DESTDIR)$(PREFIX)/bin/saturn.cat #FIXME
|
2024-08-25 19:05:51 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/locale/C/LC_MESSAGES
|
|
|
|
install -c -m 644 dist/saturn.cat $(DESTDIR)$(PREFIX)/share/locale/C/LC_MESSAGES/saturn.cat
|
2024-08-25 16:52:42 +02:00
|
|
|
|
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/saturn
|
2024-08-25 19:04:26 +02:00
|
|
|
install -c -m 644 dist/saturn.cat $(DESTDIR)$(PREFIX)/share/saturn.cat #FIXME
|
2024-08-25 17:20:40 +02:00
|
|
|
install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/saturn/hplogo.png
|
2024-08-25 16:52:42 +02:00
|
|
|
cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/saturn/
|
|
|
|
|
2024-08-25 17:05:35 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)/etc/X11/app-defaults
|
|
|
|
install -c -m 644 dist/Saturn.ad $(DESTDIR)/etc/X11/app-defaults/Saturn
|
2024-08-25 16:52:42 +02:00
|
|
|
|
|
|
|
install -m 755 -d -- $(DESTDIR)$(DOCDIR)
|
|
|
|
cp -R COPYING LICENSE README* docs* manual/ $(DESTDIR)$(DOCDIR)
|
|
|
|
|
2024-08-25 17:20:40 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications
|
|
|
|
sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn48gx.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn48gx.desktop
|
2024-08-25 17:39:50 +02:00
|
|
|
sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn49g.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn49g.desktop
|
2024-08-25 17:57:17 +02:00
|
|
|
sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn40g.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn40g.desktop
|