]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/acinclude.m4
Bug fix: savannah 99025
[u/mrichter/AliRoot.git] / HLT / acinclude.m4
CommitLineData
b521659f 1dnl
2dnl $Id$
3dnl
4dnl Copyright (C) 2002 Christian Holm Christensen <cholm@nbi.dk>
5dnl
6dnl This library is free software; you can redistribute it and/or
7dnl modify it under the terms of the GNU Lesser General Public License
8dnl as published by the Free Software Foundation; either version 2.1
9dnl of the License, or (at your option) any later version.
10dnl
11dnl This library is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14dnl Lesser General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU Lesser General Public
17dnl License along with this library; if not, write to the Free
18dnl Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19dnl 02111-1307 USA
20dnl
21dnl ------------------------------------------------------------------
22AC_DEFUN([AC_DEBUG],
23[
24 AC_REQUIRE([AC_PROG_CC])
25 AC_REQUIRE([AC_PROG_CXX])
26 AC_MSG_CHECKING(whether to make debug objects)
27 AC_ARG_ENABLE(debug,
28 [AC_HELP_STRING([--enable-debug],[Enable debugging symbols in objects])],
1e27470a 29 [],[enable_debug=no])
b521659f 30 if test "x$enable_debug" = "xno" ; then
adec4ad4 31 AC_DEFINE(NDEBUG)
b521659f 32 CFLAGS=`echo $CFLAGS | sed 's,-g,,'`
33 CXXFLAGS=`echo $CXXFLAGS | sed 's,-g,,'`
34 else
35 AC_DEFINE(__DEBUG)
adec4ad4 36 AC_DEFINE(DEBUG)
b521659f 37 case $CXXFLAGS in
38 *-g*) ;;
39 *) CXXFLAGS="$CXXFLAGS -g" ;;
40 esac
41 case $CFLAGS in
42 *-g*) ;;
43 *) CFLAGS="$CFLAGS -g" ;;
44 esac
45 fi
46 AC_MSG_RESULT($enable_debug 'CFLAGS=$CFLAGS')
47])
48
5b1c9727 49dnl ------------------------------------------------------------------
50AC_DEFUN([AC_PROFILING],
51[
52 AC_REQUIRE([AC_PROG_CC])
53 AC_REQUIRE([AC_PROG_CXX])
54 AC_MSG_CHECKING(whether to add profiling info)
55 AC_ARG_ENABLE(profiling,
56 [AC_HELP_STRING([--enable-profiling],[Enable profiling info in objects])],
57 [],[enable_profiling=no])
58 if test "x$enable_profiling" = "xno" ; then
59 CFLAGS=`echo $CFLAGS | sed 's,-pg,,'`
60 CXXFLAGS=`echo $CXXFLAGS | sed 's,-pg,,'`
61 else
62 AC_DEFINE(PROFILING)
63 case $CXXFLAGS in
64 *-pg*) ;;
65 *) CXXFLAGS="$CXXFLAGS -pg" ;;
66 esac
67 case $CFLAGS in
68 *-pg*) ;;
69 *) CFLAGS="$CFLAGS -pg" ;;
70 esac
71 fi
72 AC_MSG_RESULT($enable_profiling 'CFLAGS=$CFLAGS')
73])
74
b521659f 75dnl ------------------------------------------------------------------
76AC_DEFUN([AC_OPTIMIZATION],
77[
78 AC_REQUIRE([AC_PROG_CC])
79 AC_REQUIRE([AC_PROG_CXX])
80
81 AC_ARG_ENABLE(optimization,
f59fee6d 82 [AC_HELP_STRING([--disable-optimization],[Enable optimization of objects])],
b521659f 83 [],[enable_optimization=yes])
84
85 AC_MSG_CHECKING(for optimiztion level)
86
87 changequote(<<, >>)dnl
88 if test "x$enable_optimization" = "xno" ; then
89 CFLAGS=`echo $CFLAGS | sed 's,-O\([0-9][0-9]*\|\),,'`
90 CXXFLAGS=`echo $CXXFLAGS | sed 's,-O\([0-9][0-9]*\|\),,'`
91 elif test "x$enable_optimization" = "xyes" ; then
92 case $CXXFLAGS in
93 *-O*) ;;
94 *) CXXFLAGS="$CXXFLAGS -O2" ;;
95 esac
96 case $CFLAGS in
97 *-O*) ;;
98 *) CFLAGS="$CXXFLAGS -O2" ;;
99 esac
100 else
101 CFLAGS=`echo $CFLAGS | sed "s,-O\([0-9][0-9]*\|\),-O$enable_optimization,"`
102 CXXFLAGS=`echo $CXXFLAGS | sed "s,-O\([0-9][0-9]*\|\),-O$enable_optimization,"`
103 fi
104 changequote([, ])dnl
105 AC_MSG_RESULT($enable_optimization 'CFLAGS=$CFLAGS')
106])
107
108dnl ------------------------------------------------------------------
109
110dnl
111dnl Autoconf macro to check for existence or ROOT on the system
112dnl Synopsis:
113dnl
114dnl ROOT_PATH([MINIMUM-VERSION, [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
115dnl
116dnl Some examples:
117dnl
118dnl ROOT_PATH(3.03/05, , AC_MSG_ERROR(Your ROOT version is too old))
119dnl ROOT_PATH(, AC_DEFINE([HAVE_ROOT]))
120dnl
121dnl The macro defines the following substitution variables
122dnl
123dnl ROOTCONF full path to root-config
124dnl ROOTEXEC full path to root
125dnl ROOTCINT full path to rootcint
126dnl ROOTLIBDIR Where the ROOT libraries are
127dnl ROOTINCDIR Where the ROOT headers are
128dnl ROOTCFLAGS Extra compiler flags
129dnl ROOTLIBS ROOT basic libraries
130dnl ROOTGLIBS ROOT basic + GUI libraries
131dnl ROOTAUXLIBS Auxilary libraries and linker flags for ROOT
132dnl ROOTAUXCFLAGS Auxilary compiler flags
133dnl ROOTRPATH Same as ROOTLIBDIR
134dnl
135dnl The macro will fail if root-config and rootcint isn't found.
136dnl
137dnl Christian Holm Christensen <cholm@nbi.dk>
138dnl
139AC_DEFUN([ROOT_PATH],
140[
141 AC_ARG_WITH(rootsys,
142 [ --with-rootsys top of the ROOT installation directory],
143 user_rootsys=$withval,
144 user_rootsys="none")
145 if test ! x"$user_rootsys" = xnone; then
146 rootbin="$user_rootsys/bin"
147 elif test ! x"$ROOTSYS" = x ; then
148 rootbin="$ROOTSYS/bin"
149 else
150 rootbin=$PATH
151 fi
f5076539 152 AC_PATH_PROG(ROOTCONF, root-config , no, $rootbin) # used by HLT build system
153 AC_PATH_PROG(ROOTCONFIG, root-config , no, $rootbin) # used by AliRoot build system
b521659f 154 AC_PATH_PROG(ROOTEXEC, root , no, $rootbin)
155 AC_PATH_PROG(ROOTCINT, rootcint , no, $rootbin)
156
157 if test ! x"$ROOTCONF" = "xno" && \
158 test ! x"$ROOTCINT" = "xno" ; then
159
160 # define some variables
161 ROOTLIBDIR=`$ROOTCONF --libdir`
162 ROOTINCDIR=`$ROOTCONF --incdir`
163 ROOTCFLAGS=`$ROOTCONF --noauxcflags --cflags`
164 ROOTLIBS=`$ROOTCONF --noauxlibs --noldflags --libs`
165 ROOTGLIBS=`$ROOTCONF --noauxlibs --noldflags --glibs`
166 ROOTAUXCFLAGS=`$ROOTCONF --auxcflags`
167 ROOTAUXLIBS=`$ROOTCONF --auxlibs`
168 ROOTRPATH=$ROOTLIBDIR
169
170 if test $1 ; then
171 AC_MSG_CHECKING(wether ROOT version >= [$1])
172 vers=`$ROOTCONF --version | tr './' ' ' | awk 'BEGIN { FS = " "; } { printf "%d", ($''1 * 1000 + $''2) * 1000 + $''3;}'`
173 requ=`echo $1 | tr './' ' ' | awk 'BEGIN { FS = " "; } { printf "%d", ($''1 * 1000 + $''2) * 1000 + $''3;}'`
174 if test $vers -lt $requ ; then
175 AC_MSG_RESULT(no)
176 no_root="yes"
177 else
178 AC_MSG_RESULT(yes)
179 fi
180 fi
181 else
182 # otherwise, we say no_root
183 no_root="yes"
184 fi
185
186 AC_SUBST(ROOTLIBDIR)
187 AC_SUBST(ROOTINCDIR)
188 AC_SUBST(ROOTCFLAGS)
189 AC_SUBST(ROOTLIBS)
190 AC_SUBST(ROOTGLIBS)
191 AC_SUBST(ROOTAUXLIBS)
192 AC_SUBST(ROOTAUXCFLAGS)
193 AC_SUBST(ROOTRPATH)
194
195 if test "x$no_root" = "x" ; then
196 ifelse([$2], , :, [$2])
197 else
198 ifelse([$3], , :, [$3])
199 fi
200])
201
f59fee6d 202dnl ------------------------------------------------------------------
203dnl
204dnl Autoconf macro to check conditions for an HLT module
205dnl - header dependencies
206dnl - library dependencies
207dnl - AliRoot availability
208dnl The macro also exports the --enable/--disable option for the
209dnl module.
210dnl
211dnl Synopsis:
212dnl
213dnl ROOT_PATH([module],
214dnl [headers], [additional CPPFLAGS],
215dnl [libraries], [LD flags], [LIBS],
216dnl [circ libraries], [LD flags], [LIBS])
217dnl
218dnl First argument is the module name.
219dnl
220dnl Arg 2 and 3 allow to check a list of header files and to specify
221dnl additional CPPFLAGS which might be necessary to perform the checks.
222dnl
223dnl Arg 4 to 6 allow to check a list of libraries, with additional
224dnl LDFLAGS and LIBS to be specified.
225dnl
226dnl Arg 7 to 9 is the same for libraries with circular dependencies
227dnl among each other.
228dnl
229dnl Return:
230dnl enable_module=yes
231dnl - AliRoot was found &&
232dnl - header files found &&
233dnl - module not disabled
234dnl
235dnl enable_module=no...requires.AliRoot
236dnl - AliRoot not found
237dnl
238dnl enable_module=missheader
239dnl - one of the specified header files is missing
240dnl
241dnl Libraries are probed and the variable ALIHLTMODULE_LIBS is set to
242dnl all libraries which could be found.
243dnl
244dnl Some examples:
245dnl
246dnl Matthias Richter <Matthias.Richter@uib.no>
247AC_DEFUN([CHECK_HLTMODULE],
248[
249AH_TEMPLATE([HLT_[$1]],[hlt [$1] library])
250AC_ARG_ENABLE([$1],
251 [AC_HELP_STRING([--disable-[$1]],
252 [ compile the $1 library ])],
c6b46c3f 253 [if test "x$enableval" = "xno";
254 then enable_module=no
7233bc62 255 elif test "x$disable_all" = "xyes"; then
256 # do checks if library has been enabled after global disable
257 enable_module=yes
c6b46c3f 258 else
259 enable_module=force
260 fi],
7233bc62 261 [if test "x$disable_all" = "xyes"; then
262 enable_module=no...modules.disabled
263 else
264 enable_module=yes
265 fi # if test "x$disable_all" = "yes"
266 ])
267 if test "x$enable_module" = "xyes"; then
f59fee6d 268 if test "x$have_aliroot" = "xno" ; then
269 enable_module="no...requires.AliRoot"
270 else
adec4ad4 271 AC_MSG_NOTICE([-------------------------------------------------])
f59fee6d 272 AC_MSG_NOTICE([checking dependencies for [$1] library])
273
274 AC_LANG_PUSH(C++)
275 save_CPPFLAGS="$CPPFLAGS"
276 save_LDFLAGS="$LDFLAGS"
277 save_LIBS="$LIBS"
278 CPPFLAGS="$save_CPPFLAGS [$3]"
279
2164f8b4 280 if test "x[$2]" != "x"; then
281 AC_CHECK_HEADERS([$2], [], [enable_module="missheader"])
282 fi
f59fee6d 283
284 dnl ==========================================================================
285 dnl
286 dnl required header files and libraries for the AliHLTxxx library
287 dnl
288
289 dnl ROOT/AliRoot libs needed by libAliHLTxxx
290 CHECKLIBS="[$4]"
291 ALIHLTMODULE_LIBS=
292 LDFLAGS="$save_LDFLAGS [$5]"
293 for CHECKLIB in $CHECKLIBS ; do
294 LIBS="$save_LIBS $ROOTLIBS [$6] $ALIHLTMODULE_LIBS"
295 AC_CHECK_LIB([$CHECKLIB],[_init], [ALIHLTMODULE_LIBS="$ALIHLTMODULE_LIBS -l$CHECKLIB"])
296 done
297
298 dnl libs with circular dependencies needed by libAliHLTxxx
299 CHECKLIBS="[$7]"
300 CIRCULARS=
301 for dep in [$7]; do
302 CIRCULARS="$CIRCULARS -l$dep"
303 done
304 ALIHLTMODULE_LIBS="$ALIHLTMODULE_LIBS"
305 LDFLAGS="$save_LDFLAGS [$8]"
306 for CHECKLIB in $CHECKLIBS ; do
50f2b132 307 CIRCULARS=`echo $CIRCULARS | sed -e "s|-l$CHECKLIB||"`
f59fee6d 308 LIBS="$save_LIBS [$9] $CIRCULARS $ALIHLTMODULE_LIBS"
309 AC_CHECK_LIB([$CHECKLIB],[_init], [ALIHLTMODULE_LIBS="$ALIHLTMODULE_LIBS -l$CHECKLIB"])
310 done
311 CPPFLAGS="$save_CPPFLAGS"
312 LDFLAGS="$save_LDFLAGS"
313 LIBS="$save_LIBS"
314 AC_LANG_POP(C++)
315
7233bc62 316 fi # if test "x$have_aliroot" = "xno"
317 fi # if test "x$enable_module" = "xyes"
f59fee6d 318])
319
b521659f 320
321#
322# EOF
323#