Newer
Older
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
#!/bin/sh
# $Id$
#### barf on errors
set -e
# may be used to force a certain automake-version e.g. 1.7
AMVERS=1.8
# everybody who checks out the CVS wants the maintainer-mode to be enabled
# (should be off for source distributions, this should happen automatically)
#
DEFAULTCONFOPT="--enable-maintainer-mode"
# default values
DEBUG=1
OPTIM=0
usage () {
echo "Usage: ./autogen.sh [options]"
echo " -i, --intel use intel compiler"
echo " -g, --gnu use gnu compiler (default)"
echo " --opts=FILE use compiler-options from FILE"
echo " -d, --debug switch debug-opts on"
echo " -n, --nodebug switch debug-opts off"
echo " -o, --optim switch optimization on"
echo " --with-dune=PATH directory with dune/ inside"
echo " -h, --help you already found this :)"
echo
echo "Parameters not in the list above are directly passed to configure. See"
echo
echo " ./configure --help"
echo
echo "for a list of additional options"
}
# no compiler set yet
COMPSET=0
for OPT in $* ; do
set +e
# stolen from configure...
# when no option is set, this returns an error code
arg=`expr "x$OPT" : 'x[^=]*=\(.*\)'`
set -e
case "$OPT" in
-i|--intel) . ./icc.opts ; COMPSET=1 ;;
-g|--gnu) . ./gcc.opts ; COMPSET=1 ;;
--opts=*)
if [ -r $arg ] ; then
echo "reading options from $arg..."
. ./$arg ;
COMPSET=1;
else
echo "Cannot open compiler options file $arg!" ;
exit 1;
fi ;;
-d|--debug) DEBUG=1 ;;
-n|--nodebug) DEBUG=0 ;;
-o|--optim) OPTIM=1 ;;
-h|--help) usage ; exit 0 ;;
# special hack: use the with-dune-dir for aclocal-includes
--with-dune=*)
eval DUNEDIR=$arg
# add the option anyway
CONFOPT="$CONFOPT $OPT" ;;
# pass unknown opts to ./configure
*) CONFOPT="$CONFOPT $OPT" ;;
esac
done
# set special m4-path if --with-dune is set
if [ x$DUNEDIR != x ] ; then
# aclocal from automake 1.8 seems to need an absolute path for inclusion
FULLDIR=`cd $DUNEDIR && pwd`
# automagically use directory above if complete Dune-dir was supplied
if test `basename $FULLDIR` = "dune" ; then
FULLDIR=`cd $FULLDIR/.. && pwd`
fi
ACLOCALOPT="-I $FULLDIR/dune/m4/"
fi
# use the free compiler as default :-)
if [ "$COMPSET" != "1" ] ; then
echo "No compiler set, using GNU compiler as default"
. ./gcc.opts
fi
# create flags
COMPFLAGS="$FLAGS"
# maybe add debug flag
if [ "$DEBUG" = "1" ] ; then
COMPFLAGS="$COMPFLAGS $DEBUGFLAGS"
fi
# maybe add optimization flag
if [ "$OPTIM" = "1" ] ; then
COMPFLAGS="$COMPFLAGS $OPTIMFLAGS"
fi
# check if automake-version was set
if test "x$AMVERS" != x ; then
echo Warning: explicitly using automake version $AMVERS
# binaries are called automake-$AMVERS
AMVERS="-$AMVERS"
fi
#### create all autotools-files
echo "--> libtoolize..."
# force to write new versions of files, otherwise upgrading libtools
# doesn't do anything...
libtoolize --force
echo "--> aclocal..."
aclocal$AMVERS $ACLOCALOPT
# sanity check to catch missing --with-dune
if ! grep DUNE aclocal.m4 > /dev/null ; then
echo "aclocal.m4 doesn't contain any DUNE-macros, this would crash autoconf"
echo "or automake later. Maybe you should provide a --with-dune=PATH parameter"
exit 1
fi
echo "--> autoheader..."
autoheader
echo "--> automake..."
automake$AMVERS --add-missing
echo "--> autoconf..."
autoconf
#### start configure with special environment
export CC="$COMP"
export CXX="$CXXCOMP"
export CPP="$COMP -E"
export CFLAGS="$COMPFLAGS"
export CXXFLAGS="$COMPFLAGS"