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