aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: 7da7d179c007145d6456bb3ea744ce91dcee4fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
dnl Process this file with -*- autoconf -*- to produce a configure script. 
# This file is part of GNU Dico
# Copyright (C) 1998, 1999, 2000, 2008, 2009, 2010 Sergey Poznyakoff
#
# GNU Dico is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Dico is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Dico.  If not, see <http://www.gnu.org/licenses/>.

AC_PREREQ(2.63)
AC_INIT([GNU dico], 2.0.92, [bug-dico@gnu.org])
AC_CONFIG_SRCDIR([dicod/main.c])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR(m4)	
AM_INIT_AUTOMAKE([1.11 gnits tar-ustar dist-bzip2 dist-xz std-options])

dnl Enable silent rules by default:
AM_SILENT_RULES([yes])

dnl Some variables
AC_SUBST(DICO_MODDIR,'$(libdir)/$(PACKAGE)')

dnl Checks for programs.
AC_PROG_CC
gl_EARLY	
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_YACC
AC_PROG_LEX

LT_PREREQ(2.2.5a)
LT_CONFIG_LTDL_DIR([libltdl])
LT_INIT([dlopen])
LTDL_INIT([recursive])
LT_WITH_LTDL
AC_CONFIG_FILES([libltdl/Makefile])

dnl Checks for libraries.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyaddr)
AC_CHECK_LIB(rt, nanosleep)

dnl Checks for header files.
AC_HEADER_DIRENT dnl not needed ?
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h strings.h sys/time.h syslog.h unistd.h \
                 crypt.h readline/readline.h)

dnl Checks for typedefs, structures, and compiler characteristics.
gl_INIT

AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_CHECK_TYPE([socklen_t],,
  AC_DEFINE(socklen_t, int, [Define to int if <sys/types.h> does not define]),
[
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SOCKET_H
# include <socket.h>
#endif
])

dnl Checks for library functions.
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(gethostname select socket strdup strerror strtol \
               setegid setregid setresgid seteuid setreuid \
	       sysconf getdtablesize)

