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