kusano 7d535a
# IJG auto-configuration source file.
kusano 7d535a
# Process this file with autoconf to produce a configure script.
kusano 7d535a
kusano 7d535a
#
kusano 7d535a
# Configure script for IJG libjpeg
kusano 7d535a
#
kusano 7d535a
kusano 7d535a
AC_INIT([libjpeg], [9.0.0])
kusano 7d535a
kusano 7d535a
# Directory where autotools helper scripts lives.
kusano 7d535a
AC_CONFIG_AUX_DIR([.])
kusano 7d535a
kusano 7d535a
# Generate configuration headers.
kusano 7d535a
AC_CONFIG_HEADERS([jconfig.h:jconfig.cfg])
kusano 7d535a
kusano 7d535a
# Hack: disable autoheader so that it doesn't overwrite our cfg template.
kusano 7d535a
AUTOHEADER="echo autoheader ignored"
kusano 7d535a
kusano 7d535a
# Check system type
kusano 7d535a
AC_CANONICAL_TARGET
kusano 7d535a
kusano 7d535a
# Initialize Automake
kusano 7d535a
# Don't require all the GNU mandated files
kusano 7d535a
AM_INIT_AUTOMAKE([-Wall -Werror no-dist foreign])
kusano 7d535a
kusano 7d535a
# Make --enable-silent-rules the default.
kusano 7d535a
# To get verbose build output you may configure
kusano 7d535a
# with --disable-silent-rules or use "make V=1".
kusano 7d535a
AM_SILENT_RULES([yes])
kusano 7d535a
kusano 7d535a
# Add configure option --enable-maintainer-mode which enables
kusano 7d535a
# dependency checking and generation useful to package maintainers.
kusano 7d535a
# This is made an option to avoid confusing end users.
kusano 7d535a
AM_MAINTAINER_MODE
kusano 7d535a
kusano 7d535a
# Check for programs
kusano 7d535a
AC_PROG_CC
kusano 7d535a
AC_PROG_CC_STDC
kusano 7d535a
AC_PROG_CPP
kusano 7d535a
AC_PROG_INSTALL
kusano 7d535a
AC_PROG_MAKE_SET
kusano 7d535a
AC_PROG_LN_S
kusano 7d535a
AM_PROG_AR
kusano 7d535a
kusano 7d535a
# Check if LD supports linker scripts,
kusano 7d535a
# and define automake conditional HAVE_LD_VERSION_SCRIPT if so.
kusano 7d535a
AC_ARG_ENABLE([ld-version-script],
kusano 7d535a
  AS_HELP_STRING([--enable-ld-version-script],
kusano 7d535a
    [enable linker version script (default is enabled when possible)]),
kusano 7d535a
    [have_ld_version_script=$enableval], [])
kusano 7d535a
if test -z "$have_ld_version_script"; then
kusano 7d535a
  AC_MSG_CHECKING([if LD -Wl,--version-script works])
kusano 7d535a
  save_LDFLAGS="$LDFLAGS"
kusano 7d535a
  LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
kusano 7d535a
  cat > conftest.map <
kusano 7d535a
VERS_1 {
kusano 7d535a
        global: sym;
kusano 7d535a
};
kusano 7d535a
kusano 7d535a
VERS_2 {
kusano 7d535a
        global: sym;
kusano 7d535a
} VERS_1;
kusano 7d535a
EOF
kusano 7d535a
  AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
kusano 7d535a
                 [have_ld_version_script=yes], [have_ld_version_script=no])
kusano 7d535a
  rm -f conftest.map
kusano 7d535a
  LDFLAGS="$save_LDFLAGS"
kusano 7d535a
  AC_MSG_RESULT($have_ld_version_script)
kusano 7d535a
fi
kusano 7d535a
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
kusano 7d535a
kusano 7d535a
# See if compiler supports prototypes.
kusano 7d535a
AC_MSG_CHECKING([for function prototypes])
kusano 7d535a
AC_CACHE_VAL([ijg_cv_have_prototypes],
kusano 7d535a
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
kusano 7d535a
int testfunction (int arg1, int * arg2); /* check prototypes */
kusano 7d535a
struct methods_struct {		/* check method-pointer declarations */
kusano 7d535a
  int (*error_exit) (char *msgtext);
kusano 7d535a
  int (*trace_message) (char *msgtext);
kusano 7d535a
  int (*another_method) (void);
kusano 7d535a
};
kusano 7d535a
int testfunction (int arg1, int * arg2) /* check definitions */
kusano 7d535a
{ return arg2[arg1]; }
kusano 7d535a
int test2function (void)	/* check void arg list */
kusano 7d535a
{ return 0; }
kusano 7d535a
]])],
kusano 7d535a
          [ijg_cv_have_prototypes=yes],
