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],
54 CFLAGS="-ggdb3 `echo " $CFLAGS "|sed 's/ -O[0-9]* / /g'`" #CFLAGS="-g -Wall"
62 [ --enable-xdebug compile with xdebug code],
68 AC_ARG_ENABLE(rlpdebug,
69 [ --enable-rlpdebug compile with RLP debug code],
70 [ AC_DEFINE(RLP_DEBUG)
75 dnl ======================== NLS support
82 [ --with-libintl=DIR specifies the base NLS],
83 [ if test "x$withval" = "xyes"; then
84 AC_MSG_WARN(Usage is --with-libintl=DIR)
86 NLS_LIBS="-L$withval/lib"
87 NLS_CFLAGS="-I$withval/include"
93 [ --enable-nls force use of NLS],
94 [ USE_NLS=$enableval ],
98 if test "$USE_NLS" = "yes"; then
100 AC_CHECK_HEADERS(locale.h)
101 AC_CHECK_FUNCS(setlocale)
102 AC_SUBST(HAVE_LOCALE_H)
104 CPPFLAGS="$CPPFLAGS $NLS_CFLAGS"
105 AC_TRY_CPP([#include <libintl.h>],
106 [ AC_DEFINE(HAVE_LIBINTL_H)
107 AC_MSG_RESULT([checking for libintl.h... yes]) ],
108 [ AC_MSG_WARN(not found header file: libintl.h !!!)
113 if test "$USE_NLS" = "yes"; then
114 AC_CHECK_FUNC(gettext,
115 AC_DEFINE(HAVE_LIBINTL),
116 AC_CHECK_LIB(intl, gettext,
117 [ NLS_LIBS="$NLS_LIBS -lintl"
118 AC_DEFINE(HAVE_LIBINTL) ],
119 [ AC_MSG_WARN(not found library: intl !!!)
126 if test "$USE_NLS" = "yes"; then
128 AC_SUBST(HAVE_LIBINTL_H)
129 AC_SUBST(HAVE_LIBINTL)
132 LOCALEDIR='${prefix}/share/locale'
133 AC_ARG_WITH(locale-dir,
134 [ --with-locale-dir=DIR Location of the locale file(s)
135 [PREFIX/share/locale]],
136 [ if test x$withval = xyes; then
137 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
139 if test x$withval = xno; then
140 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
149 AC_PATH_PROG(MSGFMT, msgfmt, $MSGFMT)
150 if test -n "$MSGFMT"; then
151 AC_CHECK_FUNCS(dcgettext)
152 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
153 AC_PATH_PROG(XGETTEXT, xgettext, $XGETTEXT)
154 AC_PATH_PROG(MSGMERGE, msgmerge, $MSGMERGE)
156 dnl Test whether we really found GNU xgettext.
157 if test -n "$XGETTEXT"; then
158 if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
161 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
166 dnl We add another test for comparing GNU xgettext with openwin xgettext
167 if test -n "$XGETTEXT"; then
168 if $XGETTEXT --help > /dev/null 2> /dev/null; then
171 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
176 dnl Test whether we really found GNU msgfmt.
177 if test -n "$MSGFMT"; then
178 if $MSGFMT < /dev/null 2> /dev/null; then
179 AC_MSG_RESULT([found msgfmt program is not GNU msgfmt; NLS will not be installed])
185 [ extern int _nl_msg_cat_cntr;
186 return _nl_msg_cat_cntr],
195 if test -n "$ALL_LINGUAS"; then
196 for lang in $ALL_LINGUAS; do
197 CATALOGS="$CATALOGS $lang$CATOBJEXT"
203 AC_SUBST(DATADIRNAME)
206 dnl don't use NLS, when there is no gettext installed
207 if test x"$MSGFMT" = x; then
211 if test x"$USE_NLS" = xyes; then
215 dnl ======================== Checks for libraries.
217 AC_ARG_WITH(libpthread,
218 [ --with-libpthread=DIR specifies the base libpthread],
219 [ if test x$withval = xyes
221 AC_MSG_WARN(Usage is: --with-libpthread=DIR)
223 PTHREAD_LIBS="-L$withval/lib/"
224 PTHREAD_CFLAGS="-I$withval/include/"
229 dnl Check for libpthread
230 PTHREAD_LIBS_SAVE="$PTHREAD_LIBS"
232 AC_CHECK_LIB(pthread, pthread_attr_init, [
233 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT"
234 PTHREAD_LIBS="$PTHREAD_LIBS_SAVE -lpthread" ])
236 dnl FIXME: test this on *BSD and report results immediatelly to the ml please
237 dnl If it is not found, try to check for c_r (on FreeBSD)
238 if test "x$PTHREAD_LIBS" = xerror; then
239 AC_CHECK_LIB(c_r, pthread_attr_init, [
240 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_THREAD_SAFE"
241 PTHREAD_LIBS="-pthread" ])
244 dnl FIXME: do we really test here if libc contains this function?
245 if test "x$PTHREAD_LIBS" = xerror -a "x$cross_compiling" = xno; then
246 AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="",
247 AC_MSG_ERROR(not found library: pthread !!!))
250 dnl The following is taken from inn sources
251 AC_MSG_CHECKING(for tm_gmtoff in struct tm)
252 AC_TRY_LINK([#include <time.h>],
253 [struct tm t; t.tm_gmtoff = 0],
255 AC_DEFINE(HAVE_TM_GMTON)],
258 dnl The following is taken from inn sources
259 AC_MSG_CHECKING(for timersub)
260 AC_TRY_LINK([#include <sys/time.h>],
261 [timersub(NULL, NULL, NULL)],
262 [AC_DEFINE(HAVE_TIMEOPS)
263 AC_DEFINE(HAVE_TIMEOPS)
268 dnl Checking for setspeed in termios.h
269 AC_MSG_CHECKING(for cfsetspeed in termios.h)
270 AC_TRY_LINK([#include <termios.h>],
271 [struct termios t; cfsetspeed(&t, B9600);],
272 [AC_DEFINE(HAVE_CFSETSPEED)
277 if test $have_termios = "no"; then
278 AC_MSG_CHECKING(for cfsetispeed and cfsetospeed in termios.h)
279 AC_TRY_LINK([#include <termios.h>],
280 [struct termios t; cfsetispeed(&t, B9600); cfsetospeed(&t, B9600);],
281 [AC_DEFINE(HAVE_CFSETISPEED)
282 AC_DEFINE(HAVE_CFSETOSPEED)
287 if test $have_termios = "no"; then
288 AC_MSG_CHECKING(for c_ispeed and c_ospeed in struct termios)
289 AC_TRY_LINK([#include <termios.h>],
290 [struct termios t; t.c_iflag = B9600; t.c_oflag = B9600;],
291 [AC_DEFINE(HAVE_TERMIOS_CSPEED)
297 dnl ======================== Checks for getopt_long support
299 AC_CHECK_HEADER(getopt.h, ,
300 [CFLAGS="$CFLAGS -I../getopt"])
302 AC_ARG_WITH(gnugetopt,
303 [ --with-getopt=DIR specifies the getopt library location directory],
304 [ if test x$withval=yes; then
305 AC_MSG_WARN(Usage is: --with-getopt=DIR)
307 GETOPT_LIBS="-L$withval"
313 AC_CHECK_FUNC(getopt_long, , [
314 LIBS="$LIBS $GETOPT_LIBS"
315 AC_CHECK_LIB(gnugetopt, getopt_long, LIBS="$LIBS -lgnugetopt",
318 dnl ======================== Checks for X base support
320 if test "$no_x" = yes -o "$with_x" = "no"; then
328 CPPFLAGS="$CPPFLAGS -I$x_includes"
329 AC_CHECK_HEADERS(X11/xpm.h,
333 if test "x$XPMINC" = "xno"; then
339 AC_MSG_WARN(Cannot find include X11/xpm.h)
340 AC_MSG_WARN(Disabling xgnokii.)
341 elif test "x$x_libraries" = "xNONE"; then
347 AC_MSG_WARN(Cannot find library libX11.)
348 AC_MSG_WARN(Disabling xgnokii.)
350 AC_CHECK_LIB(Xpm, XpmWriteFileFromXpmImage,
351 [ XPM_CFLAGS="-I$x_includes" XPM_LIBS="-L$x_libraries -lXpm -lX11"
353 AC_MSG_WARN(Cannot found library libXpm - disabling XPM support.),
354 [ -L$x_libraries -lX11 ]
357 AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config, no)
358 if test "$GTK_CONFIG" = no; then
362 AC_MSG_WARN(Cannot find gtk-config.)
363 AC_MSG_WARN(Disabling xgnokii.)
365 GTK_CFLAGS=`$GTK_CONFIG --cflags`
366 GTK_LIBS=`$GTK_CONFIG --libs`
369 XGNOKIIDIR='${prefix}/share'
370 XGNOKIIPATH=${prefix}/share
371 AC_ARG_WITH(xgnokiidir,
372 [ --with-xgnokiidir=DIR specifies the base for xgnokii],
373 [ if test x$withval = xyes; then
374 AC_MSG_WARN(Usage is: --with-xgnokiilib=DIR)
376 XGNOKIIDIR="$withval"
377 XGNOKIIPATH="$withval"
385 dnl ======================== Check for libsocket
386 AC_CHECK_LIB(socket, socket)
388 dnl ======================== Additional switches
390 AC_ARG_ENABLE(security,
391 [ --enable-security enable all security features ],
392 [ AC_DEFINE(SECURITY)
398 [ --enable-win32 if you want win32 suport ],
404 AC_CHECK_FUNC(grantpt,
406 #define _XOPEN_SOURCE 500
408 #include <features.h>
410 #include <sys/types.h>
411 #include <sys/stat.h>
420 master = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK);
422 err = grantpt(master);
423 err = err || unlockpt(master);
425 name = ptsname(master);
436 AC_DEFINE(USE_UNIX98PTYS),
437 AC_MSG_WARN("No unix98ptys"),
438 AC_MSG_WARN("Ensure to disable unix98ptys when crosscompiling"))
442 dnl ======================== Checks for header files.
445 AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h)
447 dnl ======================== Checks for typedefs, structures, and compiler characteristics.
455 dnl ======================== Checks for library functions.
456 AC_PROG_GCC_TRADITIONAL
460 AC_CHECK_FUNCS(mktime select strdup strstr strtol strtok strsep snprintf)
462 CFLAGS="$CFLAGS $NLS_CFLAGS"
463 LIBS="$LIBS $NLS_LIBS"
467 AC_DEFINE_UNQUOTED(VERSION, "`cat VERSION`")
468 AC_DEFINE_UNQUOTED(XVERSION, "`cat xgnokii/VERSION`")
469 HAVE_XGNOKII=$x_support
472 'config/install-sh -c') INSTALL=`pwd`/$INSTALL
476 SHELL=${CONFIG_SHELL-/bin/sh}
480 solaris*) SHELL=/bin/ksh
484 AC_CONFIG_HEADER(include/config.h)
492 AC_SUBST(XGNOKIIPATH)
493 AC_SUBST(exec_prefix)
497 AC_SUBST(PTHREAD_CFLAGS)
498 AC_SUBST(PTHREAD_LIBS)
502 AC_SUBST(USE_UNIX98PTYS)
503 AC_SUBST(HAVE_XGNOKII)
508 packaging/RedHat/gnokii.spec
509 packaging/Slackware/SlackBuild,
510 [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]
514 dnl ======================== Final report
520 A Linux/Unix toolset and driver for Nokia mobile phones.
522 Copyright (C) 1999-2000 The Gnokii Development Team.
524 This program is free software; you can redistribute it and/or modify
525 it under the terms of the GNU General Public License as published by
526 the Free Software Foundation; either version 2 of the License, or
527 (at your option) any later version.
529 See file COPYING for more details.
531 Host system: $host_os
532 Gnokii version: $VERSION
533 Xgnokii version: $XVERSION
534 X (GTK) support: $x_support
543 Type '${MAKE}' for compilation or '${MAKE} makelib' when want to compile
544 all binaries with one shared library
546 After it '${MAKE} install', '${MAKE} install-suid', '${MAKE} install-strip'
547 or '${MAKE} install-ss' to install gnokii.