aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: 30e803f764264be16f623ab0213db7a08c819479 (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
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
dnl Process this file with autoconf to produce a configure script.

AC_INIT([crystfel],[0.6.3],[taw@physics.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([subdir-objects])

AC_PROG_CC
gl_EARLY
AM_PROG_CC_C_O
AC_PROG_CC_C99
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL
AM_SILENT_RULES([yes])

AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdlib.h unistd.h])
AC_C_CONST
AC_FUNC_MALLOC

gl_INIT


dnl Find HDF5
AC_ARG_WITH(hdf5,
[AS_HELP_STRING([--with-hdf5],
                [specify location of HDF5 (instead of trying pkg-config)])],
[
    AC_MSG_NOTICE([Using your specified location for HDF5])
    HDF5_CFLAGS="-I$withval/include"
    HDF5_LIBS="-L$withval/lib -lhdf5"
],
[
    AC_MSG_NOTICE([checking for HDF5 using pkg-config])
    PKG_CHECK_MODULES([HDF5], [hdf5],
    [
        AC_MSG_NOTICE([Found HDF5 using pkg-config])
    ],
    [
        AC_MSG_NOTICE([Did not find HDF5 using pkg-config.  Assuming default location.])
        HDF5_CFLAGS=""
        HDF5_LIBS="-lhdf5"
    ])
])

dnl Check that HDF5 *actually* works...
LIBS_SAVE=$LIBS
LIBS=$HDF5_LIBS
AC_CHECK_LIB([hdf5], [H5Fcreate], [],
[
   AC_MSG_ERROR([HDF5 not found!])
])
LIBS=$LIBS_SAVE


AC_ARG_WITH(gsl,
[AS_HELP_STRING([--with-gsl],
                [specify location of GSL (instead of using pkg-config)])],
[GSL_CFLAGS="-I$withval/include"
 GSL_LIBS="-L$withval/lib -lgsl -lgslcblas -lm"],
[PKG_CHECK_MODULES([GSL], [gsl])])

AC_ARG_ENABLE(cbf, AS_HELP_STRING([--disable-cbf], [Disable CBF file support]))
AC_ARG_WITH(cbflib,
            [Specify location of CBFlib headers and libraries])
AC_MSG_CHECKING([whether to use CBFlib])
AS_IF([test "x$enable_cbf" != "xno"],
[
   AC_MSG_RESULT([yes])
   AS_IF([test "x$with_cbflib" != "x"],
   [
      dnl NB not ${with_cbflib}/include/cbflib, because cbflib installs
      dnl its own HDF5 headers which we do not want in the include path
      CBF_CFLAGS="-I${with_cbflib}/include"
      dnl Fortunately no libhdf5.so in this folder
      CBF_LIBS="-lcbf -L${with_cbflib}/lib"
   ], [
      AC_CHECK_LIB([cbf], [cbf_make_handle], [
         CBF_LIBS="-lcbf"
      ])
   ])
   SAVED_CPPFLAGS=$CPPFLAGS
   CPPFLAGS="$CPPFLAGS $CBF_CFLAGS"
   AC_CHECK_HEADERS([cbflib/cbf.h cbf/cbf.h],
   [
      have_cbflib=true
   ])
   CPPFLAGS=$SAVE_CPPFLAGS
], [
   AC_MSG_RESULT([no])
])
AS_IF([test x$have_cbflib = xtrue],
[
   AC_DEFINE([HAVE_CBFLIB], [1], [Define to 1 if CBFlib is available])
   AC_MSG_NOTICE([CBFlib found.])
])

AC_ARG_WITH(opencl, AS_HELP_STRING([--with-opencl], [Use OpenCL]))
AC_ARG_WITH(opencl_dir, AS_HELP_STRING([--with-opencl-dir],
            [Specify location of OpenCL headers and libraries]))
AC_MSG_CHECKING([whether to use OpenCL])
AS_IF([test "x$with_opencl_dir" != "x"], [with_opencl=yes])
AS_IF([test "x$with_opencl" == "xyes"],
[
   AC_MSG_RESULT([yes])
   AS_IF([test "x$with_opencl_dir" != "x"],
   [
      dnl Path manually given
      AC_MSG_CHECKING([cl.h])
      AS_IF([test -f ${with_opencl_dir}/include/CL/cl.h],
      [
         AC_MSG_RESULT([${with_opencl_dir}/include/CL/cl.h])
         OPENCL_CFLAGS="-I${with_opencl_dir}/include"
         OPENCL_LIBS="-lOpenCL -L${with_opencl_dir}/lib64 -L${with_opencl_dir}/lib"
         cl_cl_h=true
         have_opencl=true
      ], [
         AS_IF([test -f ${with_opencl_dir}/include/cl.h],
         [
            AC_MSG_RESULT([${with_opencl_dir}/include/cl.h])
            OPENCL_CFLAGS="-I${with_opencl_dir}/include/cl.h/include"
            OPENCL_LIBS="-lOpenCL -L${with_opencl_dir}/lib64 -L${with_opencl_dir}/lib"
            cl_cl_h=false
            have_opencl=true
         ], [
            AC_MSG_RESULT([not found.])
            AC_MSG_ERROR([Could not find cl.h])
         ])
      ])

   ], [

      dnl Attempt to automatically find the headers
      AC_MSG_CHECKING([cl.h])
      AS_IF([test -f /System/Library/Frameworks/OpenCL.framework/Headers/cl.h],
      [
         AC_MSG_RESULT([/System/Library/Frameworks/OpenCL.framework/Headers/cl.h])
         OPENCL_CFLAGS="-I/System/Library/Frameworks/OpenCL.framework/Headers"
         OPENCL_LIBS="-framework OpenCL"
      ], [
         AS_IF([test -f /opt/cuda/cuda/include/CL/cl.h],
         [
            AC_MSG_RESULT([/opt/cuda/cuda/include/CL/cl.h])
            OPENCL_CFLAGS="-I/opt/cuda/cuda/include"
            OPENCL_LIBS="-lOpenCL"
            cl_cl_h=true
         ], [
            AS_IF([test -f /opt/cuda/include/CL/cl.h],
            [
               AC_MSG_RESULT([/opt/cuda/include/CL/cl.h])
               OPENCL_CFLAGS="-I/opt/cuda/include"
               OPENCL_LIBS="-lOpenCL"
               cl_cl_h=true
            ], [
               AC_MSG_RESULT([not found, assuming /usr/include/CL/cl.h])
               OPENCL_CFLAGS=""
               OPENCL_LIBS="-lOpenCL"
               cl_cl_h=true
             ])
         ])
      ])
      have_opencl=true
   ])
], [
   AC_MSG_RESULT([no])
])
AS_IF([test x$cl_cl_h = xtrue],
[
   AC_DEFINE([HAVE_CL_CL_H], [1], [Define to 1 if CL/cl.h should be used])
])
AS_IF([test x$have_opencl = xtrue],
[
   AC_DEFINE([HAVE_OPENCL], [1], [Define to 1 if OpenCL is available])
])

AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [Disable GTK+/GLib]))
have_gtk=false
AC_MSG_CHECKING([whether to use GTK])
AS_IF([test "x$enable_gtk" != "xno"],
[
   AC_MSG_RESULT([yes])
   AM_PATH_GTK_2_0(2.0.0,
   [
      have_gtk=true
      AC_DEFINE([HAVE_GTK], [1], [Define to 1 if GTK and GDK are available])
   ],
   [
      AC_MSG_WARN([GTK not found.  hdfsee will not be built.])
   ])
],
[
   AC_MSG_RESULT([no])
])


