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.

249 lines
6.9 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; \
  63. echo " $(DESTDIR)$(sysconfdir)/ntpd.conf already exists, install will not overwrite"; \
  64. fi
  65. @if [ ! -d "$(PRIVSEP_PATH)" ]; then \
  66. echo; \
  67. echo " Please created a privilege separation directory for ntpd." ; \
  68. echo " For OS X, see INSTALL for instructions." ; \
  69. echo " On Linux / BSD systems, this will probably work:"; \
  70. echo ; \
  71. echo " mkdir -p \"$(PRIVSEP_PATH)\"" ; \
  72. echo " chown 0 \"$(PRIVSEP_PATH)\"" ; \
  73. echo " chgrp 0 \"$(PRIVSEP_PATH)\"" ; \
  74. echo " chmod 0755 \"$(PRIVSEP_PATH)\"" ; \
  75. fi
  76. @if egrep "^$(PRIVSEP_USER):" /etc/group >/dev/null; then \
  77. : ; \
  78. else \
  79. echo; \
  80. echo " Please create a dedicated group for ntpd." ; \
  81. echo " For OS X, see INSTALL for instructions." ; \
  82. echo " On Linux / BSD systems, this will probably work:"; \
  83. echo ; \
  84. echo " groupadd $(PRIVSEP_USER)" ; \
  85. fi
  86. @if egrep "^$(PRIVSEP_USER):" /etc/passwd >/dev/null; then \
  87. : ; \
  88. else \
  89. echo; \
  90. echo " Please create a dedicated user for ntpd and ensure it" ; \
  91. echo " cannot be used to log in." ; \
  92. echo " For OS X, see INSTALL for instructions." ; \
  93. echo " On Linux / BSD systems, this will probably work:" ; \
  94. echo ; \
  95. echo " useradd -g $(PRIVSEP_USER) -s /sbin/nologin -d $(PRIVSEP_PATH) -c 'OpenNTP daemon' $(PRIVSEP_USER)" ; \
  96. fi
  97. @if [ -d $(PRIVSEP_PATH) ]; then \
  98. if [ `ls -A $(PRIVSEP_PATH)|wc -l` != "0" ]; then \
  99. echo; \
  100. echo " WARNING: the privilege separation path is specified as $(PRIVSEP_PATH), " ; \
  101. echo " but this directory contains files!" ; \
  102. echo ; \
  103. echo " Please ensure that $(PRIVSEP_PATH) is empty. If you installed a previous " ; \
  104. echo " OpenNTPD version and created a user with a home directory at /var/empty/ntpd, " ; \
  105. echo " please adjust that user to use /var/empty instead and delete /var/empty/ntpd." ; \
  106. fi; \
  107. fi
  108. @echo
  109. uninstall-local:
  110. @if cmp -s "$(DESTDIR)$(sysconfdir)/ntpd.conf" "$(srcdir)/ntpd.conf"; then \
  111. rm -f "$(DESTDIR)$(sysconfdir)/ntpd.conf"; \
  112. fi
  113. @rm -f "$(DESTDIR)$(sbindir)/ntpctl"
  114. # compatibility functions that need to be built without optimizations
  115. libcompatnoopt_la_CFLAGS = -O0
  116. libcompatnoopt_la_SOURCES =
  117. if !HAVE_EXPLICIT_BZERO
  118. libcompatnoopt_la_SOURCES += compat/explicit_bzero.c
  119. endif
  120. # other compatibility functions
  121. libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
  122. libcompat_la_SOURCES =
  123. libcompat_la_LIBADD = $(PLATFORM_LDADD)
  124. if !HAVE_ADJFREQ
  125. if HOST_FREEBSD
  126. libcompat_la_SOURCES += compat/adjfreq_freebsd.c
  127. endif
  128. if HOST_LINUX
  129. libcompat_la_SOURCES += compat/adjfreq_linux.c
  130. endif
  131. if HOST_NETBSD
  132. libcompat_la_SOURCES += compat/adjfreq_netbsd.c
  133. endif
  134. if HOST_DARWIN
  135. libcompat_la_SOURCES += compat/adjfreq_osx.c
  136. endif
  137. if HOST_SOLARIS
  138. libcompat_la_SOURCES += compat/adjfreq_solaris.c
  139. endif
  140. endif
  141. if !HAVE_ASPRINTF
  142. libcompat_la_SOURCES += compat/bsd-asprintf.c
  143. endif
  144. if !HAVE_CLOCK_GETRES
  145. libcompat_la_SOURCES += compat/clock_getres.c
  146. endif
  147. if !HAVE_CLOCK_GETTIME
  148. if HOST_DARWIN
  149. libcompat_la_SOURCES += compat/clock_gettime_osx.c
  150. endif
  151. endif
  152. if !HAVE_IMSG
  153. libcompat_la_SOURCES += compat/imsg.c
  154. libcompat_la_SOURCES += compat/imsg-buffer.c
  155. endif
  156. if !HAVE_MD5
  157. libcompat_la_SOURCES += compat/md5.c
  158. endif
  159. libcompat_la_SOURCES += compat/progname.c
  160. if !HAVE_REALLOCARRAY
  161. libcompat_la_SOURCES += compat/reallocarray.c
  162. endif
  163. if !HAVE_SETPROCTITLE
  164. libcompat_la_SOURCES += compat/setproctitle.c
  165. endif
  166. if !HAVE_STRLCAT
  167. libcompat_la_SOURCES += compat/strlcat.c
  168. endif
  169. if !HAVE_STRLCPY
  170. libcompat_la_SOURCES += compat/strlcpy.c
  171. endif
  172. if !HAVE_STRTONUM
  173. libcompat_la_SOURCES += compat/strtonum.c
  174. endif
  175. if !HAVE_SETRESGID
  176. libcompat_la_SOURCES += compat/bsd-setresgid.c
  177. endif
  178. if !HAVE_SETRESUID
  179. libcompat_la_SOURCES += compat/bsd-setresuid.c
  180. endif
  181. if !HAVE_ARC4RANDOM
  182. libcompat_la_SOURCES += compat/arc4random.c
  183. if !HAVE_GETENTROPY
  184. if HOST_FREEBSD
  185. libcompat_la_SOURCES += compat/getentropy_freebsd.c
  186. endif
  187. if HOST_LINUX
  188. libcompat_la_SOURCES += compat/getentropy_linux.c
  189. if !HAVE_SHA512
  190. libcompat_la_SOURCES += compat/sha2.c
  191. endif
  192. endif
  193. if HOST_NETBSD
  194. libcompat_la_SOURCES += compat/getentropy_netbsd.c
  195. endif
  196. if HOST_DARWIN
  197. libcompat_la_SOURCES += compat/getentropy_osx.c
  198. if !HAVE_SHA512
  199. libcompat_la_SOURCES += compat/sha2.c
  200. endif
  201. endif
  202. if HOST_SOLARIS
  203. libcompat_la_SOURCES += compat/getentropy_solaris.c
  204. if !HAVE_SHA512
  205. libcompat_la_SOURCES += compat/sha2.c
  206. endif
  207. endif
  208. endif
  209. endif
  210. if !HAVE_ARC4RANDOM_UNIFORM
  211. libcompat_la_SOURCES += compat/arc4random_uniform.c
  212. endif
  213. noinst_HEADERS = compat/arc4random.h
  214. noinst_HEADERS += compat/arc4random_freebsd.h
  215. noinst_HEADERS += compat/arc4random_linux.h
  216. noinst_HEADERS += compat/arc4random_netbsd.h
  217. noinst_HEADERS += compat/arc4random_osx.h
  218. noinst_HEADERS += compat/arc4random_solaris.h
  219. noinst_HEADERS += compat/arc4random_win.h
  220. noinst_HEADERS += compat/chacha_private.h