1 1.111 christos # $NetBSD: configure.ac,v 1.111 2025/09/18 20:24:48 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.100 lukem # 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.100 lukem # 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.103 lukem AC_CONFIG_HEADERS([nbtool_config.h]) 24 1.103 lukem AC_CONFIG_FILES([defs.mk]) 25 1.103 lukem AC_CONFIG_MACRO_DIR([buildaux]) 26 1.20 bjh21 27 1.103 lukem m4_pattern_forbid([^AX_]) 28 1.101 lukem m4_pattern_forbid([^NB_]) 29 1.101 lukem 30 1.56 wiz # Autoheader header and footer 31 1.72 apb AH_TOP([/* $][NetBSD$ */ 32 1.56 wiz 33 1.56 wiz #ifndef __NETBSD_NBTOOL_CONFIG_H__ 34 1.56 wiz #define __NETBSD_NBTOOL_CONFIG_H__]) 35 1.56 wiz 36 1.56 wiz AH_BOTTOM([#include "compat_defs.h" 37 1.56 wiz #endif /* !__NETBSD_NBTOOL_CONFIG_H__ */]) 38 1.56 wiz 39 1.101 lukem AC_DEFUN([NB_NETBSD], [dnl 40 1.101 lukem AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl 41 1.44 jmc AC_BEFORE([$0], [AC_RUN_IFELSE])dnl 42 1.44 jmc AC_MSG_CHECKING([for NetBSD]) 43 1.44 jmc AC_EGREP_CPP(yes, 44 1.44 jmc [#ifdef __NetBSD__ 45 1.44 jmc yes 46 1.44 jmc #endif 47 1.44 jmc ], 48 1.44 jmc [AC_MSG_RESULT([yes]) 49 1.53 wiz AC_DEFINE([_POSIX_SOURCE], 1, [Define for NetBSD headers.]) 50 1.53 wiz AC_DEFINE([_POSIX_C_SOURCE], 200112L, [Define for NetBSD headers.]) 51 1.53 wiz AC_DEFINE([_XOPEN_SOURCE], 600, [Define for NetBSD headers.])], 52 1.44 jmc [AC_MSG_RESULT([no])]) 53 1.101 lukem ])dnl NB_NETBSD 54 1.44 jmc 55 1.101 lukem NB_NETBSD() 56 1.20 bjh21 AC_PATH_PROG(BSHELL, sh, ) 57 1.20 bjh21 if test x"$BSHELL" = x; then 58 1.20 bjh21 AC_MSG_ERROR([sh must be somewhere on \$PATH]) 59 1.20 bjh21 fi 60 1.53 wiz AC_DEFINE_UNQUOTED([PATH_BSHELL], "$BSHELL", [Path to sh(1).]) 61 1.1 tv 62 1.101 lukem AC_C_BIGENDIAN() 63 1.101 lukem AC_HEADER_STDC() 64 1.6 tv 65 1.6 tv # Confirm existence of zlib. (This is available as a default install 66 1.6 tv # option on many OS's; this could be added as a reachover build in the 67 1.6 tv # future.) 68 1.6 tv AC_CHECK_HEADER(zlib.h,, 69 1.6 tv AC_MSG_ERROR([zlib must be installed in a compiler-visible path])) 70 1.6 tv AC_CHECK_LIB(z, gzdopen,, 71 1.6 tv AC_MSG_ERROR([zlib must be installed in a compiler-visible path])) 72 1.4 tv 73 1.4 tv # Make sure certain required headers are available. 74 1.4 tv # These are not necessarily required by the code, but they are not 75 1.4 tv # currently conditionalized. 76 1.69 dbj AC_CHECK_HEADERS(sys/ioctl.h sys/mman.h sys/param.h \ 77 1.34 thorpej sys/socket.h sys/stat.h sys/time.h sys/types.h sys/utsname.h \ 78 1.34 thorpej sys/wait.h assert.h ctype.h errno.h fcntl.h grp.h limits.h locale.h \ 79 1.28 briggs netdb.h pwd.h signal.h stdarg.h stdio.h stdlib.h string.h \ 80 1.22 thorpej termios.h unistd.h,, 81 1.4 tv AC_MSG_ERROR([standard system header file not found])) 82 1.4 tv 83 1.4 tv # Find headers that may not be available. 84 1.101 lukem AC_HEADER_DIRENT() 85 1.88 christos AC_CHECK_HEADERS(sys/mtio.h sys/sysmacros.h sys/syslimits.h stdio_ext.h \ 86 1.97 hannken getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h sys/uio.h) 87 1.72 apb AC_CHECK_HEADERS(sys/bswap.h machine/bswap.h sys/cdefs.h machine/endian.h \ 88 1.72 apb sys/endian.h sys/featuretest.h err.h inttypes.h libgen.h paths.h \ 89 1.86 christos libgen.h stdint.h util.h resolv.h arpa/nameser.h,, 90 1.11 tv [test -f include/$ac_header || touch include/$ac_header]) 91 1.97 hannken AC_CHECK_HEADERS(rpc/types.h,, 92 1.97 hannken [echo '#include "nbtool_config.h"' >include/$ac_header.new 93 1.97 hannken echo '#include "'$srcdir/../../common/include/$ac_header'"' \ 94 1.97 hannken >>include/$ac_header.new 95 1.97 hannken if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then 96 1.97 hannken rm -f include/$ac_header.new 97 1.97 hannken else 98 1.97 hannken mv -f include/$ac_header.new include/$ac_header 99 1.97 hannken fi]) 100 1.97 hannken AC_CHECK_HEADERS(netconfig.h,, 101 1.41 lukem [echo '#include "nbtool_config.h"' >include/$ac_header.new 102 1.72 apb echo '#include "'$srcdir/../../include/$ac_header'"' \ 103 1.72 apb >>include/$ac_header.new 104 1.11 tv if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then 105 1.11 tv rm -f include/$ac_header.new 106 1.11 tv else 107 1.11 tv mv -f include/$ac_header.new include/$ac_header 108 1.11 tv fi]) 109 1.4 tv 110 1.4 tv # Typedefs. 111 1.101 lukem AC_TYPE_SIZE_T() 112 1.44 jmc AC_CHECK_TYPES([id_t, long long, u_long, u_char, u_short, u_int, u_quad_t]) 113 1.96 kamil AC_CHECK_TYPES([uchar_t, ushort_t, uint_t, ulong_t]) 114 1.53 wiz AC_CHECK_TYPE(socklen_t, [AC_DEFINE([HAVE_SOCKLEN_T], 1, 115 1.53 wiz [Define if you have the socklen_t type.])],, 116 1.35 thorpej [#include <sys/types.h> 117 1.77 pooka #ifdef HAVE_RPC_TYPES_H 118 1.75 christos #include <rpc/types.h> 119 1.77 pooka #endif 120 1.35 thorpej #include <sys/socket.h>]) 121 1.6 tv 122 1.95 kamil AC_MSG_CHECKING([for enum uio_rw]) 123 1.95 kamil AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 124 1.95 kamil #include <sys/types.h> 125 1.95 kamil #ifdef HAVE_SYS_UIO_H 126 1.95 kamil #include <sys/uio.h> 127 1.95 kamil #endif]], 128 1.98 uwe [[enum uio_rw rw;]])], 129 1.98 uwe [AC_MSG_RESULT(yes) 130 1.98 uwe AC_DEFINE([HAVE_ENUM_UIO_RW], 1, 131 1.98 uwe [Define if you have the enum uio_rw type.])], 132 1.98 uwe [AC_MSG_RESULT(no)]) 133 1.95 kamil 134 1.95 kamil AC_MSG_CHECKING([for enum uio_seg]) 135 1.95 kamil AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 136 1.95 kamil #include <sys/types.h> 137 1.95 kamil #ifdef HAVE_SYS_UIO_H 138 1.95 kamil #include <sys/uio.h> 139 1.95 kamil #endif]], 140 1.98 uwe [[enum uio_seg seg;]])], 141 1.98 uwe [AC_MSG_RESULT(yes) 142 1.98 uwe AC_DEFINE([HAVE_ENUM_UIO_SEG], 1, 143 1.98 uwe [Define if you have the enum uio_seg type.])], 144 1.98 uwe [AC_MSG_RESULT(no)]) 145 1.95 kamil 146 1.9 tv dnl XXX - This is UGLY. Need a better way to homogenize the bitsized types, 147 1.9 tv dnl including use of compiler primitive types via AC_CHECK_SIZEOF. 148 1.9 tv dnl 149 1.101 lukem AC_DEFUN([NB_CHECK_INTTYPE], [dnl 150 1.9 tv AC_CHECK_TYPE(uint][$1][_t,, [ 151 1.9 tv AC_CHECK_TYPE(u_int][$1][_t, 152 1.53 wiz AC_DEFINE(uint][$1][_t, u_int][$1][_t, \ 153 1.53 wiz [Define if you have u_int][$1][_t, but not uint][$1][_t.]), 154 1.9 tv AC_MSG_ERROR([cannot find a suitable type for uint][$1][_t])) 155 1.9 tv ]) 156 1.6 tv AC_CHECK_TYPE(u_int][$1][_t,, [ 157 1.6 tv AC_CHECK_TYPE(uint][$1][_t, 158 1.53 wiz AC_DEFINE(u_int][$1][_t, uint][$1][_t, \ 159 1.53 wiz [Define if you have uint][$1][_t, but not u_int][$1][_t.]), 160 1.6 tv AC_MSG_ERROR([cannot find a suitable type for u_int][$1][_t])) 161 1.6 tv ]) 162 1.109 hans AC_CHECK_TYPE(__uint][$1][_t,, [ 163 1.109 hans AC_CHECK_TYPE(uint][$1][_t, 164 1.109 hans AC_DEFINE(__uint][$1][_t, uint][$1][_t, \ 165 1.109 hans [Define if you have uint][$1][_t, but not __uint][$1][_t.]), 166 1.109 hans AC_CHECK_TYPE(u_int][$1][_t, 167 1.109 hans AC_DEFINE(uint][$1][_t, u_int][$1][_t, \ 168 1.109 hans [Define if you have u_int][$1][_t, but not uint][$1][_t.]), 169 1.109 hans AC_MSG_ERROR([cannot find a suitable type for __uint][$1][_t]))) 170 1.109 hans ]) 171 1.109 hans AC_CHECK_TYPE(__int][$1][_t,, [ 172 1.109 hans AC_CHECK_TYPE(int][$1][_t, 173 1.109 hans AC_DEFINE(__int][$1][_t, int][$1][_t, \ 174 1.109 hans [Define if you have int][$1][_t, but not __int][$1][_t.]), 175 1.109 hans AC_MSG_ERROR([cannot find a suitable type for __int][$1][_t])) 176 1.109 hans ]) 177 1.101 lukem ])dnl NB_CHECK_INTTYPE 178 1.6 tv 179 1.6 tv NB_CHECK_INTTYPE(8) 180 1.6 tv NB_CHECK_INTTYPE(16) 181 1.6 tv NB_CHECK_INTTYPE(32) 182 1.6 tv NB_CHECK_INTTYPE(64) 183 1.4 tv 184 1.4 tv # Struct members. 185 1.58 thorpej AC_CHECK_MEMBERS([DIR.dd_fd, DIR.__dd_fd, struct dirent.d_namlen],,, 186 1.32 thorpej [#include <sys/types.h> 187 1.32 thorpej #include <dirent.h>]) 188 1.7 tv AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen, 189 1.49 jmc struct stat.st_birthtime, struct stat.st_birthtimensec, 190 1.49 jmc struct stat.st_atim, struct stat.st_mtimensec],,, 191 1.49 jmc [#include <sys/stat.h>]) 192 1.46 dbj AC_CHECK_MEMBERS(struct statvfs.f_iosize,,, [#include <sys/statvfs.h>]) 193 1.80 jmcneill AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, [#include <time.h>]) 194 1.4 tv 195 1.4 tv # Global variable decls. 196 1.89 sevan AC_CHECK_DECLS([asprintf, asnprintf, vasprintf, vasnprintf, vsnprintf, fgetln, fparseln, 197 1.111 christos fpurge, getdelim, getline, snprintf, vsyslog],,, [ 198 1.86 christos #include <stdio.h> 199 1.86 christos ]) 200 1.86 christos 201 1.110 christos AC_CHECK_DECLS([atoll, getsubopt, getprogname, heapsort, 202 1.110 christos mkdtemp, mkstemp, mkstemps, 203 1.110 christos reallocarr, reallocarray, 204 1.110 christos setenv, strtonum, strtoi, strtoll, strtou, setprogname, shquote],,, [ 205 1.86 christos #include <stdlib.h> 206 1.86 christos ]) 207 1.86 christos 208 1.86 christos AC_CHECK_DECLS([basename, dirname],,, [ 209 1.86 christos #include <libgen.h> 210 1.86 christos ]) 211 1.86 christos 212 1.86 christos AC_CHECK_DECLS([raise_default_signal],,, [ 213 1.86 christos #include <util.h> 214 1.86 christos ]) 215 1.86 christos 216 1.87 christos AC_CHECK_DECLS([issetugid, pread, pwrite],,, [ 217 1.86 christos #include <unistd.h> 218 1.86 christos ]) 219 1.86 christos 220 1.87 christos AC_CHECK_DECLS([strmode],,, [ 221 1.87 christos #include <unistd.h> 222 1.87 christos #include <string.h> 223 1.87 christos ]) 224 1.87 christos 225 1.86 christos AC_CHECK_DECLS([isblank],,, [ 226 1.86 christos #include <ctype.h> 227 1.86 christos ]) 228 1.86 christos 229 1.86 christos 230 1.7 tv AC_CHECK_DECLS([optind, optreset],,, [ 231 1.7 tv #include <stdio.h> 232 1.7 tv #include <stdlib.h> 233 1.7 tv #include <unistd.h> 234 1.77 pooka #ifdef HAVE_GETOPT_H 235 1.77 pooka #include <getopt.h> 236 1.77 pooka #endif 237 1.7 tv ]) 238 1.4 tv AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>]) 239 1.4 tv 240 1.4 tv # Library functions (where a .h check isn't enough). 241 1.101 lukem AC_FUNC_ALLOCA() 242 1.39 atatat AC_CHECK_FUNCS(atoll asprintf asnprintf basename devname dirfd dirname \ 243 1.100 lukem dispatch_semaphore_create \ 244 1.76 christos dprintf esetfunc fgetln flock fpurge __fpurge futimes getline \ 245 1.74 joerg getopt getopt_long group_from_gid gid_from_group \ 246 1.48 jmc heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \ 247 1.110 christos mkstemps mkdtemp poll posix_spawn pread putc_unlocked pwcache_userdb \ 248 1.110 christos pwcache_groupdb \ 249 1.99 christos pwrite raise_default_signal random reallocarr reallocarray setenv \ 250 1.78 apb setgroupent setprogname setpassent \ 251 1.78 apb snprintb_m snprintf strlcat strlcpy strmode \ 252 1.110 christos strcasecmp strncasecmp strcasestr strndup strnlen strsep strsuftoll \ 253 1.110 christos strtoi strtoll strtou strtonum \ 254 1.66 christos user_from_uid uid_from_user vasprintf vasnprintf vsnprintf) 255 1.8 tv 256 1.66 christos AC_CHECK_DECLS([user_from_uid, uid_from_user, pwcache_userdb],,,[ 257 1.66 christos #include <pwd.h> 258 1.66 christos ]) 259 1.66 christos AC_CHECK_DECLS([group_from_gid, gid_from_group, pwcache_groupdb],,,[ 260 1.66 christos #include <grp.h> 261 1.66 christos ]) 262 1.110 christos AC_CHECK_DECLS([strcasecmp, strncasecmp, strcasestr, strlcpy, strlcat, strndup, 263 1.93 christos strnlen, strsep],,,[ 264 1.85 christos #include <string.h> 265 1.85 christos ]) 266 1.85 christos AC_CHECK_DECLS([strsuftoll, mi_vector_hash],,,[#include <stdlib.h>]) 267 1.66 christos AC_CHECK_DECLS([lchflags, lchmod, lchown],,,[ 268 1.66 christos #include <sys/stat.h> 269 1.66 christos #include <unistd.h> 270 1.66 christos ]) 271 1.54 wiz 272 1.93 christos AC_CHECK_DECLS([err, errc, errx, verrc, verrx, warn, warnc, warnx, vwarnc, 273 1.93 christos vwarnx],,,[ 274 1.82 christos #ifdef HAVE_ERR_H 275 1.82 christos #include <err.h> 276 1.82 christos #endif 277 1.82 christos ]) 278 1.82 christos 279 1.72 apb AC_CHECK_DECLS([htobe16, htobe32, htobe64, htole16, htole32, htole64, 280 1.72 apb be16toh, be32toh, be64toh, le16toh, le32toh, le64toh],,, 281 1.72 apb [#include <sys/types.h>]) 282 1.44 jmc 283 1.54 wiz AC_CHECK_DECLS([bswap16, bswap32, bswap64],,, [#include <machine/bswap.h>]) 284 1.44 jmc 285 1.72 apb AC_CHECK_DECLS([be16enc, le16enc, be16dec, le16dec, be32enc, le32enc, 286 1.72 apb be32dec, le32dec, be64enc, le64enc, be64dec, le64dec],,, 287 1.72 apb [#include <sys/endian.h>]) 288 1.63 apb 289 1.54 wiz AC_CHECK_DECLS([fstatvfs],,, [#include <sys/statvfs.h>]) 290 1.47 jmc 291 1.8 tv AC_CHECK_DECLS([setgroupent, setpassent],,, [ 292 1.33 thorpej #include <sys/types.h> 293 1.8 tv #include <grp.h> 294 1.8 tv #include <pwd.h> 295 1.8 tv ]) 296 1.1 tv 297 1.4 tv # regcomp() and regexec() are also names of functions in the old V8 298 1.4 tv # regexp package. To avoid them, we need to find out who has regfree(). 299 1.1 tv 300 1.4 tv dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition. 301 1.4 tv dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next. 302 1.4 tv AC_CHECK_LIB(regex, regfree) 303 1.4 tv AC_SEARCH_LIBS(regfree, rx posix) 304 1.1 tv 305 1.79 jmcneill AC_CHECK_LIB(rt, clock_gettime) 306 1.79 jmcneill 307 1.68 tnozaki AC_CHECK_FUNCS(fparseln, [ 308 1.68 tnozaki AC_MSG_CHECKING(if fparseln seems to work) 309 1.68 tnozaki AC_RUN_IFELSE( 310 1.68 tnozaki [AC_LANG_SOURCE([[ 311 1.68 tnozaki #define _NETBSD_SOURCE 312 1.68 tnozaki #include <stdio.h> 313 1.68 tnozaki #include <stdlib.h> 314 1.68 tnozaki #define CONFTEST "conftest.fparseln" 315 1.68 tnozaki #define COMMENT '#' 316 1.68 tnozaki int 317 1.68 tnozaki main(void) 318 1.68 tnozaki { 319 1.68 tnozaki static const char delim[3] = { '\0', '\0', COMMENT }; 320 1.68 tnozaki FILE *fp; 321 1.68 tnozaki char *ptr; 322 1.68 tnozaki fp = fopen(CONFTEST, "w+"); 323 1.68 tnozaki if (fp != NULL) { 324 1.68 tnozaki unlink(CONFTEST); 325 1.68 tnozaki ungetc(COMMENT, fp); 326 1.68 tnozaki ptr = fparseln(fp, NULL, NULL, delim, 327 1.68 tnozaki FPARSELN_UNESCALL); 328 1.68 tnozaki fclose(fp); 329 1.68 tnozaki if (ptr == NULL) 330 1.68 tnozaki exit(0); 331 1.68 tnozaki } 332 1.68 tnozaki exit(1); 333 1.68 tnozaki } 334 1.68 tnozaki ]])], 335 1.68 tnozaki [AC_MSG_RESULT(yes)], 336 1.68 tnozaki [AC_MSG_RESULT(no) 337 1.68 tnozaki AC_DEFINE(BROKEN_FPARSELN, 1, 338 1.100 lukem [Define to 1 if your 'fparseln' function is broken.])], 339 1.68 tnozaki [AC_MSG_WARN([cross compiling: not checking farseln])] 340 1.68 tnozaki ) 341 1.68 tnozaki ]) 342 1.68 tnozaki 343 1.103 lukem dnl 344 1.103 lukem dnl Set per-warning CC_* variables if supported by HOST_CC. 345 1.103 lukem dnl 346 1.103 lukem 347 1.103 lukem dnl Disable use of pre-compiled headers on Darwin. 348 1.106 lukem NB_CHECK_CC_FLAG([-no-cpp-precomp]) 349 1.103 lukem 350 1.104 lukem dnl Detect HOST_CC support for <bsd.own.mk> CC_* warnings 351 1.106 lukem NB_CHECK_CC_FLAG([-Wno-address-of-packed-member]) 352 1.106 lukem NB_CHECK_CC_FLAG([-Wno-cast-function-type]) 353 1.106 lukem NB_CHECK_CC_FLAG([-Wno-error=address-of-packed-member]) 354 1.106 lukem NB_CHECK_CC_FLAG([-Wno-format-overflow]) 355 1.106 lukem NB_CHECK_CC_FLAG([-Wno-format-truncation]) 356 1.106 lukem NB_CHECK_CC_FLAG([-Wno-implicit-fallthrough]) 357 1.106 lukem NB_CHECK_CC_FLAG([-Wno-maybe-uninitialized]) 358 1.106 lukem NB_CHECK_CC_FLAG([-Wno-return-local-addr]) 359 1.106 lukem NB_CHECK_CC_FLAG([-Wno-stringop-overflow]) 360 1.106 lukem NB_CHECK_CC_FLAG([-Wno-stringop-truncation]) 361 1.103 lukem 362 1.101 lukem AC_OUTPUT() 363 1.103 lukem 364 1.104 lukem dnl Display results 365 1.104 lukem dnl 366 1.106 lukem AC_MSG_NOTICE([========= configure results for compat ==========]) 367 1.106 lukem m4_foreach_w([NB_VAR], [CC LIBS ]NB_CHECK_CC_FLAG_VARS, [dnl 368 1.105 lukem AC_MSG_NOTICE(m4_format([%-40s],NB_VAR)[$NB_VAR]) 369 1.104 lukem ]) 370 1.105 lukem AC_MSG_NOTICE([================================================]) 371