]> icculus.org git repositories - divverent/nexuiz.git/blob - misc/makebuild.sh
remove -I flag on OS X for SDL (because that's in makefile.inc now)
[divverent/nexuiz.git] / misc / makebuild.sh
1 #!/bin/bash
2
3 set -e
4
5 base=`pwd`
6
7
8 case "$pw" in
9         '')
10                 zipflags=
11                 ;;
12         *)
13                 zipflags="-P $pw"
14                 ;;
15 esac
16
17 : ${date:=`date +%Y%m%d`}
18 : ${versiontag:=}
19 echo "date stamp: $date"
20
21 case "$version" in
22         '')
23                 version=2-svntest-$date
24                 versiontag=test
25                 defaultcfg=
26                 ext=
27                 ;;
28         *)
29                 version=$version
30                 versiontag=$versiontag
31                 defaultcfg=
32                 ext=_$version
33                 ;;
34 esac
35
36 basepk3=$base/data20070531.pk3
37 hotbasepk3=$base/data20080229.pk3
38 nexdir=$base/nexuiz
39 nexprodir=$base/nexuiz/pro
40 dpdir=$base/darkplaces
41 tmpdir=/tmp/NEX
42 zipdir=$base/builds
43 buildfiles=$base/nexuiz/misc/buildfiles
44 mingwdlls=$buildfiles/w32
45 osxapps=$buildfiles/osx
46 copystrip=$buildfiles/copystrip
47 zipdiff=$base/nexuiz/misc/zipdiff
48 fteqccdir="$base/fteqcc"
49 fteqccflags=""
50 menuqc=menu
51 newest=NEWEST
52 aft="perl -I/chroot/debian-etch/usr/share/aft /chroot/debian-etch/usr/bin/aft"
53 tag=
54
55 mk7z()
56 {
57         7za a -tzip -mx=9 "$@"
58         chmod 644 "$1"
59 }
60
61 #if [ -n "$EXPERIMENTAL" ]; then
62 #       basepk3=$base/data20071231.pk3 # newer build to make smaller patches
63 #       nexdir=$base/nexuiz
64 #fi
65
66 # TODO normalize the builds
67 platforms='x86 amd64 osx'
68 buildon()
69 {
70         host=$1
71         prefix=$2
72         fteqccname=$3
73         path=$4
74         makeflags=$5
75         strip=$6
76
77         fteqcc_cflags=
78         case "$fteqccname" in
79                 *.exe)
80                         fteqcc_cflags=win
81                         ;;
82         esac
83
84         rm -f "$fteqccdir"/*.o
85         rm -f "$fteqccdir"/*.bin
86         rsync --exclude "*.o" --exclude "*.d" --exclude "nexuiz-*" --delete-excluded --delete -zvaSHP . "$copystrip" "$fteqccdir" "$host:$path"
87         ssh "$host" ". ~/.profile && cd $path && COPYSTRIP_STRIP=$strip PATH=$path/copystrip:\$PATH make $makeflags clean nexuiz && cd ${fteqccdir##*/} && make $makeflags $fteqcc_cflags"
88         rsync --exclude "*.o" --exclude "*.d" --delete-excluded --delete -zvaSHP "$host:$path/." .
89         for P in -dedicated -sdl -glx -wgl -agl -dedicated.exe -sdl.exe .exe; do
90                 [ -f nexuiz$P ] && mv nexuiz$P "$tmpdir/$prefix$P"
91                 [ -f nexuiz$P-withdebug ] && mv nexuiz$P-withdebug "$tmpdir/debuginfo/$prefix$P"
92         done
93         case "$fteqccname" in
94                 *.exe)
95                         mv "${fteqccdir##*/}"/fteqcc.exe "$tmpdir/fteqcc/$fteqccname"
96                         ;;
97                 *)
98                         mv "${fteqccdir##*/}"/fteqcc.bin "$tmpdir/fteqcc/$fteqccname"
99                         ;;
100         esac
101         make clean
102 }
103
104 build()
105 {
106         buildon mac.alientrap.org                     nexuiz-osx          fteqcc-osx          /tmp/Darkplaces.build 'CC="gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"' strip
107                 mv "$tmpdir/nexuiz-osx-agl"     "$tmpdir/Nexuiz.app/Contents/MacOS/nexuiz-osx-agl-bin"
108                 mv "$tmpdir/nexuiz-osx-sdl"     "$tmpdir/Nexuiz-SDL.app/Contents/MacOS/nexuiz-osx-sdl-bin"
109         buildon alientrap.org                         nexuiz              fteqcc.exe          /tmp/Darkplaces.build 'DP_MAKE_TARGET=mingw CC="/chroot/debian-etch/usr/bin/i586-mingw32msvc-gcc -g" WINDRES=/chroot/debian-etch/usr/bin/i586-mingw32msvc-windres SDL_CONFIG=/home/divverent/sdl-win32/SDL-1.2.13/bin/sdl-config' /chroot/debian-etch/usr/bin/i586-mingw32msvc-strip
110         buildon alientrap.org                         nexuiz-linux-686    fteqcc-linux-686    /tmp/Darkplaces.build 'CC="gcc -m32 -L/chroot/debian-etch/usr/include -L/chroot/debian-etch/lib -L/chroot/debian-etch/usr/lib -g -Wl,-rpath,/chroot/debian-etch/usr/lib" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-i386/lib SDL_CONFIG=/home/divverent/sdl-config-debian32' strip
111         buildon alientrap.org                         nexuiz-linux-x86_64 fteqcc-linux-x86_64 /tmp/Darkplaces.build 'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-x86_64/lib' strip
112 }
113
114 i=
115 while [ -f "$zipdir/nexuiz$date$i$ext.zip" ]; do
116         if [ -z "$i" ]; then
117                 i=a
118         else
119                 i=`echo "$i" | tr a-y b-z`
120         fi
121 done
122 ext=$i$ext
123
124 echo "Using build name nexuiz$date$ext"
125 sleep 3
126
127 if [ -n "$1" ]; then
128         osxhost="$1"
129 fi
130
131 conflicts=`find "$dpdir" "$nexdir" -name '*.orig' -o -name '*.rej' -o -name '*.mine' -o -name '.#*' -o -name '.*~'`
132 if [ -n "$conflicts" ]; then
133         echo "CONFLICTS OR UNNEEDED FILES HAVE BEEN FOUND!"
134         echo "NOT PROCEEDING"
135         echo
136         echo "$conflicts"
137         exit 1
138 fi
139
140 set -x
141
142 rm -rf "$tmpdir"
143 mkdir -p "$tmpdir"
144
145 cd "$dpdir"
146 quilt pop -a || true
147 svn revert -R .
148 quilt push -a # apply all patches
149
150 cp -r "$osxapps"/*.app "$tmpdir"
151 mkdir "$tmpdir/debuginfo"
152 mkdir "$tmpdir/fteqcc"
153
154 svn export "$fteqccdir" "$tmpdir/fteqcc/source"
155 svn info "$fteqccdir" > "$tmpdir/fteqcc/source/fteqcc-base-revision.txt"
156 fteqccrev=$((`grep "Last Changed Rev:" "$tmpdir/fteqcc/source/fteqcc-base-revision.txt" | cut -d : -f 2`))
157 echo "fteqcc rev $fteqccrev"
158
159 rm -f *.exe nexuiz-* *-withdebug* *.o
160 make clean
161 build
162 rm -f *.exe nexuiz-* *-withdebug '.#'* *.o
163 rm -rf fteqcc copystrip
164 make clean
165
166 cd "$tmpdir"
167 cp "$nexdir/"nexuiz-*.sh "$tmpdir/"
168 cp "$nexdir/gpl.txt" "$tmpdir/"
169
170 cd "$nexdir/data"
171 svn export . "$tmpdir/data"
172 svn info . > "$tmpdir/data/nexuiz-data-base-revision.txt"
173 svn log > "$tmpdir/data/ChangeLog"
174
175 cd "$nexprodir"
176 svn export . "$tmpdir/pro"
177
178 cd "$nexdir/Docs"
179 svn export . "$tmpdir/Docs"
180
181 cd "$tmpdir/data"
182 mkdir -p "$tmpdir/sources"
183 mk7z ../sources/gamesource$date.zip qcsrc nexuiz-data-base-revision.txt ChangeLog
184
185 cd "$dpdir"
186 svn export . "$tmpdir/darkplaces"
187 svn info > "$tmpdir/darkplaces/nexuiz-base-revision.txt"
188 svn diff > "$tmpdir/darkplaces/nexuiz-engine-changes.diff"
189 svn log > "$tmpdir/darkplaces/ChangeLog"
190
191 cd "$tmpdir"
192 mk7z "$tmpdir/sources/enginesource$date.zip" "darkplaces"
193 rm -rf darkplaces
194
195 cd "$tmpdir"
196 zip -9r "$tmpdir/sources/fteqcc-binaries-and-source-rev$fteqccrev.zip" "fteqcc"
197 rm -rf fteqcc
198
199 cd "$fteqccdir"
200 rm -f *.o *.bin
201 make
202
203 cd "$tmpdir/data/qcsrc/$menuqc"
204 "$fteqccdir/fteqcc.bin" $fteqccflags
205
206 cd "$tmpdir/data/qcsrc/server"
207 "$fteqccdir/fteqcc.bin" $fteqccflags
208
209 rm -rf "$tmpdir/data/qcsrc"
210
211 cd "$tmpdir/Docs"
212 perl -pi -e '/^#---SET nexversion=([0-9.]*)$/ and $_ = "#---SET nexversion='$version'\n"' FAQ.aft
213 perl -pi -e '/^\s*Version ([0-9.]*)<\/div>$/ and $_ = "Version '$version'</div>\n"' Readme.htm
214 cp "$dpdir/darkplaces.txt" .
215 $aft FAQ.aft
216 $aft FAQ.aft
217 rm FAQ.aft-TOC
218
219 cd "$tmpdir/data"
220 mv common-spog.pk3 ..
221 perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version'\n"' default.cfg
222 if [ -n "$versiontag" ]; then
223         perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
224         cp "$buildfiles/brand/$versiontag.tga" gfx/brand.tga
225 fi
226 echo >> default.cfg
227 echo "$defaultcfg" >> default.cfg
228 mk7z ../data.pk3 .
229
230 cd "$tmpdir/pro"
231 perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version-pro'\n"' default.cfg
232 if [ -n "$versiontag" ]; then
233         perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
234 fi
235 echo >> default.cfg
236 echo "$defaultcfg" >> default.cfg
237 mk7z ../pro.pk3 .
238
239 cd "$tmpdir"
240 rm -rf data
241 mkdir data
242 mv data.pk3 data/data$tag$date.pk3
243 mv common-spog.pk3 data/
244 rm -rf pro
245 mkdir pro
246 mv pro.pk3 pro/data$tag${date}pro.pk3
247
248 cp -r "$mingwdlls"/* .
249 # fix up permissions
250 chmod 644 *.dll *.exe
251
252 mkdir Nexuiz
253 mv * Nexuiz/ || true
254
255 find . -name .svn -exec rm -rf {} \; -prune
256
257 rm -f "$zipdir/nexuiz$date$ext.zip"
258 zip $zipflags -9yr "$zipdir/nexuiz$date$ext.zip"           Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/data/data$tag$date.pk3 Nexuiz/data/common-spog.pk3 Nexuiz/pro/*
259 ln -snf nexuiz$date$ext.zip "$zipdir/nexuiz-$newest.zip"
260
261 rm -f "$zipdir/nexuizengineonly$date$ext.zip"
262 zip $zipflags -9yr "$zipdir/nexuizengineonly$date$ext.zip" Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll
263 ln -snf nexuizengineonly$date$ext.zip "$zipdir/nexuizengineonly-$newest.zip"
264
265 rm -f "$zipdir/nexuizsource$date$ext.zip"
266 zip $zipflags -9yr "$zipdir/nexuizsource$date$ext.zip"     Nexuiz/gpl.txt                                            Nexuiz/sources
267 ln -snf nexuizsource$date$ext.zip "$zipdir/nexuizsource-$newest.zip"
268
269 $zipdiff -o "Nexuiz/data/datapatch$tag$date.pk3" -f "$basepk3" -t Nexuiz/data/data$tag$date.pk3 -x 'sound/cdtracks/track*.ogg'
270 [ -n "$hotbasepk3" ] && $zipdiff -o "Nexuiz/data/datapatch$tag$date""hotfix.pk3" -f "$hotbasepk3" -t Nexuiz/data/data$tag$date.pk3
271 mkdir -p gfx
272 if unzip "Nexuiz/data/data$tag$date.pk3" gfx/brand.tga; then
273         zip $zipflags -9r "Nexuiz/data/datapatch$tag$date.pk3" gfx/brand.tga
274         [ -n "$hotbasepk3" ] && zip $zipflags -9r "Nexuiz/data/datapatch$tag$date""hotfix.pk3" gfx/brand.tga
275         rm -rf gfx
276 fi
277
278 rm -f "$zipdir/nexuizpatch$date$ext.zip"
279 zip $zipflags -9yr "$zipdir/nexuizpatch$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/data/datapatch$tag$date.pk3 Nexuiz/pro/*
280 ln -snf nexuizpatch$date$ext.zip "$zipdir/nexuizpatch-$newest.zip"
281
282 [ -n "$hotbasepk3" ] && rm -f "$zipdir/nexuizhotfix$date$ext.zip"
283 [ -n "$hotbasepk3" ] && zip $zipflags -9yr "$zipdir/nexuizhotfix$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/data/datapatch$tag$date""hotfix.pk3 Nexuiz/pro/*
284 [ -n "$hotbasepk3" ] && ln -snf nexuizhotfix$date$ext.zip "$zipdir/nexuizhotfix-$newest.zip"
285
286 rm -f "$zipdir/nexuizdocs$date$ext.zip"
287 zip $zipflags -9yr "$zipdir/nexuizdocs$date$ext.zip"       Nexuiz/gpl.txt Nexuiz/Docs
288 ln -snf nexuizdocs$date$ext.zip "$zipdir/nexuizdocs-$newest.zip"
289
290 rm -f "$zipdir/nexuizdebug$date$ext.zip"
291 zip $zipflags -9yr "$zipdir/nexuizdebug$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/debuginfo/* Nexuiz/sources
292 ln -snf nexuizdebug$date$ext.zip "$zipdir/nexuizdebug-$newest.zip"