configure.ac
author ali <ali@juiblex.co.uk>
Tue May 28 15:17:19 2013 +0100 (2013-05-28)
changeset 69 1016349e619f
parent 19 05d082ebf685
child 71 82d3cc398b54
permissions -rw-r--r--
Use GLib functions and data types
     1 #                                               -*- Autoconf -*-
     2 # Process this file with autoconf to produce a configure script.
     3 
     4 AC_INIT([bookloupe],[1.52],[ali@juiblex.co.uk])
     5 AC_PREREQ(2.59)
     6 AC_CONFIG_AUX_DIR([config])
     7 AC_CONFIG_SRCDIR([bookloupe/bookloupe.c])
     8 AC_CONFIG_FILES([Makefile
     9 bl/Makefile
    10 bookloupe/Makefile
    11 test/Makefile
    12 test/harness/Makefile
    13 test/compatibility/Makefile
    14 doc/Makefile
    15 ])
    16 AM_INIT_AUTOMAKE(no-define,1.11)
    17 AM_SILENT_RULES([yes])
    18 AC_CANONICAL_HOST
    19 
    20 ##################################################
    21 # Checks for programs.
    22 ##################################################
    23 AC_PROG_CC
    24 LT_INIT
    25 # Libtool supports a --disable-shared option to tell it to avoid
    26 # building shared versions of libraries. We don't have any libraries
    27 # but we do want to support building static versions of our executables.
    28 # Libtool can do this (under the right circumstances) so we overload
    29 # this switch for this purpose.
    30 #
    31 # The libtool option that we use (-static-libtool-libs) means to use
    32 # static linking with libraries that supply a .la file and which
    33 # include a non-empty value for "old_library". If the library doesn't
    34 # include a .la file (they are deleted by some distributions), then
    35 # this option will have no effect and likewise if old_library is set
    36 # to '' (eg., if the library was build with --disable-static) then
    37 # again -static-libtool-libs will have no effect.
    38 #
    39 # If old_library is set to a non-empty value, then specifying
    40 # -static-libtool-libs will cause the link to fail if the old library
    41 # cannot be found (libtool will not fallback to a shared library
    42 # in these circumstances). This can happen with Fedora, for example,
    43 # if a main mingw32 library package is installed but not the
    44 # coresponding static sub-package. The solution is to either
    45 # install the relevant static sub-packages or don't use --disable-shared.
    46 AS_IF([test "$enable_shared" = no],[
    47   LDFLAGS="$LDFLAGS -static-libtool-libs"
    48 ])
    49 LT_OUTPUT
    50 ac_compile="./libtool --mode=compile --tag=CC $ac_compile"
    51 ac_link="./libtool --mode=link --tag=CC $ac_link"
    52 PKG_PROG_PKG_CONFIG
    53 
    54 ##################################################
    55 # Checks for header files.
    56 ##################################################
    57 
    58 ##################################################
    59 # Checks for typedefs, structures, and compiler characteristics.
    60 ##################################################
    61 
    62 ##################################################
    63 # Checks for libraries.
    64 ##################################################
    65 PKG_CHECK_MODULES([GLIB],[glib-2.0 >= 2.18])
    66 
    67 # Glib 2.30 (at least) doesn't include "-framework Carbon" in Libs.private
    68 # which causes link to fail for static glib on Mac (gnome bug #668152).
    69 # Test for this problem and implement a workaround.
    70 AC_MSG_CHECKING([for Mac OS X Carbon support])
    71 AC_TRY_CPP([
    72 #include <Carbon/Carbon.h>
    73 #include <CoreServices/CoreServices.h>
    74 ],[have_carbon=yes],[have_carbon=no])
    75 AC_MSG_RESULT([$have_carbon])
    76 AS_IF([test "$have_glib" != no -a "$have_carbon" = yes],[
    77   AC_MSG_CHECKING([whether -framework Carbon is needed])
    78   save_CFLAGS="$CFLAGS"
    79   save_LIBS="$LIBS"
    80   CFLAGS="$GLIB_CFLAGS"
    81   LIBS="$GLIB_LIBS"
    82   AC_TRY_LINK([
    83   #include <glib.h>
    84   ],[
    85   return !g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP);
    86   ],[framework_carbon=no],[framework_carbon=yes])
    87   CFLAGS="$save_CFLAGS"
    88   LIBS="$save_LIBS"
    89   AC_MSG_RESULT([$framework_carbon])
    90   AS_IF([test "$framework_carbon" = yes],[
    91     GLIB_LIBS="$GLIB_LIBS -framework Carbon"
    92   ])
    93 ])
    94 
    95 # If we are using a static version of glib then we should define
    96 # GLIB_STATIC_COMPILATION. This isn't needed when glib is built
    97 # only for static use (in which case glibconfig.h will already
    98 # define GLIB_STATIC_COMPILATION).
    99 AS_IF([test "$enable_shared" = no],[
   100   AC_MSG_CHECKING([whether GLIB_STATIC_COMPILATION needs to be defined])
   101   save_CFLAGS="$CFLAGS"
   102   save_LIBS="$LIBS"
   103   CFLAGS="$GLIB_CFLAGS"
   104   LIBS="$GLIB_LIBS"
   105   AC_TRY_LINK([
   106   #include <glib.h>
   107   ],[
   108   return glib_major_version!=2;
   109   ],[static_compilation=no],[static_compilation=yes])
   110   CFLAGS="$save_CFLAGS"
   111   LIBS="$save_LIBS"
   112   AC_MSG_RESULT([$static_compilation])
   113   AS_IF([test "$static_compilation" = yes],[
   114     GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_STATIC_COMPILATION"
   115   ])
   116 ])
   117 
   118 ##################################################
   119 # Checks for library functions.
   120 ##################################################
   121 save_CFLAGS="$CFLAGS"
   122 save_LIBS="$LIBS"
   123 CFLAGS="$GLIB_CFLAGS"
   124 LIBS="$GLIB_LIBS"
   125 AC_CHECK_FUNCS([g_mkdtemp mkdtemp],[break])
   126 CFLAGS="$save_CFLAGS"
   127 LIBS="$save_LIBS"
   128 
   129 ##################################################
   130 # Checks for processor independent files.
   131 ##################################################
   132 
   133 ##################################################
   134 # Generate the various configured files
   135 ##################################################
   136 AC_OUTPUT