minor bug fix in configure.ac (credit to Vincent Torri)
[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], [4])
10 m4_define([OPJ_MICRO], [99])
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)
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
63 ### Additional options to configure
64
65 # debug
66
67 AC_ARG_ENABLE([debug],
68    [AC_HELP_STRING([--enable-debug], [build with debug symbols @<:@default=disabled@:>@])],
69    [
70     if test "x${enableval}" = "xyes" ; then
71        want_debug="yes"
72     else
73        want_debug="no"
74     fi
75    ],
76    [want_debug="no"])
77
78 AC_MSG_CHECKING([whether to build in debug mode])
79 AC_MSG_RESULT([${want_debug}])
80
81 # MJ2
82
83 AC_ARG_ENABLE([mj2],
84    [AC_HELP_STRING([--enable-mj2], [build mj2 binaries @<:@default=disabled@:>@])],
85    [
86     if test "x${enableval}" = "xyes" ; then
87        want_mj2="yes"
88     else
89        want_mj2="no"
90     fi
91    ],
92    [want_mj2="no"])
93
94 AC_MSG_CHECKING([whether to build the MJ2 binaries])
95 AC_MSG_RESULT([${want_mj2}])
96
97 if test "x${want_mj2}" = "xyes" ; then
98    AC_DEFINE(USE_MJ2, [1], [define to 1 if you use mj2])
99 fi
100
101 AM_CONDITIONAL([WANT_MJ2], [test "x${want_mj2}" = "xyes"])
102
103 # JPWL
104
105 AC_ARG_ENABLE([jpwl],
106    [AC_HELP_STRING([--enable-jpwl], [build JPWL library @<:@default=disabled@:>@])],
107    [
108     if test "x${enableval}" = "xyes" ; then
109        want_jpwl="yes"
110     else
111        want_jpwl="no"
112     fi
113    ],
114    [want_jpwl="no"])
115
116 AC_MSG_CHECKING([whether to build the JPWL library])
117 AC_MSG_RESULT([${want_jpwl}])
118
119 if test "x${want_jpwl}" = "xyes" ; then
120    AC_DEFINE(USE_JPWL, [1], [define to 1 if you use jpwl])
121 fi
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 if test "x${want_jpip}" = "xyes" ; then
142    AC_DEFINE(USE_JPIP, [1], [define to 1 if you use jpip])
143 fi
144
145 # libfcgi
146
147 if test "x${want_jpip}" = "xyes" ; then
148    OPJ_CHECK_LIB([/usr],
149       [fcgi_stdio.h],
150       [fcgi],
151       [FCGI_printf],
152       [want_jpip="yes"],
153       [want_jpip="no"])
154 fi
155
156 if test "x${want_jpip}" = "xno" ; then
157    OPJ_CHECK_LIB([/usr/local],
158       [fcgi_stdio.h],
159       [fcgi],
160       [FCGI_printf],
161       [want_jpip="yes"],
162       [want_jpip="no"])
163 fi
164
165 if test "x${want_jpip}" = "xno" ; then
166    OPJ_CHECK_LIB([/opt],
167       [fcgi_stdio.h],
168       [fcgi],
169       [FCGI_printf],
170       [want_jpip="yes"],
171       [want_jpip="no"])
172 fi
173
174 AM_CONDITIONAL([WANT_JPIP], [test "x${want_jpip}" = "xyes"])
175
176
177 ### Checks for programs
178
179 AC_PROG_CC
180
181 # pkg-config
182
183 PKG_PROG_PKG_CONFIG
184
185 # Check whether pkg-config supports Requires.private
186 if $PKG_CONFIG --atleast-pkgconfig-version 0.22 ; then
187    pkgconfig_requires_private="Requires.private"
188 else
189    pkgconfig_requires_private="Requires"
190 fi
191 AC_SUBST(pkgconfig_requires_private)
192 AC_SUBST(requirements)
193
194 # doxygen
195
196 OPJ_CHECK_DOXYGEN
197
198 #  ln -s
199
200 AC_PROG_LN_S
201
202
203 ### Checks for libraries
204
205 # libpng
206
207 have_libpng="no"
208
209 AC_ARG_ENABLE([png],
210    [AC_HELP_STRING([--disable-png], [disable PNG support @<:@default=enabled@:>@])],
211    [
212     if test "x${enableval}" = "xyes" ; then
213        want_png="yes"
214     else
215        want_png="no"
216     fi
217    ],
218    [want_png="yes"])
219
220 AC_MSG_CHECKING([whether to build with PNG support])
221 AC_MSG_RESULT([${want_png}])
222
223 if test "x${want_png}" = "xyes" ; then
224
225    PKG_CHECK_MODULES([PNG], [libpng15],
226       [have_libpng="yes"],
227       [
228        PKG_CHECK_MODULES([PNG], [libpng14],
229           [have_libpng="yes"],
230           [
231            PKG_CHECK_MODULES([PNG], [libpng12],
232               [have_libpng="yes"],
233               [
234                PKG_CHECK_MODULES([PNG], [libpng],
235                   [have_libpng="yes"],
236                   [have_libpng="no"])
237               ])
238           ])
239       ])
240
241    if ! test "x${have_libpng}" = "xyes" ; then
242       OPJ_CHECK_LIB([/usr],
243          [png.h],
244          [png],
245          [png_create_write_struct],
246          [have_libpng="yes"],
247          [have_libpng="no"])
248    fi
249
250    if ! test "x${have_libpng}" = "xyes" ; then
251       OPJ_CHECK_LIB([/usr/local],
252          [png.h],
253          [png],
254          [png_create_write_struct],
255          [have_libpng="yes"],
256          [have_libpng="no"])
257    fi
258
259    if ! test "x${have_libpng}" = "xyes" ; then
260       OPJ_CHECK_LIB([/opt],
261          [png.h],
262          [png],
263          [png_create_write_struct],
264          [have_libpng="yes"],
265          [have_libpng="no"])
266    fi
267
268    if test "x${have_libpng}" = "xno" ; then
269       AC_MSG_WARN([Can not find a usuable PNG library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
270    fi
271
272 fi
273
274 AC_MSG_CHECKING([whether PNG is available])
275 AC_MSG_RESULT([${have_libpng}])
276
277 if test "x${have_libpng}" = "xyes" ; then
278    AC_DEFINE(HAVE_LIBPNG, [1], [define to 1 if you have libpng])
279 fi
280
281 AM_CONDITIONAL([with_libpng], [test x${have_libpng} = "xyes"])
282
283 # libtiff
284
285 have_libtiff="no"
286
287 AC_ARG_ENABLE([tiff],
288    [AC_HELP_STRING([--disable-tiff], [disable TIFF support @<:@default=enabled@:>@])],
289    [
290     if test "x${enableval}" = "xyes" ; then
291        want_tiff="yes"
292     else
293        want_tiff="no"
294     fi
295    ],
296    [want_tiff="yes"])
297
298 AC_MSG_CHECKING([whether to build with TIFF support])
299 AC_MSG_RESULT([${want_tiff}])
300
301 if test "x${want_tiff}" = "xyes" ; then
302
303    OPJ_CHECK_LIB([/usr],
304       [tiff.h],
305       [tiff],
306       [TIFFOpen],
307       [have_libtiff="yes"],
308       [have_libtiff="no"])
309
310    if ! test "x${have_libtiff}" = "xyes" ; then
311       OPJ_CHECK_LIB([/usr/local],
312          [tiff.h],
313          [tiff],
314          [TIFFOpen],
315          [have_libtiff="yes"],
316          [have_libtiff="no"])
317    fi
318
319    if ! test "x${have_libtiff}" = "xyes" ; then
320       OPJ_CHECK_LIB([/opt],
321          [tiff.h],
322          [tiff],
323          [TIFFOpen],
324          [have_libtiff="yes"],
325          [have_libtiff="no"])
326    fi
327
328    if test "x${have_libtiff}" = "xno" ; then
329       AC_MSG_WARN([Can not find a usuable TIFF library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
330    fi
331 fi
332
333 AC_MSG_CHECKING([whether TIFF is available])
334 AC_MSG_RESULT([${have_libtiff}])
335
336 if test "x${have_libtiff}" = "xyes" ; then
337    AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
338 fi
339
340 AM_CONDITIONAL([with_libtiff], [test "x${have_libtiff}" = "xyes"])
341
342 AC_ARG_VAR([TIFF_CFLAGS], [preprocessor flags for libtiff])
343 AC_SUBST(TIFF_CFLAGS)
344 AC_ARG_VAR([TIFF_LIBS], [linker flags for libtiff])
345 AC_SUBST(TIFF_LIBS)
346
347 # libcms2
348
349 lcms_output="no"
350 have_lcms2="no"
351
352 AC_ARG_ENABLE([lcms2],
353    [AC_HELP_STRING([--disable-lcms2], [disable LCMS-2 support @<:@default=enabled@:>@])],
354    [
355     if test "x${enableval}" = "xyes" ; then
356        want_lcms2="yes"
357     else
358        want_lcms2="no"
359     fi
360    ],
361    [want_lcms2="yes"])
362
363 AC_MSG_CHECKING([whether to build with LCMS-2 support])
364 AC_MSG_RESULT([${want_lcms2}])
365
366 if test "x${want_lcms2}" = "xyes" ; then
367    PKG_CHECK_MODULES([LCMS2], [lcms2],
368       [have_lcms2="yes"],
369       [have_lcms2="no"])
370 fi
371
372 AC_MSG_CHECKING([whether LCMS-2 is available])
373 AC_MSG_RESULT([${have_lcms2}])
374
375 if test "x${have_lcms2}" = "xyes" ; then
376    AC_DEFINE(HAVE_LIBLCMS2, [1], [define to 1 if you have lcms version 2.x])
377    lcms_output="lcms version 2.x"
378 fi
379
380 # libcms1
381
382 AC_ARG_ENABLE([lcms1],
383    [AC_HELP_STRING([--disable-lcms1], [disable LCMS-1 support @<:@default=enabled@:>@])],
384    [
385     if test "x${enableval}" = "xyes" ; then
386        want_lcms1="yes"
387     else
388        want_lcms1="no"
389     fi
390    ],
391    [want_lcms1="yes"])
392
393 AC_MSG_CHECKING([whether to build with LCMS-1 support])
394 AC_MSG_RESULT([${want_lcms1}])
395
396 if test "x${have_lcms2}" = "xno" ; then
397
398    if test "x${want_lcms1}" = "xyes" ; then
399       PKG_CHECK_MODULES([LCMS1], [lcms1],
400          [have_lcms1="yes"],
401          [PKG_CHECK_MODULES([LCMS1], [lcms],
402             [have_lcms1="yes"],
403             [have_lcms1="no"])])
404    fi
405
406    AC_MSG_CHECKING([whether LCMS-1 is available])
407    AC_MSG_RESULT([${have_lcms1}])
408
409    if test "x${have_lcms1}" = "xyes" ; then
410       AC_DEFINE(HAVE_LIBLCMS1, [1], [define to 1 if you have lcms version 1.x])
411       lcms_output="lcms version 1.x"
412    fi
413
414 fi
415
416 ### Checks for header files
417
418 ## FIXME: declarations must be fixed in source code. See autoconf manual
419 AC_HEADER_DIRENT
420
421
422 ### Checks for types
423
424
425 ### Checks for structures
426
427
428 ### Checks for compiler characteristics
429
430 AC_C_BIGENDIAN
431
432 #OPJ_COMPILER_FLAG([-Wall])
433 #OPJ_COMPILER_FLAG([-Wextra])
434 #OPJ_COMPILER_FLAG([-Wshadow])
435 #OPJ_COMPILER_FLAG([-Wpointer-arith])
436 OPJ_COMPILER_FLAG([-Wno-unused-result])
437
438 if test "x${want_debug}" = "xyes" ; then
439    OPJ_COMPILER_FLAG([-g])
440    OPJ_COMPILER_FLAG([-O0])
441 else
442    OPJ_COMPILER_FLAG([-O3])
443 fi
444
445
446 ### Checks for linker characteristics
447
448
449 ### Checks for library functions
450
451 AC_CONFIG_FILES([
452 Makefile
453 libopenjpeg1.pc
454 libopenjpeg-jpwl.pc
455 libopenjpeg/Makefile
456 libopenjpeg/jpwl/Makefile
457 applications/Makefile
458 applications/codec/Makefile
459 applications/mj2/Makefile
460 applications/jpip/Makefile
461 applications/jpip/libopenjpip/Makefile
462 applications/jpip/opj_server/Makefile
463 applications/jpip/opj_client/Makefile
464 applications/jpip/opj_client/opj_dec_server/Makefile
465 applications/jpip/tools/Makefile
466 applications/jpip/tools/indexer/Makefile
467 doc/Makefile
468 ])
469
470 AC_OUTPUT
471
472 ### Summary
473
474 echo
475 echo
476 echo
477 echo "------------------------------------------------------------------------"
478 echo "$PACKAGE $VERSION"
479 echo "------------------------------------------------------------------------"
480 echo
481 echo
482 echo "Configuration Options Summary:"
483 echo
484 echo "  Debug...............: ${want_debug}"
485 echo
486 echo "  Optional support:"
487 echo "    libpng............: ${have_libpng}"
488 echo "    libtiff...........: ${have_libtiff}"
489 echo "    libcms............: ${lcms_output}"
490 echo
491 echo "  Documentation.......: ${opj_have_doxygen}"
492 echo "    Build.............: make doc"
493 echo
494 echo "  mj2.................: ${want_mj2}"
495 echo "  jpwl................: ${want_jpwl}"
496 echo "  jpip................: ${want_jpip}"
497 echo