xref: /freebsd/contrib/ntp/ntpd/Makefile.am (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
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 check-pslsaveconfig
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-psl0		\
114	check-psl1		\
115	check-psl2		\
116	check-pslsaveconfig	\
117	check-saveconfig	\
118	compsave.conf		\
119	compsave.conf+		\
120	k-g-u-submake		\
121	psl0save.conf		\
122	psl0save.conf+		\
123	psl1save.conf		\
124	psl1save.conf+		\
125	psl2save.conf		\
126	psl2save.conf+		\
127	$(EXTRA_PROGRAMS)	\
128	$(NULL)
129
130EXTRA_DIST =			\
131	complete.conf.in	\
132	invoke-ntp.conf.menu	\
133	invoke-ntp.conf.texi	\
134	invoke-ntp.keys.menu	\
135	invoke-ntp.keys.texi	\
136	invoke-ntpd.menu	\
137	invoke-ntpd.texi	\
138	keyword-gen-utd		\
139	ntp.conf.5man		\
140	ntp.conf.5mdoc		\
141	ntp.conf.def		\
142	ntp.conf.man.in		\
143	ntp.conf.mdoc.in	\
144	ntp.conf.html		\
145	ntp.conf.texi		\
146	ntp.keys.5man		\
147	ntp.keys.5mdoc		\
148	ntp.keys.def		\
149	ntp.keys.man.in		\
150	ntp.keys.mdoc.in	\
151	ntp.keys.html		\
152	ntp.keys.texi		\
153	ntpd-opts.def		\
154	ntpd.1ntpdman		\
155	ntpd.1ntpdmdoc		\
156	ntpd.man.in		\
157	ntpd.mdoc.in		\
158	ntpd.html		\
159	ntpd.texi		\
160	ntpdbase-opts.def	\
161	psl0.conf		\
162	psl1.conf		\
163	psl2.conf		\
164	refclock_msfees.c	\
165	$(B_S_DIST)		\
166	$(NULL)
167
168###							Y2Kfixes
169check_PROGRAMS = @MAKE_CHECK_Y2K@
170EXTRA_PROGRAMS = check_y2k keyword-gen ntpd ntpdsim
171
172html_DATA=				\
173	$(srcdir)/ntp.conf.html		\
174	$(srcdir)/ntp.keys.html		\
175	$(srcdir)/ntpd.html		\
176	$(NULL)
177
178noinst_DATA =				\
179	$(srcdir)/invoke-ntp.conf.menu	\
180	$(srcdir)/invoke-ntp.conf.texi	\
181	$(srcdir)/invoke-ntp.keys.menu	\
182	$(srcdir)/invoke-ntp.keys.texi	\
183	$(srcdir)/invoke-ntpd.menu	\
184	$(srcdir)/invoke-ntpd.texi	\
185	$(srcdir)/ntp.conf.man.in	\
186	$(srcdir)/ntp.conf.mdoc.in	\
187	$(srcdir)/ntp.keys.man.in	\
188	$(srcdir)/ntp.keys.mdoc.in	\
189	$(srcdir)/ntpd.man.in		\
190	$(srcdir)/ntpd.mdoc.in		\
191	$(NULL)
192
193noinst_HEADERS =			\
194	declcond.h			\
195	ntp_leapsec.h			\
196	$(NULL)
197
198install-data-local: install-html
199
200run_ag=		cd $(srcdir) &&	env PATH="$(abs_builddir):$(PATH)" AUTOGEN_DNE_DATE=-D	\
201		autogen -L ../sntp/include -L ../sntp/ag-tpl --writable
202std_def_list =							\
203	$(top_srcdir)/sntp/include/debug-opt.def		\
204	$(top_srcdir)/sntp/include/autogen-version.def		\
205	$(top_srcdir)/sntp/include/copyright.def		\
206	$(top_srcdir)/sntp/include/homerc.def			\
207	$(top_srcdir)/sntp/include/ntp.lic			\
208	$(top_srcdir)/sntp/include/version.def			\
209	$(NULL)
210
211check-local: $(MAKE_CHECK_Y2K) $(CHECK_SAVECONFIG)
212	test -z "$(MAKE_CHECK_Y2K)" || ./$(MAKE_CHECK_Y2K)
213
214ntpd_SOURCES =			\
215	ntp_config.c		\
216	ntp_keyword.h		\
217	ntp_io.c		\
218	ntp_parser.y		\
219	ntp_scanner.c		\
220	ntp_scanner.h		\
221	ntpd.c			\
222	ntpd-opts.c		\
223	ntpd-opts.h		\
224	$(NULL)
225
226ntpdsim_SOURCES =		\
227	$(ntpd_SOURCES)		\
228	ntp_prio_q.c		\
229	ntpsim.c		\
230	$(NULL)
231
232# libntpd_a_SOURCES do not use #ifdef SIM
233
234libntpd_a_SOURCES =		\
235	cmd_args.c		\
236	jupiter.h		\
237	ntp_control.c		\
238	ntp_crypto.c		\
239	ntp_filegen.c		\
240	ntp_leapsec.c		\
241	ntp_loopfilter.c	\
242	ntp_monitor.c		\
243	ntp_peer.c		\
244	ntp_proto.c		\
245	ntp_refclock.c		\
246	ntp_request.c		\
247	ntp_restrict.c		\
248	ntp_signd.c		\
249	ntp_timer.c		\
250	ntp_util.c		\
251	ppsapi_timepps.h	\
252	rc_cmdlength.c		\
253	refclock_acts.c		\
254	refclock_arbiter.c	\
255	refclock_arc.c		\
256	refclock_as2201.c	\
257	refclock_atom.c		\
258	refclock_bancomm.c	\
259	refclock_chronolog.c	\
260	refclock_chu.c		\
261	refclock_conf.c		\
262	refclock_datum.c	\
263	refclock_dumbclock.c	\
264	refclock_fg.c		\
265	refclock_gpsdjson.c	\
266	refclock_gpsvme.c	\
267	refclock_heath.c	\
268	refclock_hopfser.c	\
269	refclock_hopfpci.c	\
270	refclock_hpgps.c	\
271	refclock_irig.c		\
272	refclock_jjy.c		\
273	refclock_jupiter.c	\
274	refclock_leitch.c	\
275	refclock_local.c	\
276	refclock_mx4200.c	\
277	refclock_neoclock4x.c	\
278	refclock_nmea.c		\
279	refclock_oncore.c	\
280	refclock_palisade.c	\
281	refclock_palisade.h	\
282	refclock_parse.c	\
283	refclock_pcf.c		\
284	refclock_pst.c		\
285	refclock_ripencc.c	\
286	refclock_shm.c		\
287	refclock_tpro.c		\
288	refclock_true.c		\
289	refclock_tt560.c	\
290	refclock_ulink.c	\
291	refclock_wwv.c		\
292	refclock_wwvb.c		\
293	refclock_zyfer.c	\
294	refclock_tsyncpci.c	\
295	$(NULL)
296
297k-g-u-submake: keyword-gen
298	./keyword-gen $(srcdir)/ntp_parser.h > k-g.out
299	@grep -v diff_ignore_line < k-g.out > cmp1
300	@grep -v diff_ignore_line < $(srcdir)/ntp_keyword.h > cmp2
301	@cmp cmp1 cmp2 > /dev/null || \
302		{ mv -f k-g.out $(srcdir)/ntp_keyword.h && \
303		  echo 'Generated changed ntp_keyword.h.' ;}
304	@[ ! -f k-g.out ] || \
305		{ rm k-g.out && echo 'ntp_keyword.h is up to date.' ;}
306	@rm cmp1 cmp2
307	@echo 'keyword-gen and ntp_keyword.h are up to date.' > $@
308
309$(srcdir)/keyword-gen-utd: $(srcdir)/keyword-gen.c $(srcdir)/ntp_parser.h
310	$(MAKE) $(AM_MAKEFLAGS) k-g-u-submake	# avoid explicit dependency
311	grep diff_ignore_line $(srcdir)/ntp_keyword.h > k-g-u
312	mv -f k-g-u $@
313
314$(srcdir)/ntp_keyword.h: $(srcdir)/keyword-gen-utd
315	@: do-nothing action to avoid default SCCS get
316	@: .h updated if needed by k-g-u-submake rule
317
318$(srcdir)/ntpd-opts.h: $(srcdir)/ntpd-opts.c
319	@: do-nothing action to avoid default SCCS get, .h built with .c
320
321$(srcdir)/ntpd-opts.c: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
322	$(run_ag) ntpd-opts.def
323
324###
325
326$(srcdir)/ntpd.1ntpdman: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
327	$(run_ag) -DMAN_SECTION=1ntpdman -Tagman-cmd.tpl ntpd-opts.def
328
329$(srcdir)/ntpd.man.in: $(srcdir)/ntpd.1ntpdman $(top_srcdir)/sntp/scripts/mansec2subst.sed
330	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntpd.1ntpdman > $(srcdir)/ntpd.man.in+
331	mv $(srcdir)/ntpd.man.in+ $(srcdir)/ntpd.man.in
332
333###
334
335$(srcdir)/ntpd.1ntpdmdoc: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
336	$(run_ag) -DMAN_SECTION=1ntpdmdoc -Tagmdoc-cmd.tpl ntpd-opts.def
337
338$(srcdir)/ntpd.mdoc.in: $(srcdir)/ntpd.1ntpdmdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
339	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntpd.1ntpdmdoc > $(srcdir)/ntpd.mdoc.in+
340	mv $(srcdir)/ntpd.mdoc.in+ $(srcdir)/ntpd.mdoc.in
341
342###
343
344ntpd.$(NTPD_MS): $(srcdir)/ntpd.$(MANTAGFMT).in $(top_builddir)/config.status
345	$(top_builddir)/config.status --file=ntpd.$(NTPD_MS)+:$(srcdir)/ntpd.$(MANTAGFMT).in
346	mv ntpd.$(NTPD_MS)+ ntpd.$(NTPD_MS)
347
348###
349
350$(srcdir)/invoke-ntp.conf.menu: $(srcdir)/invoke-ntp.conf.texi
351	@: do-nothing action to avoid default SCCS get, .menu built with .texi
352
353$(srcdir)/invoke-ntp.conf.texi: $(srcdir)/ntp.conf.def $(std_def_list)
354	$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.conf.def
355
356$(srcdir)/invoke-ntp.keys.menu: $(srcdir)/invoke-ntp.keys.texi
357	@: do-nothing action to avoid default SCCS get, .menu built with .texi
358
359$(srcdir)/invoke-ntp.keys.texi: $(srcdir)/ntp.keys.def $(std_def_list)
360	$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.keys.def
361
362$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(srcdir)/invoke-ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
363	cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.conf.html ntp.conf.texi || true )
364
365$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(srcdir)/invoke-ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
366	cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.keys.html ntp.keys.texi || true )
367
368$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(srcdir)/invoke-ntpd.texi $(top_srcdir)/sntp/include/version.texi
369	cd $(srcdir) && ( makeinfo --force --html --no-split -o ntpd.html ntpd.texi || true )
370
371###
372
373$(srcdir)/ntp.conf.5man: $(srcdir)/ntp.conf.def $(std_def_list)
374	$(run_ag) -DMAN_SECTION=5man -Tagman-cmd.tpl ntp.conf.def
375
376$(srcdir)/ntp.conf.man.in: $(srcdir)/ntp.conf.5man $(top_srcdir)/sntp/scripts/mansec2subst.sed
377	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.conf.5man > $(srcdir)/ntp.conf.man.in+
378	mv $(srcdir)/ntp.conf.man.in+ $(srcdir)/ntp.conf.man.in
379
380###
381
382$(srcdir)/ntp.conf.5mdoc: $(srcdir)/ntp.conf.def $(std_def_list)
383	$(run_ag) -DMAN_SECTION=5mdoc -Tagmdoc-cmd.tpl ntp.conf.def
384
385$(srcdir)/ntp.conf.mdoc.in: $(srcdir)/ntp.conf.5mdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
386	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.conf.5mdoc > $(srcdir)/ntp.conf.mdoc.in+
387	mv $(srcdir)/ntp.conf.mdoc.in+ $(srcdir)/ntp.conf.mdoc.in
388
389###
390
391ntp.conf.5: $(srcdir)/ntp.conf.$(MANTAGFMT).in $(top_builddir)/config.status
392	$(top_builddir)/config.status --file=ntp.conf.5+:$(srcdir)/ntp.conf.$(MANTAGFMT).in
393	mv ntp.conf.5+ ntp.conf.5
394
395###
396
397$(srcdir)/ntp.keys.5man: $(srcdir)/ntp.keys.def $(std_def_list)
398	$(run_ag) -DMAN_SECTION=5man -Tagman-file.tpl ntp.keys.def
399
400$(srcdir)/ntp.keys.man.in: $(srcdir)/ntp.keys.5man $(top_srcdir)/sntp/scripts/mansec2subst.sed
401	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.keys.5man > $(srcdir)/ntp.keys.man.in+
402	mv $(srcdir)/ntp.keys.man.in+ $(srcdir)/ntp.keys.man.in
403
404###
405
406$(srcdir)/ntp.keys.5mdoc: $(srcdir)/ntp.keys.def $(std_def_list)
407	$(run_ag) -DMAN_SECTION=5mdoc -Tagmdoc-file.tpl ntp.keys.def
408
409$(srcdir)/ntp.keys.mdoc.in: $(srcdir)/ntp.keys.5mdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
410	sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/ntp.keys.5mdoc > $(srcdir)/ntp.keys.mdoc.in+
411	mv $(srcdir)/ntp.keys.mdoc.in+ $(srcdir)/ntp.keys.mdoc.in
412
413###
414
415ntp.keys.5: $(srcdir)/ntp.keys.$(MANTAGFMT).in $(top_builddir)/config.status
416	$(top_builddir)/config.status --file=ntp.keys.5+:$(srcdir)/ntp.keys.$(MANTAGFMT).in
417	mv ntp.keys.5+ ntp.keys.5
418
419###
420
421$(srcdir)/invoke-ntpd.menu: $(srcdir)/invoke-ntpd.texi
422	@: do-nothing action to avoid default SCCS get, .menu built with .texi
423
424$(srcdir)/invoke-ntpd.texi: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
425	$(run_ag) -Tagtexi-cmd.tpl -DLEVEL=section ntpd-opts.def
426	$(top_srcdir)/scripts/build/check--help $@
427
428$(PROGRAMS): $(LDADD)
429
430check-saveconfig: complete.conf compsave.conf
431	-diff -u complete.conf compsave.conf
432	cmp complete.conf compsave.conf && echo stamp > $@
433
434compsave.conf: ntpd complete.conf
435	./ntpd --configfile complete.conf --saveconfigquit $@+
436	grep -v '^#' $@+ > $@
437
438check-pslsaveconfig: check-psl0 check-psl1 check-psl2
439	echo stamp > $@
440
441check-psl0: psl0.conf psl0save.conf
442	-diff -u $< psl0save.conf
443	cmp $< psl0save.conf && echo stamp > $@
444
445psl0save.conf: psl0.conf ntpd
446	./ntpd --configfile $< --saveconfigquit $@+
447	grep -v '^#' $@+ > $@
448
449check-psl1: psl1.conf psl1save.conf
450	-diff -u $< psl1save.conf
451	cmp $< psl1save.conf && echo stamp > $@
452
453psl1save.conf: psl1.conf ntpd
454	./ntpd --configfile $< --saveconfigquit $@+
455	grep -v '^#' $@+ > $@
456
457check-psl2: psl2.conf psl2save.conf
458	-diff -u $< psl2save.conf
459	cmp $< psl2save.conf && echo stamp > $@
460
461psl2save.conf: psl2.conf ntpd
462	./ntpd --configfile $< --saveconfigquit $@+
463	grep -v '^#' $@+ > $@
464
465../libntp/libntpsim.a:
466	cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntpsim.a
467
468../libparse/libparse.a:
469	cd ../libparse && $(MAKE) $(AM_MAKEFLAGS) check-libparse
470
471$(top_srcdir)/sntp/scm-rev:
472	cd ../sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
473
474version.c: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/sntp/scm-rev
475	env CSET=`cat $(top_srcdir)/sntp/scm-rev` $(top_builddir)/scripts/build/mkver ntpd
476
477version.o: version.c
478	env CCACHE_DISABLE=1 $(COMPILE) -c version.c -o version.o
479
480$(srcdir)/Makefile.am:
481	@: do-nothing
482
483include $(top_srcdir)/bincheck.mf
484include $(top_srcdir)/check-libopts.mf
485include $(top_srcdir)/sntp/check-libntp.mf
486include $(top_srcdir)/depsver.mf
487include $(top_srcdir)/includes.mf
488