Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
5.4 KiB

  1. #
  2. # Copyright (c) 2014-2015 Brent Cook
  3. # Parts based on configure.ac from Portable OpenNTPD:
  4. # Copyright (c) 2004-2008 Darren Tucker
  5. # which itself was based on configure.ac from OpenSSH:
  6. # Copyright (c) 1999-2004 Damien Miller
  7. #
  8. # Permission to use, copy, modify, and distribute this software for any
  9. # purpose with or without fee is hereby granted, provided that the above
  10. # copyright notice and this permission notice appear in all copies.
  11. #
  12. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. AC_INIT([OpenNTPD], m4_esyscmd([tr -d '\n' < VERSION]))
  20. AC_CANONICAL_HOST
  21. AM_INIT_AUTOMAKE([subdir-objects foreign])
  22. AC_CONFIG_MACRO_DIR([m4])
  23. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  24. AC_PROG_CC
  25. AC_PROG_CC_STDC
  26. AM_PROG_CC_C_O
  27. AC_PROG_LIBTOOL
  28. LT_INIT
  29. AC_PROG_YACC
  30. CHECK_OS_OPTIONS
  31. CHECK_CRYPTO_COMPAT
  32. # check functions that are expected to be in libc
  33. AC_CHECK_FUNCS([asprintf closefrom daemon memmem poll reallocarray])
  34. AC_CHECK_FUNCS([setproctitle setgroups])
  35. AC_CHECK_FUNCS([setregid setresgid setreuid setresuid])
  36. AC_CHECK_FUNCS([strlcat strlcpy strtonum sysconf])
  37. # check auxiliary libraries that might contain other functions
  38. AC_SEARCH_LIBS([arc4random], [crypto])
  39. AC_SEARCH_LIBS([ibuf_open], [util])
  40. AC_CHECK_FUNCS([ibuf_open])
  41. # time-specific system functions
  42. AC_CHECK_FUNCS([adjfreq ntp_adjtime adjtimex])
  43. AC_CHECK_FUNCS([clock_gettime clock_getres])
  44. AC_SEARCH_LIBS([clock_getres],[rt posix4])
  45. AC_SEARCH_LIBS([clock_gettime],[rt posix4])
  46. AM_CONDITIONAL([HAVE_ADJFREQ], [test "x$ac_cv_func_adjfreq" = xyes])
  47. AM_CONDITIONAL([HAVE_CLOCK_GETRES], [test "x$ac_cv_func_clock_getres" = xyes])
  48. AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "x$ac_cv_func_clock_gettime" = xyes])
  49. # check for libtls
  50. AC_SEARCH_LIBS([tls_config_set_ca_mem],[tls],
  51. [LIBS="$LIBS -ltls -lssl -lcrypto"],,[-lssl -lcrypto])
  52. AC_CHECK_FUNCS([tls_config_set_ca_mem])
  53. # check if libtls uses 3-argument tls_write
  54. AC_CACHE_CHECK([if tls_write takes 3 arguments], ac_cv_have_tls_write_3_arg, [
  55. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  56. #include <tls.h>
  57. size_t outlen;
  58. ]], [[ tls_write(NULL, NULL, 0); ]])],
  59. [ ac_cv_have_tls_write_3_arg="yes" ],
  60. [ ac_cv_have_tls_write_3_arg="no"
  61. ])
  62. ])
  63. AC_ARG_ENABLE([https-constraint],
  64. AS_HELP_STRING([--disable-https-constraint],
  65. [Disable HTTPS Constraint Functionality]))
  66. AM_CONDITIONAL([HAVE_LIBTLS],
  67. [test "x$ac_cv_func_tls_config_set_ca_mem" = xyes \
  68. -a "x$ac_cv_have_tls_write_3_arg" = xyes \
  69. -a "x$enable_https_constraint" != xno])
  70. if test "x$ac_cv_func_tls_config_set_ca_mem" = xyes \
  71. -a "x$ac_cv_have_tls_write_3_arg" = xyes \
  72. -a "x$enable_https_constraint" != xno; then
  73. AC_DEFINE([HAVE_LIBTLS], [yes])
  74. fi
  75. # Share test results with automake
  76. AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
  77. AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
  78. AM_CONDITIONAL([HAVE_DAEMON], [test "x$ac_cv_func_daemon" = xyes])
  79. AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes])
  80. AM_CONDITIONAL([HAVE_IFADDRS_H], [test "x$ac_cv_header_ifaddrs_h" = xyes])
  81. AM_CONDITIONAL([HAVE_IMSG], [test "x$ac_cv_func_ibuf_open" = xyes])
  82. AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
  83. AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes])
  84. AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
  85. AM_CONDITIONAL([HAVE_SETGROUPS], [test "x$ac_cv_func_setgroups" = xyes])
  86. AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
  87. AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
  88. AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
  89. AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes])
  90. AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
  91. AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes])
  92. AM_CONDITIONAL([HAVE_SYSCONF], [test "x$ac_cv_func_sysconf" = xyes])
  93. CHECK_PROGNAME
  94. CHECK_VA_COPY
  95. AC_CHECK_HEADERS([sys/sysctl.h err.h ifaddrs.h paths.h])
  96. AC_CHECK_HEADERS([sys/sensors.h],
  97. AM_CONDITIONAL(HAVE_SENSORS, true),
  98. AM_CONDITIONAL(HAVE_SENSORS, false)
  99. )
  100. AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], , ,
  101. [ #include <netdb.h>
  102. #include <netinet/in.h>
  103. #include <sys/socket.h> ]
  104. )
  105. AC_ARG_WITH([privsep-user],
  106. AS_HELP_STRING([--with-privsep-user=user],
  107. [Privilege separation user for ntpd to use]),
  108. PRIVSEP_USER="$withval",
  109. PRIVSEP_USER="_ntp"
  110. )
  111. AC_DEFINE_UNQUOTED(NTPD_USER, "$PRIVSEP_USER", [Unprivileged user])
  112. AC_SUBST(PRIVSEP_USER)
  113. AC_ARG_WITH([privsep-path],
  114. AS_HELP_STRING([--with-privsep-path=path],
  115. [Privilege separation chroot path to check on install]),
  116. PRIVSEP_PATH="$withval",
  117. PRIVSEP_PATH="/var/empty"
  118. )
  119. AC_SUBST(PRIVSEP_PATH)
  120. AC_ARG_WITH([cacert],
  121. AS_HELP_STRING([--with-cacert=path],
  122. [CA certificate location for HTTPS constraint validation]),
  123. CONSTRAINT_CA="$withval",
  124. CONSTRAINT_CA="/etc/ssl/cert.pem"
  125. )
  126. AC_DEFINE_UNQUOTED(CONSTRAINT_CA, "$CONSTRAINT_CA", [CA certificate path])
  127. AC_CONFIG_FILES([
  128. Makefile
  129. include/Makefile
  130. compat/Makefile
  131. src/Makefile
  132. ])
  133. AC_OUTPUT