Improved Makefiles (from h0tw1r3's PR): macOS Makefile will download SDL2 Framework, hopefully fixed Musashi dependency issues that occasionally affect parallel builds

This commit is contained in:
Bart Trzynadlowski 2024-07-22 20:54:06 -07:00 committed by Bart Trzynadlowski
parent 2df8511e56
commit e636dd5fb2
5 changed files with 240 additions and 140 deletions

View file

@ -1,7 +1,7 @@
##
## Supermodel
## A Sega Model 3 Arcade Emulator.
## Copyright 2003-2022 The Supermodel Team
## Copyright 2003-2024 The Supermodel Team
##
## This file is part of Supermodel.
##
@ -32,6 +32,12 @@
DELETE = rm -d -r -f
###############################################################################
# Release Package Options
###############################################################################
PKG_TYPE = tgz
PKG_FILES = Frameworks/*.framework
###############################################################################
# Platform Configuration
@ -62,11 +68,12 @@ ifeq ($(strip $(NET_BOARD)),1)
endif
#
# OSX-specific
# macOS-specific
#
PLATFORM_CXXFLAGS = $(SDL_CFLAGS) -DSUPERMODEL_OSX -F/Library/Frameworks/ -O3
PLATFORM_LDFLAGS = $(SDL_LIBS) -lz -lm -lstdc++ -F/Library/Frameworks/
PLATFORM_CXXFLAGS = -F./Frameworks $(SDL_CFLAGS) -DSUPERMODEL_OSX
PLATFORM_LDFLAGS = -F./Frameworks $(SDL_LIBS) -lz -lm -lstdc++ -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,@executable_path/Frameworks
PLATFORM_DIRS = Frameworks/SDL2_net.framework Frameworks/SDL2.framework
###############################################################################
@ -79,6 +86,52 @@ PLATFORM_SRC_FILES = \
include Makefiles/Rules.inc
clean:
$(SILENT)echo Cleaning up \"$(BIN_DIR)\" and \"$(OBJ_DIR)\"...
$(SILENT)echo Cleaning up \"Frameworks\", \"$(BIN_DIR)\" and \"$(OBJ_DIR)\"...
$(SILENT)$(DELETE) $(BIN_DIR)
$(SILENT)$(DELETE) $(OBJ_DIR)
$(SILENT)$(DELETE) Frameworks/SDL2.* Frameworks/SDL2_net.*
###############################################################################
# SDL2 Frameworks
#
# SDL2 can be installed in different seemingly incompatible ways on macOS. The
# simplest solution appears to be to download the framework files from the
# official SDL repo.
###############################################################################
Frameworks:
$(info Creating directory : $@)
$(SILENT)mkdir Frameworks
Frameworks/SDL2.dmg.url: | Frameworks
$(info Finding Latest Release : $@)
$(SILENT)curl --retry 5 --retry-delay 2 --fail-with-body -s https://api.github.com/repos/libsdl-org/SDL/releases/latest | awk '/"browser_download_url": "(.*\.dmg)"/{m++; if (m>1) exit; print $$2 }' | tr -d '"' > $@
Frameworks/SDL2_net.dmg.url: | Frameworks
$(info Finding Latest Release : $@)
$(SILENT)curl --retry 5 --retry-delay 2 --fail-with-body -s https://api.github.com/repos/libsdl-org/SDL_net/releases/latest | awk '/"browser_download_url": "(.*\.dmg)"/{m++; if (m>1) exit; print $$2 }' | tr -d '"' > $@
Frameworks/SDL2.dmg: Frameworks/SDL2.dmg.url
$(info Downloading : $(shell cat $@.url))
$(SILENT)curl "$(shell cat $@.url)" -sfL --output $@
Frameworks/SDL2_net.dmg: Frameworks/SDL2_net.dmg.url
$(info Downloading : $(shell cat $@.url))
$(SILENT)curl "$(shell cat $@.url)" -sfL --output $@
Frameworks/SDL2.framework: Frameworks/SDL2.dmg
$(info Extracting : $@)
$(SILENT)hdiutil attach -quiet Frameworks/SDL2.dmg
$(SILENT)cp -r /Volumes/SDL2/SDL2.framework Frameworks
$(SILENT)xattr -dr com.apple.quarantine $@
$(SILENT)hdiutil detach -quiet /Volumes/SDL2
$(SILENT)touch $@
Frameworks/SDL2_net.framework: Frameworks/SDL2_net.dmg
$(info Extracting : $@)
$(SILENT)hdiutil attach -quiet Frameworks/SDL2_net.dmg
$(SILENT)cp -r /Volumes/SDL2_net/SDL2_net.framework Frameworks
$(SILENT)xattr -dr com.apple.quarantine $@
$(SILENT)hdiutil detach -quiet /Volumes/SDL2_net
$(SILENT)touch $@

View file

@ -1,7 +1,7 @@
##
## Supermodel
## A Sega Model 3 Arcade Emulator.
## Copyright 2003-2022 The Supermodel Team
## Copyright 2003-2024 The Supermodel Team
##
## This file is part of Supermodel.
##
@ -33,6 +33,12 @@
DELETE = rm -d -r -f
###############################################################################
# Release Package Options
###############################################################################
PKG_TYPE = tgz
###############################################################################
# Platform Configuration
#
@ -57,13 +63,16 @@ LD = gcc
SDL2_CFLAGS = `sdl2-config --cflags`
SDL2_LIBS = `sdl2-config --libs`
ifeq ($(strip $(NET_BOARD)),1)
SDL2_LIBS += -lSDL2_net
endif
#
# UNIX-specific
#
PLATFORM_CXXFLAGS = $(SDL2_CFLAGS) -O3
PLATFORM_LDFLAGS = $(SDL2_LIBS) -lGL -lGLU -lz -lm -lstdc++ -lpthread -lSDL2_net
PLATFORM_LDFLAGS = $(SDL2_LIBS) -lGL -lGLU -lz -lm -lstdc++ -lpthread
###############################################################################

View file

@ -1,7 +1,7 @@
##
## Supermodel
## A Sega Model 3 Arcade Emulator.
## Copyright 2003-2022 The Supermodel Team
## Copyright 2003-2024 The Supermodel Team
##
## This file is part of Supermodel.
##
@ -41,17 +41,17 @@
#
include Makefiles/Options.inc
###############################################################################
# Release Package Options
###############################################################################
PKG_TYPE = zip
#
# Bitness of build ('32' or '64')
#
BITS = 64
#
# Path to SDL2
#
SDL2_INCLUDE_DIR = \msys64\mingw64\include\SDL2
SDL2_LIB_DIR = \msys64\mingw64\lib
#
# Toolchain
#
@ -82,8 +82,17 @@ endif
#
# SDL2
#
SDL2_LIBS = -lmingw32 -lSDL2main -lSDL2 -Wl,--no-undefined -lshell32 -lsetupapi -ladvapi32 -luuid -lversion -limm32 -lwinmm -lgdi32 -luser32 -lm -pipe
SDL2_CFLAGS =
ifneq (,$(findstring cmd.exe,$(shell echo %COMSPEC%)))
# When building in Command Prompt, we don't have sdl2-config and must hard-code the SDL2 include
# and library directories
SDL2_INCLUDE_DIR = \msys64\mingw64\include\SDL2
SDL2_LIB_DIR = \msys64\mingw64\lib
SDL2_LIBS = -lmingw32 -lSDL2main -lSDL2 -Wl,--no-undefined -lshell32 -lsetupapi -ladvapi32 -luuid -lversion -limm32 -lwinmm -lgdi32 -luser32 -lm -pipe
SDL2_CFLAGS =
else
SDL2_LIBS = `sdl2-config --static-libs`
SDL2_CFLAGS = `sdl2-config --cflags | sed 's/-Dmain=SDL_main//'`
endif
ifeq ($(strip $(NET_BOARD)),1)
SDL2_LIBS += -lSDL2_net -liphlpapi
endif
@ -109,8 +118,6 @@ PLATFORM_SRC_FILES = \
Src/OSD/Windows/WinOutputs.cpp \
Src/OSD/Windows/SupermodelResources.rc
.PHONY: clean
include Makefiles/Rules.inc
clean:
@ -125,6 +132,6 @@ clean:
# This section must be placed *after* the inclusion of Makefiles/Rules.inc.
###############################################################################
$(OBJ_DIR)/SupermodelResources.o: Src/OSD/Windows/SupermodelResources.rc Src/OSD/Windows/SupermodelManifest.xml
$(OBJ_DIR)/SupermodelResources.o: Src/OSD/Windows/SupermodelResources.rc Src/OSD/Windows/SupermodelManifest.xml | $(OBJ_DIR)
$(info Compiling : $< -> $@)
$(SILENT)windres -i Src/OSD/Windows/SupermodelResources.rc -o $@

View file

@ -1,7 +1,7 @@
##
## Supermodel
## A Sega Model 3 Arcade Emulator.
## Copyright 2003-2022 The Supermodel Team
## Copyright 2003-2024 The Supermodel Team
##
## This file is part of Supermodel.
##

View file

@ -1,7 +1,7 @@
##
## Supermodel
## A Sega Model 3 Arcade Emulator.
## Copyright 2003-2022 The Supermodel Team
## Copyright 2003-2024 The Supermodel Team
##
## This file is part of Supermodel.
##
@ -73,6 +73,7 @@ OPT = -O3
WARN = -Wall
CSTD = -std=iso9899:2011
CXXSTD = -std=c++17
LDOPT = -s
#
@ -81,7 +82,7 @@ CXXSTD = -std=c++17
COMMON_CFLAGS = -c $(ARCH) $(OPT) $(WARN) $(addprefix -I,$(sort $(INCLUDE_DIRS))) -DGLEW_STATIC $(SUPERMODEL_BUILD_FLAGS)
CFLAGS = $(COMMON_CFLAGS) $(CSTD)
CXXFLAGS = $(PLATFORM_CXXFLAGS) $(COMMON_CFLAGS) $(CXXSTD)
LDFLAGS = -o $(BIN_DIR)/$(OUTFILE) $(PLATFORM_LDFLAGS) -s
LDFLAGS = -o $(BIN_DIR)/$(OUTFILE) $(PLATFORM_LDFLAGS) $(LDOPT)
###############################################################################
@ -223,22 +224,52 @@ all: $(BIN_DIR)/$(OUTFILE)
# version number. Double-colon rules should force ordered execution.
# The automated build script relies on these -- don't modify their output!
#
.PHONY: clean
.PHONY: set_version
.PHONY: print_message
.PHONY: version
release:: set_version
release:: print_message
release:: clean
release:: print_message
release:: all
PKG_FILES += $(BIN_DIR)/$(OUTFILE) Docs/README.txt Docs/LICENSE.txt Config Assets
pkg: pkg/$(PKG_TYPE)
$(info Cleaning up : $(PKG_STAGE_PATH))
$(SILENT)cd pkg && rm -r $(notdir $(PKG_STAGE_PATH))
pkg/tgz: pkg/stage
$(info Creating package : $(PKG_PATH))
$(SILENT)tar -C pkg -czf $(PKG_PATH) $(notdir $(PKG_STAGE_PATH))
pkg/zip: pkg/stage
$(info Creating package : $(PKG_STAGE_PATH).zip)
$(SILENT)cd pkg && zip -r $(notdir $(PKG_PATH)) $(notdir $(PKG_STAGE_PATH))
pkg/stage:: all
pkg/stage:: pkg/path
$(info Staging package : $(PKG_STAGE_PATH))
$(SILENT)rm -rf $(PKG_PATH) $(PKG_STAGE_PATH) ; mkdir -p $(PKG_STAGE_PATH)
$(SILENT)tar -cf - $(PKG_FILES) | tar -C $(PKG_STAGE_PATH) -xf -
$(SILENT)cd $(PKG_STAGE_PATH) && \
mkdir NVRAM Saves ROMs && \
echo "NVRAM files go here." > NVRAM/DIR.txt && \
echo "Save states go here." > Saves/DIR.txt && \
echo "Recommended (but not mandatory) location for ROM sets." > ROMs/DIR.txt && \
mv $(BIN_DIR)/$(OUTFILE) . && rmdir $(BIN_DIR) && \
mv Docs//* . && rmdir Docs
$(info Generating : $(PKG_STAGE_PATH)/CHANGES.txt)
$(SILENT)OUTPUT=$(PKG_STAGE_PATH)/CHANGES.txt ./Scripts/changelog.sh
pkg/path: set_version
$(eval PKG_STAGE_PATH = pkg/supermodel-$(VERSION))
$(eval PKG_PATH = pkg/supermodel-$(VERSION).$(PKG_TYPE))
@echo $(PKG_PATH)
set_version:
$(eval VERSION = $(strip $(subst ',,0.3a-git-$(shell git rev-parse --short HEAD --sq))))
$(eval SUPERMODEL_BUILD_FLAGS += -DSUPERMODEL_VERSION=\"$(VERSION)\")
print_message:
print_message: set_version
$(info Building Supermodel Version $(VERSION))
version: set_version
@echo $(VERSION)
$(BIN_DIR)/$(OUTFILE): $(BIN_DIR) $(OBJ_DIR) $(OBJ_FILES)
$(BIN_DIR)/$(OUTFILE): $(BIN_DIR) $(OBJ_FILES)
$(info --------------------------------------------------------------------------------)
$(info Linking Supermodel : $(BIN_DIR)/$(OUTFILE))
$(SILENT)$(LD) $(OBJ_FILES) $(LDFLAGS)
@ -248,7 +279,7 @@ $(BIN_DIR):
$(info Creating directory : $(BIN_DIR))
$(SILENT)mkdir $(BIN_DIR)
$(OBJ_DIR):
$(OBJ_DIR): | $(PLATFORM_DIRS)
$(info Creating directory : $(OBJ_DIR))
$(SILENT)mkdir $(OBJ_DIR)
@ -275,13 +306,13 @@ VPATH = $(INCLUDE_DIRS)
# the source code. This technique is described in the reply by user "rr-" at:
# https://stackoverflow.com/questions/8025766/makefile-auto-dependency-generation
#
$(OBJ_DIR)/%.o: %.cpp
$(OBJ_DIR)/%.o: %.cpp | $(OBJ_DIR)
$(info Generating dependencies: $< -> $(OBJ_DIR)/$(*F).d)
$(SILENT)$(CXX) -MM -MP -MT $(OBJ_DIR)/$(*F).o -MT $(OBJ_DIR)/$(*F).d $(CXXFLAGS) $< > $(OBJ_DIR)/$(*F).d
$(info Compiling : $< -> $@)
$(SILENT)$(CXX) $(CXXFLAGS) $< -o $@
$(OBJ_DIR)/%.o: %.c
$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR)
$(info Generating dependencies: $< -> $(OBJ_DIR)/$(*F).d)
$(SILENT)$(CC) -MM -MP -MT $(OBJ_DIR)/$(*F).o -MT $(OBJ_DIR)/$(*F).d $(CFLAGS) $< > $(OBJ_DIR)/$(*F).d
$(info Compiling : $< -> $@)
@ -301,33 +332,33 @@ MUSASHI_OUTFILE = $(OBJ_DIR)/m68kmake.exe # do not remove the .exe suffix!
MUSASHI_CFLAGS = -ISrc/CPU/68K/Musashi -I$(OBJ_DIR) -DINLINE="static inline" -Wno-unused-variable
MUSASHI_LDFLAGS = -o $(MUSASHI_OUTFILE) $(OBJ_DIR)/m68kmake.o -s
$(MUSASHI_OUTFILE): Src/CPU/68K/Musashi/m68kmake.c Src/CPU/68K/Musashi/m68k_in.c
$(MUSASHI_OUTFILE): Src/CPU/68K/Musashi/m68kmake.c Src/CPU/68K/Musashi/m68k_in.c | $(OBJ_DIR)
$(info --------------------------------------------------------------------------------)
$(info Compiling : $< -> $(OBJ_DIR)/m68kmake.o)
$(SILENT)$(CC) $< $(CFLAGS) -o $(OBJ_DIR)/m68kmake.o
$(info Linking : $(MUSASHI_OUTFILE))
$(SILENT)$(LD) $(MUSASHI_LDFLAGS)
$(OBJ_DIR)/m68kops.h $(OBJ_DIR)/m68kops.c $(OBJ_DIR)/m68kopac.c $(OBJ_DIR)/m68kopdm.c $(OBJ_DIR)/m68kopnz.c: $(MUSASHI_OUTFILE) Src/CPU/68K/Musashi/m68k_in.c Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h
$(OBJ_DIR)/m68kops.h $(OBJ_DIR)/m68kops.c $(OBJ_DIR)/m68kopac.c $(OBJ_DIR)/m68kopdm.c $(OBJ_DIR)/m68kopnz.c: $(MUSASHI_OUTFILE) Src/CPU/68K/Musashi/m68k_in.c Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h | $(OBJ_DIR)
$(info Generating 68K emulator: $@)
@$(MUSASHI_OUTFILE) $(OBJ_DIR) Src/CPU/68K/Musashi/m68k_in.c
$(OBJ_DIR)/m68kcpu.o: Src/CPU/68K/Musashi/m68kcpu.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h
$(OBJ_DIR)/m68kcpu.o: Src/CPU/68K/Musashi/m68kcpu.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h | $(OBJ_DIR)
$(info Compiling : $< -> $@)
@$(CC) $< $(CFLAGS) $(MUSASHI_CFLAGS) -o $(OBJ_DIR)/m68kcpu.o
$(OBJ_DIR)/m68kops.o: $(OBJ_DIR)/m68kops.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE)
$(OBJ_DIR)/m68kops.o: $(OBJ_DIR)/m68kops.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE) | $(OBJ_DIR)
$(info Compiling : $< -> $@)
@$(CC) $< $(CFLAGS) $(MUSASHI_CFLAGS) -o $@
$(OBJ_DIR)/m68kopac.o: $(OBJ_DIR)/m68kopac.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE)
$(OBJ_DIR)/m68kopac.o: $(OBJ_DIR)/m68kopac.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE) | $(OBJ_DIR)
$(info Compiling : $< -> $@)
@$(CC) $< $(CFLAGS) $(MUSASHI_CFLAGS) -o $@
$(OBJ_DIR)/m68kopdm.o: $(OBJ_DIR)/m68kopdm.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE)
$(OBJ_DIR)/m68kopdm.o: $(OBJ_DIR)/m68kopdm.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE) | $(OBJ_DIR)
$(info Compiling : $< -> $@)
@$(CC) $< $(CFLAGS) $(MUSASHI_CFLAGS) -o $@
$(OBJ_DIR)/m68kopnz.o: $(OBJ_DIR)/m68kopnz.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE)
$(OBJ_DIR)/m68kopnz.o: $(OBJ_DIR)/m68kopnz.c $(OBJ_DIR)/m68kops.h Src/CPU/68K/Musashi/m68k.h Src/CPU/68K/Musashi/m68kconf.h $(MUSASHI_OUTFILE) | $(OBJ_DIR)
$(info Compiling : $< -> $@)
@$(CC) $< $(CFLAGS) $(MUSASHI_CFLAGS) -o $@