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