acx_mkl.m4 6.48 KB
Newer Older
1
2
3
4
5
6
7
8
9
dnl
dnl				acx_mkl.m4
dnl
dnl Set up options for using the INTEL MKL library.
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl	This file part of:	AstrOmatic software
dnl
10
dnl	Copyright:		(C) 2003-2013 Emmanuel Bertin -- IAP/CNRS/UPMC
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
dnl
dnl	License:		GNU General Public License
dnl
dnl	AstrOmatic software is free software: you can redistribute it and/or
dnl	modify it under the terms of the GNU General Public License as
dnl	published by the Free Software Foundation, either version 3 of the
dnl	License, or (at your option) any later version.
dnl	AstrOmatic software is distributed in the hope that it will be useful,
dnl	but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl	GNU General Public License for more details.
dnl	You should have received a copy of the GNU General Public License
dnl	along with AstrOmatic software.
dnl	If not, see <http://www.gnu.org/licenses/>.
dnl
26
dnl	Last modified:		17/04/2013
27
28
29
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
30
dnl @synopsis ACX_MKL([MKL_DIR, ILP64_FLAG, STATIC_FLAG, CONV_LIBS])
31
dnl
32
33
34
dnl This macro sets the MKL_CFLAGS, MKL_LDFLAGS and MKL_LIBS variables to
dnl for compiling and linking with INTEL's MKL. A coma-separated list of
dnl convenience libraries may be included in the linked group for static linking.
35
36
37
38
dnl You may wish to use these variables in your default CFLAGS:
dnl
dnl        CFLAGS="$CFLAGS $MKL_CFLAGS"
dnl
39
40
41
42
43
44
45
46
dnl You may wish to use these variables in your default LDFLAGS:
dnl
dnl        LDFLAGS="$LDFLAGS $MKL_LDLAGS"
dnl
dnl You may wish to use these variables in your default LIBS:
dnl
dnl        LIBS="$LIBS $MKL_LIBS"
dnl
47
48
49
50

