Salome HOME
rename SALOME_* options as MEDTOOL_*
[modules/med.git] / adm_local_without_kernel / unix / config_files / check_cppunit.m4
1 dnl Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License, or (at your option) any later version.
7 dnl
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl Lesser General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
20 AC_DEFUN([CHECK_CPPUNIT],[
21
22 AC_CHECKING(for cppunit)
23
24 cppunit_ok=yes
25
26 dnl were is cppunit ?
27
28 AC_ARG_WITH(cppunit,
29     [AC_HELP_STRING([--with-cppunit=DIR],[directory path to CPPUNIT installation])],
30     [CPPUNITHOME="$withval"
31       AC_MSG_RESULT("select $withval as path to CPPUNIT")
32     ])
33
34 AC_ARG_WITH(cppunit_inc,
35     [AC_HELP_STRING([--with-cppunit_inc=DIR],[directory path to CPPUNIT includes])],
36     [CPPUNIT_INCLUDES="$withval"
37       AC_MSG_RESULT("select $withval as path to CPPUNIT includes")
38     ])
39
40 if test -z "$CPPUNITHOME"; then
41   AC_MSG_RESULT(CPPUNITHOME not defined)
42   exits_ok=no   
43   if test "x$exits_ok" = "xno"; then
44      for d in /usr/local /usr ; do
45         AC_CHECK_FILE(${d}/lib64/libcppunit.so,exits_ok=yes,exits_ok=no)
46         if test "x$exits_ok" = "xyes"; then
47            CPPUNITHOME=$d
48            AC_MSG_RESULT(libcppunit.so detected in $d/lib64)
49            break
50         fi
51         AC_CHECK_FILE(${d}/lib/libcppunit.so,exits_ok=yes,exits_ok=no)
52         if test "x$exits_ok" = "xyes"; then
53            CPPUNITHOME=$d
54            AC_MSG_RESULT(libcppunit.so detected in $d/lib)
55            break
56         fi
57      done
58   fi
59   if test "x$exits_ok" = "xno"; then
60      for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
61         if test -f $d/libcppunit.so ; then
62            AC_MSG_RESULT(libcppunit.so detected in $d)
63            CPPUNITHOME=$d
64            CPPUNITHOME=`echo ${CPPUNITHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
65            exits_ok=yes
66            break
67         fi
68      done
69   fi
70   if test "x$exits_ok" = "xyes"; then
71      if test -z "$CPPUNIT_INCLUDES"; then
72         CPPUNIT_INCLUDES=$CPPUNITHOME"/include"
73      fi
74   fi
75 else
76   if test -z "$CPPUNIT_INCLUDES"; then
77      CPPUNIT_INCLUDES="$CPPUNITHOME/include"
78   fi    
79 fi
80
81 if test "x$cppunit_ok" = xno -o ! -d "$CPPUNITHOME" ; then
82   AC_MSG_RESULT(no)
83   AC_MSG_WARN(cppunit not found)
84   cppunit_ok=no
85 else
86    AC_LANG_SAVE
87    AC_LANG_CPLUSPLUS
88    CPPFLAGS_old=$CPPFLAGS
89    CPPFLAGS="$CPPFLAGS -I$CPPUNIT_INCLUDES"
90    
91    AC_CHECK_HEADER(cppunit/extensions/HelperMacros.h,cppunit_ok=yes,cppunit_ok=no) 
92
93    CPPFLAGS=$CPPFLAGS_old
94
95    if test "x$cppunit_ok" = xno ; then
96      AC_MSG_RESULT(no)
97      AC_MSG_WARN(cppunit not found)
98    else
99      cppunit_ok=yes
100    fi
101
102   if  test "x$cppunit_ok" = "xno"
103   then
104     AC_MSG_RESULT(unable to found cppunit headers and library)
105     AC_MSG_RESULT(CPPUNITHOME environment variable may be wrong)
106   else
107     if test "x$CPPUNIT_INCLUDES" = "x/usr/include"
108     then
109       CPPUNIT_INCLUDES=""
110     else
111       CPPUNIT_INCLUDES="-I$CPPUNIT_INCLUDES"
112     fi
113     if test "x$CPPUNITHOME" = "x/usr"
114     then
115       CPPUNIT_LIBS=" -lcppunit"
116     else
117       CPPUNIT_LIBS="-L$CPPUNITHOME/lib -lcppunit"
118     fi
119
120     AC_SUBST(CPPUNIT_INCLUDES)
121     AC_SUBST(CPPUNIT_LIBS)
122     AC_SUBST(cppunit_ok)
123     AC_MSG_RESULT(yes)
124   fi
125 fi
126
127 AM_CONDITIONAL(CPPUNIT_IS_OK, [test x"$cppunit_ok" = xyes])
128
129 AC_LANG_RESTORE
130
131 ])dnl
132 dnl