Home | History | Annotate | Line # | Download | only in compat
configure.ac revision 1.93
      1  1.93  christos #	$NetBSD: configure.ac,v 1.93 2018/08/16 12:03:36 christos Exp $
      2   1.1        tv #
      3   1.1        tv # Autoconf definition file for libnbcompat.
      4   1.1        tv #
      5  1.62       apb # When you edit configure.ac:
      6  1.62       apb # 0. Create the tools versions of autoconf and autoheader:
      7  1.62       apb #        cd ${SRCDIR} && build.sh -V MKMAINTAINERTOOLS=yes tools
      8  1.62       apb #    (This might not work if you try it after editing configure.ac.)
      9  1.62       apb # 1. edit configure.ac
     10  1.62       apb # 2. Regenerate "configure" and "nbtool_config.h.in" from "configure.ac":
     11  1.62       apb #        cd ${SRCDIR}/tools/compat && ${TOOLDIR}/bin/nbmake-${MACHINE} regen
     12  1.62       apb #    (Please don't use a non-tools version of autoconf or autoheader.)
     13  1.62       apb # 3. Test that the tools still build:
     14  1.62       apb #        mv ${TOOLDIR} ${TOOLDIR}.bak
     15  1.62       apb #        cd ${SRCDIR} && build.sh -V MKMAINTAINERTOOLS=yes tools
     16  1.62       apb # 4. cvs commit files that you edited.
     17  1.64       apb # 5. Regen again, to pick up changed RCS IDs from the above commit:
     18  1.64       apb #        cd ${SRCDIR}/tools/compat && ${TOOLDIR}/bin/nbmake-${MACHINE} regen
     19  1.64       apb # 6. cvs commit files that were generated.
     20  1.62       apb #
     21   1.1        tv 
     22  1.40      salo AC_INIT([libnbcompat], [noversion], [lib-bug-people (a] NetBSD.org])
     23  1.56       wiz AC_CONFIG_HEADERS(nbtool_config.h)
     24   1.1        tv AC_CONFIG_FILES(defs.mk)
     25  1.20     bjh21 
     26  1.56       wiz # Autoheader header and footer
     27  1.72       apb AH_TOP([/*      $][NetBSD$    */
     28  1.56       wiz  
     29  1.56       wiz #ifndef __NETBSD_NBTOOL_CONFIG_H__
     30  1.56       wiz #define __NETBSD_NBTOOL_CONFIG_H__])
     31  1.56       wiz 
     32  1.56       wiz AH_BOTTOM([#include "compat_defs.h"
     33  1.56       wiz #endif /* !__NETBSD_NBTOOL_CONFIG_H__ */])
     34  1.56       wiz 
     35  1.44       jmc AC_DEFUN([AC_NETBSD],
     36  1.44       jmc [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
     37  1.44       jmc       AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
     38  1.44       jmc       AC_MSG_CHECKING([for NetBSD])
     39  1.44       jmc       AC_EGREP_CPP(yes,
     40  1.44       jmc       [#ifdef __NetBSD__
     41  1.44       jmc 	yes
     42  1.44       jmc 	#endif
     43  1.44       jmc 	],
     44  1.44       jmc 	[AC_MSG_RESULT([yes])
     45  1.53       wiz 	 AC_DEFINE([_POSIX_SOURCE], 1, [Define for NetBSD headers.])
     46  1.53       wiz 	 AC_DEFINE([_POSIX_C_SOURCE], 200112L, [Define for NetBSD headers.])
     47  1.53       wiz 	 AC_DEFINE([_XOPEN_SOURCE], 600, [Define for NetBSD headers.])],
     48  1.44       jmc 	[AC_MSG_RESULT([no])])
     49  1.44       jmc ])# AC_NETBSD
     50  1.44       jmc 
     51  1.44       jmc AC_NETBSD
     52  1.20     bjh21 AC_PATH_PROG(BSHELL, sh, )
     53  1.20     bjh21 if test x"$BSHELL" = x; then
     54  1.20     bjh21 	AC_MSG_ERROR([sh must be somewhere on \$PATH])
     55  1.20     bjh21 fi
     56  1.53       wiz AC_DEFINE_UNQUOTED([PATH_BSHELL], "$BSHELL", [Path to sh(1).])
     57   1.1        tv 
     58   1.4        tv AC_C_BIGENDIAN
     59   1.6        tv AC_HEADER_STDC
     60   1.6        tv 
     61   1.6        tv # Confirm existence of zlib.  (This is available as a default install
     62   1.6        tv # option on many OS's; this could be added as a reachover build in the
     63   1.6        tv # future.)
     64   1.6        tv AC_CHECK_HEADER(zlib.h,,
     65   1.6        tv 	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
     66   1.6        tv AC_CHECK_LIB(z, gzdopen,,
     67   1.6        tv 	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
     68   1.4        tv 
     69   1.4        tv # Make sure certain required headers are available.
     70   1.4        tv # These are not necessarily required by the code, but they are not
     71   1.4        tv # currently conditionalized.
     72  1.69       dbj AC_CHECK_HEADERS(sys/ioctl.h sys/mman.h sys/param.h \
     73  1.34   thorpej 	sys/socket.h sys/stat.h sys/time.h sys/types.h sys/utsname.h \
     74  1.34   thorpej 	sys/wait.h assert.h ctype.h errno.h fcntl.h grp.h limits.h locale.h \
     75  1.28    briggs 	netdb.h pwd.h signal.h stdarg.h stdio.h stdlib.h string.h \
     76  1.22   thorpej 	termios.h unistd.h,,
     77   1.4        tv 	AC_MSG_ERROR([standard system header file not found]))
     78   1.4        tv 
     79   1.4        tv # Find headers that may not be available.
     80   1.6        tv AC_HEADER_DIRENT
     81  1.88  christos AC_CHECK_HEADERS(sys/mtio.h sys/sysmacros.h sys/syslimits.h stdio_ext.h \
     82  1.75  christos 	getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h rpc/types.h)
     83  1.72       apb AC_CHECK_HEADERS(sys/bswap.h machine/bswap.h sys/cdefs.h machine/endian.h \
     84  1.72       apb 	sys/endian.h sys/featuretest.h err.h inttypes.h libgen.h paths.h \
     85  1.86  christos 	libgen.h stdint.h util.h resolv.h arpa/nameser.h,,
     86  1.11        tv 	[test -f include/$ac_header || touch include/$ac_header])
     87  1.44       jmc AC_CHECK_HEADERS(rpc/types.h netconfig.h,,
     88  1.41     lukem 	[echo '#include "nbtool_config.h"' >include/$ac_header.new
     89  1.72       apb 	echo '#include "'$srcdir/../../include/$ac_header'"' \
     90  1.72       apb 		>>include/$ac_header.new
     91  1.11        tv 	if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
     92  1.11        tv 		rm -f include/$ac_header.new
     93  1.11        tv 	else
     94  1.11        tv 		mv -f include/$ac_header.new include/$ac_header
     95  1.11        tv 	fi])
     96   1.4        tv 
     97   1.4        tv # Typedefs.
     98   1.1        tv AC_TYPE_SIZE_T
     99  1.44       jmc AC_CHECK_TYPES([id_t, long long, u_long, u_char, u_short, u_int, u_quad_t])
    100  1.53       wiz AC_CHECK_TYPE(socklen_t, [AC_DEFINE([HAVE_SOCKLEN_T], 1,
    101  1.53       wiz 			  [Define if you have the socklen_t type.])],,
    102  1.35   thorpej [#include <sys/types.h>
    103  1.77     pooka #ifdef HAVE_RPC_TYPES_H
    104  1.75  christos #include <rpc/types.h>
    105  1.77     pooka #endif
    106  1.35   thorpej #include <sys/socket.h>])
    107   1.6        tv 
    108   1.9        tv dnl XXX - This is UGLY.  Need a better way to homogenize the bitsized types,
    109   1.9        tv dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
    110   1.9        tv dnl
    111   1.6        tv define([NB_CHECK_INTTYPE], [
    112   1.9        tv 	AC_CHECK_TYPE(uint][$1][_t,, [
    113   1.9        tv 		AC_CHECK_TYPE(u_int][$1][_t,
    114  1.53       wiz 			AC_DEFINE(uint][$1][_t, u_int][$1][_t, \
    115  1.53       wiz 			          [Define if you have u_int][$1][_t, but not uint][$1][_t.]),
    116   1.9        tv 			AC_MSG_ERROR([cannot find a suitable type for uint][$1][_t]))
    117   1.9        tv 	])
    118   1.6        tv 	AC_CHECK_TYPE(u_int][$1][_t,, [
    119   1.6        tv 		AC_CHECK_TYPE(uint][$1][_t,
    120  1.53       wiz 			AC_DEFINE(u_int][$1][_t, uint][$1][_t, \
    121  1.53       wiz 				  [Define if you have uint][$1][_t, but not u_int][$1][_t.]),
    122   1.6        tv 			AC_MSG_ERROR([cannot find a suitable type for u_int][$1][_t]))
    123   1.6        tv 	])
    124   1.6        tv ])
    125   1.6        tv 
    126   1.6        tv NB_CHECK_INTTYPE(8)
    127   1.6        tv NB_CHECK_INTTYPE(16)
    128   1.6        tv NB_CHECK_INTTYPE(32)
    129   1.6        tv NB_CHECK_INTTYPE(64)
    130   1.4        tv 
    131   1.4        tv # Struct members.
    132  1.58   thorpej AC_CHECK_MEMBERS([DIR.dd_fd, DIR.__dd_fd, struct dirent.d_namlen],,,
    133  1.32   thorpej [#include <sys/types.h>
    134  1.32   thorpej #include <dirent.h>])
    135   1.7        tv AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen,
    136  1.49       jmc 	struct stat.st_birthtime, struct stat.st_birthtimensec,
    137  1.49       jmc 	struct stat.st_atim, struct stat.st_mtimensec],,, 
    138  1.49       jmc 	[#include <sys/stat.h>])
    139  1.46       dbj AC_CHECK_MEMBERS(struct statvfs.f_iosize,,, [#include <sys/statvfs.h>])
    140  1.80  jmcneill AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, [#include <time.h>])
    141   1.4        tv 
    142   1.4        tv # Global variable decls.
    143  1.89     sevan AC_CHECK_DECLS([asprintf, asnprintf, vasprintf, vasnprintf, vsnprintf, fgetln, fparseln,
    144  1.88  christos 	fpurge, getdelim, getline, snprintf],,, [
    145  1.86  christos #include <stdio.h>
    146  1.86  christos ])
    147  1.86  christos 
    148  1.86  christos AC_CHECK_DECLS([atoll, heapsort, mkdtemp, mkstemp, reallocarr,
    149  1.86  christos 	setenv, strtoi, strtoll, strtou, setprogname, getprogname],,, [
    150  1.86  christos #include <stdlib.h>
    151  1.86  christos ])
    152  1.86  christos 
    153  1.86  christos AC_CHECK_DECLS([basename, dirname],,, [
    154  1.86  christos #include <libgen.h>
    155  1.86  christos ])
    156  1.86  christos 
    157  1.86  christos AC_CHECK_DECLS([raise_default_signal],,, [
    158  1.86  christos #include <util.h>
    159  1.86  christos ])
    160  1.86  christos 
    161  1.87  christos AC_CHECK_DECLS([issetugid, pread, pwrite],,, [
    162  1.86  christos #include <unistd.h>
    163  1.86  christos ])
    164  1.86  christos 
    165  1.87  christos AC_CHECK_DECLS([strmode],,, [
    166  1.87  christos #include <unistd.h>
    167  1.87  christos #include <string.h>
    168  1.87  christos ])
    169  1.87  christos 
    170  1.86  christos AC_CHECK_DECLS([isblank],,, [
    171  1.86  christos #include <ctype.h>
    172  1.86  christos ])
    173  1.86  christos 
    174  1.86  christos 
    175   1.7        tv AC_CHECK_DECLS([optind, optreset],,, [
    176   1.7        tv #include <stdio.h>
    177   1.7        tv #include <stdlib.h>
    178   1.7        tv #include <unistd.h>
    179  1.77     pooka #ifdef HAVE_GETOPT_H
    180  1.77     pooka #include <getopt.h>
    181  1.77     pooka #endif
    182   1.7        tv ])
    183   1.4        tv AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
    184   1.4        tv 
    185   1.4        tv # Library functions (where a .h check isn't enough).
    186  1.19     bjh21 AC_FUNC_ALLOCA
    187  1.39    atatat AC_CHECK_FUNCS(atoll asprintf asnprintf basename devname dirfd dirname \
    188  1.76  christos 	dprintf esetfunc fgetln flock fpurge __fpurge futimes getline \
    189  1.74     joerg 	getopt getopt_long group_from_gid gid_from_group \
    190  1.48       jmc 	heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \
    191  1.72       apb 	mkdtemp poll pread putc_unlocked pwcache_userdb pwcache_groupdb \
    192  1.84     kamil 	pwrite raise_default_signal random reallocarr setenv \
    193  1.78       apb 	setgroupent setprogname setpassent \
    194  1.78       apb 	snprintb_m snprintf strlcat strlcpy strmode \
    195  1.93  christos 	strcasecmp strncasecmp strndup strnlen strsep strsuftoll strtoi \
    196  1.93  christos 	strtoll strtou \
    197  1.66  christos 	user_from_uid uid_from_user vasprintf vasnprintf vsnprintf)
    198   1.8        tv 
    199  1.66  christos AC_CHECK_DECLS([user_from_uid, uid_from_user, pwcache_userdb],,,[
    200  1.66  christos #include <pwd.h>
    201  1.66  christos ])
    202  1.66  christos AC_CHECK_DECLS([group_from_gid, gid_from_group, pwcache_groupdb],,,[
    203  1.66  christos #include <grp.h>
    204  1.66  christos ])
    205  1.93  christos AC_CHECK_DECLS([strcasecmp, strncasecmp, strlcpy, strlcat, strndup,
    206  1.93  christos 		strnlen, strsep],,,[
    207  1.85  christos #include <string.h>
    208  1.85  christos ])
    209  1.85  christos AC_CHECK_DECLS([strsuftoll, mi_vector_hash],,,[#include <stdlib.h>])
    210  1.66  christos AC_CHECK_DECLS([lchflags, lchmod, lchown],,,[
    211  1.66  christos #include <sys/stat.h>
    212  1.66  christos #include <unistd.h>
    213  1.66  christos ])
    214  1.54       wiz 
    215  1.93  christos AC_CHECK_DECLS([err, errc, errx, verrc, verrx, warn, warnc, warnx, vwarnc,
    216  1.93  christos 		vwarnx],,,[
    217  1.82  christos #ifdef HAVE_ERR_H
    218  1.82  christos #include <err.h>
    219  1.82  christos #endif
    220  1.82  christos ])
    221  1.82  christos 
    222  1.72       apb AC_CHECK_DECLS([htobe16, htobe32, htobe64, htole16, htole32, htole64,
    223  1.72       apb 		be16toh, be32toh, be64toh, le16toh, le32toh, le64toh],,,
    224  1.72       apb 		[#include <sys/types.h>])
    225  1.44       jmc 
    226  1.54       wiz AC_CHECK_DECLS([bswap16, bswap32, bswap64],,, [#include <machine/bswap.h>])
    227  1.44       jmc 
    228  1.72       apb AC_CHECK_DECLS([be16enc, le16enc, be16dec, le16dec, be32enc, le32enc,
    229  1.72       apb 		be32dec, le32dec, be64enc, le64enc, be64dec, le64dec],,,
    230  1.72       apb 		[#include <sys/endian.h>])
    231  1.63       apb 
    232  1.54       wiz AC_CHECK_DECLS([fstatvfs],,, [#include <sys/statvfs.h>])
    233  1.47       jmc 
    234   1.8        tv AC_CHECK_DECLS([setgroupent, setpassent],,, [
    235  1.33   thorpej #include <sys/types.h>
    236   1.8        tv #include <grp.h>
    237   1.8        tv #include <pwd.h>
    238   1.8        tv ])
    239   1.1        tv 
    240   1.4        tv # regcomp() and regexec() are also names of functions in the old V8
    241   1.4        tv # regexp package.  To avoid them, we need to find out who has regfree().
    242   1.1        tv 
    243   1.4        tv dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
    244   1.4        tv dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
    245   1.4        tv AC_CHECK_LIB(regex, regfree)
    246   1.4        tv AC_SEARCH_LIBS(regfree, rx posix)
    247   1.1        tv 
    248  1.79  jmcneill AC_CHECK_LIB(rt, clock_gettime)
    249  1.79  jmcneill 
    250  1.68   tnozaki AC_CHECK_FUNCS(fparseln, [
    251  1.68   tnozaki     AC_MSG_CHECKING(if fparseln seems to work)
    252  1.68   tnozaki     AC_RUN_IFELSE(
    253  1.68   tnozaki         [AC_LANG_SOURCE([[
    254  1.68   tnozaki #define _NETBSD_SOURCE
    255  1.68   tnozaki #include <stdio.h>
    256  1.68   tnozaki #include <stdlib.h>
    257  1.68   tnozaki #define CONFTEST	"conftest.fparseln"
    258  1.68   tnozaki #define COMMENT		'#'
    259  1.68   tnozaki int
    260  1.68   tnozaki main(void)
    261  1.68   tnozaki {
    262  1.68   tnozaki 	static const char delim[3] = { '\0', '\0', COMMENT };
    263  1.68   tnozaki 	FILE *fp;
    264  1.68   tnozaki 	char *ptr;
    265  1.68   tnozaki 	fp = fopen(CONFTEST, "w+");
    266  1.68   tnozaki 	if (fp != NULL) {
    267  1.68   tnozaki 		unlink(CONFTEST);
    268  1.68   tnozaki 		ungetc(COMMENT, fp);
    269  1.68   tnozaki 		ptr = fparseln(fp, NULL, NULL, delim,
    270  1.68   tnozaki 		    FPARSELN_UNESCALL);
    271  1.68   tnozaki 		fclose(fp);
    272  1.68   tnozaki 		if (ptr == NULL)
    273  1.68   tnozaki 			exit(0);
    274  1.68   tnozaki 	}
    275  1.68   tnozaki 	exit(1);
    276  1.68   tnozaki }
    277  1.68   tnozaki         ]])],
    278  1.68   tnozaki         [AC_MSG_RESULT(yes)],
    279  1.68   tnozaki         [AC_MSG_RESULT(no)
    280  1.68   tnozaki          AC_DEFINE(BROKEN_FPARSELN, 1,
    281  1.68   tnozaki             [Define to 1 if your `fparseln' function is broken.])],
    282  1.68   tnozaki         [AC_MSG_WARN([cross compiling: not checking farseln])]
    283  1.68   tnozaki     )
    284  1.68   tnozaki ])
    285  1.68   tnozaki 
    286  1.73       apb # Variables substituted via @VARNAME@ in defs.mk.in
    287  1.73       apb AC_SUBST(HAVE_PTHREAD_H, $ac_cv_header_pthread_h)
    288  1.73       apb 
    289   1.1        tv AC_OUTPUT
    290