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