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.

235 lines
6.3 KiB

  1. #
  2. # Copyright (c) 2014 Brent Cook
  3. # Parts based on Makefile.in from Portable OpenNTPD:
  4. # Copyright (c) 2004-2008 Darren Tucker.
  5. #
  6. # Permission to use, copy, modify, and distribute this software for any
  7. # purpose with or without fee is hereby granted, provided that the above
  8. # copyright notice and this permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. AM_CPPFLAGS = -I$(top_srcdir)/include
  18. SUBDIRS = include
  19. ACLOCAL_AMFLAGS = -Im4
  20. EXTRA_DIST = VERSION ntpd.conf
  21. CLEANFILES = parse.c
  22. sbin_PROGRAMS = ntpd
  23. noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la
  24. dist_man_MANS = ntpctl.8 ntpd.8 ntpd.conf.5
  25. ntpd_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
  26. ntpd_CFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\"
  27. ntpd_CFLAGS += -DLOCALSTATEDIR=\"$(localstatedir)\"
  28. ntpd_LDADD = $(PLATFORM_LDADD) $(PROG_LDADD) libcompat.la libcompatnoopt.la
  29. ntpd_SOURCES = client.c
  30. ntpd_SOURCES += config.c
  31. ntpd_SOURCES += control.c
  32. ntpd_SOURCES += log.c
  33. ntpd_SOURCES += log.h
  34. ntpd_SOURCES += ntp.c
  35. ntpd_SOURCES += ntp.h
  36. ntpd_SOURCES += ntp_dns.c
  37. ntpd_SOURCES += ntp_msg.c
  38. ntpd_SOURCES += ntpd.c
  39. ntpd_SOURCES += ntpd.h
  40. ntpd_SOURCES += parse.y
  41. if HAVE_SENSORS
  42. ntpd_SOURCES += sensors.c
  43. else
  44. ntpd_SOURCES += compat/fake-sensors.c
  45. endif
  46. ntpd_SOURCES += server.c
  47. ntpd_SOURCES += util.c
  48. install-exec-hook:
  49. @ln -f "$(DESTDIR)$(sbindir)/ntpd" "$(DESTDIR)$(sbindir)/ntpctl"
  50. @if [ ! -d "$(DESTDIR)$(sysconfdir)" ]; then \
  51. $(INSTALL) -m 755 -d "$(DESTDIR)$(sysconfdir)"; \
  52. fi
  53. @if [ ! -d "$(DESTDIR)$(localstatedir)/run" ]; then \
  54. $(INSTALL) -m 755 -d "$(DESTDIR)$(localstatedir)/run"; \
  55. fi
  56. @if [ ! -d "$(DESTDIR)$(localstatedir)/db" ]; then \
  57. $(INSTALL) -m 755 -d "$(DESTDIR)$(localstatedir)/db"; \
  58. fi
  59. @if [ ! -f "$(DESTDIR)$(sysconfdir)/ntpd.conf" ]; then \
  60. $(INSTALL) -m 644 "$(srcdir)/ntpd.conf" "$(DESTDIR)$(sysconfdir)/ntpd.conf"; \
  61. else \
  62. echo "$(DESTDIR)$(sysconfdir)/ntpd.conf already exists, install will not overwrite"; \
  63. fi
  64. @if [ ! -d "$(PRIVSEP_PATH)" ]; then \
  65. echo; \
  66. echo " Please created a privilege separation directory for ntpd." ; \
  67. echo " For OS X, see INSTALL for instructions." ; \
  68. echo " On Linux / BSD systems, this will probably work:"; \
  69. echo ; \
  70. echo " mkdir -p \"$(PRIVSEP_PATH)\"" ; \
  71. echo " chown 0 \"$(PRIVSEP_PATH)\"" ; \
  72. echo " chgrp 0 \"$(PRIVSEP_PATH)\"" ; \
  73. echo " chmod 0755 \"$(PRIVSEP_PATH)\"" ; \
  74. fi
  75. @if egrep "^$(PRIVSEP_USER):" /etc/group >/dev/null; then \
  76. : ; \
  77. else \
  78. echo; \
  79. echo " Please create a dedicated group for ntpd." ; \
  80. echo " For OS X, see INSTALL for instructions." ; \
  81. echo " On Linux / BSD systems, this will probably work:"; \
  82. echo ; \
  83. echo " groupadd $(PRIVSEP_USER)" ; \
  84. fi
  85. @if egrep "^$(PRIVSEP_USER):" /etc/passwd >/dev/null; then \
  86. : ; \
  87. else \
  88. echo; \
  89. echo " Please create a dedicated user for ntpd and ensure it" ; \
  90. echo " cannot be used to log in." ; \
  91. echo " For OS X, see INSTALL for instructions." ; \
  92. echo " On Linux / BSD systems, this will probably work:" ; \
  93. echo ; \
  94. echo " useradd -g $(PRIVSEP_USER) -s /sbin/nologin -d $(PRIVSEP_PATH) -c 'OpenNTP daemon' $(PRIVSEP_USER)" ; \
  95. fi
  96. @echo
  97. uninstall-local:
  98. @if cmp -s "$(DESTDIR)$(sysconfdir)/ntpd.conf" "$(srcdir)/ntpd.conf"; then \
  99. rm -f "$(DESTDIR)$(sysconfdir)/ntpd.conf"; \
  100. fi
  101. @rm -f "$(DESTDIR)$(sbindir)/ntpctl"
  102. # compatibility functions that need to be built without optimizations
  103. libcompatnoopt_la_CFLAGS = -O0
  104. libcompatnoopt_la_SOURCES =
  105. if !HAVE_EXPLICIT_BZERO
  106. libcompatnoopt_la_SOURCES += compat/explicit_bzero.c
  107. endif
  108. # other compatibility functions
  109. libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
  110. libcompat_la_SOURCES =
  111. libcompat_la_LIBADD = $(PLATFORM_LDADD)
  112. if !HAVE_ADJFREQ
  113. if HOST_FREEBSD
  114. libcompat_la_SOURCES += compat/adjfreq_freebsd.c
  115. endif
  116. if HOST_LINUX
  117. libcompat_la_SOURCES += compat/adjfreq_linux.c
  118. endif
  119. if HOST_NETBSD
  120. libcompat_la_SOURCES += compat/adjfreq_netbsd.c
  121. endif
  122. if HOST_DARWIN
  123. libcompat_la_SOURCES += compat/adjfreq_osx.c
  124. endif
  125. if HOST_SOLARIS
  126. libcompat_la_SOURCES += compat/adjfreq_solaris.c
  127. endif
  128. endif
  129. if !HAVE_ASPRINTF
  130. libcompat_la_SOURCES += compat/bsd-asprintf.c
  131. endif
  132. if !HAVE_CLOCK_GETRES
  133. libcompat_la_SOURCES += compat/clock_getres.c
  134. endif
  135. if !HAVE_CLOCK_GETTIME
  136. if HOST_DARWIN
  137. libcompat_la_SOURCES += compat/clock_gettime_osx.c
  138. endif
  139. endif
  140. if !HAVE_IMSG
  141. libcompat_la_SOURCES += compat/imsg.c
  142. libcompat_la_SOURCES += compat/imsg-buffer.c
  143. endif
  144. if !HAVE_MD5
  145. libcompat_la_SOURCES += compat/md5.c
  146. endif
  147. if !HAVE_REALLOCARRAY
  148. libcompat_la_SOURCES += compat/reallocarray.c
  149. endif
  150. if !HAVE_SETPROCTITLE
  151. libcompat_la_SOURCES += compat/setproctitle.c
  152. endif
  153. if !HAVE_STRLCAT
  154. libcompat_la_SOURCES += compat/strlcat.c
  155. endif
  156. if !HAVE_STRLCPY
  157. libcompat_la_SOURCES += compat/strlcpy.c
  158. endif
  159. if !HAVE_STRTONUM
  160. libcompat_la_SOURCES += compat/strtonum.c
  161. endif
  162. if !HAVE_SETRESGID
  163. libcompat_la_SOURCES += compat/bsd-setresgid.c
  164. endif
  165. if !HAVE_SETRESUID
  166. libcompat_la_SOURCES += compat/bsd-setresuid.c
  167. endif
  168. if !HAVE_ARC4RANDOM
  169. libcompat_la_SOURCES += compat/arc4random.c
  170. if !HAVE_GETENTROPY
  171. if HOST_FREEBSD
  172. libcompat_la_SOURCES += compat/getentropy_freebsd.c
  173. endif
  174. if HOST_LINUX
  175. libcompat_la_SOURCES += compat/getentropy_linux.c
  176. if !HAVE_SHA512
  177. libcompat_la_SOURCES += compat/sha2.c
  178. endif
  179. endif
  180. if HOST_NETBSD
  181. libcompat_la_SOURCES += compat/getentropy_netbsd.c
  182. endif
  183. if HOST_DARWIN
  184. libcompat_la_SOURCES += compat/getentropy_osx.c
  185. if !HAVE_SHA512
  186. libcompat_la_SOURCES += compat/sha2.c
  187. endif
  188. endif
  189. if HOST_SOLARIS
  190. libcompat_la_SOURCES += compat/getentropy_solaris.c
  191. if !HAVE_SHA512
  192. libcompat_la_SOURCES += compat/sha2.c
  193. endif
  194. endif
  195. endif
  196. endif
  197. if !HAVE_ARC4RANDOM_UNIFORM
  198. libcompat_la_SOURCES += compat/arc4random_uniform.c
  199. endif
  200. noinst_HEADERS = compat/arc4random.h
  201. noinst_HEADERS += compat/arc4random_freebsd.h
  202. noinst_HEADERS += compat/arc4random_linux.h
  203. noinst_HEADERS += compat/arc4random_netbsd.h
  204. noinst_HEADERS += compat/arc4random_osx.h
  205. noinst_HEADERS += compat/arc4random_solaris.h
  206. noinst_HEADERS += compat/arc4random_win.h
  207. noinst_HEADERS += compat/chacha_private.h