#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

# Copyright (C) 2000-2012 by George Williams
# Copyright (C) 2012 by Barry Schwartz
# Copyright (C) 2013 by Ben Martin
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

AC_PREREQ([2.68])
#--------------------------------------------------------------------------
# PackageTimestamp version
m4_define([fontforge_package_stamp], [20140101])
#--------------------------------------------------------------------------
# Making point releases:
#   fontforge_major_version += 0;
#   fontforge_minor_version += 1; (patches or added function(s))
#
# If any new functions have been added:
#   fontforge_major_version += 0;
#   fontforge_minor_version += 1; (added function(s))
#
# If backwards compatibility has been broken:
#   fontforge_major_version += 1;
#   fontforge_minor_version = 0;
#
m4_define([fontforge_major_version], [2]) dnl 20120731-b was 1.0
m4_define([fontforge_minor_version], [0])
m4_define([libgdraw_major_version], [5]) dnl 20120731-b was 4.10
m4_define([libgdraw_minor_version], [0])
m4_define([libgioftp_major_version], [2]) dnl 20120731-b was 1.0
m4_define([libgioftp_minor_version], [0])
m4_define([libgunicode_major_version], [4]) dnl 20120731-b was 3.2
m4_define([libgunicode_minor_version], [0])
m4_define([libgutils_major_version], [2]) dnl 20120731-b was 1.3
m4_define([libgutils_minor_version], [0])
m4_define([libzmqcollab_major_version], [2]) dnl n/a
m4_define([libzmqcollab_minor_version], [0])
m4_define([libfontforgeexe_major_version], [fontforge_major_version]) dnl matches fontforge
m4_define([libfontforgeexe_minor_version], [fontforge_minor_version])
m4_define([libfontforge_major_version], [fontforge_major_version]) dnl matches fontforge
m4_define([libfontforge_minor_version], [fontforge_minor_version])

#--------------------------------------------------------------------------
# Setup variables before running AC_INIT()
m4_define([fontforge_version],
          [fontforge_major_version.fontforge_minor_version.fontforge_package_stamp])
#m4_define([fontforge_info],
#          [fontforge_major_version:fontforge_minor_version:0])
m4_define([fontforge_package_name], ["fontforge"])
m4_define([libfontforgeexe_info],[libfontforgeexe_major_version:libfontforgeexe_minor_version:0])
m4_define([libfontforge_info],[libfontforge_major_version:libfontforge_minor_version:0])
m4_define([libgdraw_info],[libgdraw_major_version:libgdraw_minor_version:0])
m4_define([libgioftp_info],[libgioftp_major_version:libgioftp_minor_version:0])
m4_define([libgunicode_info],[libgunicode_major_version:libgunicode_minor_version:0])
m4_define([libgutils_info],[libgutils_major_version:libgutils_minor_version:0])
m4_define([libzmqcollab_info],[libzmqcollab_major_version:libzmqcollab_minor_version:0])

