-
Notifications
You must be signed in to change notification settings - Fork 23
/
base_build.sh
executable file
·1246 lines (1074 loc) · 35.9 KB
/
base_build.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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# Copyright (c) 2015-2018 Carnegie Mellon University. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following acknowledgments
# and disclaimers.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. The names "Carnegie Mellon University," "SEI" and/or "Software
# Engineering Institute" shall not be used to endorse or promote
# products derived from this software without prior written
# permission. For written permission, please contact
# permission@sei.cmu.edu.
#
# 4. Products derived from this software may not be called "SEI" nor
# may "SEI" appear in their names without prior written permission of
# permission@sei.cmu.edu.
#
# 5. Redistributions of any form whatsoever must retain the following
# acknowledgment:
#
# Copyright 2015 Carnegie Mellon University
#
# This material is based upon work funded and supported by the
# Department of Defense under Contract No. FA8721-05-C-0003 with
# Carnegie Mellon University for the operation of the Software
# Engineering Institute, a federally funded research and development
# center.
#
# Any opinions, findings and conclusions or recommendations expressed
# in this material are those of the author(s) and do not necessarily
# reflect the views of the United States Department of Defense.
#
# NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE
# ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS"
# BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT
# LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY,
# EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE
# MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH
# RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT
# INFRINGEMENT.
#
# This material has been approved for public release and unlimited
# distribution.
#
# DM-0002489
#
# Build the required libraries for GAMS
#
# There are several expected environment variables
# $CORES - number of build jobs to launch with make
# $MADARA_ROOT - location of local copy of MADARA git repository from
# git://git.code.sf.net/p/madara/code
# $GAMS_ROOT - location of this GAMS git repository
# $VREP_ROOT - location of VREP installation, if applicable
# $SSL_ROOT - location of OpenSSL (usually /usr)
# $ZMQ_ROOT - location of ZeroMQ (usually /usr/local)
# $LZ4_ROOT - location of LZ4
#
# For android
# $LOCAL_CROSS_PREFIX
# - Set this to the toolchain prefix
#
# For java
# $JAVA_HOME
DEBUG=0
TESTS=0
TUTORIALS=0
VREP=0
JAVA=0
ROS=0
CLANG=0
ANDROID=0
STRIP=0
ODROID=0
MPC=0
MADARA=0
GAMS=0
PREREQS=0
DOCS=0
VREP_CONFIG=0
ZMQ=0
SIMTIME=0
NOTHREADLOCAL=0
SSL=0
DMPL=0
LZ4=0
PYTHON=0
CLEAN=1
MAC=${MAC:-0}
BUILD_ERRORS=0
TYPES=0
ANDROID_TESTS=0
MPC_DEPENDENCY_ENABLED=0
MADARA_DEPENDENCY_ENABLED=0
MPC_AS_A_PREREQ=0
MADARA_AS_A_PREREQ=0
VREP_AS_A_PREREQ=0
GAMS_AS_A_PREREQ=0
EIGEN_AS_A_PREREQ=0
CAPNP_AS_A_PREREQ=0
MPC_REPO_RESULT=0
DART_REPO_RESULT=0
DART_BUILD_RESULT=0
GAMS_REPO_RESULT=0
GAMS_BUILD_RESULT=0
MADARA_REPO_RESULT=0
MADARA_BUILD_RESULT=0
MPC_REPO_RESULT=0
VREP_REPO_RESULT=0
ZMQ_REPO_RESULT=0
ZMQ_BUILD_RESULT=0
LZ4_REPO_RESULT=0
CAPNP_REPO_RESULT=0
CAPNP_BUILD_RESULT=0
STRIP_EXE=strip
VREP_INSTALLER="V-REP_PRO_EDU_V3_4_0_Linux.tar.gz"
export INSTALL_DIR=`pwd`
SCRIPTS_DIR=`dirname $0`
if [ -z $CORES ] ; then
echo "CORES unset, so setting it to default of 1"
echo " If you have more than one CPU core, try export CORES=<num cores>"
echo " CORES=1 (the default) will be much slower than CORES=<num cores>"
export CORES=1
fi
# if $@ is empty, the user wants to repeat last build with noclean
if [ $# == 0 ]; then
echo "Loading last build with noclean..."
IFS=$'\r\n ' GLOBIGNORE='*' command eval 'ARGS=($(cat $GAMS_ROOT/last_build.lst))'
ARGS+=("noclean")
else
echo "Processing user arguments..."
ARGS=("$@")
fi
echo "build features: ${ARGS[@]}"
for var in "${ARGS[@]}"
do
if [ "$var" = "tests" ]; then
TESTS=1
elif [ "$var" = "clean" ]; then
CLEAN=1
elif [ "$var" = "debug" ]; then
DEBUG=1
elif [ "$var" = "docs" ]; then
DOCS=1
elif [ "$var" = "prereqs" ]; then
PREREQS=1
elif [ "$var" = "vrep" ]; then
VREP=1
elif [ "$var" = "types" ]; then
TYPES=1
elif [ "$var" = "vrep-config" ]; then
VREP_CONFIG=1
elif [ "$var" = "java" ]; then
JAVA=1
elif [ "$var" = "clang" ]; then
CLANG=1
elif [ "$var" = "ros" ]; then
ROS=1
elif [ "$var" = "mpc" ]; then
MPC=1
elif [ "$var" = "madara" ]; then
MADARA=1
elif [ "$var" = "noclean" ]; then
CLEAN=0
elif [ "$var" = "python" ]; then
PYTHON=1
elif [ "$var" = "gams" ]; then
GAMS=1
elif [ "$var" = "dart" ]; then
DMPL=1
elif [ "$var" = "dmpl" ]; then
DMPL=1
elif [ "$var" = "lz4" ]; then
LZ4=1
elif [ "$var" = "zmq" ]; then
ZMQ=1
elif [ "$var" = "simtime" ]; then
SIMTIME=1
elif [ "$var" = "tutorials" ]; then
TUTORIALS=1
elif [ "$var" = "nothreadlocal" ]; then
NOTHREADLOCAL=1
elif [ "$var" = "ssl" ]; then
SSL=1
elif [ "$var" = "odroid" ]; then
ODROID=1
STRIP_EXE=${LOCAL_CROSS_PREFIX}strip
elif [ "$var" = "android" ]; then
ANDROID=1
JAVA=1
STRIP_EXE=${LOCAL_CROSS_PREFIX}strip
elif [ "$var" = "android-tests" ]; then
ANDROID_TESTS=1
ANDROID=1
JAVA=1
elif [ "$var" = "strip" ]; then
STRIP=1
else
echo "Invalid argument: $var"
echo " args can be zero or more of the following, space delimited"
echo " debug create a debug build, with minimal optimizations"
echo " mpc download MPC if prereqs is enabled"
echo " android build android libs, turns on java"
echo " clang build using clang++-5.0 and libc++"
echo " clean run 'make clean' before builds (default)"
echo " dmpl build DART DMPL verifying compiler"
echo " docs generate API documentation"
echo " gams build GAMS"
echo " java build java jar"
echo " lz4 build with LZ4 compression"
echo " madara build MADARA"
echo " noclean do not run 'make clean' before builds."
echo " This is an option that supercharges the build"
echo " process and can reduce build times to seconds."
echo " 99.9% of update builds can use this, unless you"
echo " are changing features (e.g., enabling ssl when"
echo " you had previously not enabled ssl)"
echo " odroid target ODROID computing platform"
echo " python build with Python 2.7 support"
echo " prereqs use apt-get to install prereqs. This usually only"
echo " has to be used on the first usage of a feature"
echo " ros build ROS platform classes"
echo " ssl build with OpenSSL support"
echo " strip strip symbols from the libraries"
echo " tests build test executables"
echo " tutorials build MADARA tutorials"
echo " types builds libTYPES.so"
echo " vrep build with vrep support"
echo " vrep-config configure vrep to support up to 20 agents"
echo " zmq build with ZeroMQ support"
echo " simtime build with simtime support in Madara"
echo " help get script usage"
echo ""
echo "The following environment variables are used"
echo " CAPNP_ROOT - location of Cap'n Proto"
echo " CORES - number of build jobs to launch with make, optional"
echo " MPC_ROOT - location of MakefileProjectCreator"
echo " MADARA_ROOT - location of local copy of MADARA git repository from"
echo " git://git.code.sf.net/p/madara/code"
echo " GAMS_ROOT - location of this GAMS git repository"
echo " VREP_ROOT - location of VREP installation"
echo " JAVA_HOME - location of JDK"
echo " LZ4_ROOT - location of LZ4"
echo " ZMQ_ROOT - location of ZeroMQ"
echo " SSL_ROOT - location of OpenSSL"
echo " ROS_ROOT - location of ROS (usually set by ROS installer)"
echo " DMPL_ROOT - location of DART DMPL directory"
exit
fi
done
if [ -z $MPC_ROOT ] ; then
export MPC_ROOT=$INSTALL_DIR/MPC
fi
if [ -z $EIGEN_ROOT ] ; then
export EIGEN_ROOT=$INSTALL_DIR/eigen
fi
if [ -z $CAPNP_ROOT ] ; then
export CAPNP_ROOT=$INSTALL_DIR/capnproto
fi
if [ -z $LZ4_ROOT ] ; then
export LZ4_ROOT=$INSTALL_DIR/lz4
fi
# echo build information
echo "INSTALL_DIR will be $INSTALL_DIR"
echo "Using $CORES build jobs"
if [ $PREREQS -eq 0 ]; then
echo "No pre-requisites will be installed"
else
echo "Pre-requisites will be installed"
fi
echo "MPC_ROOT is set to $MPC_ROOT"
echo "EIGEN_ROOT is set to $EIGEN_ROOT"
echo "CAPNP_ROOT is set to $CAPNP_ROOT"
echo "LZ4_ROOT is set to $LZ4_ROOT"
echo "MADARA will be built from $MADARA_ROOT"
if [ $MADARA -eq 0 ]; then
echo "MADARA will not be built"
else
echo "MADARA will be built"
fi
echo "GAMS_ROOT is set to $GAMS_ROOT"
echo "ODROID has been set to $ODROID"
echo "TESTS has been set to $TESTS"
echo "ROS has been set to $ROS"
echo "STRIP has been set to $STRIP"
if [ $STRIP -eq 1 ]; then
echo "strip will use $STRIP_EXE"
fi
echo "JAVA has been set to $JAVA"
if [ $JAVA -eq 1 ]; then
echo "JAVA_HOME is referencing $JAVA_HOME"
fi
echo "VREP has been set to $VREP"
if [ $VREP -eq 1 ]; then
echo "VREP_ROOT is referencing $VREP_ROOT"
fi
echo "ANDROID has been set to $ANDROID"
if [ $ANDROID -eq 1 ]; then
echo "CROSS_COMPILE is set to $LOCAL_CROSS_PREFIX"
if [ -z "$ANDROID_API" ]; then
export ANDROID_API=27
echo "ANDROID_API is unset; defaulting to $ANDROID_API"
else
echo "ANDROID_API has been set to $ANDROID_API"
fi
if [ -z "$ANDROID_ABI" ]; then
export ANDROID_ABI=4.9
echo "ANDROID_ABI is unset; defaulting to $ANDROID_ABI"
else
echo "ANDROID_ABI has been set to $ANDROID_ABI"
fi
if [ -z "$ANDROID_ARCH" ]; then
export ANDROID_ARCH=armeabi-v7a
echo "ANDROID_ARCH is unset; defaulting to $ANDROID_ARCH"
else
echo "ANDROID_ARCH has been set to $ANDROID_ARCH"
fi
if [ -z "$NDK_VERSION" ]; then
export NDK_VERSION=r17c
echo "NDK_VERSION is unset; defaulting to $NDK_VERSION"
else
echo "NDK_VERSION has been set to $NDK_VERSION"
fi
if [ -z "$NDK_ROOT" ]; then
export NDK_ROOT=$INSTALL_DIR/ndk
echo "NDK_ROOT is unset; defaulting to $NDK_ROOT"
else
echo "NDK_ROOT has been set to $NDK_ROOT"
fi
if [ -z "$NDK_TOOLS" ]; then
export NDK_TOOLS=$NDK_ROOT/custom_toolchain
echo "NDK_TOOLS is unset; defaulting to $NDK_TOOLS"
else
echo "NDK_TOOLS has been set to $NDK_TOOLS"
fi
if [ -z "$SYSROOT" ]; then
export SYSROOT=$NDK_TOOLS/sysroot
echo "SYSROOT is unset; defaulting to $SYSROOT"
else
echo "SYSROOT has been set to $SYSROOT"
fi
case $ANDROID_ARCH in
arm32|arm|armeabi|armeabi-v7a)
export ANDROID_ARCH=armeabi-v7a;
export ANDROID_TOOLCHAIN_ARCH=arm;
export ANDROID_TOOLCHAIN=arm-linux-androideabi;;
arm64|aarch64)
export ANDROID_ARCH=aarch64;
export ANDROID_TOOLCHAIN_ARCH=arm64;
export ANDROID_TOOLCHAIN=aarch64-linux-android;;
x86)
true;;
x64|x86_64)
export ANDROID_ARCH=x86_64;;
*)
echo "Unknown ANDROID_ABI: $ANDROID_ABI"; exit 1 ;;
esac
export ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN:-${ANDROID_TOOLCHAIN_ARCH}-$ANDROID_ABI}
export ANDROID_TOOLCHAIN_ARCH=${ANDROID_TOOLCHAIN_ARCH:-$ANDROID_ARCH}
echo "ANDROID_TOOLCHAIN is set to $ANDROID_TOOLCHAIN"
export PATH="$NDK_TOOLS/bin:$PATH"
if [ -z "$BOOST_ANDROID_ROOT" ]; then
export BOOST_ANDROID_ROOT=$INSTALL_DIR/BoostAndroid
echo "Boost root is set to $BOOST_ANDROID_ROOT is not set."
fi
if [ $SSL -eq 1 ] && [ -z $SSL_ROOT ]; then
export SSL_ROOT=$INSTALL_DIR/openssl;
fi
fi
if [ $DOCS -eq 1 ]; then
echo "DOCS is set to $DOCS"
fi
echo ""
unzip_strip() (
local zip=$1
local dest=${2:-.}
local temp=$(mktemp -d) && unzip -qq -d "$temp" "$zip" && mkdir -p "$dest" &&
shopt -s dotglob && local f=("$temp"/*) &&
if (( ${#f[@]} == 1 )) && [[ -d "${f[0]}" ]] ; then
mv "$temp"/*/* "$dest"
else
mv "$temp"/* "$dest"
fi && rmdir "$temp"/* "$temp"
)
append_if_needed() (
if grep -q "$1" "$2"; then
true
else
echo "$1" >> "$2"
fi
)
if [ $PREREQS -eq 1 ] && [ $MAC -eq 0 ]; then
if [ $JAVA -eq 1 ]; then
sudo add-apt-repository -y ppa:webupd8team/java
fi
if [ $ROS -eq 1 ]; then
ROS_FIRST_SETUP=0
if [ ! -d "/opt/ros/kinetic" ] ; then
ROS_FIRST_SETUP=1
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
fi
fi
sudo apt-get update
sudo apt-get install -y -f build-essential subversion git-core perl doxygen graphviz libboost-all-dev
sudo apt-get install -y -f autoconf automake libtool
if [ $CLANG -eq 1 ]; then
sudo apt-get install -y -f clang-5.0 libc++-dev libc++abi-dev
fi
if [ $JAVA -eq 1 ] && [ -z $JAVA_HOME ]; then
sudo apt-get install -y -f oracle-java8-set-default
sudo apt-get install -y maven
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
rc_str="export JAVA_HOME=$JAVA_HOME"
append_if_needed "$rc_str" "$HOME/.bashrc"
fi
if [ $PYTHON -eq 1 ]; then
sudo apt-get install -y -f python2.7 python-pip
fi
if [ $ANDROID -eq 1 ]; then
sudo apt-get install -y -f gcc-arm-linux-androideabi
if [ ! -f $NDK_ROOT/README.md ]; then
mkdir -p $NDK_ROOT;
(
cd $NDK_ROOT;
NDK_ZIP="android-ndk-${NDK_VERSION}-linux-x86_64.zip"
if [ ! -f $NDK_ZIP ]; then
wget "https://dl.google.com/android/repository/$NDK_ZIP" || exit $?
fi
if [ ! -f $NDK_ZIP ]; then
echo Failed to download $NDK_ZIP
exit 1
fi
unzip_strip $NDK_ZIP . || exit $?
) || exit $?
fi
(
cd $NDK_ROOT;
./build/tools/make_standalone_toolchain.py --force \
--api=$ANDROID_API \
--install-dir=$NDK_TOOLS --stl=libc++ --arch=$ANDROID_TOOLCHAIN_ARCH || exit $?
) || exit $?
if [ ! -d $BOOST_ANDROID_ROOT ] || [ ! -d "$BOOST_ANDROID_ROOT/build/$ANDROID_ARCH" ]; then
git clone "https://github.com/amsurana/Boost-for-Android.git" $BOOST_ANDROID_ROOT
cd $BOOST_ANDROID_ROOT;
echo "Boost is cloned in $BOOST_ANDROID_ROOT"
./build-android.sh --boost=1.65.1 --arch=$ANDROID_ARCH $NDK_ROOT
fi
if [ ! -d $BOOST_ANDROID_ROOT ] || [ ! -d "$BOOST_ANDROID_ROOT/build/$ANDROID_ARCH" ]; then
echo "Unable to download or setup boos. Refer README-ANDROID.md for manual setup"
exit 1;
fi
if [ $SSL -eq 1 ]; then
echo "SSL_ROOT is set to $SSL_ROOT"
if [ ! -d $SSL_ROOT ]; then
git clone --depth 1 https://github.com/openssl/openssl.git $SSL_ROOT
fi
cd $SSL_ROOT
export ANDROID_NDK=$NDK_ROOT
HOST_ARCH="linux-x86_64";
if [ $MAC == 1 ]; then
HOST_ARCH="darwin-x86_64";
fi
export PATH=$ANDROID_NDK/toolchains/$ANDROID_TOOLCHAIN-$ANDROID_ABI/prebuilt/$HOST_ARCH/bin:$PATH
echo $PATH;
./Configure android-arm
make clean
make -j4
fi
fi #android condition ends
if [ $ROS -eq 1 ]; then
sudo apt-get install -y ros-kinetic-desktop-full python-rosinstall ros-kinetic-ros-type-introspection ros-kinetic-move-base-msgs ros-kinetic-navigation libactionlib-dev libactionlib-msgs-dev libmove-base-msgs-dev ros-kinetic-pcl-conversions ros-kinetic-pcl-ros libpcl-dev
if [ $ROS_FIRST_SETUP -eq 1 ]; then
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
fi
fi
if [ $SSL -eq 1 ]; then
sudo apt-get install -y libssl-dev
fi
if [ $ZMQ -eq 1 ]; then
sudo apt-get install -y libtool pkg-config autoconf automake
fi
if [ $DMPL -eq 1 ]; then
sudo apt-get install -y perl git build-essential subversion libboost-all-dev bison flex realpath cbmc tk xvfb libyaml-cpp-dev ant
fi
fi
if [ $MAC -eq 1 ]; then
# Install boost for mac
if [ $PREREQS -eq 1 ]; then
brew install boost@1.59
if [ $JAVA -eq 1 ]; then
brew install maven
fi
fi
export BOOST_ROOT=/usr/local/opt/boost@1.59/include
export BOOST_ROOT_LIB=/usr/local/opt/boost@1.59/lib
fi
if [ $LZ4 -eq 1 ] ; then
export LZ4=1
if [ ! -d $LZ4_ROOT ]; then
echo "git clone https://github.com/lz4/lz4.git $LZ4_ROOT"
git clone https://github.com/lz4/lz4.git $LZ4_ROOT
else
echo "UPDATING LZ4"
cd $LZ4_ROOT
git pull
fi
if [ $ANDROID -eq 1 ]; then
cd $LZ4_ROOT
export CROSS_PATH=${NDK_TOOLS}/bin/${ANDROID_TOOLCHAIN}
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-gcc
export CXX=${CROSS_PATH}-clang++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib
export STRIP=${CROSS_PATH}-strip
make clean
make
fi
LZ4_REPO_RESULT=$?
if [ -f $LZ4_ROOT/lib/lz4.c ] ; then
echo "cp $LZ4_ROOT/lib/lz4.c $LZ4_ROOT/lib/lz4.cpp"
cp $LZ4_ROOT/lib/lz4.c $LZ4_ROOT/lib/lz4.cpp
fi
if [ ! -f $LZ4_ROOT/lib/liblz4.so ]; then
echo "LZ4 library did not build properly";
fi
fi
# check if MPC is a prereq for later packages
if [ $DMPL -eq 1 ] || [ $GAMS -eq 1 ] || [ $MADARA -eq 1 ]; then
MPC_DEPENDENCY_ENABLED=1
fi
if [ $MPC_DEPENDENCY_ENABLED -eq 1 ] && [ ! -d $MPC_ROOT ]; then
MPC_AS_A_PREREQ=1
fi
if [ $MADARA -eq 1 ] && [ $PREREQS -eq 1 ]; then
CAPNP_AS_A_PREREQ=1
fi
if [ $MPC -eq 1 ] || [ $MPC_AS_A_PREREQ -eq 1 ]; then
cd $INSTALL_DIR
echo "ENTERING $MPC_ROOT"
if [ ! -d $MPC_ROOT ] ; then
echo "git clone --depth 1 https://github.com/DOCGroup/MPC.git $MPC_ROOT"
git clone --depth 1 https://github.com/DOCGroup/MPC.git $MPC_ROOT
MPC_REPO_RESULT=$?
fi
else
echo "NOT CHECKING MPC"
fi
if [ $GAMS -eq 1 ] || [ $EIGEN_AS_A_PREREQ -eq 1 ]; then
cd $INSTALL_DIR
echo "ENTERING $EIGEN_ROOT"
if [ -d $EIGEN_ROOT ]; then
(
cd $EIGEN_ROOT
if git branch | grep "* master"; then
echo "EIGEN IN $EIGEN_ROOT IS MASTER BRANCH"
echo "Deleting and redownloading stable release..."
cd $HOME
rm -rf $EIGEN_ROOT
fi
)
fi
if [ ! -d $EIGEN_ROOT ] ; then
echo "git clone --single-branch --branch 3.3.4 --depth 1 https://github.com/eigenteam/eigen-git-mirror.git $EIGEN_ROOT"
git clone --single-branch --branch 3.3.4 --depth 1 https://github.com/eigenteam/eigen-git-mirror.git $EIGEN_ROOT
EIGEN_REPO_RESULT=$?
else
echo "UPDATING Eigen"
cd $EIGEN_ROOT
git pull
EIGEN_REPO_RESULT=$?
fi
else
echo "NOT CHECKING EIGEN"
fi
if [ $CAPNP_AS_A_PREREQ -eq 1 ]; then
cd $INSTALL_DIR
echo "ENTERING $CAPNP_ROOT"
if [ -d $CAPNP_ROOT ]; then
(
cd $CAPNP_ROOT
if git branch | grep "* master"; then
echo "CAPNPROTO IN $CAPNP_ROOT IS MASTER BRANCH"
echo "Deleting and redownloading stable release..."
cd $HOME
rm -rf $CAPNP_ROOT
fi
)
fi
if [ ! -d $CAPNP_ROOT ] ; then
git clone --single-branch --branch release-0.6.1 --depth 1 https://github.com/capnproto/capnproto.git $CAPNP_ROOT
CAPNP_REPO_RESULT=$?
else
cd $CAPNP_ROOT
git pull
CAPNP_REPO_RESULT=$?
fi
cd $CAPNP_ROOT/c++
if [ $CLEAN -eq 1 ] ; then
make clean -j $CORES
fi
autoreconf -i
if [ $ANDROID -eq 1 ]; then
export CROSS_PATH=${NDK_TOOLS}/bin/${ANDROID_TOOLCHAIN}
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-clang++
export CXX=${CROSS_PATH}-clang++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib
export STRIP=${CROSS_PATH}-strip
./configure --host=${ANDROID_TOOLCHAIN} --with-sysroot=${SYSROOT} CPPFLAGS="${CPPLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${NDK_TOOLS}/include -std=c++11" LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${NDK_TOOLS}/lib -L${NDK_TOOLS}/${ANDROID_TOOLCHAIN}/lib" LIBS='-lc++_shared'
else
export PATH="$CAPNP_ROOT/c++:$PATH"
export LD_LIBRARY_PATH="$CAPNP_ROOT/c++/.libs:$LD_LIBRARY_PATH"
if [ $CLANG -ne 0 ] && [ $MAC -eq 0 ]; then
export CC=clang-5.0
export CXX=clang++-5.0
export CXXFLAGS="-stdlib=libc++ -I/usr/include/libcxxabi"
fi
./configure
fi
make -j$CORES capnp capnpc-c++ libcapnp-json.la
CAPNP_BUILD_RESULT=$?
if [ ! -d $CAPNP_ROOT/c++/.libs ]; then
echo "CapNProto is not built properly."
exit 1;
fi
#Prereq if ends
else
echo "NOT CHECKING CAPNPROTO"
fi
if [ $ZMQ -eq 1 ]; then
export ZMQ=1
cd $INSTALL_DIR
if [ -z $ZMQ_ROOT ]; then
if [ $ANDROID -eq 1 ]; then
export ZMQ_ROOT=$INSTALL_DIR/libzmq/output
else
export ZMQ_ROOT=/usr/local
fi
fi
echo "ZMQ_ROOT has been set to $ZMQ_ROOT"
if [ ! -f $ZMQ_ROOT/lib/libzmq.so ]; then
if [ ! -d libzmq ] ; then
echo "git clone --depth 1 https://github.com/zeromq/libzmq"
git clone --depth 1 https://github.com/zeromq/libzmq
ZMQ_REPO_RESULT=$?
fi
#Go to zmq directory
cd libzmq
# For Android
if [ $ANDROID -eq 1 ]; then
echo "UPDATING ZMQ FOR ANDROID"
export ZMQ_OUTPUT_DIR=`pwd`/output
./autogen.sh && ./configure --enable-shared --disable-static --host=$ANDROID_TOOLCHAIN --prefix=$ZMQ_OUTPUT_DIR LDFLAGS="-L$ZMQ_OUTPUT_DIR/lib" CPPFLAGS="-fPIC -I$ZMQ_OUTPUT_DIR/include" LIBS="-lgcc" CXX=$NDK_TOOLS/bin/$ANDROID_TOOLCHAIN-clang++ CC=$NDK_TOOLS/bin/$ANDROID_TOOLCHAIN-clang
make clean install -j $CORES
export ZMQ_ROOT=$ZMQ_OUTPUT_DIR
#For regular builds.
else
echo "UPDATING ZMQ"
./autogen.sh && ./configure && make clean -j $CORES
make check
sudo make install && sudo ldconfig
ZMQ_BUILD_RESULT=$?
export ZMQ_ROOT=/usr/local
fi
fi
#check again after installation
if [ ! -f $ZMQ_ROOT/lib/libzmq.so ]; then
echo "No libzmq found at $ZMQ_ROOT"
exit 1;
fi
#fi #libzmq.so condition check ends.
else
echo "NOT BUILDING ZEROMQ. If this is an error, delete the libzmq directory"
fi
if [ $SSL -eq 1 ]; then
export SSL=1;
if [ -z $SSL_ROOT ]; then
if [ $MAC -eq 0 ]; then
export SSL_ROOT=/usr
elif [ $ANDROID -eq 1 ]; then
export SSL_ROOT=$INSTALL_DIR/openssl
else
export SSL_ROOT=/usr/local/opt/openssl
fi
fi
fi
# set MADARA_ROOT since it is required by most other packages
if [ -z $MADARA_ROOT ] ; then
export MADARA_ROOT=$INSTALL_DIR/madara
echo "SETTING MADARA_ROOT to $MADARA_ROOT"
fi
# check if MADARA_ROOT/lib is in LD_LIBRARY_PATH and modify if needed
if [[ ! ":$LD_LIBRARY_PATH:" == *":$MADARA_ROOT/lib:"* ]]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MADARA_ROOT/lib
fi
if [ $DMPL -eq 1 ] || [ $GAMS -eq 1 ] ; then
MADARA_DEPENDENCY_ENABLED=1
fi
# check if MADARA is a prereq for later packages
if [ $MADARA_DEPENDENCY_ENABLED -eq 1 ] && [ ! -d $MADARA_ROOT ]; then
MADARA_AS_A_PREREQ=1
fi
if [ $MADARA -eq 1 ] || [ $MADARA_AS_A_PREREQ -eq 1 ]; then
echo "LD_LIBRARY_PATH for MADARA compile is $LD_LIBRARY_PATH"
if ! ls $CAPNP_ROOT/c++/.libs/libcapnp-json* > /dev/null 2>&1; then
echo "Cap'Nproto is not built properly or not installed. Please run base_build with 'prereqs' option or check out troubleshooting steps in GAMS Installation Wiki.";
exit 1;
fi
if [ $JAVA -eq 1 ] && [ -z $JAVA_HOME ]; then
echo "Set JAVA_HOME or use prereqs to download Oracle Java automatically"
exit 1;
fi
cd $INSTALL_DIR
if [ ! -d $MADARA_ROOT ] ; then
echo "DOWNLOADING MADARA"
echo "git clone -b master --depth 1 https://github.com/jredmondson/madara.git $MADARA_ROOT"
git clone -b master --depth 1 https://github.com/jredmondson/madara.git $MADARA_ROOT
MADARA_REPO_RESULT=$?
else
echo "UPDATING MADARA"
cd $MADARA_ROOT
git pull
MADARA_REPO_RESULT=$?
echo "CLEANING MADARA OBJECTS"
if [ $CLEAN -eq 1 ] ; then
make realclean -j $CORES
rm GNUmakefile*
fi
fi
cd $MADARA_ROOT
echo "GENERATING MADARA PROJECT"
echo "perl $MPC_ROOT/mwc.pl -type make -features android=$ANDROID,python=$PYTHON,java=$JAVA,tests=$TESTS,tutorials=$TUTORIALS,docs=$DOCS,ssl=$SSL,zmq=$ZMQ,simtime=$SIMTIME,nothreadlocal=$NOTHREADLOCAL,clang=$CLANG,debug=$DEBUG MADARA.mwc"
perl $MPC_ROOT/mwc.pl -type make -features lz4=$LZ4,android=$ANDROID,python=$PYTHON,java=$JAVA,tests=$TESTS,tutorials=$TUTORIALS,docs=$DOCS,ssl=$SSL,zmq=$ZMQ,simtime=$SIMTIME,nothreadlocal=$NOTHREADLOCAL,clang=$CLANG,debug=$DEBUG MADARA.mwc
if [ $JAVA -eq 1 ]; then
echo "DELETING MADARA JAVA CLASSES"
# sometimes the jar'ing will occur before all classes are actually built when performing
# multi-job builds, fix by deleting class files and recompiling with single build job
find . -name "*.class" -delete
fi
echo "BUILDING MADARA"
echo "make depend android=$ANDROID java=$JAVA tests=$TESTS tutorials=$TUTORIALS docs=$DOCS ssl=$SSL zmq=$ZMQ simtime=$SIMTIME python=$PYTHON -j $CORES"
make depend lz4=$LZ4 android=$ANDROID java=$JAVA tests=$TESTS tutorials=$TUTORIALS docs=$DOCS ssl=$SSL zmq=$ZMQ simtime=$SIMTIME python=$PYTHON -j $CORES
echo "make android=$ANDROID java=$JAVA tests=$TESTS tutorials=$TUTORIALS docs=$DOCS ssl=$SSL zmq=$ZMQ simtime=$SIMTIME python=$PYTHON -j $CORES"
make lz4=$LZ4 android=$ANDROID java=$JAVA tests=$TESTS tutorials=$TUTORIALS docs=$DOCS ssl=$SSL zmq=$ZMQ simtime=$SIMTIME python=$PYTHON -j $CORES
MADARA_BUILD_RESULT=$?
if [ ! -f $MADARA_ROOT/lib/libMADARA.so ]; then
MADARA_BUILD_RESULT=1
echo -e "\e[91m MADARA library did not build properly. \e[39m"
exit 1;
fi
if [ $STRIP -eq 1 ]; then
echo "STRIPPING MADARA"
$STRIP_EXE libMADARA.so*
fi
else
echo "NOT BUILDING MADARA"
fi
if [ $DMPL -eq 1 ] && [ ! -d $VREP_ROOT ]; then
VREP_AS_A_PREREQ=1
fi
if [ $VREP -eq 1 ] || [ $VREP_AS_A_PREREQ -eq 1 ]; then
if [ ! $VREP_ROOT ] ; then
export VREP_ROOT=$INSTALL_DIR/vrep
echo "SETTING VREP_ROOT to $VREP_ROOT"
fi
if [ ! -d $VREP_ROOT ]; then
cd $INSTALL_DIR
echo "DOWNLOADING VREP"
wget http://coppeliarobotics.com/files/$VREP_INSTALLER
VREP_REPO_RESULT=$?
mkdir $VREP_ROOT
echo "UNPACKING VREP"
tar xfz $VREP_INSTALLER -C $VREP_ROOT --strip-components 1
echo "CHANGING VREP OPTIONS"
if [ -f $VREP_ROOT/system/usrset.txt ]; then
for i in doNotShowOpenglSettingsMessage doNotShowCrashRecoveryMessage doNotShowUpdateCheckMessage; do
cat $VREP_ROOT/system/usrset.txt | sed "s/$i = false/$i = true/g" > $VREP_ROOT/system/usrset.txt1
mv $VREP_ROOT/system/usrset.txt1 $VREP_ROOT/system/usrset.txt
done
else
for i in doNotShowOpenglSettingsMessage doNotShowCrashRecoveryMessage doNotShowUpdateCheckMessage; do
echo "$i = true" >> $VREP_ROOT/system/usrset.txt
done
fi
echo "CONFIGURING 20 VREP PORTS"
$GAMS_ROOT/scripts/simulation/remoteApiConnectionsGen.pl 19905 20
echo "PATCHING VREP"
patch -b -d $VREP_ROOT -p1 -i $GAMS_ROOT/scripts/linux/patches/00_VREP_extApi_readPureDataFloat_alignment.patch
else
echo "NO CHANGE TO VREP"
fi
else
echo "NOT DOWNLOADING VREP"
fi
if [ $DMPL -eq 1 ] && [ ! -d $GAMS_ROOT ]; then
GAMS_AS_A_PREREQ=1
fi
echo "LD_LIBRARY_PATH for GAMS compile is $LD_LIBRARY_PATH"
# if gams has been specified, or if dmpl is specified and GAMS_ROOT doesn't exist
if [ $GAMS -eq 1 ] || [ $GAMS_AS_A_PREREQ -eq 1 ]; then
# build GAMS
if [ -z $GAMS_ROOT ] ; then
export GAMS_ROOT=$INSTALL_DIR/gams
echo "SETTING GAMS_ROOT to $GAMS_ROOT"
fi
if [ ! -d $GAMS_ROOT ] ; then
echo "DOWNLOADING GAMS"
echo "git clone -b master --depth 1 --single-branch https://github.com/jredmondson/gams.git $GAMS_ROOT"
git clone -b master --depth 1 --single-branch https://github.com/jredmondson/gams.git $GAMS_ROOT
GAMS_REPO_RESULT=$?
else
echo "UPDATING GAMS"
cd $GAMS_ROOT
git pull
GAMS_REPO_RESULT=$?
echo "CLEANING GAMS OBJECTS"
if [ $CLEAN -eq 1 ] ; then
make realclean -j $CORES
rm GNUmakefile*
fi
fi
cd $GAMS_ROOT
echo "GENERATING GAMS PROJECT"
echo "perl $MPC_ROOT/mwc.pl -type make -features java=$JAVA,ros=$ROS,types=$TYPES,vrep=$VREP,tests=$TESTS,android=$ANDROID,docs=$DOCS,clang=$CLANG,simtime=$SIMTIME,debug=$DEBUG gams.mwc"
perl $MPC_ROOT/mwc.pl -type make -features java=$JAVA,ros=$ROS,types=$TYPES,vrep=$VREP,tests=$TESTS,android=$ANDROID,docs=$DOCS,clang=$CLANG,simtime=$SIMTIME,debug=$DEBUG gams.mwc
if [ $TYPES -eq 1 ]; then
# Strip the unnecessary NOTPARALLEL: directives
sed -i '/\.NOTPARALLEL:/d' Makefile.types
fi
if [ $JAVA -eq 1 ]; then
# sometimes the jar'ing will occur before all classes are actually built when performing
# multi-job builds, fix by deleting class files and recompiling with single build job
find . -name "*.class" -delete
fi
echo "BUILDING GAMS"
echo "make depend java=$JAVA ros=$ROS types=$TYPES vrep=$VREP tests=$TESTS android=$ANDROID simtime=$SIMTIME docs=$DOCS -j $CORES"
make depend java=$JAVA ros=$ROS types=$TYPES vrep=$VREP tests=$TESTS android=$ANDROID simtime=$SIMTIME docs=$DOCS -j $CORES
echo "make java=$JAVA ros=$ROS types=$TYPES vrep=$VREP tests=$TESTS android=$ANDROID simtime=$SIMTIME docs=$DOCS -j $CORES"
make java=$JAVA ros=$ROS types=$TYPES vrep=$VREP tests=$TESTS android=$ANDROID simtime=$SIMTIME docs=$DOCS -j $CORES
GAMS_BUILD_RESULT=$?
GAMS_BUILD_RESULT=$?
if [ ! -f $GAMS_ROOT/lib/libGAMS.so ]; then
GAMS_BUILD_RESULT=1
echo -e "\e[91mGAMS library did not build properly\e[39m";
exit 1;
fi