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)
30 AC_PATH_PROG(AS, as, no)
32 AC_PATH_PROG(RM, rm, no)
33 AC_PATH_PROG(FIND, find, no)
34 AC_CHECK_PROGS(MAKE, gmake make)
37 dnl Let us have $prefix variable aviable here
38 test x"$prefix" = xNONE && prefix="$ac_default_prefix"
40 AC_ARG_WITH(cfg_model,
41 [ --with-cfg-model=5110 specifies the mobile phone model],,
42 [ with_cfg_model="5110" ])
43 AC_DEFINE_UNQUOTED(CONFIG_CFG_MODEL, "$with_cfg_model")
45 [ --with-cfg-port=/dev/ttyS0 specifies the mobile phone port],,
46 [ with_cfg_port="/dev/ttyS0" ])
47 AC_DEFINE_UNQUOTED(CONFIG_CFG_PORT, "$with_cfg_port")
48 AC_ARG_WITH(cfg_initlength,
49 [ --with-cfg-initlength=default specifies the mobile phone initlength],,
50 [ with_cfg_initlength="default" ])
51 AC_DEFINE_UNQUOTED(CONFIG_CFG_INITLENGTH, "$with_cfg_initlength")
54 [ --enable-debug compile with debug code],
57 CFLAGS="-ggdb3 `echo " $CFLAGS "|sed 's/ -O[0-9]* / /g'`" #CFLAGS="-g -Wall"
65 [ --enable-xdebug compile with xdebug code],
71 AC_ARG_ENABLE(rlpdebug,
72 [ --enable-rlpdebug compile with RLP debug code],
73 [ AC_DEFINE(RLP_DEBUG)
78 dnl ======================== NLS support
85 [ --with-libintl=DIR specifies the base NLS],
86 [ if test "x$withval" = "xyes"; then
87 AC_MSG_WARN(Usage is --with-libintl=DIR)
89 NLS_LIBS="-L$withval/lib"
90 NLS_CFLAGS="-I$withval/include"
96 [ --enable-nls force use of NLS],
97 [ USE_NLS=$enableval ],
101 if test "$USE_NLS" = "yes"; then
103 AC_CHECK_HEADERS(locale.h)
104 AC_CHECK_FUNCS(setlocale)
105 AC_SUBST(HAVE_LOCALE_H)
107 CPPFLAGS="$CPPFLAGS $NLS_CFLAGS"
108 AC_TRY_CPP([#include <libintl.h>],
109 [ AC_DEFINE(HAVE_LIBINTL_H)
110 AC_MSG_RESULT([checking for libintl.h... yes]) ],
111 [ AC_MSG_WARN(not found header file: libintl.h !!!)
116 if test "$USE_NLS" = "yes"; then
117 AC_CHECK_FUNC(gettext,
118 AC_DEFINE(HAVE_LIBINTL),
119 AC_CHECK_LIB(intl, gettext,
120 [ NLS_LIBS="$NLS_LIBS -lintl"
121 AC_DEFINE(HAVE_LIBINTL) ],
122 [ AC_MSG_WARN(not found library: intl !!!)
129 if test "$USE_NLS" = "yes"; then
131 AC_SUBST(HAVE_LIBINTL_H)
132 AC_SUBST(HAVE_LIBINTL)
135 LOCALEDIR='${prefix}/share/locale'
136 AC_ARG_WITH(locale-dir,
137 [ --with-locale-dir=DIR Location of the locale file(s)
138 [PREFIX/share/locale]],
139 [ if test x$withval = xyes; then
140 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
142 if test x$withval = xno; then
143 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
152 AC_PATH_PROG(MSGFMT, msgfmt, $MSGFMT)
153 if test -n "$MSGFMT"; then
154 AC_CHECK_FUNCS(dcgettext)
155 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
156 AC_PATH_PROG(XGETTEXT, xgettext, $XGETTEXT)
157 AC_PATH_PROG(MSGMERGE, msgmerge, $MSGMERGE)
159 dnl Test whether we really found GNU xgettext.
160 if test -n "$XGETTEXT"; then
161 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
164 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
169 dnl We add another test for comparing GNU xgettext with openwin xgettext
170 if test -n "$XGETTEXT"; then
171 if $XGETTEXT --help > /dev/null 2> /dev/null; then
174 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
179 dnl Test whether we really found GNU msgfmt.
180 if test -n "$MSGFMT"; then
181 if $MSGFMT < /dev/null 2> /dev/null; then
182 AC_MSG_RESULT([found msgfmt program is not GNU msgfmt; NLS will not be installed])
188 [ extern int _nl_msg_cat_cntr;
189 return _nl_msg_cat_cntr],
198 if test -n "$ALL_LINGUAS"; then
199 for lang in $ALL_LINGUAS; do
200 CATALOGS="$CATALOGS $lang$CATOBJEXT"
206 AC_SUBST(DATADIRNAME)
209 dnl don't use NLS, when there is no gettext installed
210 if test x"$MSGFMT" = x; then
214 if test x"$USE_NLS" = xyes; then
218 dnl ======================== Checks for libraries.
220 AC_ARG_WITH(libpthread,
221 [ --with-libpthread=DIR specifies the base libpthread],
222 [ if test x$withval = xyes
224 AC_MSG_WARN(Usage is: --with-libpthread=DIR)
226 PTHREAD_LIBS="-L$withval/lib/"
227 PTHREAD_CFLAGS="-I$withval/include/"
232 dnl Check for libpthread
233 PTHREAD_LIBS_SAVE="$PTHREAD_LIBS"
235 AC_CHECK_LIB(pthread, pthread_attr_init, [
236 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT"
237 PTHREAD_LIBS="$PTHREAD_LIBS_SAVE -lpthread" ])
239 dnl FIXME: test this on *BSD and report results immediatelly to the ml please
240 dnl If it is not found, try to check for c_r (on FreeBSD)
241 if test "x$PTHREAD_LIBS" = xerror; then
242 AC_CHECK_LIB(c_r, pthread_attr_init, [
243 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_THREAD_SAFE"
244 PTHREAD_LIBS="-pthread" ])
247 dnl FIXME: do we really test here if libc contains this function?
248 if test "x$PTHREAD_LIBS" = xerror -a "x$cross_compiling" = xno; then
249 AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="",
250 AC_MSG_ERROR(not found library: pthread !!!))
253 dnl The following is taken from inn sources
254 AC_MSG_CHECKING(for tm_gmtoff in struct tm)
255 AC_TRY_LINK([#include <time.h>],
256 [struct tm t; t.tm_gmtoff = 0],
258 AC_DEFINE(HAVE_TM_GMTON)],
261 dnl The following is taken from inn sources
262 AC_MSG_CHECKING(for timersub)
263 AC_TRY_LINK([#include <sys/time.h>],
264 [timersub(NULL, NULL, NULL)],
265 [AC_DEFINE(HAVE_TIMEOPS)
266 AC_DEFINE(HAVE_TIMEOPS)
271 dnl Checking for setspeed in termios.h
272 AC_MSG_CHECKING(for cfsetspeed in termios.h)
273 AC_TRY_LINK([#include <termios.h>],
274 [struct termios t; cfsetspeed(&t, B9600);],
275 [AC_DEFINE(HAVE_CFSETSPEED)
280 if test $have_termios = "no"; then
281 AC_MSG_CHECKING(for cfsetispeed and cfsetospeed in termios.h)
282 AC_TRY_LINK([#include <termios.h>],
283 [struct termios t; cfsetispeed(&t, B9600); cfsetospeed(&t, B9600);],
284 [AC_DEFINE(HAVE_CFSETISPEED)
285 AC_DEFINE(HAVE_CFSETOSPEED)
290 if test $have_termios = "no"; then
291 AC_MSG_CHECKING(for c_ispeed and c_ospeed in struct termios)
292 AC_TRY_LINK([#include <termios.h>],
293 [struct termios t; t.c_iflag = B9600; t.c_oflag = B9600;],
294 [AC_DEFINE(HAVE_TERMIOS_CSPEED)
300 dnl ======================== Checks for getopt_long support
302 AC_CHECK_HEADER(getopt.h, ,
303 [CFLAGS="$CFLAGS -I../getopt"])
305 AC_ARG_WITH(gnugetopt,
306 [ --with-getopt=DIR specifies the getopt library location directory],
307 [ if test x$withval=yes; then
308 AC_MSG_WARN(Usage is: --with-getopt=DIR)
310 GETOPT_LIBS="-L$withval"
316 AC_CHECK_FUNC(getopt_long, , [
317 LIBS="$LIBS $GETOPT_LIBS"
318 AC_CHECK_LIB(gnugetopt, getopt_long, LIBS="$LIBS -lgnugetopt",
321 dnl ======================== Checks for X base support
323 if test "$no_x" = yes -o "$with_x" = "no"; then
331 CPPFLAGS="$CPPFLAGS -I$x_includes"
332 AC_CHECK_HEADERS(X11/xpm.h,
336 if test "x$XPMINC" = "xno"; then
342 AC_MSG_WARN(Cannot find include X11/xpm.h)
343 AC_MSG_WARN(Disabling xgnokii.)
344 elif test "x$x_libraries" = "xNONE"; then
350 AC_MSG_WARN(Cannot find library libX11.)
351 AC_MSG_WARN(Disabling xgnokii.)
353 AC_CHECK_LIB(Xpm, XpmWriteFileFromXpmImage,
354 [ XPM_CFLAGS="-I$x_includes" XPM_LIBS="-L$x_libraries -lXpm -lX11"
356 AC_MSG_WARN(Cannot found library libXpm - disabling XPM support.),
357 [ -L$x_libraries -lX11 ]
360 AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config, no)
361 if test "$GTK_CONFIG" = no; then
365 AC_MSG_WARN(Cannot find gtk-config.)
366 AC_MSG_WARN(Disabling xgnokii.)
368 GTK_CFLAGS=`$GTK_CONFIG --cflags`
369 GTK_LIBS=`$GTK_CONFIG --libs`
372 XGNOKIIDIR='${prefix}/share'
373 XGNOKIIPATH=${prefix}/share
374 AC_ARG_WITH(xgnokiidir,
375 [ --with-xgnokiidir=DIR specifies the base for xgnokii],
376 [ if test x$withval = xyes; then
377 AC_MSG_WARN(Usage is: --with-xgnokiilib=DIR)
379 XGNOKIIDIR="$withval"
380 XGNOKIIPATH="$withval"
388 dnl ======================== Check for libsocket
389 AC_CHECK_LIB(socket, socket)
391 dnl ======================== Additional switches
393 AC_ARG_ENABLE(security,
394 [ --enable-security enable all security features ],
395 [ AC_DEFINE(SECURITY)
401 [ --enable-win32 if you want win32 suport ],
407 AC_CHECK_FUNC(grantpt,
409 #define _XOPEN_SOURCE 500
411 #include <features.h>
413 #include <sys/types.h>
414 #include <sys/stat.h>
423 master = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK);
425 err = grantpt(master);
426 err = err || unlockpt(master);
428 name = ptsname(master);
439 AC_DEFINE(USE_UNIX98PTYS),
440 AC_MSG_WARN("No unix98ptys"),
441 AC_MSG_WARN("Ensure to disable unix98ptys when crosscompiling"))
445 dnl ======================== Checks for header files.
448 AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h)
450 dnl ======================== Checks for typedefs, structures, and compiler characteristics.
458 dnl ======================== Checks for library functions.
459 AC_PROG_GCC_TRADITIONAL
463 AC_CHECK_FUNCS(mktime select strdup strstr strtol strtok strsep snprintf)
465 CFLAGS="$CFLAGS $NLS_CFLAGS"
466 LIBS="$LIBS $NLS_LIBS"
470 AC_DEFINE_UNQUOTED(VERSION, "`cat VERSION`")
471 AC_DEFINE_UNQUOTED(XVERSION, "`cat xgnokii/VERSION`")
472 HAVE_XGNOKII=$x_support
475 'config/install-sh -c') INSTALL=`pwd`/$INSTALL
479 SHELL=${CONFIG_SHELL-/bin/sh}
483 solaris*) SHELL=/bin/ksh
487 AC_CONFIG_HEADER(include/config.h)
496 AC_SUBST(XGNOKIIPATH)
497 AC_SUBST(exec_prefix)
501 AC_SUBST(PTHREAD_CFLAGS)
502 AC_SUBST(PTHREAD_LIBS)
506 AC_SUBST(USE_UNIX98PTYS)
507 AC_SUBST(HAVE_XGNOKII)
512 packaging/RedHat/gnokii.spec
513 packaging/Slackware/SlackBuild,
514 [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]
518 dnl ======================== Final report
524 A Linux/Unix toolset and driver for Nokia mobile phones.
526 Copyright (C) 1999-2000 The Gnokii Development Team.
528 This program is free software; you can redistribute it and/or modify
529 it under the terms of the GNU General Public License as published by
530 the Free Software Foundation; either version 2 of the License, or
531 (at your option) any later version.
533 See file COPYING for more details.
535 Host system: $host_os
536 Gnokii version: $VERSION
537 Xgnokii version: $XVERSION
538 X (GTK) support: $x_support
547 Type '${MAKE}' for compilation or '${MAKE} makelib' when want to compile
548 all binaries with one shared library
550 After it '${MAKE} install', '${MAKE} install-suid', '${MAKE} install-strip'
551 or '${MAKE} install-ss' to install gnokii.