Salome HOME
PR: merge from branch BR_auto_V310 tag mergefrom_OCC_development_for_3_2_0a2_10mar06
[modules/kernel.git] / salome_adm / 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}/lib/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/lib)
31         fi
32      done
33   fi
34   if test "x$exits_ok" = "xno"; then
35      for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
36         if test -f $d/libcppunit.so ; then
37            AC_MSG_RESULT(libcppunit.so detected in $d)
38            CPPUNITHOME=$d
39            CPPUNITHOME=`echo ${CPPUNITHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
40            exits_ok=yes
41            break
42         fi
43      done
44   fi
45   if test "x$exits_ok" = "xyes"; then
46      if test -z "$CPPUNIT_INCLUDES"; then
47         CPPUNIT_INCLUDES=$CPPUNITHOME"/include"
48      fi
49   fi
50 else
51   if test -z "$CPPUNIT_INCLUDES"; then
52      CPPUNIT_INCLUDES="$CPPUNITHOME/include"
53   fi    
54 fi
55
56 if test "x$cppunit_ok" = xno -o ! -d "$CPPUNITHOME" ; then
57   AC_MSG_RESULT(no)
58   AC_MSG_WARN(cppunit not found)
59   cppunit_ok=no
60 else
61    AC_LANG_SAVE
62    AC_LANG_CPLUSPLUS
63    CPPFLAGS_old=$CPPFLAGS
64    CPPFLAGS="$CPPFLAGS -I$CPPUNIT_INCLUDES"
65    CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
66
67    AC_CHECK_HEADER(cppunit/extensions/HelperMacros.h,cppunit_ok=yes,cppunit_ok=no) 
68
69    CPPFLAGS=$CPPFLAGS_old
70
71    if test "x$cppunit_ok" = xno ; then
72      AC_MSG_RESULT(no)
73      AC_MSG_WARN(cppunit not found)
74    else
75      cppunit_ok=yes
76    fi
77
78   if  test "x$cppunit_ok" = "xno"
79   then
80     AC_MSG_RESULT(unable to found cppunit headers and library)
81     AC_MSG_RESULT(CPPUNITHOME environment variable may be wrong)
82   else
83     if test "x$CPPUNIT_INCLUDES" = "x/usr/include"
84     then
85       CPPUNIT_INCLUDES=""
86     else
87       CPPUNIT_INCLUDES="-I$CPPUNIT_INCLUDES"
88     fi
89     if test "x$CPPUNITHOME" = "x/usr"
90     then
91       CPPUNIT_LIBS=" -lcppunit"
92     else
93       CPPUNIT_LIBS="-L$CPPUNITHOME/lib -lcppunit"
94     fi
95
96     AC_SUBST(CPPUNIT_INCLUDES)
97     AC_SUBST(CPPUNIT_LIBS)
98     AC_SUBST(cppunit_ok)
99     AC_MSG_RESULT(yes)
100   fi
101 fi
102
103 AM_CONDITIONAL(CPPUNIT_IS_OK, [test x"$cppunit_ok" = xyes])
104
105 AC_LANG_RESTORE
106
107 ])dnl
108 dnl