#--------------------------------------------------------------------------
AC_INIT([fontforge],[fontforge_version],[fontforge-devel@lists.sourceforge.net],
	[fontforge_package_name],[https://github.com/fontforge/fontforge])
AC_CONFIG_SRCDIR([Unicode/ArabicForms.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_TESTDIR([tests],[fontforge])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CONFIG_HEADER([inc/fontforge-config.h])
AM_INIT_AUTOMAKE([foreign -Wall subdir-objects tar-pax])
AM_MAINTAINER_MODE([enable])
AC_USE_SYSTEM_EXTENSIONS

#--------------------------------------------------------------------------
# automake 1.12 requires AM_PROG_AR but automake 1.11 doesn't recognize it.
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

#--------------------------------------------------------------------------
# Enable silent build rules by default, this requires atleast Automake-1.11
# Disable by passing --disable-silent-rules to configure or using make V=1
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],[AC_SUBST([AM_DEFAULT_VERBOSITY],[1])])


LT_CONFIG_LTDL_DIR([libltdl])
LT_INIT([dlopen])
LTDL_INIT([recursive convenience])
FONTFORGE_CHECK_LTDL_VERSION

# The following is for the benefit of the libltdl Makefile,
# which expects to find <inc/fontforge-config.h> in top_builddir,
# and for some other things that use a path relative to top_srcdir.
CPPFLAGS="${CPPFLAGS} AS_ESCAPE([-I${top_builddir}]) AS_ESCAPE([-I${top_srcdir}])"


AC_PATH_XTRA
i_do_have_x="${have_x}"
i_do_have_gui="${i_do_have_x}"

AC_SUBST([HOST],["$host"])
AC_SUBST([MACAPP])

FONTFORGE_PLATFORM_SPECIFICS

#--------------------------------------------------------------------------
# Pass version variables to fontforge-config.h
AC_DEFINE([FONTFORGE_VERSION_MAJOR],[fontforge_major_version],[FontForge Major Version])
AC_DEFINE([FONTFORGE_VERSION_MINOR],[fontforge_minor_version],[FontForge Minor Version])
AC_DEFINE([FONTFORGE_LIBFFE_VERSION_MAJOR],[libfontforgeexe_major_version],[ExeLibFontForge Major Version])
AC_DEFINE([FONTFORGE_LIBFFE_VERSION_MINOR],[libfontforgeexe_minor_version],[ExeLibFontForge Minor Version])
AC_DEFINE([FONTFORGE_LIBFF_VERSION_MAJOR],[libfontforge_major_version],[LibFontForge Major Version])
AC_DEFINE([FONTFORGE_LIBFF_VERSION_MINOR],[libfontforge_minor_version],[LibFontForge Minor Version])

#--------------------------------------------------------------------------
# Pass library version variables to several MAKEFILE.AM
AC_SUBST([FONTFORGE_VERSION],[fontforge_version])
AC_SUBST([LIBFONTFORGEEXE_VERSION],[libfontforgeexe_info])
AC_SUBST([LIBFONTFORGE_VERSION],[libfontforge_info])
AC_SUBST([LIBGDRAW_VERSION],[libgdraw_info])
AC_SUBST([LIBGIOFTP_VERSION],[libgioftp_info])
AC_SUBST([LIBGUNICODE_VERSION],[libgunicode_info])
AC_SUBST([LIBGUTILS_VERSION],[libgutils_info])
AC_SUBST([LIBZMQCOLLAB_VERSION],[libzmqcollab_info])

AC_SUBST([VERSION_MAJOR],[fontforge_major_version])
AC_SUBST([VERSION_MINOR],[fontforge_minor_version])
AC_SUBST([VERSION_PATCH],[fontforge_package_stamp])

#--------------------------------------------------------------------------
# URLs for dependencies.

cairo_url="http://www.cairographics.org/"
freetype_url="http://www.freetype.org/"
giflib_url="http://giflib.sourceforge.net/"
libpng_url="http://www.libpng.org/"
libxml_url="http://www.xmlsoft.org/"
libspiro_url="https://github.com/fontforge/libspiro"
libuninameslist_url="https://github.com/fontforge/libuninameslist"
libunicodenames_url="https://bitbucket.org/sortsmill/libunicodenames"
libzmq_url="http://www.zeromq.org/"
libreadline_url="http://www.gnu.org/software/readline"

# Point to the Wikipedia page, primarily because one may want
# libjpeg-turbo rather than the reference implementation.
libjpeg_url="http://en.wikipedia.org/wiki/Libjpeg"

# Point to the Wikipedia page, so people can learn not to be fooled by
# the old website, which some while ago was hijacked by androids from
# beyond the orbit of Neptune.
libtiff_url="http://en.wikipedia.org/wiki/Libtiff"

#--------------------------------------------------------------------------
#
# Checks for programs.

AC_PROG_AWK
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_GREP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
AC_PROG_SED
PKG_PROG_PKG_CONFIG
AC_PATH_PROG([MSGFMT],[msgfmt],[msgfmt])
AC_PATH_PROG([XGETTEXT],[xgettext],[xgettext])
AC_PATH_PROG([INDENT],[indent],[indent])
AC_PATH_PROG([WGET],[wget],[wget])
AC_PATH_PROG([UNZIP],[unzip],[unzip])
AC_PATH_PROG([UPDATE_MIME_DATABASE],[update-mime-database],[update-mime-database])
AC_PATH_PROG([UPDATE_DESKTOP_DATABASE],[update-desktop-database],[update-desktop-database])
AC_PATH_PROG([PLUTIL],[plutil],[:])

FONTFORGE_ARG_ENABLE_REAL

AC_ARG_ENABLE([programs],
        [AS_HELP_STRING([--disable-programs],[do not build "fontforge" and related programs
                                              (but do build libraries and possibly the Python extensions)])],
        [i_do_have_programs="${enableval}"],
        [i_do_have_programs=yes])
AM_CONDITIONAL([THE_PROGRAMS],[test x"${i_do_have_programs}" = xyes])
AC_SUBST([THE_PROGRAMS],["${i_do_have_programs}"])

FONTFORGE_ARG_ENABLE([debug],
        [AS_HELP_STRING([--enable-debug],[Turn on debug build and FONTFORGE_DEBUG conditional code])],
        [FONTFORGE_DEBUG])
if test x$enable_debug = xyes ; then
    CFLAGS="$CFLAGS -g -O0"
    CPPFLAGS="$CPPFLAGS -g -O0"
fi

FONTFORGE_ARG_DISABLE([native-scripting],
        [AS_HELP_STRING([--disable-native-scripting],[disable the legacy fontforge scripting language])],
        [_NO_FFSCRIPT])
AM_CONDITIONAL([NATIVE_SCRIPTING],[test x"${i_do_have_native_scripting}" = xyes])

FONTFORGE_ARG_DISABLE_PYTHON_SCRIPTING
FONTFORGE_ARG_DISABLE_PYTHON_EXTENSION

AC_ARG_ENABLE([freetype-debugger],
        [AS_HELP_STRING([--enable-freetype-debugger[[=DIR]]],
                [use freetype's internal debugger within fontforge; requires source code of the
                 freetype library with which fontforge will be linked.
                 You need to set DIR to the top directory of the freetype sources,
                 or alternatively set the environment variable FREETYPE_SOURCE (see below)])],
        [i_do_have_freetype_debugger="${enableval}"],
        [AC_ARG_WITH([freetype-source],
                [AS_HELP_STRING([--with-freetype-source[[=DIR]]],[synonym for --enable-freetype-debugger])],
                [i_do_have_freetype_debugger="${withval}"],
                [i_do_have_freetype_debugger=no])])
# ' make syntax checkers happy

FONTFORGE_ARG_ENABLE([capslock-for-alt],
        [AS_HELP_STRING([--enable-capslock-for-alt],
                [use capslock rather than alt/meta to alter behavior of tools in outline/bitmap windows])],
        [FONTFORGE_CONFIG_CAPSLOCK_FOR_ALT])

FONTFORGE_ARG_ENABLE([debug-raw-points],
        [AS_HELP_STRING([--enable-debug-raw-points],
                [add a raw mode to the points window of the debugger])],
        [FONTFORGE_CONFIG_SHOW_RAW_POINTS])

FONTFORGE_ARG_ENABLE([tile-path],
        [AS_HELP_STRING([--enable-tile-path],
                [enable a 'tile path' command (a variant of 'expand stroke')])],
        [FONTFORGE_CONFIG_TILEPATH])

FONTFORGE_ARG_DISABLE([link-test],
        [AS_HELP_STRING([--disable-link-test],[disable the link test during build. Handy for cross compiling])],
        [_NO_FFLINKTEST])
AM_CONDITIONAL([BUILD_LINK_TEST],[test x"${i_do_have_link_test}" = xyes])

AC_ARG_ENABLE([windows-cross-compile],
        [AS_HELP_STRING([--enable-windows-cross-compile],
                [enable cross compile for windows extra support])],
        [WINDOWS_CROSS_COMPILE=yes])

#--------------------------------------------------------------------------
# Theme pixmap ICON selection.
# Go with tango by default. Retain older 2012 theme for those who like it.
themename=tango

FONTFORGE_ARG_ENABLE([theme-2012],
        [AS_HELP_STRING([--enable-theme-2012],
                [use old circa 2012 icons instead of using the tango default icons])],
        [FONTFORGE_THEME_TANGO])
if test x$enable_theme_2012 = xyes; then
   $themename = 2012
fi

# select the theme.
AM_CONDITIONAL([USE_THEME_2012],[test x"$themename" = x2012])
AM_CONDITIONAL([USE_THEME_TANGO],[test x"$themename" = xtango])

#--------------------------------------------------------------------------

FONTFORGE_ARG_ENABLE([gb12345],
        [AS_HELP_STRING([--enable-gb12345],
                [build the GB12345 encoding plugin])],
        [FONTFORGE_CONFIG_GB12345])
AM_CONDITIONAL([PLUGIN_GB12345],[test x"${i_do_have_gb12345}" = xyes])

FONTFORGE_ARG_ENABLE([maintainer-tools],
        [AS_HELP_STRING([--enable-maintainer-tools],
                [build programs used normally only by fontforge maintainers and developers])],
        [MAINTAINER_TOOLS])
AM_CONDITIONAL([MAINTAINER_TOOLS],[test x"${i_do_have_maintainer_tools}" = xyes])
AC_SUBST([MAINTAINER_TOOLS],["${i_do_have_maintainer_tools}"])

# Enable this experimental feature via an obscure cache variable
# rather than --enable.
AC_CACHE_CHECK([whether to enable native callbacks (experimental)],
               [fontforge_cv_native_callbacks],
               [if test x"${fontforge_cv_native_callbacks}" != yes; then
                   fontforge_cv_native_callbacks=no
                fi])
i_do_have_native_callbacks="${fontforge_cv_native_callbacks}"


#--------------------------------------------------------------------------
#
# Checks for libraries.

AC_SEARCH_LIBS([cos],[m])

dnl FIXME: Is this needed, given we are using libltdl?
dnl The dlopen() function is in the C library for *BSD and in libdl on GLIBC-based systems
dnl AC_SEARCH_LIBS([dlopen], [dl dld])

FONTFORGE_CONFIG_X_LIBRARIES

# zlib is a requirement. It is too commonly available to bother
# leaving out.
PKG_CHECK_MODULES([ZLIB],[zlib])
PKG_CHECK_MODULES([GLIB],[glib-2.0 >= 2.6 gio-2.0])

if test x"${i_do_have_gui}" = xyes; then
   PKG_CHECK_MODULES([PANGO],[pango >= 1.10 pangoxft])
fi

PKG_CHECK_MODULES([FREETYPE],[freetype2])

FONTFORGE_ARG_WITH_CAIRO
AC_ARG_VAR([FREETYPE_SOURCE],
        [directory where freetype source code is located for --enable-freetype-debugger;
         however, if --enable-freetype-debugger=DIR is specified, then DIR overrides
         the setting of FREETYPE_SOURCE])
FONTFORGE_ARG_WITH_GIFLIB
FONTFORGE_ARG_WITH_LIBJPEG
FONTFORGE_ARG_WITH_LIBPNG
FONTFORGE_ARG_WITH_LIBTIFF
FONTFORGE_ARG_WITH_LIBXML
FONTFORGE_ARG_WITH_LIBSPIRO
FONTFORGE_ARG_WITH_LIBUNINAMESLIST
FONTFORGE_ARG_WITH_LIBUNICODENAMES
FONTFORGE_ARG_WITH_ICONV
FONTFORGE_ARG_WITH_ZEROMQ
FONTFORGE_ARG_WITH_LIBREADLINE

if test x"${i_do_have_x}" = xyes; then
   AC_DEFINE(HAVE_GUI,[1],[Have GUI])
fi
if test x"${i_do_have_x}" = xyes; then
   if test x"${i_do_have_libzmq}" = xyes; then
      AC_DEFINE(BUILD_COLLAB,[1],[Build the Collab Code])
   fi
fi

# We have both libraries but did not choose which one to use yet
if test x"${i_do_have_libuninameslist}" = xyes; then
   if test x"${i_do_have_libunicodenames}" = xyes; then
      if test x"${i_do_have_libuninamesfun}" = xyes; then
	  i_do_have_libunicodenames=no
	  AC_DEFINE(_NO_LIBUNICODENAMES)
      else
	  i_do_have_libuninameslist=no
	  AC_DEFINE(_NO_LIBUNINAMESLIST)
      fi
   fi
fi

if test x"${i_do_have_cairo}" = xyes; then
   PKG_CHECK_MODULES([PANGOCAIRO],[pangocairo])
fi

FONTFORGE_CONFIG_FREETYPE_DEBUGGER

#--------------------------------------------------------------------------
#
# Checks for header files.

AC_CHECK_HEADERS([arpa/inet.h fcntl.h ieeefp.h inttypes.h])
AC_CHECK_HEADERS([langinfo.h libintl.h limits.h locale.h])
AC_CHECK_HEADERS([memory.h netdb.h netinet/in.h pthread.h stddef.h stdint.h stdlib.h])
AC_CHECK_HEADERS([string.h strings.h sys/ioctl.h sys/socket.h sys/time.h unistd.h wchar.h])
if test x"${i_do_want_iconv}" = xyes; then
   AC_CHECK_HEADERS([iconv.h])
fi

#--------------------------------------------------------------------------
#
# Checks for typedefs, structures, and compiler characteristics.

AC_C_BIGENDIAN
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT8_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

AC_TYPE_LONG_LONG_INT
if test x"${ac_cv_type_long_long_int}" = xyes; then
   AC_DEFINE([_HAS_LONGLONG],1,[Define if using 'long long int'.])
fi

AX_PTHREAD

#--------------------------------------------------------------------------
# Check to see if "this" compiler can use these flags, errors, or warnings.
# Enable the flags that can be used and skip flags that are unknown.
AC_LANG_PUSH([C]) dnl NOTE: configure.ac - try not to push/pop too often
AC_SUBST([WARNING_CFLAGS],[])
FFW_FLAGS="-Wunused -Wreturn-type -Wparentheses -Wformat -Wchar-subscripts \
 -Wno-unused-but-set-variable -Wno-unused-result -Wcast-align -Wclobbered  \
 -Werror=missing-prototypes -Werror=pointer-arith -Werror=implicit"
dnl Sep2012, There's a bug in <py3 with Py_True/False that will propagate
dnl with GCC's "strict-aliasing" rules. -Wstrict-aliasing

for arg in ${FFW_FLAGS}; do
   AX_CHECK_COMPILE_FLAG([$arg],[WARNING_CFLAGS+=" $arg"])
done

dnl add --no-undefined if supported. Based on information seen here:
dnl https://mail.gnome.org/archives/commits-list/2011-October/msg10575.html
dnl http://femass.com.br/Net-SNMP/configure.d/config_os_progs
case $host in
   dnl FreeBSD (et al.) does not complete linking for shared objects when
   dnl pthreads are requested, as different implementations are present; to
   dnl avoid problems, use -Wl,-z,defs only for those platform not behaving
   dnl this way.
   *-freebsd* | *-openbsd*)
      ;;
   *) saved_LDFLAGS=$LDFLAGS
      AC_MSG_CHECKING([whether the linker supports --no-undefined])
      LDFLAGS="$saved_LDFLAGS -Wl,--no-undefined"
      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
         [AC_MSG_RESULT([yes]);
          AX_CHECK_COMPILE_FLAG([-Wl,--no-undefined],[WARNING_CFLAGS+=" -Wl,--no-undefined"])],
         [AC_MSG_RESULT([no])])
      LDFLAGS="$saved_LDFLAGS"
      ;;
