-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMake
executable file
·140 lines (125 loc) · 3.28 KB
/
Make
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
#!/bin/bash
WORK_DIR=`pwd`
BUILD_DIR=`pwd`"/Build"
TEST_DIR=`pwd`"/Test"
INSTALL_DIR=${HOME}/.local/throw
# https://stackoverflow.com/questions/192249
POSITIONAL=()
KEY="${1}"
while [[ $# -gt 0 ]]; do
case ${KEY} in
-h|--help)
HELP=true
shift
;;
-c|--clean)
CLEAN=true
shift
;;
-t|--test)
TEST=true
shift
;;
-i|--install)
INSTALL=true
shift
;;
-p|--pack)
PACK=true
shift
;;
-u|--upload)
UPLOAD=true
shift
;;
-d|--documentation)
DOCUMENTATION=true
shift
;;
*)
POSITIONAL+=("${1}")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
if [ "${HELP}" = true ]; then
echo "Usage: ./Make [-h, -c, -t, -i, -p, -u, -d]"
echo
echo " -h, --help Show this help"
echo " -c, --clean Clean build directory"
echo " -t, --test Test the library"
echo " -i, --install Test the library"
echo " -p, --pack Pack the library to tar.gz file"
echo " -u, --upload Upload the library to kjvbrt.org"
echo " -d, --documentation Compile documentation"
exit
fi
if [ "${CLEAN}" == true ]; then
echo "INFO: Cleaning \"${BUILD_DIR}\" directory..."
rm -rf ${BUILD_DIR}/*
rm -rf ${TEST_DIR}/*
rm ${WORK_DIR}/Throw.tar.gz
exit
fi
echo "INFO: Building..."
if [ ! -d "${BUILD_DIR}" ]; then
echo "WARNING: Build directory \"${BUILD_DIR}\" does not exist, creating it."
mkdir ${BUILD_DIR}
fi
cd ${BUILD_DIR}
if [ -x "$(command -v cmake)" ]; then
cmake ${WORK_DIR}
else
echo "WARNING: \"cmake\" not found, trying \"cmake3\"."
cmake3 ${WORK_DIR}
fi
make
SUCCESS=$?
if [ ${SUCCESS} -eq 0 ] && [ "${TEST}" == true ]; then
echo "INFO: Testing..."
cp ${BUILD_DIR}/Test ${TEST_DIR}/
cd ${TEST_DIR}
./Test
fi
if [ ${SUCCESS} -eq 0 ] && [ "${INSTALL}" == true ]; then
echo "INFO: Installing..."
cd ${WORK_DIR}
if [ ! -d "${INSTALL_DIR}/include" ]; then
echo "WARNING: Install include directory does not exist, creating it."
mkdir -p ${INSTALL_DIR}/include
fi
cp Throw.h ${INSTALL_DIR}/include/
if [ ! -d "${INSTALL_DIR}/lib" ]; then
echo "WARNING: Install lib directory does not exist, creating it."
mkdir -p ${INSTALL_DIR}/lib
fi
cp ${BUILD_DIR}/libThrow.a ${INSTALL_DIR}/lib/
fi
if [ ${SUCCESS} -eq 0 ] && [ "${PACK}" == true ]; then
echo "INFO: Packing..."
cd ${WORK_DIR}
tar -czvf Throw.tar.gz Throw.h Throw*cxx Build/libThrow.a README.md LICENSE
fi
if [ ${SUCCESS} -eq 0 ] && [ "${UPLOAD}" == true ]; then
echo "INFO: Uploading..."
cd ${WORK_DIR}
scp Throw.tar.gz boltzmann:/var/www/kjvbrt.org/Throw/
if [ $? -ne 0 ]; then
echo "ERROR: Problem with upload!"
exit 1
else
rm Throw.tar.gz
fi
fi
if [ ${SUCCESS} -eq 0 ] && [ "${DOCUMENTATION}" == true ]; then
echo "INFO: Compiling documentation..."
cd ${WORK_DIR}
doxygen
scp -r Documentation/html/* boltzmann:/var/www/kjvbrt.org/Throw/Documentation/
if [ $? -ne 0 ]; then
echo "ERROR: Problem with documentation upload!"
exit 1
fi
fi
exit ${SUCCESS}