Salome HOME
Add missing vtk libraries
[modules/kernel.git] / salome_adm / unix / config_files / check_tbb.m4
1 dnl Copyright (C) 2007-2012  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 email : webmaster.salome@opencascade.com
21 dnl
22
23 AC_DEFUN([CHECK_TBB],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CPP])dnl
26
27 AC_CHECKING(for TBB)
28
29 AC_ARG_WITH(TBB,
30     [  --with-TBB=DIR                 root directory path to TBB installation ],
31     [TBBHOME="$withval"
32       AC_MSG_RESULT("select $withval as path to TBB")
33     ])
34
35 AC_SUBST(TBB_INCLUDES)
36 AC_SUBST(TBB_LIBS)
37
38 TBB_INCLUDES=""
39 TBB_LIBS=""
40
41 tbb_ok=no
42
43 LOCAL_INCLUDES=""
44 LOCAL_LIBS="-ltbb -ltbbmalloc"
45
46 AC_LANG_SAVE
47 AC_LANG_CPLUSPLUS
48
49 CPPFLAGS_old=$CPPFLAGS
50
51 if test "x$TBBHOME" != "xno"; then
52     if test "x$TBBHOME" == "xyes"; then
53         TBBHOME=""
54     fi
55     if test -z $TBBHOME
56     then
57         AC_MSG_WARN(undefined TBBHOME variable which specify TBB library installation directory)
58         AC_PATH_PROG(BINDIR, tbbvars.sh)
59         if test "x$BINDIR" != "x" ; then
60             dnl e.g. BINDIR = ./tbb/bin/intel64/cc4.1.0_libc2.4_kernel2.6.16.21/tbbvars.sh
61             TBBHOME=$BINDIR
62             TBBHOME=`echo ${TBBHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
63             TBBHOME=`echo ${TBBHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
64             TBBHOME=`echo ${TBBHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
65             TBBHOME=`echo ${TBBHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
66         fi
67     fi
68     if test ! -z $TBBHOME
69     then
70         TBBKERNEL='cc4.1.0_libc2.4_kernel2.6.16.21'
71         LOCAL_INCLUDES="-I$TBBHOME/include"
72         if test "x$TBBHOME" != "x/usr"; then
73             INTEL_LOCAL_LIB=""
74             if test `uname -m` = "x86_64" ; then
75                 INTEL_LOCAL_LIB="$TBBHOME/lib/intel64/$TBBKERNEL"
76             else
77                 INTEL_LOCAL_LIB="$TBBHOME/lib/ia32/$TBBKERNEL"
78             fi
79             if test -z ${INTEL_LOCAL_LIB}; then
80                 LOCAL_LIBS="-L${INTEL_LOCAL_LIB} $LOCAL_LIBS"
81             else
82                 LOCAL_LIBS="-L${TBBHOME}/lib $LOCAL_LIBS"
83             fi
84         fi
85     fi
86
87 dnl check tbb header
88
89     CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
90
91     AC_CHECK_HEADER(tbb/tbb.h,tbb_ok=yes ,tbb_ok=no)
92 fi
93
94 if  test "x$tbb_ok" = "xyes"
95 then
96
97 dnl check TBB library
98
99   LIBS_old="$LIBS"
100   LIBS="$LIBS $LOCAL_LIBS"
101   AC_TRY_LINK([#include <tbb/tbb.h>],
102               [tbb::simple_partitioner()],
103               tbb_ok=yes,tbb_ok=no)
104
105   LIBS="$LIBS_old"
106  
107 fi
108
109 CPPFLAGS=$CPPFLAGS_old
110 AC_LANG_RESTORE
111
112 AC_MSG_RESULT(for TBB: $tbb_ok)
113
114 if  test "x$tbb_ok" = "xyes"
115 then
116   TBB_LIBS="$LOCAL_LIBS"
117   TBB_INCLUDES="$LOCAL_INCLUDES"
118   CPPFLAGS="-DWITH_TBB $CPPFLAGS"
119 fi
120
121 AM_CONDITIONAL(WITH_TBB, [test x"$tbb_ok" = xyes])
122
123 ])dnl