Cosmetic: removed no longer needed filter-out of "-pg" option
[gnokii.git] / configure.in
1 dnl
2 dnl  Makefile for the GNOKII tool suite.
3 dnl 
4 dnl  Copyright (C) 1999 Hugh Blemings & Pavel Janík ml.
5 dnl                2000 Karel Zak, Pawe³ Kot
6 dnl
7 dnl  $Id$
8 dnl
9
10 AC_INIT(gnokii/gnokii.c)
11
12 AC_CONFIG_AUX_DIR(config)
13
14 AC_CANONICAL_SYSTEM
15 AC_PREFIX_DEFAULT("/usr/local")
16
17 dnl ======================== Default setting
18 test -n "$CFLAGS"   || export CFLAGS="-O2 -Wall"
19 ALL_LINGUAS="cs de et fi nl sk pl it"
20
21 dnl ======================== Checks for programs.
22 AC_PROG_CC
23 AC_LANG_C
24 AC_PROG_CPP
25 AC_PROG_LEX
26 if test -z "$AR";then
27         AC_PATH_PROG(AR, ar, no)
28 fi
29 if test -z "$AS";then
30         AC_PATH_PROG(AS, as, no)
31 fi
32 AC_PATH_PROG(RM, rm, no)
33 AC_PATH_PROG(FIND, find, no)
34 AC_CHECK_PROGS(MAKE, gmake make)
35 AC_PROG_INSTALL
36
37 dnl Let us have $prefix variable aviable here
38 test x"$prefix" = xNONE && prefix="$ac_default_prefix"
39
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")
44 AC_ARG_WITH(cfg_port,
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")
52
53 AC_ARG_ENABLE(debug, 
54         [  --enable-debug          compile with debug code],
55         [
56 changequote({,})dnl
57           CFLAGS="-ggdb3 `echo " $CFLAGS "|sed 's/ -O[0-9]* / /g'`" #CFLAGS="-g -Wall"
58 changequote([,])dnl
59           AC_DEFINE(DEBUG)
60           debug="yes" ],
61         [ debug="no"  ]
62 )
63
64 AC_ARG_ENABLE(xdebug,
65         [  --enable-xdebug         compile with xdebug code],
66         [ AC_DEFINE(XDEBUG)
67           xdebug="yes" ],
68         [ xdebug="no"  ]
69 )
70
71 AC_ARG_ENABLE(rlpdebug, 
72         [  --enable-rlpdebug       compile with RLP debug code],
73         [ AC_DEFINE(RLP_DEBUG)
74           rlpdebug="yes" ],
75         [ rlpdebug="no"  ]
76 )
77
78 dnl ======================== NLS support
79
80 LIBS=""
81 NLS_LIBS=""
82 NLS_CFLAGS=""
83
84 AC_ARG_WITH(libintl,
85         [  --with-libintl=DIR      specifies the base NLS],
86         [ if test "x$withval" = "xyes"; then
87                 AC_MSG_WARN(Usage is --with-libintl=DIR)
88           else
89                 NLS_LIBS="-L$withval/lib"
90                 NLS_CFLAGS="-I$withval/include"
91           fi
92         ]
93 )
94
95 AC_ARG_ENABLE(nls,
96         [  --enable-nls            force use of NLS],
97         [ USE_NLS=$enableval ],
98         [ USE_NLS=no ]
99 )
100
101 if test "$USE_NLS" = "yes"; then
102         AC_PROG_MAKE_SET
103         AC_CHECK_HEADERS(locale.h)
104         AC_CHECK_FUNCS(setlocale)
105         AC_SUBST(HAVE_LOCALE_H)  
106
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 !!!)
112                      USE_NLS=no ]
113         )
114 fi
115
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 !!!)
123                                      USE_NLS=no ],
124                                    $NLS_LIBS
125                       )
126         )
127 fi
128
129 if test "$USE_NLS" = "yes"; then
130
131         AC_SUBST(HAVE_LIBINTL_H)
132         AC_SUBST(HAVE_LIBINTL)
133
134         dnl Handle localedir
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)
141                       else
142                         if test x$withval = xno; then
143                                 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
144                         else
145                                 LOCALEDIR=$withval
146                         fi
147                       fi
148                     ]
149         )
150         AC_SUBST(LOCALEDIR)
151
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)
158
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
162                                 : ;
163                         else
164                                 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
165                                 XGETTEXT=""
166                         fi
167                 fi
168
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
172                                 : ;
173                         else
174                                 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
175                                 XGETTEXT=""
176                         fi
177                 fi
178
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])
183                                 MSGFMT=""
184                         fi
185                 fi
186
187                 AC_TRY_LINK(,
188                             [ extern int _nl_msg_cat_cntr;
189                               return _nl_msg_cat_cntr],
190                             [ CATOBJEXT=.gmo
191                               DATADIRNAME=share],  
192                             [ CATOBJEXT=.mo
193                               DATADIRNAME=lib]
194                 )
195                 INSTOBJEXT=.mo
196         fi
197
198         if test -n "$ALL_LINGUAS"; then
199                 for lang in $ALL_LINGUAS; do
200                         CATALOGS="$CATALOGS $lang$CATOBJEXT"
201                 done
202         fi
203         AC_SUBST(CATALOGS)
204         AC_SUBST(CATOBJEXT)
205         AC_SUBST(INSTOBJEXT)
206         AC_SUBST(DATADIRNAME)
207 fi
208
209 dnl don't use NLS, when there is no gettext installed
210 if test x"$MSGFMT" = x; then
211         USE_NLS=no
212 fi
213
214 if test x"$USE_NLS" = xyes; then
215         AC_DEFINE(USE_NLS)
216 fi
217
218 dnl ======================== Checks for libraries.
219
220 AC_ARG_WITH(libpthread, 
221    [  --with-libpthread=DIR   specifies the base libpthread],
222    [ if test x$withval = xyes
223      then 
224       AC_MSG_WARN(Usage is: --with-libpthread=DIR)
225      else
226       PTHREAD_LIBS="-L$withval/lib/"
227       PTHREAD_CFLAGS="-I$withval/include/"
228      fi
229    ]
230 )
231
232 dnl Check for libpthread
233 PTHREAD_LIBS_SAVE="$PTHREAD_LIBS"
234 PTHREAD_LIBS=error
235 AC_CHECK_LIB(pthread, pthread_attr_init, [
236                       PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT"
237                       PTHREAD_LIBS="$PTHREAD_LIBS_SAVE -lpthread" ])
238
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" ])
245 fi
246
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 !!!))
251 fi
252
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],
257         [AC_MSG_RESULT(yes)
258          AC_DEFINE(HAVE_TM_GMTON)],
259         [AC_MSG_RESULT(no)])
260
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)
267          AC_MSG_RESULT(yes)],
268         [AC_MSG_RESULT(no)])
269
270 have_termios="no"
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)
276          have_termios="yes"
277          AC_MSG_RESULT(yes)],
278         AC_MSG_RESULT(no))
279
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)
286                 have_termios="yes"
287                 AC_MSG_RESULT(yes)],
288                [AC_MSG_RESULT(no)])
289
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)
295                    AC_MSG_RESULT(yes)],
296                   [AC_MSG_RESULT(no)])
297    fi
298 fi
299
300 dnl ======================== Checks for getopt_long support 
301
302 AC_CHECK_HEADER(getopt.h, ,
303       [CFLAGS="$CFLAGS -I../getopt"])
304
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) 
309      else
310         GETOPT_LIBS="-L$withval"
311      fi
312    ]
313 )
314
315 OWN_GETOPT=""
316 AC_CHECK_FUNC(getopt_long, , [
317         LIBS="$LIBS $GETOPT_LIBS"
318            AC_CHECK_LIB(gnugetopt, getopt_long, LIBS="$LIBS -lgnugetopt",
319             OWN_GETOPT="1")])
320
321 dnl ======================== Checks for X base support 
322
323 if test "$no_x" = yes -o "$with_x" = "no"; then
324    x_support="no"
325    XPM_CFLAGS=""
326    XPM_LIBS=""
327    GTK_CFLAGS=""
328    GTK_LIBS=""
329 else
330    AC_PATH_X
331    CPPFLAGS="$CPPFLAGS -I$x_includes"
332    AC_CHECK_HEADERS(X11/xpm.h,
333                     [ XPMINC="yes" ],
334                     [ XPMINC="no" ])
335
336    if test "x$XPMINC" = "xno"; then
337       x_support="no"
338       XPM_CFLAGS=""
339       XPM_LIBS=""
340       GTK_CFLAGS=""
341       GTK_LIBS=""
342       AC_MSG_WARN(Cannot find include X11/xpm.h)
343       AC_MSG_WARN(Disabling xgnokii.)
344    elif test "x$x_libraries" = "xNONE"; then
345       x_support="no"
346       XPM_CFLAGS=""
347       XPM_LIBS=""
348       GTK_CFLAGS=""
349       GTK_LIBS=""
350       AC_MSG_WARN(Cannot find library libX11.)
351       AC_MSG_WARN(Disabling xgnokii.)
352    else
353       AC_CHECK_LIB(Xpm, XpmWriteFileFromXpmImage,
354             [ XPM_CFLAGS="-I$x_includes" XPM_LIBS="-L$x_libraries -lXpm -lX11"
355               AC_DEFINE(XPM) ],
356             AC_MSG_WARN(Cannot found library libXpm - disabling XPM support.),
357             [ -L$x_libraries -lX11 ]
358       )
359
360       AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config, no)
361       if test "$GTK_CONFIG" = no; then
362          x_support="no"
363          GTK_CFLAGS=""
364          GTK_LIBS=""
365          AC_MSG_WARN(Cannot find gtk-config.)
366          AC_MSG_WARN(Disabling xgnokii.)
367       else
368          GTK_CFLAGS=`$GTK_CONFIG --cflags`
369          GTK_LIBS=`$GTK_CONFIG --libs`
370          x_support="yes"   
371
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)
378               else
379                  XGNOKIIDIR="$withval"
380                  XGNOKIIPATH="$withval"
381               fi
382             ]
383          )
384       fi
385    fi
386 fi
387
388 dnl ======================== Check for libsocket
389 AC_CHECK_LIB(socket, socket)
390
391 dnl ======================== Additional switches
392
393 AC_ARG_ENABLE(security, 
394    [  --enable-security       enable all security features ],
395    [ AC_DEFINE(SECURITY)
396      security="yes" ],
397    [ security="no"  ]
398 )
399
400 AC_ARG_ENABLE(win32, 
401    [  --enable-win32          if you want win32 suport ],
402    [ AC_DEFINE(WIN32)
403      win32="-DWIN32" ],
404    [ win32=""]
405 )
406
407 AC_CHECK_FUNC(grantpt,
408    [ AC_TRY_RUN([
409 #define  _XOPEN_SOURCE 500
410
411 #include <features.h>
412 #include <stdlib.h>
413 #include <sys/types.h>
414 #include <sys/stat.h>
415 #include <fcntl.h>
416 #include <unistd.h>
417
418 int main()
419 {
420         char *name = NULL;
421         int master, err;
422
423         master = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK);
424         if (master >= 0) {
425                 err = grantpt(master);
426                 err = err || unlockpt(master);
427                 if (!err) {
428                         name = ptsname(master);
429                 } else {
430                         exit(-1);
431                 }
432         } else {
433                 exit(-1);
434         }
435         close(master);
436         exit(0);
437 }
438                 ],
439                 AC_DEFINE(USE_UNIX98PTYS),
440                 AC_MSG_WARN("No unix98ptys"),
441                 AC_MSG_WARN("Ensure to disable unix98ptys when crosscompiling"))
442    ]
443 )
444
445 dnl ======================== Checks for header files.
446 AC_HEADER_STDC
447 AC_HEADER_SYS_WAIT
448 AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h)
449
450 dnl ======================== Checks for typedefs, structures, and compiler characteristics.
451 AC_C_CONST
452 AC_C_INLINE
453 AC_TYPE_PID_T
454 AC_TYPE_SIZE_T
455 AC_HEADER_TIME
456 AC_STRUCT_TM
457
458 dnl ======================== Checks for library functions.
459 AC_PROG_GCC_TRADITIONAL
460 AC_FUNC_MEMCMP
461 AC_TYPE_SIGNAL
462 AC_FUNC_STRFTIME
463 AC_CHECK_FUNCS(mktime select strdup strstr strtol strtok strsep snprintf)
464
465 CFLAGS="$CFLAGS $NLS_CFLAGS"
466 LIBS="$LIBS $NLS_LIBS"
467
468 PACKAGE=gnokii
469 XPACKAGE=xgnokii
470 AC_DEFINE_UNQUOTED(VERSION, "`cat VERSION`")
471 AC_DEFINE_UNQUOTED(XVERSION, "`cat xgnokii/VERSION`")
472 HAVE_XGNOKII=$x_support
473
474 case "$INSTALL" in
475   'config/install-sh -c') INSTALL=`pwd`/$INSTALL
476    ;;
477 esac
478
479 SHELL=${CONFIG_SHELL-/bin/sh}
480
481 AC_SUBST(SHELL)
482 case "$build_os" in
483   solaris*) SHELL=/bin/ksh
484    ;;
485 esac
486
487 AC_CONFIG_HEADER(include/config.h)
488
489 AC_SUBST(PACKAGE)
490 AC_SUBST(VERSION)
491 AC_SUBST(AR)
492 AC_SUBST(AS)
493 AC_SUBST(XVERSION)
494 AC_SUBST(XPACKAGE)
495 AC_SUBST(XGNOKIIDIR)
496 AC_SUBST(XGNOKIIPATH)
497 AC_SUBST(exec_prefix)
498 AC_SUBST(USE_NLS)
499 AC_SUBST(GTK_CFLAGS)
500 AC_SUBST(GTK_LIBS)
501 AC_SUBST(PTHREAD_CFLAGS)
502 AC_SUBST(PTHREAD_LIBS)
503 AC_SUBST(XPM_CFLAGS)
504 AC_SUBST(XPM_LIBS)
505 AC_SUBST(OWN_GETOPT)
506 AC_SUBST(USE_UNIX98PTYS)
507 AC_SUBST(HAVE_XGNOKII)
508
509 AC_OUTPUT(
510    Makefile.global
511    po/Makefile.in
512    packaging/RedHat/gnokii.spec
513    packaging/Slackware/SlackBuild,
514    [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]
515    )
516
517
518 dnl ======================== Final report
519
520 echo "
521
522   G N O K I I
523
524   A Linux/Unix toolset and driver for Nokia mobile phones.
525
526   Copyright (C) 1999-2000  The Gnokii Development Team.
527
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.
532  
533   See file COPYING for more details.
534
535     Host system:        $host_os
536     Gnokii version:     $VERSION
537     Xgnokii version:    $XVERSION
538     X (GTK) support:    $x_support
539     Debug:              $debug
540     XDebug:             $xdebug
541     RLPDebug:           $rlpdebug
542     NLS:                $USE_NLS
543     Security:           $security
544     Win32:              $win32 
545     Prefix:             $prefix
546
547   Type '${MAKE}' for compilation or '${MAKE} makelib' when want to compile
548   all binaries with one shared library
549   
550   After it '${MAKE} install', '${MAKE} install-suid', '${MAKE} install-strip'
551   or '${MAKE} install-ss' to install gnokii.
552 "