1dnl autoconf script for leafnode -*- m4 -*- vim: set tw=0:
2dnl written by Cornelius Krasel, 1999
3dnl enhanced by Matthias Andree, 2000 - 2021
4dnl Process this file with autoconf to produce a configure script.
5AC_INIT([leafnode],[1.11.12])
6AC_PREREQ(2.60)
7AC_CONFIG_SRCDIR([leafnode.h])
8AM_INIT_AUTOMAKE
9AC_CONFIG_HEADERS([config.h])
10
11dnl Checks for programs.
12AC_PROG_AWK
13AC_PROG_CC_STDC
14
15AC_USE_SYSTEM_EXTENSIONS
16
17dnl figure inline
18AC_C_INLINE
19dnl kill volatile if not understood:
20AC_C_VOLATILE
21
22AC_PROG_RANLIB
23AC_PROG_MAKE_SET
24AC_PROG_INSTALL
25AC_PROG_MAKE_SET
26AC_PROG_RANLIB
27AC_PROG_SED
28
29AC_CHECK_TOOL([AR],ar,ar,$PATH:/usr/sbin:/usr/ccs/bin )
30AC_CHECK_TOOL([STRIP],[strip])
31AC_PATH_PROG( RPM, rpm )
32AC_PATH_PROG([ID], [id], [false], /usr/xpg4/bin:/usr/bin:/bin)
33
34dnl check whether called with --with-ipv6
35AC_ARG_WITH(ipv6,
36	    AS_HELP_STRING([--without-ipv6],[disable IPv6 support (default enable)]),,[with_ipv6=yes])
37if test "$with_ipv6" != "no" ; then
38  AC_DEFINE(HAVE_IPV6, 1, [Define to 1 this to compile with IPv6 support.])
39fi
40
41AC_CHECK_DECL(AI_ADDRCONFIG,,AC_DEFINE(AI_ADDRCONFIG,0,[define to 0 if your system does not support AI_ADDRCONFIG]),[#define _XOPEN_SOURCE 600
42#include <netdb.h>])
43
44dnl check where to put the confdir
45AC_ARG_WITH(confdir,
46AS_HELP_STRING([--with-confdir],[obsolete option, use --sysconfdir]),
47 AC_MSG_ERROR([--with-confdir=D is obsolete. Please use --sysconfdir=D.]))
48if test "$sysconfdir" = '${prefix}/etc' && test "x$prefix" = "xNONE" ; then
49    CONFDIR='/etc/leafnode'
50else
51    CONFDIR="$sysconfdir"
52fi
53
54if test "$CONFDIR" != "$sysconfdir"; then
55  AC_MSG_WARN([***])
56  AC_MSG_WARN([*** overriding sysconfdir to $CONFDIR])
57  AC_MSG_WARN([*** use --sysconfdir to fix])
58  AC_MSG_WARN([*** use --sysconfdir='\$prefix/etc' to get default autoconf behaviour])
59  AC_MSG_WARN([***])
60  sleep 1
61fi
62sysconfdir=$CONFDIR
63AC_SUBST(sysconfdir)
64
65if test "$localstatedir" = '${prefix}/var' && test "$prefix" = NONE ; then
66  myvar=/var
67else
68  myvar="$localstatedir"
69fi
70
71dnl check where to put the spooldir
72AC_MSG_CHECKING(spooldir)
73AC_ARG_WITH(spooldir,
74	    AS_HELP_STRING([--with-spooldir],[news spool directory (/var/spool/news)]),
75  [ case "${withval-}" in
76  /*) ;;
77  *)  AC_MSG_ERROR(you must give an absolute path)
78      ;;
79  esac
80  withval=`echo "$withval" | sed 'sx/*$xx;'`]
81,
82  withval="$myvar/spool/news"
83)
84SPOOLDIR=$withval
85AC_MSG_RESULT($SPOOLDIR)
86AC_SUBST(SPOOLDIR)
87
88dnl check where to put the lockfile
89AC_MSG_CHECKING(lockfile)
90AC_ARG_WITH(lockfile,
91	    AS_HELP_STRING([--with-lockfile],[lockfile path (${spooldir}/leaf.node/lock.file)]),
92  [
93  case "${withval-}" in
94  /*) ;;
95  *)  AC_MSG_ERROR(you must give an absolute path)
96      ;;
97  esac ]
98,
99withval="$SPOOLDIR/leaf.node/lock.file"
100)
101LOCKFILE=$withval
102AC_MSG_RESULT($LOCKFILE)
103AC_SUBST(LOCKFILE)
104
105dnl Checks for types.
106AC_TYPE_MODE_T
107AC_TYPE_OFF_T
108AC_TYPE_UID_T
109
110dnl Checks for header files.
111AC_HEADER_DIRENT
112AC_HEADER_STDC
113AC_HEADER_SYS_WAIT
114
115dnl Check whether all necessary include files are there
116AC_MSG_CHECKING(for system include files)
117AC_CACHE_VAL(cf_cv_sysheaders, AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
118#include <sys/param.h>]], [[
119    return 0; ]])],[ cf_cv_sysheaders="yes" ],[ cf_cv_sysheaders="no" ])
120  )
121if test "$cf_cv_sysheaders" = "yes"
122then
123  AC_MSG_RESULT(yes)
124else
125  AC_MSG_RESULT(no)
126  AC_MSG_ERROR(Kernel sources not installed - unable to continue)
127fi
128
129AC_HEADER_TIME
130AC_CHECK_HEADERS([fcntl.h sys/time.h syslog.h unistd.h sys/socket.h sys/sockio.h strings.h sys/types.h stdlib.h])
131AC_CHECK_HEADERS([net/if.h], [], [],
132		 [#include <stdio.h>
133		  #ifdef HAVE_SYS_TYPES_H
134		  # include <sys/types.h>
135		  #endif
136		  #ifdef STDC_HEADERS
137		  # include <stdlib.h>
138		  # include <stddef.h>
139		  #else
140		  # ifdef HAVE_STDLIB_H
141		  #  include <stdlib.h>
142		  # endif
143		  #endif
144		  #ifdef HAVE_SYS_SOCKET_H
145		  # include <sys/socket.h>
146		  #endif
147		 ])
148AC_CHECK_HEADERS([netinet/in.h], [], [],
149		 [#include <stdio.h>
150		  #ifdef HAVE_SYS_TYPES_H
151		  # include <sys/types.h>
152		  #endif
153		  #ifdef STDC_HEADERS
154		  # include <stdlib.h>
155		  # include <stddef.h>
156		  #else
157		  # ifdef HAVE_STDLIB_H
158		  #  include <stdlib.h>
159		  # endif
160		  #endif
161		  #ifdef HAVE_SYS_SOCKET_H
162		  # include <sys/socket.h>
163		  #endif
164		 ])
165AC_CHECK_HEADERS([net/if_var.h], [], [],
166		 [#include <stdio.h>
167		  #ifdef HAVE_SYS_TYPES_H
168		  # include <sys/types.h>
169		  #endif
170		  #ifdef STDC_HEADERS
171		  # include <stdlib.h>
172		  # include <stddef.h>
173		  #else
174		  # ifdef HAVE_STDLIB_H
175		  #  include <stdlib.h>
176		  # endif
177		  #endif
178		  #ifdef HAVE_SYS_SOCKET_H
179		  # include <sys/socket.h>
180		  #endif
181		  #ifdef HAVE_NET_IF_H
182		  # include <net/if.h>
183		  #endif
184		 ])
185AC_CHECK_HEADERS([netinet/in_var.h], [], [],
186		 [#include <stdio.h>
187		  #ifdef HAVE_SYS_TYPES_H
188		  # include <sys/types.h>
189		  #endif
190		  #ifdef STDC_HEADERS
191		  # include <stdlib.h>
192		  # include <stddef.h>
193		  #else
194		  # ifdef HAVE_STDLIB_H
195		  #  include <stdlib.h>
196		  # endif
197		  #endif
198		  #ifdef HAVE_SYS_SOCKET_H
199		  # include <sys/socket.h>
200		  #endif
201		  #ifdef HAVE_NET_IF_H
202		  # include <net/if.h>
203		  #endif
204		  #ifdef HAVE_NETINET_IN_H
205		  # include <netinet/in.h>
206		  #endif
207		  #ifdef HAVE_NET_IF_VAR_H
208		  # include <net/if_var.h>
209		  #endif
210		 ])
211AC_CHECK_TYPE(socklen_t, [],
212	      [AC_DEFINE(socklen_t,int,[Define to 'int' if <sys/socket.h> does not define.])],
213[
214  #ifdef HAVE_SYS_TYPES_H
215  #include <sys/types.h>
216  #endif
217  #ifdef HAVE_SYS_SOCKET_H
218  #include <sys/socket.h>
219  #endif
220])
221
222dnl Checks for typedefs, structures, and compiler characteristics.
223AC_C_CONST
224AC_TYPE_PID_T
225AC_TYPE_SIZE_T
226AC_STRUCT_TM
227AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[
228		  #if TIME_WITH_SYS_TIME
229		  # include <sys/time.h>
230		  # include <time.h>
231		  #else
232		  # if HAVE_SYS_TIME_H
233		  #  include <sys/time.h>
234		  # else
235		  #  include <time.h>
236		  # endif
237		  #endif
238		  ])
239
240AC_CHECK_SIZEOF(long)
241AC_CHECK_SIZEOF(time_t)
242
243dnl Coerce GLIBC 2.3 to GLIBC 2.2 compatibility.
244dnl May not be complete with future extensions, but appears to work
245dnl today, 2003-10-02. Matthias Andree
246AC_DEFINE(__NO_CTYPE,1,[Define __NO_CTYPE to 1 to avoid GLIBC_2.3-specific ctype.h functions.])
247
248dnl check whether called with --with-newsuser
249AC_MSG_CHECKING(user)
250AC_ARG_WITH(user,
251	    AS_HELP_STRING([--with-user=<userid>],[name of user account to run as (news)]),,
252[ withval=news ])
253if test "x$withval" = "xyes" ; then
254    AC_MSG_ERROR([--with-user=<userid> requires an argument])
255fi
256if test "x$withval" = "xno" ; then
257    AC_MSG_ERROR([--without-user is not supported])
258fi
259if test "x$withval" = "xroot" ; then
260    AC_MSG_ERROR([--with-user=root is not allowed])
261fi
262AC_DEFINE_UNQUOTED(NEWS_USER, "$withval", [what user ID to run as])
263NEWS_USER="$withval"
264AC_MSG_RESULT($NEWS_USER)
265AC_SUBST(NEWS_USER)
266if $ID -u "$withval" >/dev/null 2>/dev/null ; then
267    :
268else
269    AC_MSG_WARN([User "$withval" does not exist.])
270    warned=1
271fi
272
273dnl check whether called with --with-newsgroup
274AC_MSG_CHECKING(group)
275AC_ARG_WITH(group,
276	    AS_HELP_STRING([--with-group=<group>],[name of news group to run as (news)]),,
277[ withval=news ]
278)
279AC_DEFINE_UNQUOTED(NEWS_GROUP, "$withval", [what group ID to run as.])
280if test "x$withval" = "xyes" ; then
281    AC_MSG_ERROR([--with-group=<groupid> requires an argument])
282fi
283if test "x$withval" = "xno" ; then
284    AC_MSG_ERROR([--without-group is not supported])
285fi
286NEWS_GROUP="$withval"
287AC_MSG_RESULT($NEWS_GROUP)
288AC_SUBST(NEWS_GROUP)
289if test "x$withval" = "xroot" || test "x$withval" = "xwheel" ; then
290    AC_MSG_WARN([--with-group=root and --with-group=wheel are not recommended])
291    warned=1
292fi
293if find / -prune -group "$withval" >/dev/null 2>/dev/null ; then
294    :
295else
296    AC_MSG_WARN([Group "$withval" does not exist.])
297    warned=1
298fi
299
300dnl ### Note that pcre-config is somewhat broken:
301dnl ### the CFLAGS contain -I which belong into CPPFLAGS
302dnl (found by William Hooper, July 2002)
303AC_ARG_VAR(PCRECONFIG,where the pcre-config script is installed)
304AC_PATH_PROG(PCRECONFIG,pcre-config,no)
305ORIG_CFLAGS="$CFLAGS"
306ORIG_CPPFLAGS="$CPPFLAGS"
307ORIG_LIBS="$LIBS"
308ORIG_LDFLAGS="$LDFLAGS"
309if test "$PCRECONFIG" != "no" ; then
310  PCRE_CFLAGS=`$PCRECONFIG --cflags`
311  PCRE_LIBS=`$PCRECONFIG --libs`
312else
313    AC_MSG_WARN([cannot find pcre-config, this can cause PCRE to not be found.])
314fi
315
316dnl check for PCRE
317CFLAGS="$CFLAGS $PCRE_CFLAGS"
318CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
319LDFLAGS="$LDFLAGS $LIBS $PCRE_LIBS"
320AC_CHECK_HEADERS(pcre.h)
321AC_CHECK_LIB(pcre, pcre_compile,[PCRELIB="-lpcre"])
322
323if test x$ac_cv_header_pcre_h = xno \
324    || test x$ac_cv_lib_pcre_pcre_compile = xno ; then
325	cat <<EOF
326----------------------------------------------------------------
327PCRE is not installed in your system or cannot be found.
328Please obtain PCRE separately from http://www.pcre.org/,
329compile and install it, then retry to install leafnode.
330See the PCRE_README file for instructions.
331----------------------------------------------------------------
332EOF
333	AC_MSG_ERROR([PCRE is not installed, cannot continue.])
334    fi
335
336AC_SUBST(PCRELIB)
337AC_SUBST(PCREDEP)
338
339dnl Check for BSD4.2 syslog
340AC_MSG_CHECKING(for BSD4.2 syslog)
341AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
342#include <syslog.h>]], [[
343       openlog( "configure", LOG_PID|LOG_CONS, LOG_NEWS ); ]])],[ cf_cv_have_bsd42="no" ],[ cf_cv_have_bsd42="yes" ])
344if test $cf_cv_have_bsd42 = "yes"
345then
346  AC_MSG_RESULT(yes)
347  AC_DEFINE(HAVE_OLD_SYSLOG, 1,
348	[Define to 1 if your openlog(3) takes only two arguments (BSD4.2 style).])
349else
350  AC_MSG_RESULT(no)
351fi
352
353dnl Checks for library functions.
354AC_FUNC_STRFTIME
355dnl AC_FUNC_UTIME_NULL
356dnl The next two aren't needed and just confuse dietlibc:
357dnl AC_FUNC_MALLOC
358dnl AC_FUNC_REALLOC
359AC_CHECK_FUNCS(setgid setuid getifaddrs)
360AC_CHECK_FUNC(lstat,,AC_DEFINE(lstat, stat, [Define to stat if you don't have lstat]))
361AC_REPLACE_FUNCS(getline strdup mkstemp strlcpy timegm)
362AC_FUNC_FORK
363
364dnl Check if system snprintf works
365AC_MSG_CHECKING(if your system's snprintf works)
366AC_RUN_IFELSE([ AC_LANG_SOURCE([
367/* tell xsnprintf.c to not include leafnode.h which depends
368 * on config.h, which doesn't exist at this time,
369 * and we don't want the overrides just yet. */
370#define RUN_FROM_CONFIGURE 1
371`cat $srcdir/xsnprintf.c`
372])],
373result=yes,
374result=no,
375result="unknown -- cross-compiling -- assuming yes")
376AC_MSG_RESULT([$result])
377if test "$result" != "no" ; then
378    AC_DEFINE(HAVE_WORKING_SNPRINTF, 1, [Define to 1 if you have a _properly working_ 'snprintf' function.])
379else
380    AC_MSG_WARN([Your system's libc is broken and provides only a faulty snprintf.])
381fi
382
383# Whenever both -lsocket and -lnsl are needed, it seems to be always the
384# case that gethostbyname requires -lnsl.  So, check -lnsl first, for it
385# to be in LIBS before the setsockopt checks are performed.  *However*,
386# on SINIX-N 5.43, this is false, and gethostent seems to be a better
387# candidate. So, let's use it below instead of gethostbyname, and see.
388# Stolen from GNU tar 1.12
389
390AC_SEARCH_LIBS(gethostent, nsl)
391AC_SEARCH_LIBS(setsockopt, socket)
392AC_SEARCH_LIBS(syslog, bsd socket inet)
393
394AC_MSG_CHECKING(if your sockaddr has sa_len)
395AC_CACHE_VAL(cf_cv_have_salen, AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
396    #include <sys/types.h>
397    #include <sys/socket.h>]], [[
398    struct sockaddr sa;
399    (void)sa.sa_len;]])],[ cf_cv_have_salen="yes" ],[ cf_cv_have_salen="no" ])
400)
401if test $cf_cv_have_salen = yes
402then
403    AC_MSG_RESULT(yes)
404    AC_DEFINE(HAVE_SALEN, 1, [Define to 1 if your ifreq's if_addr has a
405			      sa_len member.])
406else
407    AC_MSG_RESULT(no)
408fi
409
410AC_MSG_CHECKING(if your system supports SIOCGIFALIAS)
411AC_CACHE_VAL(cf_cv_have_SIOCGIFALIAS, AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
412    #include <stddef.h>
413    #include <sys/types.h>
414    #include <sys/socket.h>
415    #ifdef HAVE_SYS_SOCKIO_H
416    #include <sys/sockio.h>
417    #endif
418    #include <net/if.h>
419]], [[
420    (void)ioctl(0, SIOCGIFALIAS, NULL);]])],[ cf_cv_have_SIOCGIFALIAS="yes" ],[ cf_cv_have_SIOCGIFALIAS="no" ])
421)
422if test $cf_cv_have_SIOCGIFALIAS = yes
423then
424    AC_MSG_RESULT(yes)
425    AC_DEFINE(HAVE_SIOCGIFALIAS, 1, [Define to 1 if your system supports ioctl(., SIOCGIFALIAS; .)])
426else
427    AC_MSG_RESULT(no)
428fi
429
430if test "$GCC" = yes ; then
431    AC_MSG_CHECKING([if $CC is really Intel C++])
432    case "`$CC -V 2>&1`" in
433	[[iI][nN][tT][eE][lL]]*)	ICC=yes ;;
434	*)				ICC=no ;;
435    esac
436    AC_MSG_RESULT($ICC)
437fi
438
439if test "$GCC" = yes && test "x$GCC_FLAGS" = "x" && test "$ICC" = no
440then
441    AC_MSG_CHECKING(for some good GCC flags)
442    AC_LANG_CONFTEST([AC_LANG_SOURCE([])])
443    for i in -Wall -W -Wextra -Wstrict-prototypes -Wwrite-strings -Wno-unused-result
444    do
445	if $CC $i -c conftest.c
446	then
447	    GCC_FLAGS="$GCC_FLAGS $i"
448	fi
449    done
450    rm -f conftest.c conftest.o
451    AC_MSG_RESULT($GCC_FLAGS)
452fi
453export GCC_FLAGS
454AC_SUBST(GCC_FLAGS)
455AC_SUBST(BINDIR)
456AC_SUBST(SYSCONFDIR)
457
458dnl check for rpm build dir
459AC_MSG_CHECKING(rpm build dir)
460dnl avoid checking against /SPECS
461d=${RPMSRC:-/usr/src/rpm}
462test -d ${d}/SPECS || d=/usr/src/rpm
463test -d ${d}/SPECS || d=/usr/src/packages
464test -d ${d}/SPECS || d=/usr/src/redhat
465test -d ${d}/SPECS || d=none
466RPMSRC=${d}
467AC_MSG_RESULT(${RPMSRC})
468AC_SUBST(RPMSRC)
469
470dnl figure path to some tools
471AC_ARG_VAR(TCPSERVER, where tcpserver is installed)
472AC_PATH_PROG([TCPSERVER],tcpserver,none,/command /usr/local/bin $PATH)
473AC_ARG_VAR(ARGV0, where argv0 is installed)
474AC_PATH_PROG([ARGV0],argv0,none,/command /usr/local/bin $PATH)
475AC_ARG_VAR(TCPD, where tcpd is installed)
476AC_PATH_PROG([TCPD],tcpd,none,/usr/sbin /usr/libexec /usr/lbin /usr/etc /usr/bin /usr/local/sbin /usr/local/bin $PATH)
477
478
479dnl sysconfdir can still contain unexpanded variables, so we try to
480dnl expand them, hopefully safely enough.
481tmp="`echo $sysconfdir | sed -f ${srcdir}/sanitize.sed`"
482msysconfdir="`(
483if test "x$prefix" = xNONE ; then
484  prefix=$ac_default_prefix
485fi
486eval echo \"\\\"$tmp\\\"\" )`"
487AC_SUBST(msysconfdir)
488AC_CONFIG_FILES([subst leafnode.spec Makefile doc_german/Makefile])
489AC_CONFIG_COMMANDS([default],[[echo timestamp >stamp-h]],[[]])
490AC_OUTPUT
491
492cat <<EOF
493*** leafnode $VERSION is now configured and prepared to be compiled.
494*** to compile, type 'make' (without the quotes)
495*** to run some tests, type 'make check' (without the quotes)
496*** to install, type 'make install' as root (without the quotes)
497EOF
498
499if test "x$warned" = "x1" ; then
500    AC_MSG_WARN(Review the warnings given above and check if you need to fix)
501    AC_MSG_WARN(the situation that caused the warning)
502fi
503