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