diff options
author | bjarni <bjarni@openttd.org> | 2006-03-15 14:03:09 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-03-15 14:03:09 +0000 |
commit | 3ebc41c9fed6aa3f496884f452b9aaac62da6a3d (patch) | |
tree | 303fd17ea514eea165d715e87f7a62438f9a60d3 /os/macosx | |
parent | 63a181f3969c23c9de1c69be8507471c22a084fb (diff) | |
download | openttd-3ebc41c9fed6aa3f496884f452b9aaac62da6a3d.tar.xz |
(svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
Instead of compiling a binary for each arch and then join them in the end, each .o file is now compiled as a fat file
This means that the makefile will not call itself to make a binary for each target and we don't have to make clean between each build
it also means that if one file changed, we don't have to recompile all files
Another benefit is since it's handled at .o level and though LDFLAGS, no special code is needed if we decide to compile more binaries (like a lot of stuff used to happen at post linking)
We also needs much less flags to set up, so it should be even easier to get to work out of the box now
The tradeoff in doing so is that now the binary needs at least OSX 10.3.9 to execute
To deal with this issue, the JAGUAR flag can be used to compile for older OSes. We will release a binary for old OSes at next release to see if anybody even downloads it (not that many people use OSX 10.2 anymore)
GPMI will not work on 10.2 anyway so we will cut support for it some day anyway
Diffstat (limited to 'os/macosx')
-rw-r--r-- | os/macosx/Makefile | 51 | ||||
-rw-r--r-- | os/macosx/Makefile.setup | 94 |
2 files changed, 46 insertions, 99 deletions
diff --git a/os/macosx/Makefile b/os/macosx/Makefile index 6e53126a7..02a7660e9 100644 --- a/os/macosx/Makefile +++ b/os/macosx/Makefile @@ -2,11 +2,29 @@ # This makefile is not a standalone makefile, but is called from the general one # it contains targets specific to MacOS X -ifdef UNIVERSAL_BINARY ifdef TRIPPLE_BINARY -TRIPPLE_BINARY:=tripple_binary -endif -UNIVERSAL_BINARY:=build_universal_binary +# this is to add G5_FLAGS to ppc970 builds only. If the ability to add flags to a single arch only shows up in the future +# we can get rid of this. Xcode supports arch dependant flags, but we can't do it in the makefile (yet?) +%.o: %.c $(MAKE_CONFIG) + @echo '===> Compiling $<' + $(Q)$(CC) $(CFLAGS) $(CDEFS) -arch ppc -c -arch i386 -o $@.uni $< + $(Q)$(CC) $(CFLAGS) $(CDEFS) $(G5_FLAGS) -arch ppc970 -c -o $@.ppc970 $< + $(Q)lipo -create -output $@ $@.uni $@.ppc970 + $(Q)rm $@.uni $@.ppc970 + +%.o: %.cpp $(MAKE_CONFIG) + @echo '===> Compiling $<' + $(Q)$(CXX) $(CFLAGS) $(CDEFS) -arch ppc -arch i386 -c -o $@.uni $< + $(Q)$(CXX) $(CFLAGS) $(CDEFS) $(G5_FLAGS) -arch ppc970 -c -o $@.ppc970 $< + $(Q)lipo -create -output $@ $@.uni $@.ppc970 + $(Q)rm $@.uni $@.ppc970 + +%.o: %.m $(MAKE_CONFIG) + @echo '===> Compiling $<' + $(Q)$(CC) $(CFLAGS) $(CDEFS) -arch ppc -arch i386 -c -o $@.uni $< + $(Q)$(CC) $(CFLAGS) $(CDEFS) -arch ppc970 $(G5_FLAGS) -c -o $@.ppc970 $< + $(Q)lipo -create -output $@ $@.uni $@.ppc970 + $(Q)rm $@.uni $@.ppc970 endif ifdef UNIVERSAL_PPC_PART @@ -16,31 +34,6 @@ else BUILD_OSX_BUNDLE:=build_OSX_bundle endif -# building an universal binary -# since we can only compile for PPC or x86 at any one time, we compile one and then -# we make clean and compile the other one. In the end we use lipo to join them together -# when this is done, we can continue with the targets from the first run, which is build_OSX_bundle - -$(UNIVERSAL_BINARY): $(TTD) - $(Q)mkdir -p temp_binary_dir - $(Q)cp $(TTD) temp_binary_dir/$(TTD)_a - $(Q)rm -rf $(TTD) $(OBJS) # delete all .o files so we can compile for a new CPU - $(Q)make UNIVERSAL_PPC_PART:=1 - $(Q)cp $(TTD) temp_binary_dir/$(TTD)_b - @echo '===> Joining the PPC and x86 binaries into one universal one' - $(Q)lipo temp_binary_dir/$(TTD)_a temp_binary_dir/$(TTD)_b -create -output $(TTD) - $(Q)rm -rf temp_binary_dir - -$(TRIPPLE_BINARY): $(UNIVERSAL_BINARY) - $(Q)mkdir -p temp_binary_dir - $(Q)cp $(TTD) temp_binary_dir/$(TTD)_a - $(Q)rm -rf $(TTD) $(OBJS) # delete all .o files so we can compile for a new CPU - $(Q)make UNIVERSAL_PPC_PART:=1 IS_G5:=1 - $(Q)cp $(TTD) temp_binary_dir/$(TTD)_b - @echo '===> Joining the Universal and G5 binaries into a tripple binary' - $(Q)lipo temp_binary_dir/$(TTD)_a temp_binary_dir/$(TTD)_b -create -output $(TTD) - $(Q)rm -rf temp_binary_dir - # build the bundle. OSX wants to keep apps in bundles, so we will give it one # the good thing about bundles is that you can keep extra files in them, so we keep lng files and a data dir in it diff --git a/os/macosx/Makefile.setup b/os/macosx/Makefile.setup index 7cfb6d965..d5419900b 100644 --- a/os/macosx/Makefile.setup +++ b/os/macosx/Makefile.setup @@ -47,80 +47,34 @@ endif endif # setup flags if none are defined -ifndef CFLAGS_PPC - CFLAGS_PPC:= -isysroot /Developer/SDKs/MacOSX10.2.8.sdk -endif -ifndef LDFLAGS_PPC - LDFLAGS_PPC:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk -endif -ifndef PPC_CC - PPC_CC:=$(shell ls /usr/bin/powerpc-apple-darwin*-gcc* | tail -n 1) -endif -ifndef CFLAGS_x86 - CFLAGS_x86:= -isysroot /Developer/SDKs/MacOSX10.4u.sdk -endif -ifndef LDFLAGS_x86 - LDFLAGS_x86:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -endif -ifndef x86_CC - x86_CC:=$(shell ls /usr/bin/i686-apple-darwin*-gcc* | tail -n 1) -endif -ifdef WITH_PNG - ifndef LIBPNG_PPC_CONFIG - LIBPNG_PPC_CONFIG:=$(LIBPNG-CONFIG) - endif - ifndef LIBPNG_x86_CONFIG - LIBPNG_x86_CONFIG:=$(LIBPNG-CONFIG) - endif -endif -ifdef WITH_SDL - ifndef SDL_PPC_CONFIG - SDL_PPC_CONFIG:=$(SDL-CONFIG) - endif - ifndef SDL_x86_CONFIG - SDL_x86_CONFIG:=$(SDL-CONFIG) - endif - ifndef x86_SDL_LIB - x86_SDL_LIB:=$(shell echo "`$(SDL_x86_CONFIG) --prefix`/lib/libSDL-1.2.0.dylib") - endif +ifndef CFLAGS_JAGUAR + CFLAGS_JAGUAR:= -isysroot /Developer/SDKs/MacOSX10.2.8.sdk +endif +ifndef LDFLAGS_JAGUAR + LDFLAGS_JAGUAR:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk +endif + +ifndef CFLAGS_UNIVERSAL + CFLAGS_UNIVERSAL:= -isysroot /Developer/SDKs/MacOSX10.4u.sdk +endif +ifndef LDFLAGS_UNIVERSAL + LDFLAGS_UNIVERSAL:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk endif ifdef JAGUAR - LIBPNG-CONFIG:=$(LIBPNG_PPC_CONFIG) - SDL-CONFIG:=$(SDL_PPC_CONFIG) - CC_TARGET:=$(PPC_CC) - CFLAGS:= $(CFLAGS_PPC) -arch ppc - LDFLAGS:= $(LDFLAGS_PPC) + CFLAGS:= $(CFLAGS_JAGUAR) -arch ppc + LDFLAGS:= $(LDFLAGS_JAGUAR) +endif + +ifndef G5_FLAGS +G5_FLAGS := -mtune=970 -mcpu=970 -mpowerpc-gpopt endif ifdef UNIVERSAL_BINARY - # set up config files - ifndef SKIP_LIB_TEST - ifdef WITH_PNG - TEST:=$(shell lipo -info `$(LIBPNG_PPC_CONFIG) --prefix`/lib/libpng.a | xargs -n 1 | grep "ppc")) - ifndef TEST -$(error no PPC libpng found) - endif - TEST:=$(shell lipo -info `$(LIBPNG_x86_CONFIG) --prefix`/lib/libpng.a | xargs -n 1 | grep "i386")) - ifndef TEST -$(error no x86 libpng found) - endif - endif - endif - LIBS:= - OBJS:= - ifdef UNIVERSAL_PPC_PART - LIBPNG-CONFIG:=$(LIBPNG_PPC_CONFIG) - SDL-CONFIG:=$(SDL_PPC_CONFIG) - CC_TARGET:=$(PPC_CC) - CFLAGS:= $(CFLAGS_PPC) -arch ppc - LDFLAGS:= $(LDFLAGS_PPC) - else - LIBPNG-CONFIG:=$(LIBPNG_x86_CONFIG) - SDL-CONFIG:=$(SDL_x86_CONFIG) - CC_TARGET:=$(x86_CC) - # clear the cached list of PPC libs - CFLAGS:= $(CFLAGS_x86) -arch i386 - LDFLAGS:= $(LDFLAGS_x86) - endif +TARGET_CPU_FLAGS:= -arch ppc -arch i386 +LDFLAGS := $(LDFLAGS_UNIVERSAL) -arch ppc -arch i386 +CFLAGS += $(CFLAGS_UNIVERSAL) +ifdef TRIPPLE_BINARY +LDFLAGS += -arch ppc970 +endif endif |