-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·220 lines (180 loc) · 5.15 KB
/
configure
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
#!/bin/bash
# Copyright 2014-2015, Dominique LaSalle
#
# I know I should write this in plain 'sh', but I haven't...
###############################################################################
# CONFIG VARIABLES ############################################################
###############################################################################
NAME="mt-metis"
DOMLIB_PATH="domlib"
WILDRIVER_PATH="wildriver"
METIS_PATH="metis"
###############################################################################
# FUNCTIONS ###################################################################
###############################################################################
die() {
echo "ERROR: ${@}" 1>&2
exit 1
}
abspath() {
if [[ "${@::1}" == "/" ]]; then
echo "${@}"
else
echo "${PWD}/${@}"
fi
}
show_help() {
echo "USAGE: configure [options]"
echo ""
echo "OPTIONS:"
echo " --debug"
echo " Build with debugging symbols and turn optimizations off."
echo " --assert"
echo " Build with assertions on."
echo " --prefix=<prefix>"
echo " Set the install prefix."
echo " --shared"
echo " Generate a shared version of lib${NAME} instead of a static one."
echo " --cc=<cc>"
echo " Set the C compiler to use."
echo " --devel"
echo " Turn on compiler warnings."
echo " --edges64bit"
echo " Use 64 bit data types for edges instead of 32 bit."
echo " --vertices64bit"
echo " Use 64 bit data types for vertices instead of 32 bit."
echo " --weights64bit"
echo " Use 64 bit data types for weights instead of 32 bit."
echo " --partitions64bit"
echo " Use 64 bit data types for partitions instead of 32 bit."
echo " --test"
echo " Enable unit testing."
echo ""
}
###############################################################################
# OPTION PARSING ##############################################################
###############################################################################
CONFIG_FLAGS="-DCMAKE_VERBOSE_MAKEFILE=1"
# default values
CMAKE="$(which cmake)"
BUILDDIR="build/$(uname -s)-$(uname -m)"
# parse arguments
for i in "${@}"; do
case "${i}" in
# help
-h|--help)
show_help
exit 0
;;
# debug
--debug)
CONFIG_FLAGS="${CONFIG_FLAGS} -DDEBUG=1"
;;
# assert
--assert)
CONFIG_FLAGS="${CONFIG_FLAGS} -DASSERT=1"
;;
# prefix
--prefix=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DCMAKE_INSTALL_PREFIX=${i#*=}"
;;
# shared
--shared)
CONFIG_FLAGS="${CONFIG_FLAGS} -DSHARED=1"
;;
# devel
--devel)
CONFIG_FLAGS="${CONFIG_FLAGS} -DDEVEL=1"
;;
# cc
--cc=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DCMAKE_C_COMPILER=${i#*=}"
;;
# 64 bit edges
--edges64bit)
CONFIG_FLAGS="${CONFIG_FLAGS} -DBIGEDGES=1"
;;
# 64 bit vertices
--vertices64bit)
CONFIG_FLAGS="${CONFIG_FLAGS} -DBIGVERTICES=1"
;;
# 64 bit wegihts
--weights64bit)
CONFIG_FLAGS="${CONFIG_FLAGS} -DBIGWEIGHTS=1"
;;
# 64 bit partitions
--partitions64bit)
CONFIG_FLAGS="${CONFIG_FLAGS} -DBIGPARTITIONS=1"
;;
# testing
--test)
CONFIG_FLAGS="${CONFIG_FLAGS} -DTESTS=1"
;;
# bad argument
*)
die "Unknown option '${i}'"
;;
esac
done
# check if cmake exists
if [[ ! -x "${CMAKE}" ]]; then
die "Could not find usable cmake: '${CMAKE}'"
else
echo "Found CMAKE: '${CMAKE}'"
echo "--> $("${CMAKE}" --version)"
fi
# check if domlib exists
if [[ ! -d "${DOMLIB_PATH}" ]]; then
die "Could not find domlib: '${DOMLIB_PATH}'"
else
CONFIG_FLAGS="${CONFIG_FLAGS} -DDOMLIB_PATH=${DOMLIB_PATH}"
fi
# check if wildriver exists
if [[ ! -d "${WILDRIVER_PATH}" ]]; then
die "Could not find wildriver: '${WILDRIVER_PATH}'"
else
CONFIG_FLAGS="${CONFIG_FLAGS} -DWILDRIVER_PATH=${WILDRIVER_PATH}"
fi
# check if metis exists
if [[ ! -d "${METIS_PATH}" ]]; then
die "Could not find metis: '${METIS_PATH}'"
else
CONFIG_FLAGS="${CONFIG_FLAGS} -DMETIS_PATH=${METIS_PATH}"
fi
# clean out build directory if it exists
if [[ -d "${BUILDDIR}" ]]; then
echo "Removing old build directory '${BUILDDIR}'..."
rm -rf "${BUILDDIR}"
fi
# create build directory
mkdir -vp "${BUILDDIR}" || \
die "Failed to create build directory: '${BUILDDIR}'"
###############################################################################
# RUN CMAKE ###################################################################
###############################################################################
ROOTDIR="${PWD}"
pushd "${BUILDDIR}"
echo "Calling cmake with arguments '${CONFIG_FLAGS}'"
"${CMAKE}" "${ROOTDIR}" ${CONFIG_FLAGS}
if [[ "$?" != "0" ]]; then
echo "CMake failed with '$?'" 1>&2
exit $?
fi
popd
# create proxy makefile
(
echo "#######################################################################"
echo "# Makefile generated by '$0' at $(date)"
echo "# Using flags:"
for d in ${CONFIG_FLAGS}; do
echo "# ${d}"
done
echo "#######################################################################"
echo ""
echo "all test clean install:"
echo " make -C ${BUILDDIR} \$@ \$(MAKEFLAGS)"
echo ""
echo "distclean:"
echo " rm -rvf ${BUILDDIR} Makefile"
echo ""
) > Makefile