esac

AC_LANG_POP

#--------------------------------------------------------------------------
# Bypass older autoscan recommendations (if anyone decides to run autoscan)
# These packages promises to not use malloc(0) or realloc(n, 0) so we don't
# want autoscan to suggest using AC_FUNC_MALLOC or AC_FUNC_REALLOC, by
# redefining the problem
m4_define([AN_FUNCTION], [m4_if([$1], [malloc], [],
  [AN_OUTPUT([function], $@)])])
m4_define([AN_FUNCTION], [m4_if([$1], [realloc], [],
  [AN_OUTPUT([function], $@)])])

#--------------------------------------------------------------------------
# Checks for library functions.

AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_MKTIME
AC_FUNC_MMAP
if test x"${ac_cv_func_mmap_fixed_mapped}" != xyes; then
   AC_DEFINE([_NO_MMAP],1,[Define if not using mmap.])
fi
AC_FUNC_STRCOLL
AC_FUNC_STRTOD
AC_CHECK_FUNCS([alarm atexit dup2 endpwent floor])
AC_CHECK_FUNCS([getcwd gethostbyname gettimeofday])
AC_CHECK_FUNCS([localeconv memmove memset mkdir munmap])
AC_CHECK_FUNCS([nl_langinfo pow putenv rint rmdir])
AC_CHECK_FUNCS([select setenv setlocale snprintf socket sqrt])
AC_CHECK_FUNCS([strcasecmp strchr strdup strerror])
AC_CHECK_FUNCS([strncasecmp strpbrk strrchr strstr])
AC_CHECK_FUNCS([strtol strtoul tzset uname])
AC_CHECK_FUNC([snprintf],[:],[AC_DEFINE([_NO_SNPRINTF],1,[Define if not using snprintf.])])
AC_CHECK_FUNC([tzset],[:],[AC_DEFINE([_NO_TZSET],1,[Define if not using tzset.])])

