Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building universal binaries on macOS. #150

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
hiro/qt/qt.moc
.DS_store
3 changes: 3 additions & 0 deletions bsnes/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*)
4 changes: 2 additions & 2 deletions bsnes/obj/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.o
*.d
*
!.gitignore
4 changes: 2 additions & 2 deletions bsnes/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bsnes
bsnes.exe
*
!.gitignore
6 changes: 6 additions & 0 deletions bsnes/target-bsnes/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
13 changes: 12 additions & 1 deletion hiro/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] && \
$(compiler) $(hiro.flags) $(flags.amd64) $(flags) $(flags.deps) -c $< -o [email protected] && \
lipo -create -output $@ [email protected] [email protected] \
)
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 $< ...)
Expand Down
33 changes: 25 additions & 8 deletions nall/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ endif
ifeq ($(platform),macos)
flags += -stdlib=libc++
options += -lc++ -lobjc
flags.arm64 += -target x86_64-apple-macos10.12
flags.amd64 += -target arm64-apple-macos11
universal := true
endif

# linux settings
Expand Down Expand Up @@ -166,14 +169,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 [email protected] && \
$(compiler.c) $(flags.amd64) $(flags.deps) $(flags) $1 -c $< -o [email protected] && \
,$(if $(filter %.cpp,$<), \
$(compiler.cpp) $(flags.arm64) $(flags.deps) $(flags) $1 -c $< -o [email protected] && \
$(compiler.cpp) $(flags.amd64) $(flags.deps) $(flags) $1 -c $< -o [email protected] && \
)) \
lipo -create -output $@ [email protected] [email protected] \
)
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 = \
Expand Down
13 changes: 12 additions & 1 deletion ruby/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] && \
$(compiler) $(ruby.flags) $(flags.amd64) $(flags) $(flags.deps) -c $< -o [email protected] && \
lipo -create -output $@ [email protected] [email protected] \
)
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:)
Expand Down