:pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
[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 CFLAGS="-O2 -Wall"
19 ALL_LINGUAS="cs de et fi nl sk pl it sl"
20
21 dnl ======================== Checks for programs.
22 AC_PROG_CC
23 AC_PROG_CPP
24 AC_PROG_LEX
25 AC_PATH_PROG(RM, rm, no)
26 AC_PATH_PROG(FIND, find, no)
27 AC_CHECK_PROGS(MAKE, gmake make)
28 AC_PROG_INSTALL
29
30 dnl Let us have $prefix variable aviable here
31 test x"$prefix" = xNONE && prefix="$ac_default_prefix"
32
33 AC_ARG_ENABLE(debug, 
34         [  --enable-debug          compile with debug code],
35         [ CFLAGS="-g -Wall"
36           AC_DEFINE(DEBUG)
37           debug="yes" ],
38         [ debug="no"  ]
39 )
40
41 AC_ARG_ENABLE(xdebug,
42         [  --enable-xdebug         compile with xdebug code],
43         [ AC_DEFINE(XDEBUG)
44           xdebug="yes" ],
45         [ xdebug="no"  ]
46 )
47
48 AC_ARG_ENABLE(rlpdebug, 
49         [  --enable-rlpdebug       compile with RLP debug code],
50         [ AC_DEFINE(RLP_DEBUG)
51           rlpdebug="yes" ],
52         [ rlpdebug="no"  ]
53 )
54
55 dnl ======================== NLS support
56
57 LIBS=""
58 NLS_LIBS=""
59 NLS_CFLAGS=""
60
61 AC_ARG_WITH(libintl,
62         [  --with-libintl=DIR      specifies the base NLS],
63         [ if test "x$withval" = "xyes"; then
64                 AC_MSG_WARN(Usage is --with-libintl=DIR)
65           else
66                 NLS_LIBS="-L$withval/lib"
67                 NLS_CFLAGS="-I$withval/include"
68           fi
69         ]
70 )
71
72 AC_ARG_ENABLE(nls,
73         [  --disable-nls           do not use NLS],
74         [ USE_NLS=$enableval ],
75         [ USE_NLS=yes ]
76 )
77
78 if test "$USE_NLS" = "yes"; then
79         AC_PROG_MAKE_SET
80         AC_CHECK_HEADERS(locale.h)
81         AC_CHECK_FUNCS(setlocale)
82         AC_SUBST(HAVE_LOCALE_H)  
83
84         CPPFLAGS="$CPPFLAGS $NLS_CFLAGS"
85         AC_TRY_CPP([#include <libintl.h>],
86                    [ AC_DEFINE(HAVE_LIBINTL_H)
87                      AC_MSG_RESULT([checking for libintl.h... yes]) ],
88                    [ AC_MSG_WARN(not found header file: libintl.h !!!)
89                      USE_NLS=no ]
90         )
91 fi
92
93 if test "$USE_NLS" = "yes"; then
94         AC_CHECK_FUNC(gettext,
95                       AC_DEFINE(HAVE_LIBINTL),
96                       AC_CHECK_LIB(intl, gettext,
97                                    [ NLS_LIBS="$NLS_LIBS -lintl"
98                                      AC_DEFINE(HAVE_LIBINTL) ],
99                                    [ AC_MSG_WARN(not found library: intl !!!)
100                                      USE_NLS=no ],
101                                    $NLS_LIBS
102                       )
103         )
104 fi
105
106 if test "$USE_NLS" = "yes"; then
107
108         AC_SUBST(HAVE_LIBINTL_H)
109         AC_SUBST(HAVE_LIBINTL)
110
111         dnl Handle localedir
112         LOCALEDIR='${prefix}/share/locale'
113         AC_ARG_WITH(locale-dir,
114                     [  --with-locale-dir=DIR   Location of the locale file(s)
115                         [PREFIX/share/locale]],
116                     [ if test x$withval = xyes; then
117                         AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
118                       else
119                         if test x$withval = xno; then
120                                 AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
121                         else
122                                 LOCALEDIR=$withval
123                         fi
124                       fi
125                     ]
126         )
127         AC_SUBST(LOCALEDIR)
128
129         AC_PATH_PROG(MSGFMT, msgfmt, $MSGFMT)
130         if test -n "$MSGFMT"; then
131                 AC_CHECK_FUNCS(dcgettext)
132                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
133                 AC_PATH_PROG(XGETTEXT, xgettext, $XGETTEXT)
134                 AC_PATH_PROG(MSGMERGE, msgmerge, $MSGMERGE)
135
136                 dnl Test whether we really found GNU xgettext.
137                 if test -n "$XGETTEXT"; then
138                         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
139                                 : ;
140                         else
141                                 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
142                                 XGETTEXT=""
143                         fi
144                 fi
145
146                 dnl We add another test for comparing GNU xgettext with openwin xgettext
147                 if test -n "$XGETTEXT"; then
148                         if $XGETTEXT --help > /dev/null 2> /dev/null; then
149                                 : ;
150                         else
151                                 AC_MSG_RESULT([found xgettext program is not GNU xgettext; ignore it])
152                                 XGETTEXT=""
153                         fi
154                 fi
155
156                 dnl Test whether we really found GNU msgfmt.
157                 if test -n "$MSGFMT"; then
158                         if $MSGFMT < /dev/null 2> /dev/null; then
159                                 AC_MSG_RESULT([found msgfmt program is not GNU msgfmt; NLS will not be installed])
160                                 MSGFMT=""
161                         fi
162                 fi
163
164                 AC_TRY_LINK(,
165                             [ extern int _nl_msg_cat_cntr;
166                               return _nl_msg_cat_cntr],
167                             [ CATOBJEXT=.gmo
168                               DATADIRNAME=share],  
169                             [ CATOBJEXT=.mo
170                               DATADIRNAME=lib]
171                 )
172                 INSTOBJEXT=.mo
173         fi
174
175         if test -n "$ALL_LINGUAS"; then
176                 for lang in $ALL_LINGUAS; do
177                         CATALOGS="$CATALOGS $lang$CATOBJEXT"
178                 done
179         fi
180         AC_SUBST(CATALOGS)
181         AC_SUBST(CATOBJEXT)
182         AC_SUBST(INSTOBJEXT)
183         AC_SUBST(DATADIRNAME)
184 fi
185
186 dnl don't use NLS, when there is no gettext installed
187 if test x"$MSGFMT" = x; then
188         USE_NLS=no
189 fi
190
191 if test x"$USE_NLS" = xyes; then
192         AC_DEFINE(USE_NLS)
193 fi
194
195 dnl ======================== Checks for libraries.
196
197 AC_ARG_WITH(libpthread, 
198    [  --with-libpthread=DIR   specifies the base libpthread],
199    [ if test x$withval = xyes
200      then 
201       AC_MSG_WARN(Usage is: --with-libpthread=DIR)
202      else
203       PTHREAD_LIBS="-L$withval/lib/"
204       PTHREAD_CFLAGS="-I$withval/include/"
205      fi
206    ]
207 )
208
209 dnl Check for libpthread
210 PTHREAD_LIBS_SAVE="$PTHREAD_LIBS"
211 PTHREAD_LIBS=error
212 AC_CHECK_LIB(pthread, pthread_attr_init, [
213                       PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT"
214                       PTHREAD_LIBS="$PTHREAD_LIBS_SAVE -lpthread" ])
215
216 dnl FIXME: test this on *BSD and report results immediatelly to the ml please
217 dnl If it is not found, try to check for c_r (on FreeBSD)
218 if test "x$PTHREAD_LIBS" = xerror; then
219   AC_CHECK_LIB(c_r, pthread_attr_init, [
220                     PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_THREAD_SAFE"
221                     PTHREAD_LIBS="-pthread" ])
222 fi
223
224 dnl FIXME: do we really test here if libc contains this function?
225 if test "x$PTHREAD_LIBS" = xerror; then
226    AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="",
227       AC_MSG_ERROR(not found library: pthread !!!))
228 fi
229
230 dnl The following is taken from inn sources
231 AC_MSG_CHECKING(for tm_gmtoff in struct tm)
232 AC_TRY_LINK([#include <time.h>],
233         [struct tm t; t.tm_gmtoff = 0],
234         [AC_MSG_RESULT(yes)
235          AC_DEFINE(HAVE_TM_GMTON)],
236         [AC_MSG_RESULT(no)])
237
238 dnl The following is taken from inn sources
239 AC_MSG_CHECKING(for timersub)
240 AC_TRY_LINK([#include <sys/time.h>],
241         [timersub(NULL, NULL, NULL)],
242         [AC_DEFINE(HAVE_TIMEOPS)
243          AC_DEFINE(HAVE_TIMEOPS)
244          AC_MSG_RESULT(yes)],
245         [AC_MSG_RESULT(no)])
246
247 have_termios="no"
248 dnl Checking for setspeed in termios.h
249 AC_MSG_CHECKING(for cfsetspeed in termios.h)
250 AC_TRY_LINK([#include <termios.h>],
251         [struct termios t; cfsetspeed(&t, B9600);],
252         [AC_DEFINE(HAVE_CFSETSPEED)
253          have_termios="yes"
254          AC_MSG_RESULT(yes)],
255         AC_MSG_RESULT(no))
256
257 if test $have_termios = "no"; then
258    AC_MSG_CHECKING(for cfsetispeed and cfsetospeed in termios.h)
259    AC_TRY_LINK([#include <termios.h>],
260                [struct termios t; cfsetispeed(&t, B9600);  cfsetospeed(&t, B9600);],
261                [AC_DEFINE(HAVE_CFSETISPEED)
262                 AC_DEFINE(HAVE_CFSETOSPEED)
263                 have_termios="yes"
264                 AC_MSG_RESULT(yes)],
265                [AC_MSG_RESULT(no)])
266
267    if test $have_termios = "no"; then
268       AC_MSG_CHECKING(for c_ispeed and c_ospeed in struct termios)
269       AC_TRY_LINK([#include <termios.h>],
270                   [struct termios t; t.c_iflag = B9600; t.c_oflag = B9600;],
271                   [AC_DEFINE(HAVE_TERMIOS_CSPEED)
272                    AC_MSG_RESULT(yes)],
273                   [AC_MSG_RESULT(no)])
274    fi
275 fi
276
277 dnl ======================== Checks for getopt_long support 
278
279 AC_CHECK_HEADER(getopt.h, ,
280       [CFLAGS="$CFLAGS -I../getopt"])
281
282 AC_ARG_WITH(gnugetopt,
283    [  --with-getopt=DIR       specifies the getopt library location directory],
284    [ if test x$withval=yes; then
285         AC_MSG_WARN(Usage is: --with-getopt=DIR) 
286      else
287         GETOPT_LIBS="-L$withval"
288      fi
289    ]
290 )
291
292 OWN_GETOPT=""
293 AC_CHECK_FUNC(getopt_long, , [
294         LIBS="$LIBS $GETOPT_LIBS"
295            AC_CHECK_LIB(gnugetopt, getopt_long, LIBS="$LIBS -lgnugetopt",
296             OWN_GETOPT="1")])
297
298 dnl ======================== Checks for X base support 
299
300 if test "$no_x" = yes -o "$with_x" = "no"; then
301    x_support="no"
302    XPM_CFLAGS=""
303    XPM_LIBS=""
304    GTK_CFLAGS=""
305    GTK_LIBS=""
306 else
307    AC_PATH_X
308    CPPFLAGS="$CPPFLAGS -I$x_includes"
309    AC_CHECK_HEADERS(X11/xpm.h,
310                     [ XPMINC="yes" ],
311                     [ XPMINC="no" ])
312
313    if test "x$XPMINC" = "xno"; then
314       x_support="no"
315       XPM_CFLAGS=""
316       XPM_LIBS=""
317       GTK_CFLAGS=""
318       GTK_LIBS=""
319       AC_MSG_WARN(Cannot find include X11/xpm.h)
320       AC_MSG_WARN(Disabling xgnokii.)
321    elif test "x$x_libraries" = "xNONE"; then
322       x_support="no"
323       XPM_CFLAGS=""
324       XPM_LIBS=""
325       GTK_CFLAGS=""
326       GTK_LIBS=""
327       AC_MSG_WARN(Cannot find library libX11.)
328       AC_MSG_WARN(Disabling xgnokii.)
329    else
330       AC_CHECK_LIB(Xpm, XpmWriteFileFromXpmImage,
331             [ XPM_CFLAGS="-I$x_includes" XPM_LIBS="-L$x_libraries -lX11 -lXpm"
332               AC_DEFINE(XPM) ],
333             AC_MSG_WARN(Cannot found library libXpm - disabling XPM support.),
334             [ -L$x_libraries -lX11 ]
335       )
336
337       AC_PATH_PROGS(GTK_CONFIG, gtk-config gtk12-config, no)
338       if test "$GTK_CONFIG" = no; then
339          x_support="no"
340          GTK_CFLAGS=""
341          GTK_LIBS=""
342          AC_MSG_WARN(Cannot find gtk-config.)
343          AC_MSG_WARN(Disabling xgnokii.)
344       else
345          GTK_CFLAGS=`$GTK_CONFIG --cflags`
346          GTK_LIBS=`$GTK_CONFIG --libs`
347          x_support="yes"   
348
349          XGNOKIIDIR='${prefix}/share'
350          XGNOKIIPATH=${prefix}/share
351          AC_ARG_WITH(xgnokiidir,
352             [  --with-xgnokiidir=DIR   specifies the base for xgnokii],
353             [ if test x$withval = xyes; then 
354                  AC_MSG_WARN(Usage is: --with-xgnokiilib=DIR)
355               else
356                  XGNOKIIDIR="$withval"
357                  XGNOKIIPATH="$withval"
358               fi
359             ]
360          )
361       fi
362    fi
363 fi
364
365 dnl ======================== Check for libsocket
366 AC_CHECK_LIB(socket, socket)
367
368 dnl ======================== Additional switches
369
370 AC_ARG_ENABLE(security, 
371    [  --enable-security       enable all security features ],
372    [ AC_DEFINE(SECURITY)
373      security="yes" ],
374    [ security="no"  ]
375 )
376
377 AC_ARG_ENABLE(win32, 
378    [  --enable-win32          if you want win32 suport ],
379    [ AC_DEFINE(WIN32)
380      win32="-DWIN32" ],
381    [ win32=""]
382 )
383
384 AC_CHECK_FUNC(grantpt,
385    [ AC_TRY_RUN([
386 #define  _XOPEN_SOURCE 500
387
388 #include <features.h>
389 #include <stdlib.h>
390 #include <sys/types.h>
391 #include <sys/stat.h>
392 #include <fcntl.h>
393 #include <unistd.h>
394
395 int main()
396 {
397         char *name = NULL;
398         int master, err;
399
400         master = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK);
401         if (master >= 0) {
402                 err = grantpt(master);
403                 err = err || unlockpt(master);
404                 if (!err) {
405                         name = ptsname(master);
406                 } else {
407                         exit(-1);
408                 }
409         } else {
410                 exit(-1);
411         }
412         close(master);
413         exit(0);
414 }
415                 ],
416                 AC_DEFINE(USE_UNIX98PTYS),
417                 AC_MSG_WARN("No unix98ptys"),
418                 AC_MSG_WARN("Ensure to disable unix98ptys when crosscompiling"))
419    ]
420 )
421
422 dnl ======================== Checks for header files.
423 AC_HEADER_STDC
424 AC_HEADER_SYS_WAIT
425 AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h)
426
427 dnl ======================== Checks for typedefs, structures, and compiler characteristics.
428 AC_C_CONST
429 AC_C_INLINE
430 AC_TYPE_PID_T
431 AC_TYPE_SIZE_T
432 AC_HEADER_TIME
433 AC_STRUCT_TM
434
435 dnl ======================== Checks for library functions.
436 AC_PROG_GCC_TRADITIONAL
437 AC_FUNC_MEMCMP
438 AC_TYPE_SIGNAL
439 AC_FUNC_STRFTIME
440 AC_CHECK_FUNCS(mktime select strdup strstr strtol strtok strsep snprintf)
441
442 CFLAGS="$CFLAGS $NLS_CFLAGS"
443 LIBS="$LIBS $NLS_LIBS"
444
445 PACKAGE=gnokii
446 XPACKAGE=xgnokii
447 VERSION=`cat VERSION`
448 XVERSION=`cat xgnokii/VERSION`
449 HAVE_XGNOKII=$x_support
450
451 case "$INSTALL" in
452   'config/install-sh -c') INSTALL=`pwd`/$INSTALL
453    ;;
454 esac
455
456 SHELL=${CONFIG_SHELL-/bin/sh}
457
458 AC_SUBST(SHELL)
459 case "$build_os" in
460   solaris*) SHELL=/bin/ksh
461    ;;
462 esac
463
464 AC_CONFIG_HEADER(include/config.h)
465
466 AC_SUBST(PACKAGE)
467 AC_SUBST(VERSION)
468 AC_SUBST(XVERSION)
469 AC_SUBST(XPACKAGE)
470 AC_SUBST(XGNOKIIDIR)
471 AC_SUBST(XGNOKIIPATH)
472 AC_SUBST(exec_prefix)
473 AC_SUBST(USE_NLS)
474 AC_SUBST(GTK_CFLAGS)
475 AC_SUBST(GTK_LIBS)
476 AC_SUBST(PTHREAD_CFLAGS)
477 AC_SUBST(PTHREAD_LIBS)
478 AC_SUBST(XPM_CFLAGS)
479 AC_SUBST(XPM_LIBS)
480 AC_SUBST(OWN_GETOPT)
481 AC_SUBST(USE_UNIX98PTYS)
482 AC_SUBST(HAVE_XGNOKII)
483
484 AC_OUTPUT(
485    include/config.h.in
486    Makefile.global
487    po/Makefile.in
488    packaging/RedHat/gnokii.spec
489    packaging/Slackware/SlackBuild,
490    [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]
491    )
492
493
494 dnl ======================== Final report
495
496 echo "
497
498   G N O K I I
499
500   A Linux/Unix toolset and driver for Nokia mobile phones.
501
502   Copyright (C) 1999-2000  The Gnokii Development Team.
503
504   This program is free software; you can redistribute it and/or modify
505   it under the terms of the GNU General Public License as published by
506   the Free Software Foundation; either version 2 of the License, or
507   (at your option) any later version.
508  
509   See file COPYING for more details.
510
511     Host system:        $host_os
512     Gnokii version:     $VERSION
513     Xgnokii version:    $XVERSION
514     X (GTK) support:    $x_support
515     Debug:              $debug
516     XDebug:             $xdebug
517     RLPDebug:           $rlpdebug
518     NLS:                $USE_NLS
519     Security:           $security
520     Win32:              $win32 
521     Prefix:             $prefix
522
523   Type '${MAKE}' for compilation and then '${MAKE} install',
524   '${MAKE} install-suid', '${MAKE} install-strip' or '${MAKE} install-ss' to
525   install gnokii.
526 "