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