Salome HOME
In openmpi need to link with libmpi_cxx and libmpi.so
[modules/kernel.git] / salome_adm / unix / config_files / check_libbatch.m4
1 dnl Copyright (C) 2007-2011  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.
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 # CHECK_LIBBATCH
21 # This macro can be used to find libBatch and set the associated variables in
22 # a project based on autoconf. You can copy this file in your own project and
23 # eventually modify it according to your own needs.
24 # ----------------------------------------------------------------------------
25
26 AC_DEFUN([CHECK_LIBBATCH],[
27
28 AC_MSG_NOTICE(Checking for libBatch library)
29
30 AC_SUBST(LIBBATCH_INCLUDES)
31 AC_SUBST(LIBBATCH_LIBS)
32
33 LIBBATCH_INCLUDES=""
34 LIBBATCH_LIBS=""
35
36 libbatch_ok=no
37
38 AC_ARG_WITH([libbatch],
39                         [AS_HELP_STRING([--with-libbatch=DIR],
40                                                         [root directory path of libBatch installation])],
41                         [LIBBATCH_DIR="$withval"],
42                         [LIBBATCH_DIR=""])
43
44 if test "x$LIBBATCH_DIR" = "x" ; then
45   # no --with-libbatch option used
46   if test "x$LIBBATCH_ROOT_DIR" != "x" ; then
47     # LIBBATCH_ROOT_DIR environment variable defined
48     LIBBATCH_DIR=$LIBBATCH_ROOT_DIR
49   fi
50 fi
51
52 LOCAL_INCLUDES=""
53 LOCAL_LIBS=""
54
55 if test "x$LIBBATCH_DIR" != "x" ; then
56   LOCAL_INCLUDES="-I$LIBBATCH_DIR/include"
57   if test "x$LIBBATCH_DIR" = "x/usr" ; then
58     LOCAL_LIBS="-lBatch"
59   else
60     LOCAL_LIBS="-L$LIBBATCH_DIR/lib -lBatch"
61   fi
62 else
63   LOCAL_INCLUDES="-I/usr/include"
64   LOCAL_LIBS="-lBatch"
65 fi
66
67 # libBatch headers
68
69 CPPFLAGS_old="$CPPFLAGS"
70 CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
71 AC_CHECK_HEADER(Batch/Batch_BatchManager.hxx,
72                                 libbatch_ok="yes",
73                                 libbatch_ok="no")
74 CPPFLAGS="$CPPFLAGS_old"
75
76
77 if  test "x$libbatch_ok" = "xyes" ; then
78   # libBatch library
79
80   LIBS_old=$LIBS
81   LIBS="$LIBS $LOCAL_LIBS"
82   # Can't use AC_SEARCH_LIBS or AC_CHECK_LIB here because
83   # they don't work with C++ namespaces
84   # AC_SEARCH_LIBS(Batch::BatchManagerCatalog::getInstance,Batch,
85   #                                libbatch_ok="yes",libbatch_ok="no")
86   AC_MSG_CHECKING(
87                         [for library containing Batch::BatchManagerCatalog::getInstance])
88   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
89                                     namespace Batch {
90                                       class BatchManagerCatalog {
91                                         public: static void getInstance();
92                                       };
93                                     }
94                                   ]],
95                                   [using namespace Batch;
96                                    BatchManagerCatalog::getInstance();])],
97                  [libbatch_ok="yes"],
98                  [libbatch_ok="no"])
99   AC_MSG_RESULT($libbatch_ok)
100   
101   LIBS=$LIBS_old
102 fi
103
104 if test "x$libbatch_ok" = "xyes" ; then
105   LIBBATCH_INCLUDES="$LOCAL_INCLUDES"
106   LIBBATCH_LIBS="$LOCAL_LIBS"
107 fi
108
109 AC_MSG_RESULT(for libBatch: $libbatch_ok)
110
111 ])