1 dnl ****************************************************************************
2 dnl Copyright (c) 2001-2004 Michael David Adams.
3 dnl All rights reserved.
5 dnl The complete licensing terms for this software can be found in the file
6 dnl named "LICENSE" in this software distribution.
7 dnl ****************************************************************************
10 define(AC_JAS_NAME, jasper)
12 dnl ************************************************************
13 dnl Package version information.
14 dnl ************************************************************
16 dnl The major, minor, and micro version numbers of the package.
17 define(AC_JAS_MAJOR_VERSION, 1)
18 define(AC_JAS_MINOR_VERSION, 900)
19 define(AC_JAS_MICRO_VERSION, 29)
21 dnl The package version.
22 define(AC_JAS_VERSION,
23 AC_JAS_MAJOR_VERSION.AC_JAS_MINOR_VERSION.AC_JAS_MICRO_VERSION)
25 dnl ************************************************************
26 dnl RPM version information.
27 dnl ************************************************************
29 define(AC_JAS_RPM_RELEASE, 1)
31 dnl ************************************************************
32 dnl Dynamically-linked library version information (for Libtool).
33 dnl ************************************************************
35 dnl Guidelines for updating these definitions:
36 dnl 1) If the library source code has changed at all since the last update,
37 dnl then increment REVISION.
38 dnl 2) If any interfaces have been added, removed, or changed since the last
39 dnl update, increment CURRENT, and set REVISION to zero.
40 dnl 3) If any interfaces have been added since the last public release, then
42 dnl 4) If any interfaces have been removed since the last public release, then
45 dnl The most recent interface number that this library implements.
46 define(AC_JAS_LT_CURRENT, 4)
48 dnl The implementation number of the current interface.
49 define(AC_JAS_LT_REVISION, 0)
51 dnl The difference between the newest and oldest interfaces that this library
52 dnl implements. In other words, the library implements all of the interface
53 dnl numbers in the range from current - age to current.
54 define(AC_JAS_LT_AGE, 0)
56 dnl The release number of the library.
57 define(AC_JAS_LT_RELEASE, AC_JAS_MAJOR_VERSION.AC_JAS_MINOR_VERSION)
59 dnl ****************************************************************************
60 dnl NOTHING BELOW THIS LINE SHOULD REQUIRE MODIFICATION (IDEALLY :-)
61 dnl ****************************************************************************
63 dnl Initialize autoconf.
64 AC_INIT(AC_JAS_NAME, AC_JAS_VERSION)
66 AC_CONFIG_SRCDIR(README)
67 dnl Note: Avoid the temptation to call the auxiliary directory "aux" because
68 dnl Microsoft Windows will barf if you try to use "aux" as a directory name. :-(
69 AC_CONFIG_AUX_DIR([ac_aux])
70 AC_CONFIG_MACRO_DIR([ac_m4])
72 dnl Initialize automake.
73 AM_INIT_AUTOMAKE([1.11 foreign dist-xz dist-bzip2])
75 m4_include([ac_m4/m4_ax_generate_changelog.m4])
76 m4_include([ac_m4/m4_ax_cflags_gcc_option.m4])
77 m4_include([ac_m4/m4_ax_check_compile_flag.m4])
78 m4_include([ac_m4/m4_ax_append_flag.m4])
83 LT_INIT([shared static])
85 # Detect the canonical host and target build environment.
86 # Note: This precedes automake initialization to avoid warnings.
90 # Initialize version information parameters.
91 JAS_MAJOR_VERSION=AC_JAS_MAJOR_VERSION
92 JAS_MINOR_VERSION=AC_JAS_MINOR_VERSION
93 JAS_MICRO_VERSION=AC_JAS_MICRO_VERSION
94 JAS_VERSION=AC_JAS_VERSION
95 AC_SUBST(JAS_MAJOR_VERSION)
96 AC_SUBST(JAS_MINOR_VERSION)
97 AC_SUBST(JAS_MICRO_VERSION)
99 AC_DEFINE_UNQUOTED(JAS_VERSION, "$JAS_VERSION")
100 JAS_RPM_RELEASE=AC_JAS_RPM_RELEASE
101 AC_SUBST(JAS_RPM_RELEASE)
103 # Initialize version information for libtool.
104 LT_RELEASE=AC_JAS_LT_RELEASE
105 LT_CURRENT=AC_JAS_LT_CURRENT
106 LT_REVISION=AC_JAS_LT_REVISION
110 AC_SUBST(LT_REVISION)
113 # Indicate a configure-based build is being used.
114 AC_DEFINE(JAS_CONFIGURE)
116 ############################################################
117 # Configuration header file.
118 ############################################################
120 AH_TEMPLATE([DEBUG_OVERFLOW], [Debugging overflow detection])
121 AH_TEMPLATE([JAS_CONFIGURE], [JasPer configure])
122 AH_TEMPLATE([JAS_VERSION], [JasPer version])
123 AH_TEMPLATE([DEBUG], [Extra debugging support])
126 /* Avoid problems due to multiple inclusion. */
130 /* This preprocessor symbol identifies the version of JasPer. */
132 /* If configure is being used, this symbol will be defined automatically
133 at this point in the configuration header file. */
135 /* The preprocessor symbol JAS_WIN_MSVC_BUILD should not be defined
136 unless the JasPer software is being built under Microsoft Windows
137 using Microsoft Visual C. */
138 #if !defined(JAS_WIN_MSVC_BUILD)
139 /* A configure-based build is being used. */
145 /* A configure-based build is not being used. */
146 #include <jasper/jas_pconf2.h>
152 ############################################################
153 # Checks for programs.
154 ############################################################
158 # In the ideal world, AC_PROG_CC_C11 would exist and work.
161 # Attempt to enable C11 support if available.
162 # If C11 support is not available, attempt to fall back on C99 support
164 AX_CHECK_COMPILE_FLAG([-std=c11], [AX_APPEND_FLAG([-std=c11])], [
165 AX_CHECK_COMPILE_FLAG([-std=c99], [AX_APPEND_FLAG([-std=c99])], [])
178 ############################################################
179 # Add a few other compiler flags.
180 ############################################################
182 if test "$GCC" = yes; then
183 CFLAGS="$CFLAGS -pedantic"
184 CFLAGS="$CFLAGS -Wall -Wno-unused"
185 #CFLAGS="$CFLAGS -W -Wformat -Wmissing-prototypes -Wstrict-prototypes"
188 AC_ARG_ENABLE(strict,
189 [ --disable-strict Disable pedantic errors.], [
190 case "${enableval}" in
196 AC_MSG_ERROR(bad value ${enableval} for --disable-strict)
202 if test $ENABLE_STRICT = yes; then
203 if test "$GCC" = yes; then
204 AX_APPEND_FLAG([-pedantic-errors])
208 ############################################################
209 # Check for the IJG JPEG library.
210 ############################################################
212 # Allow the user to explicitly specify whether the JPEG library is present.
213 AC_ARG_ENABLE(libjpeg,
214 [ --disable-libjpeg Force the IJG JPEG library to be ignored],
216 case "${enableval}" in
222 AC_MSG_ERROR(bad value ${enableval} for --disable-libjpeg)
225 ], ENABLE_LIBJPEG=yes)
228 if test $ENABLE_LIBJPEG = yes; then
229 # Check for the JPEG library.
230 AC_CHECK_LIB(jpeg, jpeg_destroy, HAVE_LIBJPEG=yes, HAVE_LIBJPEG=no)
231 if test $HAVE_LIBJPEG = yes; then
235 AM_CONDITIONAL(HAVE_LIBJPEG, test $HAVE_LIBJPEG = yes)
237 ############################################################
238 # Check for OpenGL libraries.
239 ############################################################
241 AC_ARG_WITH(glut-include-dir,
242 [ --with-glut-include-dir=DIR Set GLUT include directory.],
246 CFLAGS="$CFLAGS -I$withval"
247 CPPFLAGS="$CPPFLAGS -I$withval";;
249 AC_MSG_ERROR(--with-glut-include-dir requires absolute path)
254 AC_ARG_WITH(glut-lib-dir,
255 [ --with-glut-lib-dir=DIR Set GLUT library directory.],
259 LIBS="$LIBS -L$withval";;
261 AC_MSG_ERROR(--with-glut-lib-dir requires absolute path)
267 AC_ARG_ENABLE(opengl,
268 [ --disable-opengl Disable use of OpenGL. ],
276 AC_MSG_ERROR(bad value ${enableval} for --disable-libjpeg)
284 if test $ENABLE_OPENGL = yes; then
285 if test $HAVE_OPENGL = no; then
286 TMPLIBS="-lglut -lGL -lGLU"
287 AC_CHECK_LIB(glut, glutInit, [HAVE_OPENGL=yes;
288 OPENGL_LIBS=$TMPLIBS], HAVE_OPENGL=no, $TMPLIBS)
290 AC_CHECK_HEADER(GL/glut.h,, [HAVE_OPENGL=no; OPENGL_LIBS="";])
293 AM_CONDITIONAL(HAVE_OPENGL, test $HAVE_OPENGL = yes)
294 AC_SUBST(OPENGL_LIBS)
295 AC_MSG_CHECKING([whether OpenGL libraries and headers were detected])
296 AC_MSG_RESULT($HAVE_OPENGL)
298 ############################################################
299 # Check for other libraries.
300 ############################################################
302 # Check for the math library.
303 AC_CHECK_LIB(m, main)
305 ############################################################
306 # Check for header files.
307 ############################################################
310 AC_CHECK_HEADERS(fcntl.h io.h unistd.h windows.h sys/time.h sys/types.h)
312 # Surely, there must be a better way to do this, but
313 # let's just get something working for now.
315 if test $ac_cv_header_fcntl_h = yes; then
316 AC_SUBST([JAS_HAVE_FCNTL_H], ["#define JAS_HAVE_FCNTL_H 1"])
318 AC_SUBST([JAS_HAVE_FCNTL_H], ["#undef JAS_HAVE_FCNTL_H"])
321 if test $ac_cv_header_io_h = yes; then
322 AC_SUBST([JAS_HAVE_IO_H], ["#define JAS_HAVE_IO_H 1"])
324 AC_SUBST([JAS_HAVE_IO_H], ["#undef JAS_HAVE_IO_H"])
327 if test $ac_cv_header_unistd_h = yes; then
328 AC_SUBST([JAS_HAVE_UNISTD_H], ["#define JAS_HAVE_UNISTD_H 1"])
330 AC_SUBST([JAS_HAVE_UNISTD_H], ["#undef JAS_HAVE_UNISTD_H"])
333 if test $ac_cv_header_windows_h = yes; then
334 AC_SUBST([JAS_HAVE_WINDOWS_H], ["#define JAS_HAVE_WINDOWS_H 1"])
336 AC_SUBST([JAS_HAVE_WINDOWS_H], ["#undef JAS_HAVE_WINDOWS_H"])
339 if test $ac_cv_header_sys_time_h = yes; then
340 AC_SUBST([JAS_HAVE_SYS_TIME_H], ["#define JAS_HAVE_SYS_TIME_H 1"])
342 AC_SUBST([JAS_HAVE_SYS_TIME_H], ["#undef JAS_HAVE_SYS_TIME_H"])
345 if test $ac_cv_header_sys_types_h = yes; then
346 AC_SUBST([JAS_HAVE_SYS_TYPES_H], ["#define JAS_HAVE_SYS_TYPES_H 1"])
348 AC_SUBST([JAS_HAVE_SYS_TYPES_H], ["#undef JAS_HAVE_SYS_TYPES_H"])
351 ############################################################
352 # Check for typedefs, structures, and compiler characteristics.
353 ############################################################
358 dnl AC_CHECK_TYPE(uchar, unsigned char)
359 dnl AC_CHECK_TYPE(ushort, unsigned short)
360 dnl AC_CHECK_TYPE(uint, unsigned int)
361 dnl AC_CHECK_TYPE(ulong, unsigned long)
362 dnl AC_CHECK_TYPE(longlong, long long)
363 dnl AC_CHECK_TYPE(ulonglong, unsigned long long)
364 dnl AC_CHECK_TYPE(ssize_t, int)
365 AC_CHECK_FUNCS(gettimeofday)
366 AC_CHECK_FUNCS(getrusage)
368 if test $ac_cv_func_gettimeofday = yes; then
369 AC_SUBST([JAS_HAVE_GETTIMEOFDAY], ["#define JAS_HAVE_GETTIMEOFDAY 1"])
371 AC_SUBST([JAS_HAVE_GETTIMEOFDAY], ["#undef JAS_HAVE_GETTIMEOFDAY"])
374 if test $ac_cv_func_getrusage = yes; then
375 AC_SUBST([JAS_HAVE_GETRUSAGE], ["#define JAS_HAVE_GETRUSAGE 1"])
377 AC_SUBST([JAS_HAVE_GETRUSAGE], ["#undef JAS_HAVE_GETRUSAGE"])
380 ############################################################
381 # Checks for library functions.
382 ############################################################
386 ############################################################
387 # Enable memory limit feature.
388 ############################################################
390 AC_ARG_ENABLE(memory-limit,
391 [ --enable-memory-limit=[ARG] Set memory limit to ARG (where ARG defaults to SIZE_MAX).],
393 if test "${enableval}" != no; then
394 if test "${enableval}" = yes; then
397 AC_DEFINE_UNQUOTED([JAS_DEFAULT_MAX_MEM_USAGE],
399 [Maximum memory usage limit])
404 ############################################################
405 # Enable/disable sanitizers.
406 ############################################################
409 [ --enable-asan Enable Address Sanitizer.],
411 case "${enableval}" in
413 CFLAGS="$CFLAGS -fsanitize=address"
414 LDFLAGS="$LDFLAGS -fsanitize=address"
421 [ --enable-usan Enable Undefined-Behavior Sanitizer.],
423 case "${enableval}" in
425 CFLAGS="$CFLAGS -fsanitize=undefined"
426 LDFLAGS="$LDFLAGS -fsanitize=undefined"
432 [ --enable-leak Enable Leak Sanitizer.],
434 case "${enableval}" in
436 CFLAGS="$CFLAGS -fsanitize=leak"
437 LDFLAGS="$LDFLAGS -fsanitize=leak"
443 [ --enable-msan Enable Memory Sanitizer.],
445 case "${enableval}" in
447 CFLAGS="$CFLAGS -fsanitize=memory"
448 LDFLAGS="$LDFLAGS -fsanitize=memory"
453 ############################################################
454 # Enable/disable extra code for debugging.
455 ############################################################
458 [ --enable-debug add extra code for debugging],
460 case "${enableval}" in
464 AC_DEFINE(DEBUG_OVERFLOW)
465 if test "$GCC" = yes; then
467 CFLAGS="$CFLAGS -g -O0"
474 AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
479 ############################################################
481 ############################################################
483 if test -n "$EXTRA_CFLAGS"; then
484 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
487 ############################################################
488 # Generate the configuration header file.
489 ############################################################
491 # The private header file generated by AC_CONFIG_HEADERS is not
492 # currently used. This just causes less verbose command lines
494 AC_CONFIG_HEADERS([src/libjasper/include/jasper/jas_pconf.h])
496 ############################################################
497 # Generate the makefiles.
498 ############################################################
501 src/libjasper/include/jasper/jas_config.h
505 src/libjasper/Makefile
506 src/libjasper/base/Makefile
507 src/libjasper/bmp/Makefile
508 src/libjasper/include/Makefile
509 src/libjasper/include/jasper/Makefile
510 src/libjasper/jp2/Makefile
511 src/libjasper/jpc/Makefile
512 src/libjasper/jpg/Makefile
513 src/libjasper/mif/Makefile
514 src/libjasper/pgx/Makefile
515 src/libjasper/pnm/Makefile
516 src/libjasper/ras/Makefile