dnl dnl If you're using this on IRIX, you'll need to get autoconf, automake, dnl libtool, GNU tar, GNU make, and maybe some other stuff, which should dnl be available on your freeware CD or from http://freeware.sgi.com/. dnl dnl At the moment, this file suffers from a number of aesthetic shortcomings. dnl dnl To change compiler flags etc., you should set the CXXFLAGS environment dnl variable before running the configure script. dnl dnl Process this file with autoconf to produce a configure script. dnl The order you want to use is: dnl aclocal (only need to do this once?) dnl autoconf dnl autoheader dnl automake -v --add-missing (you only need the --add-missing once, or dnl configure every time you switch between IRIX & Linux dnl make in the same workarea) dnl dnl THINGS WHICH ARE STILL BROKEN dnl dnl packaging. dnl makedepends. The generated Makefiles don't include the Makedepends dnl files, so I removed the makedepends flags. We should figure out how dnl to fix that & put them back. (g++ I think wants to put each file's dnl dependencies in a separate file.d instead of a single directory-wide dnl Makedepend file, too.) dnl dnl Uncomment to keep from using the cache file. (It was causing problems dnl with GCC and GXX being set to "yes" even when the compilers aren't GNU.) dnl define([AC_CACHE_LOAD], )dnl dnl define([AC_CACHE_SAVE], )dnl AC_INIT(libfam/fam.c++) AM_INIT_AUTOMAKE(fam, 2.6.10) dnl Put configuration #defines in config.h. AM_CONFIG_HEADER(config.h) dnl Initialize libtool dnl AC_PATH_PROG(LIBTOOL, libtool) AM_PROG_LIBTOOL dnl dnl We want to include our header in $(top_srcdir)/include dnl FAMPROTOINC='-I$(top_srcdir)/include' AC_SUBST(FAMPROTOINC) dnl dnl We want everyone to agree on our config file's path & name dnl FAM_CONF=$sysconfdir/fam.conf AC_SUBST(FAM_CONF) dnl I hate autoconf so much. dnl AC_DEFINE_UNQUOTED(FAM_CONF, "${FAM_CONF}") dnl AC_DEFINE_UNQUOTED(FAM_CONF, "`echo ${FAM_CONF} | xargs`") dnl AC_DEFINE_UNQUOTED(FAM_CONF, "`echo ${FAM_CONF} | sed s/\$\{prefix\}/${prefix:-NONE}/ | sed s/^NONE//`") dnl Make our AC_TRY_COMPILE's use C++ instead of C. (It doesn't matter dnl for most of them, though.) AC_LANG_CPLUSPLUS dnl This is sort of a perversion of the AC_ARGS_WITH macro, but I want dnl people to be able to set their CFLAGS on the command line. AC_ARG_WITH(CFLAGS, [ --with-CFLAGS=\"flags\" set CFLAGS and CXXFLAGS to the given value], [CFLAGS=$withval; CXXFLAGS=$withval]) dnl dnl Checks for programs. dnl dnl Nuts! On IRIX, we want to use the SGI compilers, not GNU. dnl not necessarily. rusty == bozo. if test `uname` = 'IRIX' || test `uname` = 'IRIX64'; then AC_PATH_PROG(CXX, CC) fi AC_PROG_CXX AC_PROG_CXXCPP AC_PROG_RANLIB AC_PROG_INSTALL dnl I don't know why, but automake wants to use ./mkinstalldirs. dnl AC_PATH_PROG(MKINSTALLDIRS, mkinstalldirs) AC_PROG_MAKE_SET dnl AC_PROG_AWK dnl autoconf/automake expects GNU tar, so find it on IRIX. AC_PATH_PROG(TAR, tar, tar, /usr/freeware/bin:$PATH) AC_PATH_PROG(LDCONFIG, ldconfig) dnl dnl Checks for header files. dnl dnl AC_HEADER_STDC dnl AC_HEADER_DIRENT dnl AC_HEADER_SYS_WAIT dnl AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h syslog.h unistd.h) dnl dnl See if imon is available; if so, is it IRIX or Linux? dnl if test `uname` = 'IRIX' || test `uname` = 'IRIX64'; then have_imon=yes AC_DEFINE(HAVE_IMON, 1) IMON_FUNCS=IMonIrix dnl dnl As long as we're here, check for struct revokdi and IMONIOC_REVOKDI. dnl Old IRIX boxes don't have them. dnl AC_EGREP_HEADER(revokdi, sys/imon.h, AC_DEFINE(HAVE_IMON_REVOKDI)) fi if test "$have_imon" != "yes"; then AC_CHECK_HEADER(linux/imon.h, have_imon=yes) if test "$have_imon" = "yes"; then AC_DEFINE(HAVE_IMON, 1) IMON_FUNCS=IMonLinux fi fi if test "$have_imon" != "yes"; then have_imon=no AC_DEFINE(HAVE_IMON, 0) IMON_FUNCS=IMonNone fi AC_SUBST(IMON_FUNCS) echo "Using imon support module $IMON_FUNCS" AC_CHECK_HEADER(sys/statvfs.h, [AC_DEFINE(HAVE_STATVFS, 1) have_statvfs="yes"], [AC_DEFINE(HAVE_STATVFS, 0) have_statvfs="no"]) AC_CHECK_HEADER(sys/syssgi.h, AC_DEFINE(HAVE_SYSSGI, 1), AC_DEFINE(HAVE_SYSSGI, 0)) AC_CHECK_HEADER(sys/fs/nfs_clnt.h, AC_DEFINE(HAVE_SYS_FS_NFS_CLNT_H, 1), AC_DEFINE(HAVE_SYS_FS_NFS_CLNT_H, 0)) dnl Linux has statvfs, but its f_fsid is a struct, and SmallTable can't dnl be instantiated for it because there's no > or < operator for it yet. dnl fam does work without the fs_by_id table, so we'll pretend we don't dnl have statvfs for now. This should be fixed, though. if test `uname` != 'IRIX' && test `uname` != 'IRIX64'; then AC_DEFINE(HAVE_STATVFS, 0) have_statvfs="no" fi dnl dnl dnl dnl If we have statvfs, test for fsid_t. dnl dnl dnl if test "$have_statvfs" = "yes"; then dnl for fsid_t in ulong_t fsid_t __fsid_t; do dnl AC_MSG_CHECKING([sys/statvfs.h for $fsid_t fsid]) dnl AC_TRY_COMPILE([#include ], [struct statvfs s; $fsid_t i = s.f_fsid;], have_fsid_t=yes, have_fsid_t=no) dnl AC_MSG_RESULT($have_fsid_t) dnl if test "$have_fsid_t" = "yes"; then dnl AC_DEFINE_UNQUOTED(CONFIG_FSID_T, $fsid_t) dnl break dnl fi dnl done dnl if test "$have_fsid_t" != "yes"; then dnl AC_MSG_ERROR([Have sys/statvfs.h, but couldn't get statvfs.f_fsid type]) dnl fi dnl fi dnl dnl Test for SGI_NOHANG in syssgi.h dnl AC_MSG_CHECKING([SGI_NOHANG]) AC_TRY_COMPILE([#include ], [int i = SGI_NOHANG; ], have_sgi_nohang=yes, have_sgi_nohang=no) if test "$have_sgi_nohang" = "yes"; then AC_DEFINE(HAVE_SGI_NOHANG, 1) else AC_DEFINE(HAVE_SGI_NOHANG, 0) fi AC_MSG_RESULT($have_sgi_nohang) dnl dnl Test for a function to background the fam process dnl AC_CHECK_FUNCS([_daemonize daemon]) dnl dnl Test for a function to get a user's groups dnl AC_CHECK_FUNCS([getgrmember getgroups]) dnl dnl This section is commented out because HAVE_AUDIT and HAVE_MAC should dnl not be used. HAVE_AUDIT is probably OK (although it doesn't do anything dnl special) but HAVE_MAC is definitely not. (The test is fine, but the dnl code it #ifdef's in isn't.) dnl dnl dnl dnl dnl Test for sys/sat.h, satvwrite(), and _SC_AUDIT. dnl dnl dnl AC_MSG_CHECKING([satvwrite in sat.h]) dnl AC_TRY_COMPILE([#include dnl #include ], [sysconf(_SC_AUDIT); satvwrite(SAT_AE_CUSTOM, SAT_FAILURE, "%s", "Denied root root access to jesus"); ], have_audit=yes, have_audit=no) dnl AC_MSG_RESULT($have_audit) dnl if test "$have_audit" = "yes"; then dnl AC_DEFINE(HAVE_AUDIT) dnl fi dnl dnl dnl dnl dnl Test for sys/mac.h and t6net.h, mac_get_file() and tsix_get_mac(), dnl dnl and _SC_MAC and _SC_IP_SECOPTS. These are all squished together into dnl dnl a single test because even if the system has MAC labels, they're no use dnl dnl to us unless we have a way to get them from the client connection (which dnl dnl is what tsix_get_mac is for). dnl dnl dnl dnl On IRIX, install trix_eoe to get t6net.h. dnl dnl dnl AC_MSG_CHECKING([MAC and TSIX (tsix_get_mac and mac_get_file, mostly)]) dnl AC_TRY_COMPILE([#include dnl #include dnl #include dnl #include ], [sysconf(_SC_MAC); sysconf(_SC_IP_SECOPTS); mac_get_file("/"); tsix_get_mac(0, (mac_t *)0);], have_mac=yes, have_mac=no) dnl AC_MSG_RESULT($have_mac) dnl if test "$have_mac" = "yes"; then dnl AC_DEFINE(HAVE_MAC) dnl fi dnl dnl Checks for typedefs, structures, and compiler characteristics. dnl dnl (we don't need any of these for the simple tcpmux test... we will need to dnl fix many of these later, though, and comment them in.) dnl dnl Good candidates for this section would be support for bool and namespaces. dnl dnl AC_C_CONST dnl AC_TYPE_UID_T dnl AC_C_INLINE dnl AC_TYPE_MODE_T dnl AC_TYPE_OFF_T dnl AC_TYPE_PID_T dnl AC_TYPE_SIZE_T dnl AC_STRUCT_ST_RDEV dnl AC_HEADER_TIME dnl AC_STRUCT_TM dnl dnl Test for stat.st_fstype member (a char[] on IRIX) dnl AC_CACHE_CHECK([for stat.st_fstype string], fam_cv_stat_st_fstype_is_string, AC_TRY_COMPILE([#include ], [struct stat st; char *s = st.st_fstype; ], fam_cv_stat_st_fstype_is_string=yes, fam_cv_stat_st_fstype_is_string=no)) if test "$fam_cv_stat_st_fstype_is_string" = "yes"; then AC_DEFINE(HAVE_STAT_ST_FSTYPE_STRING, 1) else AC_DEFINE(HAVE_STAT_ST_FSTYPE_STRING, 0) fi dnl dnl Test for stat.st_ctim.tv_nsec member dnl AC_CACHE_CHECK([for stat.st_ctim.tv_nsec (nanoseconds)], fam_cv_stat_st_ctim_tv_nsec, AC_TRY_COMPILE([#include ], [struct stat st; st.st_ctim.tv_nsec = 0; ], fam_cv_stat_st_ctim_tv_nsec=yes, fam_cv_stat_st_ctim_tv_nsec=no)) if test "$fam_cv_stat_st_ctim_tv_nsec" = "yes"; then AC_DEFINE(HAVE_STAT_ST_CTIM_TV_NSEC, 1) fi dnl dnl Test for mountlist struct or pointer-to-struct. For now we will assume dnl that if mountlist is a pointer-to-struct, its relevant members are dnl ml_hostname and ml_directory; otherwise we will assume they're ml_host dnl and ml_path. dnl AC_MSG_CHECKING([for mountlist struct]) AC_TRY_COMPILE([ typedef int fhandle_t; #include #include ], [mountlist ml; char *h = ml.ml_name; ], have_mountlist_struct=yes, have_mountlist_struct=no) AC_MSG_RESULT($have_mountlist_struct) if test "$have_mountlist_struct" = "yes"; then AC_DEFINE(HAVE_MOUNTLIST_STRUCT, 1) AC_DEFINE(HAVE_MOUNTLIST_PTR, 0) else AC_DEFINE(HAVE_MOUNTLIST_STRUCT, 0) AC_MSG_CHECKING([for mountlist pointer]) AC_TRY_COMPILE([#include ], [mountlist ml; char *h = ml->ml_hostname; ], have_mountlist_ptr=yes, have_mountlist_ptr=no) AC_MSG_RESULT($have_mountlist_ptr) if test "$have_mountlist_ptr" = "yes"; then AC_DEFINE(HAVE_MOUNTLIST_PTR, 1) else AC_DEFINE(HAVE_MOUNTLIST_PTR, 0) AC_MSG_ERROR([Didn't find mountlist.ml_name or mountlist->ml_hostname in rpcsvc/mount.h]) fi fi dnl FAM_DECL_IN_MNTENT(mntent def to check, [action-if-true [,action-if-false]]) AC_DEFUN(FAM_DECL_IN_MNTENT, [ AC_MSG_CHECKING([mntent.h for $1]) AC_TRY_COMPILE([#include ], [const char *foo = $1;], fam_have_decl_in_mntent=yes, fam_have_decl_in_mntent=no) AC_MSG_RESULT($fam_have_decl_in_mntent) if test "$fam_have_decl_in_mntent" = "yes"; then ifelse([$2], , :, [$2]) else ifelse([$3], , :, [$3]) fi ]) dnl dnl Test for MNTTYPE_NFS, MNTTYPE_NFS2, MNTTYPE_NFS3, and MNTTYPE_CACHEFS. dnl If we don't have MNTTYPE_NFS , we croak. dnl dnl dnl Test for bindresvport() prototype. dnl AC_CACHE_CHECK([netinet/in.h for bindresvport()], fam_cv_bindresvport_in_in_h, AC_TRY_COMPILE([#include ], [int p = 0; struct sockaddr_in s; bindresvport(p, &s); ], fam_cv_bindresvport_in_in_h=yes, fam_cv_bindresvport_in_in_h=no)) if test "$fam_cv_bindresvport_in_in_h" = "yes"; then AC_DEFINE(HAVE_BINDRESVPORT_PROTO, 1) else AC_DEFINE(HAVE_BINDRESVPORT_PROTO, 0) fi dnl dnl Test for prmap_sgi_t dnl AC_CACHE_CHECK([for prmap_sgi_t], fam_cv_have_prmap_sgi_t, AC_TRY_COMPILE([#include ], [prmap_sgi_t f; f.pr_lockcnt = 0; ], fam_cv_have_prmap_sgi_t=yes, fam_cv_have_prmap_sgi_t=no)) if test "$fam_cv_have_prmap_sgi_t" = "yes"; then AC_DEFINE(HAVE_PRMAP_SGI_T, 1) else AC_DEFINE(HAVE_PRMAP_SGI_T, 0) fi dnl dnl Test for socklen_t dnl AC_CACHE_CHECK([for socklen_t], fam_cv_have_socklen_t, AC_TRY_COMPILE([#include #include ], [socklen_t len; struct sockaddr s; accept(0, &s, &len); ], fam_cv_have_socklen_t=yes, fam_cv_have_socklen_t=no)) if test "$fam_cv_have_socklen_t" = "yes"; then AC_DEFINE(CONFIG_SOCKLEN_T, socklen_t) else AC_DEFINE(CONFIG_SOCKLEN_T, int) fi dnl dnl Test for built-in C++ bool type dnl AC_CACHE_CHECK([for built-in bool], fam_cv_have_bool, AC_TRY_COMPILE(, [bool foo = true; if(foo) foo = false; ], fam_cv_have_bool=yes, fam_cv_have_bool=no)) if test "$fam_cv_have_bool" = "yes"; then AC_DEFINE(HAVE_BOOL, 1) else AC_DEFINE(HAVE_BOOL, 0) fi dnl dnl Test for C++ namespace support dnl AC_CACHE_CHECK([for C++ namespace support], fam_cv_have_namespace, AC_TRY_RUN([namespace foo { int bar(void) { return 0; } } int main(void) { return foo::bar(); } ], fam_cv_have_namespace=yes, fam_cv_have_namespace=no, fam_cv_have_namespace=no)) if test "$fam_cv_have_namespace" = "yes"; then AC_DEFINE(HAVE_NAMESPACE, 1) else AC_DEFINE(HAVE_NAMESPACE, 0) fi dnl dnl Test for IRIX xtab/Linux knfs xtab/no xtab support. dnl dnl AC_MSG_CHECKING([for IRIX xtab support]) if test `uname` = 'IRIX' || test `uname` = 'IRIX64'; then AC_DEFINE(HAVE_IRIX_XTAB_VERIFICATION, 1) fi dnl XXX This should test for knfs on Linux, too. dnl dnl dnl dnl This is lame. Here's a list of flags which are different (or where we dnl dnl want different behaviors) depending on whether we're using CC on IRIX dnl dnl or g++ on Linux. And if we're using g++ on IRIX... well, ignore that dnl dnl squeaking sound. dnl dnl dnl if test -n "$GXX"; then dnl dnl WOFF="-Wall -Wtemplate-debugging" dnl WOFF="-Wall" dnl OPTIMIZER="-g" dnl CSTYLE= dnl MKDEPFILE= dnl dnl MKDEPFILE='$(OBJECTS:.o=.d)' dnl MKDEPOPT="-MD" dnl CXXTEMPLATES= dnl dnl CXXTEMPLATES=-Wtemplate-debugging dnl else dnl dnl 1209 - remark - controlling expression (in assertion or loop?) is dnl dnl constant dnl dnl 1355 - remark - extra ";" ignored dnl WOFF="-fullwarn -woff 1209,1355" dnl OPTIMIZER="-g" dnl dnl XXX THE NEXT LINE IS LAME dnl CSTYLE="-mips3 -n32" dnl dnl The Makedepend stuff is pointless because it's not being included dnl dnl in the makefile. How to fix that? You can't just go dnl dnl "sinclude $MKDEPFILE" because the g++ stuff uses a bunch of .d files. dnl dnl (The compiler doesn't actually read the Makedepend file & determine dnl dnl which files it needs to update, right?) dnl MKDEPFILE=Makedepend dnl MKDEPOPT='-MDupdate $(MKDEPFILE)' dnl dnl MKDEPOPT= dnl dnl GCXXINCS='-nostdinc -I$(INCLDIR)/CC -I$(INCLDIR)' dnl CXXTEMPLATES="-ptused" dnl fi AC_SUBST(MKDEPFILE) dnl dnl We will stomp CXXFLAGS here. dnl CXXFLAGS="$WOFF $OPTIMIZER $CSTYLE $MKDEPOPT $CXXTEMPLATES" dnl echo "setting CXXFLAGS = $CXXFLAGS" dnl dnl See if "echo" needs -e flag. dnl AC_PATH_PROG(ECHO, echo) AC_MSG_CHECKING([for echo -e flag]) if test "`$ECHO -e foo`" = 'foo'; then ECHO="$ECHO -e" fi AC_SUBST(ECHO) AC_MSG_RESULT($ECHO) dnl dnl Checks for library functions. dnl dnl (we don't need any of these for the simple tcpmux test... we will need to dnl fix many of these later, though, and comment them in.) dnl dnl AC_PROG_GCC_TRADITIONAL dnl AC_HEADER_MAJOR dnl AC_FUNC_STRFTIME dnl AC_FUNC_UTIME_NULL dnl AC_FUNC_VPRINTF dnl AC_CHECK_FUNCS(getcwd gethostname gettimeofday getwd mkdir putenv rmdir select socket strdup strerror strspn strtol strtoul) SUPPORT_OBJS= dnl AC_CHECK_FUNCS(snprintf, have_snprintf=yes, have_snprintf=no) dnl if test "$have_snprintf" = "yes"; then dnl AC_DEFINE(HAVE_SNPRINTF) snprintf_o= dnl else dnl snprintf_o=snprintf.o dnl SUPPORT_OBJS="$SUPPORT_OBJS \$\(top_srcdir\)/support/snprintf.o" dnl fi AC_SUBST(snprintf_o) dnl dnl AC_CHECK_FUNCS(foo, have_foo=yes, have_foo=no) dnl if test "$have_foo" = "yes"; then dnl AC_DEFINE(HAVE_FOO) foo_o= dnl else dnl foo_o=foo.o dnl SUPPORT_OBJS="$SUPPORT_OBJS \$\(top_srcdir\)/support/foo.o" dnl fi AC_SUBST(foo_o) dnl dnl This adds #!gmake as the first line of each of these files. We need this dnl on IRIX to use gmake instead of smake/pmake/etc., which will croak on the dnl gmake Makefiles. dnl AC_OUTPUT_COMMANDS( [ if test `uname` = 'IRIX' || test `uname` = 'IRIX64'; then TMPFILE=configure.tmp for f in $CONFIG_FILES; do if test `basename $f` != 'Makefile'; then # echo "skipping $f" continue fi echo "adding #!gmake to $f" if test -s $TMPFILE; then echo "gahh, file $TMPFILE already exists" exit 1 fi mv $f $TMPFILE echo '#!gmake' > $f cat $TMPFILE >> $f rm $TMPFILE done fi ]) dnl dnl This removes lines starting with ## from fam.conf. dnl AC_OUTPUT_COMMANDS( [ TMPFILE=configure.tmp for f in $CONFIG_FILES; do if test `basename $f` != 'fam.conf'; then continue fi echo "removing maintainer comments from $f" if test -s $TMPFILE; then echo "gahh, file $TMPFILE already exists" exit 1 fi mv $f $TMPFILE sed -e "/^##/ d" < $TMPFILE > $f rm $TMPFILE done ]) dnl dnl This grief is for replacing XXX_FAM_CONF with $FAM_CONF dnl in the fam(1M) man page. (Simply putting @FAM_CONF@ in dnl fam.1m.in puts the string "$sysconfdir/fam.conf" in the dnl man page, which isn't acceptable. Isn't there a way to make dnl autoconf handle this??) dnl dnl While we're at it, we also remove lines starting with .\"##, dnl and fiddle with lines starting with .\"IRIX depending on dnl whether we're building on Linux or IRIX. dnl AC_OUTPUT_COMMANDS( [ TMPFILE=configure.tmp for f in $CONFIG_FILES; do if test `basename $f` != 'fam.1m'; then continue fi echo "replacing XXX_FAM_CONF with $FAM_CONF and removing maintainer comments in $f" if test -s $TMPFILE; then echo "gahh, file $TMPFILE already exists" exit 1 fi mv $f $TMPFILE if test `uname` = 'IRIX' || test `uname` = 'IRIX64'; then # remove leading .\"IRIX parts so that the lines will be # printed on IRIX. sed -e '/^\.\\"##/ d' -e "s#XXX_FAM_CONF#$FAM_CONF#" -e 's/^\.\\"IRIX[ ]\{0,2\}//' < $TMPFILE > $f else sed -e '/^\.\\"##/ d' -e "s#XXX_FAM_CONF#$FAM_CONF#" -e '/^\.\\"IRIX/ d' < $TMPFILE > $f fi rm $TMPFILE done ], [prefix=$prefix ; sysconfdir=$sysconfdir ; FAM_CONF=$FAM_CONF]) dnl dnl The list of files to generate. dnl AC_OUTPUT( Makefile build/Makefile build/rpm/Makefile build/rpm/rpm.spec fam/Makefile fam/fam.conf include/Makefile libfam/Makefile man/Makefile man/fam.1m support/Makefile test/Makefile ) dnl dnl fam is a good deal less interesting without imon. dnl if test "$have_imon" != 'yes'; then cat << EOF ****************************************************************** * * * Note! Kernel support for imon was not detected. fam should * * still work, but it will have to poll monitored filesystems * * instead of receiving file operation events from the kernel. * * * * If you think your kernel has imon, see what this script is * * looking for (on Linux, probably /usr/include/linux/imon.h), * * fix the problem (perhaps by adding a link), and run this * * again. (You probably need to remove config.cache first.) * * * * See http://oss.sgi.com/projects/fam/ for more information. * * * ****************************************************************** EOF fi