Blob Blame History Raw
dnl Copyright (C) 2007-2010 Hubert Figuiere
dnl Small portions are:
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License.  As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.

AC_PREREQ(2.50)
AC_INIT(exempi, 2.4.5)
AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
AM_MAINTAINER_MODE
m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
AM_SILENT_RULES([yes])

dnl ---------------------------------------------------------------------------
dnl Advanced information about versioning:
dnl   * "Writing shared libraries" by Mike Hearn
dnl         http://plan99.net/~mike/writing-shared-libraries.html
dnl   * libtool.info chapter "Versioning"
dnl   * libtool.info chapter "Updating library version information"
dnl ---------------------------------------------------------------------------
dnl Versioning:
dnl  - CURRENT (Major):  Increment if the interface has changes. AGE is always
dnl                      *changed* at the same time.
dnl  - AGE (Micro):      Increment if any interfaces have been added; set to 0
dnl                      if any interfaces have been removed. Removal has
dnl                      precedence over adding, so set to 0 if both happened.
dnl                      It denotes upward compatibility.
dnl  - REVISION (Minor): Increment any time the source changes; set to
dnl                      0 if you incremented CURRENT.
dnl
dnl  To summarize. Any interface *change* increment CURRENT. If that interface
dnl  change does not break upward compatibility (ie it is an addition),
dnl  increment AGE, Otherwise AGE is reset to 0. If CURRENT has changed,
dnl  REVISION is set to 0, otherwise REVISION is incremented.
dnl ---------------------------------------------------------------------------
dnl 1.99.0 is the revision 2 0 0
dnl 1.99.1 is the revision 3 1 0
dnl 1.99.2 is the revision 4 2 0
dnl 1.99.3 is the revision 5 3 0
dnl 1.99.4 is the revision 6 4 0
dnl ABI breakage reset major to 3
dnl 1.99.5 is the revision 3.0.0
dnl 1.99.6 is the revision 3.1.0 WHICH IS WRONG!!!
dnl 1.99.7 is the revision 4.1.0
dnl 1.99.8 is the revision 4.1.1
dnl 1.99.9 is the revision 4.1.1 (no library change have been made)
dnl 2.0.0 is the revision 4.1.2
dnl 2.0.1 is the revision 4.1.3
dnl 2.0.2 is the revision 4.1.4
dnl 2.1.0 is the revision 5.2.0
dnl 2.1.1 is the revision 5.2.1
dnl 2.2.0 is the revision 5.2.2 -- no public API change
dnl 2.2.1 is the revision 5.2.3 -- no public API change
dnl 2.2.2 is the revision 5.2.4 -- no public API change
dnl 2.2.3 is the revision 5.2.5 -- no public API change
dnl 2.3.0 is the revision 6.3.0
dnl 2.4.0 is the revision 7.4.0
dnl 2.4.1 is the revision 7.4.1
dnl 2.4.2 is the revision 7.4.2
dnl 2.4.3 is the revision 7.4.3
dnl 2.4.4 is the revision 7.4.4
dnl 2.4.5 is the revision 7.4.5
AC_SUBST([EXEMPI_REVISION], [5])
AC_SUBST([EXEMPI_AGE],      [4])
AC_SUBST([EXEMPI_CURRENT],  [7])
AC_SUBST([EXEMPI_CURRENT_MIN],
         [`expr $EXEMPI_CURRENT - $EXEMPI_AGE`])
AC_SUBST([EXEMPI_VERSION_INFO],
         [$EXEMPI_CURRENT:$EXEMPI_REVISION:$EXEMPI_AGE])

dnl the major version. used for package names, etc
EXEMPI_MAJOR_VERSION=2.0
AC_SUBST(EXEMPI_MAJOR_VERSION)

dnl the path where includes are installed
EXEMPI_INCLUDE_BASE=exempi-$EXEMPI_MAJOR_VERSION
AC_SUBST(EXEMPI_INCLUDE_BASE)

dnl --------------------------------------------------------------------
dnl guess directory to install *.pc into
dnl --------------------------------------------------------------------
pkgconfigdir='${libdir}/pkgconfig'
AC_SUBST(pkgconfigdir)

AC_CONFIG_MACRO_DIR([m4])

AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AX_CXX_COMPILE_STDCXX_11(noext,mandatory)

AC_C_BIGENDIAN
AC_DEFINE(CHECKED_ENDIANNESS)

AC_ARG_WITH(darwinports,[  --with-darwinports     add /opt/local/... to CPP/LDFLAGS (Mac OSX)],[
        if test "x$withval" != "xno"; then
                CPPFLAGS="$CPPFLAGS -I/opt/local/include"
                LDFLAGS="$LDFLAGS -L/opt/local/lib"
		CC=g++
        fi
])
AC_ARG_WITH(fink,[  --with-fink          add /sw/... to CPP/LDFLAGS (Mac OSX)],[
        if test "x$withval" != "xno"; then
                CPPFLAGS="$CPPFLAGS -I/sw/include"
                LDFLAGS="$LDFLAGS -L/sw/lib"
		CC=g++
        fi
])


AC_CHECK_HEADER(expat.h, ,
	 AC_MSG_ERROR([expat headers missing]))
AC_CHECK_HEADER(iconv.h, ,
	 AC_MSG_ERROR([iconv headers missing]))
AC_CHECK_HEADER(zlib.h, ,
	 AC_MSG_ERROR([zlib headers missing]))

