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