os/macosx/Makefile
author bjarni
Wed, 15 Mar 2006 14:03:09 +0000
changeset 3211 a0f00b66cfad
parent 3087 b93cccf54381
child 3212 39c32be8404c
permissions -rw-r--r--
(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
2688
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
     1
# $Id: Makefile 3214 2005-11-17 19:43:37Z bjarni $
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
     2
# This makefile is not a standalone makefile, but is called from the general one
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
     3
# it contains targets specific to MacOS X
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
     4
3085
d56874235364 (svn r3674) -Feature: [OSX] Added support for tripple binaries (binaries optimised for G3, G5 and i686)
bjarni
parents: 2835
diff changeset
     5
ifdef TRIPPLE_BINARY
3211
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
     6
# 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
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
     7
# we can get rid of this. Xcode supports arch dependant flags, but we can't do it in the makefile (yet?)
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
     8
%.o: %.c $(MAKE_CONFIG)
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
     9
	@echo '===> Compiling $<'
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    10
	$(Q)$(CC) $(CFLAGS) $(CDEFS) -arch ppc -c -arch i386 -o $@.uni $<
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    11
	$(Q)$(CC) $(CFLAGS) $(CDEFS) $(G5_FLAGS) -arch ppc970 -c -o $@.ppc970 $<
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    12
	$(Q)lipo -create -output $@ $@.uni $@.ppc970
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    13
	$(Q)rm $@.uni $@.ppc970
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    14
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    15
%.o: %.cpp  $(MAKE_CONFIG)
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    16
	@echo '===> Compiling $<'
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    17
	$(Q)$(CXX) $(CFLAGS) $(CDEFS) -arch ppc -arch i386 -c -o $@.uni $<
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    18
	$(Q)$(CXX) $(CFLAGS) $(CDEFS) $(G5_FLAGS) -arch ppc970 -c -o $@.ppc970 $<
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    19
	$(Q)lipo -create -output $@ $@.uni $@.ppc970
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    20
	$(Q)rm $@.uni $@.ppc970
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    21
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    22
%.o: %.m  $(MAKE_CONFIG)
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    23
	@echo '===> Compiling $<'
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    24
	$(Q)$(CC) $(CFLAGS) $(CDEFS) -arch ppc -arch i386 -c -o $@.uni $<
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    25
	$(Q)$(CC) $(CFLAGS) $(CDEFS) -arch ppc970 $(G5_FLAGS) -c -o $@.ppc970 $<
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    26
	$(Q)lipo -create -output $@ $@.uni $@.ppc970
a0f00b66cfad (svn r3882) -Codechange: [OSX] changed the way universal and tripple binaries are build
bjarni
parents: 3087
diff changeset
    27
	$(Q)rm $@.uni $@.ppc970
2713
9c42385e4f41 (svn r3258) -Feature: [OSX] added support for universal binaries
bjarni
parents: 2712
diff changeset
    28
endif
9c42385e4f41 (svn r3258) -Feature: [OSX] added support for universal binaries
bjarni
parents: 2712
diff changeset
    29
3085
d56874235364 (svn r3674) -Feature: [OSX] Added support for tripple binaries (binaries optimised for G3, G5 and i686)
bjarni
parents: 2835
diff changeset
    30
ifdef UNIVERSAL_PPC_PART
2722
d2ab10ffc5e7 (svn r3267) -Codechange: [OSX] universal binary makefile code cleanup
bjarni
parents: 2717
diff changeset
    31
# the bundle is build by the PPC compile when making universal binaries
2714
2d0366113f47 (svn r3259) -Fix: [OSX] fixed that universal binaries did not make a bundle
bjarni
parents: 2713
diff changeset
    32
BUILD_OSX_BUNDLE:=
2d0366113f47 (svn r3259) -Fix: [OSX] fixed that universal binaries did not make a bundle
bjarni
parents: 2713
diff changeset
    33
else
2d0366113f47 (svn r3259) -Fix: [OSX] fixed that universal binaries did not make a bundle
bjarni
parents: 2713
diff changeset
    34
BUILD_OSX_BUNDLE:=build_OSX_bundle
2d0366113f47 (svn r3259) -Fix: [OSX] fixed that universal binaries did not make a bundle
bjarni
parents: 2713
diff changeset
    35
endif
2d0366113f47 (svn r3259) -Fix: [OSX] fixed that universal binaries did not make a bundle
bjarni
parents: 2713
diff changeset
    36
2688
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    37
# build the bundle. OSX wants to keep apps in bundles, so we will give it one
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    38
# 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
2713
9c42385e4f41 (svn r3258) -Feature: [OSX] added support for universal binaries
bjarni
parents: 2712
diff changeset
    39
3085
d56874235364 (svn r3674) -Feature: [OSX] Added support for tripple binaries (binaries optimised for G3, G5 and i686)
bjarni
parents: 2835
diff changeset
    40
$(BUILD_OSX_BUNDLE): $(TTD) $(UNIVERSAL_BINARY) $(TRIPPLE_BINARY)
2722
d2ab10ffc5e7 (svn r3267) -Codechange: [OSX] universal binary makefile code cleanup
bjarni
parents: 2717
diff changeset
    41
	@echo '===> Building application bundle'
2688
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    42
	$(Q)rm -fr "$(OSXAPP)"
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    43
	$(Q)mkdir -p "$(OSXAPP)"/Contents/MacOS
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    44
	$(Q)mkdir -p "$(OSXAPP)"/Contents/Resources
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    45
	$(Q)mkdir -p "$(OSXAPP)"/Contents/Data
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    46
	$(Q)mkdir -p "$(OSXAPP)"/Contents/Lang
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    47
	$(Q)echo "APPL????" > "$(OSXAPP)"/Contents/PkgInfo
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    48
	$(Q)cp os/macosx/openttd.icns "$(OSXAPP)"/Contents/Resources/openttd.icns
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    49
	$(Q)os/macosx/plistgen.sh "$(OSXAPP)" "$(REV)"
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    50
	$(Q)cp data/* "$(OSXAPP)"/Contents/Data/
2736
3d6487cbbb69 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents: 2731
diff changeset
    51
	$(Q)cp os/macosx/splash.png "$(OSXAPP)"/Contents/Data/
2688
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    52
	$(Q)cp lang/*.lng "$(OSXAPP)"/Contents/Lang/
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    53
	$(Q)cp $(TTD) "$(OSXAPP)"/Contents/MacOS/$(TTD)
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    54
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    55
# make the release disk image. Should only be used with releases and is a good and fast way to make sure to remember all the needed files
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    56
release: all
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    57
	$(Q)mkdir -p "OpenTTD $(RELEASE)"
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    58
	$(Q)mkdir -p "OpenTTD $(RELEASE)"/docs
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    59
	$(Q)mkdir -p "OpenTTD $(RELEASE)"/scenario
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    60
	$(Q)cp -R $(OSXAPP) "OpenTTD $(RELEASE)"/
3087
b93cccf54381 (svn r3676) -Change: [OSX] changed info about package to how to install the game
bjarni
parents: 3085
diff changeset
    61
	$(Q)cp docs/OSX_install_instructions.txt "OpenTTD $(RELEASE)"/How\ to\ install\ (please\ read).txt
2688
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    62
	$(Q)cp readme.txt "OpenTTD $(RELEASE)"/docs/
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    63
	$(Q)cp docs/README_if_game_crashed_on_OSX.txt "OpenTTD $(RELEASE)"/docs/readme\ if\ crashed\ on\ OSX.txt
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    64
	$(Q)cp docs/console.txt "OpenTTD $(RELEASE)"/docs/
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    65
	$(Q)cp COPYING "OpenTTD $(RELEASE)"/docs/
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    66
	$(Q)cp changelog.txt "OpenTTD $(RELEASE)"/docs/
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    67
	$(Q)cp docs/README_if_game_crashed_on_OSX.txt "OpenTTD $(RELEASE)"/docs/
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    68
	$(Q)cp os/macosx/*.webloc "OpenTTD $(RELEASE)"
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    69
	$(Q)cp known-bugs.txt "OpenTTD $(RELEASE)"/known-bugs.txt
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    70
	$(Q)cp scenario/* "OpenTTD $(RELEASE)"/scenario/
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    71
	$(Q)/usr/bin/hdiutil create -ov -format UDZO -srcfolder "OpenTTD $(RELEASE)" openttd-"$(RELEASE)"-osx.dmg
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    72
	$(Q)rm -fr "OpenTTD $(RELEASE)"
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    73
2714
2d0366113f47 (svn r3259) -Fix: [OSX] fixed that universal binaries did not make a bundle
bjarni
parents: 2713
diff changeset
    74
$(OSX): $(TTD) $(BUILD_OSX_BUNDLE)
2688
067c4362dcb0 (svn r3230) -Feature: [OSX] OSX builds can now change where it searches for dynamic libs and can move libs into the bundle
bjarni
parents:
diff changeset
    75
3085
d56874235364 (svn r3674) -Feature: [OSX] Added support for tripple binaries (binaries optimised for G3, G5 and i686)
bjarni
parents: 2835
diff changeset
    76
.PHONY: release $(BUILD_OSX_BUNDLE) $(UNIVERSAL_BINARY)