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.

162 lines
5.6 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 freezero memmem poll reallocarray recallocarray])
  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_SEARCH_LIBS([clock_getres],[rt posix4])
  44. AC_SEARCH_LIBS([clock_gettime],[rt posix4])
  45. AC_CHECK_FUNCS([adjfreq ntp_adjtime adjtimex])
  46. AC_CHECK_FUNCS([clock_gettime clock_getres])
  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_FREEZERO], [test "x$ac_cv_func_freezero" = xyes])
  82. AM_CONDITIONAL([HAVE_IFADDRS_H], [test "x$ac_cv_header_ifaddrs_h" = xyes])
  83. AM_CONDITIONAL([HAVE_IMSG], [test "x$ac_cv_func_ibuf_open" = xyes])
  84. AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
  85. AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes])
  86. AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
  87. AM_CONDITIONAL([HAVE_RECALLOCARRAY], [test "x$ac_cv_func_recallocarray" = xyes])
  88. AM_CONDITIONAL([HAVE_SETGROUPS], [test "x$ac_cv_func_setgroups" = xyes])
  89. AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
  90. AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])
  91. AM_CONDITIONAL([HAVE_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" = xyes])
  92. AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes])
  93. AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
  94. AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes])
  95. AM_CONDITIONAL([HAVE_SYSCONF], [test "x$ac_cv_func_sysconf" = xyes])
  96. CHECK_PROGNAME
  97. CHECK_VA_COPY
  98. AC_CHECK_HEADERS([sys/sysctl.h err.h ifaddrs.h paths.h])
  99. AC_CHECK_HEADERS([sys/sensors.h],
  100. AM_CONDITIONAL(HAVE_SENSORS, true),
  101. AM_CONDITIONAL(HAVE_SENSORS, false)
  102. )
  103. AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], , ,
  104. [ #include <netdb.h>
  105. #include <netinet/in.h>
  106. #include <sys/socket.h> ]
  107. )
  108. AC_ARG_WITH([privsep-user],
  109. AS_HELP_STRING([--with-privsep-user=user],
  110. [Privilege separation user for ntpd to use]),
  111. PRIVSEP_USER="$withval",
  112. PRIVSEP_USER="_ntp"
  113. )
  114. AC_DEFINE_UNQUOTED(NTPD_USER, "$PRIVSEP_USER", [Unprivileged user])
  115. AC_SUBST(PRIVSEP_USER)
  116. AC_ARG_WITH([privsep-path],
  117. AS_HELP_STRING([--with-privsep-path=path],
  118. [Privilege separation chroot path to check on install]),
  119. PRIVSEP_PATH="$withval",
  120. PRIVSEP_PATH="/var/empty"
  121. )
  122. AC_SUBST(PRIVSEP_PATH)
  123. AC_ARG_WITH([cacert],
  124. AS_HELP_STRING([--with-cacert=path],
  125. [CA certificate location for HTTPS constraint validation]),
  126. CONSTRAINT_CA="$withval",
  127. CONSTRAINT_CA="/etc/ssl/cert.pem"
  128. )
  129. AC_DEFINE_UNQUOTED(CONSTRAINT_CA, "$CONSTRAINT_CA", [CA certificate path])
  130. AC_CONFIG_FILES([
  131. Makefile
  132. include/Makefile
  133. compat/Makefile
  134. src/Makefile
  135. ])
  136. AC_OUTPUT