xref: /netbsd-src/external/bsd/ntp/dist/ntpd/Makefile.am (revision 2b3d1ee8a773e028429b331332895d44f445d720)
1NULL=
2AUTOMAKE_OPTIONS=
3
4if NTP_BINSUBDIR_IS_BIN
5bin_PROGRAMS=	ntpd @MAKE_NTPDSIM@
6else
7sbin_PROGRAMS=	ntpd @MAKE_NTPDSIM@
8endif
9
10noinst_LIBRARIES=	libntpd.a
11
12AM_CPPFLAGS= -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include \
13	-I$(top_srcdir)/lib/isc/nothreads/include \
14	-I$(top_srcdir)/lib/isc/unix/include $(LIBOPTS_CFLAGS)
15
16# LDADD might need RESLIB and ADJLIB.
17LDADD=	version.o libntpd.a @LIBPARSE@
18AM_YFLAGS=	-d -t -r all
19
20if SAVECONFIG_ENABLED
21if NTP_CROSSCOMPILE
22CHECK_SAVECONFIG=
23else
24CHECK_SAVECONFIG= check-saveconfig
25endif
26else !SAVECONFIG_ENABLED
27CHECK_SAVECONFIG=
28endif
29
30#
31# VPHACK and VPHACK_AFTER are enabled on non-GNU makes (such as
32# BSD make) to work around issues specific to compiling
33# ntp_parser.y into ntp_parser.h and ntp_parser.c in a vPATH
34# configuration where we would like (for a change) the output
35# files ntp_parser.[ch] to be placed in the source directory,
36# as opposed to the build directory.  This allows a single
37# host of a flock configured with Bison to update ntp_parser.[ch]
38# used by the rest.
39#
40
41if VPATH_HACK
42VPHACK=	vphack
43VPHACK_AFTER= vphack_after
44else
45VPHACK=
46VPHACK_AFTER=
47endif
48
49vphack:
50	test -e ntp_parser.c || ln -s $(srcdir)/ntp_parser.c .
51	test -e ntp_parser.h || ln -s $(srcdir)/ntp_parser.h .
52
53#
54# ylwrap script which invokes Bison replaces ntp_parser.h
55# symlink with the updated file, when ntp_parser.h changes.
56# vphack_after detects this and copies the updated file to srcdir
57# and re-creates the ntp_parser.h symlink in its place.
58#
59
60vphack_after:
61	test -L ntp_parser.h || ( \
62		mv ntp_parser.h $(srcdir)/ntp_parser.h && \
63		ln -s $(srcdir)/ntp_parser.h . \
64		)
65
66# BUILT_SOURCES which should also be in EXTRA_DIST
67B_S_DIST=		\
68	ntpd-opts.c 	\
69	ntpd-opts.h 	\
70	$(NULL)
71
72BUILT_SOURCES=		\
73	$(VPHACK) 	\
74	ntp_parser.c 	\
75	ntp_parser.h 	\
76	$(VPHACK_AFTER)	\
77	$(B_S_DIST)	\
78	$(NULL)
79
80man_MANS=	$(srcdir)/ntpd.1
81
82# ntpdsim.1 is a remnant along with all the ntpdsim-opts.* files, the
83# simulator currently uses ntpd-opts.[ch].  This also means there is no
84# longer a reason to have ntpdbase-opts.def split off of ntpd-opts.def.
85
86# ntpd may need:
87# log10                               refclock_wwv.o
88# sqrt                                ntp_control.o
89# floor                               refclock_wwv.o
90# which are (usually) provided by -lm.
91ntpd_LDADD = $(LDADD) $(LIBOPTS_LDADD) ../libntp/libntp.a -lm @LCRYPTO@ @LSCF@
92ntpdsim_LDADD = $(LDADD) $(LIBOPTS_LDADD) ../libntp/libntpsim.a -lm @LCRYPTO@ @LSCF@
93ntpdsim_CFLAGS = $(CFLAGS) -DSIM
94check_y2k_LDADD = $(LDADD) ../libntp/libntp.a
95keyword_gen_LDADD = ../libntp/libntp.a	# we don't want $(LDADD) here
96
97DISTCLEANFILES =		\
98	keyword-gen		\
99	.version		\
100	version.c		\
101	$(NULL)
102
103CLEANFILES =			\
104	check-saveconfig	\
105	compsave.conf		\
106	k-g-u-submake		\
107	$(NULL)
108
109EXTRA_DIST =			\
110	complete.conf		\
111	keyword-gen-utd		\
112	ntpd.1			\
113	ntpd-opts.def		\
114	ntpd-opts.menu		\
115	ntpd-opts.texi		\
116	ntpdbase-opts.def	\
117	refclock_msfees.c	\
118	refclock_trak.c		\
119	$(B_S_DIST)		\
120	$(NULL)
121
122ETAGS_ARGS = Makefile.am
123###							Y2Kfixes
124check_PROGRAMS = @MAKE_CHECK_Y2K@
125EXTRA_PROGRAMS = check_y2k ntpdsim keyword-gen
126noinst_DATA =	$(srcdir)/ntpd-opts.texi $(srcdir)/ntpd-opts.menu
127run_ag=		cd $(srcdir) &&	env PATH="$(abs_builddir):$(PATH)"	\
128		autogen -L ../include --writable
129std_def_list=	$(top_srcdir)/include/autogen-version.def 	\
130		$(top_srcdir)/include/copyright.def 		\
131		$(top_srcdir)/include/version.def
132
133check-local: @MAKE_CHECK_Y2K@ $(CHECK_SAVECONFIG)
134	test -z "@MAKE_CHECK_Y2K@" || ./@MAKE_CHECK_Y2K@
135
136ntpd_SOURCES =			\
137	cmd_args.c		\
138	ntp_config.c		\
139	ntp_data_structures.c	\
140	ntp_keyword.h		\
141	ntp_io.c		\
142	ntp_parser.y		\
143	ntp_scanner.c		\
144	ntp_scanner.h		\
145	ntpd.c			\
146	ntpd-opts.c		\
147	ntpd-opts.h		\
148	$(NULL)
149
150ntpdsim_SOURCES =		\
151	$(ntpd_SOURCES)		\
152	ntpsim.c		\
153	$(NULL)
154
155# libntpd_a_SOURCES do not use #ifdef SIM
156
157libntpd_a_SOURCES =		\
158	jupiter.h		\
159	ntp_control.c		\
160	ntp_crypto.c		\
161	ntp_filegen.c		\
162	ntp_intres.c		\
163	ntp_loopfilter.c	\
164	ntp_monitor.c		\
165	ntp_peer.c		\
166	ntp_proto.c		\
167	ntp_refclock.c		\
168	ntp_request.c		\
169	ntp_restrict.c		\
170	ntp_signd.c		\
171	ntp_timer.c		\
172	ntp_util.c		\
173	ppsapi_timepps.h	\
174	refclock_acts.c		\
175	refclock_arbiter.c	\
176	refclock_arc.c		\
177	refclock_as2201.c	\
178	refclock_atom.c		\
179	refclock_bancomm.c	\
180	refclock_chronolog.c	\
181	refclock_chu.c		\
182	refclock_conf.c		\
183	refclock_datum.c	\
184	refclock_dumbclock.c	\
185	refclock_fg.c		\
186	refclock_gpsvme.c	\
187	refclock_heath.c	\
188	refclock_hopfser.c	\
189	refclock_hopfpci.c	\
190	refclock_hpgps.c	\
191	refclock_irig.c		\
192	refclock_jjy.c		\
193	refclock_jupiter.c	\
194	refclock_leitch.c	\
195	refclock_local.c	\
196	refclock_mx4200.c	\
197	refclock_neoclock4x.c	\
198	refclock_nmea.c		\
199	refclock_oncore.c	\
200	refclock_palisade.c	\
201	refclock_palisade.h	\
202	refclock_parse.c	\
203	refclock_pcf.c		\
204	refclock_pst.c		\
205	refclock_ripencc.c	\
206	refclock_shm.c		\
207	refclock_tpro.c		\
208	refclock_true.c		\
209	refclock_tt560.c	\
210	refclock_ulink.c	\
211	refclock_wwv.c		\
212	refclock_wwvb.c		\
213	refclock_zyfer.c	\
214	$(NULL)
215
216k-g-u-submake: keyword-gen
217	./keyword-gen $(srcdir)/ntp_parser.h > k-g.out
218	@grep -v diff_ignore_line < k-g.out > cmp1
219	@grep -v diff_ignore_line < $(srcdir)/ntp_keyword.h > cmp2
220	@cmp cmp1 cmp2 > /dev/null || \
221		{ mv -f k-g.out $(srcdir)/ntp_keyword.h && \
222		  echo 'Generated changed ntp_keyword.h.' ;}
223	@[ ! -f k-g.out ] || \
224		{ rm k-g.out && echo 'ntp_keyword.h is up to date.' ;}
225	@rm cmp1 cmp2
226	@echo 'keyword-gen and ntp_keyword.h are up to date.' > $@
227
228$(srcdir)/keyword-gen-utd: $(srcdir)/keyword-gen.c $(srcdir)/ntp_parser.h
229	$(MAKE) k-g-u-submake	# avoid explicit dependency
230	grep diff_ignore_line $(srcdir)/ntp_keyword.h > k-g-u
231	mv -f k-g-u $@
232
233$(srcdir)/ntp_keyword.h: $(srcdir)/keyword-gen-utd
234	@: do-nothing action to avoid default SCCS get
235	@: .h updated if needed by k-g-u-submake rule
236
237$(srcdir)/ntpd-opts.h: $(srcdir)/ntpd-opts.c
238	@: do-nothing action to avoid default SCCS get, .h built with .c
239
240$(srcdir)/ntpd-opts.c: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
241	$(run_ag) ntpd-opts.def
242
243$(srcdir)/ntpd.1: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
244	$(run_ag) -Tagman1.tpl -bntpd ntpd-opts.def
245
246$(srcdir)/ntpd-opts.menu: $(srcdir)/ntpd-opts.texi
247	@: do-nothing action to avoid default SCCS get, .menu built with .texi
248
249$(srcdir)/ntpd-opts.texi: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
250	$(run_ag) -Taginfo.tpl -DLEVEL=section ntpd-opts.def
251	$(top_srcdir)/scripts/check--help $@
252
253$(PROGRAMS): $(LDADD)
254
255compsave.conf: ntpd $(srcdir)/complete.conf
256	./ntpd --configfile $(srcdir)/complete.conf --saveconfigquit $@
257
258check-saveconfig: $(srcdir)/complete.conf compsave.conf
259	cmp $(srcdir)/complete.conf compsave.conf && echo stamp > $@
260
261../libopts/libopts.la:
262	cd ../libopts && $(MAKE) libopts.la
263
264../libntp/libntp.a:
265	cd ../libntp && $(MAKE) libntp.a
266
267../libparse/libparse.a:
268	cd ../libparse && $(MAKE) libparse.a
269
270$(top_srcdir)/version:
271	cd $(top_srcdir) && $(MAKE) version
272
273version.o: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/version
274	env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpd
275	$(COMPILE) -c version.c
276
277include $(top_srcdir)/bincheck.mf
278include $(top_srcdir)/depsver.mf
279