summaryrefslogtreecommitdiffstats
path: root/build/linux/configure.ac
blob: f58ad0e47dddd037e3005d8871089928aab766ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
dnl -----------------------------------------------------------------------
dnl Copyright 2012 iMinds-Vision Lab, University of Antwerp
dnl 
dnl Contact: astra@ua.ac.be
dnl Website: http://astra.ua.ac.be
dnl 
dnl 
dnl This file is part of the
dnl All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
dnl 
dnl The ASTRA Toolbox is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
dnl 
dnl The ASTRA Toolbox 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 
dnl You should have received a copy of the GNU General Public License
dnl along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
dnl 
dnl -----------------------------------------------------------------------
dnl $Id$

AC_INIT(astra_toolbox, 1.3.0)
AC_CONFIG_SRCDIR([Makefile.in])
LT_INIT([disable-static])

SAVED_CPPFLAGS="$CPPFLAGS"
SAVED_CXXFLAGS="$CXXFLAGS"
SAVED_LDFLAGS="$LDFLAGS"

AC_CANONICAL_BUILD
AC_CANONICAL_HOST

AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET

AC_LANG([C++])

dnl Use iostream to check if the C++ compiler works
AC_CHECK_HEADER(iostream, , AC_MSG_ERROR([No working c++ compiler found]))

dnl TODO: Use ../../lib/include instead of .../tnt once all other
dnl       libraries have been moved out of SVN
TNT_CPPFLAGS="-I../../lib/include/tnt -DJAMA_NO_SUBDIR"
CPPFLAGS="$CPPFLAGS $TNT_CPPFLAGS"
AC_CHECK_HEADER(tnt.h, HAVETNT=yes, HAVETNT=no)
AC_CHECK_HEADER(jama_lu.h, HAVEJAMA=yes, HAVEJAMA=no)

if test x$HAVETNT = xno -o x$HAVEJAMA = xno; then
  AC_MSG_ERROR([tnt or jama not found])
fi
AC_SUBST(TNT_CPPFLAGS)



# boost-unit-test-framework

AC_MSG_CHECKING([for boost-unit-test-framework])

ASTRA_CHECK_BOOST_UNIT_TEST_FRAMEWORK(-lboost_unit_test_framework-mt, BOOSTUTF=yes_mt, BOOSTUTF=no)
if test x$BOOSTUTF = xno; then
  ASTRA_CHECK_BOOST_UNIT_TEST_FRAMEWORK(-lboost_unit_test_framework, BOOSTUTF=yes, BOOSTUTF=no)
  if test x$BOOSTTHREAD = xno; then
    AC_MSG_RESULT(no)
    AC_MSG_ERROR([No boost-unit-test-framework library found])
  else
    AC_MSG_RESULT([yes, libboost_unit_test_framework])
    LIBS_BOOSTUTF="-lboost_unit_test_framework"
  fi
else
  AC_MSG_RESULT([yes, libboost_unit_test_framework-mt])
  LIBS_BOOSTUTF="-lboost_unit_test_framework-mt"
fi
# TODO: do something with the result


# nvcc, cuda

AC_ARG_WITH(cuda, [[  --with-cuda=path        path of CUDA SDK (optional)]],,)

NVCC_PATH=$PATH
if test x"$with_cuda" != x; then
  NVCC_PATH="$with_cuda/bin:$NVCC_PATH"
fi
AC_PATH_PROG([NVCC], [nvcc], [no], [$NVCC_PATH])
# TODO: do something with the result

HAVECUDA=no
if test x"$NVCC" != xno; then
  HAVECUDA=yes
  BACKUP_CUDA_LDFLAGS="$LDFLAGS"
  if test x"$with_cuda" != x; then
    LDFLAGS_CUDA="-L$with_cuda/lib"
    CPPFLAGS_CUDA="-I$with_cuda/include"
    LDFLAGS="$LDFLAGS $LDFLAGS_CUDA"
  fi
  AC_CHECK_LIB(cudart,cudaMalloc, ,HAVECUDA=no)
  AC_CHECK_LIB(cufft,cufftPlan1d, ,HAVECUDA=no)

  if test x"$HAVECUDA" = xno; then
    # try lib64 instead of lib

    HAVECUDA=yes
    LDFLAGS="$BACKUP_CUDA_LDFLAGS"

    # prevent cached values from being used
    unset ac_cv_lib_cudart_cudaMalloc
    unset ac_cv_lib_cufft_cufftPlan1d

    LDFLAGS_CUDA="-L$with_cuda/lib64"
    LDFLAGS="$LDFLAGS $LDFLAGS_CUDA"
    AC_CHECK_LIB(cudart,cudaMalloc, ,HAVECUDA=no)
    AC_CHECK_LIB(cufft,cufftPlan1d, ,HAVECUDA=no)
  fi

  LDFLAGS="$BACKUP_CUDA_LDFLAGS"
  unset BACKUP_CUDA_LDFLAGS
  # TODO: check for cuda headers?

  AC_SUBST(NVCC)
fi

NVCCFLAGS=""
AC_MSG_CHECKING([if nvcc works])
if test x"$HAVECUDA" = xyes; then
  ASTRA_CHECK_NVCC(HAVECUDA,NVCCFLAGS)
fi
AC_MSG_RESULT($HAVECUDA)

if test x"$HAVECUDA" = xyes; then
  AC_MSG_CHECKING([for nvcc archs])
  ASTRA_FIND_NVCC_ARCHS([10 12 20 30 35],NVCCFLAGS,NVCCARCHS)
  AC_MSG_RESULT($NVCCARCHS)
fi


AC_SUBST(HAVECUDA)
AC_SUBST(LDFLAGS_CUDA)
AC_SUBST(CPPFLAGS_CUDA)
AC_SUBST(NVCCFLAGS)


# mex, matlab

AC_ARG_WITH(matlab, [[  --with-matlab=path      path of Matlab (optional)]],,)

MEX_PATH=$PATH
HAVEMATLAB=no
if test x"$with_matlab" != x; then
  MEX_PATH="$with_matlab/bin:$MEX_PATH"
  AC_PATH_PROG([MEX], [mex], [no], [$MEX_PATH])
  if test x"$MEX" != xno; then
    HAVEMATLAB=yes
    # TODO: check platform of C compiler is same as mex
    AC_SUBST(MEX)
    MATLAB_ROOT="$with_matlab"
    AC_SUBST(MATLAB_ROOT)

    ASTRA_CHECK_MEX_SUFFIX([mexa64 mexglx mexmaci64 mexmaci],[MEXSUFFIX])
    if test x$MEXSUFFIX = x; then
      AC_MSG_FAILURE([Unable to determine matlab mex suffix])
      HAVEMATLAB=no
    fi
    AC_SUBST(MEXSUFFIX)
  fi
fi

AC_SUBST(HAVEMATLAB)


# TODO:

# Detection of tools:
# libtool (how?)

# options:
# debugging/optimization/profiling flags


AC_SUBST(SAVED_CPPFLAGS)
AC_SUBST(SAVED_CXXFLAGS)
AC_SUBST(SAVED_LDFLAGS)


AC_CONFIG_FILES([Makefile])
AC_OUTPUT