2 dnl Makefile for the GNOKII tool suite.
4 dnl Copyright (C) 1999 Hugh Blemings & Pavel Janík ml.
5 dnl 2000 Karel Zak, Pawe³ Kot
10 AC_INIT(gnokii/gnokii.c)
12 AC_CONFIG_AUX_DIR(config)
15 AC_PREFIX_DEFAULT("/usr/local")
17 dnl ======================== Default setting
18 test -n "$CFLAGS" || export CFLAGS="-O2 -Wall"
19 ALL_LINGUAS="cs de et fi nl sk pl it"
21 dnl ======================== Checks for programs.
27 AC_PATH_PROG(AR, ar, no)
29 AC_PATH_PROG(RM, rm, no)
30 AC_PATH_PROG(FIND, find, no)
31 AC_CHECK_PROGS(MAKE, gmake make)
34 dnl Let us have $prefix variable aviable here
35 test x"$prefix" = xNONE && prefix="$ac_default_prefix"
37 AC_ARG_WITH(cfg_model,
38 [ --with-cfg-model=5110 specifies the mobile phone model],,
39 [ with_cfg_model="5110" ])
40 AC_DEFINE_UNQUOTED(CONFIG_CFG_MODEL, "$with_cfg_model")
42 [ --with-cfg-port=/dev/ttyS0 specifies the mobile phone port],,
43 [ with_cfg_port="/dev/ttyS0" ])
44 AC_DEFINE_UNQUOTED(CONFIG_CFG_PORT, "$with_cfg_port")
45 AC_ARG_WITH(cfg_initlength,
46 [ --with-cfg-initlength=default specifies the mobile phone initlength],,
47 [ with_cfg_initlength="default" ])
48 AC_DEFINE_UNQUOTED(CONFIG_CFG_INITLENGTH, "$with_cfg_initlength")
51 [ --enable-debug compile with debug code],
59 [ --enable-xdebug compile with xdebug code],
65 AC_ARG_ENABLE(rlpdebug,
66 [ --enable-rlpdebug compile with RLP debug code],
67 [ AC_DEFINE(RLP_DEBUG)
72 dnl ======================== NLS support
79 [ --with-libintl=DIR specifies the base NLS],
80 [ if test "x$withval" = "xyes"; then
81 AC_MSG_WARN(Usage is --with-libintl=DIR)
83 NLS_LIBS="-L$withval/lib"
84 NLS_CFLAGS="-I$withval/include"
90 [ --enable-nls force use of NLS],
91 [ USE_NLS=$enableval ],
95 if test "$USE_NLS" = "yes"; then
97 AC_CHECK_HEADERS(locale.h)
98 AC_CHECK_FUNCS(setlocale)
99 AC_SUBST(HAVE_LOCALE_H)
101 CPPFLAGS="$CPPFLAGS $NLS_CFLAGS"
102 AC_TRY_CPP([#include <libintl.h>],
103 [ AC_DEFINE(HAVE_LIBINTL_H)
104 AC_MSG_RESULT([checking for libintl.h... yes]) ],
105 [ AC_MSG_WARN(not found header file: libintl.h !!!)
110 if test "$USE_NLS" = "yes"; then
111 AC_CHECK_FUNC(gettext,
112 AC_DEFINE(HAVE_LIBINTL),
113 AC_CHECK_LIB(intl, gettext,
114 [ NLS_LIBS="$NLS_LIBS -lintl"
115 AC_DEFINE(HAVE_LIBINTL) ],
116 [ AC_MSG_WARN(not found library: intl !!!)
123 if test "$USE_NLS" = "yes"; then
125 AC_SUBST(HAVE_LIBINTL_H)
126 AC_SUBST(HAVE_LIBINTL)
129 LOCALEDIR='${prefix}/share/locale'
130 AC_ARG_WITH(locale-dir,
131 [ --with-locale-dir=DIR Location of the locale file(s)
132 [PREFIX/share/locale]],
133 [ if test x$withval = xyes; then
134 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
136 if test x$withval = xno; then
137 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
146 AC_PATH_PROG(MSGFMT, msgfmt, $MSGFMT)
147 if test -n "$MSGFMT"; then
148 AC_CHECK_FUNCS(dcgettext)
149 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
150 AC_PATH_PROG(XGETTEXT, xgettext, $XGETTEXT)
151 AC_PATH_PROG(MSGMERGE, msgmerge, $MSGMERGE)
153 dnl Test whether we really found GNU xgettext.
154 if test -n "$XGETTEXT"; then
155 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
158 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
163 dnl We add another test for comparing GNU xgettext with openwin xgettext
164 if test -n "$XGETTEXT"; then
165 if $XGETTEXT --help > /dev/null 2> /dev/null; then
168 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
173 dnl Test whether we really found GNU msgfmt.
174 if test -n "$MSGFMT"; then
175 if $MSGFMT < /dev/null 2> /dev/null; then
176 AC_MSG_RESULT([found msgfmt program is not GNU msgfmt; NLS will not be installed])
182 [ extern int _nl_msg_cat_cntr;
183 return _nl_msg_cat_cntr],
192 if test -n "$ALL_LINGUAS"; then
193 for lang in $ALL_LINGUAS; do
194 CATALOGS="$CATALOGS $lang$CATOBJEXT"
200 AC_SUBST(DATADIRNAME)
203 dnl don't use NLS, when there is no gettext installed
204 if test x"$MSGFMT" = x; then
208 if test x"$USE_NLS" = xyes; then
212 dnl ======================== Checks for libraries.
214 AC_ARG_WITH(libpthread,
215 [ --with-libpthread=DIR specifies the base libpthread],
216 [ if test x$withval = xyes
218 AC_MSG_WARN(Usage is: --with-libpthread=DIR)
220 PTHREAD_LIBS="-L$withval/lib/"
221 PTHREAD_CFLAGS="-I$withval/include/"
226 dnl Check for libpthread
227 PTHREAD_LIBS_SAVE="$PTHREAD_LIBS"
229 AC_CHECK_LIB(pthread, pthread_attr_init, [
230 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT"
231 PTHREAD_LIBS="$PTHREAD_LIBS_SAVE -lpthread" ])
233 dnl FIXME: test this on *BSD and report results immediatelly to the ml please
234 dnl If it is not found, try to check for c_r (on FreeBSD)
235 if test "x$PTHREAD_LIBS" = xerror; then
236 AC_CHECK_LIB(c_r, pthread_attr_init, [
237 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_THREAD_SAFE"
238 PTHREAD_LIBS="-pthread" ])
241 dnl FIXME: do we really test here if libc contains this function?
242 if test "x$PTHREAD_LIBS" = xerror -a "x$cross_compiling" = xno; then
243 AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="",
244 AC_MSG_ERROR(not found library: pthread !!!))
247 dnl The following is taken from inn sources
248 AC_MSG_CHECKING(for tm_gmtoff in struct tm)
249 AC_TRY_LINK([#include <time.h>],
250 [struct tm t; t.tm_gmtoff = 0],
252 AC_DEFINE(HAVE_TM_GMTON)],
255 dnl The following is taken from inn sources
256 AC_MSG_CHECKING(for timersub)
257 AC_TRY_LINK([#include <sys/time.h>],
258 [timersub(NULL, NULL, NULL)],
259 [AC_DEFINE(HAVE_TIMEOPS)
260 AC_DEFINE(HAVE_TIMEOPS)
265 dnl Checking for setspeed in termios.h
266 AC_MSG_CHECKING(for cfsetspeed in termios.h)
267 AC_TRY_LINK([#include <termios.h>],
268 [struct termios t; cfsetspeed(&t, B9600);],
269 [AC_DEFINE(HAVE_CFSETSPEED)
274 if test $have_termios = "no"; then
275 AC_MSG_CHECKING(for cfsetispeed and cfsetospeed in termios.h)
276 AC_TRY_LINK([#include <termios.h>],
277 [struct termios t; cfsetispeed(&t, B9600); cfsetospeed(&t, B9600);],
278 [AC_DEFINE(HAVE_CFSETISPEED)
279 AC_DEFINE(HAVE_CFSETOSPEED)
284 if test $have_termios = "no"; then
285 AC_MSG_CHECKING(for c_ispeed and c_ospeed in struct termios)
286 AC_TRY_LINK([#include <termios.h>],
287 [struct termios t; t.c_iflag = B9600; t.c_oflag = B9600;],
288 [AC_DEFINE(HAVE_TERMIOS_CSPEED)
294 dnl ======================== Checks for getopt_long support
296 AC_CHECK_HEADER(getopt.h, ,
297 [CFLAGS="$CFLAGS -I../getopt"])
299 AC_ARG_WITH(gnugetopt,
300 [ --with-getopt=DIR specifies the getopt library location directory],
301 [ if test x$withval=yes; then
302 AC_MSG_WARN(Usage is: --with-getopt=DIR)
304 GETOPT_LIBS="-L$withval"
310 AC_CHECK_FUNC(getopt_long, , [
311 LIBS="$LIBS $GETOPT_LIBS"
312 AC_CHECK_LIB(gnugetopt, getopt_long, LIBS="$LIBS -lgnugetopt",
315 dnl ======================== Checks for X base support
317 if test "$no_x" = yes -o "$with_x" = "no"; then
325 CPPFLAGS="$CPPFLAGS -I$x_includes"
326 AC_CHECK_HEADERS(X11/xpm.h,
330 if test "x$XPMINC" = "xno"; then
336 AC_MSG_WARN(Cannot find include X11/xpm.h)
337 AC_MSG_WARN(Disabling xgnokii.)
338 elif test "x$x_libraries" = "xNONE"; then
344 AC_MSG_WARN(Cannot find library libX11.)
345 AC_MSG_WARN(Disabling xgnokii.)
347 AC_CHECK_LIB(Xpm, XpmWriteFileFromXpmImage,
348 [ XPM_CFLAGS="-I$x_includes" XPM_LIBS="-L$x_libraries -lXpm -lX11"
350 AC_MSG_WARN(Cannot found library libXpm - disabling XPM support.),
351 [ -L$x_libraries -lX11 ]
354 AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config, no)
355 if test "$GTK_CONFIG" = no; then
359 AC_MSG_WARN(Cannot find gtk-config.)
360 AC_MSG_WARN(Disabling xgnokii.)
362 GTK_CFLAGS=`$GTK_CONFIG --cflags`
363 GTK_LIBS=`$GTK_CONFIG --libs`
366 XGNOKIIDIR='${prefix}/share'
367 XGNOKIIPATH=${prefix}/share
368 AC_ARG_WITH(xgnokiidir,
369 [ --with-xgnokiidir=DIR specifies the base for xgnokii],
370 [ if test x$withval = xyes; then
371 AC_MSG_WARN(Usage is: --with-xgnokiilib=DIR)
373 XGNOKIIDIR="$withval"
374 XGNOKIIPATH="$withval"
382 dnl ======================== Check for libsocket
383 AC_CHECK_LIB(socket, socket)
385 dnl ======================== Additional switches
387 AC_ARG_ENABLE(security,
388 [ --enable-security enable all security features ],
389 [ AC_DEFINE(SECURITY)
395 [ --enable-win32 if you want win32 suport ],
401 AC_CHECK_FUNC(grantpt,
403 #define _XOPEN_SOURCE 500
405 #include <features.h>
407 #include <sys/types.h>
408 #include <sys/stat.h>
417 master = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK);
419 err = grantpt(master);
420 err = err || unlockpt(master);
422 name = ptsname(master);
433 AC_DEFINE(USE_UNIX98PTYS),
434 AC_MSG_WARN("No unix98ptys"),
435 AC_MSG_WARN("Ensure to disable unix98ptys when crosscompiling"))
439 dnl ======================== Checks for header files.
442 AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h)
444 dnl ======================== Checks for typedefs, structures, and compiler characteristics.
452 dnl ======================== Checks for library functions.
453 AC_PROG_GCC_TRADITIONAL
457 AC_CHECK_FUNCS(mktime select strdup strstr strtol strtok strsep snprintf)
459 CFLAGS="$CFLAGS $NLS_CFLAGS"
460 LIBS="$LIBS $NLS_LIBS"
464 AC_DEFINE_UNQUOTED(VERSION, "`cat VERSION`")
465 AC_DEFINE_UNQUOTED(XVERSION, "`cat xgnokii/VERSION`")
466 HAVE_XGNOKII=$x_support
469 'config/install-sh -c') INSTALL=`pwd`/$INSTALL
473 SHELL=${CONFIG_SHELL-/bin/sh}
477 solaris*) SHELL=/bin/ksh
481 AC_CONFIG_HEADER(include/config.h)
489 AC_SUBST(XGNOKIIPATH)
490 AC_SUBST(exec_prefix)
494 AC_SUBST(PTHREAD_CFLAGS)
495 AC_SUBST(PTHREAD_LIBS)
499 AC_SUBST(USE_UNIX98PTYS)
500 AC_SUBST(HAVE_XGNOKII)
505 packaging/RedHat/gnokii.spec
506 packaging/Slackware/SlackBuild,
507 [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]
511 dnl ======================== Final report
517 A Linux/Unix toolset and driver for Nokia mobile phones.
519 Copyright (C) 1999-2000 The Gnokii Development Team.
521 This program is free software; you can redistribute it and/or modify
522 it under the terms of the GNU General Public License as published by
523 the Free Software Foundation; either version 2 of the License, or
524 (at your option) any later version.
526 See file COPYING for more details.
528 Host system: $host_os
529 Gnokii version: $VERSION
530 Xgnokii version: $XVERSION
531 X (GTK) support: $x_support
540 Type '${MAKE}' for compilation or '${MAKE} makelib' when want to compile
541 all binaries with one shared library
543 After it '${MAKE} install', '${MAKE} install-suid', '${MAKE} install-strip'
544 or '${MAKE} install-ss' to install gnokii.