Home | History | Annotate | Line # | Download | only in librumpuser
      1 #
      2 # Rump kernel POSIX hypervisor autoconf support.
      3 #
      4 # NOTE!  regen by doing the following
      5 #   1) autoreconf -iv
      6 #   2) edit rumpuser_port.h (search for RUMPUSER_CONFIG for instructions)
      7 #   3) rm -rf autom4te.cache
      8 #   4) commit to NetBSD, pullup to https://github.com/rumpkernel/
      9 #
     10 
     11 AC_PREREQ([2.66])
     12 AC_INIT([rumpuser-posix], [999], [https://github.com/rumpkernel/])
     13 
     14 AC_CONFIG_HEADERS([rumpuser_config.h])
     15 AC_CONFIG_AUX_DIR([build-aux])
     16 AC_CONFIG_MACRO_DIR([build-aux])
     17 
     18 AC_LANG([C])
     19 
     20 AC_SYS_LARGEFILE
     21 
     22 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h sys/disk.h \
     23 	sys/disklabel.h sys/dkio.h sys/atomic.h paths.h])
     24 
     25 AC_CANONICAL_TARGET
     26 
     27 AC_CHECK_TYPES([clockid_t, register_t])
     28 
     29 AC_CHECK_FUNCS([kqueue chflags strsuftoll setprogname getprogname	\
     30 	getenv_r posix_memalign memalign aligned_alloc	\
     31 	arc4random_buf getsubopt fsync_range __quotactl utimensat	\
     32 	preadv pwritev])
     33 
     34 AC_TRY_LINK_FUNC([clock_nanosleep],,
     35         AC_CHECK_LIB([rt], [clock_nanosleep])
     36 )
     37 AC_CHECK_LIB([rt], [clock_gettime],
     38 	AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [clock_gettime]),
     39 	AC_TRY_LINK_FUNC([clock_gettime],
     40 	    AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [clock_gettime])))
     41 AC_CHECK_LIB([rt], [clock_nanosleep],
     42 	AC_DEFINE([HAVE_CLOCK_NANOSLEEP], 1, [clock_nanosleep]),
     43 	AC_TRY_LINK_FUNC([clock_nanosleep],
     44 	    AC_DEFINE([HAVE_CLOCK_NANOSLEEP], 1, [clock_nanosleep])))
     45 AC_CHECK_LIB([dl], [dlinfo],
     46 	AC_DEFINE([HAVE_DLINFO], 1, [dlinfo]),
     47 	AC_TRY_LINK_FUNC([dlinfo], AC_DEFINE([HAVE_DLINFO], 1, [dlinfo])))
     48 
     49 AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,,[#include <netinet/in.h>])
     50 
     51 dnl
     52 dnl pthread_setname() sillyness is a bit longer; we need the signature
     53 dnl
     54 SAVE_CFLAGS="${CFLAGS}"
     55 CFLAGS="${SAVE_CFLAGS} -Werror"
     56 
     57 dnl check sys/cdefs.h creatively to process only with cc, not cpp
     58 dnl (sys/cdefs.h in at least in musl contains a #warning)
     59 AC_CHECK_HEADERS([sys/cdefs.h], [], [], [#include <sys/cdefs.h>])
     60 
     61 SAVE_LIBS="${LIBS}"
     62 LIBS="${LIBS} -lpthread"
     63 AC_MSG_CHECKING([for two-argument pthread_setname_np()])
     64 AC_COMPILE_IFELSE(
     65 	[AC_LANG_PROGRAM(
     66 		[[#define _GNU_SOURCE
     67 		  #include <pthread.h>]],
     68 		[[pthread_t pt;]
     69 		[pthread_setname_np(pt, "x");return 0;]])
     70 	],[
     71 		AC_MSG_RESULT([yes])
     72 		AC_DEFINE(HAVE_PTHREAD_SETNAME2, [1],
     73 		    [Define to 1 if you have 2-arg pthread_setname_np()])
     74 	],[
     75 		AC_MSG_RESULT([no])
     76 ])
     77 AC_MSG_CHECKING([for three-argument pthread_setname_np()])
     78 AC_COMPILE_IFELSE(
     79 	[AC_LANG_PROGRAM(
     80 		[[#define _GNU_SOURCE
     81 		  #include <pthread.h>]],
     82 		[[pthread_t pt;]
     83 		[pthread_setname_np(pt, "X", (void *)0);return 0;]])
     84 	],[
     85 		AC_MSG_RESULT([yes])
     86 		AC_DEFINE(HAVE_PTHREAD_SETNAME3, [1],
     87 		    [Define to 1 if you have 3-arg pthread_setname_np()])
     88 	],[
     89 		AC_MSG_RESULT([no])
     90 ])
     91 LIBS="${SAVELIBS}"
     92 
     93 AC_MSG_CHECKING([for ioctl cmd being int])
     94 AC_COMPILE_IFELSE(
     95 	[AC_LANG_PROGRAM(
     96 		[[#include <sys/ioctl.h>
     97 		  #include <unistd.h>
     98 		  int ioctl(int fd, int, ...);]],
     99 		[[]
    100 		[return 0;]])
    101 	],[
    102 		AC_MSG_RESULT([yes])
    103 		AC_DEFINE(HAVE_IOCTL_CMD_INT, [1],
    104 		    [Define to 1 if ioctl()'s cmd arg is int])
    105 	],[
    106 		AC_MSG_RESULT([no])
    107 ])
    108 CFLAGS="${SAVE_CFLAGS}"
    109 
    110 AC_OUTPUT
    111