AC_MSG_CHECKING([whether to use PNG])
AC_ARG_ENABLE([png],
    AS_HELP_STRING([--disable-png], [Disable the use of libPNG]))
AS_IF([test "x$enable_png" != "xno"],
[
   AC_MSG_RESULT([yes])
   PKG_CHECK_MODULES([libPNG], [libpng >= 1.2.0],
   [
      AC_DEFINE([HAVE_LIBPNG], [1], [Define to 1 if libPNG is available])
      have_libpng=true
   ], [
      have_libpng=false
   ])
],[
   AC_MSG_RESULT([no])
])


AC_MSG_CHECKING([whether to use TIFF])
AC_ARG_ENABLE([tiff],
    AS_HELP_STRING([--disable-tiff], [Disable the use of libTIFF]))
AS_IF([test "x$enable_tiff" != "xno"],
[
   AC_MSG_RESULT([yes])
   AC_ARG_WITH(libtiff,
   [AS_HELP_STRING([--with-libtiff], [specify location of libTIFF library])],
   [
      LIBTIFF_CFLAGS="-I$withval/include"
      LIBTIFF_LIBS="-L$withval/lib -ltiff"
      have_libtiff=true
   ], [
      AC_CHECK_LIB([tiff], [TIFFOpen], [
         have_libtiff=true
         LIBTIFF_LIBS="-ltiff"
      ])
   ])
], [
   AC_MSG_RESULT([no])
])
AS_IF([test x$have_libtiff = xtrue],
[
   AC_DEFINE([HAVE_TIFF], [1], [Define to 1 if libTIFF is available])
])


