1 # This file is part of OpenTTD.
2 # OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
3 # OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4 # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 # The revision is needed for the bundle name and creating an OSX application bundle.
12 VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
13 VERSION := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
15 # Make sure we have something in VERSION
21 BUNDLE_NAME = openttd-custom-$(VERSION)-$(OS)
24 # An OSX application bundle needs the data files, lang files and openttd executable in a different location.
26 AI_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/ai
27 GAME_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/game
28 BASESET_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/baseset
29 LANG_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/lang
30 TTD_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/MacOS
32 AI_DIR = $(BUNDLE_DIR)/ai
33 GAME_DIR = $(BUNDLE_DIR)/game
34 BASESET_DIR = $(BUNDLE_DIR)/baseset
35 LANG_DIR = $(BUNDLE_DIR)/lang
36 TTD_DIR = $(BUNDLE_DIR)
40 @echo '[BUNDLE] Constructing bundle'
41 $(Q)rm -rf "$(BUNDLE_DIR)"
42 $(Q)mkdir -p "$(BUNDLE_DIR)"
43 $(Q)mkdir -p "$(BUNDLE_DIR)/docs"
44 $(Q)mkdir -p "$(BUNDLE_DIR)/media"
45 $(Q)mkdir -p "$(BUNDLE_DIR)/scripts"
46 $(Q)mkdir -p "$(TTD_DIR)"
47 $(Q)mkdir -p "$(AI_DIR)"
48 $(Q)mkdir -p "$(GAME_DIR)"
49 $(Q)mkdir -p "$(BASESET_DIR)"
50 $(Q)mkdir -p "$(LANG_DIR)"
52 $(Q)mkdir -p "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources"
53 $(Q)echo "APPL????" > "$(BUNDLE_DIR)/$(OSXAPP)/Contents/PkgInfo"
54 $(Q)cp "$(ROOT_DIR)/os/macosx/openttd.icns" "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/openttd.icns"
55 $(Q)$(ROOT_DIR)/os/macosx/plistgen.sh "$(BUNDLE_DIR)/$(OSXAPP)" "$(VERSION)"
56 $(Q)cp "$(ROOT_DIR)/os/macosx/splash.png" "$(BASESET_DIR)"
59 $(Q)cp "$(ROOT_DIR)/media/openttd.32.bmp" "$(BASESET_DIR)/"
61 $(Q)cp "$(BIN_DIR)/$(TTD)" "$(TTD_DIR)/"
62 $(Q)cp "$(BIN_DIR)/ai/"compat_*.nut "$(AI_DIR)/"
63 $(Q)cp "$(BIN_DIR)/game/"compat_*.nut "$(GAME_DIR)/"
64 $(Q)cp "$(BIN_DIR)/baseset/"*.grf "$(BASESET_DIR)/"
65 $(Q)cp "$(BIN_DIR)/baseset/"*.obg "$(BASESET_DIR)/"
66 $(Q)cp "$(BIN_DIR)/baseset/"*.obs "$(BASESET_DIR)/"
67 $(Q)cp "$(BIN_DIR)/baseset/opntitle.dat" "$(BASESET_DIR)/"
68 $(Q)cp "$(BIN_DIR)/baseset/"*.obm "$(BASESET_DIR)/"
69 $(Q)cp "$(BIN_DIR)/lang/"*.lng "$(LANG_DIR)/"
70 $(Q)cp "$(ROOT_DIR)/README.md" "$(BUNDLE_DIR)/"
71 $(Q)cp "$(ROOT_DIR)/COPYING.md" "$(BUNDLE_DIR)/"
72 $(Q)cp "$(ROOT_DIR)/known-bugs.txt" "$(BUNDLE_DIR)/"
73 $(Q)cp "$(ROOT_DIR)/docs/multiplayer.md" "$(BUNDLE_DIR)/docs/"
74 $(Q)cp "$(ROOT_DIR)/changelog.txt" "$(BUNDLE_DIR)/"
76 $(Q)mkdir -p "$(BUNDLE_DIR)/man/"
77 $(Q)cp "$(ROOT_DIR)/docs/openttd.6" "$(BUNDLE_DIR)/man/"
78 $(Q)gzip -9 "$(BUNDLE_DIR)/man/openttd.6"
80 $(Q)cp "$(ROOT_DIR)/media/openttd.32.xpm" "$(BUNDLE_DIR)/media/"
81 $(Q)cp "$(ROOT_DIR)/media/openttd."*.png "$(BUNDLE_DIR)/media/"
82 $(Q)cp "$(BIN_DIR)/scripts/"* "$(BUNDLE_DIR)/scripts/"
84 $(Q)cp "$(ROOT_DIR)/media/openttd.desktop" "$(BUNDLE_DIR)/media/"
85 $(Q)$(AWK) -f "$(ROOT_DIR)/media/openttd.desktop.translation.awk" "$(SRC_DIR)/lang/"*.txt | LC_ALL=C $(SORT) | $(AWK) -f "$(ROOT_DIR)/media/openttd.desktop.filter.awk" >> "$(BUNDLE_DIR)/media/openttd.desktop"
86 $(Q)sed s/=openttd/=$(BINARY_NAME)/g "$(BUNDLE_DIR)/media/openttd.desktop" > "$(ROOT_DIR)/media/openttd.desktop.install"
88 ifeq ($(TTD), openttd.exe)
89 $(Q)unix2dos "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/README.md" "$(BUNDLE_DIR)/COPYING.md" "$(BUNDLE_DIR)/changelog.txt" "$(BUNDLE_DIR)/known-bugs.txt"
92 ### Packing the current bundle into several compressed file formats ###
94 # Zips & dmgs do not contain a root folder, i.e. they have files in the root of the zip/dmg.
95 # gzip, bzip2 and lha archives have a root folder, with the same name as the bundle.
97 # One can supply a custom name by adding BUNDLE_NAME:=<name> to the make command.
100 @echo '[BUNDLE] Creating $(BUNDLE_NAME).zip'
101 $(Q)mkdir -p "$(BUNDLES_DIR)"
102 $(Q)cd "$(BUNDLE_DIR)" && zip -r $(shell if test -z "$(VERBOSE)"; then echo '-q'; fi) "$(BUNDLES_DIR)/$(BUNDLE_NAME).zip" .
105 @echo '[BUNDLE] Creating $(BUNDLE_NAME).7z'
106 $(Q)mkdir -p "$(BUNDLES_DIR)"
107 $(Q)cd "$(BUNDLE_DIR)" && 7z a "$(BUNDLES_DIR)/$(BUNDLE_NAME).7z" .
110 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.gz'
111 $(Q)mkdir -p "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)"
112 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)/"
113 $(Q)cd "$(BUNDLES_DIR)/.gzip" && tar -zc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.gz" "$(BUNDLE_NAME)"
114 $(Q)rm -rf "$(BUNDLES_DIR)/.gzip"
117 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.bz2'
118 $(Q)mkdir -p "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)"
119 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)/"
120 $(Q)cd "$(BUNDLES_DIR)/.bzip2" && tar -jc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.bz2" "$(BUNDLE_NAME)"
121 $(Q)rm -rf "$(BUNDLES_DIR)/.bzip2"
124 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.lzma'
125 $(Q)mkdir -p "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)"
126 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)/"
127 $(Q)cd "$(BUNDLES_DIR)/.lzma" && tar --lzma -c$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.lzma" "$(BUNDLE_NAME)"
128 $(Q)rm -rf "$(BUNDLES_DIR)/.lzma"
131 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.xz'
132 $(Q)mkdir -p "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)"
133 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)/"
134 $(Q)cd "$(BUNDLES_DIR)/.xz" && tar --xz -c$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.xz" "$(BUNDLE_NAME)"
135 $(Q)rm -rf "$(BUNDLES_DIR)/.xz"
138 @echo '[BUNDLE] Creating $(BUNDLE_NAME).lha'
139 $(Q)mkdir -p "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)"
140 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)/"
141 $(Q)cd "$(BUNDLES_DIR)/.lha" && lha ao6 "$(BUNDLES_DIR)/$(BUNDLE_NAME).lha" "$(BUNDLE_NAME)"
142 $(Q)rm -rf "$(BUNDLES_DIR)/.lha"
145 @echo '[BUNDLE] Creating $(BUNDLE_NAME).dmg'
146 $(Q)mkdir -p "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
147 $(Q)cp -R "$(BUNDLE_DIR)/" "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
148 $(Q)hdiutil create -ov -format UDZO -srcfolder "$(BUNDLES_DIR)/OpenTTD $(VERSION)" "$(BUNDLES_DIR)/$(BUNDLE_NAME).dmg"
149 $(Q)rm -fr "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
152 @echo '[BUNDLE] Creating $(BUNDLE_NAME).exe'
153 $(Q)mkdir -p "$(BUNDLES_DIR)"
154 $(Q)unix2dos "$(ROOT_DIR)/docs/"* "$(ROOT_DIR)/README.md" "$(ROOT_DIR)/COPYING.md" "$(ROOT_DIR)/changelog.txt" "$(ROOT_DIR)/known-bugs.txt"
155 $(Q)cd $(ROOT_DIR)/os/windows/installer && makensis.exe //DVERSION_INCLUDE=version_$(PLATFORM).txt install.nsi
156 $(Q)mv $(ROOT_DIR)/os/windows/installer/*$(PLATFORM).exe "$(BUNDLES_DIR)/$(BUNDLE_NAME).exe"
160 @echo '[INSTALL] Cannot install the OSX Application Bundle'
163 @echo '[INSTALL] Installing OpenTTD'
164 $(Q)install -d "$(INSTALL_BINARY_DIR)"
165 $(Q)install -d "$(INSTALL_ICON_DIR)"
166 $(Q)install -d "$(INSTALL_DATA_DIR)/ai"
167 $(Q)install -d "$(INSTALL_DATA_DIR)/game"
168 $(Q)install -d "$(INSTALL_DATA_DIR)/baseset"
169 $(Q)install -d "$(INSTALL_DATA_DIR)/lang"
170 $(Q)install -d "$(INSTALL_DATA_DIR)/scripts"
171 ifeq ($(TTD), openttd.exe)
172 $(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}.exe"
174 $(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}"
176 $(Q)install -m 644 "$(BUNDLE_DIR)/lang/"* "$(INSTALL_DATA_DIR)/lang"
177 $(Q)install -m 644 "$(BUNDLE_DIR)/ai/"* "$(INSTALL_DATA_DIR)/ai"
178 $(Q)install -m 644 "$(BUNDLE_DIR)/game/"* "$(INSTALL_DATA_DIR)/game"
179 $(Q)install -m 644 "$(BUNDLE_DIR)/baseset/"* "$(INSTALL_DATA_DIR)/baseset"
180 $(Q)install -m 644 "$(BUNDLE_DIR)/scripts/"* "$(INSTALL_DATA_DIR)/scripts"
181 ifndef DO_NOT_INSTALL_DOCS
182 $(Q)install -d "$(INSTALL_DOC_DIR)"
183 $(Q)install -m 644 "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/README.md" "$(BUNDLE_DIR)/known-bugs.txt" "$(INSTALL_DOC_DIR)"
185 ifndef DO_NOT_INSTALL_CHANGELOG
186 $(Q)install -d "$(INSTALL_DOC_DIR)"
187 $(Q)install -m 644 "$(BUNDLE_DIR)/changelog.txt" "$(INSTALL_DOC_DIR)"
189 ifndef DO_NOT_INSTALL_LICENSE
190 $(Q)install -d "$(INSTALL_DOC_DIR)"
191 $(Q)install -m 644 "$(BUNDLE_DIR)/COPYING.md" "$(INSTALL_DOC_DIR)"
193 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.xpm" "$(INSTALL_ICON_DIR)/${BINARY_NAME}.32.xpm"
195 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)"
196 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/16x16/apps"
197 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.16.png" "$(INSTALL_ICON_THEME_DIR)/16x16/apps/${BINARY_NAME}.png"
198 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/32x32/apps"
199 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.png" "$(INSTALL_ICON_THEME_DIR)/32x32/apps/${BINARY_NAME}.png"
200 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/48x48/apps"
201 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.48.png" "$(INSTALL_ICON_THEME_DIR)/48x48/apps/${BINARY_NAME}.png"
202 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/64x64/apps"
203 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.64.png" "$(INSTALL_ICON_THEME_DIR)/64x64/apps/${BINARY_NAME}.png"
204 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/128x128/apps"
205 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.128.png" "$(INSTALL_ICON_THEME_DIR)/128x128/apps/${BINARY_NAME}.png"
206 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/256x256/apps"
207 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.256.png" "$(INSTALL_ICON_THEME_DIR)/256x256/apps/${BINARY_NAME}.png"
209 $(Q)install -m 644 "$(BUNDLE_DIR)/media/"*.png "$(INSTALL_ICON_DIR)"
212 ifndef DO_NOT_INSTALL_MAN
213 $(Q)install -d "$(INSTALL_MAN_DIR)"
214 $(Q)install -m 644 "$(BUNDLE_DIR)/man/openttd.6.gz" "$(INSTALL_MAN_DIR)/${BINARY_NAME}.6.gz"
218 $(Q)install -d "$(INSTALL_MENU_DIR)"
219 $(Q)install -m 644 "$(ROOT_DIR)/media/openttd.desktop.install" "$(INSTALL_MENU_DIR)/${BINARY_NAME}.desktop"