[1.5] fix issue #104
[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 AM_CONDITIONAL([WANT_JPWL], [test "x${want_jpwl}" = "xyes"])
120
121 # JPIP
122
123 AC_ARG_ENABLE([jpip],
124    [AC_HELP_STRING([--enable-jpip], [build jpip library @<:@default=disabled@:>@])],
125    [
126     if test "x${enableval}" = "xyes" ; then
127        want_jpip="yes"
128     else
129        want_jpip="no"
130     fi
131    ],
132    [want_jpip="no"])
133
134 AC_MSG_CHECKING([whether to build the JPIP library])
135 AC_MSG_RESULT([${want_jpip}])
136
137
138 ### Checks for programs
139
140 AC_PROG_CC
141
142 # pkg-config
143
144 PKG_PROG_PKG_CONFIG
145
146 # Check whether pkg-config supports Requires.private
147 if $PKG_CONFIG --atleast-pkgconfig-version 0.22 ; then
148    pkgconfig_requires_private="Requires.private"
149 else
150    pkgconfig_requires_private="Requires"
151 fi
152 AC_SUBST(pkgconfig_requires_private)
153 AC_SUBST(requirements)
154
155 # doxygen
156
157 OPJ_CHECK_DOXYGEN
158
159 #  ln -s
160
161 AC_PROG_LN_S
162
163
164 ### Checks for libraries
165
166 # libpng
167
168 have_libpng="no"
169
170 AC_ARG_ENABLE([png],
171    [AC_HELP_STRING([--disable-png], [disable PNG support @<:@default=enabled@:>@])],
172    [
173     if test "x${enableval}" = "xyes" ; then
174        want_png="yes"
175     else
176        want_png="no"
177     fi
178    ],
179    [want_png="yes"])
180
181 AC_MSG_CHECKING([whether to build with PNG support])
182 AC_MSG_RESULT([${want_png}])
183
184 if test "x${want_png}" = "xyes" ; then
185
186    PKG_CHECK_MODULES([PNG], [libpng15],
187       [have_libpng="yes"],
188       [
189        PKG_CHECK_MODULES([PNG], [libpng14],
190           [have_libpng="yes"],
191           [
192            PKG_CHECK_MODULES([PNG], [libpng12],
193               [have_libpng="yes"],
194               [
195                PKG_CHECK_MODULES([PNG], [libpng],
196                   [have_libpng="yes"],
197                   [have_libpng="no"])
198               ])
199           ])
200       ])
201
202    if ! test "x${have_libpng}" = "xyes" ; then
203       OPJ_CHECK_LIB([png.h],
204          [png],
205          [png_create_write_struct],
206          [have_libpng="yes"],
207          [have_libpng="no"])
208    fi
209
210    if test "x${have_libpng}" = "xno" ; then
211       AC_MSG_WARN([Can not find a usuable PNG library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
212    fi
213
214 fi
215
216 AC_MSG_CHECKING([whether PNG is available])
217 AC_MSG_RESULT([${have_libpng}])
218
219 if test "x${have_libpng}" = "xyes" ; then
220    AC_DEFINE(HAVE_LIBPNG, [1], [define to 1 if you have libpng])
221 fi
222
223 AM_CONDITIONAL([with_libpng], [test x${have_libpng} = "xyes"])
224
225 # libtiff
226
227 have_libtiff="no"
228
229 AC_ARG_ENABLE([tiff],
230    [AC_HELP_STRING([--disable-tiff], [disable TIFF support @<:@default=enabled@:>@])],
231    [
232     if test "x${enableval}" = "xyes" ; then
233        want_tiff="yes"
234     else
235        want_tiff="no"
236     fi
237    ],
238    [want_tiff="yes"])
239
240 AC_MSG_CHECKING([whether to build with TIFF support])
241 AC_MSG_RESULT([${want_tiff}])
242
243 if test "x${want_tiff}" = "xyes" ; then
244
245    OPJ_CHECK_LIB(
246       [tiff.h],
247       [tiff],
248       [TIFFOpen],
249       [have_libtiff="yes"],
250       [have_libtiff="no"])
251
252    if test "x${have_libtiff}" = "xno" ; then
253       AC_MSG_WARN([Can not find a usuable TIFF library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
254    fi
255 fi
256
257 AC_MSG_CHECKING([whether TIFF is available])
258 AC_MSG_RESULT([${have_libtiff}])
259
260 if test "x${have_libtiff}" = "xyes" ; then
261    AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
262 fi
263
264 AM_CONDITIONAL([with_libtiff], [test "x${have_libtiff}" = "xyes"])
265
266 # libcms2
267
268 lcms_output="no"
269 have_lcms2="no"
270
271 AC_ARG_ENABLE([lcms2],
272    [AC_HELP_STRING([--disable-lcms2], [disable LCMS-2 support @<:@default=enabled@:>@])],
273    [
274     if test "x${enableval}" = "xyes" ; then
275        want_lcms2="yes"
276     else
277        want_lcms2="no"
278     fi
279    ],
280    [want_lcms2="yes"])
281
282 AC_MSG_CHECKING([whether to build with LCMS-2 support])
283 AC_MSG_RESULT([${want_lcms2}])
284
285 if test "x${want_lcms2}" = "xyes" ; then
286    PKG_CHECK_MODULES([LCMS2], [lcms2],
287       [have_lcms2="yes"],
288       [have_lcms2="no"])
289 fi
290
291 AC_MSG_CHECKING([whether LCMS-2 is available])
292 AC_MSG_RESULT([${have_lcms2}])
293
294 if test "x${have_lcms2}" = "xyes" ; then
295    AC_DEFINE(HAVE_LIBLCMS2, [1], [define to 1 if you have lcms version 2.x])
296    lcms_output="lcms version 2.x"
297 fi
298
299 # libcms1
300
301 AC_ARG_ENABLE([lcms1],
302    [AC_HELP_STRING([--disable-lcms1], [disable LCMS-1 support @<:@default=enabled@:>@])],
303    [
304     if test "x${enableval}" = "xyes" ; then
305        want_lcms1="yes"
306     else
307        want_lcms1="no"
308     fi
309    ],
310    [want_lcms1="yes"])
311
312 AC_MSG_CHECKING([whether to build with LCMS-1 support])
313 AC_MSG_RESULT([${want_lcms1}])
314
315 if test "x${have_lcms2}" = "xno" ; then
316
317    if test "x${want_lcms1}" = "xyes" ; then
318       PKG_CHECK_MODULES([LCMS1], [lcms1],
319          [have_lcms1="yes"],
320          [PKG_CHECK_MODULES([LCMS1], [lcms],
321             [have_lcms1="yes"],
322             [have_lcms1="no"])])
323    fi
324
325    AC_MSG_CHECKING([whether LCMS-1 is available])
326    AC_MSG_RESULT([${have_lcms1}])
327
328    if test "x${have_lcms1}" = "xyes" ; then
329       AC_DEFINE(HAVE_LIBLCMS1, [1], [define to 1 if you have lcms version 1.x])
330       lcms_output="lcms version 1.x"
331    fi
332
333 fi
334
335 # libfcgi
336
337 if test "x${want_jpip}" = "xyes" ; then
338
339    have_fcgi="no"
340    OPJ_CHECK_LIB(
341       [fcgi_stdio.h],
342       [fcgi],
343       [FCGI_Accept],
344       [have_fcgi="yes"],
345       [have_fcgi="no"])
346
347    if ! test "x${have_fcgi}" = "xyes" ; then
348       AC_MSG_WARN([FastCGI library not found. OpenJPIP will not be compiled.])
349       want_jpip="no"
350    fi
351
352 fi
353
354 # libcurl
355
356 if test "x${want_jpip}" = "xyes" ; then
357
358    PKG_CHECK_MODULES([LIBCURL], [libcurl],
359       [have_libcurl="yes"],
360       [have_libcurl="no"])
361
362    if ! test "x${have_libcurl}" = "xyes" ; then
363       AC_MSG_WARN([libcurl library not found. OpenJPIP will not be compiled.])
364       want_jpip="no"
365    fi
366
367 fi
368
369 if test "x${want_jpip}" = "xyes" ; then
370    AC_DEFINE(USE_JPIP, [1], [define to 1 if you use jpip])
371 fi
372
373 AM_CONDITIONAL([WANT_JPIP], [test "x${want_jpip}" = "xyes"])
374
375 ### Checks for header files
376
377 ## FIXME: declarations must be fixed in source code. See autoconf manual
378 AC_HEADER_DIRENT
379
380
381 ### Checks for types
382
383
384 ### Checks for structures
385
386
387 ### Checks for compiler characteristics
388
389 AM_PROG_CC_C_O
390 AC_C_BIGENDIAN
391
392 #OPJ_COMPILER_FLAG([-Wall])
393 #OPJ_COMPILER_FLAG([-Wextra])
394 #OPJ_COMPILER_FLAG([-Wshadow])
395 #OPJ_COMPILER_FLAG([-Wpointer-arith])
396 OPJ_COMPILER_FLAG([-Wno-unused-result])
397
398 if test "x${want_debug}" = "xyes" ; then
399    OPJ_COMPILER_FLAG([-g])
400    OPJ_COMPILER_FLAG([-O0])
401 else
402    OPJ_COMPILER_FLAG([-O3])
403 fi
404
405
406 ### Checks for linker characteristics
407
408
409 ### Checks for library functions
410
411
412 ### Post configuration
413
414 AM_CONDITIONAL([BUILD_SHARED], [test "x${enable_shared}" = "xyes"])
415 AM_CONDITIONAL([BUILD_STATIC], [test "x${enable_static}" = "xyes"])
416
417
418 AC_CONFIG_FILES([
419 Makefile
420 libopenjpeg1.pc
421 libopenjpeg-jpwl.pc
422 libopenjpeg/Makefile
423 libopenjpeg/jpwl/Makefile
424 applications/Makefile
425 applications/codec/Makefile
426 applications/mj2/Makefile
427 applications/jpip/Makefile
428 applications/jpip/libopenjpip/Makefile
429 applications/jpip/util/Makefile
430 doc/Makefile
431 ])
432
433 AC_OUTPUT
434
435 ### Summary
436
437 echo
438 echo
439 echo
440 echo "------------------------------------------------------------------------"
441 echo "$PACKAGE $VERSION"
442 echo "------------------------------------------------------------------------"
443 echo
444 echo
445 echo "Configuration Options Summary:"
446 echo
447 echo "  Debug...............: ${want_debug}"
448 echo
449 echo "  Optional support:"
450 echo "    libpng............: ${have_libpng}"
451 echo "    libtiff...........: ${have_libtiff}"
452 echo "    libcms............: ${lcms_output}"
453 echo
454 echo "  Documentation.......: ${opj_have_doxygen}"
455 echo "    Build.............: make doc"
456 echo
457 echo "  mj2.................: ${want_mj2}"
458 echo "  jpwl................: ${want_jpwl}"
459 echo "  jpip................: ${want_jpip}"
460 echo