# Crypt
AC_CHECK_DECLS(crypt,,,[
#include <unistd.h>
#ifdef HAVE_CRYPT_H
# include <crypt.h>
#endif])
AH_BOTTOM([
#if !HAVE_DECL_CRYPT
char *crypt(const char *key, const char *salt);
#endif])

AC_CHECK_LIB(crypt, crypt)

# Gettext.
AM_ICONV
AM_GNU_GETTEXT([external], [need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.17])
AC_CONFIG_LINKS(include/gettext.h:gnu/gettext.h)

# Check for zlib
AC_CHECK_HEADER(zlib.h,
                AC_CHECK_LIB(z, inflate,
                             [AC_DEFINE_UNQUOTED([USE_LIBZ], 1,
			              [Define this if you have libz library])
	                      AC_SUBST(LIBZ, -lz)]))

LOG_FACILITY="LOG_DAEMON"

AC_ARG_VAR([LOG_FACILITY],
	   [Default syslog facility])
if test -n "$LOG_FACILITY"; then
   logfacility=`echo $LOG_FACILITY | tr a-z A-Z`
   case $logfacility in
   USER|DAEMON|AUTH|AUTHPRIV|MAIL|CRON|LOCAL[[0-7]])
      LOG_FACILITY=LOG_$logfacility;;
   LOG_USER|LOG_DAEMON|LOG_AUTH|LOG_AUTHPRIV|LOG_MAIL|LOG_CRON|LOG_LOCAL[[0-7]])
      LOG_FACILITY=$logfacility;;
   *) AC_MSG_ERROR([Invalid value of LOG_FACILITY]);;
   esac
fi		      
AC_DEFINE_UNQUOTED([LOG_FACILITY],$LOG_FACILITY,
                   [Default syslog facility.])
	
# FIXME: This is not a right place for this
AH_BOTTOM([
#if defined (SETVBUF_REVERSED)
# define SETVBUF(str,buf,mode,size) setvbuf(str,mode,buf,size)
#else
# define SETVBUF(str,buf,mode,size) setvbuf(str,buf,mode,size)
#endif
])


# Check for Berkeley DB
db_path=
db_version=4
status_dbm=no

AC_ARG_WITH([berkeley-db],
            AC_HELP_STRING([--with-berkeley-db=version],
                           [use this Berkeley DB version]),
            [
case "${withval}" in
  /*)       db_path=${withval};;
  [[0-9]]*) db_version=${withval}
            ver=`echo $withval | tr -d '.'`
	    if test "$ver" -lt 4; then
	      AC_MSG_ERROR([Berkeley DB version 4 or greater is required])
	    fi;;
  *)        AC_MSG_ERROR([erroneous or missing argument to --with-berkeley-db]);;
esac])

## Set the variable status_dbm to $1 if:
##
##  1. Function $3 is defined in the library $2;
##  2. Header file db.h is available;
##  3. Version triplets defined in db.h and in the library match.        
##
## Then check if the major version, minor version and patchlevel of the
## library matches those from the header. If so, define WITH_BDB
## to the version (i.e. $1 with all dots removed). Otherwise, report
## an error and stop.
##
check_bdb() {
        ver=`echo $1 | tr -d '.'`
	major=`expr $ver : '\(.\).*'`
	save_LIBS=$LIBS
	AC_CHECK_LIB($2, $3,
                     [AC_CHECK_HEADERS(db.h)
                      if test $ac_cv_header_db_h = yes; then
		        LIBS="$LIBS -l$2"
                        status_dbm=$1
                      fi])
	if test $status_dbm = no; then
	  :
	else
	  AC_RUN_IFELSE(
           [AC_LANG_PROGRAM([#include "db.h"],
            [int v_major, v_minor, v_patch;
             db_version(&v_major, &v_minor, &v_patch);
             return !(DB_VERSION_MAJOR == $major
                       && v_major == DB_VERSION_MAJOR
                       && v_minor == DB_VERSION_MINOR
                       && v_patch == DB_VERSION_PATCH);
            ])],
           [DB_LIBS="-l$2"],
           [unset ac_cv_header_db_h
	    status_dbm=no])
	   LIBS=$save_LIBS
	fi
}

AC_SUBST(DB_INCLUDES)
AC_SUBST(DB_LIBS)
	
## Check for the Berkeley DB library version $1, assuming Slackware-like
## installation layout (header files in /usr/incude/db$vn and library named
## libdb-$version.so, where $version is the library version and $vn is
## $version with all dots removed.
##
check_slackware_bdb() {
	dir=db`echo $1|tr -d '.'`
	save_CPPFLAGS=$CPPFLAGS
	while test -n "$dir"
	do
		if test -d /usr/include/$dir; then
			CPPFLAGS="$CPPFLAGS -I/usr/include/$dir"
			break
		elif test -d /usr/local/include/$dir; then
			CPPFLAGS="$CPPFLAGS -I/usr/local/include/$dir"
			break
		fi		
		dir=`expr "$dir" : '\(.*\)[[0-9]]$'`
	done
	check_bdb $1 db-$1 db_create
	CPPFLAGS=$save_CPPFLAGS
	if test $status_dbm = "$1"; then
	    DB_INCLUDES="$DB_INCLUDES -I/usr/include/$dir"
	fi
}
	
check_bdb $db_version db db_create
if test $status_dbm = no; then
   check_slackware_bdb $db_version
fi   	  

if test $status_dbm != no; then
  AC_SUBST(BUILD_JDICT_PROGS,'$(JDICT_PROGS)')
fi

AC_ARG_WITH([preprocessor],
            AC_HELP_STRING([--without-preprocessor],
                           [do not use external preprocessor]),
            [
case "${withval}" in
yes) use_ext_pp=yes ;;
no)  use_ext_pp=no ;;
*)   AC_MSG_ERROR(bad value ${withval} for --with-preprocessor) ;;
esac],[use_ext_pp=yes])

if test $use_ext_pp != no; then
  # Check for default preprocessor
  AC_ARG_VAR([DEFAULT_PREPROCESSOR],
             [Set default preprocessor name])
  if test -z "$DEFAULT_PREPROCESSOR" ; then
    DEFAULT_PREPROCESSOR="m4 -s"
  fi
  
  save_PATH=$PATH
  PREPROC_OPTIONS=`echo $DEFAULT_PREPROCESSOR | sed -n 's/[[^ ]][[^ ]]* //p'`
  case "$DEFAULT_PREPROCESSOR" in
  /*) PATH=`expr $DEFAULT_PREPROCESSOR : '\(.*\)/.*'`:$PATH
      DEFAULT_PREPROCESSOR=`expr $DEFAULT_PREPROCESSOR : '.*/\(.*\)'`;;
  esac
  AC_PATH_PROG(PPBIN, $DEFAULT_PREPROCESSOR)
  DEFAULT_PREPROCESSOR=$PPBIN
  if test -n "$DEFAULT_PREPROCESSOR"; then
    DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS"
    case $PPBIN in
    *m4) AC_SUBST(PP_SETUP_FILE,'pp-setup');; # Install default pp-setup
    esac
  fi
  PATH=$save_PATH
  DEFAULT_PREPROCESSOR="\\\"$DEFAULT_PREPROCESSOR\\\""
else
  DEFAULT_PREPROCESSOR=NULL
fi

AC_ARG_VAR([DEFAULT_DICT_SERVER],
           [Set the name of the default DICT server for dico utility])
if test -z "$DEFAULT_DICT_SERVER" ; then
   DEFAULT_DICT_SERVER="gnu.org.ua"
fi

# Check for Guile
GINT_INIT([gint],[1.8 with-guile nodoc],
	  [status_guile=yes],
	  [status_guile=no])
AM_CONDITIONAL([GUILE_COND],[test $status_guile = yes])

# Check for Python
AC_ARG_WITH([python],
            AC_HELP_STRING([--without-python],
                           [do not build Python interface]),
            [
case "${withval}" in
  yes) status_python=yes ;;
  no)  status_python=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --without-python) ;;
esac],[status_python=yes])

