1dnl Process this file with autoconf to produce a configure script.
2
3# Init.
4AC_PREREQ(2.57)
5AC_INIT(libtifiles2, 1.1.7, [tilp-users@lists.sourceforge.net])
6
7dnl Release versioning info
8VERSION="1.1.7"
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, 10)
19m4_define(LT_REVISION, 2)
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/tifiles.c])
32AC_CONFIG_HEADERS([config.h])
33AC_CONFIG_FILES([
34  Makefile
35  build/mingw/Makefile
36  docs/Makefile
37  po/Makefile.in
38  src/Makefile
39  tests/Makefile
40  tifiles2.pc
41])
42
43# Setup libtool.
44AC_DISABLE_STATIC
45AC_LIBTOOL_WIN32_DLL
46LT_INIT
47
48# Checks for programs.
49AC_PROG_CC
50AM_PROG_CC_C_O
51AC_PROG_INSTALL
52AC_PROG_MAKE_SET
53AC_PROG_LN_S
54AC_ISC_POSIX
55AC_PROG_AWK
56AC_CHECK_PROG(TFDOCGEN, tfdocgen, yes, no)
57AM_CONDITIONAL(USE_DOCGEN, test "$TFDOCGEN" != "no")
58AC_CHECK_TOOL(RC, windres, windres)
59
60# Checks for libraries.
61AM_GNU_GETTEXT(external)
62AM_GNU_GETTEXT_VERSION([0.18])
63
64PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6.0)
65AC_SUBST(GLIB_CFLAGS)
66AC_SUBST(GLIB_LIBS)
67
68PKG_CHECK_MODULES(TICONV, ticonv >= 1.1.5)
69AC_SUBST(TICONV_CFLAGS)
70AC_SUBST(TICONV_LIBS)
71
72PKG_CHECK_MODULES(ARCHIVE, libarchive)
73AC_SUBST(ARCHIVE_CFLAGS)
74AC_SUBST(ARCHIVE_LIBS)
75
76# Checks for header files.
77AC_HEADER_STDC
78AC_CHECK_HEADERS([inttypes.h stdint.h stdlib.h string.h])
79
80# Checks for typedefs, structures, and compiler characteristics.
81AC_C_CONST
82AC_TYPE_SIZE_T
83AC_STRUCT_TM
84
85# Checks for library functions.
86AC_PROG_GCC_TRADITIONAL
87AC_FUNC_STAT
88AC_CHECK_FUNCS([memset strcasecmp strchr strdup strrchr])
89
90# Platform specific tests.
91dnl AC_CANONICAL_HOST
92case "$host" in
93  *-*-*bsd*)  ARCH="-D__BSD__" ;;
94  *-*-dragonfly*)  ARCH="-D__BSD__" ;;
95  *-*-mingw*) ARCH="-D__WIN32__ -D__MINGW32__" ;;
96  *)          ARCH="-D__LINUX__" ;;
97esac
98CFLAGS="$CFLAGS $ARCH"
99
100# Ensure MSVC-compatible struct packing convention is used when
101# compiling for Win32 with gcc.
102# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
103# gcc2 uses "-fnative-struct".
104case $host_os in
105*mingw*|*cygwin*)
106  if test x$GCC = xyes; then
107    msnative_struct=''
108    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
109    if test -z "$ac_cv_prog_CC"; then
110      our_gcc="$CC"
111    else
112      our_gcc="$ac_cv_prog_CC"
113    fi
114    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
115      2.)
116        if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
117          msnative_struct='-fnative-struct'
118        fi
119        ;;
120      *)
121        if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
122          msnative_struct='-mms-bitfields'
123        fi
124        ;;
125    esac
126    if test x"$msnative_struct" = x ; then
127      AC_MSG_RESULT([no way])
128      AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
129    else
130      CFLAGS="$CFLAGS $msnative_struct"
131      AC_MSG_RESULT([${msnative_struct}])
132    fi
133  fi
134  ;;
135esac
136
137AM_CONDITIONAL(OS_WIN32, test "$msnative_struct")
138
139# Check for the new -fvisibility=hidden flag introduced in gcc 4.0
140# Allow to reduce shared library size and avoid symbol clash
141case $host_os in
142*mingw*)
143  ;;
144*)
145	if test x$GCC = xyes; then
146	   visibility_flag=''
147	   AC_MSG_CHECKING([whether gcc accepts -fvisibility])
148	   if test -z "$ac_cv_prog_CC"; then
149	      our_gcc="$CC"
150	   else
151	      our_gcc="$ac_cv_prog_CC"
152	   fi
153	   if $our_gcc -v --help 2>/dev/null | grep "fvisibility" >/dev/null; then
154	      visibility_flag='-fvisibility=hidden'
155	   fi
156	   if test x"$visibility_flag" = x ; then
157	      AC_MSG_RESULT([no])
158	   else
159	      CFLAGS="$CFLAGS $visibility_flag"
160	      AC_MSG_RESULT([${visibility_flag}])
161	      AC_DEFINE(HAVE_FVISIBILITY, 1, [Use -fvisibility=hidden flag])
162	    fi
163	fi
164	;;
165esac
166
167# Custom support
168AC_ARG_ENABLE(ti8x,
169  AC_HELP_STRING([--disable-ti8x], [disable TI8x support]),
170  [use_ti8x=$enableval], [use_ti8x=yes])
171if test x$use_ti8x = xno; then
172  AC_DEFINE(DISABLE_TI8X, 1, [Defined to disable the TI8x support])
173fi
174
175# Custom support
176AC_ARG_ENABLE(ti9x,
177  AC_HELP_STRING([--disable-ti9x], [disable TI9x support]),
178  [use_ti9x=$enableval], [use_ti9x=yes])
179if test x$use_ti9x = xno; then
180  AC_DEFINE(DISABLE_TI9X, 1, [Defined to disable the TI9x support])
181fi
182
183# Output.
184AC_OUTPUT
185
186echo "Now, you can type 'make' and 'make install'."
187