-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfigure.ac
347 lines (274 loc) · 7.66 KB
/
configure.ac
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
AC_INIT(threeB,1.2-dev)
AC_COPYRIGHT(Copyright Edward Rosten and Susan Cox (2011, 2012, 2013))
orig_CXXFLAGS="$CXXFLAGS"
AC_PROG_AWK
AC_PROG_CXX
AC_LANG(C++)
################################################################################
#
# Useful macros
#
dnl APPEND(var, value)
dnl This appends vale to a shell variable var
define(APPEND, [$1="$$1 $2"])
dnl CHECK_FOR_OPTION(option, code, [success], [fail])
dnl option corresponds to the first parameter for the corresponding
dnl AC_ARG_WITH. If the library is present, then have_option and CVD_HAVE_OPTION
dnl are set. If with_option is "", it will be set to yes.
dnl
dnl The test code shall do nothing on success, and set the shell variable a to 1
dnl on failure. For convenience, LIBS and CXXFLAGS are checkpointed
dnl automatically. On failure, they are restored automatically.
dnl
dnl On success, "option" is appended to options, and the code "success" is run
dnl On failure including --without) fail is run.
define(CHECK_FOR_OPTION,[
if test "$have_$1" != yes
then
if test "$with_$1" == ""
then
with_$1=yes
fi
save_LIBS="$LIBS"
save_CXXFLAGS="$CXXFLAGS"
a=
$2
if test x$a == x
then
AC_DEFINE(CVD_HAVE_[]m4_toupper($1), 1)
AC_SUBST(have_$1, yes)
APPEND(options, $1)
$3
else
LIBS="$save_LIBS"
CXXFLAGS="$save_CXXFLAGS"
fi
fi
if test "$have_$1" != yes
then
:
$4
fi
])
dnl TEST_AND_SET_CXXFLAG(flag, [program], [run])
dnl
dnl This attempts to compile a and run program with a certain compiler flag.
dnl If no program is given, then the minimal C++ program is compiled, and
dnl this tests just the validity of the compiler flag.
dnl
define([TEST_AND_SET_CXXFLAG],[
if test "$3" == ""
then
AC_MSG_CHECKING([if compiler flag $1 works])
else
AC_MSG_CHECKING([$3])
fi
save_CXXFLAGS="$CXXFLAGS"
APPEND(CXXFLAGS, [$1])
m4_if([$2],[],[pushdef(prog, [int main(){}])], [pushdef(prog, [$2])])
m4_if([$4],[run],
[AC_RUN_IFELSE([AC_LANG_SOURCE([prog])], [cvd_conf_test=1],[cvd_conf_test=0], [cvd_conf_test=0])],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([prog])], [cvd_conf_test=1],[cvd_conf_test=0])]
)
popdef([prog])
if test $cvd_conf_test = 1
then
AC_MSG_RESULT(yes)
ts_success=yes
else
AC_MSG_RESULT(no)
CXXFLAGS="$save_CXXFLAGS"
ts_success=no
fi
])
TEST_AND_SET_CXXFLAG(-Wall)
TEST_AND_SET_CXXFLAG(-Wextra)
TEST_AND_SET_CXXFLAG(-W)
TEST_AND_SET_CXXFLAG(-fPIC)
if ! echo $host | grep mingw
then
TEST_AND_SET_CXXFLAG(-fPIC)
if test $ts_success == no
then
AC_MSG_WARN(["I don't know how to compile position independent code. The Java plugin won't work"])
fi
fi
################################################################################
#
# Check for TooN
#
toon=yes
AC_CHECK_HEADERS(TooN/TooN.h, [], [toon=no])
comp=no
AC_MSG_CHECKING([TooN])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <TooN/TooN.h>
int main(){TooN::Vector<2> v;return 0;}
])], [comp=yes], [toon=no])
AC_MSG_RESULT($comp)
if test $toon = no
then
AC_MSG_ERROR([A working copy of TooN is required for this program.
Get TooN here: http://www.edwardrosten.com/cvd/toon.html
])
fi
################################################################################
#
# Check for TaG
#
#tag=yes
#AC_CHECK_HEADERS(tag/printf.h, [], [tag=no])
#AC_MSG_CHECKING([tag])
#AC_COMPILE_IFELSE([
# #include <tag/printf.h>
# int main(){Printf("Hello, world.\n");}
#], [comp=yes], [tag=no])
#
#AC_MSG_RESULT($comp)
#
#if test $tag = no
#then
# AC_MSG_ERROR([A working copy of tag is required for this program.
#Get tag here: http://www.edwardrosten.com/cvd/tag.html
#])
#fi
#
################################################################################
#
# Check for GVars
#
gvars=yes
AC_CHECK_HEADERS(gvars3/instances.h, [], [gvars=no])
AC_CHECK_LIB(GVars3_headless, main)
gvars=no
test "$ac_cv_lib_GVars3_headless_main" == yes && gvars=yes
if test $gvars == yes
then
gvars=no
AC_MSG_CHECKING([gvars])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <gvars3/instances.h>
int main(){GVars3::GUI.LoadFile("");}
])], [gvars=yes], [gvars=no])
AC_MSG_RESULT($gvars)
fi
if test $gvars = no
then
AC_MSG_ERROR([A working copy of GVars3 is required for this program.
Get GVars3 here: http://www.edwardrosten.com/cvd/gvars3.html
])
fi
AC_MSG_CHECKING([TooN support in GVars])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <gvars3/instances.h>
#include <TooN/TooN.h>
int main(){GVars3::GV3::get<TooN::Vector<> >("", "");}
])], [gvarstoon=yes], [gvarstoon=no])
AC_MSG_RESULT($gvarstoon)
if test $gvarstoon = no
then
AC_MSG_ERROR([GVars3 has not been compiled with TooN support.
Since TooN is installed, this means you need to recompile GVars3.
])
fi
################################################################################
#
# Check for libcvd
#
cvd=yes
AC_CHECK_HEADERS(cvd/image_io.h, [], [cvd=no])
AC_CHECK_LIB(cvd, main)
cvd=no
cvdlib=no
test "$ac_cv_lib_cvd_main" == yes && cvdlib=yes
if test $cvdlib == yes
then
AC_MSG_CHECKING(libCVD)
cvd=no
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <cvd/fast_corner.h>
#include <cvd/image_io.h>
int main(){
const char *s = "";
std::string str(s);
CVD::Image<CVD::byte> i = CVD::img_load(str); return 0;
}
])], [cvd=yes], [cvd=no])
AC_MSG_RESULT([$cvd])
fi
if test $cvdlib == yes && test $cvd == no
then
AC_MSG_CHECKING(If libcvd needs -msse2)
APPEND(CXXFLAGS,[ -msse2])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <cvd/fast_corner.h>
#include <cvd/image_io.h>
int main(){
const char *s = "";
std::string str(s);
CVD::Image<CVD::byte> i = CVD::img_load(str); return 0;
}
])], [cvd=yes], [cvd=no])
AC_MSG_RESULT($cvd)
fi
if test $cvd = no
then
AC_MSG_ERROR([A working copy of libCVD is required for this program.
Get libCVD here: http://www.edwardrosten.com/cvd/
])
fi
CHECK_FOR_OPTION(lapack, [
AC_MSG_CHECKING(if Accelerate framework is needed for LAPACK)
AC_MSG_RESULT()
APPEND(LIBS, -framework Accelerate)
AC_CHECK_FUNC(dgesvd_, [], [a=1])
])
CHECK_FOR_OPTION(gfortran, [
AC_CHECK_LIB(gfortran, printf, [], [a=1])
])
CHECK_FOR_OPTION(blas, [
AC_CHECK_LIB(blas, printf, [], [a=1])
])
CHECK_FOR_OPTION(lapack, [
AC_CHECK_LIB(lapack, dgesvd_, [], [a=1])
])
CHECK_FOR_OPTION(lapack, [
AC_CHECK_LIB(f2c, main, [], [a=1])
AC_CHECK_LIB(lapack, dsyev_, [], [a=1])
])
if test "$have_lapack" != yes
then
AC_MSG_ERROR([Lapack is missing.])
fi
AC_ARG_WITH(imagej, AC_HELP_STRING(--with-imagej=/path/to/imagej/ij.jar, [specify location of ImageJ in order to build plugin]))
if test "$with_imagej" != ""
then
AC_SUBST(CLASSPATH, [$with_imagej])
fi
java=/usr/lib/jvm/default-java/include/
AC_ARG_WITH(jni, AC_HELP_STRING(--with-jni=/path/to/jni, [specify location of JNI headers]))
dnl Test some likely looking places for the JNI header files...
if test "$with_jni" != ""
then
javas="$with_jni"
else
jvm="$(readlink -f `which java` | sed -e's!bin/java!include!')"
javas="$jvm /usr/lib/jvm/java-7-openjdk/include/ /usr/lib/jvm/java-6-openjdk/include/"
fi
for i in $javas
do
save_CPPFLAGS="$CPPFLAGS"
AC_MSG_CHECKING([for jni.h in $i])
AC_MSG_RESULT([])
CPPFLAGS="$CPPFLAGS -I$i"
AC_CHECK_HEADERS([jni.h], [a=0], [a=1])
unset ac_cv_header_jni_h
CPPFLAGS="$save_CPPFLAGS"
if test x$a == x0
then
java="$i"
break
fi
done
AC_SUBST(JAVAPATH, [$java])
AC_OUTPUT(Makefile)