kusano 7d535a
          [ijg_cv_have_prototypes=no])])
kusano 7d535a
AC_MSG_RESULT([$ijg_cv_have_prototypes])
kusano 7d535a
if test $ijg_cv_have_prototypes = yes; then
kusano 7d535a
  AC_DEFINE([HAVE_PROTOTYPES],[1],[Compiler supports function prototypes.])
kusano 7d535a
else
kusano 7d535a
  AC_MSG_WARN([Your compiler does not seem to know about function prototypes.
kusano 7d535a
    Perhaps it needs a special switch to enable ANSI C mode.
kusano 7d535a
    If so, we recommend running configure like this:
kusano 7d535a
       ./configure  CC='cc -switch'
kusano 7d535a
    where -switch is the proper switch.])
kusano 7d535a
fi
kusano 7d535a
kusano 7d535a
# Check header files
kusano 7d535a
AC_CHECK_HEADERS([stddef.h stdlib.h locale.h])
kusano 7d535a
AC_CHECK_HEADER([string.h], [],
kusano 7d535a
 [AC_DEFINE([NEED_BSD_STRINGS], [1],
kusano 7d535a
            [Compiler has <strings.h> rather than standard <string.h>.])])</string.h></strings.h>
kusano 7d535a
kusano 7d535a
# See whether type size_t is defined in any ANSI-standard places;
kusano 7d535a
# if not, perhaps it is defined in <sys types.h="">.</sys>
kusano 7d535a
AC_MSG_CHECKING([for size_t])
kusano 7d535a
AC_TRY_COMPILE([
kusano 7d535a
#ifdef HAVE_STDDEF_H
kusano 7d535a
#include <stddef.h></stddef.h>
kusano 7d535a
#endif
kusano 7d535a
#ifdef HAVE_STDLIB_H
kusano 7d535a
#include <stdlib.h></stdlib.h>
kusano 7d535a
#endif
kusano 7d535a
#include <stdio.h></stdio.h>
kusano 7d535a
#ifdef NEED_BSD_STRINGS
kusano 7d535a
#include <strings.h></strings.h>
kusano 7d535a
#else
kusano 7d535a
#include <string.h></string.h>
kusano 7d535a
#endif
kusano 7d535a
typedef size_t my_size_t;
kusano 7d535a
],
kusano 7d535a
      [ my_size_t foovar; ],
kusano 7d535a
      [ijg_size_t_ok=yes],
kusano 7d535a
      [ijg_size_t_ok="not ANSI, perhaps it is in sys/types.h"])