AC_DEFUN([ACX_MKL], [
AC_REQUIRE([AC_CANONICAL_HOST])

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
dnl ------------------------
dnl Set MKL's root directory
dnl ------------------------

if test x$1 = x; then
  mklroot=${MKLROOT}
else
  mklroot=$1
fi

dnl -----------------------------
dnl Include convenience libraries
dnl -----------------------------

if test x$4 = x; then
  startgroup="-Wl,--start-group"
else
  startgroup="-Wl,--start-group,$4"
fi

71
72
73
74
dnl ----------------------
dnl Set architecture flags
dnl ----------------------

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
dnl check if INTEL compiler is present
icc -V 2>&1 | grep -i "Intel" > /dev/null 2>&1 && flagicc=yes
dnl check if INTEL compiler uses x86_64 architecture
icc -V 2>&1 | grep -i "Intel(R) 64" > /dev/null 2>&1 && flag64=yes
dnl check if the platform is OSX
icc -dumpmachine 2>&1 | grep -i "darwin" > /dev/null 2>&1 && flagosx=yes

dnl ----------------------
dnl Exit if INTEL compiler is not found
dnl ----------------------
if test x$flagicc = x; then
  AC_SUBST(MKL_CFLAGS, "")
  AC_SUBST(MKL_LDFLAGS, "")
  AC_SUBST(MKL_LIBS, "")
  MKL_WARN="INTEL compiler not detected"
  AC_SUBST(MKL_WARN)
  exit
fi

if test x$flagosx = xyes; then
dnl MacOSX
  if test x$flag64 = xyes; then
dnl INTEL compiler uses Intel64 architecture
    if test x$2 = xyes; then
99
dnl 64 bit pointers
100
101
102
103
104
105
106
107
108
109
110
      AC_SUBST(MKL_CFLAGS, "-openmp -DMKL_ILP64 -I$mklroot/include")
      if test x$3 = xyes; then
dnl Static linking
        AC_SUBST(MKL_LIBS, ["$mklroot/lib/libmkl_intel_ilp64.a \
		$mklroot/lib/libmkl_intel_thread.a \
		$mklroot/lib/libmkl_core.a -lpthread -lm"])
      else
dnl Dynamic linking
        AC_SUBST(MKL_LIBS, "-L$mklroot/lib  -lmkl_intel_ilp64 \
	-lmkl_intel_thread -lmkl_core -lpthread -lm")
      fi
111
    else
112
113
114
115
116
117
118
119
120
121
122
123
dnl 32 bit pointers
      AC_SUBST(MKL_CFLAGS, "-openmp -I$mklroot/include")
      if test x$3 = xyes; then
dnl Static linking
        AC_SUBST(MKL_LIBS, ["$mklroot/lib/libmkl_intel_lp64.a \
		$mklroot/lib/libmkl_intel_thread.a \
		$mklroot/lib/libmkl_core.a -lpthread -lm"])
      else
dnl Dynamic linking
        AC_SUBST(MKL_LIBS, "-L$mklroot/lib -lmkl_intel_lp64 \
		-lmkl_intel_thread -lmkl_core -lpthread -lm")
      fi
124
125
    fi
  else
126
127
dnl INTEL compiler uses IA32 architecture
    AC_SUBST(MKL_CFLAGS, "-openmp -I$mklroot/include")
128
    if test x$3 = xyes; then
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
dnl Static linking
    AC_SUBST(MKL_LIBS, ["$mklroot/lib/libmkl_intel.a \
	$mklroot/lib/libmkl_intel_thread.a \
	$mklroot/lib/libmkl_core.a -lpthread -lm"])
    else
dnl Dynamic linking
      AC_SUBST(MKL_LIBS, "-L$mklroot/lib -lmkl_intel -lmkl_intel_thread \
	-lmkl_core -lpthread -lm")
    fi
  fi
else
dnl Linux
  if test x$flag64 = xyes; then
dnl INTEL compiler uses Intel64 architecture
    if test x$2 = xyes; then
dnl 64 bit pointers
      AC_SUBST(MKL_CFLAGS, "-openmp -DMKL_ILP64 -I$mklroot/include")
      if test x$3 = xyes; then
dnl Static linking
148
      AC_SUBST(MKL_LIBS,
149
	["$startgroup,$mklroot/lib/intel64/libmkl_intel_ilp64.a,\
150
$mklroot/lib/intel64/libmkl_intel_thread.a,\
151
152
153
154
155
156
$mklroot/lib/intel64/libmkl_core.a,-end-group -lpthread -lm"])
      else
dnl Dynamic linking
        AC_SUBST(MKL_LIBS, "-L$mklroot/lib/intel64  -lmkl_intel_ilp64 \
		-lmkl_intel_thread -lmkl_core -lpthread -lm")
      fi
157
    else
158
159
160
161
162
163
164
165
166
dnl 32 bit pointers
      AC_SUBST(MKL_CFLAGS, "-openmp -I$mklroot/include")
      if test x$3 = xyes; then
dnl Static linking
        AC_SUBST(MKL_LIBS,
		["$startgroup,$mklroot/lib/intel64/libmkl_intel_lp64.a,\
$mklroot/lib/intel64/libmkl_intel_thread.a,\
$mklroot/lib/intel64/libmkl_core.a,--end-group -lpthread -lm"])
      else
167
dnl Dynamic linking
168
169
170
        AC_SUBST(MKL_LIBS, "-L$mklroot/lib/intel64 -lmkl_intel_lp64 \
	-lmkl_intel_thread -lmkl_core -lpthread -lm")
      fi
171
    fi
172
  else
173
dnl INTEL compiler uses IA32 architecture
174
175
176
177
    AC_SUBST(MKL_CFLAGS, "-openmp -I$mklroot/include")
    if test x$3 = xyes; then
dnl Static linking
      AC_SUBST(MKL_LIBS, ["$startgroup,$mklroot/lib/ia32/libmkl_intel.a,\
178
$mklroot/lib/ia32/libmkl_intel_thread.a,\
179
180
$mklroot/lib/ia32/libmkl_core.a,--end-group -lpthread -lm"])
    else
181
dnl Dynamic linking
182
183
184
      AC_SUBST(MKL_LIBS, "-L$mklroot/lib/ia32 -lmkl_intel -lmkl_intel_thread \
	-lmkl_core -lpthread -lm")
    fi
185
  fi
186
187
fi

188
AC_SUBST(MKL_LDFLAGS, "")
189

190
191
192
193
dnl --------------------
dnl Set internal flags
dnl --------------------

194
195
196
197
AC_DEFINE(HAVE_MKL,1, [Define if you have the MKL libraries.])
AC_DEFINE(HAVE_FFTW,1, [Define if you have the FFTW libraries.])
AC_DEFINE(HAVE_LAPACK,1, [Define if you have the LAPACK libraries.])
AC_DEFINE(HAVE_LAPACKE,1, [Define if you have the LAPACKe libraries.])
198
199
200
201
202

dnl --------------------
dnl Set include files
dnl --------------------

203
204
205
206
AC_DEFINE_UNQUOTED(MKL_H, "mkl.h", [MKL header filename.])
AC_DEFINE_UNQUOTED(FFTW_H, "fftw/fftw3_mkl.h", [FFTW header filename.])
AC_DEFINE_UNQUOTED(LAPACK_H, "mkl_lapack.h", [LAPACK header filename.])
AC_DEFINE_UNQUOTED(LAPACKE_H, "mkl_lapacke.h", [LAPACKe header filename.])
207
208

])dnl ACX_MKL