This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathhammer.sh
executable file
·882 lines (777 loc) · 27.3 KB
/
hammer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
#!/bin/bash
set -e
function show_help()
{
if [ "$1" = "main" ] ; then
echo "Script for automating the process of installing dependencies"
echo "and compiling Worldforge in a self contained environment."
echo ""
echo "Usage: hammer.sh [<options>] <command> <target>"
echo "Commands:"
echo " install-deps - install all 3rd party dependencies"
echo " checkout - fetch worldforge source (libraries, clients)"
echo " build - build the sources and install in environment"
echo " clean - delete build directory so a fresh build can be performed"
echo " release_ember - change ember to a specific release"
echo ""
echo "Options:"
echo " debug - Build for debuging instead of max performance"
echo " cross-compile - Compile to different platform: --cross_compile=android"
echo " Can be android (=ARMv7), android-ARMv7 or android-x86"
echo " make_flags - Variable passed to every make call: --make_flags=\"-j4\""
echo " configure_flags- Variable passed to every configure call"
echo " cmake_flags - Variable passed to every cmake call"
echo " compile_flags - Variable passed to the compiler"
echo " link_flags - Variable passed to the linker"
echo " force-autogen - Force autogen when it is already autogenerated"
echo " force-configure- Force configure when it is already configured"
echo ""
echo "For more help, type: hammer.sh help <command>"
elif [ "$1" = "install-deps" ] ; then
echo "Install all 3rd party dependencies into build environment."
echo ""
echo "Usage: hammer.sh install-deps <dependency to install>"
echo "Dependencies Available:"
echo " all - install all dependencies listed below"
echo " cegui - a free library providing windowing and widgets for "
echo " graphics APIs / engines"
echo " ogre - 3D rendering engine"
echo " basedir - implementation of the XDG Base Directory specifications"
echo "Hint: build ogre first then cegui"
elif [ "$1" = "checkout" ] ; then
echo "Fetch latest source code for worldforge libraries and clients."
echo "If you want Hammer to stash away any local changes, use the"
echo "environment variable HAMMERALWAYSSTASH=yes."
echo ""
echo "Usage: hammer.sh checkout <target>"
echo "Available targets:"
echo " all - fetch everything"
echo " libs - fetch libraries only"
echo " ember - fetch ember only"
echo " cyphesis - fetch cyphesis server only"
echo " worlds - fetch worlds only"
elif [ "$1" = "build" ] ; then
echo "Build the sources and install in environment."
echo ""
echo "Usage: hammer.sh build <target>"
echo "Available targets:"
echo " all - build everything"
echo " libs - build libraries only"
echo " ember - build ember only"
echo " cyphesis - build cyphesis server only"
echo " worlds - build worlds only"
echo ""
echo "Hint: after a checkout use 'all'. To rebuild after changing code"
echo "only in Ember, use 'ember'. Will build much quicker!"
elif [ "$1" = "clean" ] ; then
echo "Clean out build files of a project."
echo ""
echo "Usage: hammer.sh clean <target>"
echo "Targets:"
echo " cegui, ogre, libs/<name>, clients/<name>, servers/<name>"
elif [ "$1" = "release_ember" ] ; then
echo "Build a specific release of Ember, including latest stable libraries."
echo "Do not run this command as root, AppImage building will fail."
echo ""
echo "Usage: hammer.sh release_ember <version number> [<target>]"
echo "Available targets [optional]:"
echo " dir - build into a standard directory structure"
echo " image - build an AppImage or AppBundle (Default)"
echo ""
echo "e.g. hammer.sh release_ember 0.7.1 dir"
else
echo "No help page found!"
fi
}
if [ $# -eq 0 ] ; then
show_help "main"
exit 1
fi
#default flags, which can be changed with hammer.sh flags
#Change these for custom builds.
export DEBUG_BUILD=0 # Can be 0 (release build) or 1 (debug build). Only used if COMPILE_FLAGS is empty!
export MAKE_FLAGS="-j5"
export CONFIGURE_FLAGS=""
#Retain RPATH for installed binaries, since we'll be linking to our own shared libraries.
export CMAKE_FLAGS="-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -DCMAKE_BUILD_TYPE=RelWithDebInfo"
export COMPILE_FLAGS=""
export LINK_FLAGS=""
export FORCE_AUTOGEN=0 # Can be 0 or 1.
export FORCE_CONFIGURE=0 # Can be 0 or 1.
export TARGET_OS="native" # Can be native or android.
# NOTE: These are only valid for non-native builds
export TARGET_ARCH="ARMv7" # Can be ARMv7 or x86. (ARMv6, ARMv8, ARM_NEON, MIPS may be added later)
if [[ $OSTYPE == *darwin* ]] ; then
export HOST_ARCH="x86_64" # On OS X -p option returns i386, but in reality its 64 bit.
export HOST_OS="$(uname -s)" # == "Darwin". On OS X -o option is unsupported.
else
export HOST_ARCH="$(uname -p)" # Can be x86_64 or x86.
if [[ $HOST_ARCH = i[3456]86 ]] ; then
export HOST_ARCH=x86
fi
export HOST_OS="$(uname -o)" # Can be GNU/Linux.
fi
# Directory hierarchy base
export HAMMERDIR=$PWD # It should contain hammer.sh file only.
export WORKDIR=$HAMMERDIR/work # It should contain anything generated.
export SUPPORTDIR=$HAMMERDIR/support # It should contain any other script.
EMBER_VER="master"
VARCONF_VER="master"
ATLAS_CPP_VER="master"
SKSTREAM_VER="master"
WFMATH_VER="master"
ERIS_VER="master"
LIBWFUT_VER="master"
MERCATOR_VER="master"
WORLDS_VER="master"
CYPHESIS_VER="master"
MEDIA_VER="dev"
while :
do
case $1 in
help | -h | --help | -\?)
if [ $# -eq 2 ] ; then
show_help "$2"
else
show_help "main"
fi
exit 0
;;
-t=* | --cross_compile=* | --cross-compile=*) # --cross-compile=android
TARGET_NAME=${1#*=}
if [ "$TARGET_NAME" = "android" ] || [ "$TARGET_NAME" = "android-ARMv7" ]; then
export TARGET_OS="android"
export TARGET_ARCH="ARMv7"
elif [ "$TARGET_NAME" = "android-x86" ]; then
export TARGET_OS="android"
export TARGET_ARCH="x86"
else
echo "Unknown target '$TARGET_NAME'!"
exit 1
fi
shift
;;
-d | --debug)
export DEBUG_BUILD=1
shift
;;
--make_flags=* | --make-flags=*) # --make_flags="-j4"
export MAKE_FLAGS=${1#*=}
shift
;;
--configure_flags=* | --configure-flags=*) # --configure_flags="--static"
export CONFIGURE_FLAGS=${1#*=}
shift
;;
--cmake_flags=* | --cmake-flags=*) # --cmake_flags="-DOGRE_UNITY_BUILD=true"
export CMAKE_FLAGS=${1#*=}
shift
;;
--compile_flags=* | --compile-flags=*) # --compile_flags="-O0 -g"
export COMPILE_FLAGS=${1#*=}
shift
;;
--link_flags=* | --compile-flags=*) # --link_flags="-L/usr/lib -lfoo"
export LINK_FLAGS=${1#*=}
shift
;;
-a | --force-autogen | --force_autogen)
export FORCE_AUTOGEN=1
shift
;;
-c | --force-configure | --force_configure)
export FORCE_CONFIGURE=1
shift
;;
--use-release-ember=*)
EMBER_VER="release-${1#*=}"
shift
;;
--use-release-media=*)
MEDIA_VER="${1#*=}"
shift
;;
--use-release-libs)
VARCONF_VER=1.0.1
ATLAS_CPP_VER=0.6.3
SKSTREAM_VER=0.3.9
WFMATH_VER=1.0.2
ERIS_VER=1.3.23
LIBWFUT_VER=libwfut-0.2.3
WORLDS_VER="master"
CYPHESIS_VER=0.6.2
MERCATOR_VER=0.3.3
shift
;;
-*)
printf >&2 'Unknown option: %s\n' "$1"
exit 1
;;
*) # end of options.
break
;;
esac
done
#+++++++++++++++++++++
#+ Setup environment +
#+++++++++++++++++++++
# It will use the settings from above to set up the environment.
# You can use pop_env to get back to system environment.
#$SUPPORTDIR/setup_env.sh push_env #Use this to debug setup_env.sh
eval $($SUPPORTDIR/setup_env.sh push_env)
echo "Building for $BUILDDIR!"
#Add RPATH/RUNPATH entries to our install locations
export CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_INSTALL_RPATH=${PREFIX}/lib64:${PREFIX}/lib"
# Define component versions
CEGUI_VER=cegui-0.8.7
CEGUI_DOWNLOAD=cegui-0.8.7.tar.bz2
OGRE_VER=ogre-13.4.2
OGRE_DOWNLOAD=v13.4.2.tar.gz
BASEDIR_VER=1.2.0
# setup directories
mkdir -p "$PREFIX" "$DEPS_SOURCE" "$SOURCE" "$DEPS_BUILD" "$BUILD" "$LOGDIR"
# Output redirect logs
AUTOLOG=autogen.log # Autogen output
CONFIGLOG=config.log # Configure output
MAKELOG=build.log # Make output
INSTALLLOG=install.log # Install output
function buildwfautotools()
{
if [ x"$2" = x"" ]; then
PRJNAME="$1"
else
PRJNAME="$2"
fi
mkdir -p "$LOGDIR/$PRJNAME"
if [ ! -d "$SOURCE/$1" ] ; then
echo "The source directory is missing!"
echo "Try: ./hammer.sh help checkout"
exit 1
fi
cd "$SOURCE/$1"
if [ $FORCE_AUTOGEN -eq 1 ] || [ ! -f "configure" ] ; then
echo " Running autogen..."
NOCONFIGURE=1 ./autogen.sh > "$LOGDIR/$PRJNAME/$AUTOLOG"
fi
mkdir -p "$BUILD/$1/$BUILDDIR"
cd "$BUILD/$1/$BUILDDIR"
if [ $FORCE_CONFIGURE -eq 1 ] || [ ! -f "Makefile" ] ; then
echo " Running configure..."
"$SOURCE/$1/configure" $CONFIGURE_FLAGS > "$LOGDIR/$PRJNAME/$CONFIGLOG"
fi
echo " Building..."
make $MAKE_FLAGS > "$LOGDIR/$PRJNAME/$MAKELOG"
echo " Installing..."
make install > "$LOGDIR/$PRJNAME/$INSTALLLOG"
}
function buildwf()
{
if [ x"$2" = x"" ]; then
PRJNAME="$1"
else
PRJNAME="$2"
fi
mkdir -p "$LOGDIR/$PRJNAME"
if [ ! -d "$SOURCE/$1" ] ; then
echo "The source directory is missing!"
echo "Try: ./hammer.sh help checkout"
exit 1
fi
mkdir -p "$BUILD/$1/$BUILDDIR"
cd "$BUILD/$1/$BUILDDIR"
echo " Configuring..."
cmake -DCMAKE_INSTALL_PREFIX="$PREFIX" $CMAKE_FLAGS "$SOURCE/$1" > "$LOGDIR/$PRJNAME/$CONFIGLOG"
if [[ $OSTYPE == *darwin* ]] ; then
echo " Building..."
xcodebuild -configuration RelWithDebInfo > "$LOGDIR/$PRJNAME/$MAKELOG"
echo " Installing..."
xcodebuild -configuration RelWithDebInfo -target install > "$LOGDIR/$PRJNAME/$INSTALLLOG"
else
echo " Building..."
make $MAKE_FLAGS > "$LOGDIR/$PRJNAME/$MAKELOG"
echo " Installing..."
make install > "$LOGDIR/$PRJNAME/$INSTALLLOG"
fi
}
function checkoutwf()
{
if [ x"$2" = x"" ]; then
USER="worldforge"
else
USER="$2"
fi
if [ x"$3" = x"" ]; then
# atlas-cpp ==> ATLAS_CPP
BRANCH="$(echo "$1" | tr '[:lower:]' '[:upper:]' | tr '-' '_')_VER"
# ATLAS_CPP ==> master
BRANCH="${!BRANCH}"
else
BRANCH="$3"
fi
echo "Getting $1 $BRANCH"
if [ ! -d "$1" ]; then
git clone "https://github.com/$USER/$1.git" -b "$BRANCH"
else
cd "$1"
if [ x"$HAMMERALWAYSSTASH" = x"yes" ]; then
git stash save "Hammer stash"
fi
git fetch && git rebase "origin/$BRANCH" && cd ..
fi
}
function cyphesis_post_install()
{
cd "$PREFIX/bin"
# Rename real cyphesis binary to cyphesis.bin
mv cyphesis cyphesis.bin
# Install our cyphesis.in script as cyphesis
cp "$SUPPORTDIR/cyphesis.in" cyphesis
chmod +x cyphesis
}
function install_deps_ogre()
{
# Ogre3D
echo " Installing Ogre..."
mkdir -p "$LOGDIR/deps/ogre"
cd "$DEPS_SOURCE"
if [ ! -d $OGRE_VER ]; then
echo " Downloading..."
curl -C - -OL "https://github.com/OGRECave/ogre/archive/$OGRE_DOWNLOAD"
tar -xzf "$OGRE_DOWNLOAD"
cd "$OGRE_VER"
echo "Patching OGRE..."
OGRE_SOURCE="$DEPS_SOURCE/$OGRE_VER"
else
OGRE_SOURCE="$DEPS_SOURCE/$OGRE_VER"
fi
mkdir -p "$DEPS_BUILD/$OGRE_VER/$BUILDDIR"
cd "$DEPS_BUILD/$OGRE_VER/$BUILDDIR"
echo " Configuring..."
OGRE_EXTRA_FLAGS=""
cmake "$OGRE_SOURCE" -DCMAKE_INSTALL_PREFIX="$PREFIX" -DOGRE_BUILD_SAMPLES="FALSE" -DOGRE_RESOURCEMANAGER_STRICT=true \
-DOGRE_INSTALL_SAMPLES="FALSE" -DOGRE_INSTALL_DOCS="FALSE" -DOGRE_BUILD_TOOLS="FALSE" -DOGRE_BUILD_PLUGIN_PCZ="FALSE" -DOGRE_BUILD_DEPENDENCIES=false \
-DOGRE_BUILD_PLUGIN_BSP="FALSE" -DOGRE_BUILD_COMPONENT_PYTHON="FALSE" -DOGRE_BUILD_COMPONENT_BITES="FALSE" -DOGRE_BUILD_COMPONENT_OVERLAY_IMGUI="FALSE" \
-DOGRE_BUILD_COMPONENT_PROPERTY="FALSE" -DOGRE_BUILD_COMPONENT_VOLUME="FALSE" -DOGRE_BUILD_COMPONENT_JAVA="FALSE" -DOGRE_BUILD_COMPONENT_CSHARP="FALSE" \
-DOGRE_NODELESS_POSITIONING="FALSE" -DOGRE_BUILD_RENDERSYSTEM_GLES2="FALSE" -DOGRE_BUILD_COMPONENT_BULLET="FALSE" \
$OGRE_EXTRA_FLAGS $CMAKE_FLAGS > "$LOGDIR/deps/ogre/$CONFIGLOG"
if [[ $OSTYPE == *darwin* ]] ; then
echo " Building..."
xcodebuild -configuration RelWithDebInfo #> "$LOGDIR/deps/ogre/$MAKELOG"
echo " Installing..."
xcodebuild -configuration RelWithDebInfo -target install #> "$LOGDIR/deps/ogre/$INSTALLLOG"
#cp -r lib/macosx/RelWithDebInfo/* "$PREFIX/lib"
#on mac, we have only Ogre.framework
#sed -i "" -e "s/-L\$[{]libdir[}]\ -lOgreMain/-F\${libdir} -framework Ogre/g" "$PREFIX/lib/pkgconfig/OGRE.pc"
echo " Done."
else
echo " Building..."
make $MAKE_FLAGS > "$LOGDIR/deps/ogre/$MAKELOG"
echo " Installing..."
make install > "$LOGDIR/deps/ogre/$INSTALLLOG"
echo " Done."
fi
}
function install_deps_basedir()
{
# libxdg-basedir
echo " Installing libxdg-basedir..."
mkdir -p "$LOGDIR/deps/libxdg-basedir"
cd "$DEPS_SOURCE"
echo " Downloading..."
curl -OL "https://github.com/devnev/libxdg-basedir/archive/libxdg-basedir-$BASEDIR_VER.tar.gz"
tar -xf "libxdg-basedir-$BASEDIR_VER.tar.gz"
cd "libxdg-basedir-libxdg-basedir-$BASEDIR_VER"
echo " Running autogen..."
#This library is currently not compatible with automake 1.12, the following line fixes this:
sed -i 's/AC_PROG_CC/m4_ifdef([AM_PROG_AR], [AM_PROG_AR])\nAC_PROG_CC/' configure.ac
autoreconf --install --force --warnings=all
mkdir -p "$DEPS_BUILD/libxdg-basedir/$BUILDDIR"
cd "$DEPS_BUILD/libxdg-basedir/$BUILDDIR"
echo " Running configure..."
"$DEPS_SOURCE/libxdg-basedir-libxdg-basedir-$BASEDIR_VER/configure" $CONFIGURE_FLAGS > "$LOGDIR/deps/libxdg-basedir/$CONFIGLOG"
echo " Building..."
make $MAKE_FLAGS > "$LOGDIR/deps/libxdg-basedir/$MAKELOG"
echo " Installing..."
make install > "$LOGDIR/deps/libxdg-basedir/$INSTALLLOG"
}
function install_deps_cegui()
{
# CEGUI
echo " Installing CEGUI..."
mkdir -p "$LOGDIR/deps/CEGUI" # create CEGUI log directory
cd "$DEPS_SOURCE"
if [ ! -d "$CEGUI_VER" ] ; then
echo " Downloading..."
curl -C - -OL "http://downloads.sourceforge.net/sourceforge/crayzedsgui/$CEGUI_DOWNLOAD"
tar -xjf "$CEGUI_DOWNLOAD"
fi
mkdir -p "$DEPS_BUILD/$CEGUI_VER/$BUILDDIR"
cd "$DEPS_BUILD/$CEGUI_VER/$BUILDDIR"
echo " Configuring..."
if [[ $OSTYPE == *darwin* ]] ; then #Fast hack to get cegui building on OS X. Should be fixed upstream in CEGUI.
export CXXFLAGS="$CXXFLAGS -I/opt/local/include"
export LDFLAGS="$LDFLAGS -F$PREFIX/lib/RelWithDebInfo -L$PREFIX/lib/RelWithDebInfo"
fi
cmake -DCMAKE_INSTALL_PREFIX="$PREFIX" -C "${SUPPORTDIR}/CEGUI_defaults.cmake" $CMAKE_FLAGS "$DEPS_SOURCE/$CEGUI_VER" > "$LOGDIR/deps/CEGUI/$CONFIGLOG"
if [[ $OSTYPE == *darwin* ]] ; then
echo " Building..."
xcodebuild -configuration RelWithDebInfo #> "$LOGDIR/deps/CEGUI/$MAKELOG"
echo " Installing..."
xcodebuild -configuration RelWithDebInfo -target install > "$LOGDIR/deps/CEGUI/$INSTALLLOG"
#on mac we use -DCEGUI_STATIC, which will disable the plugin interface and we need to link the libraries manually.
#sed -i "" -e "s/-lCEGUIBase/-lCEGUIBase -lCEGUIFalagardWRBase -lCEGUIFreeImageImageCodec -lCEGUITinyXMLParser/g" "$PREFIX/lib/pkgconfig/CEGUI.pc"
echo " Done."
else
echo " Building..."
make $MAKE_FLAGS > "$LOGDIR/deps/CEGUI/$MAKELOG"
echo " Installing..."
make install > "$LOGDIR/deps/CEGUI/$INSTALLLOG"
echo " Done."
fi
}
function install_deps_all()
{
install_deps_ogre
install_deps_cegui
install_deps_basedir
}
function install_deps_AppImageKit()
{
# AppImageKit
echo " Installing core AppImageKit functionality..."
mkdir -p "$LOGDIR/deps/AppImageKit" # create AppImageKit log directory
cd "$DEPS_SOURCE"
if [ ! -d "AppImageKit" ] ; then
echo " Downloading..."
mkdir AppImageKit && cd AppImageKit
curl -OL https://raw.github.com/probonopd/AppImageKit/master/CMakeLists.txt
curl -OL https://raw.github.com/probonopd/AppImageKit/master/AppRun.c
curl -OL https://raw.github.com/probonopd/AppImageKit/master/fuseiso.c
curl -OL https://raw.github.com/probonopd/AppImageKit/master/isofs.c
curl -OL https://raw.github.com/probonopd/AppImageKit/master/isofs.h
curl -OL https://raw.github.com/probonopd/AppImageKit/master/md5.c
curl -OL https://raw.github.com/probonopd/AppImageKit/master/md5.h
curl -OL https://raw.github.com/probonopd/AppImageKit/master/runtime.c
#AppImageKit isn't smart enough to find debian library locations, let's help it.
sed -i 's|"/usr/lib64"|"/usr/lib" "/usr/lib64" "/usr/lib/i386-linux-gnu" "/usr/lib/x86_64-linux-gnu"|' CMakeLists.txt
mkdir linux && cd linux
curl -OL https://raw.github.com/probonopd/AppImageKit/master/linux/iso_fs.h
curl -OL https://raw.github.com/probonopd/AppImageKit/master/linux/rock.h
fi
mkdir -p "$DEPS_BUILD/AppImageKit"
cd "$DEPS_BUILD/AppImageKit"
curl -OL https://raw.github.com/probonopd/AppImageKit/master/AppImageAssistant.AppDir/package
curl -OL https://raw.github.com/probonopd/AppImageKit/master/AppImageAssistant.AppDir/xdgappdir.py
echo " Configuring..."
cmake -DCMAKE_INSTALL_PREFIX="$PREFIX" $CMAKE_EXTRA_FLAGS "$DEPS_SOURCE/AppImageKit" &> "$LOGDIR/deps/AppImageKit/$CONFIGLOG"
echo " Building..."
make $MAKEOPTS AppRun &> "$LOGDIR/deps/AppImageKit/${MAKELOG}_AppRun"
make $MAKEOPTS runtime &> "$LOGDIR/deps/AppImageKit/${MAKELOG}_runtime"
echo " Installing..."
echo "Installed." > "$LOGDIR/deps/AppImageKit/$INSTALLLOG"
echo " Done."
}
function ember_fetch_media()
{
if [ x"$MEDIA_VER" = x"dev" ] ; then
MEDIAURL="http://amber.worldforge.org/media/media-dev/"
MEDIA_PREFETCH="set +e"
MEDIA_POSTFETCH="set -e"
else
MEDIAURL="http://downloads.sourceforge.net/worldforge/ember-media-${MEDIA_VER}.tar.bz2"
MEDIA_PREFETCH=""
MEDIA_POSTFETCH=""
fi
# Fetch Ember Media
if command -v rsync &> /dev/null; then
echo "Fetching media..."
cd "$BUILD/clients/ember/$BUILDDIR"
$MEDIA_PREFETCH
make media-download &> "$LOGDIR/clients/ember/media.log"
if [ $? != 0 ] ; then
echo "Could not fetch media. This may be caused by the media server being down, by the network being down, or by a firewall which prevents rsync from running. You need to get the media manually from $MEDIAURL"
else
echo "Media fetched."
fi
$MEDIA_POSTFETCH
else
echo "Rsync not found, skipping fetching of media. You will need to download and install it yourself from $MEDIAURL"
fi
}
mkdir -p "$PREFIX" "$SOURCE" "$DEPS_SOURCE" "$BUILD" "$DEPS_BUILD"
# Dependencies install
if [ x"$1" = x"install-deps" ] ; then
if [ x"$MSYSTEM" = x"MINGW32" ] ; then
"$SUPPORTDIR/mingw_install_deps.sh" "$2"
exit 0
fi
if [[ x"$TARGET_OS" = x"android" ]] ; then
"$SUPPORTDIR/android_install_deps.sh" "$2"
exit 0
fi
if [ $# -ne 2 ] ; then
echo "Missing required parameter!"
show_help "install-deps"
exit 1
fi
echo "Installing 3rd party dependencies..."
# Create deps log directory
mkdir -p "$LOGDIR/deps"
if [ "$2" = "all" ] || [ "$2" = "ogre" ] || [ "$2" = "cegui" ] ||
[ "$2" = "basedir" ] ; then
install_deps_$2
else
printf >&2 'Unknown target: %s\n' "$2"
exit 1
fi
# AppImageKit
if [ "$2" = "appimage" ] ; then
install_deps_AppImageKit
fi
echo "Install of 3rd party dependencies is complete."
# Source checkout
elif [ "$1" = "checkout" ] ; then
if [ $# -ne 2 ] ; then
echo "Missing required parameter!"
show_help "checkout"
exit 1
fi
echo "Checking out sources..."
if [ "$2" = "libs" ] || [ "$2" = "all" ] ; then
mkdir -p "$SOURCE/libs"
cd "$SOURCE/libs"
# Varconf
echo " Varconf..."
checkoutwf "varconf"
echo " Done."
# Atlas-C++
echo " Atlas-C++..."
checkoutwf "atlas-cpp"
echo " Done."
# Wfmath
echo " Wfmath..."
checkoutwf "wfmath"
echo " Done."
# Eris
echo " Eris..."
checkoutwf "eris"
echo " Done."
# Libwfut
echo " Libwfut..."
checkoutwf "libwfut"
echo " Done."
# Mercator
echo " Mercator..."
checkoutwf "mercator"
echo " Done."
fi
if [ "$2" = "worlds" ] || [ "$2" = "all" ] || [ "$2" = "cyphesis" ] ; then
# Worlds
echo " Worlds..."
mkdir -p "$SOURCE"
cd "$SOURCE"
checkoutwf "worlds"
echo " Done."
fi
if [ "$2" = "ember" ] || [ "$2" = "all" ] ; then
# Ember client
echo " Ember client..."
mkdir -p "$SOURCE/clients"
cd "$SOURCE/clients"
checkoutwf "ember"
echo " Done."
fi
if [ "$2" = "cyphesis" ] || [ "$2" = "all" ] ; then
# Cyphesis
echo " Cyphesis..."
mkdir -p "$SOURCE/servers"
cd "$SOURCE/servers"
checkoutwf "cyphesis"
echo " Done."
fi
if [ "$2" = "metaserver-ng" ] ; then
# Metaserver
echo " Metaserver-ng..."
mkdir -p "$SOURCE/servers"
cd "$SOURCE/servers"
checkoutwf "metaserver-ng"
echo " Done."
fi
echo "Checkout complete."
# Build source
elif [ "$1" = "build" ] ; then
if [ $# -lt 2 ] ; then
echo "Missing required parameter!"
show_help "build"
exit 1
fi
# Check for make options
if [ $# -ge 3 ] ; then
export MAKE_FLAGS="$MAKE_FLAGS $3"
fi
echo "Building sources..."
# Build libraries
if [ "$2" = "libs" ] || [ "$2" = "all" ] ; then
# Varconf
echo " Varconf..."
buildwf "libs/varconf"
echo " Done."
# Atlas-C++
echo " Atlas-C++..."
buildwf "libs/atlas-cpp"
echo " Done."
# Wfmath
echo " Wfmath..."
buildwf "libs/wfmath"
echo " Done."
# Mercator
echo " Mercator..."
buildwf "libs/mercator"
echo " Done."
# Eris
echo " Eris..."
buildwf "libs/eris"
echo " Done."
# Libwfut
echo " Libwfut..."
buildwf "libs/libwfut"
echo " Done."
fi
if [ "$2" = "worlds" ] || [ "$2" = "all" ] || [ "$2" = "cyphesis" ] ; then
# Worlds
echo " Worlds..."
buildwf "worlds"
echo " Done."
fi
if [ "$2" = "ember" ] || [ "$2" = "all" ] ; then
# Ember client
echo " Ember client..."
buildwf "clients/ember"
echo " Done."
# Ember media
ember_fetch_media
echo "Ember is built and installed. Use this command to run the client:"
echo "$PREFIX/bin/ember"
fi
if [ "$2" = "cyphesis" ] || [ "$2" = "all" ] ; then
# Cyphesis
echo " Cyphesis..."
buildwf "servers/cyphesis"
echo " Getting assets..."
if [[ $OSTYPE == *darwin* ]] ; then
xcodebuild -configuration RelWithDebInfo assets-download >> "$LOGDIR/$PRJNAME/$MAKELOG"
else
make assets-download >> "$LOGDIR/$PRJNAME/$MAKELOG"
fi
cyphesis_post_install
echo " Done."
echo "Cyphesis is built and installed. Use this command to run the server:"
echo "$PREFIX/bin/cyphesis"
fi
if [ "$2" = "metaserver-ng" ] ; then
# metaserver-ng
# change sysconfdir in order to conform with the manner
# of WF builds
echo " metaserver-ng..."
CONFIGURE_FLAGS_SAVED="$CONFIGURE_FLAGS"
export CONFIGURE_FLAGS="$CONFIGURE_FLAGS --sysconfdir=$PREFIX/etc/metaserver-ng"
buildwfautotools "servers/metaserver-ng"
export CONFIGURE_FLAGS="$CONFIGURE_FLAGS_SAVED"
echo " Done."
fi
if [ $TARGET_OS = "android" ] && [ "$2" = "ember_apk" ] ; then
echo " Bundling Ember into ember.apk..."
"$SUPPORTDIR/AppBundler.sh"
echo " Done."
fi
echo "Build complete."
elif [ "$1" = "clean" ] ; then
if [ $# -ne 2 ] ; then
echo "Missing required parameter!"
show_help "clean"
exit 1
fi
# Delete build directory
if [ "$2" = "cegui" ] ; then
rm -rf "${DEPS_BUILD:?}/${CEGUI_VER:?}/${BUILDDIR:?}"
elif [ "$2" = "ogre" ] ; then
rm -rf "${DEPS_BUILD:?}/${OGRE_VER:?}/${BUILDDIR:?}"
else
rm -rf "${BUILD:?}/${2:?}/${BUILDDIR:?}"
fi
elif [ "$1" = "release_ember" ] ; then
# Set configuration for building a release
if [[ $OSTYPE != *darwin* ]] ; then
export CXXFLAGS="$CXXFLAGS -O3 -g0 -s"
export CFLAGS="$CFLAGS -O3 -g0 -s"
fi
# Remove hammer environment
eval $("$SUPPORTDIR/setup_env.sh" pop_env)
CURDIR="$PWD"
HAMMER="$0"
# Install external dependencies
echo "Installing 3rd party dependencies..."
"$HAMMER" --compile_flags="$CXXFLAGS" install-deps all
HAMMER_EXTRA_FLAGS=""
# Source checkout
echo "Checking out sources..."
if [ x"$2" != x"" ] && [ x"$2" != x"dev" ] ; then
# Push native build environment to checkout skstream
eval $("$SUPPORTDIR/setup_env.sh" push_env)
mkdir -p "$SOURCE/libs"
cd "$SOURCE/libs"
# skstream is deprecated, but we need it to build older ember releases!
checkoutwf "skstream" "worldforge" $SKSTREAM_VER
eval $("$SUPPORTDIR/setup_env.sh" pop_env)
HAMMER_EXTRA_FLAGS="--use-release-libs --use-release-ember=$2"
cd "$CURDIR"
fi
"$HAMMER" $HAMMER_EXTRA_FLAGS checkout libs
"$HAMMER" $HAMMER_EXTRA_FLAGS checkout ember
# Build source
echo "Building sources..."
"$HAMMER" --compile_flags="$CXXFLAGS" build libs
if [ x"$2" != x"" ] && [ x"$2" != x"dev" ] ; then
# skstream is deprecated, but we need it to build older ember releases!
# Push native build environment to build skstream
eval $("$SUPPORTDIR/setup_env.sh" push_env)
buildwf "libs/skstream"
eval $("$SUPPORTDIR/setup_env.sh" pop_env)
HAMMER_EXTRA_FLAGS="--use-release-media=$2"
cd "$CURDIR"
fi
"$HAMMER" $HAMMER_EXTRA_FLAGS --compile_flags="$CXXFLAGS" build ember
eval $("$SUPPORTDIR/setup_env.sh" push_env)
# Check for Ember release target option
if [ x"$3" = x"" ] || [ "$3" = "image" ] ; then
# making an AppImage/AppBundle
if [[ $OSTYPE == *darwin* ]] ; then
echo "Creating AppBundle."
source "$HAMMERDIR/support/AppBundler.sh"
echo "AppBundle creation complete."
else
export APP_DIR_ROOT="$WORKDIR/Ember.AppDir"
echo "Creating AppImage."
install_deps_AppImageKit
source "$HAMMERDIR/support/linux_AppDir_create.sh" &> "$LOGDIR/deps/AppImageKit/AppDir.log"
echo "AppImage will be created from the AppDir at $APP_DIR_ROOT and placed into $WORKDIR."
PACKAGE_FILE="$WORKDIR/ember-${2}-x86_$BUILDDIR"
if [ -e "$PACKAGE_FILE" ] ; then
echo "Removing existing artifact at '$PACKAGE_FILE'."
rm "$PACKAGE_FILE"
fi
python "$DEPS_BUILD/AppImageKit/package" "$APP_DIR_ROOT" "$PACKAGE_FILE" create new &> "$LOGDIR/deps/AppImageKit/AppImage.log"
echo "AppImage creation complete."
fi
else
# making a standard directory
echo "Creating release directory."
cd "$HAMMERDIR"
source "$HAMMERDIR/support/linux_release_bundle.sh"
echo "Release directory created."
fi
eval $("$SUPPORTDIR/setup_env.sh" pop_env)
else
echo "Invalid command!"
show_help "main"
fi