kusano 7d535a
AC_MSG_RESULT([$ijg_size_t_ok])
kusano 7d535a
if test "$ijg_size_t_ok" != yes; then
kusano 7d535a
  AC_CHECK_HEADER([sys/types.h],
kusano 7d535a
     [AC_DEFINE([NEED_SYS_TYPES_H], [1],
kusano 7d535a
                [Need to include <sys types.h=""> in order to obtain size_t.])</sys>
kusano 7d535a
      AC_EGREP_CPP([size_t], [#include <sys types.h="">],</sys>
kusano 7d535a
                   [ijg_size_t_ok="size_t is in sys/types.h"],
kusano 7d535a
                   [ijg_size_t_ok=no])],
kusano 7d535a
     [ijg_size_t_ok=no])
kusano 7d535a
  AC_MSG_RESULT([$ijg_size_t_ok])
kusano 7d535a
  if test "$ijg_size_t_ok" = no; then
kusano 7d535a
    AC_MSG_WARN([Type size_t is not defined in any of the usual places.
kusano 7d535a
      Try putting '"typedef unsigned int size_t;"' in jconfig.h.])
kusano 7d535a
  fi
kusano 7d535a
fi
kusano 7d535a
kusano 7d535a
# Check compiler characteristics
kusano 7d535a
AC_MSG_CHECKING([for type unsigned char])
kusano 7d535a
AC_TRY_COMPILE([], [ unsigned char un_char; ],
kusano 7d535a
 [AC_MSG_RESULT(yes)
kusano 7d535a
  AC_DEFINE([HAVE_UNSIGNED_CHAR], [1],
kusano 7d535a
            [Compiler supports 'unsigned char'.])],
kusano 7d535a
 [AC_MSG_RESULT(no)])
kusano 7d535a
kusano 7d535a
AC_MSG_CHECKING([for type unsigned short])
kusano 7d535a
AC_TRY_COMPILE([], [ unsigned short un_short; ],
kusano 7d535a
  [AC_MSG_RESULT(yes)
kusano 7d535a
   AC_DEFINE([HAVE_UNSIGNED_SHORT], [1],
kusano 7d535a
             [Compiler supports 'unsigned short'.])],
kusano 7d535a
  [AC_MSG_RESULT(no)])
kusano 7d535a
kusano 7d535a
AC_MSG_CHECKING([for type void])
kusano 7d535a
AC_TRY_COMPILE([
kusano 7d535a
/* Caution: a C++ compiler will insist on valid prototypes */
kusano 7d535a
typedef void * void_ptr;	/* check void * */
kusano 7d535a
#ifdef HAVE_PROTOTYPES		/* check ptr to function returning void */
kusano 7d535a
typedef void (*void_func) (int a, int b);
kusano 7d535a
#else
kusano 7d535a
typedef void (*void_func) ();
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifdef HAVE_PROTOTYPES		/* check void function result */
kusano 7d535a
void test3function (void_ptr arg1, void_func arg2)
kusano 7d535a
#else
kusano 7d535a
void test3function (arg1, arg2)
kusano 7d535a
     void_ptr arg1;
kusano 7d535a
     void_func arg2;
kusano 7d535a
#endif
kusano 7d535a
{
kusano 7d535a
  char * locptr = (char *) arg1; /* check casting to and from void * */
kusano 7d535a
  arg1 = (void *) locptr;
kusano 7d535a
  (*arg2) (1, 2);		/* check call of fcn returning void */
kusano 7d535a
}
kusano 7d535a
], [ ],
kusano 7d535a
        [AC_MSG_RESULT(yes)],
kusano 7d535a
        [AC_MSG_RESULT(no)
kusano 7d535a
         AC_DEFINE([void], [char],
kusano 7d535a
                   [Define 'void' as 'char' for archaic compilers
kusano 7d535a
                    that don't understand it.])])
kusano 7d535a
AC_C_CONST
kusano 7d535a
kusano 7d535a
# Check for non-broken inline under various spellings
kusano 7d535a
AC_MSG_CHECKING([for inline])
kusano 7d535a
ijg_cv_inline=""
kusano 7d535a
AC_TRY_COMPILE([], [} __inline__ int foo() { return 0; }
kusano 7d535a
int bar() { return foo();], ijg_cv_inline="__inline__",
kusano 7d535a
[AC_TRY_COMPILE(, [} __inline int foo() { return 0; }
kusano 7d535a
int bar() { return foo();], ijg_cv_inline="__inline",
kusano 7d535a
[AC_TRY_COMPILE(, [} inline int foo() { return 0; }
kusano 7d535a
int bar() { return foo();], ijg_cv_inline="inline")])])
kusano 7d535a
AC_MSG_RESULT($ijg_cv_inline)
kusano 7d535a
AC_DEFINE_UNQUOTED([INLINE], [$ijg_cv_inline],
kusano 7d535a
                   [How to obtain function inlining.])
kusano 7d535a
kusano 7d535a
# We cannot check for bogus warnings, but at least we can check for errors
kusano 7d535a
AC_MSG_CHECKING([for broken incomplete types])
kusano 7d535a
AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ],
kusano 7d535a
               [],
kusano 7d535a
               [AC_MSG_RESULT(ok)],
kusano 7d535a
               [AC_MSG_RESULT(broken)
kusano 7d535a
                AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
kusano 7d535a
                          [Compiler does not support pointers to unspecified
kusano 7d535a
                           structures.])])
kusano 7d535a
kusano 7d535a
# Test whether global names are unique to at least 15 chars
kusano 7d535a
AC_MSG_CHECKING([for short external names])
kusano 7d535a
AC_TRY_LINK([
kusano 7d535a
int possibly_duplicate_function () { return 0; }
kusano 7d535a
int possibly_dupli_function () { return 1; }
kusano 7d535a
], [],
kusano 7d535a
            [AC_MSG_RESULT(ok)],
kusano 7d535a
            [AC_MSG_RESULT(short)
kusano 7d535a
             AC_DEFINE([NEED_SHORT_EXTERNAL_NAMES], [1],
kusano 7d535a
                       [Linker requires that global names be unique in
kusano 7d535a
                        first 15 characters.])])
kusano 7d535a
kusano 7d535a
# Run-time checks
kusano 7d535a
AC_MSG_CHECKING([to see if char is signed])
kusano 7d535a
AC_TRY_RUN([
kusano 7d535a
#ifdef HAVE_STDLIB_H
kusano 7d535a
#include <stdlib.h></stdlib.h>
kusano 7d535a
#endif
kusano 7d535a
#include <stdio.h></stdio.h>
kusano 7d535a
#ifdef HAVE_PROTOTYPES
kusano 7d535a
int is_char_signed (int arg)
kusano 7d535a
#else
kusano 7d535a
int is_char_signed (arg)
kusano 7d535a
     int arg;
kusano 7d535a
#endif
kusano 7d535a
{
kusano 7d535a
  if (arg == 189) {		/* expected result for unsigned char */
kusano 7d535a
    return 0;			/* type char is unsigned */
kusano 7d535a
  }
kusano 7d535a
  else if (arg != -67) {	/* expected result for signed char */
kusano 7d535a
    printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
kusano 7d535a
    printf("I fear the JPEG software will not work at all.\n\n");
kusano 7d535a
  }
kusano 7d535a
  return 1;			/* assume char is signed otherwise */
kusano 7d535a
}
kusano 7d535a
char signed_char_check = (char) (-67);
kusano 7d535a
int main() {
kusano 7d535a
  exit(is_char_signed((int) signed_char_check));
kusano 7d535a
}], [AC_MSG_RESULT(no)
kusano 7d535a
     AC_DEFINE([CHAR_IS_UNSIGNED], [1],
kusano 7d535a
               [Characters are unsigned])],
kusano 7d535a
               [AC_MSG_RESULT(yes)],
kusano 7d535a
[AC_MSG_WARN([Assuming that char is signed on target machine.
kusano 7d535a
    If it is unsigned, this will be a little bit inefficient.])
kusano 7d535a
])
kusano 7d535a
kusano 7d535a
AC_MSG_CHECKING([to see if right shift is signed])
kusano 7d535a
AC_TRY_RUN([
kusano 7d535a
#ifdef HAVE_STDLIB_H
kusano 7d535a
#include <stdlib.h></stdlib.h>
kusano 7d535a
#endif
kusano 7d535a
#include <stdio.h></stdio.h>
kusano 7d535a
#ifdef HAVE_PROTOTYPES
kusano 7d535a
int is_shifting_signed (long arg)
kusano 7d535a
#else
kusano 7d535a
int is_shifting_signed (arg)
kusano 7d535a
     long arg;
kusano 7d535a
#endif
kusano 7d535a
/* See whether right-shift on a long is signed or not. */
kusano 7d535a
{
kusano 7d535a
  long res = arg >> 4;
kusano 7d535a
kusano 7d535a
  if (res == -0x7F7E80CL) {	/* expected result for signed shift */
kusano 7d535a
    return 1;			/* right shift is signed */
kusano 7d535a
  }
kusano 7d535a
  /* see if unsigned-shift hack will fix it. */
kusano 7d535a
  /* we can't just test exact value since it depends on width of long... */
kusano 7d535a
  res |= (~0L) << (32-4);
kusano 7d535a
  if (res == -0x7F7E80CL) {	/* expected result now? */
kusano 7d535a
    return 0;			/* right shift is unsigned */
kusano 7d535a
  }
kusano 7d535a
  printf("Right shift isn't acting as I expect it to.\n");
kusano 7d535a
  printf("I fear the JPEG software will not work at all.\n\n");
kusano 7d535a
  return 0;			/* try it with unsigned anyway */
kusano 7d535a
}
kusano 7d535a
int main() {
kusano 7d535a
  exit(is_shifting_signed(-0x7F7E80B1L));
kusano 7d535a
}],
kusano 7d535a
      [AC_MSG_RESULT(no)
kusano 7d535a
       AC_DEFINE([RIGHT_SHIFT_IS_UNSIGNED], [1],
kusano 7d535a
                 [Broken compiler shifts signed values as an unsigned shift.])],
kusano 7d535a
       [AC_MSG_RESULT(yes)],
kusano 7d535a
       [AC_MSG_RESULT(Assuming that right shift is signed on target machine.)])
kusano 7d535a
kusano 7d535a
AC_MSG_CHECKING([to see if fopen accepts b spec])
kusano 7d535a
AC_TRY_RUN([
kusano 7d535a
#ifdef HAVE_STDLIB_H
kusano 7d535a
#include <stdlib.h></stdlib.h>
kusano 7d535a
#endif
kusano 7d535a
#include <stdio.h></stdio.h>
kusano 7d535a
int main() {
kusano 7d535a
  if (fopen("conftestdata", "wb") != NULL)
kusano 7d535a
    exit(0);
kusano 7d535a
  exit(1);
kusano 7d535a
}],
kusano 7d535a
          [AC_MSG_RESULT(yes)],
kusano 7d535a
          [AC_MSG_RESULT(no)
kusano 7d535a
           AC_DEFINE([DONT_USE_B_MODE], [1],
kusano 7d535a
                     [Don't open files in binary mode.])],
kusano 7d535a
          [AC_MSG_RESULT(Assuming that it does.)])
kusano 7d535a
kusano 7d535a
# Configure libtool
kusano 7d535a
AC_LIBTOOL_WIN32_DLL
kusano 7d535a
AC_PROG_LIBTOOL
kusano 7d535a
kusano 7d535a
# Select memory manager depending on user input.
kusano 7d535a
# If no "-enable-maxmem", use jmemnobs
kusano 7d535a
MEMORYMGR='jmemnobs'
kusano 7d535a
MAXMEM="no"
kusano 7d535a
AC_ARG_ENABLE([maxmem],
kusano 7d535a
[  --enable-maxmem[=N]     enable use of temp files, set max mem usage to N MB],
kusano 7d535a
[MAXMEM="$enableval"])
kusano 7d535a
dnl [# support --with-maxmem for backwards compatibility with IJG V5.]
kusano 7d535a
dnl AC_ARG_WITH(maxmem, , MAXMEM="$withval")
kusano 7d535a
if test "x$MAXMEM" = xyes; then
kusano 7d535a
  MAXMEM=1
kusano 7d535a
fi
kusano 7d535a
if test "x$MAXMEM" != xno; then
kusano 7d535a
  if test -n "`echo $MAXMEM | sed 's/[[0-9]]//g'`"; then
kusano 7d535a
    AC_MSG_ERROR(non-numeric argument to --enable-maxmem)
kusano 7d535a
  fi
kusano 7d535a
  DEFAULTMAXMEM=`expr $MAXMEM \* 1048576`
kusano 7d535a
  AC_DEFINE_UNQUOTED([DEFAULT_MAX_MEM], [${DEFAULTMAXMEM}],
kusano 7d535a
                     [Maximum data space library will allocate.])
kusano 7d535a
  AC_MSG_CHECKING([for 'tmpfile()'])
kusano 7d535a
  AC_TRY_LINK([#include <stdio.h>], [ FILE * tfile = tmpfile(); ],</stdio.h>
kusano 7d535a
    [AC_MSG_RESULT(yes)
kusano 7d535a
    MEMORYMGR='jmemansi'],
kusano 7d535a
    [AC_MSG_RESULT(no)
kusano 7d535a
    dnl if tmpfile is not present, must use jmemname.
kusano 7d535a
    MEMORYMGR='jmemname'
kusano 7d535a
kusano 7d535a
    # Test for the need to remove temporary files using a signal handler
kusano 7d535a
    # (for cjpeg/djpeg)
kusano 7d535a
    AC_DEFINE([NEED_SIGNAL_CATCHER], [1],
kusano 7d535a
              [Need signal handler to clean up temporary files.])
kusano 7d535a
    AC_MSG_CHECKING([for 'mktemp()'])
kusano 7d535a
    AC_TRY_LINK([], [ char fname[80]; mktemp(fname); ],
kusano 7d535a
                [AC_MSG_RESULT(yes)],
kusano 7d535a
                [AC_MSG_RESULT(no)
kusano 7d535a
                 AC_DEFINE([NO_MKTEMP], [1],
kusano 7d535a
                           [The mktemp() function is not available.])])])
kusano 7d535a
fi
kusano 7d535a
AC_SUBST([MEMORYMGR])
kusano 7d535a
kusano 7d535a
# Extract the library version IDs from jpeglib.h.
kusano 7d535a
AC_MSG_CHECKING([libjpeg version number])
kusano 7d535a
[major=`sed -ne 's/^#define JPEG_LIB_VERSION_MAJOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`
kusano 7d535a
minor=`sed -ne 's/^#define JPEG_LIB_VERSION_MINOR *\([0-9][0-9]*\).*$/\1/p' $srcdir/jpeglib.h`]
kusano 7d535a
AC_SUBST([JPEG_LIB_VERSION],
kusano 7d535a
         [`expr $major + $minor`:0:$minor])
kusano 7d535a
AC_MSG_RESULT([$JPEG_LIB_VERSION])
kusano 7d535a
kusano 7d535a
AC_CONFIG_FILES([Makefile])
kusano 7d535a
AC_OUTPUT