mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r3267) -Codechange: [OSX] universal binary makefile code cleanup
now PPC code is always compiled before x86 code strgen and lng files are only compiled once, which results in shorter building time the makefile now assigns default values to undefined values so much less needs to be set up the code is now easier to maintain
This commit is contained in:
parent
bab6f56967
commit
967abb24e4
25
Makefile
25
Makefile
@ -170,19 +170,6 @@ ifndef SDL-CONFIG
|
|||||||
CONFIG_INCLUDED:=
|
CONFIG_INCLUDED:=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef UNIVERSAL_OTHER_HALF
|
|
||||||
ifndef CC_HOST
|
|
||||||
# we are crosscompiling, so we should remember what compiler we should use for strgen
|
|
||||||
CC_HOST = $(CC)
|
|
||||||
endif
|
|
||||||
CC_TARGET = $(CC_UNI)
|
|
||||||
CFLAGS = $(CFLAGS_UNI)
|
|
||||||
LDFLAGS = $(LDFLAGS_UNI)
|
|
||||||
SDL-CONFIG = $(SDL-CONFIG_UNI)
|
|
||||||
LIBPNG-CONFIG = $(LIBPNG-CONFIG_UNI)
|
|
||||||
LIBS:=
|
|
||||||
endif
|
|
||||||
|
|
||||||
# this is used if there aren't any Makefile.config
|
# this is used if there aren't any Makefile.config
|
||||||
ifndef CONFIG_INCLUDED
|
ifndef CONFIG_INCLUDED
|
||||||
# sets network on by default if there aren't any config file
|
# sets network on by default if there aren't any config file
|
||||||
@ -203,6 +190,10 @@ ifdef SUPRESS_LANG_ERRORS
|
|||||||
LANG_ERRORS = >/dev/null 2>&1
|
LANG_ERRORS = >/dev/null 2>&1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef OSX
|
||||||
|
-include os/MacOSX/Makefile.setup
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef STATIC
|
ifdef STATIC
|
||||||
ifndef WIN32
|
ifndef WIN32
|
||||||
ifndef OSX
|
ifndef OSX
|
||||||
@ -215,14 +206,6 @@ endif
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef OSX
|
|
||||||
ifdef RELEASE
|
|
||||||
# all OSX releases needs to be static
|
|
||||||
# end users don't tend to have the dynamic libs installed
|
|
||||||
$(warning Compiling a dynamic release. It should be static unless you really know what you are doing!!!)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Force SDL on UNIX platforms
|
# Force SDL on UNIX platforms
|
||||||
ifndef WITH_SDL
|
ifndef WITH_SDL
|
||||||
ifdef UNIX
|
ifdef UNIX
|
||||||
|
@ -94,12 +94,18 @@ $(MAKE_CONFIG):
|
|||||||
$(call CONFIG_LINE,)
|
$(call CONFIG_LINE,)
|
||||||
|
|
||||||
$(call CONFIG_LINE,\# Universal binary setup)
|
$(call CONFIG_LINE,\# Universal binary setup)
|
||||||
$(call CONFIG_LINE,\# use these settings for the CPU type, that is not covered by the other settings)
|
$(call CONFIG_LINE,\# use these settings for building universal binaries. Most settings should work with the default settings)
|
||||||
$(call CONFIG_LINE,CC_UNI:=$(CC_UNI))
|
$(call CONFIG_LINE,UNIVERSAL_CFLAGS:=$(UNIVERSAL_CFLAGS))
|
||||||
$(call CONFIG_LINE,CFLAGS_UNI:=$(CFLAGS_UNI))
|
$(call CONFIG_LINE,UNIVERSAL_LDFLAGS:=$(UNIVERSAL_LDFLAGS))
|
||||||
$(call CONFIG_LINE,LDFLAGS_UNI:=$(LDFLAGS_UNI))
|
$(call CONFIG_LINE,SKIP_LIB_TEST:=$(SKIP_LIB_TEST))
|
||||||
$(call CONFIG_LINE,SDL-CONFIG_UNI:=$(SDL-CONFIG_UNI))
|
$(call CONFIG_LINE,PPC_CC:=$(PPC_CC))
|
||||||
$(call CONFIG_LINE,LIBPNG-CONFIG_UNI:=$(LIBPNG-CONFIG_UNI))
|
$(call CONFIG_LINE,SDL_PPC_CONFIG:=$(SDL_PPC_CONFIG))
|
||||||
|
$(call CONFIG_LINE,LIBPNG_PPC_CONFIG:=$(LIBPNG_PPC_CONFIG))
|
||||||
|
$(call CONFIG_LINE,x86_CC:=$(x86_CC))
|
||||||
|
$(call CONFIG_LINE,SDL_x86_CONFIG:=$(SDL_x86_CONFIG))
|
||||||
|
$(call CONFIG_LINE,LIBPNG_x86_CONFIG:=$(LIBPNG_x86_CONFIG))
|
||||||
|
$(call CONFIG_LINE,x86_SDL_LIB:=$(x86_SDL_LIB))
|
||||||
|
$(call CONFIG_LINE,)
|
||||||
|
|
||||||
$(call CONFIG_LINE,\# For cross-compiling)
|
$(call CONFIG_LINE,\# For cross-compiling)
|
||||||
$(call CONFIG_LINE,CC_TARGET:=$(CC_TARGET))
|
$(call CONFIG_LINE,CC_TARGET:=$(CC_TARGET))
|
||||||
|
@ -7,26 +7,8 @@ BUILD_UNIVERSAL_BINARY:=build_universal_binary
|
|||||||
COPY_x86_SDL_LIB:=$(Q)cp $(x86_SDL_LIB) $(OSXAPP)/Contents/lib/libSDL-x86.dylib
|
COPY_x86_SDL_LIB:=$(Q)cp $(x86_SDL_LIB) $(OSXAPP)/Contents/lib/libSDL-x86.dylib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# setting the default vars for making universal binaries
|
ifdef UNIVERSAL_x86_PART
|
||||||
# this can be overwritten in Makefile.config
|
# the bundle is build by the PPC compile when making universal binaries
|
||||||
# default values are for PPC host and commends are for x86 hosts (so you know what to put in)
|
|
||||||
# the absolute path is the one Apple uses in Xcode 2.1
|
|
||||||
ifndef CC_UNI
|
|
||||||
# powerpc-apple-darwin8-gcc-4.0.0
|
|
||||||
CC_UNI:=i686-apple-darwin8-gcc-4.0.0
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef CFLAGS_UNI
|
|
||||||
# -arch ppc
|
|
||||||
CFLAGS_UNI:= -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef LDFLAGS_UNI
|
|
||||||
LDFLAGS_UNI:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef UNIVERSAL_OTHER_HALF
|
|
||||||
# if UNIVERSAL_OTHER_HALF is defined, we know that the original makefile call will build the bundle
|
|
||||||
BUILD_OSX_BUNDLE:=
|
BUILD_OSX_BUNDLE:=
|
||||||
else
|
else
|
||||||
BUILD_OSX_BUNDLE:=build_OSX_bundle
|
BUILD_OSX_BUNDLE:=build_OSX_bundle
|
||||||
@ -40,12 +22,11 @@ endif
|
|||||||
$(BUILD_UNIVERSAL_BINARY): $(TTD)
|
$(BUILD_UNIVERSAL_BINARY): $(TTD)
|
||||||
$(Q)mkdir -p temp_binary_dir
|
$(Q)mkdir -p temp_binary_dir
|
||||||
$(Q)cp $(TTD) temp_binary_dir/$(TTD)_a
|
$(Q)cp $(TTD) temp_binary_dir/$(TTD)_a
|
||||||
@echo '===> Cleaning up to build for the other architecture'
|
$(Q)rm -rf $(TTD) $(OBJS) # delete all .o files so we can compile for a new endian
|
||||||
$(Q)make clean
|
$(Q)make UNIVERSAL_x86_PART:=1
|
||||||
$(Q)make UNIVERSAL_OTHER_HALF:=1
|
|
||||||
$(Q)install_name_tool -change $(x86_SDL_LIB) @executable_path/../lib/libSDL-x86.dylib $(TTD)
|
$(Q)install_name_tool -change $(x86_SDL_LIB) @executable_path/../lib/libSDL-x86.dylib $(TTD)
|
||||||
$(Q)cp $(TTD) temp_binary_dir/$(TTD)_b
|
$(Q)cp $(TTD) temp_binary_dir/$(TTD)_b
|
||||||
@echo '===> Joining binaries into one universal one'
|
@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)lipo temp_binary_dir/$(TTD)_a temp_binary_dir/$(TTD)_b -create -output $(TTD)
|
||||||
$(Q)rm -rf temp_binary_dir
|
$(Q)rm -rf temp_binary_dir
|
||||||
|
|
||||||
@ -53,6 +34,7 @@ $(BUILD_UNIVERSAL_BINARY): $(TTD)
|
|||||||
# 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
|
# 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
|
||||||
|
|
||||||
$(BUILD_OSX_BUNDLE): $(TTD) $(BUILD_UNIVERSAL_BINARY)
|
$(BUILD_OSX_BUNDLE): $(TTD) $(BUILD_UNIVERSAL_BINARY)
|
||||||
|
@echo '===> Building application bundle'
|
||||||
$(Q)rm -fr "$(OSXAPP)"
|
$(Q)rm -fr "$(OSXAPP)"
|
||||||
$(Q)mkdir -p "$(OSXAPP)"/Contents/MacOS
|
$(Q)mkdir -p "$(OSXAPP)"/Contents/MacOS
|
||||||
$(Q)mkdir -p "$(OSXAPP)"/Contents/Resources
|
$(Q)mkdir -p "$(OSXAPP)"/Contents/Resources
|
||||||
|
102
os/macosx/Makefile.setup
Normal file
102
os/macosx/Makefile.setup
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# $Id: Makefile 3214 2005-11-17 19:43:37Z bjarni $
|
||||||
|
# This makefile is not a standalone makefile, but is called from the general one
|
||||||
|
# it contains code specific to MacOS X
|
||||||
|
|
||||||
|
ifdef RELEASE
|
||||||
|
ifndef STATIC
|
||||||
|
# all OSX releases needs to be static
|
||||||
|
# end users don't tend to have the dynamic libs installed
|
||||||
|
$(warning Compiling a dynamic release. It should be static unless you really know what you are doing!!!)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef RELEASE
|
||||||
|
ifndef BUILD_UNIVERSAL_BINARY
|
||||||
|
$(warning Compiling a release build, that is not a universal binary)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef RELEASE
|
||||||
|
ifdef DEBUG
|
||||||
|
$(warning Compiling a release build, that is a debug build)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# setup flags if none are defined
|
||||||
|
ifndef UNIVERSAL_CFLAGS
|
||||||
|
UNIVERSAL_CFLAGS:= -isysroot /Developer/SDKs/MacOSX10.4u.sdk
|
||||||
|
endif
|
||||||
|
ifndef UNIVERSAL_LDFLAGS
|
||||||
|
UNIVERSAL_LDFLAGS:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
|
||||||
|
endif
|
||||||
|
ifndef PPC_CC
|
||||||
|
PPC_CC:=powerpc-apple-darwin8-gcc-4.0.0
|
||||||
|
endif
|
||||||
|
ifndef x86_CC
|
||||||
|
x86_CC:=i686-apple-darwin8-gcc-4.0.0
|
||||||
|
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
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef BUILD_UNIVERSAL_BINARY
|
||||||
|
CFLAGS:= $(UNIVERSAL_CFLAGS)
|
||||||
|
LDFLAGS:= $(UNIVERSAL_LDFLAGS)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
ifdef WITH_SDL
|
||||||
|
ifdef STATIC
|
||||||
|
ifndef x86_SDL_LIB
|
||||||
|
$(error static universal build without a defined x86 SDL lib)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
TEST:=$(shell lipo -info `$(SDL_PPC_CONFIG) --prefix`/lib/libSDL.a | xargs -n 1 | grep "ppc"))
|
||||||
|
ifndef TEST
|
||||||
|
$(error no PPC SDL lib found)
|
||||||
|
endif
|
||||||
|
TEST:=$(shell lipo -info `$(SDL_x86_CONFIG) --prefix`/lib/libSDL.a | xargs -n 1 | grep "i386"))
|
||||||
|
ifndef TEST
|
||||||
|
$(error no x86 SDL lib found)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef UNIVERSAL_x86_PART
|
||||||
|
CFLAGS += -arch i386
|
||||||
|
LIBPNG-CONFIG:=$(LIBPNG_x86_CONFIG)
|
||||||
|
SDL-CONFIG:=$(SDL_x86_CONFIG)
|
||||||
|
CC_TARGET:=$(x86_CC)
|
||||||
|
# clear the cached list of PPC libs
|
||||||
|
LIBS:=
|
||||||
|
else
|
||||||
|
CFLAGS += -arch ppc
|
||||||
|
LIBPNG-CONFIG:=$(LIBPNG_PPC_CONFIG)
|
||||||
|
SDL-CONFIG:=$(SDL_PPC_CONFIG)
|
||||||
|
CC_TARGET:=$(PPC_CC)
|
||||||
|
endif
|
||||||
|
endif
|
Loading…
Reference in New Issue
Block a user