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