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.

160 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. DISABLE_COMPILER_WARNINGS
  31. CHECK_OS_OPTIONS
  32. CHECK_CRYPTO_COMPAT
  33. # check functions that are expected to be in libc
  34. AC_CHECK_FUNCS([asprintf closefrom daemon memmem poll reallocarray])
  35. AC_CHECK_FUNCS([setproctitle setgroups])
  36. AC_CHECK_FUNCS([setregid setresgid setreuid setresuid])
  37. AC_CHECK_FUNCS([strlcat strlcpy strtonum sysconf])
  38. # check auxiliary libraries that might contain other functions
  39. AC_SEARCH_LIBS([arc4random], [crypto])
  40. AC_SEARCH_LIBS([ibuf_open], [util])
  41. AC_CHECK_FUNCS([ibuf_open])
  42. # time-specific system functions
  43. AC_CHECK_FUNCS([adjfreq ntp_adjtime adjtimex])
  44. AC_CHECK_FUNCS([clock_gettime clock_getres])
  45. AC_SEARCH_LIBS([clock_getres],[rt posix4])
  46. AC_SEARCH_LIBS([clock_gettime],[rt posix4])
  47. AM_CONDITIONAL([HAVE_ADJFREQ], [test "x$ac_cv_func_adjfreq" = xyes])
  48. AM_CONDITIONAL([HAVE_CLOCK_GETRES], [test "x$ac_cv_func_clock_getres" = xyes])
  49. AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "x$ac_cv_func_clock_gettime" = xyes])
  50. # check for libtls
  51. AC_SEARCH_LIBS([tls_config_set_ca_mem],[tls],
  52. [LIBS="$LIBS -ltls -lssl -lcrypto"],,[-lssl -lcrypto])
  53. AC_CHECK_FUNCS([tls_config_set_ca_mem])
  54. # check if libtls uses 3-argument tls_write
  55. AC_CACHE_CHECK([if tls_write takes 3 arguments], ac_cv_have_tls_write_3_arg, [
  56. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  57. #include <tls.h>
  58. size_t outlen;
  59. ]], [[ tls_write(NULL, NULL, 0); ]])],
  60. [ ac_cv_have_tls_write_3_arg="yes" ],
  61. [ ac_cv_have_tls_write_3_arg="no"
  62. ])
  63. ])
  64. AC_ARG_ENABLE([https-constraint],
  65. AS_HELP_STRING([--disable-https-constraint],
  66. [Disable HTTPS Constraint Functionality]))
  67. AM_CONDITIONAL([HAVE_LIBTLS],
  68. [test "x$ac_cv_func_tls_config_set_ca_mem" = xyes \
  69. -a "x$ac_cv_have_tls_write_3_arg" = xyes \
  70. -a "x$enable_https_constraint" != xno])
  71. if test "x$ac_cv_func_tls_config_set_ca_mem" = xyes \
  72. -a "x$ac_cv_have_tls_write_3_arg" = xyes \
  73. -a "x$enable_https_constraint" != xno; then
  74. AC_DEFINE([HAVE_LIBTLS], [yes])
  75. fi
  76. # Share test results with automake
  77. AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
  78. AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
  79. AM_CONDITIONAL([HAVE_DAEMON], [test "x$ac_cv_func_daemon" = xyes])
  80. AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes])
  81. AM_CONDITIONAL([HAVE_IFADDRS_H], [test "x$ac_cv_header_ifaddrs_h" = xyes])
  82. AM_CONDITIONAL([HAVE_IMSG], [test "x$ac_cv_func_ibuf_open" = xyes])
  83. AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
  84. AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes])
  85. AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
  86. AM_CONDITIONAL([HAVE_SETGROUPS], [test "x$ac_cv_func_setgroups" = xyes])
  87. AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
  88. AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
  89. AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
  90. AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes])
  91. AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
  92. AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes])
  93. AM_CONDITIONAL([HAVE_SYSCONF], [test "x$ac_cv_func_sysconf" = xyes])
  94. CHECK_PROGNAME
  95. CHECK_VA_COPY
  96. AC_CHECK_HEADERS([sys/sysctl.h err.h ifaddrs.h paths.h])
  97. AC_CHECK_HEADERS([sys/sensors.h],
  98. AM_CONDITIONAL(HAVE_SENSORS, true),
  99. AM_CONDITIONAL(HAVE_SENSORS, false)
  100. )
  101. AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], , ,
  102. [ #include <netdb.h>
  103. #include <netinet/in.h>
  104. #include <sys/socket.h> ]
  105. )
  106. AC_ARG_WITH([privsep-user],
  107. AS_HELP_STRING([--with-privsep-user=user],
  108. [Privilege separation user for ntpd to use]),
  109. PRIVSEP_USER="$withval",
  110. PRIVSEP_USER="_ntp"
  111. )
  112. AC_DEFINE_UNQUOTED(NTPD_USER, "$PRIVSEP_USER", [Unprivileged user])
  113. AC_SUBST(PRIVSEP_USER)
  114. AC_ARG_WITH([privsep-path],
  115. AS_HELP_STRING([--with-privsep-path=path],
  116. [Privilege separation chroot path to check on install]),
  117. PRIVSEP_PATH="$withval",
  118. PRIVSEP_PATH="/var/empty"
  119. )
  120. AC_SUBST(PRIVSEP_PATH)
  121. AC_ARG_WITH([cacert],
  122. AS_HELP_STRING([--with-cacert=path],
  123. [CA certificate location for HTTPS constraint validation]),
  124. CONSTRAINT_CA="$withval",
  125. CONSTRAINT_CA="/etc/ssl/cert.pem"
  126. )
  127. AC_DEFINE_UNQUOTED(CONSTRAINT_CA, "$CONSTRAINT_CA", [CA certificate path])
  128. AC_CONFIG_FILES([
  129. Makefile
  130. include/Makefile
  131. compat/Makefile
  132. src/Makefile
  133. ])
  134. AC_OUTPUT