Salome HOME
To see which hdf5 we're using in configure log
[modules/kernel.git] / salome_adm / unix / config_files / check_cppunit.m4
1 dnl  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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
8 dnl  License as published by the Free Software Foundation; either
9 dnl  version 2.1 of the License.
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 Software
18 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 dnl
20 dnl  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 dnl
22 AC_DEFUN([CHECK_CPPUNIT],[
23
24 AC_CHECKING(for cppunit)
25
26 cppunit_ok=yes
27
28 dnl were is cppunit ?
29
30 AC_ARG_WITH(cppunit,
31     [AC_HELP_STRING([--with-cppunit=DIR],[directory path to CPPUNIT installation])],
32     [CPPUNITHOME="$withval"
33       AC_MSG_RESULT("select $withval as path to CPPUNIT")
34     ])
35
36 AC_ARG_WITH(cppunit_inc,
37     [AC_HELP_STRING([--with-cppunit_inc=DIR],[directory path to CPPUNIT includes])],
38     [CPPUNIT_INCLUDES="$withval"
39       AC_MSG_RESULT("select $withval as path to CPPUNIT includes")
40     ])
41
42 if test -z "$CPPUNITHOME"; then
43   AC_MSG_RESULT(CPPUNITHOME not defined)
44   exits_ok=no   
45   if test "x$exits_ok" = "xno"; then
46      for d in /usr/local /usr ; do
47         AC_CHECK_FILE(${d}/lib64/libcppunit.so,exits_ok=yes,exits_ok=no)
48         if test "x$exits_ok" = "xyes"; then
49            CPPUNITHOME=$d
50            AC_MSG_RESULT(libcppunit.so detected in $d/lib64)
51            break
52         fi
53         AC_CHECK_FILE(${d}/lib/libcppunit.so,exits_ok=yes,exits_ok=no)
54         if test "x$exits_ok" = "xyes"; then
55            CPPUNITHOME=$d
56            AC_MSG_RESULT(libcppunit.so detected in $d/lib)
57            break
58         fi
59      done
60   fi
61   if test "x$exits_ok" = "xno"; then
62      for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
63         if test -f $d/libcppunit.so ; then
64            AC_MSG_RESULT(libcppunit.so detected in $d)
65            CPPUNITHOME=$d
66            CPPUNITHOME=`echo ${CPPUNITHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
67            exits_ok=yes
68            break
69         fi
70      done
71   fi
72   if test "x$exits_ok" = "xyes"; then
73      if test -z "$CPPUNIT_INCLUDES"; then
74         CPPUNIT_INCLUDES=$CPPUNITHOME"/include"
75      fi
76   fi
77 else
78   if test -z "$CPPUNIT_INCLUDES"; then
79      CPPUNIT_INCLUDES="$CPPUNITHOME/include"
80   fi    
81 fi
82
83 if test "x$cppunit_ok" = xno -o ! -d "$CPPUNITHOME" ; then
84   AC_MSG_RESULT(no)
85   AC_MSG_WARN(cppunit not found)
86   cppunit_ok=no
87 else
88    AC_LANG_SAVE
89    AC_LANG_CPLUSPLUS
90    CPPFLAGS_old=$CPPFLAGS
91    CPPFLAGS="$CPPFLAGS -I$CPPUNIT_INCLUDES"
92    
93    AC_CHECK_HEADER(cppunit/extensions/HelperMacros.h,cppunit_ok=yes,cppunit_ok=no) 
94
95    CPPFLAGS=$CPPFLAGS_old
96
97    if test "x$cppunit_ok" = xno ; then
98      AC_MSG_RESULT(no)
99      AC_MSG_WARN(cppunit not found)
100    else
101      cppunit_ok=yes
102    fi
103
104   if  test "x$cppunit_ok" = "xno"
105   then
106     AC_MSG_RESULT(unable to found cppunit headers and library)
107     AC_MSG_RESULT(CPPUNITHOME environment variable may be wrong)
108   else
109     if test "x$CPPUNIT_INCLUDES" = "x/usr/include"
110     then
111       CPPUNIT_INCLUDES=""
112     else
113       CPPUNIT_INCLUDES="-I$CPPUNIT_INCLUDES"
114     fi
115     if test "x$CPPUNITHOME" = "x/usr"
116     then
117       CPPUNIT_LIBS=" -lcppunit"
118     else
119       CPPUNIT_LIBS="-L$CPPUNITHOME/lib -lcppunit"
120     fi
121
122     AC_SUBST(CPPUNIT_INCLUDES)
123     AC_SUBST(CPPUNIT_LIBS)
124     AC_SUBST(cppunit_ok)
125     AC_MSG_RESULT(yes)
126   fi
127 fi
128
129 AM_CONDITIONAL(CPPUNIT_IS_OK, [test x"$cppunit_ok" = xyes])
130
131 AC_LANG_RESTORE
132
133 ])dnl
134 dnl