Add necessary autotools stuff.
[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], [5])
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
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 AC_ARG_ENABLE([jpip-server],
138    [AC_HELP_STRING([--enable-jpip-server], [build jpip server @<:@default=disabled@:>@])],
139    [
140     if test "x${enableval}" = "xyes" ; then
141        want_jpip_server="yes"
142     else
143        want_jpip_server="no"
144     fi
145    ],
146    [want_jpip_server="no"])
147
148 AC_MSG_CHECKING([whether to build the JPIP server])
149 AC_MSG_RESULT([${want_jpip_server}])
150
151
152 ### Checks for programs
153
154 AC_PROG_CC
155
156 # pkg-config
157
158 PKG_PROG_PKG_CONFIG
159
160 # Check whether pkg-config supports Requires.private
161 if $PKG_CONFIG --atleast-pkgconfig-version 0.22 ; then
162    pkgconfig_requires_private="Requires.private"
163 else
164    pkgconfig_requires_private="Requires"
165 fi
166 AC_SUBST([pkgconfig_requires_private])
167 AC_SUBST([requirements])
168
169 # doxygen
170
171 OPJ_CHECK_DOXYGEN
172
173 #  ln -s
174
175 AC_PROG_LN_S
176
177
178 ### Checks for libraries
179
180 # libpng
181
182 have_libpng="no"
183
184 AC_ARG_ENABLE([png],
185    [AC_HELP_STRING([--disable-png], [disable PNG support @<:@default=enabled@:>@])],
186    [
187     if test "x${enableval}" = "xyes" ; then
188        want_png="yes"
189     else
190        want_png="no"
191     fi
192    ],
193    [want_png="yes"])
194
195 AC_MSG_CHECKING([whether to build with PNG support])
196 AC_MSG_RESULT([${want_png}])
197
198 if test "x${want_png}" = "xyes" ; then
199
200    PKG_CHECK_MODULES([PNG], [libpng15 zlib],
201       [have_libpng="yes"],
202       [
203        PKG_CHECK_MODULES([PNG], [libpng14 zlib],
204           [have_libpng="yes"],
205           [
206            PKG_CHECK_MODULES([PNG], [libpng12 zlib],
207               [have_libpng="yes"],
208               [
209                PKG_CHECK_MODULES([PNG], [libpng zlib],
210                   [have_libpng="yes"],
211                   [have_libpng="no"])
212               ])
213           ])
214       ])
215
216    if ! test "x${have_libpng}" = "xyes" ; then
217
218       OPJ_CHECK_LIB([zlib.h],
219          [z],
220          [zlibVersion],
221          [
222           OPJ_CHECK_LIB([png.h],
223              [png],
224              [png_access_version_number],
225              [
226               have_libpng="yes"
227               PNG_CFLAGS="${PNG_CFLAGS} ${Z_CFLAGS}"
228               PNG_LIBS="${PNG_LIBS} ${Z_LIBS}"
229              ],
230              [have_libpng="no"])
231          ],
232          [have_libpng="no"])
233
234    fi
235
236    if test "x${have_libpng}" = "xno" ; then
237       AC_MSG_WARN([Can not find a usuable PNG library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
238    fi
239
240 fi
241
242 AC_MSG_CHECKING([whether PNG is available])
243 AC_MSG_RESULT([${have_libpng}])
244
245 if test "x${have_libpng}" = "xyes" ; then
246    AC_DEFINE(HAVE_LIBPNG, [1], [define to 1 if you have libpng])
247 fi
248
249 AM_CONDITIONAL([with_libpng], [test x${have_libpng} = "xyes"])
250
251 # libtiff
252
253 have_libtiff="no"
254
255 AC_ARG_ENABLE([tiff],
256    [AC_HELP_STRING([--disable-tiff], [disable TIFF support @<:@default=enabled@:>@])],
257    [
258     if test "x${enableval}" = "xyes" ; then
259        want_tiff="yes"
260     else
261        want_tiff="no"
262     fi
263    ],
264    [want_tiff="yes"])
265
266 AC_MSG_CHECKING([whether to build with TIFF support])
267 AC_MSG_RESULT([${want_tiff}])
268
269 if test "x${want_tiff}" = "xyes" ; then
270
271    OPJ_CHECK_LIB(
272       [tiff.h],
273       [tiff],
274       [TIFFOpen],
275       [have_libtiff="yes"],
276       [have_libtiff="no"])
277
278    if test "x${have_libtiff}" = "xno" ; then
279       AC_MSG_WARN([Can not find a usuable TIFF library. Make sure that CPPFLAGS and LDFLAGS are correctly set.])
280    fi
281 fi
282
283 AC_MSG_CHECKING([whether TIFF is available])
284 AC_MSG_RESULT([${have_libtiff}])
285
286 if test "x${have_libtiff}" = "xyes" ; then
287    AC_DEFINE(HAVE_LIBTIFF, [1], [define to 1 if you have libtiff])
288 fi
289
290 AM_CONDITIONAL([with_libtiff], [test "x${have_libtiff}" = "xyes"])
291
292 # libcms2
293
294 lcms_output="no"
295 have_lcms2="no"
296
297 AC_ARG_ENABLE([lcms2],
298    [AC_HELP_STRING([--disable-lcms2], [disable LCMS-2 support @<:@default=enabled@:>@])],
299    [
300     if test "x${enableval}" = "xyes" ; then
301        want_lcms2="yes"
302     else
303        want_lcms2="no"
304     fi
305    ],
306    [want_lcms2="yes"])
307
308 AC_MSG_CHECKING([whether to build with LCMS-2 support])
309 AC_MSG_RESULT([${want_lcms2}])
310
311 if test "x${want_lcms2}" = "xyes" ; then
312    PKG_CHECK_MODULES([LCMS2], [lcms2],
313       [have_lcms2="yes"],
314       [have_lcms2="no"])
315 fi
316
317 AC_MSG_CHECKING([whether LCMS-2 is available])
318 AC_MSG_RESULT([${have_lcms2}])
319
320 if test "x${have_lcms2}" = "xyes" ; then
321    AC_DEFINE(HAVE_LIBLCMS2, [1], [define to 1 if you have lcms version 2.x])
322    lcms_output="lcms version 2.x"
323 fi
324
325 # libcms1
326
327 AC_ARG_ENABLE([lcms1],
328    [AC_HELP_STRING([--disable-lcms1], [disable LCMS-1 support @<:@default=enabled@:>@])],
329    [
330     if test "x${enableval}" = "xyes" ; then
331        want_lcms1="yes"
332     else
333        want_lcms1="no"
334     fi
335    ],
336    [want_lcms1="yes"])
337
338 AC_MSG_CHECKING([whether to build with LCMS-1 support])
339 AC_MSG_RESULT([${want_lcms1}])
340
341 if test "x${have_lcms2}" = "xno" ; then
342
343    if test "x${want_lcms1}" = "xyes" ; then
344       PKG_CHECK_MODULES([LCMS1], [lcms1],
345          [have_lcms1="yes"],
346          [PKG_CHECK_MODULES([LCMS1], [lcms],
347             [have_lcms1="yes"],
348             [have_lcms1="no"])])
349    fi
350
351    AC_MSG_CHECKING([whether LCMS-1 is available])
352    AC_MSG_RESULT([${have_lcms1}])
353
354    if test "x${have_lcms1}" = "xyes" ; then
355       AC_DEFINE(HAVE_LIBLCMS1, [1], [define to 1 if you have lcms version 1.x])
356       lcms_output="lcms version 1.x"
357    fi
358
359 fi
360
361 # threads
362
363 if test "x${want_jpip_server}" = "xyes" ; then
364
365    if test "x${have_win32}" = "xno" ; then
366
367       SAVE_CFLAGS=${CFLAGS}
368       CFLAGS="${CFLAGS} -pthread"
369       SAVE_LIBS=${LIBS}
370       LIBS="${LIBS} -pthread"
371       AC_LINK_IFELSE(
372          [AC_LANG_PROGRAM([[
373 #include <pthread.h>
374                           ]],
375                           [[
376 pthread_t id;
377 id = pthread_self();
378                           ]])],
379          [have_pthread="yes"],
380          [have_pthread="no"])
381       CFLAGS=${SAVE_CFLAGS}
382       LIBS=${SAVE_LIBS}
383
384       AC_MSG_CHECKING([whether Pthread library is available])
385       AC_MSG_RESULT([${have_pthread}])
386
387       if ! test "x${have_pthread}" = "xyes" ; then
388          AC_MSG_WARN([Pthread library not found. OpenJPIP server will not be compiled.])
389          want_jpip_server="no"
390       else
391          THREAD_CFLAGS="-pthread"
392          THREAD_LIBS="-pthread"
393       fi
394
395    else
396       THREAD_LIBS="-lws2_32"
397    fi
398
399 fi
400
401 AC_ARG_VAR([THREAD_CFLAGS], [compiler flag for the thread library])
402 AC_SUBST([THREAD_CFLAGS])
403 AC_ARG_VAR([THREAD_LIBS], [linker flags for thread library])
404 AC_SUBST([THREAD_LIBS])
405
406 # libfcgi
407
408 if test "x${want_jpip_server}" = "xyes" ; then
409
410    have_fcgi="no"
411    OPJ_CHECK_LIB(
412       [fcgi_stdio.h],
413       [fcgi],
414       [FCGI_Accept],
415       [have_fcgi="yes"],
416       [have_fcgi="no"])
417
418    if ! test "x${have_fcgi}" = "xyes" ; then
419       AC_MSG_WARN([FastCGI library not found. OpenJPIP server will not be compiled.])
420       want_jpip_server="no"
421    fi
422
423 fi
424
425 # libcurl
426
427 if test "x${want_jpip_server}" = "xyes" ; then
428
429    PKG_CHECK_MODULES([LIBCURL], [libcurl],
430       [have_libcurl="yes"],
431       [have_libcurl="no"])
432
433    if ! test "x${have_libcurl}" = "xyes" ; then
434       AC_MSG_WARN([libcurl library not found. OpenJPIP server will not be compiled.])
435       want_jpip_server="no"
436    fi
437
438 fi
439
440 if test "x${want_jpip}" = "xyes" ; then
441    AC_DEFINE(USE_JPIP, [1], [define to 1 if you use jpip])
442 fi
443
444 AM_CONDITIONAL([WANT_JPIP], [test "x${want_jpip}" = "xyes"])
445
446 if test "x${want_jpip_server}" = "xyes" ; then
447    AC_DEFINE(USE_JPIP_SERVER, [1], [define to 1 if you use jpip server])
448 fi
449
450 AM_CONDITIONAL([WANT_JPIP_SERVER], [test "x${want_jpip_server}" = "xyes"])
451
452 AM_CONDITIONAL([WANT_JPIP_CODE], [test "x${want_jpip}" = "xyes" || test "x${want_jpip_server}" = "xyes"])
453
454 ### Checks for header files
455
456 ## FIXME: declarations must be fixed in source code. See autoconf manual
457 AC_HEADER_DIRENT
458
459
460 ### Checks for types
461
462
463 ### Checks for structures
464
465
466 ### Checks for compiler characteristics
467
468 AM_PROG_CC_C_O
469 AC_C_BIGENDIAN
470
471 #OPJ_COMPILER_FLAG([-Wall])
472 #OPJ_COMPILER_FLAG([-Wextra])
473 #OPJ_COMPILER_FLAG([-Wshadow])
474 #OPJ_COMPILER_FLAG([-Wpointer-arith])
475 OPJ_COMPILER_FLAG([-Wno-unused-result])
476
477 if test "x${want_debug}" = "xyes" ; then
478    OPJ_COMPILER_FLAG([-g])
479    OPJ_COMPILER_FLAG([-O0])
480 else
481    OPJ_COMPILER_FLAG([-O3])
482 fi
483
484
485 ### Checks for linker characteristics
486
487
488 ### Checks for library functions
489
490
491 ### Post configuration
492
493 AM_CONDITIONAL([BUILD_SHARED], [test "x${enable_shared}" = "xyes"])
494 AM_CONDITIONAL([BUILD_STATIC], [test "x${enable_static}" = "xyes"])
495
496
497 AC_CONFIG_FILES([
498 Makefile
499 libopenjpeg1.pc
500 libopenjpeg-jpwl.pc
501 libopenjpeg/Makefile
502 libopenjpeg/jpwl/Makefile
503 applications/Makefile
504 applications/codec/Makefile
505 applications/mj2/Makefile
506 applications/jpip/Makefile
507 applications/jpip/libopenjpip/Makefile
508 applications/jpip/util/Makefile
509 doc/Makefile
510 ])
511
512 AC_OUTPUT
513
514 ### Summary
515
516 echo
517 echo
518 echo
519 echo "------------------------------------------------------------------------"
520 echo "$PACKAGE $VERSION"
521 echo "------------------------------------------------------------------------"
522 echo
523 echo
524 echo "Configuration Options Summary:"
525 echo
526 echo "  Debug...............: ${want_debug}"
527 echo
528 echo "  Optional support:"
529 echo "    libpng............: ${have_libpng}"
530 echo "    libtiff...........: ${have_libtiff}"
531 echo "    libcms............: ${lcms_output}"
532 echo
533 echo "  Documentation.......: ${opj_have_doxygen}"
534 echo "    Build.............: make doc"
535 echo
536 echo "  mj2.................: ${want_mj2}"
537 echo "  jpwl................: ${want_jpwl}"
538 echo "  jpip................: ${want_jpip}"
539 echo "  jpip server.........: ${want_jpip_server}"
540 echo