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