1dnl Process this file with autoconf to produce a configure script.
2dnl $Id: configure.ac,v 1.1.2.4 2003/05/18 10:57:24 egil Exp $
3dnl
4dnl copyright 1996,1997,1998,1999,2000,2001,2002 Egil Kvaleberg
5dnl the GNU General Public License applies
6dnl
7dnl $Log: configure.ac,v $
8dnl Revision 1.1.2.4  2003/05/18 10:57:24  egil
9dnl Version 1.6, with fixes from bug #237
10dnl
11dnl Revision 1.1.2.3  2003/01/22 15:09:20  egil
12dnl NEWS for 1.6pre3
13dnl
14dnl Revision 1.1.2.2  2003/01/22 15:06:59  egil
15dnl Added prerequesite for autoconf version >= 2.50
16dnl
17dnl Revision 1.1.2.1  2003/01/22 13:04:55  egil
18dnl Renamed configure.in to configure.ac
19dnl
20dnl Revision 1.98.2.21  2003/01/22 13:01:13  egil
21dnl Support sys/malloc.h as used by Mac OS X.
22dnl
23dnl Revision 1.98.2.20  2003/01/22 10:18:24  egil
24dnl Implemented hostconfig, removed storageapi
25dnl
26dnl Revision 1.98.2.19  2003/01/21 20:19:44  egil
27dnl mktemp() replaced by newstemp()
28dnl
29dnl Revision 1.98.2.18  2003/01/21 12:54:01  egil
30dnl Better configure support for storage.h
31dnl There is also a new option --with-newsinclude
32dnl
33dnl Revision 1.98.2.17  2003/01/21 09:46:43  egil
34dnl Make a better assumption for newslib
35dnl
36dnl Revision 1.98.2.16  2003/01/21 08:21:41  egil
37dnl Updated to new autoconf version, including new PACKAGE_... symbols
38dnl
39dnl Revision 1.98.2.15  2002/10/02 10:44:32  egil
40dnl New configure options --with-rnews and --with-inews
41dnl
42dnl Revision 1.98.2.14  2002/10/02 10:08:29  egil
43dnl New filter for SMretrieve
44dnl
45dnl Revision 1.98.2.13  2002/10/02 09:25:40  egil
46dnl Version 1.5pre - report bugs to Bugzilla
47dnl
48dnl Revision 1.98.2.12  2002/09/26 05:28:39  egil
49dnl Better README, more warnings re. INN 2 in configure
50dnl
51dnl Revision 1.98.2.11  2002/09/22 07:35:25  egil
52dnl Bug #84
53dnl
54dnl Revision 1.98.2.10  2002/09/21 17:29:59  egil
55dnl Fix authinfo with ihave
56dnl
57dnl Revision 1.98.2.9  2002/07/15 07:29:56  egil
58dnl Security fix for syslog
59dnl
60dnl Revision 1.98.2.8  2002/02/06 20:11:31  egil
61dnl Debian Bug#88795: newsx: Inn 2.3.1 storage API compilation
62dnl
63dnl Revision 1.98.2.7  2002/02/06 17:57:57  egil
64dnl Fixes for configure from John H. Briggs
65dnl
66dnl Revision 1.98.2.6  2002/01/29 19:15:19  egil
67dnl Copyright update in configure
68dnl
69dnl Revision 1.98.2.5  2002/01/29 19:02:06  egil
70dnl Fix configure documentation bugs
71dnl
72dnl Revision 1.98.2.4  2002/01/29 17:43:49  egil
73dnl RPM support, mkstemp()
74dnl
75dnl Revision 1.98.2.3  2002/01/29 07:12:37  egil
76dnl Version V1_4pl5
77dnl
78dnl Revision 1.98.2.2  2002/01/29 06:45:46  egil
79dnl Patch to V1.4p1
80dnl
81dnl Revision 1.98.2.1  2001/02/14 07:14:11  egil
82dnl Fixes from Winston Edmond
83dnl
84dnl Revision 1.98  1999/04/20 06:45:42  src
85dnl Use reasonably sane config values in documentation even for runtime config
86dnl
87dnl Revision 1.97  1999/04/19 03:50:56  src
88dnl Added config options for newsq
89dnl
90dnl Revision 1.96  1999/04/19 03:32:30  src
91dnl Standard profile in $PATHETC/newsx.conf
92dnl
93dnl Revision 1.95  1999/04/17 15:00:45  src
94dnl Documentation for 1.4
95dnl
96dnl Revision 1.94  1999/04/15 04:26:56  src
97dnl Updated automake/autoconf version
98dnl
99dnl Revision 1.93  1999/04/08 16:57:17  src
100dnl Looking for innshellvars under ../etc and ../lib too
101dnl
102dnl Revision 1.92  1999/04/08 10:48:49  src
103dnl Extendeddbz to configure
104dnl
105dnl Revision 1.91  1999/04/08 10:19:34  src
106dnl Check for extendeddbz in configure
107dnl
108dnl Revision 1.90  1999/04/08 08:04:33  src
109dnl Updated installation documentation
110dnl
111dnl Revision 1.89  1999/04/08 07:31:26  src
112dnl Support for a list of runtime configuration files.
113dnl
114dnl Revision 1.88  1999/04/08 06:31:06  src
115dnl Support for full runtime configuration
116dnl
117dnl Revision 1.87  1999/04/05 19:01:43  src
118dnl Lock for scanlogs
119dnl
120dnl Revision 1.86  1999/04/05 13:07:22  src
121dnl Various fixes for storage-API
122dnl
123dnl Revision 1.85  1999/03/24 03:52:51  src
124dnl Implemented "newsx" as magic exclude pattern
125dnl
126dnl Revision 1.84  1999/03/18 19:24:05  src
127dnl Removed bash-thing
128dnl
129dnl Revision 1.83  1999/03/11 11:53:54  src
130dnl Spec-file for building RPM package
131dnl
132dnl Revision 1.82  1999/03/11 08:00:05  src
133dnl Created more directory
134dnl
135dnl Revision 1.81  1999/03/11 07:54:37  src
136dnl Moved storage to lib and src
137dnl
138dnl Revision 1.80  1999/03/11 07:44:14  src
139dnl Moved storage to src and lib
140dnl
141dnl Revision 1.79  1999/03/11 07:29:51  src
142dnl Implemented check for spool free space
143dnl
144dnl Revision 1.78  1999/03/07 15:41:24  src
145dnl Removed DBZ_VERSION from configuration
146dnl
147dnl Revision 1.77  1999/03/07 14:58:07  src
148dnl Read newsconfig supported. Storage API supported.
149dnl
150dnl Revision 1.76  1999/03/05 16:15:16  src
151dnl Version 1.4pre
152dnl
153dnl Revision 1.75  1999/03/05 11:20:22  src
154dnl Delayed decision of dbz v3 vz. 6 to runtime.
155dnl
156dnl Revision 1.74  1999/03/04 17:42:51  src
157dnl
158dnl Revision 1.73  1999/03/04 17:18:07  src
159dnl
160dnl Revision 1.72  1999/03/04 16:19:07  src
161dnl Fixed hostname in log
162dnl
163dnl Revision 1.71  1998/11/24 17:25:37  src
164dnl Version 1.3pre2: Repaired INN mode hamdling of ME entry
165dnl
166dnl Revision 1.70  1998/11/21 19:14:17  src
167dnl Added --filter option
168dnl
169dnl Revision 1.69  1998/10/25 13:42:25  src
170dnl Now finds libinn in INN lib directory
171dnl
172dnl Revision 1.68  1998/10/23 03:38:35  src
173dnl INN 2.1 sets VERSION, which confuses us
174dnl
175dnl Revision 1.67  1998/09/27 07:33:48  src
176dnl Version 1.2
177dnl
178dnl Revision 1.66  1998/09/21 10:33:02  src
179dnl Version 1.2pre3
180dnl
181dnl Revision 1.65  1998/09/21 10:03:32  src
182dnl Repaired HAVE_LIBINN
183dnl
184dnl Revision 1.64  1998/09/18 07:30:51  src
185dnl Implemented --inews
186dnl
187dnl Revision 1.63  1998/09/13 16:53:54  src
188dnl Statistics lock file
189dnl
190dnl Revision 1.62  1998/09/13 13:51:44  src
191dnl Moved getopt to lib, and implemented HAVE_GETOPT
192dnl
193dnl Revision 1.61  1998/09/13 13:28:32  src
194dnl Implemented HAVE_SETENV
195dnl
196dnl Revision 1.60  1998/09/11 16:37:36  src
197dnl Lockfile for logfile of posted articles and for posted article folder.
198dnl
199dnl Revision 1.59  1998/09/11 09:11:05  src
200dnl Check for putenv and setenv, support --help
201dnl
202dnl Revision 1.58  1998/09/09 07:32:06  src
203dnl Version 1.1
204dnl
205dnl Revision 1.57  1998/09/06 06:20:09  src
206dnl Build libdbz.a only if not HAVE_LIBINN
207dnl
208dnl Revision 1.56  1998/09/03 02:49:21  src
209dnl Fixed stuff detected by -Wall
210dnl
211dnl Revision 1.55  1998/09/03 02:19:18  src
212dnl Added -Wall for GCC
213dnl
214dnl Revision 1.54  1998/09/02 06:50:16  src
215dnl newsx version 1.0
216dnl
217dnl Revision 1.53  1998/09/02 06:34:30  src
218dnl Support @-syntax in newsfeeds, and support AUTHINFO GENERIC
219dnl
220dnl Revision 1.52  1998/08/24 07:10:50  src
221dnl Removed HAVE_SENDMAIL and HAVE_RNEWS
222dnl
223dnl Revision 1.51  1998/08/24 07:02:38  src
224dnl Fixes for NeXT
225dnl
226
227AC_PREREQ(2.50)
228AC_INIT(newsx,
229	1.6,
230	[http://www.kvaleberg.com/bug/])
231dnl Only most recent year required:
232PACKAGE_COPYRIGHT="Copyright 2003 Egil Kvaleberg <egil@kvaleberg.no>"
233
234AC_CONFIG_SRCDIR([FAQ])
235
236AM_INIT_AUTOMAKE
237AM_CONFIG_HEADER(config.h)
238
239AC_REVISION(Configure for newsx $PACKAGE_VERSION)
240dnl We need brackets:
241changequote(<<, >>)
242PACKAGE_DATE=`date | sed 's/^[^ ]* \([^ ]*\) *\([0-9]*\) .* \([0-9]*\)$/\2 \1 \3/'`
243changequote([, ])
244
245AC_SUBST(PACKAGE_NAME)
246AC_SUBST(PACKAGE_VERSION)
247AC_SUBST(PACKAGE_DATE)
248AC_SUBST(PACKAGE_COPYRIGHT)
249AC_SUBST(PACKAGE_BUGREPORT)
250
251dnl -----------------------------------------------------------------
252dnl
253dnl  Default list of locations to visit in search of the
254dnl  news configuration file
255dnl
256VISIT="/usr/lib/news /var/news/etc /usr/spool/news /usr/share/news \
257 /var/db/news /usr/local/news/control /usr/local/news /local/news /etc/news \
258 /usr/local/news/bin/control /usr/local/lib/news /news /usr/local/inn \
259 /var/lib/news /usr/lib /var/spool/news"
260
261dnl Other defaults
262INN_NEWSUMASK=002
263INN_EXTENDEDDBZ=0
264
265RNEWS_PATH=/usr/bin/rnews
266INEWS_PATH=/usr/bin/inews
267
268dnl -----------------------------------------------------------------
269dnl
270dnl Command line options
271dnl
272AC_ARG_WITH(newshome, \
273  [--with-newshome=DIR     news home directory is DIR], \
274	    NEWSHOME="$withval")
275AC_ARG_WITH(history, \
276  [--without-history       do not perform history database lookup
277  --with-history=FILE     use FILE as history database])
278	    if test x$with_history != xno; then
279		AC_DEFINE_UNQUOTED(WITH_HISTORY, 1, [perform history database lookup])
280	    fi
281AC_ARG_WITH(errlog, \
282  [--with-errlog=LOG_XX    do syslog in category LOG_XX],[
283	    if test x$with_errlog = xno; then
284		AC_DEFINE_UNQUOTED(WITHOUT_ERRLOG, 1, ["LOG_NEWS"])
285	    elif test x$with_errlog != xyes ; then
286		AC_DEFINE_UNQUOTED(WITH_ERRLOG, $with_errlog, ["LOG_NEWS"])
287	    fi ])
288AC_ARG_WITH(inhosts, \
289  [--with-inhosts=DIR      use DIR as in.hosts directory], \
290	    INHOSTS="$with_inhosts")
291AC_ARG_WITH(hostconfig, \
292  [--with-hostconfig=DIR   use DIR for newsx per host configuration, default is INHOSTS], \
293	    HOSTCONFIG="$with_hostconfig")
294AC_ARG_WITH(minspool, \
295  [--with-minspool=size    use size as guideline for incoming spool size], [
296	    if test x$with_minspool != xyes ; then
297		AC_DEFINE_UNQUOTED(MINSPOOL, $with_minspool, [incoming spool size, default is 100000])
298	    fi ])
299AC_ARG_WITH(timeout, \
300  [--with-timeout=secs     use secs as general timeout, default is 600], [
301	    if test x$with_timeout != xyes ; then
302		AC_DEFINE_UNQUOTED(TIMEOUT, $with_timeout, [general timeout, default is 600])
303	    fi ])
304AC_ARG_WITH(ps-status, \
305  [--without-ps-status     do not modify 'ps' status])
306	    if test x$with_ps_status != xno; then
307		AC_DEFINE_UNQUOTED(PS_STATUS, 1, [modify status (i.e. command line) available for the ps command])
308	    fi
309AC_ARG_WITH(rnews, \
310  [--with-rnews=PROG       rnews program is PROG], \
311	    RNEWS_PATH="$withval")
312AC_ARG_WITH(inews, \
313  [--with-inews=PROG       inews program is PROG], \
314	    INEWS_PATH="$withval")
315
316dnl
317dnl Specify explicitly where we find things...
318dnl Should often not be necessary, but configure is not always clever enough
319dnl
320AC_ARG_WITH(newslib, \
321  [--with-newslib=DIR      use DIR for news shareable library files; libinn and libstorage], \
322	    NEWSLIB="$withval")
323AC_ARG_WITH(newsinclude, \
324  [--with-newsinclude=DIR  use DIR for news include file; storage.h], \
325	    NEWSINCLUDE="$withval")
326AC_ARG_WITH(newsconfig, \
327  [--with-newsconfig=FILE  use FILE(s) for runtime configuration], \
328	    NEWSCONFIG="$withval")
329
330dnl -----------------------------------------------------------------
331dnl
332dnl Config at runtime instead?
333dnl
334if test x$NEWSCONFIG != x; then
335  dnl
336  dnl Experimental: Runtime configuration
337  dnl
338  AC_MSG_CHECKING(runtime news configuration)
339  AC_MSG_RESULT($NEWSCONFIG)
340
341  dnl default to INN to pick libraries
342  INN_MODE=1
343
344else
345  dnl
346  dnl Find out what news system we have...
347  dnl Will handle NEWSHOME from the environment or the command line
348  dnl Some modern INNs have the config-files in NEWSHOME/etc
349  dnl
350
351  AC_MSG_CHECKING(for a news home directory)
352
353  if test x$NEWSHOME = x; then
354    list="$VISIT"
355  else
356    list="$NEWSHOME"
357    NEWSHOME=
358  fi
359  for a in ${list} ; do
360    dnl The "innshellvars" file is used for INN
361    if test -f $a/innshellvars; then
362	NEWSCONFIGDIR=$a
363    else if test -f $a/lib/innshellvars; then
364	NEWSCONFIGDIR=$a/lib
365    else if test -f $a/etc/innshellvars; then
366	NEWSCONFIGDIR=$a/etc
367    fi fi fi
368    if test x$NEWSCONFIGDIR != x; then
369	NEWSCONFIG=$NEWSCONFIGDIR/innshellvars
370	NEWSHOME=$a
371	AC_MSG_RESULT($a)
372	AC_MSG_CHECKING(and found INN, reading configuration)
373	if test -r $NEWSCONFIG; then
374	    INN_MODE=1
375	    # it has been reported that some INN 2.1 had its own VERSION
376	    VERSION_save="$VERSION"
377	    VERSION=
378	    . $NEWSCONFIG
379	    INN_VERSION="$VERSION"
380	    VERSION="$VERSION_save"
381	    INN_NEWSUMASK=`umask`
382	    if test x$NEWSBIN = x ; then
383	      AC_MSG_RESULT(ERROR: $NEWSCONFIG is probably in wrong format)
384	      exit 1
385	    fi
386	else
387	  AC_MSG_RESULT(ERROR: $NEWSCONFIG is inaccessible)
388	  AC_MSG_RESULT([Do one of the following (in an order of preference): ])
389	  AC_MSG_RESULT([ 1. Add yourself to the 'news' group in /etc/group])
390	  AC_MSG_RESULT([ 2. Compile this package as user news])
391	  AC_MSG_RESULT([ 3. Make the news configuration world readable])
392	  exit 1
393	fi
394	AC_MSG_RESULT(OK)
395
396	AC_MSG_CHECKING(binaries)
397	AC_MSG_RESULT($NEWSBIN)
398	dnl AC_MSG_CHECKING(rnews)
399	dnl AC_MSG_RESULT($RNEWS)
400
401	AC_MSG_CHECKING(etc)
402	if test x$PATHETC = x ; then
403		PATHETC="$NEWSHOME"
404	fi
405	AC_MSG_RESULT($PATHETC)
406
407	AC_MSG_CHECKING(spool)
408	AC_MSG_RESULT($SPOOL)
409	AC_MSG_CHECKING(outgoing batch)
410	AC_MSG_RESULT($BATCH)
411	AC_MSG_CHECKING(incoming batch)
412	AC_MSG_RESULT($INCOMING)
413	if test x$INHOSTS = x ; then
414	    case x"$SPOOL" in
415	    x*/articles )
416		  dnl new form (INN 2.0)
417		  INHOSTS=`echo "$SPOOL" | sed "s/articles$/inhosts/"`
418		  ;;
419	    * )
420		  dnl old form
421		  INHOSTS="$SPOOL/in.hosts"
422		  ;;
423	    esac
424	fi
425
426	AC_MSG_CHECKING(active)
427	AC_MSG_RESULT($ACTIVE)
428
429	if test x$with_history != xno; then
430	    AC_MSG_CHECKING(history)
431	    if test x$with_history != x; then
432		if test x$with_history != xyes; then
433		    HISTORY="$with_history"
434		fi
435	    fi
436	    if test -f $HISTORY; then
437		if test -f $HISTORY.index; then
438		    AC_MSG_RESULT($HISTORY, indexed hash)
439		elif test -f $HISTORY.pag; then
440		    AC_DEFINE_UNQUOTED(DO_TAGGED_HASH, 1, [for INN 2.x and dbz v.6])
441		    AC_MSG_RESULT($HISTORY, tagged hash)
442		elif test -f $HISTORY.n.index; then
443		    AC_MSG_RESULT($HISTORY, indexed hash)
444		elif test -f $HISTORY.n.pag; then
445		    AC_DEFINE_UNQUOTED(DO_TAGGED_HASH, 1, [for INN 2.x and dbz v.6])
446		    AC_MSG_RESULT($HISTORY, tagged hash)
447		else
448		    AC_MSG_RESULT(ERROR: cannot determine hash mode of $HISTORY)
449		    AC_MSG_RESULT(Try running makehistory first)
450		    exit 1
451		fi
452	    else
453		AC_MSG_RESULT(ERROR: cannot find database $HISTORY)
454		exit 1
455	    fi
456	fi
457
458	dnl AC_MSG_CHECKING(error log)
459	dnl AC_MSG_RESULT($ERRLOG)
460	AC_MSG_CHECKING(locks)
461	AC_MSG_RESULT($LOCKS)
462	AC_MSG_CHECKING(newsfeeds)
463	AC_MSG_RESULT($NEWSFEEDS)
464
465	if test x$NEWSLIB = x; then
466	    dnl BUG: have something better here...
467	    dnl was: NEWSLIB="$NEWSHOME/lib"
468	    NEWSLIB="$NEWSCONFIGDIR"
469	fi
470
471	AC_MSG_CHECKING(news user)
472	AC_MSG_RESULT($NEWSUSER)
473
474	dnl
475	dnl For early INN 2.x
476	dnl If we have libinn, then this is irrelevant
477	dnl
478	if test x$EXTENDEDDBZ = xtrue ||
479	   test x$EXTENDEDDBZ = xyes  ||
480	   test x$EXTENDEDDBZ = xon; then
481	    INN_EXTENDEDDBZ=1
482	fi
483
484	break
485    fi
486    dnl The "bin/config" file is used for C News
487    if test -f $a/bin/config; then
488	NEWSHOME=$a
489	NEWSCONFIG=$a/bin/config
490	AC_MSG_RESULT($a)
491	AC_MSG_CHECKING(and found C News, reading configuration)
492	if test -r $a/bin/config; then
493	    INN_MODE=0
494	    . $a/bin/config
495	    if test x$NEWSBIN = x ; then
496		AC_MSG_RESULT(ERROR: $a/bin/config is inaccessible or wrong format)
497		exit 1
498	    fi
499	else
500	  AC_MSG_RESULT(ERROR: $a/bin/config is inaccessible)
501	  AC_MSG_RESULT([Do one of the following (in an order of preference): ])
502	  AC_MSG_RESULT([ 1. Add yourself to the 'news' group in /etc/group])
503	  AC_MSG_RESULT([ 2. Compile this package as user news])
504	  AC_MSG_RESULT([ 3. Make the news configuration world readable])
505	  exit 1
506	fi
507	AC_MSG_RESULT(OK)
508
509	AC_MSG_CHECKING(binaries)
510	AC_MSG_RESULT($NEWSBIN)
511
512	AC_MSG_CHECKING(control)
513	AC_MSG_RESULT($NEWSCTL)
514
515	AC_MSG_CHECKING(spool)
516	AC_MSG_RESULT($NEWSARTS)
517
518	dnl Convert to INN equivalents
519	dnl $RNEWS
520	PATHETC="$NEWSHOME"
521	SPOOL="$NEWSARTS"
522	BATCH="$NEWSARTS/out.going"
523	INCOMING="$NEWSARTS/in.coming"
524	if test x$INHOSTS = x ; then
525	    INHOSTS="$NEWSARTS/in.hosts"
526	fi
527
528	dnl This is pretty standard:
529	AC_MSG_CHECKING(active)
530	ACTIVE="$NEWSCTL/active"
531	if test -f $ACTIVE; then
532	    AC_MSG_RESULT($ACTIVE)
533	else
534	    AC_MSG_RESULT(ERROR: cannot find file $ACTIVE)
535	    exit 1
536	fi
537
538	dnl But this isn't always:
539	if test x$with_history != xno; then
540	    AC_MSG_CHECKING(history)
541	    if test x$with_history != x; then
542		if test x$with_history != xyes; then
543		    HISTORY="$with_history"
544		fi
545	    fi
546	    if test x$HISTORY = x ; then
547		dnl BUG: history may be elsewhere...
548		HISTORY="$NEWSCTL/history"
549	    fi
550	    if test -f $HISTORY; then
551		AC_MSG_RESULT($HISTORY)
552	    else
553		AC_MSG_RESULT(ERROR: cannot find $HISTORY database)
554		echo
555		echo "Perhaps you need to build a history database. See the INN"
556		echo "documentation (INSTALL for instance) for enlightenment."
557		exit 1
558	    fi
559	fi
560
561	dnl ERRLOG
562
563	LOCKS="$NEWSHOME"
564	NEWSFEEDS="$NEWSCTL/sys"
565	if test x$NEWSLIB = x; then
566	    NEWSLIB="$NEWSHOME"
567	fi
568
569	dnl BUG: fixed user name
570	NEWSUSER="news"
571	AC_MSG_CHECKING(news user)
572	AC_MSG_RESULT($NEWSUSER)
573
574	break
575    fi
576  done
577  if test x$NEWSCONFIG = x ; then
578    AC_MSG_RESULT(ERROR: cannot find a news configuration)
579    exit 1
580  fi
581fi
582
583dnl
584dnl News config finished
585dnl
586
587AC_SUBST(NEWSCONFIG)
588AC_SUBST(NEWSHOME)
589AC_SUBST(NEWSBIN)
590AC_SUBST(PATHETC)
591AC_SUBST(SPOOL)
592AC_SUBST(BATCH)
593AC_SUBST(INCOMING)
594AC_SUBST(INHOSTS)
595AC_SUBST(HOSTCONFIG)
596AC_SUBST(ACTIVE)
597AC_SUBST(HISTORY)
598AC_SUBST(LOCKS)
599AC_SUBST(NEWSFEEDS)
600AC_SUBST(NEWSUSER)
601AC_SUBST(NEWSLIB)
602AC_SUBST(INN_MODE)
603AC_SUBST(INN_NEWSUMASK)
604AC_SUBST(INN_EXTENDEDDBZ)
605
606dnl -----------------------------------------------------------------
607dnl
608dnl  Check out the C compiler, tools and libraries
609dnl
610
611dnl Check for CC before anything else..
612AC_PROG_CC
613
614dnl Issue all GCC warnings..
615if test "$GCC" = yes; then
616  CFLAGS="$CFLAGS -Wall"
617fi
618
619dnl Extra include directory
620if test x"$NEWSINCLUDE" != x; then
621  CPPFLAGS="$CPPFLAGS -I$NEWSINCLUDE"
622fi
623
624dnl Check for Posixized ISC, and NeXT
625AC_ISC_POSIX
626
627if test "$ISC" != yes; then
628  dnl method suggested by Helmut Heller <heller@altoetting-online.de>
629  AC_CACHE_CHECK([for NeXT], ac_cv_nextstep, [
630    if test -d /NextApps; then
631      ac_cv_nextstep=yes
632    else
633      ac_cv_nextstep=no
634    fi])
635  if test "$ac_cv_nextstep" = yes; then
636    if test "$GCC" = yes; then
637      CFLAGS="$CFLAGS -posix"
638    else
639      CFLAGS="$CFLAGS -Xp"
640    fi
641    AC_DEFINE(_POSIX_SOURCE, [], [Next with Posix source])
642  fi
643fi
644
645dnl Checks for programs.
646AC_PROG_MAKE_SET
647AC_PROG_INSTALL
648AC_PROG_RANLIB
649AM_C_PROTOTYPES
650AC_PATH_PROG(SENDMAIL_PATH, sendmail, /usr/lib/sendmail)
651AC_PATH_PROG(RNEWS_PATH, rnews, $RNEWS_PATH)
652AC_PATH_PROG(INEWS_PATH, inews, $INEWS_PATH)
653
654dnl Checks for header files.
655AC_HEADER_STDC
656AC_HEADER_TIME
657AC_CHECK_HEADERS(sys/time.h limits.h syslog.h values.h stdlib.h          \
658		 malloc.h sys/malloc.h string.h strings.h memory.h stdarg.h \
659		 varargs.h \
660		 fcntl.h sys/filio.h sys/ioctl.h sys/file.h sys/stat.h   \
661		 sys/wait.h sys/socket.h ansi/string.h sys/vfs.h         \
662		 sys/statvfs.h sys/param.h sys/mount.h libc.h)
663
664dnl Checks for compiler characteristics.
665AC_C_CONST
666
667AC_CACHE_CHECK([for packed struct], ac_cv_gnuc_packed,
668[AC_TRY_COMPILE(,
669changequote(<<, >>)dnl
670<<
671/* NEXTSTEP Gnu C does not support this */
672struct { char a; char b; } __attribute__((packed)) s;
673>>,
674changequote([, ])dnl
675ac_cv_gnuc_packed=yes, ac_cv_gnuc_packed=no)])
676if test $ac_cv_gnuc_packed = yes; then
677  AC_DEFINE(PACKED, [__attribute__((packed))], [Attribute for packed structure])
678else
679  AC_DEFINE(PACKED, [/* packed */])
680fi
681
682dnl Checks for standard include file completeness.
683AC_TYPE_SIGNAL
684AC_TYPE_PID_T
685AC_TYPE_OFF_T
686AC_TYPE_SIZE_T
687AC_TYPE_MODE_T
688AC_CHECK_TYPE(nlink_t, short)
689
690dnl Checks for library functions.
691AC_FUNC_VPRINTF
692AC_FUNC_MMAP
693AC_CHECK_LIB(nsl, main)
694AC_CHECK_LIB(inet, main)
695AC_CHECK_LIB(socket, main)
696AC_CHECK_LIB(gen, syslog)
697AC_CHECK_FUNCS(strerror strsignal strtoul waitpid gettimeofday)
698AC_CHECK_FUNCS(putenv setenv, HAVE_SETENV=1)
699AC_CHECK_FUNCS(getopt_long, HAVE_GETOPT=1)
700AC_CHECK_FUNCS(statfs statvfs)
701AC_SUBST(HAVE_SETENV)
702AC_SUBST(HAVE_GETOPT)
703
704dnl unistd.h presumably already verified above
705if test x$ac_cv_header_unistd_h = x; then
706    AC_CHECK_HEADERS(unistd.h)
707fi
708
709dnl
710dnl Checks for INN 2.0 and onwards
711dnl
712if test x$INN_MODE = x1; then
713    LDFLAGS_save="$LDFLAGS"
714    LDFLAGS="$LDFLAGS -L$NEWSLIB"
715    AC_CHECK_LIB(inn, HashMessageID, HAVE_LIBINN=1)
716
717    LIBS_save="$LIBS"
718    dnl
719    dnl Note that double inclusion of -lstorage seem to be required
720    dnl on some systems to get the QIO-functions
721    dnl
722    LIBS="$LIBS -linn -lstorage"
723    AC_CHECK_LIB(storage, IsToken, HAVE_LIBSTORAGE=1)
724
725    dnl
726    dnl Regretfully, the standard INN install does not place this
727    dnl crucial include-file in any standard place. So, unless it is
728    dnl installed manually, we have to resort to a local copy.
729    dnl Debian and RedHat Linux places it under /usr/include/inn
730    dnl In addition, $NEWSHOME/include may be a logical place to look
731    dnl The option --with-newsinclude may be used to override
732    dnl
733
734    dnl Extra include directory
735    if test -d /$NEWSHOME/include; then
736       CPPFLAGS="$CPPFLAGS -I$NEWSHOME/include"
737    fi
738
739    AC_CHECK_HEADERS(storage.h)
740    AC_CHECK_HEADERS(inn/storage.h)
741
742    LDFLAGS="$LDFLAGS_save"
743    LIBS="$LIBS_save"
744fi
745AC_SUBST(HAVE_LIBINN)
746AC_SUBST(HAVE_LIBSTORAGE)
747
748dnl Handle extra object files and libraries
749AC_CHECK_HEADERS(inn/dbz.h)
750dnl Always include good old version 3.4:
751MORELIBS2="../dbz/libdbzv3.a"
752if test x$HAVE_SETENV != x1; then
753    MORELIBS2="$MORELIBS2 ../lib/libsetenv.a"
754fi
755if test x$HAVE_GETOPT != x1; then
756    MORELIBS2="$MORELIBS2 ../lib/libgetopt.a"
757fi
758if test x$HAVE_LIBINN = x1; then
759    dnl Yes, we'll use the INN library
760    MORELIBS1="$MORELIBS1 -L$NEWSLIB"
761    MORELIBS2="$MORELIBS2 -linn"
762    AC_DEFINE_UNQUOTED(HAVE_LIBINN, 1, [ for INN 2.x: libinn available?])
763else
764    dnl No, so we'll use our home made stuff...
765    MORELIBS2="$MORELIBS2 ../dbz/libdbz.a"
766fi
767if test x$HAVE_LIBSTORAGE = x1; then
768    dnl Yes, we'll use the Storage-API library
769    if test x$HAVE_LIBINN != x1; then
770	MORELIBS1="$MORELIBS1 -L$NEWSLIB"
771    fi
772    dnl
773    dnl BUG:
774    dnl Note that double inclusion of -lstorage seem to be required
775    dnl on some systems to get the QIO-functions
776    dnl
777    MORELIBS2="-lstorage $MORELIBS2 -lstorage"
778    dnl BUG: remove...
779    dnl LIBS="-lstorage $LIBS -lstorage"
780    AC_DEFINE_UNQUOTED(HAVE_LIBSTORAGE, 1, [for INN 2.x: storage-API available?])
781else
782    dnl No, default to dummy...
783    MORELIBS2="$MORELIBS2 ../lib/libstorage.a"
784fi
785MORELIBS="$MORELIBS1 $MORELIBS2"
786AC_SUBST(MORELIBS)
787
788dnl Extra substitutions into config.h
789AC_DEFINE_UNQUOTED(PACKAGE_COPYRIGHT, "$PACKAGE_COPYRIGHT", [Copyleft?])
790AC_DEFINE_UNQUOTED(NEWSCONFIG,  "$NEWSCONFIG",     [e.g. "/usr/lib/news/bin/config"])
791AC_DEFINE_UNQUOTED(NEWSHOME,    "$NEWSHOME",       [e.g. "/usr/lib/news"])
792AC_DEFINE_UNQUOTED(NEWSBIN,     "$NEWSBIN",        [e.g. "/usr/lib/newsbin"])
793AC_DEFINE_UNQUOTED(PATHETC,     "$PATHETC",        [e.g. "/usr/lib/news"])
794AC_DEFINE_UNQUOTED(ACTIVE,      "$ACTIVE",         [e.g. "/usr/lib/news/active"])
795AC_DEFINE_UNQUOTED(HISTORY,     "$HISTORY",        [e.g. "/usr/lib/news/history"])
796AC_DEFINE_UNQUOTED(NEWSFEEDS,   "$NEWSFEEDS",      [e.g. "usr/lib/news/newsfeeds"])
797AC_DEFINE_UNQUOTED(SPOOL,       "$SPOOL",          [e.g. "/var/spool/news"])
798AC_DEFINE_UNQUOTED(BATCH,       "$BATCH",          [e.g. "/var/spool/news/out.going"])
799AC_DEFINE_UNQUOTED(INCOMING,    "$INCOMING",       [e.g. "/var/spool/news/in.coming"])
800AC_DEFINE_UNQUOTED(INHOSTS,     "$INHOSTS",        [e.g. "/var/spool/news/in.hosts"])
801AC_DEFINE_UNQUOTED(HOSTCONFIG,  "$HOSTCONFIG",     [e.g. "/var/spool/news/in.hosts" or "/etc/newsx"])
802AC_DEFINE_UNQUOTED(LOCKS,       "$LOCKS",          [e.g. "/usr/lib/news"])
803AC_DEFINE_UNQUOTED(NEWSLIB,     "$NEWSLIB",        [e.g. "/usr/lib/news"])
804AC_DEFINE_UNQUOTED(SENDMAIL_PATH,"$SENDMAIL_PATH", [e.g. "/usr/bin/sendmail"])
805AC_DEFINE_UNQUOTED(RNEWS_PATH,  "$RNEWS_PATH",     [e.g. "/usr/bin/rnews"])
806AC_DEFINE_UNQUOTED(INEWS_PATH,  "$INEWS_PATH",     [e.g. "/usr/bin/inews"])
807AC_DEFINE_UNQUOTED(INN_MODE,     $INN_MODE,        [running under INN?])
808AC_DEFINE_UNQUOTED(INN_NEWSUMASK, $INN_NEWSUMASK,  [default to 002])
809AC_DEFINE_UNQUOTED(INN_EXTENDEDDBZ,$INN_EXTENDEDDBZ,[for INN 2.x: using extended dbz?])
810
811dnl
812dnl We must have sensible default values
813dnl for all files and directories mentioned in the
814dnl documentation.  Use new INN names as defaults.
815dnl
816mk_doc ()
817{
818	e=`eval echo $\{"$1"\}`
819	if test "x$e" = "x"; then
820		eval DOC_$1="$2"
821	else
822		eval DOC_$1="$e"
823	fi
824	e="s%@DOC_$1@%`eval echo $\{DOC_$1\}`%g"
825	extrasub=`(echo "$extrasub"; echo "$e")`
826}
827dnl
828dnl BUG: --with_newsconfig these values are very misleading
829dnl      since this is all decided at runtime
830dnl
831mk_doc NEWSUSER         "news"
832mk_doc SPOOL            "/var/spool/news"
833mk_doc NEWSHOME         "/usr/lib/news"
834mk_doc NEWSBIN          "/usr/lib/newsbin"
835mk_doc BATCH            "$DOC_SPOOL/outgoing"
836mk_doc INCOMING         "$DOC_SPOOL/incoming"
837mk_doc INHOSTS          "$DOC_SPOOL/in.hosts"
838mk_doc HOSTCONFIG       "$DOC_SPOOL/in.hosts"
839mk_doc LOCKS            "$DOC_NEWSHOME"
840mk_doc PATHETC          "$DOC_NEWSHOME"
841mk_doc NEWSFEEDS        "$DOC_NEWSHOME/newsfeeds"
842mk_doc ACTIVE           "$DOC_NEWSHOME/active"
843mk_doc HISTORY          "$DOC_NEWSHOME/history"
844mk_doc NEWSCONFIG       "$DOC_NEWSHOME/innshellvars"
845
846AC_CONFIG_FILES([README doc/newsx.8 doc/newsq.1 doc/in.hosts.5 doc/newsx.conf.5 \
847 src/newsq more/addgroup.all newsx.spec \
848 Makefile src/Makefile dbz/Makefile doc/Makefile lib/Makefile more/Makefile \
849 test/Makefile])
850AC_CONFIG_COMMANDS([default],[[ \
851# Makefile uses this timestamp file to record whether config.h is up to date.
852touch stamp-config]],[[]])
853AC_OUTPUT
854chmod +x more/addgroup.all
855
856dnl
857dnl Complain about missing libraries
858dnl
859if test x$INN_MODE = x1; then
860    if test x$HAVE_LIBINN != x1; then
861	echo
862	echo "NOTE: Could not find a libinn library."
863	echo "This is really required for INN 2.x"
864	if test x$INN_VERSION != x; then
865	    echo "Ensure that the proper libraries are installed for INN 2.x"
866	    echo "and re-run configure, possibly using --with-newslib"
867	    mv -f config.h config.h.incomplete
868	    exit 1
869	fi
870    fi
871    if test x$HAVE_LIBSTORAGE != x1; then
872	echo
873	echo "NOTE: Could not find a libstorage library"
874	echo "This is really required for INN 2.x"
875	if test x$INN_VERSION != x; then
876	    echo "Ensure that the proper libraries are installed for INN 2.x"
877	    echo "and re-run configure, possibly using --with-newslib"
878	    mv -f config.h config.h.incomplete
879	    exit 1
880	fi
881    else
882	if test "$ac_cv_header_storage_h$ac_cv_header_inn_storage_h" = nono; then
883	    echo
884	    echo "NOTE: Could not find a storage.h include file"
885	    echo "This is really required for INN 2.x"
886	    echo "Ensure that the proper include file is installed for INN 2.x"
887	    echo "and re-run configure."
888	    mv -f config.h config.h.incomplete
889	    exit 1
890	fi
891    fi
892fi
893