AC_MSG_CHECKING([whether to use Cairo])
AC_ARG_ENABLE([cairo],
              AS_HELP_STRING([--disable-cairo], [Disable the use of Cairo]))
AS_IF([test "x$enable_cairo" != "xno"],
[
   AC_MSG_RESULT([yes])
   PKG_CHECK_MODULES([Cairo], [cairo >= 1.2.0],
   [
      have_cairo=true
      AC_DEFINE([HAVE_CAIRO], [1], [Define to 1 if Cairo is available])
   ], [
      have_cairo=false
   ])
], [
   AC_MSG_RESULT([no])
])


AC_MSG_CHECKING([whether to use Pango])
AC_ARG_ENABLE([pango],
              AS_HELP_STRING([--disable-pango], [Disable the use of Pango]))
AS_IF([test "x$enable_pango" != "xno"],
[
   AC_MSG_RESULT([yes])
   PKG_CHECK_MODULES([Pango], [pango >= 1.0.0],
   [
      have_pango=true
      AC_DEFINE([HAVE_PANGO], [1], [Define to 1 if Pango is available])
   ], [
      have_pango=false
   ])
   PKG_CHECK_MODULES([PangoCairo], [pangocairo],
   [
      have_pangocairo=true
      AC_DEFINE([HAVE_PANGOCAIRO], [1],
                [Define to 1 if PangoCairo is available])
   ], [
      have_pangocairo=false
   ])
], [
   AC_MSG_RESULT([no])
])


have_gdk_pixbuf=false
AC_MSG_CHECKING([whether to use GDK-pixbuf])
AC_ARG_ENABLE([gdk-pixbuf], AS_HELP_STRING([--disable-gdk-pixbuf],
                                           [Disable the use of gdk-pixbuf]))
AS_IF([test "x$enable_gdk_pixbuf" != "xno"],
[
   AC_MSG_RESULT([yes])

   PKG_CHECK_MODULES([GDK_pixbuf_2], [gdk-pixbuf-2.0],
   [
      have_gdk_pixbuf=true
   ], [
      PKG_CHECK_MODULES([GDK_pixbuf], [gdk-pixbuf], [],
      [
         have_gdk_pixbuf=true
      ])
   ])
], [
   AC_MSG_RESULT([no])
])

AS_IF([test "$have_gdk_pixbuf" != "false"],
[
  AC_DEFINE([HAVE_GDK_PIXBUF], [1], [Define to 1 if gdk-pixbuf is available])
])


AC_CHECK_LIB([pthread], [sched_setaffinity], [
   AC_DEFINE([HAVE_CPU_AFFINITY], [1],
             [Define to 1 if sched_setaffinity is available.])
])


AC_CHECK_LIB([rt], [clock_gettime],
[
   AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
             [Define to 1 if clock_gettime is available.])
   TIMER_LIBS="-lrt"
], [
   AC_MSG_WARN([Falling back on gettimeofday().])
   AC_MSG_WARN([Time intervals may not be correct in certain circumstances.])
])

