[trunk] update the name of the executable used for the tests
[openjpeg.git] / configure.ac
1
2 # According to http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info :
3 #
4 # 1) when bugs are fixed or internal code is changed: increase MICRO
5 # 2) if API is added, increase MINOR and set MICRO to 0
6 # 3) if API or ABI is broken (this case should (must) never happen as it's very bad for a library), or a new designed library, increase MAJOR and set MINOR and MICRO to 0
7
8 m4_define([OPJ_MAJOR], [1])
9 m4_define([OPJ_MINOR], [99])
10 m4_define([OPJ_MICRO], [0])
11
12 m4_define([lt_cur], m4_eval(OPJ_MAJOR + OPJ_MINOR))
13 m4_define([lt_rev], OPJ_MICRO)
14 m4_define([lt_age], OPJ_MINOR)
15
16 AC_PREREQ([2.62])
17 AC_INIT([OpenJPEG],
18    [OPJ_MAJOR.OPJ_MINOR.OPJ_MICRO],
19    [openjpeg@googlegroups.com],
20    [openjpeg],
21    [http://www.openjpeg.org])
22 AC_CONFIG_SRCDIR([configure.ac])
23 AC_CONFIG_MACRO_DIR([m4])
24 AC_CONFIG_HEADERS([opj_config.h])
25
26 AC_CANONICAL_SYSTEM
27 AC_CANONICAL_HOST
28
29 AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 dist-xz dist-zip])
30 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
31
32 MAJOR_NR=OPJ_MAJOR
33 MINOR_NR=OPJ_MINOR
34 MICRO_NR=OPJ_MICRO
35 AC_SUBST([MAJOR_NR])
36 AC_SUBST([MINOR_NR])
37 AC_SUBST([MICRO_NR])
38
39 LT_PREREQ([2.0])
40 LT_INIT([win32-dll])
41
42 lt_version=lt_cur:lt_rev:lt_age
43 AC_SUBST([lt_version])
44
45
46 ### Needed information
47
48 have_win32=no
49 have_darwin="no"
50 case "$host_os" in
51    mingw*)
52       have_win32="yes"
53       ;;
54    darwin*)
55       have_darwin="yes"
56       ;;
57 esac
58
59 AM_CONDITIONAL([HAVE_WIN32], [test "x${have_win32}" = "xyes"])
60 AM_CONDITIONAL([HAVE_DARWIN], [test "x${have_darwin}" = "xyes"])
61
62 AC_TYPE_SSIZE_T
63 if test "x$ac_cv_type_ssize_t" = xyes; then
64 AC_DEFINE([HAVE_SSIZE_T], [1],[Define to 1 if you have ssize_t.],
65  [AC_MSG([ssize_t not found])])
66 fi
67 ### Additional options to configure
68
69 # debug
70
71 AC_ARG_ENABLE([debug],
72    [AC_HELP_STRING([--enable-debug], [build with debug symbols @<:@default=disabled@:>@])],
73    [
74     if test "x${enableval}" = "xyes" ; then
75        want_debug="yes"
76     else
77        want_debug="no"
78     fi
79    ],
80    [want_debug="no"])
81
82 AC_MSG_CHECKING([whether to build in debug mode])
83 AC_MSG_RESULT([${want_debug}])
84
85 # MJ2
86
87 AC_ARG_ENABLE([mj2],
88    [AC_HELP_STRING([--enable-mj2], [build mj2 binaries @<:@default=disabled@:>@])],
89    [
90     if test "x${enableval}" = "xyes" ; then
91        want_mj2="yes"
92     else
93        want_mj2="no"
94     fi
95    ],
96    [want_mj2="no"])
97
98 AC_MSG_CHECKING([whether to build the MJ2 binaries])
99 AC_MSG_RESULT([${want_mj2}])
100
101 if test "x${want_mj2}" = "xyes" ; then
102    AC_DEFINE(USE_MJ2, [1], [define to 1 if you use mj2])
103 fi
104
105 AM_CONDITIONAL([WANT_MJ2], [test "x${want_mj2}" = "xyes"])
106
107 # JPWL
108
109 AC_ARG_ENABLE([jpwl],
110    [AC_HELP_STRING([--enable-jpwl], [build JPWL library @<:@default=disabled@:>@])],
111    [
112     if test "x${enableval}" = "xyes" ; then
113        want_jpwl="yes"
114     else
115        want_jpwl="no"
116     fi
117    ],
118    [want_jpwl="no"])
119
120 AC_MSG_CHECKING([whether to build the JPWL library])
121 AC_MSG_RESULT([${want_jpwl}])
122
123 AM_CONDITIONAL([WANT_JPWL], [test "x${want_jpwl}" = "xyes"])
124
125 # JPIP
126
127 AC_ARG_ENABLE([jpip],
128    [AC_HELP_STRING([--enable-jpip], [build jpip library @<:@default=disabled@:>@])],
129    [
130     if test "x${enableval}" = "xyes" ; then
131        want_jpip="yes"
132     else
133        want_jpip="no"
134     fi
135    ],
136    [want_jpip="no"])
137
138 AC_MSG_CHECKING([whether to build the JPIP library])
139 AC_MSG_RESULT([${want_jpip}])
140
141 AC_ARG_ENABLE([jpip-server],
142    [AC_HELP_STRING([--enable-jpip-server], [build jpip server @<:@default=disabled@:>@])],
143    [
144     if test "x${enableval}" = "xyes" ; then
145        want_jpip_server="yes"
146     else
147        want_jpip_server="no"
148     fi
149    ],
150    [want_jpip_server="no"])
151
152 AC_MSG_CHECKING([whether to build the JPIP server])
153 AC_MSG_RESULT([${want_jpip_server}])
154
155
156 ### Checks for programs
157
158 AC_PROG_CC
159
160 # pkg-config
161
162 PKG_PROG_PKG_CONFIG
163
164 # Check whether pkg-config supports Requires.private
165 if $PKG_CONFIG --atleast-pkgconfig-version 0.22 ; then
166    pkgconfig_requires_private="Requires.private"
167 else
168    pkgconfig_requires_private="Requires"
169 fi
170 AC_SUBST([pkgconfig_requires_private])
171 AC_SUBST([requirements])
172
173 # doxygen
174
175 OPJ_CHECK_DOXYGEN
176
177 #  ln -s
178
179 AC_PROG_LN_S
180
181
182 ### Checks for libraries
183
184 # libpng
185
186 have_libpng="no"
187
188 AC_ARG_ENABLE([png],
189    [AC_HELP_STRING([--disable-png], [disable PNG support @<:@default=enabled@:>@])],
190    [
191     if test "x${enableval}" = "xyes" ; then
192        want_png="yes"
193     else
194        want_png="no"
195     fi
196    ],
197    [want_png="yes"])
198
199 AC_MSG_CHECKING([whether to build with PNG support])
200 AC_MSG_RESULT([${want_png}])
201
202 if test "x${want_png}" = "xyes" ; then
203
204    PKG_CHECK_MODULES([PNG], [libpng15 zlib],
205       [have_libpng="yes"],
206       [
207        PKG_CHECK_MODULES([PNG], [libpng14 zlib],
208           [have_libpng="yes"],
209           [
210            PKG_CHECK_MODULES([PNG], [libpng12 zlib],
211               [have_libpng="yes"],
212               [
213                PKG_CHECK_MODULES([PNG], [libpng zlib],
214                   [have_libpng="yes"],
215                   [have_libpng="no"])
216               ])
217           ])
218       ])
219
220    if ! test "x${have_libpng}" = "xyes" ; then
221
222       OPJ_CHECK_LIB([zlib.h],
223          [z],
224          [zlibVersion],
225          [
226           OPJ_CHECK_LIB([png.h],
227              [png],
228              [png_access_version_number],
229              [
230               have_libpng="yes"
231               PNG_CFLAGS="${PNG_CFLAGS} ${Z_CFLAGS}"
232               PNG_LIBS="${PNG_LIBS} ${Z_LIBS}"
233              ],
234              [have_libpng="no"])
235          ],
236          [have_libpng="no"])
237
238    fi
239
240    if test "x${have_libpng}" = "xno" ; then
241       AC_MSG_WARN([Can not find a usuable PNG library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
242    fi
243
244 fi
245
246 AC_MSG_CHECKING([whether PNG is available])
247 AC_MSG_RESULT([${have_libpng}])
248
249 if test "x${have_libpng}" = "xyes" ; then
250    AC_DEFINE(HAVE_LIBPNG, [1], [define to 1 if you have libpng])
251 fi
252
253 AM_CONDITIONAL([with_libpng], [test x${have_libpng} = "xyes"])
254
255 # libtiff
256
257 have_libtiff="no"
258
259 AC_ARG_ENABLE([tiff],
260    [AC_HELP_STRING([--disable-tiff], [disable TIFF support @<:@default=enabled@:>@])],
261    [
262     if test "x${enableval}" = "xyes" ; then
263        want_tiff="yes"
264     else
265        want_tiff="no"
266     fi
267    ],
268    [want_tiff="yes"])
269
270 AC_MSG_CHECKING([whether to build with TIFF support])
271 AC_MSG_RESULT([${want_tiff}])
272
273 if test "x${want_tiff}" = "xyes" ; then
274
275    OPJ_CHECK_LIB(
276       [tiff.h],
277       [tiff],
278       [TIFFOpen],
279       [have_libtiff="yes"],
280       [have_libtiff="no"])
281
282    if test "x${have_libtiff}" = "xno" ; then
283       AC_MSG_WARN([Can not find a usuable TIFF library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
284    fi
285 fi
286
287 AC_MSG_CHECKING([whether TIFF is available])
288 AC_MSG_RESULT([${have_libtiff}])
289
290 if test "x${have_libtiff}" = "xyes" ; then
291    AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
292 fi
293
294 AM_CONDITIONAL([with_libtiff], [test "x${have_libtiff}" = "xyes"])
295
296 # libcms2
297
298 lcms_output="no"
299 have_lcms2="no"
300
301 AC_ARG_ENABLE([lcms2],
302    [AC_HELP_STRING([--disable-lcms2], [disable LCMS-2 support @<:@default=enabled@:>@])],
303    [
304     if test "x${enableval}" = "xyes" ; then
305        want_lcms2="yes"
306     else
307        want_lcms2="no"
308     fi
309    ],
310    [want_lcms2="yes"])
311
312 AC_MSG_CHECKING([whether to build with LCMS-2 support])
313 AC_MSG_RESULT([${want_lcms2}])
314
315 if test "x${want_lcms2}" = "xyes" ; then
316    PKG_CHECK_MODULES([LCMS2], [lcms2],
317       [have_lcms2="yes"],
318       [have_lcms2="no"])
319 fi
320
321 AC_MSG_CHECKING([whether LCMS-2 is available])
322 AC_MSG_RESULT([${have_lcms2}])
323
324 if test "x${have_lcms2}" = "xyes" ; then
325    AC_DEFINE(HAVE_LIBLCMS2, [1], [define to 1 if you have lcms version 2.x])
326    lcms_output="lcms version 2.x"
327 fi
328
329 # libcms1
330
331 AC_ARG_ENABLE([lcms1],
332    [AC_HELP_STRING([--disable-lcms1], [disable LCMS-1 support @<:@default=enabled@:>@])],
333    [
334     if test "x${enableval}" = "xyes" ; then
335        want_lcms1="yes"
336     else
337        want_lcms1="no"
338     fi
339    ],
340    [want_lcms1="yes"])
341
342 AC_MSG_CHECKING([whether to build with LCMS-1 support])
343 AC_MSG_RESULT([${want_lcms1}])
344
345 if test "x${have_lcms2}" = "xno" ; then
346
347    if test "x${want_lcms1}" = "xyes" ; then
348       PKG_CHECK_MODULES([LCMS1], [lcms1],
349          [have_lcms1="yes"],
350          [PKG_CHECK_MODULES([LCMS1], [lcms],
351             [have_lcms1="yes"],
352             [have_lcms1="no"])])
353    fi
354
355    AC_MSG_CHECKING([whether LCMS-1 is available])
356    AC_MSG_RESULT([${have_lcms1}])
357
358    if test "x${have_lcms1}" = "xyes" ; then
359       AC_DEFINE(HAVE_LIBLCMS1, [1], [define to 1 if you have lcms version 1.x])
360       lcms_output="lcms version 1.x"
361    fi
362
363 fi
364
365 # threads
366
367 if test "x${want_jpip_server}" = "xyes" ; then
368
369    if test "x${have_win32}" = "xno" ; then
370
371       SAVE_CFLAGS=${CFLAGS}
372       CFLAGS="${CFLAGS} -pthread"
373       SAVE_LIBS=${LIBS}
374       LIBS="${LIBS} -pthread"
375       AC_LINK_IFELSE(
376          [AC_LANG_PROGRAM([[
377 #include <pthread.h>
378                           ]],
379                           [[
380 pthread_t id;
381 id = pthread_self();
382                           ]])],
383          [have_pthread="yes"],
384          [have_pthread="no"])
385       CFLAGS=${SAVE_CFLAGS}
386       LIBS=${SAVE_LIBS}
387
388       AC_MSG_CHECKING([whether Pthread library is available])
389       AC_MSG_RESULT([${have_pthread}])
390
391       if ! test "x${have_pthread}" = "xyes" ; then
392          AC_MSG_WARN([Pthread library not found. OpenJPIP server will not be compiled.])
393          want_jpip_server="no"
394       else
395          THREAD_CFLAGS="-pthread"
396          THREAD_LIBS="-pthread"
397       fi
398
399    else
400       THREAD_LIBS="-lws2_32"
401    fi
402
403 fi
404
405 AC_ARG_VAR([THREAD_CFLAGS], [compiler flag for the thread library])
406 AC_SUBST([THREAD_CFLAGS])
407 AC_ARG_VAR([THREAD_LIBS], [linker flags for thread library])
408 AC_SUBST([THREAD_LIBS])
409
410 # libfcgi
411
412 if test "x${want_jpip_server}" = "xyes" ; then
413
414    have_fcgi="no"
415    OPJ_CHECK_LIB(
416       [fcgi_stdio.h],
417       [fcgi],
418       [FCGI_Accept],
419       [have_fcgi="yes"],
420       [have_fcgi="no"])
421
422    if ! test "x${have_fcgi}" = "xyes" ; then
423       AC_MSG_WARN([FastCGI library not found. OpenJPIP server will not be compiled.])
424       want_jpip_server="no"
425    fi
426
427 fi
428
429 # libcurl
430
431 if test "x${want_jpip_server}" = "xyes" ; then
432
433    PKG_CHECK_MODULES([LIBCURL], [libcurl],
434       [have_libcurl="yes"],
435       [have_libcurl="no"])
436
437    if ! test "x${have_libcurl}" = "xyes" ; then
438       AC_MSG_WARN([libcurl library not found. OpenJPIP server will not be compiled.])
439       want_jpip_server="no"
440    fi
441
442 fi
443
444 if test "x${want_jpip}" = "xyes" ; then
445    AC_DEFINE(USE_JPIP, [1], [define to 1 if you use jpip])
446 fi
447
448 AM_CONDITIONAL([WANT_JPIP], [test "x${want_jpip}" = "xyes"])
449
450 if test "x${want_jpip_server}" = "xyes" ; then
451    AC_DEFINE(USE_JPIP_SERVER, [1], [define to 1 if you use jpip server])
452 fi
453
454 AM_CONDITIONAL([WANT_JPIP_SERVER], [test "x${want_jpip_server}" = "xyes"])
455
456 AM_CONDITIONAL([WANT_JPIP_CODE], [test "x${want_jpip}" = "xyes" || test "x${want_jpip_server}" = "xyes"])
457
458 ### Checks for header files
459
460 ## FIXME: declarations must be fixed in source code. See autoconf manual
461 AC_HEADER_DIRENT
462
463
464 ### Checks for types
465
466
467 ### Checks for structures
468
469
470 ### Checks for compiler characteristics
471
472 AM_PROG_CC_C_O
473 AC_C_BIGENDIAN
474
475 #OPJ_COMPILER_FLAG([-Wall])
476 #OPJ_COMPILER_FLAG([-Wextra])
477 #OPJ_COMPILER_FLAG([-Wshadow])
478 #OPJ_COMPILER_FLAG([-Wpointer-arith])
479 OPJ_COMPILER_FLAG([-Wno-unused-result])
480
481 if test "x${want_debug}" = "xyes" ; then
482    OPJ_COMPILER_FLAG([-g])
483    OPJ_COMPILER_FLAG([-O0])
484 else
485    OPJ_COMPILER_FLAG([-O3])
486 fi
487
488
489 ### Checks for linker characteristics
490
491
492 ### Checks for library functions
493
494
495 ### Post configuration
496
497 AM_CONDITIONAL([BUILD_SHARED], [test "x${enable_shared}" = "xyes"])
498 AM_CONDITIONAL([BUILD_STATIC], [test "x${enable_static}" = "xyes"])
499
500
501 AC_CONFIG_FILES([
502 Makefile
503 libopenjpeg1.pc
504 libopenjpeg-jpwl.pc
505 libopenjpeg/Makefile
506 libopenjpeg/jpwl/Makefile
507 applications/Makefile
508 applications/codec/Makefile
509 applications/mj2/Makefile
510 applications/jpip/Makefile
511 applications/jpip/libopenjpip/Makefile
512 applications/jpip/util/Makefile
513 doc/Makefile
514 ])
515
516 AC_OUTPUT
517
518 ### Summary
519
520 echo
521 echo
522 echo
523 echo "------------------------------------------------------------------------"
524 echo "$PACKAGE $VERSION"
525 echo "------------------------------------------------------------------------"
526 echo
527 echo
528 echo "Configuration Options Summary:"
529 echo
530 echo "  Debug...............: ${want_debug}"
531 echo
532 echo "  Optional support:"
533 echo "    libpng............: ${have_libpng}"
534 echo "    libtiff...........: ${have_libtiff}"
535 echo "    libcms............: ${lcms_output}"
536 echo
537 echo "  Documentation.......: ${opj_have_doxygen}"
538 echo "    Build.............: make doc"
539 echo
540 echo "  mj2.................: ${want_mj2}"
541 echo "  jpwl................: ${want_jpwl}"
542 echo "  jpip................: ${want_jpip}"
543 echo "  jpip server.........: ${want_jpip_server}"
544 echo