#--------------------------------------------------------------------------
# Put ifndef wrapper on fontforge-config.h so we don't call it repeatedly.
AH_TOP([#ifndef _FF_CONFIG_H
#define _FF_CONFIG_H 1])
AH_BOTTOM([#endif])
#--------------------------------------------------------------------------

AM_CONDITIONAL([GRAPHICAL_USER_INTERFACE],[test x"${i_do_have_gui}" = xyes])
AM_CONDITIONAL([MACINTOSH],[test x"${gww_ismac}" = xyes])

# The following conditionals are always false, so the directories
# never get built by default. Nevertheless, they will be included by
# "make dist".
AM_CONDITIONAL([DESKTOP],[test x != x])
AM_CONDITIONAL([FONTTOOLS],[test x != x])

#--------------------------------------------------------------------------
# Create and Set FontForge Compiler Flags

my_cflags="${WARNING_CFLAGS}"
if test x"${i_do_have_freetype_debugger}" != xno; then
   my_cflags="${my_cflags} -I${FREETYPE_SOURCE}/src/truetype"
   my_cflags="${my_cflags} -I${FREETYPE_SOURCE}/include"
   my_cflags="${my_cflags} -I${FREETYPE_SOURCE}/include/freetype"
fi
my_cflags="${my_cflags} ${ZLIB_CFLAGS}"
my_cflags="${my_cflags} ${GLIB_CFLAGS}"
my_cflags="${my_cflags} ${CAIRO_CFLAGS}"
my_cflags="${my_cflags} ${PANGO_CFLAGS}"
my_cflags="${my_cflags} ${PANGOCAIRO_CFLAGS}"
my_cflags="${my_cflags} ${FREETYPE_CFLAGS}"
my_cflags="${my_cflags} ${GIFLIB_CFLAGS}"
my_cflags="${my_cflags} ${LIBJPEG_CFLAGS}"
my_cflags="${my_cflags} ${LIBPNG_CFLAGS}"
my_cflags="${my_cflags} ${LIBTIFF_CFLAGS}"
my_cflags="${my_cflags} ${LIBSPIRO_CFLAGS}"
my_cflags="${my_cflags} ${LIBUNINAMESLIST_CFLAGS}"
my_cflags="${my_cflags} ${LIBUNICODENAMES_CFLAGS}"
my_cflags="${my_cflags} ${LIBXML_CFLAGS}"
my_cflags="${my_cflags} ${PYTHON_CFLAGS}"
my_cflags="${my_cflags} ${PTHREAD_CFLAGS}"
my_cflags="${my_cflags} ${LIBREADLINE_CFLAGS}"
test x"${SDK}" = x || my_cflags="${my_cflags} -I${SDK}"
test x"${LTDLINCL}" = x || my_cflags="${my_cflags} -I${LTDLINCL}"
AC_SUBST([MY_CFLAGS],[${my_cflags}])

#--------------------------------------------------------------------------
# Create and Set FontForge Library Flags

test x"${i_do_have_python_scripting}" = xyes && my_libs="${my_libs} ${PYTHON_LIBS}"
test x"${i_do_have_giflib}" = xyes && my_libs="${my_libs} ${GIFLIB_LIBS}"
test x"${i_do_have_libjpeg}" = xyes && my_libs="${my_libs} ${LIBJPEG_LIBS}"
test x"${i_do_have_libpng}" = xyes && my_libs="${my_libs} ${LIBPNG_LIBS}"
test x"${i_do_have_libtiff}" = xyes && my_libs="${my_libs} ${LIBTIFF_LIBS}"
test x"${i_do_have_libuninameslist}" = xyes && my_libs="${my_libs} ${LIBUNINAMESLIST_LIBS}"
test x"${i_do_have_libunicodenames}" = xyes && my_libs="${my_libs} ${LIBUNICODENAMES_LIBS}"
test x"${i_do_have_libxml}" = xyes && my_libs="${my_libs} ${LIBXML_LIBS}"
test x"${i_do_have_libspiro}" = xyes && my_libs="${my_libs} ${LIBSPIRO_LIBS}"
test x"${i_do_have_cairo}" = xyes && my_libs="${my_libs} ${CAIRO_LIBS}"
test x"${i_do_have_cairo}" = xyes && my_libs="${my_libs} ${PANGOCAIRO_LIBS}"
test x"${i_do_have_gui}" = xyes && my_libs="${my_libs} ${PANGO_LIBS}"
test x"${i_do_have_x}" = xyes && my_libs="${my_libs} ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
test x"${i_do_have_libreadline}" = xyes && my_libs="${my_libs} ${LIBREADLINE_LIBS}"
my_libs="${my_libs} ${FREETYPE_LIBS}"
my_libs="${my_libs} ${PTHREAD_LIBS}"
my_libs="${my_libs} ${ZLIB_LIBS}"
my_libs="${my_libs} ${GLIB_LIBS}"
AC_SUBST([MY_LIBS],[${my_libs}])

#--------------------------------------------------------------------------
# Output commands - Create FontForge Portable Makefiles

AC_CONFIG_FILES([
Makefile
inc/Makefile
libltdl/Makefile
Unicode/Makefile
gutils/Makefile
collab/Makefile
hotkeys/Makefile
share/Makefile
gdraw/Makefile
fontforge/Makefile
fontforgeexe/Makefile
fontforgeexe/pixmaps/Makefile
fontforgeexe/pixmaps/2012/Makefile
fontforgeexe/pixmaps/tango/Makefile
fontforgeexe/collab/Makefile
po/Makefile
mackeys/Makefile
htdocs/Makefile
pycontrib/Makefile
pycontrib/simple/Makefile
pycontrib/collab/Makefile
nodejs/Makefile
nodejs/collabwebview/Makefile
nodejs/collabwebview/css/Makefile
nodejs/collabwebview/js/Makefile
nodejs/collabwebview/js/contentEditable/Makefile
pyhook/Makefile
cidmap/Makefile
plugins/Makefile
tests/Makefile
desktop/Makefile
fonttools/Makefile
osx/Makefile
osx/FontForge.app/Makefile
osx/FontForge.app/Contents/Makefile
osx/FontForge.app/Contents/Resources/Makefile
osx/FontForge.app/Contents/Resources/English.lproj/Makefile
osx/FontForge.app/Contents/MacOS/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/MacOS/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/Inputbox.nib/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/MainMenu.nib/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/Msgbox.nib/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/PopUpButton.nib/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/Progressbar.nib/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/SecureInputbox.nib/Makefile
osx/FontForge.app/Contents/MacOS/CocoaDialog.app/Contents/Resources/Textbox.nib/Makefile
fontforge.pc
])

# GNUmakefiles that act as wrappers around portable makefiles and
# provide additional targets.
AC_CONFIG_FILES([fontforge/GNUmakefile])

#--------------------------------------------------------------------------

FONTFORGE_CREATE_PKGCONFIG_FILES

#--------------------------------------------------------------------------
# Create FontForge Operating System Specific files
AC_CONFIG_FILES([fontforgeexe/darwinsetup],[chmod +x fontforgeexe/darwinsetup])

#--------------------------------------------------------------------------
# Create FontForge and Python test scripts to be used with 'make check' or
# individually as 'fontforge --lang=XX --script=testXXXX.XX'
AC_CONFIG_FILES([tests/atlocal])

rm -f tests/*.pe tests/*.py

if test x$i_do_have_native_scripting = xyes; then
  ff_script_files="helper107 helper118A helper118B svg2ttf test001	\
	test002 test003 test004 test005 test006 test007 test008 test009	\
	test010 test101 test102 test103 test104 test105 test106 test107	\
	test108 test109 test110 test111 test112 test113 test114 test115	\
	test116 test117 test118 test119 test120 test121 test122 test123	\
	test124 test125 test126 test127"
  for arg in ${ff_script_files}; do
    AC_CONFIG_FILES([tests/$arg.pe])
  done
fi

if test x$i_do_have_python_scripting = xyes; then
  py_script_files="findoverlapbugs test0001 test0101 test1001a test1001b \
	test1001c test1001 test1002 test1003 test1004 test1005 test1006	\
	test1007"
  for arg in ${py_script_files}; do
    AC_CONFIG_FILES([tests/$arg.py])
  done
fi

#--------------------------------------------------------------------------
# Collect "GIT" compile-time information to help when debugging FontForge.

FONTFORGE_GIT_VERSION=""
if test -d ${srcdir}/.git; then
  FONTFORGE_GIT_VERSION=`cd ${srcdir} && git log --pretty=format:'%H' -n 1`
fi
FONTFORGE_MODTIME="`date '+%s'`L"
FONTFORGE_MODTIME_STR="`date +'%H:%M %Z %e-%b-%Y'`"
FONTFORGE_VERSIONDATE="`date '+%Y%m%d'`"
AC_DEFINE_UNQUOTED(FONTFORGE_GIT_VERSION,"$FONTFORGE_GIT_VERSION","git hash that source are built from")
AC_DEFINE_UNQUOTED(FONTFORGE_MODTIME,"$FONTFORGE_MODTIME","Epoch time that configure was run at")
AC_DEFINE_UNQUOTED(FONTFORGE_MODTIME_STR,"$FONTFORGE_MODTIME_STR",
	"A user friendly date that that configure was run at: For example 01:48 GMT 6-Sep-2012")
AC_DEFINE_UNQUOTED(FONTFORGE_VERSIONDATE,"$FONTFORGE_VERSIONDATE","YYYYMMDD as number when configure was run")
AC_DEFINE_UNQUOTED(FONTFORGE_MODTIME_RAW,$FONTFORGE_MODTIME,"Epoch time that configure was run at (no quotes)")
AC_DEFINE_UNQUOTED(FONTFORGE_MODTIME_STR_RAW,$FONTFORGE_MODTIME_STR,
	"A user friendly date that that configure was run at: For example 01:48 GMT 6-Sep-2012 (no quotes)")
AC_DEFINE_UNQUOTED(FONTFORGE_VERSIONDATE_RAW,$FONTFORGE_VERSIONDATE,"YYYYMMDD as number when configure was run (no quotes)")

#--------------------------------------------------------------------------

AC_OUTPUT

AC_MSG_NOTICE([

Configuration:

  Source code location	${srcdir}
  Build code location	${builddir}
  Destination prefix	${prefix}
  Compiler		${CC}

Summary of optional features:

  real (floating pt)	${my_real_type}
  programs		${i_do_have_programs}
  native scripting	${i_do_have_native_scripting}
  python scripting	${i_do_have_python_scripting}
  python extension	${i_do_have_python_extension}
  freetype debugger	${i_do_have_freetype_debugger}
  capslock for alt	${i_do_have_capslock_for_alt}
  raw points mode	${i_do_have_debug_raw_points}
  tile path		${i_do_have_tile_path}
  gb12345 encoding	${i_do_have_gb12345}

Summary of optional dependencies:

  cairo			${i_do_have_cairo}  	${cairo_url}
  giflib		${i_do_have_giflib}  	${giflib_url}
  libjpeg		${i_do_have_libjpeg}  	${libjpeg_url}
  libpng		${i_do_have_libpng}  	${libpng_url}
  libtiff		${i_do_have_libtiff}  	${libtiff_url}
  libxml		${i_do_have_libxml}  	${libxml_url}
  libspiro		${i_do_have_libspiro}  	${libspiro_url}
  libuninameslist	${i_do_have_libuninameslist}  	${libuninameslist_url}
  libunicodenames	${i_do_have_libunicodenames}  	${libunicodenames_url}
  zeromq (libzmq)	${i_do_have_libzmq}  	${libzmq_url}
  libreadline		${i_do_have_libreadline}  	${libreadline_url}
  X Window System	${i_do_have_x}
])

#--------------------------------------------------------------------------