AC_ARG_WITH(fftw,
[AS_HELP_STRING([--with-ffftw],
                [specify location of FFTW (instead of using pkg-config)])],
[FFTW_CFLAGS="-I$withflag/include"
 FFTW_LIBS="-L$withval/lib -L$withval/lib64 -lfftw3"
 have_fftw=true],
[PKG_CHECK_MODULES([FFTW], [fftw3],
[
   have_fftw=true
], [
   AC_MSG_WARN([asdf indexing wil not be available.])
   have_fftw=false
])])
AS_IF([test x$have_fftw = xtrue],
[
   AC_DEFINE([HAVE_FFTW], [1], [Define to 1 if FFTW is available])
])

AX_WITH_CURSES

dnl Conditionals...
AM_CONDITIONAL([HAVE_OPENCL], test x$have_opencl = xtrue)

AM_CONDITIONAL([BUILD_HDFSEE], test x$have_gdk_pixbuf = xtrue \
                                -a "x$have_gtk" = "xtrue" \
                                -a "x$have_cairo" = "xtrue")

AM_CONDITIONAL([BUILD_EXPLORER], test "x$have_gtk" = "xtrue" \
                                  -a "x$have_cairo" = "xtrue")

AM_CONDITIONAL([HAVE_CAIRO], test x$have_cairo = xtrue)

AM_CONDITIONAL([HAVE_PANGOCAIRO], test x$have_pangocairo = xtrue)

AM_CONDITIONAL([HAVE_PANGO], test x$have_pango = xtrue)

AM_CONDITIONAL([HAVE_FFTW], test x$have_fftw = xtrue)

gl_IGNORE_UNUSED_LIBRARIES


MAIN_CFLAGS="$CFLAGS $HDF5_CFLAGS $GSL_CFLAGS $OPENCL_CFLAGS -pthread"
MAIN_CFLAGS="$MAIN_CFLAGS $GTK_CFLAGS $LIBTIFF_CFLAGS -D_GNU_SOURCE "
MAIN_CFLAGS="$MAIN_CFLAGS $libPNG_CFLAGS $Cairo_CFLAGS $GDK_pixbuf_CFLAGS"
MAIN_CFLAGS="$MAIN_CFLAGS $GDK_pixbuf_2_CFLAGS $FFTW_CFLAGS $Pango_CFLAGS"
MAIN_CFLAGS="$MAIN_CFLAGS $PangoCairo_CFLAGS"
AC_SUBST([MAIN_CFLAGS])

LIBCRYSTFEL_CFLAGS="$CFLAGS $HDF5_CFLAGS $GSL_CFLAGS $FFTW_CFLAGS $CBF_CFLAGS"
AC_SUBST([LIBCRYSTFEL_CFLAGS])

MAIN_LIBS="$LIBS $HDF5_LIBS -lm -lz $GSL_LIBS $GTK_LIBS $OPENCL_LIBS -pthread"
MAIN_LIBS="$MAIN_LIBS $LIBTIFF_LIBS $libPNG_LIBS $Cairo_LIBS $GDK_pixbuf_LIBS"
MAIN_LIBS="$MAIN_LIBS $GDK_pixbuf_2_LIBS $TIMER_LIBS $FFTW_LIBS"
MAIN_LIBS="$MAIN_LIBS $Pango_LIBS $PangoCairo_LIBS $LDFLAGS"
AC_SUBST([MAIN_LIBS])

LIBCRYSTFEL_LIBS="$LIBS $HDF5_LIBS $GSL_LIBS $FFTW_LIBS $CURSES_LIB $LDFLAGS"
LIBCRYSTFEL_LIBS="$LIBCRYSTFEL_LIBS -pthread $CBF_LIBS"
AC_SUBST([LIBCRYSTFEL_LIBS])

GTK_DOC_CHECK([1.9],[--flavour no-tmpl])
AC_CONFIG_MACRO_DIR(m4)

HTML_DIR=${docdir}/reference/libcrystfel


AC_CONFIG_FILES(Makefile lib/Makefile doc/reference/libcrystfel/Makefile libcrystfel/Makefile)
AC_CONFIG_FILES(libcrystfel/crystfel.pc)
AC_OUTPUT