Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 384 lines (321 sloc) 9.528 kb
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
1 #!/bin/bash
2
3 set -e
4
87b9c57 @joshthecoder Added cyphesis support.
joshthecoder authored
5 export HAMMERDIR=$PWD/hammer
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
6 export PREFIX=$PWD/local
7 export SOURCE=$PWD/dev/worldforge
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
8 export DEPS_SOURCE=$PWD/dev
d3c089f @joshthecoder Removed the make -s option. Doesn't help any.
joshthecoder authored
9 export MAKEOPTS="-j3"
355bf65 @erikogenvik Include the original PKG_CONFIG_PATH as well.
erikogenvik authored
10 export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
a0d9f19 @joshthecoder arch --> uname
joshthecoder authored
11 export BUILDDIR=`uname -m`
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
12
4ffe0b3 @joshthecoder Minor fixes.
joshthecoder authored
13 # setup directories
14 mkdir -p $PREFIX
15 mkdir -p $DEPS_SOURCE
dde0cd5 @joshthecoder Bump ogre version.
joshthecoder authored
16 mkdir -p $SOURCE
4ffe0b3 @joshthecoder Minor fixes.
joshthecoder authored
17
477df2d @joshthecoder Added logging build output to files.
joshthecoder authored
18 # Log Directory
19 LOGDIR=$PWD/logs
20 mkdir -p $LOGDIR
21
22 # Output redirect logs
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
23 AUTOLOG=autogen.log # Autogen output
24 CONFIGLOG=config.log # Configure output
25 MAKELOG=build.log # Make output
26 INSTALLLOG=install.log # Install output
477df2d @joshthecoder Added logging build output to files.
joshthecoder authored
27
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
28 # Dependencies
9b1790d @erikogenvik Bumped Ogre and CEGUI versions.
erikogenvik authored
29 CEGUI=CEGUI-0.7.5
30 CEGUI_DOWNLOAD=CEGUI-0.7.5.tar.gz
31 OGRE=ogre_1_7_2
32 OGRE_DOWNLOAD=ogre_src_v1-7-2.tar.bz2
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
33
a7f75ad @erikogenvik Various fixes for getting it to compile on mingw.
erikogenvik authored
34 CONFIGURE_EXTRA_FLAGS=""
e517660 @erikogenvik Upgrade to Ogre 1.7.1 and CEGUI 0.7.1. Note that this haven't been tried
erikogenvik authored
35 CMAKE_EXTRA_FLAGS=""
a7f75ad @erikogenvik Various fixes for getting it to compile on mingw.
erikogenvik authored
36
d5a1b34 @erikogenvik Protect from empty string.
erikogenvik authored
37 if [ x$MSYSTEM = x"MINGW32" ] ; then
a7f75ad @erikogenvik Various fixes for getting it to compile on mingw.
erikogenvik authored
38 export CXXFLAGS="-march=i686 $CXXFLAGS"
39 export CONFIGURE_EXTRA_FLAGS="--enable-shared --disable-static"
40 export LDFLAGS="-no-undefined $LDFLAGS"
41 fi
42
43
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
44 function buildwf()
45 {
477df2d @joshthecoder Added logging build output to files.
joshthecoder authored
46 mkdir -p $LOGDIR/$1
47
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
48 cd $SOURCE/forge/$1
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
49 if [ ! -f "configure" ] ; then
50 echo " Running autogen..."
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
51 NOCONFIGURE=1 ./autogen.sh > $LOGDIR/$1/$AUTOLOG
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
52 fi
53
54 mkdir -p $BUILDDIR
55 cd $BUILDDIR
f411aca @joshthecoder Added ability to select build target.
joshthecoder authored
56 if [ ! -f "Makefile" ] ; then
355bf65 @erikogenvik Include the original PKG_CONFIG_PATH as well.
erikogenvik authored
57 echo " Running configure..."
a7f75ad @erikogenvik Various fixes for getting it to compile on mingw.
erikogenvik authored
58 ../configure --prefix=$PREFIX $CONFIGURE_EXTRA_FLAGS > $LOGDIR/$1/$CONFIGLOG
f411aca @joshthecoder Added ability to select build target.
joshthecoder authored
59 fi
477df2d @joshthecoder Added logging build output to files.
joshthecoder authored
60
1fa95d8 @joshthecoder Added a few echoes in buildwf.
joshthecoder authored
61 echo " Building..."
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
62 make $MAKEOPTS > $LOGDIR/$1/$MAKELOG
1fa95d8 @joshthecoder Added a few echoes in buildwf.
joshthecoder authored
63 echo " Installing..."
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
64 make install > $LOGDIR/$1/$INSTALLLOG
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
65 }
66
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
67 function checkoutwf()
68 {
69 if [ ! -d $1 ]; then
edb7af1 @erikogenvik Update with Github urls.
erikogenvik authored
70 git clone git://github.com/worldforge/$1.git
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
71 else
72 cd $1 && git fetch && git rebase origin/master && cd ..
73 fi
74 }
75
87b9c57 @joshthecoder Added cyphesis support.
joshthecoder authored
76 function cyphesis_post_install()
77 {
78 cd $PREFIX/bin
79
80 # Rename real cyphesis binary to cyphesis.bin
81 mv cyphesis cyphesis.bin
82
83 # Install our cyphesis.in script as cyphesis
84 cp $HAMMERDIR/cyphesis.in cyphesis
85 chmod +x cyphesis
86 }
87
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
88 function show_help()
89 {
90 if [ $1 = "main" ] ; then
91 echo "Script for automating the process of installing dependencies"
87b9c57 @joshthecoder Added cyphesis support.
joshthecoder authored
92 echo "and compiling Worldforge in a self contained environment."
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
93 echo ""
94 echo "Usage: hammer.sh <command> <arguments>"
95 echo "Commands:"
96 echo " install-deps - install all 3rd party dependencies"
97 echo " checkout - fetch worldforge source (libraries, clients)"
98 echo " build - build the sources and install in environment"
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
99 echo " clean - delete build directory so a fresh build can be performed"
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
100 echo ""
101 echo "For more help, type: hammer.sh help <command>"
102 elif [ $1 = "install-deps" ] ; then
103 echo "Install all 3rd party dependencies into build environment."
104 echo ""
105 echo "Usage: hammer.sh install-deps <dependency to install>"
106 echo "Dependencies Available:"
107 echo " all - install all dependencies listed below"
108 echo " cegui - a free library providing windowing and widgets for
109 graphics APIs / engines"
110 echo " ogre - 3D rendering engine"
07b40e1 @erikogenvik Updated help texts.
erikogenvik authored
111 echo "Hint: build ogre first then cegui"
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
112 elif [ $1 = "checkout" ] ; then
113 echo "Fetch latest source code for worldforge libraries and clients."
114 echo ""
115 echo "Usage: hammer.sh checkout"
116 elif [ $1 = "build" ] ; then
117 echo "Build the sources and install in environment."
118 echo ""
da7cd4e @joshthecoder Added support for passing in make options.
joshthecoder authored
119 echo "Usage: hammer.sh build <target> \"<makeopts>\""
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
120 echo "Available targets:"
121 echo " libs - build libraries only"
122 echo " ember - build ember only"
87b9c57 @joshthecoder Added cyphesis support.
joshthecoder authored
123 echo " cyphesis - build cyphesis server only"
da7cd4e @joshthecoder Added support for passing in make options.
joshthecoder authored
124 echo "makeopts [optional] - options to pass into make"
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
125 echo ""
126 echo "Hint: after a checkout use 'all'. To rebuild after changing code"
127 echo "only in Ember, use 'ember'. Will build much quicker!"
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
128 elif [ $1 = "clean" ] ; then
129 echo "Clean out build files of a project."
130 echo ""
131 echo "Usage: hammer.sh clean <target>"
132 echo "Targets:"
133 echo " cegui, ogre, libs/<name>, clients/<name>, servers/<name>"
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
134 else
135 echo "No help page found!"
136 fi
137 }
138
139 # Show main help page if no arguments given
140 if [ $# -eq 0 ] ; then
141 show_help "main"
142
143 # If help command given, show help page
144 elif [ $1 = "help" ] ; then
145 if [ $# -eq 2 ] ; then
146 show_help $2
147 else
148 show_help "main"
149 fi
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
150
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
151 mkdir -p $PREFIX $SOURCE $DEPS_SOURCE
152
153 # Dependencies install
71810f9 @joshthecoder Added help command that will display help text.
joshthecoder authored
154 elif [ $1 = "install-deps" ] ; then
fb61b3f @joshthecoder Updated Ogre. Added parameter checks.
joshthecoder authored
155 if [ $# -ne 2 ] ; then
156 echo "Missing required parameter!"
157 show_help "install-deps"
158 exit 1
159 fi
160
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
161 echo "Installing deps..."
162
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
163 # Create deps log directory
164 mkdir -p $LOGDIR/deps
165
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
166 # Ogre3D
167 if [ $2 = "all" ] || [ $2 = "ogre" ] ; then
168 echo " Installing Ogre..."
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
169 mkdir -p $LOGDIR/deps/ogre
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
170 cd $DEPS_SOURCE
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
171 if [ ! -d $OGRE ]; then
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
172 echo " Downloading..."
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
173 wget -c http://downloads.sourceforge.net/sourceforge/ogre/$OGRE_DOWNLOAD
174 mkdir -p $OGRE
175 cd $OGRE
176 tar -xjf ../$OGRE_DOWNLOAD
1b99135 @joshthecoder Fixes for errors during testing.
joshthecoder authored
177 fi
e517660 @erikogenvik Upgrade to Ogre 1.7.1 and CEGUI 0.7.1. Note that this haven't been tried
erikogenvik authored
178 cd $DEPS_SOURCE/$OGRE/`ls $DEPS_SOURCE/$OGRE`
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
179 mkdir -p $BUILDDIR
180 cd $BUILDDIR
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
181 echo " Configuring..."
a7f75ad @erikogenvik Various fixes for getting it to compile on mingw.
erikogenvik authored
182 OGRE_EXTRA_FLAGS=""
95a84b8 @kblin Another empty string protection.
kblin authored
183 if [ x$MSYSTEM = x"MINGW32" ] ; then
a7f75ad @erikogenvik Various fixes for getting it to compile on mingw.
erikogenvik authored
184 OGRE_EXTRA_FLAGS="--with-gui=win32 --with-platform=win32 --enable-direct3d"
185 # We need to alter the configure script to use "-mthreads" instead of "-pthread" as the latter isn't available when using mingw gcc
186 # The check for FreeImage also needs to be slightly altered on mingw.
187 sed -i -e 's/-pthread/-mthreads/g' -e 's/char FreeImage_Load ();/#include <FreeImage.h>/g' -e 's/return FreeImage_Load ();/FreeImage_Load(FIF_UNKNOWN, "test.png", 0);/g' ../configure
188 fi
e517660 @erikogenvik Upgrade to Ogre 1.7.1 and CEGUI 0.7.1. Note that this haven't been tried
erikogenvik authored
189 cmake .. -DCMAKE_INSTALL_PREFIX="$PREFIX" -DOGRE_BUILD_SAMPLES=false $OGRE_EXTRA_FLAGS $CMAKE_EXTRA_FLAGS > $LOGDIR/deps/ogre/$CONFIGLOG
819925a @joshthecoder Added logging for dependency install.
joshthecoder authored
190 echo " Building..."
191 make $MAKEOPTS > $LOGDIR/deps/ogre/$MAKELOG
192 echo " Installing..."
193 make install > $LOGDIR/deps/ogre/$INSTALLLOG
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
194 echo " Done."
195 fi
196
e517660 @erikogenvik Upgrade to Ogre 1.7.1 and CEGUI 0.7.1. Note that this haven't been tried
erikogenvik authored
197 # CEGUI
198 if [ $2 = "all" ] || [ $2 = "cegui" ] ; then
199 echo " Installing CEGUI..."
200 mkdir -p $LOGDIR/deps/CEGUI # create CEGUI log directory
201 cd $DEPS_SOURCE
202 if [ ! -d $CEGUI ] ; then
203 echo " Downloading..."
204 wget -c http://downloads.sourceforge.net/sourceforge/crayzedsgui/$CEGUI_DOWNLOAD
205 tar zxvf $CEGUI_DOWNLOAD
206 fi
207 cd $CEGUI
208 mkdir -p $BUILDDIR
209 cd $BUILDDIR
210 echo " Configuring..."
211 ../configure --prefix=$PREFIX --disable-samples --disable-opengl-renderer --disable-irrlicht-renderer --disable-xerces-c --disable-libxml --disable-expat --disable-directfb-renderer $CONFIGURE_EXTRA_FLAGS > $LOGDIR/deps/CEGUI/$CONFIGLOG
212 echo " Building..."
213 make $MAKEOPTS > $LOGDIR/deps/CEGUI/$MAKELOG
214 echo " Installing..."
215 make install > $LOGDIR/deps/CEGUI/$INSTALLLOG
216 echo " Done."
217 fi
218
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
219 echo "Install Done."
220
221 # Source checkout
222 elif [ $1 = "checkout" ] ; then
223 echo "Fetching sources..."
224
41676a5 @joshthecoder Minor fix.
joshthecoder authored
225 mkdir -p $SOURCE/forge/libs
b22888e @joshthecoder Bump ogre version to 1.6. Checkout atlas and varconf from Git.
joshthecoder authored
226 cd $SOURCE/forge/libs
227
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
228 # Varconf
229 echo " Varconf..."
b22888e @joshthecoder Bump ogre version to 1.6. Checkout atlas and varconf from Git.
joshthecoder authored
230 checkoutwf "varconf"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
231 echo " Done."
232
b22888e @joshthecoder Bump ogre version to 1.6. Checkout atlas and varconf from Git.
joshthecoder authored
233 # Atlas-C++
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
234 echo " Atlas-C++..."
edb7af1 @erikogenvik Update with Github urls.
erikogenvik authored
235 checkoutwf "atlas-cpp"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
236 echo " Done."
237
238 # Skstream
239 echo " Skstream..."
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
240 checkoutwf "skstream"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
241 echo " Done."
242
243 # Wfmath
244 echo " Wfmath..."
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
245 checkoutwf "wfmath"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
246 echo " Done."
247
248 # Eris
249 echo " Eris..."
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
250 checkoutwf "eris"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
251 echo " Done."
252
253 # Libwfut
254 echo " Libwfut..."
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
255 checkoutwf "libwfut"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
256 echo " Done."
257
258 # Mercator
259 echo " Mercator..."
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
260 checkoutwf "mercator"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
261 echo " Done."
262
263 # Ember client
264 echo " Ember client..."
265 mkdir -p $SOURCE/forge/clients
266 cd $SOURCE/forge/clients
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
267 checkoutwf "ember"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
268 echo " Done."
269
87b9c57 @joshthecoder Added cyphesis support.
joshthecoder authored
270 # Cyphesis
271 echo " Cyphesis..."
272 mkdir -p $SOURCE/forge/servers
273 cd $SOURCE/forge/servers
274 checkoutwf "cyphesis"
275 echo " Done."
276
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
277 echo "Checkout Done."
278
279 # Build source
280 elif [ $1 = "build" ] ; then
da7cd4e @joshthecoder Added support for passing in make options.
joshthecoder authored
281 if [ $# -lt 2 ] ; then
fb61b3f @joshthecoder Updated Ogre. Added parameter checks.
joshthecoder authored
282 echo "Missing required parameter!"
283 show_help "build"
da7cd4e @joshthecoder Added support for passing in make options.
joshthecoder authored
284 exit 1
285 fi
286
287 # Check for make options
288 if [ $# -ge 3 ] ; then
289 MAKEOPTS=$3
fb61b3f @joshthecoder Updated Ogre. Added parameter checks.
joshthecoder authored
290 fi
291
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
292 echo "Building sources..."
f411aca @joshthecoder Added ability to select build target.
joshthecoder authored
293
294 # Build libraries
295 if [ $2 = "libs" ] || [ $2 = "all" ] ; then
296
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
297 # Varconf
298 echo " Varconf..."
299 buildwf "libs/varconf"
300 echo " Done."
301
302 # Skstream
303 echo " Skstream..."
304 buildwf "libs/skstream"
305 echo " Done."
306
307 # Wfmath
308 echo " Wfmath..."
309 buildwf "libs/wfmath"
310 echo " Done."
311
312 # Atlas-C++
313 echo " Atlas-C++..."
0938978 @joshthecoder Minor fix.
joshthecoder authored
314 buildwf "libs/atlas-c++"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
315 echo " Done."
316
1b99135 @joshthecoder Fixes for errors during testing.
joshthecoder authored
317 # Mercator
318 echo " Mercator..."
319 buildwf "libs/mercator"
320 echo " Done."
321
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
322 # Eris
323 echo " Eris..."
324 buildwf "libs/eris"
325 echo " Done."
326
327 # Libwfut
328 echo " Libwfut..."
329 buildwf "libs/libwfut"
330 echo " Done."
331
fde5310 @joshthecoder Fix for build all issue where ember and cyphesis where not getting
joshthecoder authored
332 fi
333
334 if [ $2 = "ember" ] || [ $2 = "all" ] ; then
f411aca @joshthecoder Added ability to select build target.
joshthecoder authored
335
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
336 # Ember client
337 echo " Ember client..."
b3e1474 @erikogenvik Oops, this shouldn't have been commented out.
erikogenvik authored
338 buildwf "clients/ember"
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
339 echo " Done."
340
a7f75ad @erikogenvik Various fixes for getting it to compile on mingw.
erikogenvik authored
341 if command -v rsync &> /dev/null; then
342 echo "Fetching media..."
343 cd $SOURCE/forge/clients/ember/$BUILDDIR
344 make devmedia
345 echo "Media fetched."
346 else
347 echo "Rsync not found, skipping fetching media. You will need to download and install it yourself."
348 fi
2806726 @joshthecoder Applying patch from Erik.
joshthecoder authored
349
fde5310 @joshthecoder Fix for build all issue where ember and cyphesis where not getting
joshthecoder authored
350 fi
351
352 if [ $2 = "cyphesis" ] || [ $2 = "all" ] ; then
87b9c57 @joshthecoder Added cyphesis support.
joshthecoder authored
353
354 # Cyphesis
355 echo " Cyphesis..."
356 buildwf "servers/cyphesis"
357 cyphesis_post_install
358 echo " Done."
359
360 fi
361
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
362 echo "Build Done."
363
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
364 elif [ $1 = "clean" ] ; then
365 if [ $# -ne 2 ] ; then
366 echo "Missing required parameter!"
367 show_help "clean"
368 exit 1
369 fi
817c9a5 @joshthecoder Initial commit!
joshthecoder authored
370
bdb8ced @joshthecoder Added clean command to delete build files.
joshthecoder authored
371 # Delete build directory
372 if [ $2 = "cegui" ] ; then
373 rm -rf $DEPS_SOURCE/$CEGUI/$BUILDDIR
374 elif [ $2 = "ogre" ] ; then
375 rm -rf $DEPS_SOURCE/$OGRE/ogre/$BUILDDIR
376 else
377 rm -rf $SOURCE/forge/$2/$BUILDDIR
378 fi
379
380 else
381 echo "Invalid command!"
382 show_help "main"
383 fi
Something went wrong with that request. Please try again.