2016-08-26 22:30:11 +00:00
|
|
|
# Make hacks
|
|
|
|
.INTERMEDIATE:
|
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Set target, configuration, version and destination folders
|
|
|
|
|
|
|
|
PLATFORM := $(shell uname -s)
|
2018-03-29 18:27:19 +00:00
|
|
|
ifneq ($(findstring MINGW,$(PLATFORM)),)
|
|
|
|
PLATFORM := windows32
|
2018-03-29 19:02:01 +00:00
|
|
|
USE_WINDRES := true
|
2018-03-29 18:27:19 +00:00
|
|
|
endif
|
2016-08-20 14:51:17 +00:00
|
|
|
|
2018-08-19 20:07:16 +00:00
|
|
|
ifneq ($(findstring MSYS,$(PLATFORM)),)
|
|
|
|
PLATFORM := windows32
|
|
|
|
endif
|
|
|
|
|
2019-05-04 12:35:17 +00:00
|
|
|
ifeq ($(PLATFORM),windows32)
|
|
|
|
_ := $(shell chcp 65001)
|
2019-07-16 20:58:16 +00:00
|
|
|
EXESUFFIX:=.exe
|
2020-10-05 21:33:36 +00:00
|
|
|
NATIVE_CC = clang -IWindows -Wno-deprecated-declarations --target=i386-pc-windows
|
2019-07-16 20:58:16 +00:00
|
|
|
else
|
|
|
|
EXESUFFIX:=
|
2020-06-10 20:00:41 +00:00
|
|
|
NATIVE_CC := cc
|
2019-05-04 12:35:17 +00:00
|
|
|
endif
|
|
|
|
|
2020-05-06 20:30:01 +00:00
|
|
|
PB12_COMPRESS := build/pb12$(EXESUFFIX)
|
2019-07-16 20:58:16 +00:00
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
ifeq ($(PLATFORM),Darwin)
|
2016-08-06 12:57:32 +00:00
|
|
|
DEFAULT := cocoa
|
2016-03-30 20:07:55 +00:00
|
|
|
else
|
2016-08-06 12:57:32 +00:00
|
|
|
DEFAULT := sdl
|
2016-03-30 20:07:55 +00:00
|
|
|
endif
|
|
|
|
|
2021-02-28 12:55:30 +00:00
|
|
|
ifneq ($(shell which xdg-open)$(FREEDESKTOP),)
|
2021-02-27 02:13:50 +00:00
|
|
|
# Running on an FreeDesktop environment, configure for (optional) installation
|
|
|
|
DESTDIR ?=
|
|
|
|
PREFIX ?= /usr/local
|
|
|
|
DATA_DIR ?= $(PREFIX)/share/sameboy/
|
2021-02-28 12:51:58 +00:00
|
|
|
FREEDESKTOP ?= true
|
2021-02-27 02:13:50 +00:00
|
|
|
endif
|
|
|
|
|
2016-08-06 12:57:32 +00:00
|
|
|
default: $(DEFAULT)
|
|
|
|
|
|
|
|
ifeq ($(MAKECMDGOALS),)
|
|
|
|
MAKECMDGOALS := $(DEFAULT)
|
|
|
|
endif
|
|
|
|
|
2020-10-10 23:33:10 +00:00
|
|
|
include version.mk
|
2017-12-29 11:26:11 +00:00
|
|
|
export VERSION
|
2016-08-20 14:51:17 +00:00
|
|
|
CONF ?= debug
|
2020-04-27 18:12:30 +00:00
|
|
|
SDL_AUDIO_DRIVER ?= sdl
|
2016-04-01 20:36:43 +00:00
|
|
|
|
2016-03-30 20:07:55 +00:00
|
|
|
BIN := build/bin
|
|
|
|
OBJ := build/obj
|
2016-08-26 22:30:11 +00:00
|
|
|
BOOTROMS_DIR ?= $(BIN)/BootROMs
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2018-11-09 22:20:57 +00:00
|
|
|
ifdef DATA_DIR
|
|
|
|
CFLAGS += -DDATA_DIR="\"$(DATA_DIR)\""
|
|
|
|
endif
|
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Set tools
|
2018-10-13 00:14:34 +00:00
|
|
|
|
|
|
|
# Use clang if it's available.
|
2019-05-09 16:01:15 +00:00
|
|
|
ifeq ($(origin CC),default)
|
2018-10-13 00:14:34 +00:00
|
|
|
ifneq (, $(shell which clang))
|
2020-01-01 20:57:24 +00:00
|
|
|
CC := clang
|
2018-10-13 00:14:34 +00:00
|
|
|
endif
|
2019-05-09 16:01:15 +00:00
|
|
|
endif
|
2018-10-13 00:14:34 +00:00
|
|
|
|
2019-06-26 03:01:54 +00:00
|
|
|
# Find libraries with pkg-config if available.
|
|
|
|
ifneq (, $(shell which pkg-config))
|
2022-05-23 19:16:06 +00:00
|
|
|
# But not on macOS, it's annoying
|
|
|
|
ifneq ($(PLATFORM),Darwin)
|
2019-06-26 03:01:54 +00:00
|
|
|
PKG_CONFIG := pkg-config
|
|
|
|
endif
|
2022-05-23 19:16:06 +00:00
|
|
|
endif
|
2019-06-26 03:01:54 +00:00
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
ifeq ($(PLATFORM),windows32)
|
|
|
|
# To force use of the Unix version instead of the Windows version
|
|
|
|
MKDIR := $(shell which mkdir)
|
|
|
|
else
|
|
|
|
MKDIR := mkdir
|
|
|
|
endif
|
|
|
|
|
2017-02-24 16:35:31 +00:00
|
|
|
ifeq ($(CONF),native_release)
|
|
|
|
override CONF := release
|
|
|
|
LDFLAGS += -march=native -mtune=native
|
|
|
|
CFLAGS += -march=native -mtune=native
|
|
|
|
endif
|
|
|
|
|
2020-06-25 16:51:58 +00:00
|
|
|
ifeq ($(CONF),fat_release)
|
|
|
|
override CONF := release
|
|
|
|
FAT_FLAGS += -arch x86_64 -arch arm64
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Set compilation and linkage flags based on target, platform and configuration
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2019-06-01 11:29:46 +00:00
|
|
|
OPEN_DIALOG = OpenDialog/gtk.c
|
2020-01-01 20:57:24 +00:00
|
|
|
NULL := /dev/null
|
2019-06-01 11:29:46 +00:00
|
|
|
|
|
|
|
ifeq ($(PLATFORM),windows32)
|
|
|
|
OPEN_DIALOG = OpenDialog/windows.c
|
2020-01-01 20:57:24 +00:00
|
|
|
NULL := NUL
|
2019-06-01 11:29:46 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(PLATFORM),Darwin)
|
|
|
|
OPEN_DIALOG = OpenDialog/cocoa.m
|
|
|
|
endif
|
|
|
|
|
2020-04-24 17:44:25 +00:00
|
|
|
# These must come before the -Wno- flags
|
2021-03-28 23:47:57 +00:00
|
|
|
WARNINGS += -Werror -Wall -Wno-unknown-warning -Wno-unknown-warning-option -Wno-missing-braces
|
2020-12-26 22:23:16 +00:00
|
|
|
WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-strict-aliasing -Wno-multichar -Wno-int-in-bool-context -Wno-format-truncation
|
2020-04-24 18:59:51 +00:00
|
|
|
|
|
|
|
# Only add this flag if the compiler supports it
|
|
|
|
ifeq ($(shell $(CC) -x c -c $(NULL) -o $(NULL) -Werror -Wpartial-availability 2> $(NULL); echo $$?),0)
|
2020-04-28 18:44:29 +00:00
|
|
|
WARNINGS += -Wpartial-availability
|
2020-04-24 18:59:51 +00:00
|
|
|
endif
|
|
|
|
|
2020-09-17 20:18:16 +00:00
|
|
|
# GCC's implementation of this warning has false positives, so we skip it
|
|
|
|
ifneq ($(shell $(CC) --version 2>&1 | grep "gcc"), )
|
2020-09-17 20:25:56 +00:00
|
|
|
WARNINGS += -Wno-maybe-uninitialized
|
2020-09-17 20:18:16 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-28 18:44:29 +00:00
|
|
|
CFLAGS += $(WARNINGS)
|
|
|
|
|
2021-05-30 17:55:04 +00:00
|
|
|
CFLAGS += -std=gnu11 -D_GNU_SOURCE -DGB_VERSION='"$(VERSION)"' -I. -D_USE_MATH_DEFINES
|
2021-04-25 19:28:24 +00:00
|
|
|
ifneq (,$(UPDATE_SUPPORT))
|
|
|
|
CFLAGS += -DUPDATE_SUPPORT
|
|
|
|
endif
|
2019-06-01 11:29:46 +00:00
|
|
|
|
2019-06-26 03:01:54 +00:00
|
|
|
ifeq (,$(PKG_CONFIG))
|
|
|
|
SDL_CFLAGS := $(shell sdl2-config --cflags)
|
2021-09-08 21:13:09 +00:00
|
|
|
SDL_LDFLAGS := $(shell sdl2-config --libs) -lpthread
|
2019-06-26 03:01:54 +00:00
|
|
|
else
|
|
|
|
SDL_CFLAGS := $(shell $(PKG_CONFIG) --cflags sdl2)
|
2021-09-08 21:13:09 +00:00
|
|
|
SDL_LDFLAGS := $(shell $(PKG_CONFIG) --libs sdl2) -lpthread
|
2019-06-26 03:01:54 +00:00
|
|
|
endif
|
|
|
|
ifeq (,$(PKG_CONFIG))
|
|
|
|
GL_LDFLAGS := -lGL
|
|
|
|
else
|
|
|
|
GL_CFLAGS := $(shell $(PKG_CONFIG) --cflags gl)
|
|
|
|
GL_LDFLAGS := $(shell $(PKG_CONFIG) --libs gl || echo -lGL)
|
|
|
|
endif
|
2016-08-20 14:51:17 +00:00
|
|
|
ifeq ($(PLATFORM),windows32)
|
2020-10-05 21:33:36 +00:00
|
|
|
CFLAGS += -IWindows -Drandom=rand --target=i386-pc-windows
|
2020-12-26 13:10:11 +00:00
|
|
|
LDFLAGS += -lmsvcrt -lcomdlg32 -luser32 -lshell32 -lole32 -lSDL2main -Wl,/MANIFESTFILE:NUL --target=i386-pc-windows
|
2019-12-26 00:00:58 +00:00
|
|
|
SDL_LDFLAGS := -lSDL2
|
|
|
|
GL_LDFLAGS := -lopengl32
|
2016-08-20 14:51:17 +00:00
|
|
|
else
|
2019-06-01 11:29:46 +00:00
|
|
|
LDFLAGS += -lc -lm -ldl
|
2016-08-20 14:51:17 +00:00
|
|
|
endif
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
ifeq ($(PLATFORM),Darwin)
|
2020-01-01 20:57:24 +00:00
|
|
|
SYSROOT := $(shell xcodebuild -sdk macosx -version Path 2> $(NULL))
|
2020-04-29 17:44:55 +00:00
|
|
|
ifeq ($(SYSROOT),)
|
2020-04-29 17:54:28 +00:00
|
|
|
SYSROOT := /Library/Developer/CommandLineTools/SDKs/$(shell ls /Library/Developer/CommandLineTools/SDKs/ | grep 10 | tail -n 1)
|
2020-04-29 17:44:55 +00:00
|
|
|
endif
|
2020-04-29 17:59:19 +00:00
|
|
|
ifeq ($(SYSROOT),/Library/Developer/CommandLineTools/SDKs/)
|
2020-04-29 17:44:55 +00:00
|
|
|
$(error Could not find a macOS SDK)
|
|
|
|
endif
|
|
|
|
|
2020-06-25 16:51:58 +00:00
|
|
|
CFLAGS += -F/Library/Frameworks -mmacosx-version-min=10.9 -isysroot $(SYSROOT)
|
2020-01-01 20:57:24 +00:00
|
|
|
OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(SYSROOT)
|
2020-06-25 16:51:58 +00:00
|
|
|
LDFLAGS += -framework AppKit -framework PreferencePanes -framework Carbon -framework QuartzCore -weak_framework Metal -weak_framework MetalKit -mmacosx-version-min=10.9 -isysroot $(SYSROOT)
|
2019-12-26 00:00:58 +00:00
|
|
|
GL_LDFLAGS := -framework OpenGL
|
2016-03-30 20:07:55 +00:00
|
|
|
endif
|
2017-05-21 18:44:28 +00:00
|
|
|
CFLAGS += -Wno-deprecated-declarations
|
2016-08-20 14:51:17 +00:00
|
|
|
ifeq ($(PLATFORM),windows32)
|
2017-05-24 18:44:43 +00:00
|
|
|
CFLAGS += -Wno-deprecated-declarations # Seems like Microsoft deprecated every single LIBC function
|
2017-05-21 18:44:28 +00:00
|
|
|
LDFLAGS += -Wl,/NODEFAULTLIB:libcmt.lib
|
2016-08-20 14:51:17 +00:00
|
|
|
endif
|
|
|
|
|
2016-04-01 19:53:29 +00:00
|
|
|
ifeq ($(CONF),debug)
|
|
|
|
CFLAGS += -g
|
|
|
|
else ifeq ($(CONF), release)
|
2016-08-20 14:51:17 +00:00
|
|
|
CFLAGS += -O3 -DNDEBUG
|
2020-01-01 20:57:24 +00:00
|
|
|
STRIP := strip
|
|
|
|
ifeq ($(PLATFORM),Darwin)
|
|
|
|
LDFLAGS += -Wl,-exported_symbols_list,$(NULL)
|
2021-11-07 11:39:18 +00:00
|
|
|
STRIP := strip -x
|
2020-01-01 20:57:24 +00:00
|
|
|
endif
|
2021-12-30 22:40:34 +00:00
|
|
|
ifeq ($(PLATFORM),windows32)
|
|
|
|
LDFLAGS += -fuse-ld=lld
|
|
|
|
endif
|
2016-08-06 13:18:23 +00:00
|
|
|
LDFLAGS += -flto
|
2016-08-20 14:51:17 +00:00
|
|
|
CFLAGS += -flto
|
2020-04-25 11:55:51 +00:00
|
|
|
LDFLAGS += -Wno-lto-type-mismatch # For GCC's LTO
|
2020-01-01 20:57:24 +00:00
|
|
|
|
2016-04-01 19:53:29 +00:00
|
|
|
else
|
2017-02-24 16:35:31 +00:00
|
|
|
$(error Invalid value for CONF: $(CONF). Use "debug", "release" or "native_release")
|
2016-04-01 19:53:29 +00:00
|
|
|
endif
|
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Define our targets
|
|
|
|
|
|
|
|
ifeq ($(PLATFORM),windows32)
|
2017-05-23 20:18:16 +00:00
|
|
|
SDL_TARGET := $(BIN)/SDL/sameboy.exe $(BIN)/SDL/sameboy_debugger.exe $(BIN)/SDL/SDL2.dll
|
2016-09-03 00:39:32 +00:00
|
|
|
TESTER_TARGET := $(BIN)/tester/sameboy_tester.exe
|
2016-08-20 14:51:17 +00:00
|
|
|
else
|
2017-05-23 20:18:16 +00:00
|
|
|
SDL_TARGET := $(BIN)/SDL/sameboy
|
2016-09-03 00:39:32 +00:00
|
|
|
TESTER_TARGET := $(BIN)/tester/sameboy_tester
|
2016-08-20 14:51:17 +00:00
|
|
|
endif
|
|
|
|
|
2017-01-20 16:35:20 +00:00
|
|
|
cocoa: $(BIN)/SameBoy.app
|
|
|
|
quicklook: $(BIN)/SameBoy.qlgenerator
|
2021-12-30 22:40:34 +00:00
|
|
|
sdl: $(SDL_TARGET) $(BIN)/SDL/dmg_boot.bin $(BIN)/SDL/mgb_boot.bin $(BIN)/SDL/cgb0_boot.bin $(BIN)/SDL/cgb_boot.bin $(BIN)/SDL/agb_boot.bin $(BIN)/SDL/sgb_boot.bin $(BIN)/SDL/sgb2_boot.bin $(BIN)/SDL/LICENSE $(BIN)/SDL/registers.sym $(BIN)/SDL/background.bmp $(BIN)/SDL/Shaders
|
2021-11-03 22:32:15 +00:00
|
|
|
bootroms: $(BIN)/BootROMs/agb_boot.bin $(BIN)/BootROMs/cgb_boot.bin $(BIN)/BootROMs/cgb0_boot.bin $(BIN)/BootROMs/dmg_boot.bin $(BIN)/BootROMs/sgb_boot.bin $(BIN)/BootROMs/sgb2_boot.bin
|
|
|
|
tester: $(TESTER_TARGET) $(BIN)/tester/dmg_boot.bin $(BIN)/tester/cgb_boot.bin $(BIN)/tester/agb_boot.bin $(BIN)/tester/sgb_boot.bin $(BIN)/tester/sgb2_boot.bin
|
2017-10-12 19:40:48 +00:00
|
|
|
all: cocoa sdl tester libretro
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Get a list of our source files and their respective object file targets
|
|
|
|
|
|
|
|
CORE_SOURCES := $(shell ls Core/*.c)
|
2020-04-27 18:12:30 +00:00
|
|
|
SDL_SOURCES := $(shell ls SDL/*.c) $(OPEN_DIALOG) SDL/audio/$(SDL_AUDIO_DRIVER).c
|
2016-09-03 00:39:32 +00:00
|
|
|
TESTER_SOURCES := $(shell ls Tester/*.c)
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
ifeq ($(PLATFORM),Darwin)
|
2019-10-19 16:26:04 +00:00
|
|
|
COCOA_SOURCES := $(shell ls Cocoa/*.m) $(shell ls HexFiend/*.m) $(shell ls JoyKit/*.m)
|
2017-01-20 16:35:20 +00:00
|
|
|
QUICKLOOK_SOURCES := $(shell ls QuickLook/*.m) $(shell ls QuickLook/*.c)
|
2016-03-30 20:07:55 +00:00
|
|
|
endif
|
|
|
|
|
2018-03-28 18:59:27 +00:00
|
|
|
ifeq ($(PLATFORM),windows32)
|
|
|
|
CORE_SOURCES += $(shell ls Windows/*.c)
|
|
|
|
endif
|
|
|
|
|
2016-03-30 20:07:55 +00:00
|
|
|
CORE_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(CORE_SOURCES))
|
|
|
|
COCOA_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(COCOA_SOURCES))
|
2017-01-20 16:35:20 +00:00
|
|
|
QUICKLOOK_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(QUICKLOOK_SOURCES))
|
2016-03-30 20:07:55 +00:00
|
|
|
SDL_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(SDL_SOURCES))
|
2016-09-03 00:39:32 +00:00
|
|
|
TESTER_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(TESTER_SOURCES))
|
2016-03-30 20:07:55 +00:00
|
|
|
|
|
|
|
# Automatic dependency generation
|
2016-08-20 14:51:17 +00:00
|
|
|
|
2017-10-15 17:26:49 +00:00
|
|
|
ifneq ($(filter-out clean bootroms libretro %.bin, $(MAKECMDGOALS)),)
|
2016-08-06 12:57:32 +00:00
|
|
|
-include $(CORE_OBJECTS:.o=.dep)
|
|
|
|
ifneq ($(filter $(MAKECMDGOALS),sdl),)
|
|
|
|
-include $(SDL_OBJECTS:.o=.dep)
|
|
|
|
endif
|
2016-09-03 00:39:32 +00:00
|
|
|
ifneq ($(filter $(MAKECMDGOALS),tester),)
|
|
|
|
-include $(TESTER_OBJECTS:.o=.dep)
|
|
|
|
endif
|
2016-08-06 12:57:32 +00:00
|
|
|
ifneq ($(filter $(MAKECMDGOALS),cocoa),)
|
|
|
|
-include $(COCOA_OBJECTS:.o=.dep)
|
|
|
|
endif
|
|
|
|
endif
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2019-06-26 03:01:54 +00:00
|
|
|
$(OBJ)/SDL/%.dep: SDL/%
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
$(CC) $(CFLAGS) $(SDL_CFLAGS) $(GL_CFLAGS) -MT $(OBJ)/$^.o -M $^ -c -o $@
|
|
|
|
|
2016-03-30 20:07:55 +00:00
|
|
|
$(OBJ)/%.dep: %
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2016-03-30 20:07:55 +00:00
|
|
|
$(CC) $(CFLAGS) -MT $(OBJ)/$^.o -M $^ -c -o $@
|
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Compilation rules
|
|
|
|
|
2017-04-17 17:16:17 +00:00
|
|
|
$(OBJ)/Core/%.c.o: Core/%.c
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $(CFLAGS) $(FAT_FLAGS) -DGB_INTERNAL -c $< -o $@
|
2017-04-17 17:16:17 +00:00
|
|
|
|
2019-06-26 03:01:54 +00:00
|
|
|
$(OBJ)/SDL/%.c.o: SDL/%.c
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $(CFLAGS) $(FAT_FLAGS) $(SDL_CFLAGS) $(GL_CFLAGS) -c $< -o $@
|
2019-06-26 03:01:54 +00:00
|
|
|
|
2016-03-30 20:07:55 +00:00
|
|
|
$(OBJ)/%.c.o: %.c
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $(CFLAGS) $(FAT_FLAGS) -c $< -o $@
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2016-08-12 19:49:17 +00:00
|
|
|
# HexFiend requires more flags
|
|
|
|
$(OBJ)/HexFiend/%.m.o: HexFiend/%.m
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $(CFLAGS) $(FAT_FLAGS) $(OCFLAGS) -c $< -o $@ -fno-objc-arc -include HexFiend/HexFiend_2_Framework_Prefix.pch
|
2016-08-12 19:49:17 +00:00
|
|
|
|
2016-03-30 20:07:55 +00:00
|
|
|
$(OBJ)/%.m.o: %.m
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $(CFLAGS) $(FAT_FLAGS) $(OCFLAGS) -c $< -o $@
|
2016-03-30 20:07:55 +00:00
|
|
|
|
|
|
|
# Cocoa Port
|
|
|
|
|
2017-01-20 16:35:20 +00:00
|
|
|
$(BIN)/SameBoy.app: $(BIN)/SameBoy.app/Contents/MacOS/SameBoy \
|
2018-12-01 14:08:59 +00:00
|
|
|
$(shell ls Cocoa/*.icns Cocoa/*.png) \
|
2017-01-20 16:35:20 +00:00
|
|
|
Cocoa/License.html \
|
|
|
|
Cocoa/Info.plist \
|
2017-02-20 12:37:15 +00:00
|
|
|
Misc/registers.sym \
|
2017-01-20 16:35:20 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/dmg_boot.bin \
|
2021-10-23 20:28:54 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/mgb_boot.bin \
|
2021-11-03 22:32:15 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/cgb0_boot.bin \
|
2017-01-20 16:35:20 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/cgb_boot.bin \
|
2018-01-13 11:02:31 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/agb_boot.bin \
|
2018-11-10 23:16:32 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/sgb_boot.bin \
|
2018-12-01 15:28:57 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/sgb2_boot.bin \
|
2017-02-24 16:15:31 +00:00
|
|
|
$(patsubst %.xib,%.nib,$(addprefix $(BIN)/SameBoy.app/Contents/Resources/Base.lproj/,$(shell cd Cocoa;ls *.xib))) \
|
2017-01-20 16:35:20 +00:00
|
|
|
$(BIN)/SameBoy.qlgenerator \
|
|
|
|
Shaders
|
|
|
|
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Resources
|
2018-12-01 14:08:59 +00:00
|
|
|
cp Cocoa/*.icns Cocoa/*.png Misc/registers.sym $(BIN)/SameBoy.app/Contents/Resources/
|
2017-01-20 16:35:20 +00:00
|
|
|
sed s/@VERSION/$(VERSION)/ < Cocoa/Info.plist > $(BIN)/SameBoy.app/Contents/Info.plist
|
|
|
|
cp Cocoa/License.html $(BIN)/SameBoy.app/Contents/Resources/Credits.html
|
|
|
|
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Resources/Shaders
|
2018-06-15 09:58:33 +00:00
|
|
|
cp Shaders/*.fsh Shaders/*.metal $(BIN)/SameBoy.app/Contents/Resources/Shaders
|
2017-01-20 16:35:20 +00:00
|
|
|
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Library/QuickLook/
|
|
|
|
cp -rf $(BIN)/SameBoy.qlgenerator $(BIN)/SameBoy.app/Contents/Library/QuickLook/
|
|
|
|
|
|
|
|
$(BIN)/SameBoy.app/Contents/MacOS/SameBoy: $(CORE_OBJECTS) $(COCOA_OBJECTS)
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $^ -o $@ $(LDFLAGS) $(FAT_FLAGS) -framework OpenGL -framework AudioUnit -framework AVFoundation -framework CoreVideo -framework CoreMedia -framework IOKit
|
2016-08-06 13:19:04 +00:00
|
|
|
ifeq ($(CONF), release)
|
2020-01-01 20:57:24 +00:00
|
|
|
$(STRIP) $@
|
2016-08-06 13:19:04 +00:00
|
|
|
endif
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2017-01-20 16:35:20 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/Base.lproj/%.nib: Cocoa/%.xib
|
2020-06-25 17:50:24 +00:00
|
|
|
ibtool --compile $@ $^ 2>&1 | cat -
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2017-01-20 16:35:20 +00:00
|
|
|
# Quick Look generator
|
|
|
|
|
|
|
|
$(BIN)/SameBoy.qlgenerator: $(BIN)/SameBoy.qlgenerator/Contents/MacOS/SameBoyQL \
|
|
|
|
$(shell ls QuickLook/*.png) \
|
|
|
|
QuickLook/Info.plist \
|
|
|
|
$(BIN)/SameBoy.qlgenerator/Contents/Resources/cgb_boot_fast.bin
|
|
|
|
$(MKDIR) -p $(BIN)/SameBoy.qlgenerator/Contents/Resources
|
|
|
|
cp QuickLook/*.png $(BIN)/SameBoy.qlgenerator/Contents/Resources/
|
|
|
|
sed s/@VERSION/$(VERSION)/ < QuickLook/Info.plist > $(BIN)/SameBoy.qlgenerator/Contents/Info.plist
|
|
|
|
|
|
|
|
# Currently, SameBoy.app includes two "copies" of each Core .o file once in the app itself and
|
|
|
|
# once in the QL Generator. It should probably become a dylib instead.
|
|
|
|
$(BIN)/SameBoy.qlgenerator/Contents/MacOS/SameBoyQL: $(CORE_OBJECTS) $(QUICKLOOK_OBJECTS)
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $^ -o $@ $(LDFLAGS) $(FAT_FLAGS) -Wl,-exported_symbols_list,QuickLook/exports.sym -bundle -framework Cocoa -framework Quicklook
|
2017-01-20 16:35:20 +00:00
|
|
|
|
|
|
|
# cgb_boot_fast.bin is not a standard boot ROM, we don't expect it to exist in the user-provided
|
|
|
|
# boot ROM directory.
|
|
|
|
$(BIN)/SameBoy.qlgenerator/Contents/Resources/cgb_boot_fast.bin: $(BIN)/BootROMs/cgb_boot_fast.bin
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# SDL Port
|
|
|
|
|
|
|
|
# Unix versions build only one binary
|
2017-05-23 20:18:16 +00:00
|
|
|
$(BIN)/SDL/sameboy: $(CORE_OBJECTS) $(SDL_OBJECTS)
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-06-25 16:51:58 +00:00
|
|
|
$(CC) $^ -o $@ $(LDFLAGS) $(FAT_FLAGS) $(SDL_LDFLAGS) $(GL_LDFLAGS)
|
2016-08-06 13:19:04 +00:00
|
|
|
ifeq ($(CONF), release)
|
2020-01-01 20:57:24 +00:00
|
|
|
$(STRIP) $@
|
2016-08-06 13:19:04 +00:00
|
|
|
endif
|
2016-08-20 14:51:17 +00:00
|
|
|
|
|
|
|
# Windows version builds two, one with a conole and one without it
|
2017-05-23 20:18:16 +00:00
|
|
|
$(BIN)/SDL/sameboy.exe: $(CORE_OBJECTS) $(SDL_OBJECTS) $(OBJ)/Windows/resources.o
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2019-12-31 22:27:41 +00:00
|
|
|
$(CC) $^ -o $@ $(LDFLAGS) $(SDL_LDFLAGS) $(GL_LDFLAGS) -Wl,/subsystem:windows
|
2016-08-20 14:51:17 +00:00
|
|
|
|
2017-05-23 20:18:16 +00:00
|
|
|
$(BIN)/SDL/sameboy_debugger.exe: $(CORE_OBJECTS) $(SDL_OBJECTS) $(OBJ)/Windows/resources.o
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2019-12-31 22:27:41 +00:00
|
|
|
$(CC) $^ -o $@ $(LDFLAGS) $(SDL_LDFLAGS) $(GL_LDFLAGS) -Wl,/subsystem:console
|
2016-08-20 14:51:17 +00:00
|
|
|
|
2018-03-29 19:02:01 +00:00
|
|
|
ifneq ($(USE_WINDRES),)
|
|
|
|
$(OBJ)/%.o: %.rc
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2018-03-29 20:11:53 +00:00
|
|
|
windres --preprocessor cpp -DVERSION=\"$(VERSION)\" $^ $@
|
2018-03-29 19:02:01 +00:00
|
|
|
else
|
2016-08-20 19:59:03 +00:00
|
|
|
$(OBJ)/%.res: %.rc
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
rc /fo $@ /dVERSION=\"$(VERSION)\" $^
|
|
|
|
|
|
|
|
%.o: %.res
|
|
|
|
cvtres /OUT:"$@" $^
|
2018-03-29 19:02:01 +00:00
|
|
|
endif
|
2016-08-20 19:59:03 +00:00
|
|
|
|
2018-03-12 21:38:05 +00:00
|
|
|
# We must provide SDL2.dll with the Windows port.
|
2017-05-23 20:18:16 +00:00
|
|
|
$(BIN)/SDL/SDL2.dll:
|
2018-03-12 21:38:05 +00:00
|
|
|
@$(eval MATCH := $(shell where $$LIB:SDL2.dll))
|
2016-08-20 14:51:17 +00:00
|
|
|
cp "$(MATCH)" $@
|
|
|
|
|
2016-09-03 00:39:32 +00:00
|
|
|
# Tester
|
|
|
|
|
|
|
|
$(BIN)/tester/sameboy_tester: $(CORE_OBJECTS) $(TESTER_OBJECTS)
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
$(CC) $^ -o $@ $(LDFLAGS)
|
|
|
|
ifeq ($(CONF), release)
|
2020-01-01 20:57:24 +00:00
|
|
|
$(STRIP) $@
|
2016-09-03 00:39:32 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
$(BIN)/tester/sameboy_tester.exe: $(CORE_OBJECTS) $(SDL_OBJECTS)
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
$(CC) $^ -o $@ $(LDFLAGS) -Wl,/subsystem:console
|
|
|
|
|
2020-04-25 14:57:19 +00:00
|
|
|
$(BIN)/SDL/%.bin: $(BOOTROMS_DIR)/%.bin
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
|
|
|
|
|
|
|
$(BIN)/tester/%.bin: $(BOOTROMS_DIR)/%.bin
|
2016-08-26 22:30:11 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
2019-07-16 20:58:16 +00:00
|
|
|
|
2017-01-20 16:35:20 +00:00
|
|
|
$(BIN)/SameBoy.app/Contents/Resources/%.bin: $(BOOTROMS_DIR)/%.bin
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
2019-07-16 20:58:16 +00:00
|
|
|
|
2017-05-23 20:18:16 +00:00
|
|
|
$(BIN)/SDL/LICENSE: LICENSE
|
2017-12-23 15:29:42 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2016-08-20 14:51:17 +00:00
|
|
|
cp -f $^ $@
|
|
|
|
|
2017-05-23 20:18:16 +00:00
|
|
|
$(BIN)/SDL/registers.sym: Misc/registers.sym
|
2017-12-23 15:29:42 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2017-05-23 20:18:16 +00:00
|
|
|
cp -f $^ $@
|
2019-07-16 20:58:16 +00:00
|
|
|
|
2017-10-04 09:43:31 +00:00
|
|
|
$(BIN)/SDL/background.bmp: SDL/background.bmp
|
2017-12-23 15:29:42 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2017-02-20 12:37:15 +00:00
|
|
|
cp -f $^ $@
|
|
|
|
|
2017-12-23 15:29:42 +00:00
|
|
|
$(BIN)/SDL/Shaders: Shaders
|
2018-06-15 15:08:54 +00:00
|
|
|
-@$(MKDIR) -p $@
|
2018-06-15 09:58:33 +00:00
|
|
|
cp -rf Shaders/*.fsh $@
|
2017-12-23 15:29:42 +00:00
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Boot ROMs
|
|
|
|
|
2020-05-03 20:44:13 +00:00
|
|
|
$(OBJ)/%.2bpp: %.png
|
2019-06-10 15:45:14 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2020-05-03 20:44:13 +00:00
|
|
|
rgbgfx -h -u -o $@ $<
|
2019-06-10 15:45:14 +00:00
|
|
|
|
2020-05-06 20:30:01 +00:00
|
|
|
$(OBJ)/BootROMs/SameBoyLogo.pb12: $(OBJ)/BootROMs/SameBoyLogo.2bpp $(PB12_COMPRESS)
|
2020-05-31 18:54:54 +00:00
|
|
|
$(realpath $(PB12_COMPRESS)) < $< > $@
|
2020-05-06 20:30:01 +00:00
|
|
|
|
|
|
|
$(PB12_COMPRESS): BootROMs/pb12.c
|
2020-10-07 06:03:39 +00:00
|
|
|
$(NATIVE_CC) -std=c99 -Wall -Werror $< -o $@
|
2019-06-10 15:45:14 +00:00
|
|
|
|
2021-11-03 22:32:15 +00:00
|
|
|
$(BIN)/BootROMs/cgb0_boot.bin: BootROMs/cgb_boot.asm
|
2019-06-08 10:37:49 +00:00
|
|
|
$(BIN)/BootROMs/agb_boot.bin: BootROMs/cgb_boot.asm
|
|
|
|
$(BIN)/BootROMs/cgb_boot_fast.bin: BootROMs/cgb_boot.asm
|
|
|
|
$(BIN)/BootROMs/sgb2_boot: BootROMs/sgb_boot.asm
|
|
|
|
|
2020-05-03 20:44:13 +00:00
|
|
|
$(BIN)/BootROMs/%.bin: BootROMs/%.asm $(OBJ)/BootROMs/SameBoyLogo.pb12
|
2016-08-20 14:51:17 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2019-06-10 15:45:14 +00:00
|
|
|
rgbasm -i $(OBJ)/BootROMs/ -i BootROMs/ -o $@.tmp $<
|
2016-03-30 20:07:55 +00:00
|
|
|
rgblink -o $@.tmp2 $@.tmp
|
2020-01-01 20:57:24 +00:00
|
|
|
dd if=$@.tmp2 of=$@ count=1 bs=$(if $(findstring dmg,$@)$(findstring sgb,$@),256,2304) 2> $(NULL)
|
2016-03-30 20:07:55 +00:00
|
|
|
@rm $@.tmp $@.tmp2
|
|
|
|
|
2017-10-12 19:40:48 +00:00
|
|
|
# Libretro Core (uses its own build system)
|
|
|
|
libretro:
|
2020-04-28 18:44:29 +00:00
|
|
|
CFLAGS="$(WARNINGS)" $(MAKE) -C libretro
|
2019-07-16 20:58:16 +00:00
|
|
|
|
2021-02-27 02:13:50 +00:00
|
|
|
# install for Linux/FreeDesktop/etc.
|
|
|
|
# Does not install mimetype icons because FreeDesktop is cursed abomination with no right to exist.
|
|
|
|
# If you somehow find a reasonable way to make associate an icon with an extension in this dumpster
|
|
|
|
# fire of a desktop environment, open an issue or a pull request
|
2021-02-28 12:51:58 +00:00
|
|
|
ifneq ($(FREEDESKTOP),)
|
2021-02-27 15:34:11 +00:00
|
|
|
ICON_NAMES := apps/sameboy mimetypes/x-gameboy-rom mimetypes/x-gameboy-color-rom
|
2021-02-27 02:13:50 +00:00
|
|
|
ICON_SIZES := 16x16 32x32 64x64 128x128 256x256 512x512
|
|
|
|
ICONS := $(foreach name,$(ICON_NAMES), $(foreach size,$(ICON_SIZES),$(DESTDIR)$(PREFIX)/share/icons/hicolor/$(size)/$(name).png))
|
2021-02-27 16:39:14 +00:00
|
|
|
install: sdl $(DESTDIR)$(PREFIX)/share/mime/packages/sameboy.xml $(ICONS) FreeDesktop/sameboy.desktop
|
2021-02-28 13:17:00 +00:00
|
|
|
-@$(MKDIR) -p $(dir $(DESTDIR)$(PREFIX))
|
2021-03-25 18:17:45 +00:00
|
|
|
mkdir -p $(DESTDIR)$(DATA_DIR)/ $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
cp -rf $(BIN)/SDL/* $(DESTDIR)$(DATA_DIR)/
|
2021-03-30 15:29:55 +00:00
|
|
|
mv $(DESTDIR)$(DATA_DIR)/sameboy $(DESTDIR)$(PREFIX)/bin/sameboy
|
2021-02-27 02:13:50 +00:00
|
|
|
ifeq ($(DESTDIR),)
|
2021-02-27 16:39:14 +00:00
|
|
|
-update-mime-database -n $(PREFIX)/share/mime
|
|
|
|
-xdg-desktop-menu install --novendor --mode system FreeDesktop/sameboy.desktop
|
2021-02-27 02:13:50 +00:00
|
|
|
-xdg-icon-resource forceupdate --mode system
|
|
|
|
-xdg-desktop-menu forceupdate --mode system
|
2021-02-28 13:17:00 +00:00
|
|
|
ifneq ($(SUDO_USER),)
|
2021-02-27 15:34:11 +00:00
|
|
|
-su $(SUDO_USER) -c "xdg-desktop-menu forceupdate --mode system"
|
2021-02-27 02:13:50 +00:00
|
|
|
endif
|
2021-02-28 13:17:00 +00:00
|
|
|
else
|
2021-02-28 18:41:58 +00:00
|
|
|
-@$(MKDIR) -p $(DESTDIR)$(PREFIX)/share/applications/
|
2021-02-28 13:17:00 +00:00
|
|
|
cp FreeDesktop/sameboy.desktop $(DESTDIR)$(PREFIX)/share/applications/sameboy.desktop
|
|
|
|
endif
|
2021-02-27 02:13:50 +00:00
|
|
|
|
|
|
|
$(DESTDIR)$(PREFIX)/share/icons/hicolor/%/apps/sameboy.png: FreeDesktop/AppIcon/%.png
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
|
|
|
|
2021-02-27 15:34:11 +00:00
|
|
|
$(DESTDIR)$(PREFIX)/share/icons/hicolor/%/mimetypes/x-gameboy-rom.png: FreeDesktop/Cartridge/%.png
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
|
|
|
|
|
|
|
$(DESTDIR)$(PREFIX)/share/icons/hicolor/%/mimetypes/x-gameboy-color-rom.png: FreeDesktop/ColorCartridge/%.png
|
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
|
|
|
|
2021-02-27 16:39:14 +00:00
|
|
|
$(DESTDIR)$(PREFIX)/share/mime/packages/sameboy.xml: FreeDesktop/sameboy.xml
|
2021-02-27 02:13:50 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
|
|
|
cp -f $^ $@
|
|
|
|
endif
|
|
|
|
|
2016-08-20 14:51:17 +00:00
|
|
|
# Clean
|
2016-03-30 20:07:55 +00:00
|
|
|
clean:
|
2017-10-12 19:40:48 +00:00
|
|
|
rm -rf build
|
|
|
|
|
2020-04-25 14:57:19 +00:00
|
|
|
.PHONY: libretro tester
|