2024-09-26 14:49:57 +02:00
|
|
|
# Simple Makefile to build saturn
|
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-09-26 14:49:57 +02:00
|
|
|
NAME = saturn
|
|
|
|
|
2024-09-26 15:40:46 +02:00
|
|
|
PREFIX ?= /usr
|
|
|
|
DOCDIR ?= $(PREFIX)/doc/$(NAME)
|
2024-10-06 16:11:38 +02:00
|
|
|
INFODIR ?= $(PREFIX)/info
|
2024-08-25 16:52:42 +02:00
|
|
|
|
2024-09-26 15:40:46 +02:00
|
|
|
VERSION_MAJOR = 5
|
2024-10-06 12:10:43 +02:00
|
|
|
VERSION_MINOR = 3
|
2024-10-06 19:17:15 +02:00
|
|
|
PATCHLEVEL = 1
|
2024-09-24 13:47:04 +02:00
|
|
|
|
2024-03-20 18:54:37 +01:00
|
|
|
OPTIM ?= 2
|
|
|
|
|
2024-09-26 15:40:46 +02:00
|
|
|
override CFLAGS := -O$(OPTIM) \
|
2024-09-24 13:47:04 +02:00
|
|
|
-D_GNU_SOURCE=1 \
|
|
|
|
-DVERSION_MAJOR=$(VERSION_MAJOR) \
|
|
|
|
-DVERSION_MINOR=$(VERSION_MINOR) \
|
2024-09-24 15:45:16 +02:00
|
|
|
-DPATCHLEVEL=$(PATCHLEVEL) \
|
|
|
|
-I./src/ \
|
2024-09-27 10:01:51 +02:00
|
|
|
-I./src/libChf/src/ \
|
2024-09-26 15:40:46 +02:00
|
|
|
$(CFLAGS)
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-09-27 10:01:51 +02:00
|
|
|
LIBS = -L./src/libChf -lChf
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-09-19 15:39:02 +02:00
|
|
|
SDLCFLAGS = $(shell pkg-config --cflags sdl2)
|
|
|
|
SDLLIBS = $(shell pkg-config --libs sdl2)
|
|
|
|
|
|
|
|
NCURSESCFLAGS = $(shell pkg-config --cflags ncursesw)
|
2024-09-24 13:47:04 +02:00
|
|
|
NCURSESLIBS = $(shell pkg-config --libs ncursesw)
|
2024-09-19 15:39:02 +02:00
|
|
|
|
2024-03-20 18:54:37 +01:00
|
|
|
FULL_WARNINGS = no
|
|
|
|
|
2024-09-24 15:45:16 +02:00
|
|
|
DOTOS = src/cpu.o \
|
2024-03-20 18:54:37 +01:00
|
|
|
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-26 13:51:03 +02:00
|
|
|
src/x_func.o \
|
2024-09-27 10:10:54 +02:00
|
|
|
src/chf_messages.o \
|
2024-09-26 10:55:14 +02:00
|
|
|
src/main.o
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-09-27 10:10:54 +02:00
|
|
|
DOTOS_UI4x = src/ui4x/config.o \
|
2024-10-02 10:16:57 +02:00
|
|
|
src/ui4x/fonts.o \
|
|
|
|
src/ui4x/48sx.o \
|
|
|
|
src/ui4x/48gx.o \
|
|
|
|
src/ui4x/49g.o \
|
2024-09-27 10:10:54 +02:00
|
|
|
src/ui4x/common.o \
|
|
|
|
src/ui4x/sdl2.o \
|
|
|
|
src/ui4x/ncurses.o \
|
|
|
|
src/ui4x/emulator.o
|
|
|
|
|
2024-10-04 19:01:09 +02:00
|
|
|
HEADERS = src/ui4x/bitmaps_misc.h \
|
|
|
|
src/ui4x/common.h \
|
|
|
|
src/ui4x/config.h \
|
|
|
|
src/ui4x/ncurses.h \
|
|
|
|
src/ui4x/sdl2.h \
|
|
|
|
src/ui4x/inner.h \
|
|
|
|
src/ui4x/emulator.h \
|
|
|
|
src/disk_io.h \
|
|
|
|
src/flash49.h \
|
|
|
|
src/keyb.h \
|
|
|
|
src/machdep.h \
|
|
|
|
src/modules.h \
|
|
|
|
src/monitor.h \
|
|
|
|
src/serial.h \
|
|
|
|
src/x_func.h \
|
|
|
|
src/chf_messages.h \
|
|
|
|
src/config.h \
|
|
|
|
src/cpu.h \
|
|
|
|
src/debug.h
|
|
|
|
|
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-09-19 15:39:02 +02:00
|
|
|
$(SDLCFLAGS) \
|
|
|
|
$(NCURSESCFLAGS) \
|
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-27 10:01:51 +02:00
|
|
|
all: src/libChf/libChf.a dist/$(NAME) docs
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-03-21 11:25:58 +01:00
|
|
|
# Building
|
2024-09-27 10:01:51 +02:00
|
|
|
src/libChf/libChf.a:
|
2024-10-03 15:44:03 +02:00
|
|
|
make -C src/libChf #MT=yes
|
2024-09-18 14:39:36 +02:00
|
|
|
|
2024-10-04 19:01:09 +02:00
|
|
|
dist/$(NAME): $(DOTOS) $(DOTOS_UI4x) $(HEADERS) src/libChf/libChf.a
|
|
|
|
$(CC) $(DOTOS) $(DOTOS_UI4x) src/libChf/libChf.a -o $@ $(CFLAGS) $(LIBS) $(SDLLIBS) $(NCURSESLIBS)
|
2024-03-20 18:54:37 +01:00
|
|
|
|
2024-09-27 10:01:51 +02:00
|
|
|
dist/pack: src/pack.o src/disk_io.o src/debug.o src/libChf/libChf.a
|
2024-09-19 13:33:59 +02:00
|
|
|
# UNUSED
|
2024-03-20 18:54:37 +01:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS) $(LIBS)
|
|
|
|
|
2024-09-19 15:18:53 +02:00
|
|
|
doc:
|
|
|
|
make -C docs
|
2024-09-27 10:01:51 +02:00
|
|
|
make -C src/libChf doc
|
2024-03-20 20:36:02 +01:00
|
|
|
|
2024-03-20 18:54:37 +01:00
|
|
|
# Cleaning
|
|
|
|
clean:
|
|
|
|
rm -f src/*.o
|
2024-09-27 10:01:51 +02:00
|
|
|
make -C src/libChf clean
|
2024-09-19 15:18:53 +02:00
|
|
|
make -C docs clean
|
2024-03-20 18:54:37 +01:00
|
|
|
|
|
|
|
mrproper: clean
|
2024-09-26 14:49:57 +02:00
|
|
|
rm -f dist/$(NAME) dist/pack
|
2024-08-25 16:52:42 +02:00
|
|
|
make -C dist/ROMs mrproper
|
2024-09-27 10:01:51 +02:00
|
|
|
make -C src/libChf mrproper
|
2024-09-19 15:18:53 +02:00
|
|
|
make -C docs mrproper
|
2024-03-20 18:54:37 +01:00
|
|
|
|
|
|
|
clean-all: mrproper
|
|
|
|
|
|
|
|
# Formatting
|
|
|
|
pretty-code:
|
2024-10-03 15:12:04 +02:00
|
|
|
clang-format -i src/*.c src/*.h src/ui4x/*.c src/ui4x/*.h
|
2024-09-27 10:01:51 +02:00
|
|
|
make -C src/libChf pretty-code
|
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-26 14:49:57 +02:00
|
|
|
install: dist/$(NAME) doc
|
2024-08-25 16:52:42 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin
|
2024-09-26 14:49:57 +02:00
|
|
|
install -c -m 755 dist/$(NAME) $(DESTDIR)$(PREFIX)/bin/$(NAME)
|
2024-08-29 09:46:34 +02:00
|
|
|
install -c -m 755 dist/saturn48gx $(DESTDIR)$(PREFIX)/bin/saturn48gx
|
2024-09-25 17:01:40 +02:00
|
|
|
install -c -m 755 dist/saturn48sx $(DESTDIR)$(PREFIX)/bin/saturn48sx
|
2024-08-29 09:46:34 +02:00
|
|
|
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
|
|
|
|
2024-09-26 14:49:57 +02:00
|
|
|
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/$(NAME)
|
|
|
|
install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/$(NAME)/hplogo.png
|
|
|
|
cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/$(NAME)/
|
2024-08-25 16:52:42 +02:00
|
|
|
|
|
|
|
install -m 755 -d -- $(DESTDIR)$(DOCDIR)
|
2024-10-06 16:11:38 +02:00
|
|
|
cp -R COPYING LICENSE README* docs-4.1.1.1 docs/*.{dvi,ps,pdf} src/libChf/docs/*.{dvi,ps,pdf} $(DESTDIR)$(DOCDIR)
|
|
|
|
|
|
|
|
install -m 755 -d -- $(DESTDIR)$(INFODIR)
|
|
|
|
cp docs/*.info src/libChf/docs/*.info $(DESTDIR)$(INFODIR)
|
2024-08-25 16:52:42 +02:00
|
|
|
|
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-09-25 17:01:40 +02:00
|
|
|
sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn48sx.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn48sx.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
|
2024-09-19 15:27:31 +02:00
|
|
|
|
|
|
|
uninstall:
|
2024-09-26 14:49:57 +02:00
|
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/$(NAME)
|
2024-09-19 15:27:31 +02:00
|
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/saturn48gx
|
2024-09-25 14:41:48 +02:00
|
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/saturn48sx
|
2024-09-19 15:27:31 +02:00
|
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/saturn40g
|
|
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/saturn49g
|
2024-09-26 14:49:57 +02:00
|
|
|
rm -fr $(DESTDIR)$(PREFIX)/share/$(NAME)
|
2024-09-19 15:27:31 +02:00
|
|
|
rm -fr $(DESTDIR)$(DOCDIR)
|
|
|
|
rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn48gx.desktop
|
2024-09-25 14:41:48 +02:00
|
|
|
rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn48sx.desktop
|
2024-09-19 15:27:31 +02:00
|
|
|
rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn49g.desktop
|
|
|
|
rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn40g.desktop
|