if test "$status_python" = yes; then
  AC_ARG_VAR([PYTHON_CONFIG], [The name of python-config binary])
  AC_PATH_PROG([PYTHON_CONFIG], python-config)
  if test -n "$PYTHON_CONFIG"; then
    AC_SUBST(PYTHON_LIBS,`python-config --libs`)
    AC_SUBST(PYTHON_INCLUDES,`python-config --includes`)
  else
    status_python=no     
  fi	
fi
AM_CONDITIONAL([PYTHON_COND],[test $status_python = yes])

#
AC_ARG_WITH(autologin-file,
            AC_HELP_STRING([--with-autologin-file@<:@=NAME@:>@],
	                   [Use the autologin file (default NAME is .dicologin)]),
            [case $withval in
	     yes) DEFAULT_AUTOLOGIN_FILE=".dicologin";;
	     no)  DEFAULT_AUTOLOGIN_FILE=;;
	     *)   DEFAULT_AUTOLOGIN_FILE=$withval;;
	     esac],
	    [DEFAULT_AUTOLOGIN_FILE=".dicologin"])
if test -n "$DEFAULT_AUTOLOGIN_FILE" ; then
   AC_DEFINE_UNQUOTED(DEFAULT_AUTOLOGIN_FILE, "$DEFAULT_AUTOLOGIN_FILE",
                      [Define to the name of a netrc-style autologin file])
else
   AC_DEFINE_UNQUOTED(DEFAULT_AUTOLOGIN_FILE, NULL,
                      [Define to the name of a netrc-style autologin file])
fi

AC_ARG_WITH([readline],
            AC_HELP_STRING([--without-readline],
                           [do not use readline]),
            [
case "${withval}" in
  yes) status_readline=yes ;;
  no)  status_readline=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
esac],[status_readline=yes])

# Test for GNU Readline
AC_SUBST(READLINE_LIBS)

