Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / adm_local_without_kernel / unix / config_files / check_cppunit.m4
1
2 AC_DEFUN([CHECK_CPPUNIT],[
3
4 AC_CHECKING(for cppunit)
5
6 cppunit_ok=yes
7
8 dnl were is cppunit ?
9
10 AC_ARG_WITH(cppunit,
11     [AC_HELP_STRING([--with-cppunit=DIR],[directory path to CPPUNIT installation])],
12     [CPPUNITHOME="$withval"
13       AC_MSG_RESULT("select $withval as path to CPPUNIT")
14     ])
15
16 AC_ARG_WITH(cppunit_inc,
17     [AC_HELP_STRING([--with-cppunit_inc=DIR],[directory path to CPPUNIT includes])],
18     [CPPUNIT_INCLUDES="$withval"
19       AC_MSG_RESULT("select $withval as path to CPPUNIT includes")
20     ])
21
22 if test -z "$CPPUNITHOME"; then
23   AC_MSG_RESULT(CPPUNITHOME not defined)
24   exits_ok=no   
25   if test "x$exits_ok" = "xno"; then
26      for d in /usr/local /usr ; do
27         AC_CHECK_FILE(${d}/lib64/libcppunit.so,exits_ok=yes,exits_ok=no)
28         if test "x$exits_ok" = "xyes"; then
29            CPPUNITHOME=$d
30            AC_MSG_RESULT(libcppunit.so detected in $d/lib64)
31            break
32         fi
33         AC_CHECK_FILE(${d}/lib/libcppunit.so,exits_ok=yes,exits_ok=no)
34         if test "x$exits_ok" = "xyes"; then
35            CPPUNITHOME=$d
36            AC_MSG_RESULT(libcppunit.so detected in $d/lib)
37            break
38         fi
39      done
40   fi
41   if test "x$exits_ok" = "xno"; then
42      for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
43         if test -f $d/libcppunit.so ; then
44            AC_MSG_RESULT(libcppunit.so detected in $d)
45            CPPUNITHOME=$d
46            CPPUNITHOME=`echo ${CPPUNITHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
47            exits_ok=yes
48            break
49         fi
50      done
51   fi
52   if test "x$exits_ok" = "xyes"; then
53      if test -z "$CPPUNIT_INCLUDES"; then
54         CPPUNIT_INCLUDES=$CPPUNITHOME"/include"
55      fi
56   fi
57 else
58   if test -z "$CPPUNIT_INCLUDES"; then
59      CPPUNIT_INCLUDES="$CPPUNITHOME/include"
60   fi    
61 fi
62
63 if test "x$cppunit_ok" = xno -o ! -d "$CPPUNITHOME" ; then
64   AC_MSG_RESULT(no)
65   AC_MSG_WARN(cppunit not found)
66   cppunit_ok=no
67 else
68    AC_LANG_SAVE
69    AC_LANG_CPLUSPLUS
70    CPPFLAGS_old=$CPPFLAGS
71    CPPFLAGS="$CPPFLAGS -I$CPPUNIT_INCLUDES"
72    
73    AC_CHECK_HEADER(cppunit/extensions/HelperMacros.h,cppunit_ok=yes,cppunit_ok=no) 
74
75    CPPFLAGS=$CPPFLAGS_old
76
77    if test "x$cppunit_ok" = xno ; then
78      AC_MSG_RESULT(no)
79      AC_MSG_WARN(cppunit not found)
80    else
81      cppunit_ok=yes
82    fi
83
84   if  test "x$cppunit_ok" = "xno"
85   then
86     AC_MSG_RESULT(unable to found cppunit headers and library)
87     AC_MSG_RESULT(CPPUNITHOME environment variable may be wrong)
88   else
89     if test "x$CPPUNIT_INCLUDES" = "x/usr/include"
90     then
91       CPPUNIT_INCLUDES=""
92     else
93       CPPUNIT_INCLUDES="-I$CPPUNIT_INCLUDES"
94     fi
95     if test "x$CPPUNITHOME" = "x/usr"
96     then
97       CPPUNIT_LIBS=" -lcppunit"
98     else
99       CPPUNIT_LIBS="-L$CPPUNITHOME/lib -lcppunit"
100     fi
101
102     AC_SUBST(CPPUNIT_INCLUDES)
103     AC_SUBST(CPPUNIT_LIBS)
104     AC_SUBST(cppunit_ok)
105     AC_MSG_RESULT(yes)
106   fi
107 fi
108
109 AM_CONDITIONAL(CPPUNIT_IS_OK, [test x"$cppunit_ok" = xyes])
110
111 AC_LANG_RESTORE
112
113 ])dnl
114 dnl