3 # This file is part of OpenTTD.
4 # 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.
5 # 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.
6 # 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/>.
12 # The revision is needed for the bundle name and creating an OSX application bundle.
14 VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
15 VERSION := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
17 # Make sure we have something in VERSION
23 BUNDLE_NAME = openttd-custom-$(VERSION)-$(OS)
26 # An OSX application bundle needs the data files, lang files and openttd executable in a different location.
28 AI_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/ai
29 GAME_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/game
30 BASESET_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/baseset
31 LANG_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/lang
32 TTD_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/MacOS
34 AI_DIR = $(BUNDLE_DIR)/ai
35 GAME_DIR = $(BUNDLE_DIR)/game
36 BASESET_DIR = $(BUNDLE_DIR)/baseset
37 LANG_DIR = $(BUNDLE_DIR)/lang
38 TTD_DIR = $(BUNDLE_DIR)
42 @echo '[BUNDLE] Constructing bundle'
43 $(Q)rm -rf "$(BUNDLE_DIR)"
44 $(Q)mkdir -p "$(BUNDLE_DIR)"
45 $(Q)mkdir -p "$(BUNDLE_DIR)/docs"
46 $(Q)mkdir -p "$(BUNDLE_DIR)/media"
47 $(Q)mkdir -p "$(BUNDLE_DIR)/scripts"
48 $(Q)mkdir -p "$(TTD_DIR)"
49 $(Q)mkdir -p "$(AI_DIR)"
50 $(Q)mkdir -p "$(GAME_DIR)"
51 $(Q)mkdir -p "$(BASESET_DIR)"
52 $(Q)mkdir -p "$(LANG_DIR)"
54 $(Q)mkdir -p "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources"
55 $(Q)echo "APPL????" > "$(BUNDLE_DIR)/$(OSXAPP)/Contents/PkgInfo"
56 $(Q)cp "$(ROOT_DIR)/os/macosx/openttd.icns" "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/openttd.icns"
57 $(Q)$(ROOT_DIR)/os/macosx/plistgen.sh "$(BUNDLE_DIR)/$(OSXAPP)" "$(VERSION)"
58 $(Q)cp "$(ROOT_DIR)/os/macosx/splash.png" "$(BASESET_DIR)"
61 $(Q)cp "$(ROOT_DIR)/media/openttd.32.bmp" "$(BASESET_DIR)/"
63 $(Q)cp "$(BIN_DIR)/$(TTD)" "$(TTD_DIR)/"
64 $(Q)cp "$(BIN_DIR)/ai/"compat_*.nut "$(AI_DIR)/"
65 $(Q)cp "$(BIN_DIR)/game/"compat_*.nut "$(GAME_DIR)/"
66 $(Q)cp "$(BIN_DIR)/baseset/"*.grf "$(BASESET_DIR)/"
67 $(Q)cp "$(BIN_DIR)/baseset/"*.obg "$(BASESET_DIR)/"
68 $(Q)cp "$(BIN_DIR)/baseset/"*.obs "$(BASESET_DIR)/"
69 $(Q)cp "$(BIN_DIR)/baseset/opntitle.dat" "$(BASESET_DIR)/"
70 $(Q)cp "$(BIN_DIR)/baseset/"*.obm "$(BASESET_DIR)/"
71 $(Q)cp "$(BIN_DIR)/lang/"*.lng "$(LANG_DIR)/"
72 $(Q)cp "$(ROOT_DIR)/README.md" "$(BUNDLE_DIR)/"
73 $(Q)cp "$(ROOT_DIR)/COPYING" "$(BUNDLE_DIR)/"
74 $(Q)cp "$(ROOT_DIR)/known-bugs.txt" "$(BUNDLE_DIR)/"
75 $(Q)cp "$(ROOT_DIR)/docs/multiplayer.txt" "$(BUNDLE_DIR)/docs/"
76 $(Q)cp "$(ROOT_DIR)/changelog.txt" "$(BUNDLE_DIR)/"
78 $(Q)mkdir -p "$(BUNDLE_DIR)/man/"
79 $(Q)cp "$(ROOT_DIR)/docs/openttd.6" "$(BUNDLE_DIR)/man/"
80 $(Q)gzip -9 "$(BUNDLE_DIR)/man/openttd.6"
82 $(Q)cp "$(ROOT_DIR)/media/openttd.32.xpm" "$(BUNDLE_DIR)/media/"
83 $(Q)cp "$(ROOT_DIR)/media/openttd."*.png "$(BUNDLE_DIR)/media/"
84 $(Q)cp "$(BIN_DIR)/scripts/"* "$(BUNDLE_DIR)/scripts/"
86 $(Q)cp "$(ROOT_DIR)/media/openttd.desktop" "$(BUNDLE_DIR)/media/"
87 $(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"
88 $(Q)sed s/=openttd/=$(BINARY_NAME)/g "$(BUNDLE_DIR)/media/openttd.desktop" > "$(ROOT_DIR)/media/openttd.desktop.install"
90 ifeq ($(TTD), openttd.exe)
91 $(Q)unix2dos "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/README.md" "$(BUNDLE_DIR)/COPYING" "$(BUNDLE_DIR)/changelog.txt" "$(BUNDLE_DIR)/known-bugs.txt"
94 ### Packing the current bundle into several compressed file formats ###
96 # Zips & dmgs do not contain a root folder, i.e. they have files in the root of the zip/dmg.
97 # gzip, bzip2 and lha archives have a root folder, with the same name as the bundle.
99 # One can supply a custom name by adding BUNDLE_NAME:=<name> to the make command.
102 @echo '[BUNDLE] Creating $(BUNDLE_NAME).zip'
103 $(Q)mkdir -p "$(BUNDLES_DIR)"
104 $(Q)cd "$(BUNDLE_DIR)" && zip -r $(shell if test -z "$(VERBOSE)"; then echo '-q'; fi) "$(BUNDLES_DIR)/$(BUNDLE_NAME).zip" .
107 @echo '[BUNDLE] Creating $(BUNDLE_NAME).7z'
108 $(Q)mkdir -p "$(BUNDLES_DIR)"
109 $(Q)cd "$(BUNDLE_DIR)" && 7z a "$(BUNDLES_DIR)/$(BUNDLE_NAME).7z" .
112 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.gz'
113 $(Q)mkdir -p "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)"
114 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)/"
115 $(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)"
116 $(Q)rm -rf "$(BUNDLES_DIR)/.gzip"
119 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.bz2'
120 $(Q)mkdir -p "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)"
121 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)/"
122 $(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)"
123 $(Q)rm -rf "$(BUNDLES_DIR)/.bzip2"
126 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.lzma'
127 $(Q)mkdir -p "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)"
128 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)/"
129 $(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)"
130 $(Q)rm -rf "$(BUNDLES_DIR)/.lzma"
133 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.xz'
134 $(Q)mkdir -p "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)"
135 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)/"
136 $(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)"
137 $(Q)rm -rf "$(BUNDLES_DIR)/.xz"
140 @echo '[BUNDLE] Creating $(BUNDLE_NAME).lha'
141 $(Q)mkdir -p "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)"
142 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)/"
143 $(Q)cd "$(BUNDLES_DIR)/.lha" && lha ao6 "$(BUNDLES_DIR)/$(BUNDLE_NAME).lha" "$(BUNDLE_NAME)"
144 $(Q)rm -rf "$(BUNDLES_DIR)/.lha"
147 @echo '[BUNDLE] Creating $(BUNDLE_NAME).dmg'
148 $(Q)mkdir -p "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
149 $(Q)cp -R "$(BUNDLE_DIR)/" "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
150 $(Q)hdiutil create -ov -format UDZO -srcfolder "$(BUNDLES_DIR)/OpenTTD $(VERSION)" "$(BUNDLES_DIR)/$(BUNDLE_NAME).dmg"
151 $(Q)rm -fr "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
154 @echo '[BUNDLE] Creating $(BUNDLE_NAME).exe'
155 $(Q)mkdir -p "$(BUNDLES_DIR)"
156 $(Q)unix2dos "$(ROOT_DIR)/docs/"*.txt "$(ROOT_DIR)/README.md" "$(ROOT_DIR)/COPYING" "$(ROOT_DIR)/changelog.txt" "$(ROOT_DIR)/known-bugs.txt"
157 $(Q)cd $(ROOT_DIR)/os/windows/installer && makensis.exe //DVERSION_INCLUDE=version_$(PLATFORM).txt install.nsi
158 $(Q)mv $(ROOT_DIR)/os/windows/installer/*$(PLATFORM).exe "$(BUNDLES_DIR)/$(BUNDLE_NAME).exe"
162 @echo '[INSTALL] Cannot install the OSX Application Bundle'
165 @echo '[INSTALL] Installing OpenTTD'
166 $(Q)install -d "$(INSTALL_BINARY_DIR)"
167 $(Q)install -d "$(INSTALL_ICON_DIR)"
168 $(Q)install -d "$(INSTALL_DATA_DIR)/ai"
169 $(Q)install -d "$(INSTALL_DATA_DIR)/game"
170 $(Q)install -d "$(INSTALL_DATA_DIR)/baseset"
171 $(Q)install -d "$(INSTALL_DATA_DIR)/lang"
172 $(Q)install -d "$(INSTALL_DATA_DIR)/scripts"
173 ifeq ($(TTD), openttd.exe)
174 $(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}.exe"
176 $(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}"
178 $(Q)install -m 644 "$(BUNDLE_DIR)/lang/"* "$(INSTALL_DATA_DIR)/lang"
179 $(Q)install -m 644 "$(BUNDLE_DIR)/ai/"* "$(INSTALL_DATA_DIR)/ai"
180 $(Q)install -m 644 "$(BUNDLE_DIR)/game/"* "$(INSTALL_DATA_DIR)/game"
181 $(Q)install -m 644 "$(BUNDLE_DIR)/baseset/"* "$(INSTALL_DATA_DIR)/baseset"
182 $(Q)install -m 644 "$(BUNDLE_DIR)/scripts/"* "$(INSTALL_DATA_DIR)/scripts"
183 ifndef DO_NOT_INSTALL_DOCS
184 $(Q)install -d "$(INSTALL_DOC_DIR)"
185 $(Q)install -m 644 "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/README.md" "$(BUNDLE_DIR)/known-bugs.txt" "$(INSTALL_DOC_DIR)"
187 ifndef DO_NOT_INSTALL_CHANGELOG
188 $(Q)install -d "$(INSTALL_DOC_DIR)"
189 $(Q)install -m 644 "$(BUNDLE_DIR)/changelog.txt" "$(INSTALL_DOC_DIR)"
191 ifndef DO_NOT_INSTALL_LICENSE
192 $(Q)install -d "$(INSTALL_DOC_DIR)"
193 $(Q)install -m 644 "$(BUNDLE_DIR)/COPYING" "$(INSTALL_DOC_DIR)"
195 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.xpm" "$(INSTALL_ICON_DIR)/${BINARY_NAME}.32.xpm"
197 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)"
198 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/16x16/apps"
199 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.16.png" "$(INSTALL_ICON_THEME_DIR)/16x16/apps/${BINARY_NAME}.png"
200 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/32x32/apps"
201 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.png" "$(INSTALL_ICON_THEME_DIR)/32x32/apps/${BINARY_NAME}.png"
202 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/48x48/apps"
203 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.48.png" "$(INSTALL_ICON_THEME_DIR)/48x48/apps/${BINARY_NAME}.png"
204 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/64x64/apps"
205 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.64.png" "$(INSTALL_ICON_THEME_DIR)/64x64/apps/${BINARY_NAME}.png"
206 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/128x128/apps"
207 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.128.png" "$(INSTALL_ICON_THEME_DIR)/128x128/apps/${BINARY_NAME}.png"
208 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/256x256/apps"
209 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.256.png" "$(INSTALL_ICON_THEME_DIR)/256x256/apps/${BINARY_NAME}.png"
211 $(Q)install -m 644 "$(BUNDLE_DIR)/media/"*.png "$(INSTALL_ICON_DIR)"
214 ifndef DO_NOT_INSTALL_MAN
215 $(Q)install -d "$(INSTALL_MAN_DIR)"
216 $(Q)install -m 644 "$(BUNDLE_DIR)/man/openttd.6.gz" "$(INSTALL_MAN_DIR)/${BINARY_NAME}.6.gz"
220 $(Q)install -d "$(INSTALL_MENU_DIR)"
221 $(Q)install -m 644 "$(ROOT_DIR)/media/openttd.desktop.install" "$(INSTALL_MENU_DIR)/${BINARY_NAME}.desktop"