Salome HOME
Copyright update 2020
[tools/configuration.git] / autotools / m4 / check_tbb.m4
1 dnl Copyright (C) 2007-2020  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 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 ! -d ${INTEL_LOCAL_LIB} ; then
80                 INTEL_LOCAL_LIB="${TBBHOME}/lib"
81             fi
82             if test -d ${INTEL_LOCAL_LIB} ; then
83                 LOCAL_LIBS="-L${INTEL_LOCAL_LIB} $LOCAL_LIBS"
84             fi
85         fi
86     fi
87
88 dnl check tbb header
89
90     CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
91
92     AC_CHECK_HEADER(tbb/tbb.h,tbb_ok=yes ,tbb_ok=no)
93 fi
94
95 if  test "x$tbb_ok" = "xyes"
96 then
97
98 dnl check TBB library
99
100   LIBS_old="$LIBS"
101   LIBS="$LIBS $LOCAL_LIBS"
102   AC_TRY_LINK([#include <tbb/tbb.h>],
103               [tbb::simple_partitioner()],
104               tbb_ok=yes,tbb_ok=no)
105
106   LIBS="$LIBS_old"
107  
108 fi
109
110 CPPFLAGS=$CPPFLAGS_old
111 AC_LANG_RESTORE
112
113 AC_MSG_RESULT(for TBB: $tbb_ok)
114
115 if  test "x$tbb_ok" = "xyes"
116 then
117   TBB_LIBS="$LOCAL_LIBS"
118   TBB_INCLUDES="$LOCAL_INCLUDES"
119   CPPFLAGS="-DWITH_TBB $CPPFLAGS"
120 fi
121
122 AM_CONDITIONAL(WITH_TBB, [test x"$tbb_ok" = xyes])
123
124 ])dnl