dnl Blatently copied from iconv.m4 to remove the crack about libtool
dnl But check for constness of the iconv parameters.
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [
      AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
         }[$]am_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
      [Define as const if the declaration of iconv() needs const.])
dnl end iconv checks


dnl TLS.
AX_TLS
if test "$ac_cv_tls" != "none"; then
   AC_DEFINE(HAVE_NATIVE_TLS, [1], [Define if compiler has native TLS.])
fi
dnl end TLS

dnl check LD Flags
dnl we need a valid symfile. Make one.
cat >> _ac_foo.sym << _ACEOF
foo
_ACEOF
AX_LD_CHECK_FLAG([-Wl,--retain-symbols-file=_ac_foo.sym],[],[],[
dnl success
cv_support_symfile=yes
],[
dnl fail
cv_support_symfile=no
])
rm -f _ac_foo.sym
AM_CONDITIONAL(HAVE_SYMBOLS_FILE, test x$cv_support_symfile = "xyes")


AC_ARG_ENABLE(unittest,
              AC_HELP_STRING([--enable-unittest=yes|no],
                            [enable the unittest. requires boost (default is yes)]),
              ENABLE_UNITTEST=$enableval,
              ENABLE_UNITTEST=yes)
if test x$ENABLE_UNITTEST = xyes ; then
   BOOST_REQUIRE([1.48.0])
   BOOST_TEST([mt-s])
else
   ENABLE_UNITTEST=no
fi


case $build_vendor in
	apple)
		EXEMPI_PLATFORM_DEF=MAC_ENV
		LDFLAGS="$LDFLAGS -framework CoreServices -stdlib=libc++"
		CPPFLAGS="$CPPFLAGS -std=c++11 -stdlib=libc++"
		;;
	*)
		EXEMPI_PLATFORM_DEF=UNIX_ENV
		;;
esac

AC_SUBST(EXEMPI_PLATFORM_DEF)
AM_CONDITIONAL(MAC_ENV, test x$EXEMPI_PLATFORM_DEF = xMAC_ENV)
AM_CONDITIONAL(UNIX_ENV, test x$EXEMPI_PLATFORM_DEF = xUNIX_ENV)

AM_CONDITIONAL(WITH_UNIT_TEST, test x$ENABLE_UNITTEST = xyes)

dnl Check for valgrind (optional) for make check.
dnl AC_CHECK_PROG(VALGRIND, valgrind, valgrind)
AC_CHECK_HEADERS(valgrind/memcheck.h)
if test "$VALGRIND" = ""; then
        AC_MSG_WARN([Valgrind is missing. checks will run without])
fi
if test "$VALGRIND" != ""; then
dnl due to stupid m4 I had to double the [ and ] in the regexp
        vg_ver=`valgrind --version | sed -e  's/.*-\([[0-9]]\)\.[[0-9]].*/\1/'`
        VALGRIND="$VALGRIND --tool=memcheck --leak-check=yes --num-callers=10 --error-exitcode=100"
        if test "$vg_ver" != "3" ; then
           VALGRIND="$VALGRIND --logfile-fd=-1"
        fi
fi
AC_SUBST(VALGRIND)

AC_ARG_ENABLE(asan,[  --enable-asan    Turn on address sanitizer],[
    AX_CFLAGS_GCC_OPTION([-fsanitize=address -fno-omit-frame-pointer])
    AX_CXXFLAGS_GCC_OPTION([-fsanitize=address -fno-omit-frame-pointer])
]
,
[

])

XMPCORE_CPPFLAGS="-D$EXEMPI_PLATFORM_DEF=1 -DXMP_IMPL=1 -DXMP_ClientBuild=0 \
	-DXMP_StaticBuild=1 -DBanAllEntityUsage=1 \
	-D_FILE_OFFSET_BITS=64 -DHAVE_EXPAT_CONFIG_H=1 -DXML_STATIC=1 \
	-DDISABLE_QUICKTIME"
AC_SUBST(XMPCORE_CPPFLAGS)

AC_OUTPUT([
Makefile
third-party/Makefile
third-party/zuid/interfaces/Makefile
third-party/zlib/Makefile
third-party/expat/Makefile
source/Makefile
XMPCore/Makefile
XMPCore/source/Makefile
XMPFiles/Makefile
XMPFiles/source/Makefile
XMPFiles/source/FileHandlers/Makefile
XMPFiles/source/FormatSupport/Makefile
XMPFiles/source/NativeMetadataSupport/Makefile
XMPFiles/source/PluginHandler/Makefile
XMPFilesPlugins/Makefile
XMPFilesPlugins/api/Makefile
XMPFilesPlugins/api/source/Makefile
XMPFilesPlugins/PDF_Handler/Makefile
samples/Makefile
samples/source/Makefile
samples/testfiles/Makefile
build/GNUmakefile
public/Makefile
public/include/Makefile
public/include/client-glue/Makefile
exempi/Makefile
exempi/doc/Makefile
exempi/doc/Doxyfile
exempi/tests/Makefile
exempi/exempi-2.0.pc
])


echo "
Defines:

   EXEMPI_PLATFORM_DEF  = $EXEMPI_PLATFORM_DEF
   CPPFLAGS             = $CPPFLAGS
   LDFLAGS              = $LDFLAGS
   Thread Local Storage = $ac_cv_tls
   Run unit test        = $ENABLE_UNITTEST
"