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 REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
17 # Make sure we have something in REV
23 BUNDLE_NAME = openttd-custom-$(REV)-$(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)" "$(REV)"
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.txt" "$(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 | $(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.txt" "$(BUNDLE_DIR)/COPYING" "$(BUNDLE_DIR)/changelog.txt" "$(BUNDLE_DIR)/known-bugs.txt"
93 $(Q)cp "$(ROOT_DIR)/os/dos/cwsdpmi/cwsdpmi.txt" "$(BUNDLE_DIR)/docs/"
95 $(Q)cp "$(ROOT_DIR)/os/dos/cwsdpmi/cwsdpmi.exe" "$(TTD_DIR)/"
100 ### Packing the current bundle into several compressed file formats ###
102 # Zips & dmgs do not contain a root folder, i.e. they have files in the root of the zip/dmg.
103 # gzip, bzip2 and lha archives have a root folder, with the same name as the bundle.
105 # One can supply a custom name by adding BUNDLE_NAME:=<name> to the make command.
108 @echo '[BUNDLE] Creating $(BUNDLE_NAME).zip'
109 $(Q)mkdir -p "$(BUNDLES_DIR)"
110 $(Q)cd "$(BUNDLE_DIR)" && zip -r $(shell if test -z "$(VERBOSE)"; then echo '-q'; fi) "$(BUNDLES_DIR)/$(BUNDLE_NAME).zip" .
113 @echo '[BUNDLE] Creating $(BUNDLE_NAME).7z'
114 $(Q)mkdir -p "$(BUNDLES_DIR)"
115 $(Q)cd "$(BUNDLE_DIR)" && 7z a "$(BUNDLES_DIR)/$(BUNDLE_NAME).7z" .
118 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.gz'
119 $(Q)mkdir -p "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)"
120 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)/"
121 $(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)"
122 $(Q)rm -rf "$(BUNDLES_DIR)/.gzip"
125 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.bz2'
126 $(Q)mkdir -p "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)"
127 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)/"
128 $(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)"
129 $(Q)rm -rf "$(BUNDLES_DIR)/.bzip2"
132 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.lzma'
133 $(Q)mkdir -p "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)"
134 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)/"
135 $(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)"
136 $(Q)rm -rf "$(BUNDLES_DIR)/.lzma"
139 @echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.xz'
140 $(Q)mkdir -p "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)"
141 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)/"
142 $(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)"
143 $(Q)rm -rf "$(BUNDLES_DIR)/.xz"
146 @echo '[BUNDLE] Creating $(BUNDLE_NAME).lha'
147 $(Q)mkdir -p "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)"
148 $(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)/"
149 $(Q)cd "$(BUNDLES_DIR)/.lha" && lha ao6 "$(BUNDLES_DIR)/$(BUNDLE_NAME).lha" "$(BUNDLE_NAME)"
150 $(Q)rm -rf "$(BUNDLES_DIR)/.lha"
153 @echo '[BUNDLE] Creating $(BUNDLE_NAME).dmg'
154 $(Q)mkdir -p "$(BUNDLES_DIR)/OpenTTD $(REV)"
155 $(Q)cp -R "$(BUNDLE_DIR)/" "$(BUNDLES_DIR)/OpenTTD $(REV)"
156 $(Q)hdiutil create -ov -format UDZO -srcfolder "$(BUNDLES_DIR)/OpenTTD $(REV)" "$(BUNDLES_DIR)/$(BUNDLE_NAME).dmg"
157 $(Q)rm -fr "$(BUNDLES_DIR)/OpenTTD $(REV)"
160 @echo '[BUNDLE] Creating $(BUNDLE_NAME).exe'
161 $(Q)mkdir -p "$(BUNDLES_DIR)"
162 $(Q)unix2dos "$(ROOT_DIR)/docs/"*.txt "$(ROOT_DIR)/readme.txt" "$(ROOT_DIR)/COPYING" "$(ROOT_DIR)/changelog.txt" "$(ROOT_DIR)/known-bugs.txt"
163 $(Q)cd $(ROOT_DIR)/os/windows/installer && makensis.exe //DVERSION_INCLUDE=version_$(PLATFORM).txt install.nsi
164 $(Q)mv $(ROOT_DIR)/os/windows/installer/*$(PLATFORM).exe "$(BUNDLES_DIR)/$(BUNDLE_NAME).exe"
168 @echo '[INSTALL] Cannot install the OSX Application Bundle'
171 @echo '[INSTALL] Installing OpenTTD'
172 $(Q)install -d "$(INSTALL_BINARY_DIR)"
173 $(Q)install -d "$(INSTALL_ICON_DIR)"
174 $(Q)install -d "$(INSTALL_DATA_DIR)/ai"
175 $(Q)install -d "$(INSTALL_DATA_DIR)/baseset"
176 $(Q)install -d "$(INSTALL_DATA_DIR)/lang"
177 $(Q)install -d "$(INSTALL_DATA_DIR)/scripts"
178 ifeq ($(TTD), openttd.exe)
179 $(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}.exe"
181 $(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}"
183 $(Q)install -m 644 "$(BUNDLE_DIR)/lang/"* "$(INSTALL_DATA_DIR)/lang"
184 $(Q)install -m 644 "$(BUNDLE_DIR)/ai/"* "$(INSTALL_DATA_DIR)/ai"
185 $(Q)install -m 644 "$(BUNDLE_DIR)/baseset/"* "$(INSTALL_DATA_DIR)/baseset"
186 $(Q)install -m 644 "$(BUNDLE_DIR)/scripts/"* "$(INSTALL_DATA_DIR)/scripts"
187 ifndef DO_NOT_INSTALL_DOCS
188 $(Q)install -d "$(INSTALL_DOC_DIR)"
189 $(Q)install -m 644 "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/readme.txt" "$(BUNDLE_DIR)/known-bugs.txt" "$(INSTALL_DOC_DIR)"
191 ifndef DO_NOT_INSTALL_CHANGELOG
192 $(Q)install -d "$(INSTALL_DOC_DIR)"
193 $(Q)install -m 644 "$(BUNDLE_DIR)/changelog.txt" "$(INSTALL_DOC_DIR)"
195 ifndef DO_NOT_INSTALL_LICENSE
196 $(Q)install -d "$(INSTALL_DOC_DIR)"
197 $(Q)install -m 644 "$(BUNDLE_DIR)/COPYING" "$(INSTALL_DOC_DIR)"
199 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.xpm" "$(INSTALL_ICON_DIR)/${BINARY_NAME}.32.xpm"
201 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)"
202 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/16x16/apps"
203 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.16.png" "$(INSTALL_ICON_THEME_DIR)/16x16/apps/${BINARY_NAME}.png"
204 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/32x32/apps"
205 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.png" "$(INSTALL_ICON_THEME_DIR)/32x32/apps/${BINARY_NAME}.png"
206 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/48x48/apps"
207 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.48.png" "$(INSTALL_ICON_THEME_DIR)/48x48/apps/${BINARY_NAME}.png"
208 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/64x64/apps"
209 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.64.png" "$(INSTALL_ICON_THEME_DIR)/64x64/apps/${BINARY_NAME}.png"
210 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/128x128/apps"
211 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.128.png" "$(INSTALL_ICON_THEME_DIR)/128x128/apps/${BINARY_NAME}.png"
212 $(Q)install -d "$(INSTALL_ICON_THEME_DIR)/256x256/apps"
213 $(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.256.png" "$(INSTALL_ICON_THEME_DIR)/256x256/apps/${BINARY_NAME}.png"
215 $(Q)install -m 644 "$(BUNDLE_DIR)/media/"*.png "$(INSTALL_ICON_DIR)"
218 ifndef DO_NOT_INSTALL_MAN
219 $(Q)install -d "$(INSTALL_MAN_DIR)"
220 $(Q)install -m 644 "$(BUNDLE_DIR)/man/openttd.6.gz" "$(INSTALL_MAN_DIR)/${BINARY_NAME}.6.gz"
224 $(Q)install -d "$(INSTALL_MENU_DIR)"
225 $(Q)install -m 644 "$(ROOT_DIR)/media/openttd.desktop.install" "$(INSTALL_MENU_DIR)/${BINARY_NAME}.desktop"