1dnl!
2dnl! aegis - a project change supervisor
3dnl! Copyright (C) 1994, 1995, 1997-1999, 2001-2010, 2012 Peter Miller
4dnl! Copyright (C) 2006-2009 Walter Franzini
5dnl!
6dnl! This program is free software; you can redistribute it and/or
7dnl! modify it under the terms of the GNU General Public License as
8dnl! published by the Free Software Foundation; either version 3 of the
9dnl! License, or (at your option) any later version.
10dnl!
11dnl! This program is distributed in the hope that it will be useful,
12dnl! but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14dnl! General Public License for more details.
15dnl!
16dnl! You should have received a copy of the GNU General Public License
17dnl! along with this program. If not, see <http://www.gnu.org/licenses/>.
18dnl!
19AC_INIT(install-sh)
20AC_CONFIG_HEADER(common/config.h)
21AC_LANG(C++)
22AC_PROG_CXX
23AC_PROG_CPP
24AC_CANONICAL_HOST
25AC_GNU_SOURCE
26
27dnl!
28dnl! Look for an existing Aegis installation, and use the "aegis
29dnl! --configured" command to replicate its configuration.
30dnl! Unless they said --with-no-aegis-configured
31dnl!
32if test "x$prefix" = "xNONE"
33then
34    if test "x$with_no_aegis_configured" = "x"; then
35        cfgval=`aegis --configured 2> /dev/null`
36        if test $? -eq 0; then
37            eval "$cfgval"
38        else
39            cfgval=`which aegis 2> /dev/null`
40            if test $? -ne 0; then
41                case "$cfgval" in
42                /bin/aegis )
43                    prefix=/
44                    ;;
45                */bin/aegis )
46                    prefix=`echo $cfgval | sed 's|/bin/aegis$||'`
47                    ;;
48                esac
49            fi
50        fi
51    fi
52fi
53
54AC_PROG_INSTALL
55
56AC_PROG_YACC
57
58if test "$YACC" = "yacc" -a ! -f /usr/bin/yacc
59then
60  AC_MSG_RESULT([
61        You must have the bison command installed in order
62        to build Aegis.
63        Homepage: http://www.gnu.org/software/bison/])
64  OK=no
65  if apt-get --version > /dev/null 2> /dev/null; then
66    AC_MSG_RESULT([
67        The following command may be used to install it:
68        sudo apt-get install bison
69    ])
70    OK=yes
71  fi
72  if yum --version > /dev/null 2> /dev/null; then
73    AC_MSG_RESULT([
74        The following command may be used to install it:
75        sudo yum install bison
76    ])
77    OK=yes
78  fi
79  if test "$OK" != "yes"; then
80    AC_MSG_RESULT([
81        If you are using a package based install, you will need the
82        bison package.
83    ])
84  fi
85  exit 1
86fi
87
88AC_CHECK_PROGS(AR, ar)
89AC_PROG_RANLIB
90AC_MINIX
91AC_ISC_POSIX
92AC_OBJEXT
93AC_EXEEXT
94
95dnl!
96dnl! Large file support.
97dnl!
98AC_TYPE_OFF_T
99AC_FUNC_FSEEKO
100AC_SYS_LARGEFILE
101
102dnl!
103dnl! DO NOT check for -ldmalloc, using
104dnl!     AC_CHECK_LIB(dmalloc, dmalloc_malloc)
105dnl! or similar.
106dnl!
107dnl! The dmalloc library can be instructed to log to a file,
108dnl! circumventing the Aegis I/O layer, thus it's possible to create
109dnl! file owned by root.  The dmalloc library should only ever be
110dnl! used as a debugging tool, and NEVER be used in a production build
111dnl! of Aegis.
112dnl!
113
114dnl! Solaris 2.5.1 and below wide-character support
115AC_CHECK_FUNC(wschr, ,
116        unset ac_cv_func_wschr
117        AC_CHECK_LIB(w, wschr))
118
119dnl!
120dnl! we need to check for libiconv before we check for libintl
121dnl!
122AC_CHECK_LIB(iconv, iconv, ,
123    unset ac_cv_func_iconv)
124
125dnl!
126dnl! Solaris needs to use the GNU Gettext to have any chance of
127dnl! having working error message translation.  So we look for -lintl
128dnl! unconditionally.
129dnl!
130AC_CHECK_LIB(intl, gettext, ,
131  [
132    unset ac_cv_func_gettext
133    AC_CHECK_LIB(gettext, gettext, ,
134      unset ac_cv_func_gettext)
135  ]
136)
137
138AC_CHECK_FUNC(setsockopt, ,
139        unset ac_cv_func_setsockopt
140        AC_CHECK_LIB(socket, setsockopt))
141dnl!
142dnl! Check the presence of libm.  We use additional parentheses around
143dnl! the name of the function to avoid problems if atan2 is *also*
144dnl! defined as a macro.
145dnl!
146AC_CHECK_LIB(m, (atan2))
147AC_CHECK_LIB(rx, regcomp)
148AC_CHECK_LIB(z, gzopen, ,
149  [
150    AC_MSG_RESULT([
151        You must have the zlib compression library installed in order
152        to build Aegis.  Please install zlib, and then re-run this
153        ./configure script.
154        Homepage: http://www.zlib.net/])
155    OK=no
156    if apt-get --version > /dev/null 2> /dev/null; then
157      AC_MSG_RESULT([
158        The following command may be used to install it:
159        sudo apt-get install zlib1g-dev
160      ])
161      OK=yes
162    fi
163    if yum --version > /dev/null 2> /dev/null; then
164      AC_MSG_RESULT([
165        The following command may be used to install it:
166        sudo yum install zlib-devel
167      ])
168      OK=yes
169    fi
170    if test "$OK" != "yes"; then
171      AC_MSG_RESULT([
172        If you are using a package based install, you will need the
173        zlib-devel package in addition to the zlib package.
174      ])
175    fi
176    exit 1
177  ]
178)
179AC_CHECK_LIB(bz2, BZ2_bzopen, ,
180  [
181    AC_MSG_RESULT([
182        You must have the BZip2 compression library installed in order
183        to build Aegis.  Please install the bzip2 library, and then
184        re-run this ./configure script.
185        Homepage: http://www.bzip.org/])
186    OK=no
187    if apt-get --version > /dev/null 2> /dev/null; then
188      AC_MSG_RESULT([
189        The following command may be used to install it:
190        sudo apt-get install libbz2-dev bzip2
191      ])
192      OK=yes
193    fi
194    if yum --version > /dev/null 2> /dev/null; then
195      AC_MSG_RESULT([
196        The following command may be used to install it:
197        sudo yum install libbz2-devel bzip2
198      ])
199      OK=yes
200    fi
201    if test "$OK" != "yes"; then
202      AC_MSG_RESULT([
203        If you are using a package based install, you will need the
204        bzip2-devel package in addition to the bzip package.
205      ])
206    fi
207    exit 1
208  ]
209)
210AC_CHECK_LIB(crypt, crypt)
211AC_CHECK_LIB(magic, magic_file, ,
212  [
213    AC_MSG_RESULT([
214        You may like to have the file magic number library installed in
215        order to build Aegis.  This will result is superior Content-Type
216        information being inserted at several points in the code.
217        Homepage: http://www.darwinsys.com/file/])
218    OK=no
219    if apt-get --version > /dev/null 2> /dev/null; then
220      AC_MSG_RESULT([
221        The following command may be used to install it:
222        sudo apt-get install libmagic-dev
223      ])
224      OK=yes
225    fi
226    if yum --version > /dev/null 2> /dev/null; then
227      AC_MSG_RESULT([
228        The following command may be used to install it:
229        sudo yum install libmagic-devel
230      ])
231      OK=yes
232    fi
233    if test "$OK" != "yes"; then
234      AC_MSG_RESULT([
235        If you are using a package based install, you will need the
236        libmagic-devel package in addition to the libmagic package.
237      ])
238    fi
239  ]
240)
241dnl! The -lclu library is for OSF/1 clustering
242AC_CHECK_LIB(clu, clu_info)
243
244STATIC_LIBS=
245
246dnl!
247dnl! Look for static libraries necessary with -lcurl, but we don't need
248dnl! them when we are using shared libraries.
249dnl!
250AC_CHECK_PROGS(CURL_CONFIG, curl-config)
251
252if test -n "$CURL_CONFIG"
253then
254    CFLAGS="$CFLAGS `$CURL_CONFIG --cflags`"
255    CXXFLAGS="$CXXFLAGS `$CURL_CONFIG --cflags`"
256    STATIC_LIBS="`$CURL_CONFIG --libs`"
257fi
258
259dnl!
260dnl! The curl library is used to read from arbitrary URLs.
261dnl!
262AC_CHECK_LIB(curl, curl_multi_perform, [],
263  [
264    AC_MSG_RESULT([
265        You may like to have the multi-protocol file transfer library
266        installed in order to build Aegis.
267        Homepage: http://curl.haxx.se/])
268    OK=no
269    if apt-get --version > /dev/null 2> /dev/null; then
270      AC_MSG_RESULT([
271        One of the following commands may be used to install it:
272        sudo apt-get install libcurl4-gnutls-dev
273        sudo apt-get install libcurl3-dev
274        (The first is preferred, it is more Free; the second needs
275        openssl, which is not so Free.)
276      ])
277      OK=yes
278    fi
279    if yum --version > /dev/null 2> /dev/null; then
280      AC_MSG_RESULT([
281        The following command may be used to install it:
282        sudo yum install libcurl-devel
283      ])
284      OK=yes
285    fi
286    if test "$OK" != "yes"; then
287      AC_MSG_RESULT([
288        If you are using a package based install, you will need the
289        libcurl-devel package in addition to the libcurl package.
290      ])
291    fi
292  ],
293  [$STATIC_LIBS])
294
295dnl!
296dnl! Look for static libraries necessary with -lxml2, but we don't need
297dnl! them when we are using shared libraries.
298dnl!
299AC_CHECK_PROGS(XML2_CONFIG, xml2-config)
300
301if test -n "$XML2_CONFIG"
302then
303    CFLAGS="$CFLAGS `$XML2_CONFIG --cflags`"
304    CXXFLAGS="$CXXFLAGS `$XML2_CONFIG --cflags`"
305    STATIC_LIBS="$STATIC_LIBS `$XML2_CONFIG --libs` -lpthread"
306fi
307
308dnl!
309dnl! The libxml2 library is used by the aerevml(1) command to parse its
310dnl! input files.
311dnl!
312AC_CHECK_LIB(xml2, xmlTextReaderRead, [],
313  [
314    AC_MSG_RESULT([
315        You must have the Gnome libxml2 library installed in order to
316        build Aegis.  Please install the xml2 library version 1.8.17 or
317        later, and then re-run this ./configure script.  You do not have
318        to install the rest of Gnome, the library can be used on its own.
319        Homepage: http://xmlsoft.org/])
320    OK=no
321    if apt-get --version > /dev/null 2> /dev/null; then
322      AC_MSG_RESULT([
323        The following command may be used to install it:
324        sudo apt-get install libxml2-dev
325      ])
326      OK=yes
327    fi
328    if yum --version > /dev/null 2> /dev/null; then
329      AC_MSG_RESULT([
330        The following command may be used to install it:
331        sudo yum install libxml2-devel
332      ])
333      OK=yes
334    fi
335    if test "$OK" != "yes"; then
336      AC_MSG_RESULT([
337        If you are using a package based install, you will need the
338        libxml2-devel package in addition to the libxml2 package.
339      ])
340    fi
341    exit 1
342  ],
343  [$STATIC_LIBS]
344)
345
346dnl!
347dnl! Arrange for a special make variable for static builds.
348dnl!
349AC_SUBST(STATIC_LIBS)
350
351dnl!
352dnl! Try to detect a library with the UUID functions, where available
353dnl! (FreeBSD) prefer libc.
354dnl!
355dnl! The OSSP variant has uuid_load in -luuid
356dnl!     and which include file?
357dnl!     *** later we check for uuid_create, uuid_make and uuid_export
358dnl!
359dnl! The e2fsprogs variant has uuid_generate in -luuid
360dnl!     and which include file?
361dnl!     *** later we check for uuid_generate and uuid_unparse
362dnl!
363dnl! The DCE compliant variant has uuid_hash in -luuid
364dnl!     The include file is <dce/uuid.h>
365dnl!     *** later we check for uuid_create and uuid_to_string
366dnl!
367dnl! The BSD variant has uuid_has in libc (no -l required)
368dnl!     The include file is <uuid.h>
369dnl!     *** it is supposed to be the same as the DCE variant.  Is it?
370AC_CHECK_LIB(c, uuid_hash,,
371AC_CHECK_LIB(uuid, uuid_load)
372AC_CHECK_LIB(uuid, uuid_generate)
373AC_CHECK_LIB(uuid, uuid_hash)
374)
375
376dnl!
377dnl! If there are no UUID libraries we can roll our own, but first we
378dnl! need to see if the Linux kernel will do it for us.
379dnl!
380AC_MSG_CHECKING([for Linux /proc/sys/kernel/random/uuid])
381HAVE_LINUX_UUID=no
382if test -f "/proc/sys/kernel/random/uuid"
383then
384    AC_DEFINE(HAVE_LINUX_UUID, 1,
385        [Define this symbol if your system has
386/proc/sys/kernel/random/uuid])
387    AC_DEFINE(LINUX_UUID_FILENAME,["/proc/sys/kernel/random/uuid"],
388        [Define this symbol if your system has
389/proc/sys/kernel/random/uuid])
390    AC_DEFINE(LINUX_UUID_SIZE, 36,
391        [Define this symbol if your system has
392/proc/sys/kernel/random/uuid])
393        HAVE_LINUX_UUID=yes
394fi
395AC_MSG_RESULT([$HAVE_LINUX_UUID])
396
397AC_CHECK_PROGS(MSGFMT, gmsgfmt msgfmt)
398AC_CHECK_PROGS(MSGCAT, gmsgcat msgcat)
399AC_CHECK_PROGS(GROFF, groff roff)
400AC_CHECK_PROGS(SOELIM, roffpp gsoelim soelim)
401AC_CHECK_PROGS(REFER, grefer refer)
402AC_PROG_AWK
403
404dnl!
405dnl! We need some way to determine the value of the default MANPATH
406dnl! setting, so that we can append to it.  There are (at least) two
407dnl! incompatible man implementations out there.  The one used by Debian
408dnl! Linux has a "manpath -q" command, the one used by RedHat Linux has
409dnl! a "man -w" command.  If neither works, assume a constant string.
410dnl!
411AC_CHECK_PROGS(MANPATH_PROG, manpath)
412
413if test -n "$MANPATH_PROG"
414then
415    dnl!
416    dnl! Sometimes manpath prints irritating warnings,
417    dnl! but not all versions have -q to silence them.
418    dnl!
419    MANPATH_PROG="$MANPATH_PROG 2>/dev/null"
420else
421    dnl!
422    dnl! Some versions of man have a -w option, but it's short for --whatis
423    dnl! and so they print nothing on stdout, and an error message about
424    dnl! the missing argument on stderr.  Some versions of man -w do the
425    dnl! same thing as manpath.
426    dnl!
427    temp_str=`man -w 2>/dev/null`
428    if test -n "$temp_str"
429    then
430        MANPATH_PROG="man -w 2>/dev/null"
431    else
432        MANPATH_PROG="echo /usr/man:/usr/share/man"
433    fi
434fi
435
436AC_CHECK_PROGS(LOCALE_PROG, locale, , [${PATH}:/usr/sbin:/sbin])
437if test -n "$LOCALE_PROG"
438then
439    AC_DEFINE(HAVE_LOCALE_PROG, 1,
440    [Define this symbol if your system has the locale(1) program.])
441fi
442
443AC_CHECK_PROGS(LOCALE_GEN_PROG, locale-gen, , [${PATH}:/usr/sbin:/sbin])
444if test -n "$LOCALE_GEN_PROG"
445then
446    AC_DEFINE(HAVE_LOCALE_GEN_PROG, 1,
447    [Define this symbol if your system has the locale-gen(8) program.])
448fi
449
450AC_PATH_PROG(WISH, wish, /usr/local/bin/wish)
451AC_PATH_PROG(VI_PROG, vi, /bin/vi)
452
453AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
454AC_DEFINE_UNQUOTED(CONF_PERL, ["$PERL"],
455[Set this to be the absolute path of a Perl interpreter.])
456
457dnl!
458dnl! See if we are using GNU diff
459dnl!
460AC_CHECK_PROGS(DIFFsimple, gdiff diff, diff)
461AC_PATH_PROG(DIFF, $DIFFsimple, /usr/local/bin/$DIFFsimple)
462AC_DEFINE_UNQUOTED(CONF_DIFF, ["$DIFF"],
463[Set this to be the absolute path of the GNU diff command.])
464AC_MSG_CHECKING([for GNU diff])
465HAVE_GNU_DIFF=no
466if $DIFF --version > conftest.out 2>&1
467then
468    if grep 'GNU diff' conftest.out > conftest.err 2>&1
469    then
470        AC_DEFINE(HAVE_GNU_DIFF, 1,
471            [Define this symbol of your system has GNU diff.])
472        HAVE_GNU_DIFF=yes
473    fi
474fi
475AC_MSG_RESULT([$HAVE_GNU_DIFF])
476
477dnl!
478dnl! Find the patch program, and check whether or not it understands
479dnl! the -f and -s options.
480dnl!
481AC_CHECK_PROGS(PATCHsimple, gpatch patch)
482AC_PATH_PROG(PATCH, $PATCHsimple, /usr/local/bin/$PATCHsimple)
483AC_DEFINE_UNQUOTED(CONF_PATCH, ["$PATCH"],
484[Set this to be the absolute path of the GNU diff command.])
485AC_MSG_CHECKING([for GNU patch])
486HAVE_GNU_PATCH=no
487if $PATCH -f -s < /dev/null > conftest.out 2>&1
488then
489    AC_DEFINE(HAVE_GNU_PATCH, 1,
490        [Define this symbol of your system has GNU patch.])
491    HAVE_GNU_PATCH=yes
492fi
493AC_MSG_RESULT([$HAVE_GNU_PATCH])
494
495dnl!
496dnl! Test if groff takes -ms or -mgs for the macro package.
497dnl!
498AC_MSG_CHECKING([for $GROFF -ms macros])
499if test `echo ' ' | groff -mgs 2> /dev/null | wc -l` -gt 0
500then
501    GROFF_MS_MACROS=gs
502else
503    GROFF_MS_MACROS=s
504fi
505AC_SUBST(GROFF_MS_MACROS)
506AC_MSG_RESULT([-m$GROFF_MS_MACROS])
507
508dnl!
509dnl! Test if groff takes -mm or -mgm for the macro package.
510dnl!
511AC_MSG_CHECKING([for $GROFF -mm macros])
512if test `echo ' ' | groff -mgm 2> /dev/null | wc -l` -gt 0
513then
514        GROFF_MM_MACROS=gm
515else
516        GROFF_MM_MACROS=m
517fi
518AC_SUBST(GROFF_MM_MACROS)
519AC_MSG_RESULT([-m$GROFF_MM_MACROS])
520
521dnl!
522dnl! Test to see where TIOCGWINSZ is defined.
523dnl!
524AC_MSG_CHECKING([for TIOCGWINSZ])
525AC_TRY_RUN([
526#include <sys/ioctl.h>
527int main(int argc, char **argv){
528#ifdef TIOCGWINSZ
529struct winsize window_size; window_size.ws_col = 0; return(window_size.ws_col);
530#else
531return(1);
532#endif
533}]
534, AC_DEFINE(HAVE_winsize_SYS_IOCTL_H,1,
535[Define this symbol if your system as <sys/ioctl.h> AND it
536defines TIOCGWINSZ and struct winsize.])
537AC_MSG_RESULT([sys/ioctl.h]),
538AC_MSG_RESULT([not found]),
539AC_MSG_RESULT(cross))
540
541dnl!
542dnl! Test to see where struct winsize is defined.
543dnl!
544AC_MSG_CHECKING([for struct winsize])
545AC_TRY_RUN([
546#include <termios.h>
547int main(int argc, char **argv){
548#ifdef TIOCGWINSZ
549struct winsize window_size; window_size.ws_col = 0; return(window_size.ws_col);
550#else
551return(1);
552#endif
553}]
554, AC_DEFINE(HAVE_winsize_TERMIOS_H,1,
555[Define this symbol if your system as <termios.h> AND it
556defines TIOCGWINSZ and struct winsize.])
557AC_MSG_RESULT([termios.h]),
558AC_MSG_RESULT([not found]),
559AC_MSG_RESULT(cross))
560
561dnl!
562dnl! Test to see if stdarg.h is available *and* works.
563dnl!
564AC_MSG_CHECKING([for working stdarg.h])
565AC_TRY_RUN([
566#include <stdarg.h>
567char *foo = "test";
568#if defined(__GNUC__) || __STDC__
569int test(char*,...);
570#endif
571int test(fmt)char*fmt;{va_list ap;char*a;int x;
572va_start(ap,fmt);a=va_arg(ap,char*);x=(a!=foo);va_end(ap);return x;}
573int main(int argc, char **argv){
574return(test("",foo));}]
575, AC_DEFINE(HAVE_STDARG_H,1,
576[Define this symbol of your system has <stdarg.h> AND it works.])
577AC_MSG_RESULT(yes),
578AC_MSG_RESULT(no),
579AC_MSG_RESULT(cross))
580
581dnl!
582dnl! Test to see if mblen is available *and* works.
583dnl!
584AC_MSG_CHECKING([for working mblen])
585AC_TRY_RUN([
586#include <stdlib.h>
587int main(){mblen(0,0);
588return(mblen("OK", 2) != 1);}],
589AC_DEFINE(HAVE_MBLEN,1,
590[Define this symbol of your system has mblen AND it works.])
591AC_MSG_RESULT(yes),
592AC_MSG_RESULT(no),
593AC_MSG_RESULT(cross))
594
595AC_CHECK_HEADERS(            \
596        bits/c++locale.h     \
597        boost/shared_ptr.hpp \
598        bzlib.h              \
599        crypt.h              \
600        curl/curl.h          \
601        curl/multi.h         \
602        dce/rpc.h            \
603        dce/uuid.h           \
604        execinfo.h           \
605        fcntl.h              \
606        iso646.h             \
607        libgettext.h         \
608        libintl.h            \
609        limits.h             \
610        locale.h             \
611        magic.h              \
612        memory.h             \
613        mntent.h             \
614        new.h                \
615        regex.h              \
616        rxposix.h            \
617        shadow.h             \
618        stddef.h             \
619        stdlib.h             \
620        string.h             \
621        sys/clu.h            \
622        sys/ioctl.h          \
623        sys/prctl.h          \
624        sys/uuid.h           \
625        tr1/memory           \
626        unistd.h             \
627        uuid.h               \
628        uuid/uuid.h          \
629        wchar.h              \
630        wctype.h             \
631        widec.h              \
632        zlib.h               \
633        )
634
635#
636# Look for the C++ <new> header.
637#
638AC_MSG_CHECKING([for <new>])
639AC_COMPILE_IFELSE([#include <new>],
640AC_DEFINE(HAVE_HEADER_NEW, 1,
641    [Define this symbol of your system has the <new> C++ header])
642AC_MSG_RESULT(yes),
643AC_MSG_RESULT(no))
644
645AC_HEADER_DIRENT
646AC_TYPE_SIGNAL
647AC_TYPE_SIZE_T
648AC_CHECK_SIZEOF(int)
649AC_CHECK_SIZEOF(long)
650AC_CHECK_SIZEOF(long long)
651
652AC_COMPUTE_INT(ac_cv_long_bit, [LONG_BIT], [#include <limits.h>],
653    [ac_cv_long_bit="LONG_BIT"])
654AC_DEFINE_UNQUOTED(LONG_BIT, [$ac_cv_long_bit],
655    [Define this symbol to be the number of bits in a long.
656    This is analogous to the standard CHAR_BIT define.])
657
658AC_HEADER_TIME
659AC_C_CONST
660AC_SYS_LONG_FILE_NAMES
661AC_CHECK_FUNCS(                 \
662    backtrace                   \
663    clu_info                    \
664    crypt                       \
665    curl_easy_strerror          \
666    curl_multi_strerror         \
667    getpgrp                     \
668    igetspnam                   \
669    initgroups                  \
670    gettext                     \
671    gettimeofday                \
672    iswctype                    \
673    lutime                      \
674    magic_file                  \
675    mbrtowc                     \
676    memmem                      \
677    pathconf                    \
678    prctl                       \
679    regcomp                     \
680    rpc_string_free             \
681    seteuid setlocale           \
682    setresuid                   \
683    setreuid                    \
684    sighold                     \
685    sigrelse                    \
686    sigprocmask                 \
687    snprintf                    \
688    strcasecmp                  \
689    strendcpy                   \
690    strlcat                     \
691    strlcpy                     \
692    strncasecmp                 \
693    strerror                    \
694    strftime                    \
695    strsignal                   \
696    strtoll                     \
697    strtoul                     \
698    strverscmp                  \
699    symlink                     \
700    tcgetpgrp                   \
701    uuid_create                 \
702    uuid_export                 \
703    uuid_generate               \
704    uuid_hash                   \
705    uuid_load                   \
706    uuid_make                   \
707    uuid_to_string              \
708    uuid_unparse                \
709    vsnprintf                   \
710    wcrtomb                     \
711    wcslen                      \
712    wcswidth                    \
713    wcwidth                     \
714    xmlReaderForIO              \
715    )
716AC_CHECK_DECLS([crypt],,, [
717#if HAVE_UNISTD_H
718#include <unistd.h>
719#endif
720#if HAVE_CRYPT_H
721#include <crypt.h>
722#endif
723])
724AC_CHECK_DECLS([mbrtowc, wcrtomb, wcwidth, wcswidth],,, [
725#if HAVE_WCHAR_H
726#include <wchar.h>
727#endif
728])
729dnl! the strsignal function is usually defined in <string.h>
730dnl! but is sometimes defined in <unistd.h>
731AC_CHECK_DECLS([strsignal],,, [
732#if HAVE_STRING_H
733#include <string.h>
734#include <unistd.h>
735#endif
736])
737
738dnl!
739dnl! Check to see if wint_t is defined.
740dnl! The ANSI C standard states that this symbol shall be defined
741dnl! by <wchar.h> and <wctype.h>.  The GNU people also define it in
742dnl! <stddef.h>, but this is incorrect.
743dnl!
744AC_MSG_CHECKING([for wint_t])
745AC_TRY_COMPILE([
746#ifdef HAVE_WCHAR_H
747#include <wchar.h>
748#endif
749],
750[ wint_t x; ],
751AC_DEFINE(HAVE_WINT_T,1,
752[Define this symbol of your system has the wint_t type defined.
753It is usually in <stddef.h> or <wctype.h>.])
754AC_MSG_RESULT(yes),
755AC_MSG_RESULT(no))dnl
756
757dnl!
758dnl! Check to see if mbstate_t is defined.
759dnl!
760AC_MSG_CHECKING([for mbstate_t])
761AC_TRY_COMPILE([
762#include <ctype.h>
763#ifdef HAVE_STDDEF_H
764#include <stddef.h>
765#endif
766/* Solaris bug 1250837: include wchar.h before widec.h */
767#ifdef HAVE_WCHAR_H
768#include <wchar.h>
769#endif
770#ifdef HAVE_WIDEC_H
771#include <widec.h>
772#endif
773#ifdef HAVE_WCTYPE_H
774#include <wctype.h>
775#endif
776],
777[ mbstate_t x; return sizeof x;],
778AC_DEFINE(HAVE_MBSTATE_T,1,
779[Define this symbol of your system has the mbstate_t type defined.
780 It is usually in <stddef.h> or <wchar.h>.])
781AC_MSG_RESULT(yes),
782AC_MSG_RESULT(no))dnl
783
784dnl!
785dnl! Test to see if iswprint is available *and* works.
786dnl!
787AC_MSG_CHECKING([for working iswprint])
788AC_TRY_RUN([
789#include <ctype.h>
790/* Solaris bug 1250837: include wchar.h before widec.h */
791#ifdef HAVE_WCHAR_H
792#include <wchar.h>
793#endif
794#ifdef HAVE_WIDEC_H
795#include <widec.h>
796#endif
797#ifdef HAVE_WCTYPE_H
798#include <wctype.h>
799#endif
800int main(int argc, char **argv){
801return(iswprint('a') == 0);}]
802, AC_DEFINE(HAVE_ISWPRINT,1,
803[Define this symbol of your system has iswprint() AND it works.])
804AC_MSG_RESULT(yes),
805AC_MSG_RESULT(no),
806AC_MSG_RESULT(cross))dnl
807
808dnl!
809dnl! Test to see if getpgrp() or getpgrp(0) should be used to
810dnl! discover the process group of the current process.
811dnl!
812AC_MSG_CHECKING([for appropriate getpgrp argument])
813AC_TRY_RUN([
814int main(int argc, char **argv) {
815#ifdef HAVE_GETPGRP
816if (getpgrp(32767) == getpgrp(0)) return(2);
817#endif
818return(0); }]
819, AC_DEFINE(CONF_getpgrp_arg, 0,
820[Set this to a suitable argument for the getpgrp function to discover
821the process group of the current process.])
822AC_MSG_RESULT(zero),
823AC_DEFINE(CONF_getpgrp_arg, [])
824AC_MSG_RESULT(empty),
825AC_MSG_RESULT(cross))
826
827dnl!
828dnl! Test to see if the pw_comment field exists in
829dnl! the passwd struct defined in the <pwd.h> include file.
830dnl!
831AC_MSG_CHECKING([for pw_comment in struct passwd])
832AC_TRY_COMPILE([
833#include <pwd.h>
834#include <stdio.h>
835], [
836struct passwd *pw;
837pw = getpwnam("root");
838printf("%s\n", pw->pw_comment);
839],
840AC_DEFINE(HAVE_pw_comment,1,
841[Define this symbol if your system has
842the pw_comment field in the passwd struct defined in <pwd.h>.])
843AC_MSG_RESULT(yes),AC_MSG_RESULT(no))dnl
844
845dnl!
846dnl! Test to see if the tm_zone field exists in
847dnl! the struct tm defined in the <time.h> include file.
848dnl!
849AC_MSG_CHECKING([for tm_zone in struct tm])
850AC_TRY_COMPILE([
851#include <stdio.h>
852dnl! #ifdef TIME_WITH_SYS_TIME
853#include <sys/time.h>
854dnl!  #include <time.h>
855dnl! #else
856dnl! #ifdef HAVE_SYS_TIME_H
857dnl! #include <sys/time.h>
858dnl! #else
859dnl! #include <time.h>
860dnl! #endif
861#endif], [struct tm *tm;
862printf("%s\n", tm->tm_zone);],
863AC_DEFINE(HAVE_tm_zone,1,
864[Define this symbol if your system has
865the tm_zone field in the tm struct defined in <time.h>.])
866AC_MSG_RESULT(yes),AC_MSG_RESULT(no))dnl
867
868dnl!
869dnl! Test to find a Bourne shell which understands functions
870dnl!
871AC_MSG_CHECKING([for a Bourne shell which understands functions])
872if test "z$SH" = "z"; then
873    if test -f /bin/sh5; then
874        SH=/bin/sh5
875    else
876        SH=/bin/sh
877    fi
878fi
879AC_SUBST(SH)
880AC_DEFINE_UNQUOTED(CONF_SHELL, ["$SH"],
881[Set this to be the absolute path of a Bourne shell
882which understands functions.])
883AC_MSG_RESULT($SH)
884
885dnl!
886dnl! Evaluate some of the variables, to remove ${prefix} references.
887dnl! This way, they can be used in C programs and Roff input.
888dnl! Make sure that aegis is mentioned in the libdir and datadir paths;
889dnl! add it if it is not already there.
890dnl!
891test "x$prefix" = xNONE && prefix="${ac_default_prefix-/usr/local}"
892test "x$exec_prefix" = xNONE && exec_prefix="$prefix"
893eval "bindir=$bindir"
894eval "datarootdir=$datarootdir"
895eval "datadir=$datadir"
896eval "libdir=$libdir"
897eval "mandir=$mandir"
898eval "sharedstatedir=$sharedstatedir"
899eval "sysconfdir=$sysconfdir"
900
901dnl!
902dnl! support for NLSDIR substitution
903dnl! and ./configure --with-nlsdir=path option
904dnl!
905AC_ARG_WITH(nlsdir,
906    [  --with-nlsdir=PATH   specify where the locale files should go])
907
908if test "x$NLSDIR" = "x"; then
909    if test "x$with_nlsdir" != "x"; then
910        NLSDIR=$with_nlsdir
911    else
912        NLSDIR=${datarootdir}/locale
913    fi
914fi
915eval "NLSDIR=$NLSDIR"
916AC_SUBST(NLSDIR)
917
918dnl!
919dnl! See if there is already existing library files
920dnl! Use uid/gid if so, otherwise use 3/3
921dnl!
922dnl! Cygwin always runs in "single user" mode, so this test isn't
923dnl! useful.  Just default the values to the preferred ones.
924dnl!
925if test "x$AEGIS_UID" = "x"; then
926    AC_MSG_CHECKING([for owner of aegis library files])
927    AEGIS_UID=3
928    AEGIS_GID=3
929    if test "$OSTYPE" != "cygwin32" -a "$OSTYPE" != "cygwin" ; then
930    if test -f ${sharedstatedir}/lockfile -o -f ${libdir}/lockfile ; then
931        cat > conftest.$ac_ext << 'EOF'
932#line __oline__ "configure"
933#include <stdio.h>
934#include <sys/types.h>
935#include <sys/stat.h>
936main(int ac, char **av){struct stat st;
937if (stat(*(av+1),&st)!=0)return(1);
938printf("%d\n", ac>2?st.st_gid:st.st_uid);return(0);}
939EOF
940        if AC_TRY_EVAL(ac_link); then
941                if maybe=`./conftest ${sharedstatedir}/lockfile`; then
942                        AEGIS_UID=$maybe
943                else
944                        if maybe=`./conftest ${libdir}/lockfile`; then
945                                AEGIS_UID=$maybe
946                        fi
947                fi
948                if maybe=`./conftest ${sharedstatedir}/lockfile gid`; then
949                        AEGIS_GID=$maybe
950                else
951                        if maybe=`./conftest ${libdir}/lockfile gid`; then
952                                AEGIS_GID=$maybe
953                        fi
954                fi
955        fi
956        rm -rf conftest*
957    fi
958    fi
959    AC_SUBST(AEGIS_UID)
960    AC_SUBST(AEGIS_GID)
961    AC_MSG_RESULT([$AEGIS_UID, $AEGIS_GID])
962fi
963
964dnl!
965dnl! If the libz.h is not present, Aegis will fail to compile.
966dnl! If the -lz is not present, Aegis will fail to link.
967dnl!
968if test "$ac_cv_lib_z_gzopen" != "yes" -o "$ac_cv_header_zlib_h" != "yes"
969then
970  AC_MSG_RESULT([
971        You need to install the GNU zlib compression
972        library, and then re-run this configure script.
973        Remember to use \`\`rm config.cache'' before you do.])
974fi
975
976dnl!
977dnl! If the curl/curl.h and -lcurl are not present, remote files are
978dnl! inaccessable.
979dnl!
980if test "$ac_cv_lib_curl_curl_multi_perform" != "yes" -o \
981    "$ac_cv_header_curl_curl_h" != "yes"
982then
983    AC_MSG_RESULT([
984        You may wish to install the Curl library, used to access
985        remote files.  Don't Panic: this library is optional, nothing
986        will break, but you will not be able to use all of aedist's
987        functions.  If you choose to install the Curl library, first
988        use \`\`rm config.cache'', and then re-run this configure
989        script.])
990fi
991
992dnl!
993dnl! Warn them about UUID libraries.
994dnl!
995UUID_OK=0
996if test "$ac_cv_func_uuid_generate" = "yes" \
997    -a "$ac_cv_func_uuid_unparse" = "yes"
998then
999    UUID_OK=1
1000fi
1001if test "$ac_cv_func_uuid_create" = "yes" \
1002    -a "$ac_cv_func_uuid_make" = "yes" \
1003    -a "$ac_cv_func_uuid_export" = "yes"
1004then
1005    UUID_OK=1
1006fi
1007if test "$ac_cv_func_uuid_create" = "yes" \
1008    -a "$ac_cv_func_uuid_to_string" = "yes"
1009then
1010    UUID_OK=1
1011fi
1012AC_DEFINE_UNQUOTED([UUID_OK], [$UUID_OK],
1013    [Define this symbol if your system has a working UUID implementation.])
1014if test "$UUID_OK" != "1"
1015then
1016  AC_MSG_RESULT([
1017        You may wish to install one of the following UUID
1018        library flavors:
1019         * e2fsprogs implementation
1020         * OSSP implementation
1021        Don't Panic: this library is optional, nothing will break.])
1022        dnl! ' <-- this is a work-around for a vim syntax highlighting bug
1023    OK=no
1024    if apt-get --version > /dev/null 2> /dev/null; then
1025      AC_MSG_RESULT([
1026        ONE of the following commands may be used to install it:
1027        sudo apt-get install uuid-dev
1028        sudo apt-get install libossp-uuid-dev
1029      ])
1030      OK=yes
1031    fi
1032    if yum --version > /dev/null 2> /dev/null; then
1033      AC_MSG_RESULT([
1034        The following command may be used to install it:
1035        sudo yum install uuid-devel
1036      ])
1037      OK=yes
1038    fi
1039fi
1040
1041dnl!
1042dnl! If the gettext function exists, assume the msgfmt program does
1043dnl! also, and arrange for the Makefile to install the .mo files
1044dnl! from the .po files.
1045dnl!
1046po_files=no
1047if test "$ac_cv_func_gettext" = "yes"
1048then
1049  if test -n "$MSGFMT"
1050  then
1051    po_files=yes
1052  fi
1053fi
1054if test "$po_files" = "no"
1055then
1056  AC_MSG_RESULT([
1057        Aegis will emit much more useful error messages if
1058        you install GNU Gettext and then re-run this
1059        ./configure script.
1060        Remember to use \`\`rm config.cache'' before you do.
1061        Homepage: http://www.gnu.org/software/gettext/])
1062  OK=no
1063  if apt-get --version > /dev/null 2> /dev/null; then
1064    AC_MSG_RESULT([
1065        The following command may be used to install it:
1066        sudo apt-get install gettext
1067    ])
1068    OK=yes
1069  fi
1070  if yum --version > /dev/null 2> /dev/null; then
1071    AC_MSG_RESULT([
1072        The following command may be used to install it:
1073        sudo yum install gettext
1074    ])
1075    OK=yes
1076  fi
1077  if test "$OK" != "yes"; then
1078    AC_MSG_RESULT([
1079        If you are using a package based install, you will need the
1080        gettext package.
1081    ])
1082  fi
1083fi
1084AC_SUBST(po_files)
1085
1086dnl!
1087dnl! If the soelim program exists, and understands the -I option,
1088dnl! arrange for the Makefile to install the .ps files from the
1089dnl! documentation source files.
1090dnl!
1091if test -n "$SOELIM"
1092then
1093  if $SOELIM -I. /dev/null > /dev/null 2>&1
1094  then
1095    : nothing
1096  else
1097    AC_MSG_RESULT([
1098        The $SOELIM program does not understand the -I option.
1099        GNU Groff 1.15 or later works correctly.
1100        See the BUILDING file for details.])
1101    GROFF=
1102  fi
1103else
1104  GROFF=
1105fi
1106if test -n "$REFER"
1107then
1108    : nothing
1109else
1110    # It turns out that somehow Debian systems get a half-assed groff
1111    # install from build-essential.  Looking for "refer" is a better
1112    # test of the completeness of the groff install than either
1113    # "groff" or "soelim" on their own, plus it's needed for the build.
1114    GROFF=
1115fi
1116if test -n "$GROFF"
1117then
1118  HAVE_GROFF=yes
1119else
1120  HAVE_GROFF=no
1121  AC_MSG_RESULT([
1122        The Aegis documentation set and manual pages will
1123        be formatted and installed if you first install
1124        GNU Groff 1.15 or later and then re-run this ./configure script.
1125        Remember to use \`\`rm config.cache'' before you do.
1126        Homepage: http://www.gnu.org/software/groff/])
1127  OK=no
1128  if apt-get --version > /dev/null 2> /dev/null; then
1129    AC_MSG_RESULT([
1130        The following command may be used to install it:
1131        sudo apt-get install groff
1132    ])
1133    OK=yes
1134  fi
1135  if yum --version > /dev/null 2> /dev/null; then
1136    AC_MSG_RESULT([
1137        The following command may be used to install it:
1138        sudo yum install groff
1139    ])
1140    OK=yes
1141  fi
1142  if test "$OK" != "yes"; then
1143    AC_MSG_RESULT([
1144        If you are using a package based install, you will need the
1145        groff package.
1146    ])
1147  fi
1148fi
1149AC_SUBST(HAVE_GROFF)
1150
1151if test "$HAVE_GNU_DIFF" != "yes"
1152then
1153  AC_MSG_RESULT([
1154        Some of the tests in the Aegis test suite (133, 136, 167, 168,
1155        180, 195) assume the presence of GNU diff.  Some functionality
1156        will be more limited without it.  You may wish to install GNU
1157        Diff 2.8 or later and then re-run this ./configure script.
1158        Remember to use \`\`rm config.cache'' before you do.
1159])
1160fi
1161
1162dnl!
1163dnl! If the $host is Linux then we add -rdynamic to LD_FLAGS in order
1164dnl! to make make backtrace return function names.
1165dnl!
1166case $host in
1167     i?86-*-gnu* | *amd64* | *86_64* )
1168        LDFLAGS="$LDFLAGS -rdynamic" ;;
1169esac
1170AC_SUBST(LDFLAGS)
1171
1172# program prefix is the bit to add to the start of the name
1173if test ${PROGRAM_PREFIX-NONE} != NONE -a ${program_prefix-NONE} != NONE; then
1174PROGRAM_PREFIX=${program_prefix}
1175fi
1176AC_SUBST(PROGRAM_PREFIX)
1177
1178# program suffix is the bit to add to the end of the name (before .exe)
1179if test ${PROGRAM_SUFFIX-NONE} != NONE -a ${program_suffix-NONE} != NONE; then
1180PROGRAM_SUFFIX=${program_suffix}
1181fi
1182AC_SUBST(PROGRAM_SUFFIX)
1183
1184AH_TOP(
1185[/*
1186 *      aegis - project change supervisor
1187 *      Copyright (C) 1991-2008, 2010, 2012 Peter Miller
1188 *
1189 *      This program is free software; you can redistribute it and/or modify
1190 *      it under the terms of the GNU General Public License as published by
1191 *      the Free Software Foundation; either version 3 of the License, or
1192 *      (at your option) any later version.
1193 *
1194 *      This program is distributed in the hope that it will be useful,
1195 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
1196 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1197 *      GNU General Public License for more details.
1198 *
1199 *      You should have received a copy of the GNU General Public License
1200 *      along with this program. If not, see
1201 *      <http://www.gnu.org/licenses/>.
1202 */
1203
1204#ifndef COMMON_CONFIG_H
1205#define COMMON_CONFIG_H
1206])
1207
1208AH_BOTTOM(
1209[/*
1210 * This defines the file creation mask.  See umask(2) for more information.
1211 * Some bits are not available, because aegis is _meant_ to be paranoid.
1212 * Owner: always has read, write and search/exec.
1213 * Group: always has read and search/exec, so that developers can get at the
1214 *      baseline.  There is never group write, because then developers
1215 *      could trash the baseline, which is counter-productive.
1216 * Others: There is never others write, for the same reason as group.
1217 *      Others read and search/execute is configurable.
1218 *
1219 * The permissions mask in binary looks like
1220 *      000 010 X1X
1221 * where the Xs may be configured.
1222 *
1223 * Alternatives for default umask are thus
1224 *      027     others get nothing
1225 *      026     others can execute the results if they know where they are going
1226 *      022     others can see and copy and execute anything
1227 *      023     don't do this (why is left as an exersize for the reader)
1228 *
1229 * Projects have a configurable umask, this is just the default.
1230 *      See aepattr(1) for more information.
1231 */
1232#define DEFAULT_UMASK 026
1233
1234/*
1235 * These symbols define where non-system user IDs start,
1236 * and where non-system group IDs start.
1237 * This is mostly to ensure that accounts "root" and "bin"
1238 * and "uucp" are not project owners.
1239 */
1240#define AEGIS_MIN_UID 100
1241#define AEGIS_MIN_GID 10
1242
1243/*
1244 * There is more to do, but we need to insulate it from config.status,
1245 * because it screws up the #undef lines.  They are all implications of
1246 * the above information, so there is no need for you to edit the file,
1247 * if you are configuring Aegis manually.
1248 */
1249#include <common/config.messy.h>
1250
1251#endif /* COMMON_CONFIG_H */])
1252
1253AC_OUTPUT(Makefile lib/cshrc lib/profile etc/libdir.so
1254        common/libdir.cc etc/compat.2.3)
1255
1256dnl! vim: set ts=8 sw=4 et :
1257