xref: /netbsd-src/lib/librumpuser/configure.ac (revision b5c2429f34feb91ed733f03fa2eab8620587f9f2)
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
11AC_PREREQ([2.66])
12AC_INIT([rumpuser-posix], [999], [https://github.com/rumpkernel/])
13
14AC_CONFIG_HEADERS([rumpuser_config.h])
15AC_CONFIG_AUX_DIR([build-aux])
16AC_CONFIG_MACRO_DIR([build-aux])
17
18AC_LANG([C])
19
20AC_SYS_LARGEFILE
21
22AC_CHECK_HEADERS([sys/param.h sys/sysctl.h sys/disk.h \
23	sys/disklabel.h sys/dkio.h sys/atomic.h paths.h])
24
25AC_CANONICAL_TARGET
26
27AC_CHECK_TYPES([clockid_t, register_t])
28
29AC_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
34AC_TRY_LINK_FUNC([clock_nanosleep],,
35        AC_CHECK_LIB([rt], [clock_nanosleep])
36)
37AC_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])))
41AC_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])))
45AC_CHECK_LIB([dl], [dlinfo],
46	AC_DEFINE([HAVE_DLINFO], 1, [dlinfo]),
47	AC_TRY_LINK_FUNC([dlinfo], AC_DEFINE([HAVE_DLINFO], 1, [dlinfo])))
48
49AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,,[#include <netinet/in.h>])
50
51dnl
52dnl pthread_setname() sillyness is a bit longer; we need the signature
53dnl
54SAVE_CFLAGS="${CFLAGS}"
55CFLAGS="${SAVE_CFLAGS} -Werror"
56
57dnl check sys/cdefs.h creatively to process only with cc, not cpp
58dnl (sys/cdefs.h in at least in musl contains a #warning)
59AC_CHECK_HEADERS([sys/cdefs.h], [], [], [#include <sys/cdefs.h>])
60
61SAVE_LIBS="${LIBS}"
62LIBS="${LIBS} -lpthread"
63AC_MSG_CHECKING([for two-argument pthread_setname_np()])
64AC_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])
77AC_MSG_CHECKING([for three-argument pthread_setname_np()])
78AC_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])
91LIBS="${SAVELIBS}"
92
93AC_MSG_CHECKING([for ioctl cmd being int])
94AC_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])
108CFLAGS="${SAVE_CFLAGS}"
109
110AC_OUTPUT
111