-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake.sh
executable file
·80 lines (71 loc) · 2.42 KB
/
make.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
#!/bin/bash
#Wrapper script for cmake
#./make.sh clean - delete all build files
#./make.sh uninstall - delete all installed files
#./make.sh build - configure and compile
#./make.sh - same (configure and compile)
#./make.sh install - configure, compile, and install
#./make.sh run - configure, compile, install, and run
#./make.sh reconfigure - configure from scratch (can be shortened up to ./make.sh rec)
#Default install is in source:
#executable goes to ./bin
#main library goes to ./lib
#dynamically loaded modules go to ./lib/xfitter
CMAKE_FLAGS=$CMAKE_FLAGS" -DCMAKE_BUILD_TYPE=Release"
#Uncommect to disable some some of the optional packages
#CMAKE_FLAGS=$CMAKE_FLAGS" -DCMAKE_DISABLE_FIND_PACKAGE_APFEL=TRUE"
#CMAKE_FLAGS=$CMAKE_FLAGS" -DCMAKE_DISABLE_FIND_PACKAGE_APFELxx=TRUE"
#CMAKE_FLAGS=$CMAKE_FLAGS" -DCMAKE_DISABLE_FIND_PACKAGE_Ceres=TRUE"
SOURCE_DIR=`pwd` #absolute path to directory of this script
BUILD_DIR=$SOURCE_DIR/build
INSTALL_DIR=$SOURCE_DIR
cmd=$1
if [ "$(echo "$cmd"|cut -b1-3)" == "rec" ];then #reconfigure
cmd=reconfigure
fi
if [ "$cmd" == "clean" ];then
#Delete the build directory
if [ -d $BUILD_DIR ];then
rm -r $BUILD_DIR
rmdir $INSTALL_DIR
fi
elif [ "$cmd" == "uninstall" ];then
#Delete the installed exeuctable and libraries
if [ $INSTALL_DIR == $SOURCE_DIR ];then #if xFitter is installed in-source
#then only remove lib and bin
rm -r lib bin share
else
#else remove the whole install dir
rm -r $INSTALL_DIR
fi
elif [ "$cmd" == "reconfigure" ] || [ "$cmd" == "install" ] || [ "$cmd" == "run" ] || [ "$cmd" == "build" ] || [ -z "$cmd" ];then
#make sure build directory exists
mkdir -p $BUILD_DIR
#cd to build directory and invoke cmake theere
cd $BUILD_DIR
if [ "$cmd" == "reconfigure" ] && [ -e CMakeCache.txt ];then
rm CMakeCache.txt
fi
cmake3='cmake3'
if ! command -v cmake3 >/dev/null 2>&1; then
cmake3='cmake'
fi
if [ ! -f Makefile ] || [ ! -f CMakeCache.txt ];then
$cmake3 $CMAKE_FLAGS $SOURCE_DIR -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR || exit
fi
if [ "$cmd" == "reconfigure" ];then
exit 0
fi
if [ "$cmd" == "install" ] || [ "$cmd" == "run" ];then
make -j$(nproc) install || exit
else
make -j$(nproc) || exit
fi
if [ "$cmd" == "run" ];then
cd $SOURCE_DIR #cd to where steering files are
$INSTALL_DIR/bin/xfitter || exit
fi
else
echo "Unknown command \"$1\""
exit 10
fi