if test "$status_readline" != "no"; then
  
  dnl FIXME This should only link in the curses libraries if it's
  dnl really needed!
  
  dnl Check for Curses libs.
  CURSES_LIBS=
  for lib in ncurses curses termcap
  do
    AC_CHECK_LIB($lib, tputs, [CURSES_LIBS="-l$lib"; break])
  done

  saved_LIBS=$LIBS
  LIBS="$LIBS $CURSES_LIBS"
  AC_CHECK_LIB(readline, readline, mf_have_readline=yes)
  LIBS=$saved_LIBS
  
  if test "$mf_have_readline" = "yes"; then
    AC_CHECK_HEADERS(readline/readline.h,
  		     AC_DEFINE(WITH_READLINE,1,[Enable use of readline]))
    READLINE_LIBS="-lreadline $CURSES_LIBS"
    saved_LIBS=$LIBS
    LIBS="$LIBS $READLINE_LIBS"
    AC_CHECK_FUNCS(rl_completion_matches)
    LIBS=$saved_LIBS
    status_readline="yes"
  else
    if test "$status_readline" = "yes"; then
      AC_MSG_WARN(readline requested but does not seem to be installed)
    fi
    status_readline="no"
  fi
fi

AH_BOTTOM([
/* Some older versions of readline have completion_matches */
#ifndef HAVE_RL_COMPLETION_MATCHES
# define rl_completion_matches completion_matches
#endif])

# GNU SASL
status_gsasl=no
MU_CHECK_GSASL(0.2.5, [
    AC_DEFINE(WITH_GSASL,1,[Define if GNU SASL is present])
    status_gsasl=yes
    AC_SUBST(BUILD_LIBDICOSASL,'libdicosasl.a')
    AC_SUBST(LIBDICOSASL,'../lib/libdicosasl.a')])

# SASL

AC_ARG_WITH(ldap,
            [AC_HELP_STRING([--with-ldap],
		            [Configure to work with OpenLDAP])],
	    [status_ldap=$withval],
            [status_ldap=maybe])

if test $status_ldap != no; then
  AC_CHECK_LIB(ldap, ldap_bind,
               [status_ldap=yes],
               [if test $status_ldap = yes; then
	          AC_MSG_ERROR([required library ldap is not found])
		fi
 	        status_ldap=no])
fi
AM_CONDITIONAL([LDAP_COND], [test $status_ldap = yes])
    
# Doc hints.
# Select a rendition level:
#  DISTRIB for stable releases (at most one dot in the version number)
#  and maintenance releases (two dots, patchlevel < 50)
#  PROOF for alpha releases.
#  PUBLISH can only be required manually when running make in doc/
AC_SUBST(RENDITION)
case `echo $VERSION|sed  's/[[^.]]//g'` in
""|".")  RENDITION=DISTRIB;;
"..")  if test `echo $VERSION | sed  's/.*\.//'` -lt 50; then
	 RENDITION=DISTRIB
       else
         RENDITION=PROOF
       fi;;
*)     RENDITION=PROOF;;
esac

AC_CONFIG_COMMANDS([status],[
cat <<EOT

*******************************************************************
Dico configured with the following settings:

Guile ........................... $status_guile
Python .......................... $status_python
GSASL ........................... $status_gsasl
LDAP ............................ $status_ldap
Readline ........................ $status_readline
Preprocessor .................... $dicopp

Default server .................. $defserver
Autologin file .................. $autologin_file
*******************************************************************
EOT
],
[status_guile=$status_guile
status_python=$status_python
status_gsasl=$status_gsasl
status_ldap=$status_ldap
status_readline=$status_readline
if test $use_ext_pp = no; then
  dicopp=no
else
  dicopp="$DEFAULT_PREPROCESSOR"
fi
defserver="$DEFAULT_DICT_SERVER"
autologin_file="$DEFAULT_AUTOLOGIN_FILE"
])
	
AC_CONFIG_FILES([Makefile
                 include/Makefile
                 include/dico/Makefile
                 utils/Makefile
		 gint/Makefile
		 gnu/Makefile
                 lib/Makefile
                 dicod/Makefile
		 modules/Makefile
		 modules/outline/Makefile
		 modules/dict.org/Makefile
		 modules/guile/Makefile
		 modules/python/Makefile
		 modules/stratall/Makefile
		 modules/substr/Makefile
		 modules/ldap/Makefile
		 dico/Makefile
		 tests/Makefile
		 doc/Makefile
		 po/Makefile.in])

AC_OUTPUT

Return to:

Send suggestions and report system problems to the System administrator.