From c26ffeea2a1d5b55896ed9de335745881648b764 Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Wed, 10 Feb 2021 19:17:10 -0800 Subject: [PATCH 1/3] Update .gitignore files to be better on macOS. Adds .DS_store to global ignore. Makes obj and out ignores more general. --- .gitignore | 1 + bsnes/obj/.gitignore | 4 ++-- bsnes/out/.gitignore | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8052edb32..646d8828e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ hiro/qt/qt.moc +.DS_store diff --git a/bsnes/obj/.gitignore b/bsnes/obj/.gitignore index 6142305dc..d6b7ef32c 100644 --- a/bsnes/obj/.gitignore +++ b/bsnes/obj/.gitignore @@ -1,2 +1,2 @@ -*.o -*.d +* +!.gitignore diff --git a/bsnes/out/.gitignore b/bsnes/out/.gitignore index 1aeaff24b..d6b7ef32c 100644 --- a/bsnes/out/.gitignore +++ b/bsnes/out/.gitignore @@ -1,2 +1,2 @@ -bsnes -bsnes.exe +* +!.gitignore From 1f75ba8912d84bba918033d546ef3333f12e4150 Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Wed, 10 Feb 2021 19:21:03 -0800 Subject: [PATCH 2/3] Support for building universal macOS binaries. --- bsnes/GNUmakefile | 3 +++ bsnes/target-bsnes/GNUmakefile | 6 ++++++ hiro/GNUmakefile | 13 ++++++++++++- nall/GNUmakefile | 32 ++++++++++++++++++++++++-------- ruby/GNUmakefile | 13 ++++++++++++- 5 files changed, 57 insertions(+), 10 deletions(-) diff --git a/bsnes/GNUmakefile b/bsnes/GNUmakefile index 9450f39ce..2b365bc9e 100644 --- a/bsnes/GNUmakefile +++ b/bsnes/GNUmakefile @@ -60,5 +60,8 @@ include $(ui)/GNUmakefile -include obj/*.d clean: +ifeq ($(platform),macos) + rm -rf out/$(name).app +endif $(call delete,obj/*) $(call delete,out/*) diff --git a/bsnes/target-bsnes/GNUmakefile b/bsnes/target-bsnes/GNUmakefile index c693a2ed9..fe303d13c 100644 --- a/bsnes/target-bsnes/GNUmakefile +++ b/bsnes/target-bsnes/GNUmakefile @@ -21,7 +21,13 @@ obj/ui-resource.o: $(ui)/resource/resource.cpp all: $(hiro.objects) $(ruby.objects) $(objects) $(info Linking out/$(name) ...) +ifeq ($(universal),true) + +@$(compiler) -o obj/$(name).arm64 $(hiro.objects) $(ruby.objects) $(objects) $(hiro.options) $(ruby.options) $(options) $(flags.arm64) + +@$(compiler) -o obj/$(name).amd64 $(hiro.objects) $(ruby.objects) $(objects) $(hiro.options) $(ruby.options) $(options) $(flags.amd64) + lipo -create -output out/$(name) obj/$(name).arm64 obj/$(name).amd64 +else +@$(compiler) -o out/$(name) $(hiro.objects) $(ruby.objects) $(objects) $(hiro.options) $(ruby.options) $(options) +endif ifeq ($(platform),macos) rm -rf out/$(name).app mkdir -p out/$(name).app/Contents/MacOS/ diff --git a/hiro/GNUmakefile b/hiro/GNUmakefile index 04837b274..918598e34 100755 --- a/hiro/GNUmakefile +++ b/hiro/GNUmakefile @@ -66,11 +66,22 @@ hiro.objects := \ $(object.path)/hiro-$(hiro).o \ $(if $(filter windows,$(hiro)),$(object.path)/hiro-resource.o) +ifeq ($(universal),true) + compile.hiro = \ + $(strip \ + $(compiler) $(hiro.flags) $(flags.arm64) $(flags) $(flags.deps) -c $< -o $@.arm64 && \ + $(compiler) $(hiro.flags) $(flags.amd64) $(flags) $(flags.deps) -c $< -o $@.amd64 && \ + lipo -create -output $@ $@.arm64 $@.amd64 \ + ) +else + compile.hiro = $(strip $(compiler) $(hiro.flags) $(flags) $(flags.deps) -c $< -o $@) +endif + $(object.path)/hiro-$(hiro).o: $(hiro.path)/hiro.cpp $(if $(filter qt%,$(hiro)),$(info Compiling $(hiro.path)/qt/qt.moc ...)) $(if $(filter qt%,$(hiro)),@$(moc) -i -o $(hiro.path)/qt/qt.moc $(hiro.path)/qt/qt.hpp) $(info Compiling $< ...) - @$(compiler) $(hiro.flags) $(flags) $(flags.deps) -c $< -o $@ + @$(call compile.hiro) $(object.path)/hiro-resource.o: $(hiro.resource) $(info Compiling $< ...) diff --git a/nall/GNUmakefile b/nall/GNUmakefile index f064ae772..c285f29a7 100755 --- a/nall/GNUmakefile +++ b/nall/GNUmakefile @@ -124,6 +124,8 @@ endif ifeq ($(platform),macos) flags += -stdlib=libc++ options += -lc++ -lobjc + flags.arm64 += -target x86_64-apple-macos10.12 + flags.amd64 += -target arm64-apple-macos11 endif # linux settings @@ -166,14 +168,28 @@ nall.verbose: @$(call compile) # function compile([arguments]) -compile = \ - $(strip \ - $(if $(filter %.c,$<), \ - $(compiler.c) $(flags.deps) $(flags) $1 -c $< -o $@ \ - ,$(if $(filter %.cpp,$<), \ - $(compiler.cpp) $(flags.deps) $(flags) $1 -c $< -o $@ \ - )) \ - ) +ifeq ($(universal),true) + compile = \ + $(strip \ + $(if $(filter %.c,$<), \ + $(compiler.c) $(flags.arm64) $(flags.deps) $(flags) $1 -c $< -o $@.arm64 && \ + $(compiler.c) $(flags.amd64) $(flags.deps) $(flags) $1 -c $< -o $@.amd64 && \ + ,$(if $(filter %.cpp,$<), \ + $(compiler.cpp) $(flags.arm64) $(flags.deps) $(flags) $1 -c $< -o $@.arm64 && \ + $(compiler.cpp) $(flags.amd64) $(flags.deps) $(flags) $1 -c $< -o $@.amd64 && \ + )) \ + lipo -create -output $@ $@.arm64 $@.amd64 \ + ) +else + compile = \ + $(strip \ + $(if $(filter %.c,$<), \ + $(compiler.c) $(flags.deps) $(flags) $1 -c $< -o $@ \ + ,$(if $(filter %.cpp,$<), \ + $(compiler.cpp) $(flags.deps) $(flags) $1 -c $< -o $@ \ + )) \ + ) +endif # function rwildcard(directory, pattern) rwildcard = \ diff --git a/ruby/GNUmakefile b/ruby/GNUmakefile index f27418b2f..406d275de 100755 --- a/ruby/GNUmakefile +++ b/ruby/GNUmakefile @@ -71,9 +71,20 @@ endif ruby.objects := $(object.path)/ruby.o +ifeq ($(universal),true) + compile.ruby = \ + $(strip \ + $(compiler) $(ruby.flags) $(flags.arm64) $(flags) $(flags.deps) -c $< -o $@.arm64 && \ + $(compiler) $(ruby.flags) $(flags.amd64) $(flags) $(flags.deps) -c $< -o $@.amd64 && \ + lipo -create -output $@ $@.arm64 $@.amd64 \ + ) +else + compile.ruby = $(strip $(compiler) $(ruby.flags) $(flags) $(flags.deps) -c $< -o $@) +endif + $(object.path)/ruby.o: $(ruby.path)/ruby.cpp $(call rwildcard,$(ruby.path)) $(info Compiling $< ...) - @$(compiler) $(ruby.flags) $(flags) $(flags.deps) -c $< -o $@ + @$(call compile.ruby) ruby.verbose: $(info ruby Drivers:) From b7874e89c4be602d745c3cc97f1fd9c60f7cd73d Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Wed, 10 Feb 2021 19:23:28 -0800 Subject: [PATCH 3/3] Default to building a universal binary on macOS. --- nall/GNUmakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/nall/GNUmakefile b/nall/GNUmakefile index c285f29a7..2bbc3176b 100755 --- a/nall/GNUmakefile +++ b/nall/GNUmakefile @@ -126,6 +126,7 @@ ifeq ($(platform),macos) options += -lc++ -lobjc flags.arm64 += -target x86_64-apple-macos10.12 flags.amd64 += -target arm64-apple-macos11 + universal := true endif # linux settings