xref: /freebsd/contrib/ntp/ntpd/Makefile.am (revision aa24f48b361effe51163877d84f1b70d32b77e04)
1NULL=
2
3bin_PROGRAMS=	$(NTPD_DB) $(NTPDSIM_DB)
4libexec_PROGRAMS=	$(NTPD_DL) $(NTPDSIM_DL)
5sbin_PROGRAMS=	$(NTPD_DS) $(NTPDSIM_DS)
6
7noinst_LIBRARIES=	libntpd.a
8
9AM_CFLAGS = $(CFLAGS_NTP)
10AM_CFLAGS += $(NTP_HARD_CFLAGS)
11
12AM_CPPFLAGS  = $(NTP_INCS)
13AM_CPPFLAGS += $(LIBOPTS_CFLAGS)
14AM_CPPFLAGS += $(CPPFLAGS_NTP)
15AM_CPPFLAGS += $(NTP_HARD_CPPFLAGS)
16
17AM_LDFLAGS = $(LDFLAGS_NTP)
18AM_LDFLAGS += $(NTP_HARD_LDFLAGS)
19
20# LDADD might need RESLIB and ADJLIB.
21LDADD = version.o libntpd.a $(LIBPARSE)
22AM_YFLAGS = -d -t -r all
23
24if SAVECONFIG_ENABLED
25if NTP_CROSSCOMPILE
26CHECK_SAVECONFIG=
27else
28CHECK_SAVECONFIG= check-saveconfig
29endif
30else !SAVECONFIG_ENABLED
31CHECK_SAVECONFIG=
32endif
33
34#
35# VPHACK and VPHACK_AFTER are enabled on non-GNU makes (such as
36# BSD make) to work around issues specific to compiling
37# ntp_parser.y into ntp_parser.h and ntp_parser.c in a VPATH
38# configuration where we would like (for a change) the output
39# files ntp_parser.[ch] to be placed in the source directory,
40# as opposed to the build directory.  This allows a single
41# host of a flock configured with Bison to update ntp_parser.[ch]
42# used by the rest.
43#
44
45if VPATH_HACK
46VPHACK=	vphack
47VPHACK_AFTER= vphack_after
48else
49VPHACK=
50VPHACK_AFTER=
51endif
52
53vphack:
54	test -e ntp_parser.c || ln -s $(srcdir)/ntp_parser.c .
55	test -e ntp_parser.h || ln -s $(srcdir)/ntp_parser.h .
56
57#
58# ylwrap script which invokes Bison replaces ntp_parser.h
59# symlink with the updated file, when ntp_parser.h changes.
60# vphack_after detects this and copies the updated file to srcdir
61# and re-creates the ntp_parser.h symlink in its place.
62#
63
64vphack_after:
65	test -L ntp_parser.h || ( \
66		mv ntp_parser.h $(srcdir)/ntp_parser.h && \
67		ln -s $(srcdir)/ntp_parser.h . \
68		)
69
70# BUILT_SOURCES which should also be in EXTRA_DIST
71B_S_DIST=			\
72	$(srcdir)/ntpd-opts.c	\
73	$(srcdir)/ntpd-opts.h	\
74	$(NULL)
75
76BUILT_SOURCES=		\
77	$(VPHACK)	\
78	$(LIBPARSE)	\
79	ntp_parser.c	\
80	ntp_parser.h	\
81	$(VPHACK_AFTER)	\
82	$(B_S_DIST)	\
83	$(NULL)
84
85man1_MANS=
86man5_MANS=	ntp.conf.5 ntp.keys.5
87man8_MANS=
88man_MANS=	ntpd.$(NTPD_MS)
89
90# ntpdsim.1 is a remnant along with all the ntpdsim-opts.* files, the
91# simulator currently uses ntpd-opts.[ch].  This also means there is no
92# longer a reason to have ntpdbase-opts.def split off of ntpd-opts.def.
93
94LDADD_NTPD_COMMON  = $(LDADD_LIBNTP) $(LIBOPTS_LDADD) $(PTHREAD_LIBS)
95LDADD_NTPD_COMMON += $(LIBM) $(LDADD_NTP) $(LSCF)
96ntpd_LDADD = $(LDADD) ../libntp/libntp.a $(LDADD_NTPD_COMMON) $(LDADD_LIBUTIL)
97ntpdsim_LDADD = $(LDADD) ../libntp/libntpsim.a $(LDADD_NTPD_COMMON)
98ntpdsim_CPPFLAGS = $(AM_CPPFLAGS) -DSIM
99check_y2k_LDADD = $(LDADD) ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(LDADD_LIBNTP) $(PTHREAD_LIBS)
100## we don't want $(LDADD) in keyword_gen_LDADD
101keyword_gen_LDADD = ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS)
102
103DISTCLEANFILES =		\
104	keyword-gen		\
105	.version		\
106	version.c		\
107	config.log		\
108	$(man5_MANS)		\
109	$(man_MANS)		\
110	$(NULL)
111
112CLEANFILES =			\
113	check-saveconfig	\
114	compsave.conf		\
115	k-g-u-submake		\
116	$(EXTRA_PROGRAMS)	\
117	$(NULL)
118
119EXTRA_DIST =			\
120	complete.conf.in	\
121	invoke-ntp.conf.menu	\
122	invoke-ntp.conf.texi	\
123	invoke-ntp.keys.menu	\
124	invoke-ntp.keys.texi	\
125	invoke-ntpd.menu	\
126	invoke-ntpd.texi	\
127	keyword-gen-utd		\
128	ntp.conf.5man		\
129	ntp.conf.5mdoc		\
130	ntp.conf.def		\
131	ntp.conf.man.in		\
132	ntp.conf.mdoc.in	\
133	ntp.conf.html		\
134	ntp.conf.texi		\
135	ntp.keys.5man		\
136	ntp.keys.5mdoc		\
137	ntp.keys.def		\
138	ntp.keys.man.in		\
139	ntp.keys.mdoc.in	\
140	ntp.keys.html		\
141	ntp.keys.texi		\
142	ntpd-opts.def		\
143	ntpd.1ntpdman		\
144	ntpd.1ntpdmdoc		\
145	ntpd.man.in		\
146	ntpd.mdoc.in		\
147	ntpd.html		\
148	ntpd.texi		\
149	ntpdbase-opts.def	\
150	refclock_msfees.c	\
151	$(B_S_DIST)		\
152	$(NULL)
153
154###							Y2Kfixes
155check_PROGRAMS = @MAKE_CHECK_Y2K@
156EXTRA_PROGRAMS = check_y2k keyword-gen ntpd ntpdsim
157
158html_DATA=				\
159	$(srcdir)/ntp.conf.html		\
160	$(srcdir)/ntp.keys.html		\
161	$(srcdir)/ntpd.html		\
162	$(NULL)
163
164noinst_DATA =				\
165	$(srcdir)/invoke-ntp.conf.menu	\
166	$(srcdir)/invoke-ntp.conf.texi	\
167	$(srcdir)/invoke-ntp.keys.menu	\
168	$(srcdir)/invoke-ntp.keys.texi	\
169	$(srcdir)/invoke-ntpd.menu	\
170	$(srcdir)/invoke-ntpd.texi	\
171	$(srcdir)/ntp.conf.man.in	\
172	$(srcdir)/ntp.conf.mdoc.in	\
173	$(srcdir)/ntp.keys.man.in	\
174	$(srcdir)/ntp.keys.mdoc.in	\
175	$(srcdir)/ntpd.man.in		\
176	$(srcdir)/ntpd.mdoc.in		\
177	$(NULL)
178
179noinst_HEADERS =			\
180	declcond.h			\
181	ntp_leapsec.h			\
182	$(NULL)
183
184install-data-local: install-html
185
186run_ag=		cd $(srcdir) &&	env PATH="$(abs_builddir):$(PATH)" AUTOGEN_DNE_DATE=-D	\
187		autogen -L ../sntp/include -L ../sntp/ag-tpl --writable
188std_def_list =							\
189	$(top_srcdir)/sntp/include/debug-opt.def		\
190	$(top_srcdir)/sntp/include/autogen-version.def		\
191	$(top_srcdir)/sntp/include/copyright.def		\
192	$(top_srcdir)/sntp/include/homerc.def			\
193	$(top_srcdir)/sntp/include/ntp.lic			\
194	$(top_srcdir)/sntp/include/version.def			\
195	$(NULL)
196
197check-local: $(MAKE_CHECK_Y2K) $(CHECK_SAVECONFIG)
198	test -z "$(MAKE_CHECK_Y2K)" || ./$(MAKE_CHECK_Y2K)
199
200ntpd_SOURCES =			\
201	ntp_config.c		\
202	ntp_keyword.h		\
203	ntp_io.c		\
204	ntp_parser.y		\
205	ntp_scanner.c		\
206	ntp_scanner.h		\
207	ntpd.c			\
208	ntpd-opts.c		\
209	ntpd-opts.h		\
210	$(NULL)
211
212ntpdsim_SOURCES =		\
213	$(ntpd_SOURCES)		\
214	ntp_prio_q.c		\
215	ntpsim.c		\
216	$(NULL)
217
218# libntpd_a_SOURCES do not use #ifdef SIM
219
220libntpd_a_SOURCES =		\
221	cmd_args.c		\
222	jupiter.h		\
223	ntp_control.c		\
224	ntp_crypto.c		\
225	ntp_filegen.c		\
226	ntp_leapsec.c		\
227	ntp_loopfilter.c	\
228	ntp_monitor.c		\
229	ntp_peer.c		\
230	ntp_proto.c		\
231	ntp_refclock.c		\
232	ntp_request.c		\
233	ntp_restrict.c		\
234	ntp_signd.c		\
235	ntp_timer.c		\
236	ntp_util.c		\
237	ppsapi_timepps.h	\
238	rc_cmdlength.c		\
239	refclock_acts.c		\
240	refclock_arbiter.c	\
241	refclock_arc.c		\
242	refclock_as2201.c	\
243	refclock_atom.c		\
244	refclock_bancomm.c	\
245	refclock_chronolog.c	\
246	refclock_chu.c		\
247	refclock_conf.c		\
248	refclock_datum.c	\
249	refclock_dumbclock.c	\
250	refclock_fg.c		\
251	refclock_gpsdjson.c	\
252	refclock_gpsvme.c	\
253	refclock_heath.c	\
254	refclock_hopfser.c	\
255	refclock_hopfpci.c	\
256	refclock_hpgps.c	\
257	refclock_irig.c		\
258	refclock_jjy.c		\
259	refclock_jupiter.c	\
260	refclock_leitch.c	\
261	refclock_local.c	\
262	refclock_mx4200.c	\
263	refclock_neoclock4x.c	\
264	refclock_nmea.c		\
265	refclock_oncore.c	\
266	refclock_palisade.c	\
267	refclock_palisade.h	\
268	refclock_parse.c	\
269	refclock_pcf.c		\
270	refclock_pst.c		\
271	refclock_ripencc.c	\
272	refclock_shm.c		\
273	refclock_tpro.c		\
274	refclock_true.c		\
275	refclock_tt560.c	\
276	refclock_ulink.c	\
277	refclock_wwv.c		\
278	refclock_wwvb.c		\
279	refclock_zyfer.c	\
280	refclock_tsyncpci.c	\
281	$(NULL)
282
283k-g-u-submake: keyword-gen
284	./keyword-gen $(srcdir)/ntp_parser.h > k-g.out
285	@grep -v diff_ignore_line < k-g.out > cmp1
286	@grep -v diff_ignore_line < $(srcdir)/ntp_keyword.h > cmp2
287	@cmp cmp1 cmp2 > /dev/null || \
288		{ mv -f k-g.out $(srcdir)/ntp_keyword.h && \
289		  echo 'Generated changed ntp_keyword.h.' ;}
290	@[ ! -f k-g.out ] || \
291		{ rm k-g.out && echo 'ntp_keyword.h is up to date.' ;}
292	@rm cmp1 cmp2
293	@echo 'keyword-gen and ntp_keyword.h are up to date.' > $@
294
295$(srcdir)/keyword-gen-utd: $(srcdir)/keyword-gen.c $(srcdir)/ntp_parser.h
296	$(MAKE) $(AM_MAKEFLAGS) k-g-u-submake	# avoid explicit dependency
297	grep diff_ignore_line $(srcdir)/ntp_keyword.h > k-g-u
298	mv -f k-g-u $@
299
300$(srcdir)/ntp_keyword.h: $(srcdir)/keyword-gen-utd
301	@: do-nothing action to avoid default SCCS get
302	@: .h updated if needed by k-g-u-submake rule
303
304$(srcdir)/ntpd-opts.h: $(srcdir)/ntpd-opts.c
305	@: do-nothing action to avoid default SCCS get, .h built with .c
306
307$(srcdir)/ntpd-opts.c: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
308	$(run_ag) ntpd-opts.def
309
310###
311
312$(srcdir)/ntpd.1ntpdman: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
313	$(run_ag) -DMAN_SECTION=1ntpdman -Tagman-cmd.tpl ntpd-opts.def
314
315$(srcdir)/ntpd.man.in: $(srcdir)/ntpd.1ntpdman $(top_srcdir)/sntp/scripts/mansec2subst.sed
316	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntpd.1ntpdman > $(srcdir)/ntpd.man.in+
317	mv $(srcdir)/ntpd.man.in+ $(srcdir)/ntpd.man.in
318
319###
320
321$(srcdir)/ntpd.1ntpdmdoc: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
322	$(run_ag) -DMAN_SECTION=1ntpdmdoc -Tagmdoc-cmd.tpl ntpd-opts.def
323
324$(srcdir)/ntpd.mdoc.in: $(srcdir)/ntpd.1ntpdmdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
325	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntpd.1ntpdmdoc > $(srcdir)/ntpd.mdoc.in+
326	mv $(srcdir)/ntpd.mdoc.in+ $(srcdir)/ntpd.mdoc.in
327
328###
329
330ntpd.$(NTPD_MS): $(srcdir)/ntpd.$(MANTAGFMT).in $(top_builddir)/config.status
331	$(top_builddir)/config.status --file=ntpd.$(NTPD_MS)+:$(srcdir)/ntpd.$(MANTAGFMT).in
332	mv ntpd.$(NTPD_MS)+ ntpd.$(NTPD_MS)
333
334###
335
336$(srcdir)/invoke-ntp.conf.menu: $(srcdir)/invoke-ntp.conf.texi
337	@: do-nothing action to avoid default SCCS get, .menu built with .texi
338
339$(srcdir)/invoke-ntp.conf.texi: $(srcdir)/ntp.conf.def $(std_def_list)
340	$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.conf.def
341
342$(srcdir)/invoke-ntp.keys.menu: $(srcdir)/invoke-ntp.keys.texi
343	@: do-nothing action to avoid default SCCS get, .menu built with .texi
344
345$(srcdir)/invoke-ntp.keys.texi: $(srcdir)/ntp.keys.def $(std_def_list)
346	$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.keys.def
347
348$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
349	cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.conf.html ntp.conf.texi || true )
350
351$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
352	cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.keys.html ntp.keys.texi || true )
353
354$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(top_srcdir)/sntp/include/version.texi
355	cd $(srcdir) && ( makeinfo --force --html --no-split -o ntpd.html ntpd.texi || true )
356
357###
358
359$(srcdir)/ntp.conf.5man: $(srcdir)/ntp.conf.def $(std_def_list)
360	$(run_ag) -DMAN_SECTION=5man -Tagman-cmd.tpl ntp.conf.def
361
362$(srcdir)/ntp.conf.man.in: $(srcdir)/ntp.conf.5man $(top_srcdir)/sntp/scripts/mansec2subst.sed
363	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.conf.5man > $(srcdir)/ntp.conf.man.in+
364	mv $(srcdir)/ntp.conf.man.in+ $(srcdir)/ntp.conf.man.in
365
366###
367
368$(srcdir)/ntp.conf.5mdoc: $(srcdir)/ntp.conf.def $(std_def_list)
369	$(run_ag) -DMAN_SECTION=5mdoc -Tagmdoc-cmd.tpl ntp.conf.def
370
371$(srcdir)/ntp.conf.mdoc.in: $(srcdir)/ntp.conf.5mdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
372	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.conf.5mdoc > $(srcdir)/ntp.conf.mdoc.in+
373	mv $(srcdir)/ntp.conf.mdoc.in+ $(srcdir)/ntp.conf.mdoc.in
374
375###
376
377ntp.conf.5: $(srcdir)/ntp.conf.$(MANTAGFMT).in $(top_builddir)/config.status
378	$(top_builddir)/config.status --file=ntp.conf.5+:$(srcdir)/ntp.conf.$(MANTAGFMT).in
379	mv ntp.conf.5+ ntp.conf.5
380
381###
382
383$(srcdir)/ntp.keys.5man: $(srcdir)/ntp.keys.def $(std_def_list)
384	$(run_ag) -DMAN_SECTION=5man -Tagman-file.tpl ntp.keys.def
385
386$(srcdir)/ntp.keys.man.in: $(srcdir)/ntp.keys.5man $(top_srcdir)/sntp/scripts/mansec2subst.sed
387	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.keys.5man > $(srcdir)/ntp.keys.man.in+
388	mv $(srcdir)/ntp.keys.man.in+ $(srcdir)/ntp.keys.man.in
389
390###
391
392$(srcdir)/ntp.keys.5mdoc: $(srcdir)/ntp.keys.def $(std_def_list)
393	$(run_ag) -DMAN_SECTION=5mdoc -Tagmdoc-file.tpl ntp.keys.def
394
395$(srcdir)/ntp.keys.mdoc.in: $(srcdir)/ntp.keys.5mdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
396	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.keys.5mdoc > $(srcdir)/ntp.keys.mdoc.in+
397	mv $(srcdir)/ntp.keys.mdoc.in+ $(srcdir)/ntp.keys.mdoc.in
398
399###
400
401ntp.keys.5: $(srcdir)/ntp.keys.$(MANTAGFMT).in $(top_builddir)/config.status
402	$(top_builddir)/config.status --file=ntp.keys.5+:$(srcdir)/ntp.keys.$(MANTAGFMT).in
403	mv ntp.keys.5+ ntp.keys.5
404
405###
406
407$(srcdir)/invoke-ntpd.menu: $(srcdir)/invoke-ntpd.texi
408	@: do-nothing action to avoid default SCCS get, .menu built with .texi
409
410$(srcdir)/invoke-ntpd.texi: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
411	$(run_ag) -Tagtexi-cmd.tpl -DLEVEL=section ntpd-opts.def
412	$(top_srcdir)/scripts/build/check--help $@
413
414$(PROGRAMS): $(LDADD)
415
416compsave.conf: ntpd complete.conf
417	./ntpd --configfile complete.conf --saveconfigquit $@
418
419check-saveconfig: complete.conf compsave.conf
420	-diff -u complete.conf compsave.conf
421	cmp complete.conf compsave.conf && echo stamp > $@
422
423../libntp/libntpsim.a:
424	cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntpsim.a
425
426../libparse/libparse.a:
427	cd ../libparse && $(MAKE) $(AM_MAKEFLAGS) check-libparse
428
429$(top_srcdir)/sntp/scm-rev:
430	cd ../sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
431
432version.c: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/sntp/scm-rev
433	env CSET=`cat $(top_srcdir)/sntp/scm-rev` $(top_builddir)/scripts/build/mkver ntpd
434
435version.o: version.c
436	env CCACHE_DISABLE=1 $(COMPILE) -c version.c -o version.o
437
438$(srcdir)/Makefile.am:
439	@: do-nothing
440
441include $(top_srcdir)/bincheck.mf
442include $(top_srcdir)/check-libopts.mf
443include $(top_srcdir)/sntp/check-libntp.mf
444include $(top_srcdir)/depsver.mf
445include $(top_srcdir)/includes.mf
446