1dnl Process this file with autoconf to produce a configure script.
2
3# Init.
4AC_PREREQ(2.57)
5AC_INIT(libticonv, 1.1.5, [tilp-users@lists.sourceforge.net])
6
7dnl Release versioning info
8VERSION="1.1.5"
9AC_SUBST(VERSION)
10
11dnl Library version.
12dnl current:revision:age
13dnl  * On a new release, increment 'revision'.
14dnl  * If you added things to the api, increment 'current',
15dnl    reset 'revision' and increment 'age'.
16dnl  * If you changed/removed things from the api, increment 'current',
17dnl    reset 'revision' and reset 'age'.
18m4_define(LT_CURRENT, 8)
19m4_define(LT_REVISION, 4)
20m4_define(LT_AGE, 0)
21LT_LIBVERSION="LT_CURRENT():LT_REVISION():LT_AGE()"
22AC_SUBST(LT_LIBVERSION)
23
24AM_INIT_AUTOMAKE([dist-bzip2 subdir-objects])
25AM_MAINTAINER_MODE
26AC_CONFIG_MACRO_DIR([m4])
27
28AC_PREFIX_DEFAULT(/usr/local)
29
30dnl Files to configure.
31AC_CONFIG_SRCDIR([src/ticonv.c])
32AC_CONFIG_HEADERS([config.h])
33AC_CONFIG_FILES([
34  Makefile
35  build/mingw/Makefile
36  docs/Makefile
37  src/Makefile
38  tests/Makefile
39  ticonv.pc
40])
41
42# Setup libtool.
43AC_DISABLE_STATIC
44AC_LIBTOOL_WIN32_DLL
45LT_INIT
46
47# Checks for programs.
48AC_PROG_CC
49AC_PROG_INSTALL
50AC_PROG_MAKE_SET
51AC_PROG_LN_S
52AC_ISC_POSIX
53AC_PROG_AWK
54AC_CHECK_PROG(TFDOCGEN, tfdocgen, yes, no)
55AM_CONDITIONAL(USE_DOCGEN, test "$TFDOCGEN" != "no")
56AC_CHECK_TOOL(RC, windres, windres)
57
58# Checks for libraries.
59dnl No translatable strings in this library.
60dnl AM_GNU_GETTEXT
61
62PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6.0)
63AC_SUBST(GLIB_CFLAGS)
64AC_SUBST(GLIB_LIBS)
65
66# Checks for header files.
67AC_HEADER_STDC
68AC_CHECK_HEADERS([inttypes.h stdint.h stdlib.h string.h])
69
70# Checks for typedefs, structures, and compiler characteristics.
71AC_C_CONST
72AC_TYPE_SIZE_T
73AC_STRUCT_TM
74
75# Checks for library functions.
76AC_PROG_GCC_TRADITIONAL
77AC_FUNC_STAT
78AC_CHECK_FUNCS([memset strcasecmp strchr strdup strrchr])
79
80# Platform specific tests.
81dnl AC_CANONICAL_HOST
82case "$host" in
83  *-*-*bsd*)  ARCH="-D__BSD__" ;;
84  *-*-mingw*) ARCH="-D__WIN32__ -D__MINGW32__" ;;
85  *)          ARCH="-D__LINUX__" ;;
86esac
87CFLAGS="$CFLAGS $ARCH"
88
89# Ensure MSVC-compatible struct packing convention is used when
90# compiling for Win32 with gcc.
91# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
92# gcc2 uses "-fnative-struct".
93case $host_os in
94*mingw*|*cygwin*)
95  if test x$GCC = xyes; then
96    msnative_struct=''
97    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
98    if test -z "$ac_cv_prog_CC"; then
99      our_gcc="$CC"
100    else
101      our_gcc="$ac_cv_prog_CC"
102    fi
103    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
104      2.)
105        if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
106          msnative_struct='-fnative-struct'
107        fi
108        ;;
109      *)
110        if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
111          msnative_struct='-mms-bitfields'
112        fi
113        ;;
114    esac
115    if test x"$msnative_struct" = x ; then
116      AC_MSG_RESULT([no way])
117      AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
118    else
119      CFLAGS="$CFLAGS $msnative_struct"
120      AC_MSG_RESULT([${msnative_struct}])
121    fi
122  fi
123  ;;
124esac
125
126AM_CONDITIONAL(OS_WIN32, test "$msnative_struct")
127
128# Check for the new -fvisibility=hidden flag introduced in gcc 4.0
129# Allow to reduce shared library size and avoid symbol clash
130case $host_os in
131*mingw*)
132  ;;
133*)
134	if test x$GCC = xyes; then
135	   visibility_flag=''
136	   AC_MSG_CHECKING([whether gcc accepts -fvisibility])
137	   if test -z "$ac_cv_prog_CC"; then
138	      our_gcc="$CC"
139	   else
140	      our_gcc="$ac_cv_prog_CC"
141	   fi
142	   if $our_gcc -v --help 2>/dev/null | grep "fvisibility" >/dev/null; then
143	      visibility_flag='-fvisibility=hidden'
144	   fi
145	   if test x"$visibility_flag" = x ; then
146	      AC_MSG_RESULT([no])
147	   else
148	      CFLAGS="$CFLAGS $visibility_flag"
149	      AC_MSG_RESULT([${visibility_flag}])
150	      AC_DEFINE(HAVE_FVISIBILITY, 1, [Use -fvisibility=hidden flag])
151	    fi
152	fi
153	;;
154esac
155
156#iconv emulation interface
157AC_ARG_ENABLE(iconv,
158  AC_HELP_STRING([--enable-iconv], [enable iconv interface]),
159  [cab_cv_enable_iconv=$enableval], [])
160AC_CACHE_CHECK([whether to enable experimental iconv interface],
161  [cab_cv_enable_iconv], [cab_cv_enable_iconv=no])
162AM_CONDITIONAL(USE_ICONV, test x$cab_cv_enable_iconv = xyes)
163
164# Output.
165AC_OUTPUT
166
167echo "Now, you can type 'make' and 'make install'."
168