1dnl Process this file with autoconf to produce a configure script.
2dnl $Id$
3
4# Init.
5AC_PREREQ(2.57)
6AC_INIT(TILP2, 1.18, [tilp-users@lists.sourceforge.net])
7
8AM_INIT_AUTOMAKE([dist-bzip2])
9AM_MAINTAINER_MODE
10AC_CONFIG_MACRO_DIR([m4])
11
12AC_PREFIX_DEFAULT(/usr/local)
13
14# Files to configure.
15AC_CONFIG_SRCDIR([src/main.c])
16AC_CONFIG_HEADERS([config.h])
17AC_CONFIG_FILES([
18  Makefile
19  build/Makefile
20  build/mingw/Makefile
21  builder/Makefile
22  desktop/Makefile
23  help/Makefile
24  icons/Makefile
25  man/Makefile
26  pixmaps/Makefile
27  src/Makefile
28  wicons/Makefile
29])
30
31AC_MSG_CHECKING([for something to drink while compiling])
32AC_MSG_RESULT([err: no fridge found!])
33
34# Setup libtool.
35AC_DISABLE_STATIC
36AC_LIBTOOL_WIN32_DLL
37LT_INIT
38
39# Checks for programs.
40AC_PROG_CC
41AC_PROG_CXX
42AM_PROG_CC_C_O
43AC_PROG_INSTALL
44AC_PROG_MAKE_SET
45AC_PROG_LN_S
46AC_ISC_POSIX
47AC_PROG_AWK
48AC_CHECK_PROG(GROFF, groff, yes, no)
49AM_CONDITIONAL(USE_GROFF, test "$GROFF" != "no")
50AC_CHECK_TOOL(RC, windres, windres)
51
52# Translation
53AC_PROG_INTLTOOL([0.40.0])
54
55GETTEXT_PACKAGE=tilp2
56AC_SUBST(GETTEXT_PACKAGE)
57AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [tilp2])
58AM_GLIB_GNU_GETTEXT
59
60# Checks for libraries.
61PKG_CHECK_MODULES(TICONV, ticonv >= 1.1.5)
62AC_SUBST(TICONV_CFLAGS)
63AC_SUBST(TICONV_LIBS)
64
65PKG_CHECK_MODULES(TIFILES, tifiles2 >= 1.1.7)
66AC_SUBST(TIFILES_CFLAGS)
67AC_SUBST(TIFILES_LIBS)
68
69PKG_CHECK_MODULES(TICABLES, ticables2 >= 1.3.5)
70AC_SUBST(TICABLES_CFLAGS)
71AC_SUBST(TICABLES_LIBS)
72
73PKG_CHECK_MODULES(TICALCS, ticalcs2 >= 1.1.9)
74AC_SUBST(TICALCS_CFLAGS)
75AC_SUBST(TICALCS_LIBS)
76
77PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6.0)
78AC_SUBST(GLIB_CFLAGS)
79AC_SUBST(GLIB_LIBS)
80
81PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.12.0)
82AC_SUBST(GTK_CFLAGS)
83AC_SUBST(GTK_LIBS)
84
85# Check for zlib
86AC_CHECK_HEADER(zlib.h)
87AC_CHECK_LIB(z, compress)
88LIBZ="$LIBS"
89LIBS=""
90AC_SUBST(LIBZ)
91
92# Checks for header files.
93AC_HEADER_STDC
94AC_CHECK_HEADERS([stdlib.h string.h unistd.h])
95
96# Checks for typedefs, structures, and compiler characteristics.
97AC_C_CONST
98AC_HEADER_STAT
99AC_TYPE_UID_T
100AC_TYPE_MODE_T
101AC_TYPE_OFF_T
102AC_STRUCT_TM
103
104# Checks for library functions.
105AC_PROG_GCC_TRADITIONAL
106AC_TYPE_SIGNAL
107AC_FUNC_STAT
108AC_CHECK_FUNCS([getcwd memset mkdir strcasecmp strchr strdup strrchr strstr strtol])
109
110# Platform specific tests.
111dnl AC_CANONICAL_HOST
112case "$host" in
113  *-*-mingw*) ARCH="-D__WIN32__ -D__MINGW32__ -mwindows" ;;
114  *-*-cygwin) ARCH="-D__WIN32__ -D__CYGWIN__ -mwindows -mno-cygwin" ;;
115  *-*-*bsd*|*-*-dragonfly*)  ARCH="-D__BSD__" ;;
116  *)          ARCH="-D__LINUX__" ;;
117esac
118CFLAGS="$CFLAGS $ARCH"
119
120# KDE dialogs support
121AC_ARG_WITH(kde, AC_HELP_STRING([--with-kde], [Compile with KDE support]), [kde=$withval], [kde=no])
122if test "x$kde" = "xdefault"; then
123  case $host_os in
124    *mingw*)
125      kde=no
126      ;;
127    *)
128      kde=yes
129      ;;
130  esac
131fi
132if test "x$kde" = "xyes"; then
133        AC_PROG_CXX
134        AC_DEFINE(WITH_KDE, 1, [Use KDE support])
135fi
136AM_CONDITIONAL(USE_KDE, test "x$kde" = "xyes")
137AC_SUBST(kde)
138
139# Ensure MSVC-compatible struct packing convention is used when
140# compiling for Win32 with gcc.
141# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
142# gcc2 uses "-fnative-struct".
143case $host_os in
144*mingw*|*cygwin*)
145  if test x$GCC = xyes; then
146    msnative_struct=''
147    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
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    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
154      2.)
155        if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
156          msnative_struct='-fnative-struct'
157        fi
158        ;;
159      *)
160        if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
161          msnative_struct='-mms-bitfields'
162        fi
163        ;;
164    esac
165    if test x"$msnative_struct" = x ; then
166      AC_MSG_RESULT([no way])
167      AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
168    else
169      CFLAGS="$CFLAGS $msnative_struct"
170      AC_MSG_RESULT([${msnative_struct}])
171    fi
172  fi
173  ;;
174esac
175
176AM_CONDITIONAL(OS_WIN32, test "$msnative_struct")
177
178# Check for the new -fvisibility=hidden flag introduced in gcc 4.0
179# Allow to reduce shared library size and avoid symbol clash
180case $host_os in
181*mingw*)
182  ;;
183*)
184        if test x$GCC = xyes; then
185           visibility_flag=''
186           AC_MSG_CHECKING([whether gcc accepts -fvisibility])
187           if test -z "$ac_cv_prog_CC"; then
188              our_gcc="$CC"
189           else
190              our_gcc="$ac_cv_prog_CC"
191           fi
192           if $our_gcc -v --help 2>/dev/null | grep "fvisibility" >/dev/null; then
193              visibility_flag='-fvisibility=hidden'
194           fi
195           if test x"$visibility_flag" = x ; then
196              AC_MSG_RESULT([no])
197           else
198              CFLAGS="$CFLAGS $visibility_flag"
199              AC_MSG_RESULT([${visibility_flag}])
200              AC_DEFINE(HAVE_FVISIBILITY, 1, [Use -fvisibility=hidden flag])
201            fi
202        fi
203        ;;
204esac
205
206# Find a C compiler for the build system (needed for compiling cleaner)
207AC_ARG_VAR([CC_FOR_BUILD], [C compiler for programs to be run on the build system])
208AC_ARG_VAR([CFLAGS_FOR_BUILD], [C compiler flags for CC_FOR_BUILD])
209AC_MSG_CHECKING([for the host compiler])
210if test "x$build" == "x$host" ; then
211  # Not cross-compiling.
212  CC_FOR_BUILD=$CC
213  CFLAGS_FOR_BUILD=$CFLAGS
214  AC_MSG_RESULT([${CC_FOR_BUILD}])
215else
216  # Try to find the host CC among several choices
217  AC_CHECK_PROGS(CC_FOR_BUILD, [gcc cc clang c89 c99], [false])
218  if test "x$CC_FOR_BUILD" = "xfalse" ; then
219    AC_MSG_FAILURE([not found.])
220  else
221    AC_MSG_RESULT([${CC_FOR_BUILD}])
222  fi
223fi
224
225case "$host" in
226  *-*-linux*) EXFL="-Wl,--export-dynamic" ;;
227  *-*-mingw*) EXFL="-lcomdlg32" ;;
228  *)          EXFL="" ;;
229esac
230LDFLAGS="$LDFLAGS $EXFL"
231
232# On Darwin, libglade chokes on stripped executables.
233case "$host" in
234  *-apple-darwin*)
235    case "$CFLAGS $CXXFLAGS $LDFLAGS" in
236      *" -s "*|"-s "*|*" -s"|"-s")
237         echo "warning: cannot strip libglade executables on this host"
238         CFLAGS=`echo "$CFLAGS"|sed 's/\( -s\)* / /g;s/^-s //g;s/ -s$//g;s/^-s$//g'`
239         CXXFLAGS=`echo "$CXXFLAGS"|sed 's/\( -s\)* / /g;s/^-s //g;s/ -s$//g;s/^-s$//g'`
240         LDFLAGS=`echo "$LDFLAGS"|sed 's/\( -s\)* / /g;s/^-s //g;s/ -s$//g;s/^-s$//g'`
241         ;;
242    esac
243    ;;
244esac
245
246# some extra flags
247CXXFLAGS="$CFLAGS -fno-rtti -fno-exceptions"
248
249AC_SUBST(CFLAGS)
250AC_SUBST(LDFLAGS)
251AC_SUBST(CXXFLAGS)
252
253# Output.
254AC_OUTPUT([
255po/Makefile.in
256])
257
258echo "Now, you can type 'make' and 'make install'."
259