-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·326 lines (295 loc) · 8.28 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
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
#!/bin/sh
# beautify configure script (C) 2003 Tom White
echo "-----------------------------------------"
echo "Beautify Version 1.00"
echo "-----------------------------------------"
#set temporary files
if test ! -z "$TMPDIR"; then
TMPDIR1="{TMPDIR}"
elif test ! -z "$TEMPDIR" ; then
TMPDIR1="${TEMPDIR}";
else
TMPDIR1="/tmp"
fi;
#for testing C files
TMPC="${TMPDIR1}/beautify-conf-${RANDOM}-$$-${RANDOM}.c"
#for output files
TMPO="${TMPDIR1}/beautify-conf-${RANDOM}-$$-${RANDOM}.o"
#this becomes config.h
TMPH="${TMPDIR1}/beautify-conf-${RANDOM}-$$-${RANDOM}.h"
#default params
prefix="/usr/local"
cc="g++"
make="make"
cpu=`uname -m`
gprof="no"
mpi="no"
mpi_path=""
win32="no"
mingw32="no"
cygwin="no"
debug="no"
#do not recompile libraries by default
#beautify_config_args="--enable-mpi"
targets="beautify"
tom="no"
anonymous1="no"
#default compiler optimizations to check for
#omit-frame-pointer
ofp="yes"
#inline-funtions
fif="yes"
#OS Specific default settings
#switch to set them up
targetos=`uname -s`
case $targetos in
SunOS)
;;
FreeBSD)
;;
MINGW32*)
;;
CYGWIN*)
;;
Linux)
;;
*)
;;
esac
#find path to project root
# we assume an absolute path is given when launching configure,
# unless ./configure is used.
source_path=${0%configure}
source_path=${source_path%/}
source_path_used="yes"
#check for ./configure
if test -z "$source_path" -o "$source_path" = "." ; then
source_path=`pwd`
source_path_used="no"
fi
#check for options passed to configure script
for opt do
case "$opt" in
--prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
;;
--source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
;;
--cc=*) cc=`echo $opt | cut -d '=' -f 2`
;;
--make=*) make=`echo $opt | cut -d '=' -f 2`
;;
--extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
;;
--extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
;;
--extra-libs=*) extralibs=${opt#--extra-libs=}
;;
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
;;
--enable-gprof) gprof="yes"
;;
--enable-win32) win32="yes"
;;
--enable-mingw32) mingw32="yes"
;;
--enable-mpi) mpi="yes"
;;
--mpi-path=*) mpi_path=`echo $opt | cut -d '=' -f 2`
;;
--enable-debug) debug="yes"
;;
esac
done
#see if CFlags or has been enabled
#if not, optimize if debug not set. Otherwise don't debug.
if test -z "$CFLAGS"; then
if test "$debug" = "no"; then
CFLAGS="-O3"
else
CFLAGS="-g"
fi
fi
CFLAGS="$CFLAGS -I$source_path/include/Functions -I$source_path/include/linAlgLib -Wno-endif-labels -Wno-format-contains-nul `pkg-config --cflags ImageMagick++`"
LDFLAGS="$LDFLAGS -lm -lTomFun -llinAlg -lglut -lGLU -lGL `pkg-config --libs-only-l ImageMagick++`"
#test to see if win32 was set; if so, cross-compile
if test "$win32" = "yes" ; then
cross_prefix="i386-mingw32msvc-"
fi
#if mpi was enabled, set cc to mpiCC
if test "$mpi" = "yes" ; then
cc="mpiCC";
echo "#define PARALLEL" > $TMPH
fi
cc="${cross_prefix}${cc}"
# ---
# check availability of some libraries
#is Anonymous1's linear algebra library working?
echo -n "Checking for Anonymous1's Linear Algebra Library..."
cat > $TMPC <<EOF
#include <Point3Df.h>
#include <Point3Dd.h>
#include <Point4Df.h>
#include <Point4Dd.h>
int main(int argc, char ** argv) {
Point3Dd bob(0.1,0.2,0.3);
Point3Dd susan(0.2,0.3,0.4);
bob.normalize();
double dsusan=susan.norm();
return 0;
}
EOF
#echo $cc $CFLAGS -o $TMPO $TMPC -llinAlg
$cc $CFLAGS -o $TMPO $TMPC -llinAlg 2>/dev/null || {
echo "NOT FOUND using $cc. Linear Algebra Library must be installed.";
anonymous1="yes";
}
if test "$anonymous1"="no"; then
echo "yes."
fi;
#is Tom's Function Library working?
echo -n "Checking for Tom's Function Library..."
cat > $TMPC <<EOF
#include <FunNode.h>
#include <SumFunNode.h>
#include <FunTransform4Dd.h>
int main(int argc, char ** argv) {
return 0;
}
EOF
#echo $cc $CFLAGS -o $TMPO $TMPC -llinAlg -lTomFun
$cc $CFLAGS -o $TMPO $TMPC -llinAlg -lTomFun 2>/dev/null || {
echo "NOT FOUND using $cc. Function Library Must Be Installed.";
targets="tom $targets";
tom="yes"
}
if test "$tom" = "no"; then
echo "yes."
fi;
if test "$anonymous1" = "yes"; then
targets="anonymous1 $targets";
fi;
#is MPI enabled & working?
# (MPI is the message passing interface, for running on multiple
# workstations)
if test "$mpi" = "yes"; then
echo -n "Checking for mpi..."
cat > $TMPC <<EOF
#include <mpi.h>
int main( int argc, char ** argv) {
MPI_Init(&argc,&argv);
MPI_Finalize();
return 0;
}
EOF
$cc -I $mpi_path/include -o $TMPO $TMPC 2> /dev/null || mpi="no"
if test "$mpi" = "no"; then
cc="g++";
cc="${cross_prefix}${cc}"
else
CFLAGS="$CFLAGS -I $mpi_path/include"
fi
echo "MPI status: $mpi";
fi
# ---
#check to see if compiler supports some optimization options
#does compiler support omit-frame-pointer?
#this option makes debugging nearly impossible,
#but saves instructions in simple functions.
if test "$debug" = "no"; then
if test "$ofp" = "yes"; then
echo -n "Checking $cc -fomit-frame-pointer..."
cat > $TMPC <<EOF
int main(int argc, char ** argv) {
return 0;
}
EOF
$cc -fomit-frame-pointer -o $TMPO $TMPC 2> /dev/null || ofp = "no"
if test "$ofp" = "yes"; then
CFLAGS="$CFLAGS -fomit-frame-pointer"
echo "yes"
else
echo "no"
fi fi
#does compiler support -finline-functions?
if test "$fif"="yes"; then
echo -n "Checking $cc -finline-functions..."
cat > $TMPC <<EOF
int main(int argc, char ** argv) {
return 0;
}
EOF
$cc -finline-functions -o $TMPO $TMPC 2> /dev/null || fif = "no"
if test "$fif" = "yes"; then
CFLAGS="$CFLAGS -finline-functions"
echo "yes"
else
echo "no"
fi fi fi
#did the user ask for help with ./configure -h | --help?
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
cat << EOF
Usage: configure [options]
Options: [defaults in brackets after descriptions]
EOF
echo "Standard options:"
echo " --help print this message"
echo " --prefix=PREFIX install in PREFIX [$prefix]"
echo " --enable-win32 enable win32 cross compile"
echo " --enable-mingw32 enable mingw32 native windows compile"
echo " --enable-mpi enable the Message Passing Interface"
echo ""
echo "Advanced options (experts only):"
echo " --source-path=PATH path of source code [$source_path]"
echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
echo " --cc=CC use C compiler CC [$cc]"
echo " --make=MAKE use specified make [$make]"
echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
echo " --cpu=CPU force cpu to CPU [$cpu]"
echo " --enable-gprof enable profiling with gprof [$gprof]"
echo " --mpi-path=PATH path of MPI install [$mpi_path]"
echo ""
echo "NOTE: The object files are build at the place where configure is launched"
exit 1
fi
echo "Install prefix $prefix"
echo "Source path $source_path"
echo "Debug build $debug"
echo "Using mpi $mpi"
#echo "Path to MPI $mpi_path"
echo "C compiler $cc"
echo "make $make"
echo "CPU $cpu"
echo "gprof enabled $gprof"
echo "targets $targets"
echo "Creating config.mak"
echo "# Automatically generated by configure - do not modify" > config.mak
echo "/* Automatically generated by configure - do not modify */" > config.h
echo "targets=$targets" >> config.mak
echo "prefix=$prefix" >> config.mak
echo "MAKE=$make" >> config.mak
echo "CC=$cc" >> config.mak
#echo "OPTFLAGS=$CFLAGS" >> config.mak
echo "beautify_config_args=$beautify_config_args" >> config.mak
echo "CCFLAGS=$CFLAGS -I$source_path -I$source_path/src -I$source_path/src/Functions" >> config.mak
echo "LDFLAGS=$LDFLAGS" >> config.mak
if test "$mpi" = "yes" ; then
echo "MPI=yes" >> config.mak
echo "#define PARALLEL" >> config.h
echo "#define BEAUTIFY_USES_MPI" >> config.h
fi;
if test "$mpi_path" ; then
echo "mpi_path=$mpi_path" >> config.mak
fi;
if test "$cpu" = "x86" ; then
echo "TARGET_ARCH_X86=yes" >> config.mak
elif test "$cpu" = "powerpc" ; then
echo "TARGET_ARCH_POWERPC=yes" >> config.mak
fi
if test "$gprof" = "yes" ; then
echo "TARGET_GPROF=yes" >> config.mak
fi
echo GTESTLIBDIRS=`pkg-config --lflags google-test` >> config.mak
rm -f $TMPO $TMPC $TMPS $TMPH
rm -f beautify-conf*.o