add a nice patch from esteel to fix the rapid weapon switching "NexMG"
[divverent/nexuiz.git] / misc / makebuild.sh
1 #!/bin/sh
2 set -ex
3
4 base=`pwd`
5
6 basepk3=$base/data20060905.pk3
7 nexdir=$base/nexuiz
8 dpdir=$base/darkplaces
9 tmpdir=/tmp/NEX
10 zipdir=/home/polzer/UT/distfiles/nex/
11 buildfiles=$base/buildfiles
12 mingwdlls=$buildfiles/w32
13 osxapps=$buildfiles/osx
14 copystrip=$buildfiles/copystrip
15 fteqcc="fteqcc.bin -O2"
16 mingw=/home/polzer/mingw32
17 ia32=/chroot/fc5-i386
18 osxhost=macmini_osx
19 osxtemp=/Users/rpolzer/Darkplaces.build
20
21 if [ -n "$1" ]; then
22         osxhost=macmini
23 fi
24
25 : ${date:=`date +%Y%m%d`}
26 : ${versiontag:=}
27 echo "date stamp: $date"
28
29 buildosx()
30 {
31         rsync --exclude "*.o" --exclude "*.d" --exclude "nexuiz-*" --delete-excluded --delete -zvaSHP . $copystrip "$osxhost:$osxtemp"
32         ssh "$osxhost" ". ~/.profile && cd $osxtemp && PATH=$osxtemp/copystrip:\$PATH make CC=\"gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk\" clean $*"
33         rsync --exclude "*.o" --exclude "*.d" --delete-excluded --delete -zvaSHP "$osxhost:$osxtemp/." .
34 }
35
36 build64()
37 {
38         PATH=$copystrip:$PATH make CC="gcc -g" "$@"
39 }
40
41 build32()
42 {
43         PATH=$copystrip:$PATH make CC="gcc -g -I$ia32/usr/include -I$ia32/usr/X11R6/include -L$ia32/usr/lib -L$ia32/usr/X11R6/lib -m32" DP_MACHINE=i686 "$@"
44 }
45
46 buildwin()
47 {
48         PATH=$copystrip:$mingw/bin:$PATH make CC="gcc -g" DP_MAKE_TARGET=mingw "$@"
49 }
50
51 rm -rf "$tmpdir"
52 mkdir -p "$tmpdir"
53 cd "$dpdir"
54
55 cp -r "$osxapps"/*.app "$tmpdir"
56 mkdir "$tmpdir/debuginfo"
57 rm -f *.exe nexuiz-* *-withdebug
58
59 make clean
60 buildosx sdl-nexuiz cl-nexuiz sv-nexuiz
61 cp nexuiz-agl "$tmpdir/Nexuiz.app/Contents/MacOS/nexuiz-osx-ppc-agl-bin"
62 cp nexuiz-dedicated "$tmpdir/nexuiz-osx-ppc-dedicated"
63 cp nexuiz-sdl "$tmpdir/Nexuiz-SDL.app/Contents/MacOS/nexuiz-osx-ppc-sdl-bin"
64 cp nexuiz-agl-withdebug "$tmpdir/debuginfo/nexuiz-osx-ppc-agl-bin"
65 cp nexuiz-dedicated-withdebug "$tmpdir/debuginfo/nexuiz-osx-ppc-dedicated-bin"
66 cp nexuiz-sdl-withdebug "$tmpdir/debuginfo/nexuiz-osx-ppc-sdl-bin"
67
68 make clean
69 buildwin nexuiz
70 for x in -dedicated -sdl ''; do
71         cp nexuiz$x.exe "$tmpdir/nexuiz$x.exe"
72         cp nexuiz$x.exe-withdebug "$tmpdir/debuginfo/nexuiz$x.exe"
73 done
74
75 make clean
76 build32 nexuiz
77 for x in dedicated sdl glx; do
78         cp nexuiz-$x "$tmpdir/nexuiz-linux-686-$x"
79         cp nexuiz-$x-withdebug "$tmpdir/debuginfo/nexuiz-linux-686-$x"
80 done
81
82 make clean
83 build64 nexuiz
84 for x in dedicated sdl glx; do
85         cp nexuiz-$x "$tmpdir/nexuiz-linux-x86_64-$x"
86         cp nexuiz-$x-withdebug "$tmpdir/debuginfo/nexuiz-linux-x86_64-$x"
87 done
88
89 cp "$nexdir/nexuiz-linux-sdl.sh" "$tmpdir/"
90 cp "$nexdir/nexuiz-linux-glx.sh" "$tmpdir/"
91 cp "$nexdir/gpl.txt" "$tmpdir/"
92
93 make clean
94 rm -f *.exe nexuiz-* *-withdebug '.#'*
95
96 cd "$nexdir/data"
97 svn export . "$tmpdir/data"
98
99 cd "$nexdir/Docs"
100 svn export . "$tmpdir/Docs"
101
102 cd "$tmpdir/data"
103 mkdir -p "$tmpdir/sources"
104 #zip -9r ../sources/gamesource$date.zip qcsrc
105 7za a -mx=9 -tzip ../sources/gamesource$date.zip qcsrc
106
107 cd "$dpdir/.."
108 #zip -9r "$tmpdir/sources/enginesource$date.zip" "${dpdir##*/}"
109 7za a -mx=9 -tzip "$tmpdir/sources/enginesource$date.zip" "${dpdir##*/}"
110
111 cd "$tmpdir/data/qcsrc/menu"
112 $fteqcc
113
114 cd "$tmpdir/data/qcsrc/server"
115 $fteqcc
116
117 rm -rf "$tmpdir/data/qcsrc"
118
119 cd "$tmpdir/data"
120 mv common-spog.pk3 ..
121 #zip -9r ../data.pk3 .
122 v=$versiontag perl -pi -e '/^set g_nexuizversion "([0-9.]*)[^"]*"/ and $_ = "set g_nexuizversion \"$1$ENV{v}\"\n"' default.cfg
123 if [ -n "$versiontag" ]; then
124         perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 1\n$_"' default.cfg
125         cp "$buildfiles/brand/$versiontag.tga" gfx/brand.tga
126 fi
127 7za a -mx=7 -tzip ../data.pk3 .
128
129 cd "$tmpdir"
130 rm -rf data
131 mkdir data
132 mv data.pk3 data/data$date.pk3
133 mv common-spog.pk3 data/
134
135 cp -r "$mingwdlls"/* .
136 # fix up permissions
137 chmod 644 *.dll *.exe
138
139 mkdir Nexuiz
140 mv * Nexuiz/ || true
141
142 find . -name .svn -exec rm -rf {} \; -prune
143
144 rm -f "$zipdir/nexuiz$date$ext.zip"
145 zip -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
146 rm -f "$zipdir/nexuizengineonly$date$ext.zip"
147 zip -9yr "$zipdir/nexuizengineonly$date$ext.zip" Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll
148 rm -f "$zipdir/nexuizsource$date$ext.zip"
149 zip -9yr "$zipdir/nexuizsource$date$ext.zip"     Nexuiz/gpl.txt                                            Nexuiz/sources
150
151 zipdiff -o "Nexuiz/data/datapatch$date.pk3" -f "$basepk3" -t Nexuiz/data/data$date.pk3
152 mkdir -p gfx
153 if unzip "Nexuiz/data/data$date.pk3" gfx/brand.tga; then
154         zip -9r "Nexuiz/data/datapatch$date.pk3" gfx/brand.tga
155         rm -rf gfx
156 fi
157
158 rm -f "$zipdir/nexuizpatch$date$ext.zip"
159 zip -9yr "$zipdir/nexuizpatch$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/data/datapatch$date.pk3
160
161 rm -f "$zipdir/nexuizdebug$date$ext.zip"
162 zip -9yr "$zipdir/nexuizdebug$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/debuginfo/*