xref: /netbsd/external/bsd/ntp/dist/ntpd/Makefile.am (revision 6550d01e)
1NULL=
2AUTOMAKE_OPTIONS=
3
4bindir=	${exec_prefix}/${BINSUBDIR}
5
6bin_PROGRAMS=	ntpd @MAKE_NTPDSIM@
7
8noinst_LIBRARIES=	libntpd.a
9
10AM_CPPFLAGS= -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include \
11	-I$(top_srcdir)/lib/isc/nothreads/include \
12	-I$(top_srcdir)/lib/isc/unix/include $(LIBOPTS_CFLAGS)
13
14# LDADD might need RESLIB and ADJLIB.
15LDADD=	version.o libntpd.a @LIBPARSE@
16AM_YFLAGS=	-d -t -r all
17
18if SAVECONFIG_ENABLED
19if NTP_CROSSCOMPILE
20CHECK_SAVECONFIG=
21else
22CHECK_SAVECONFIG= check-saveconfig
23endif
24else !SAVECONFIG_ENABLED
25CHECK_SAVECONFIG=
26endif
27
28if NTP_CROSSCOMPILE
29NTP_KEYWORD_OUT=ntp_keyword.dummy
30else
31NTP_KEYWORD_OUT=ntp_keyword.out
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
70BUILT_SOURCES=	$(VPHACK) ntp_parser.c ntp_parser.h $(VPHACK_AFTER) \
71	ntp_keyword.h ntpd-opts.c ntpd-opts.h ntpd.1 ntpd-opts.texi \
72	ntpd-opts.menu
73
74man_MANS=	ntpd.1
75
76# ntpdsim.1 is a remnant along with all the ntpdsim-opts.* files, the
77# simulator currently uses ntpd-opts.[ch].  This also means there is no
78# longer a reason to have ntpdbase-opts.def split off of ntpd-opts.def.
79
80# ntpd may need:
81# log10                               refclock_wwv.o
82# sqrt                                ntp_control.o
83# floor                               refclock_wwv.o
84# which are (usually) provided by -lm.
85keyword_gen_LDADD = ../libntp/libntp.a
86ntpd_LDADD = $(LDADD) -lm @LCRYPTO@ @LSCF@ $(LIBOPTS_LDADD) ../libntp/libntp.a
87ntpdsim_LDADD = $(LDADD) -lm @LCRYPTO@ @LSCF@ $(LIBOPTS_LDADD) ../libntp/libntpsim.a
88ntpdsim_CFLAGS = $(CFLAGS) -DSIM
89check_y2k_LDADD = $(LDADD) ../libntp/libntp.a
90DISTCLEANFILES = keyword-gen .version version.c
91CLEANFILES = check-saveconfig compsave.conf ntp_keyword.out \
92	ntp_keyword.dummy
93EXTRA_DIST = \
94	complete.conf		\
95	ntpd-opts.def		\
96	ntpdbase-opts.def	\
97	ntp_keyword.h		\
98	refclock_msfees.c	\
99	refclock_trak.c		\
100	$(BUILT_SOURCES)	\
101	$(NULL)
102ETAGS_ARGS = Makefile.am
103###							Y2Kfixes
104check_PROGRAMS = @MAKE_CHECK_Y2K@
105EXTRA_PROGRAMS = check_y2k ntpdsim keyword-gen
106run_ag=		cd $(srcdir) &&					\
107		env PATH="$(abs_builddir):$(PATH)"		\
108		autogen -L ../include --writable
109std_def_list=	$(top_srcdir)/include/autogen-version.def 	\
110		$(top_srcdir)/include/copyright.def 		\
111		$(top_srcdir)/include/version.def
112
113check-local: @MAKE_CHECK_Y2K@ $(CHECK_SAVECONFIG)
114	test -z "@MAKE_CHECK_Y2K@" || ./@MAKE_CHECK_Y2K@
115
116ntpd_SOURCES =			\
117	cmd_args.c		\
118	ntp_config.c		\
119	ntp_data_structures.c	\
120	ntp_io.c		\
121	ntp_parser.y		\
122	ntp_scanner.c		\
123	ntp_scanner.h		\
124	ntpd.c			\
125	ntpd-opts.c		\
126	ntpd-opts.h		\
127	$(NULL)
128
129ntpdsim_SOURCES =		\
130	$(ntpd_SOURCES)		\
131	ntpsim.c		\
132	$(NULL)
133
134# libntpd_a_SOURCES do not use #ifdef SIM
135
136libntpd_a_SOURCES =		\
137	jupiter.h		\
138	ntp_control.c		\
139	ntp_crypto.c		\
140	ntp_filegen.c		\
141	ntp_intres.c		\
142	ntp_loopfilter.c	\
143	ntp_monitor.c		\
144	ntp_peer.c		\
145	ntp_proto.c		\
146	ntp_refclock.c		\
147	ntp_request.c		\
148	ntp_restrict.c		\
149	ntp_signd.c		\
150	ntp_timer.c		\
151	ntp_util.c		\
152	ppsapi_timepps.h	\
153	refclock_acts.c		\
154	refclock_arbiter.c	\
155	refclock_arc.c		\
156	refclock_as2201.c	\
157	refclock_atom.c		\
158	refclock_bancomm.c	\
159	refclock_chronolog.c	\
160	refclock_chu.c		\
161	refclock_conf.c		\
162	refclock_datum.c	\
163	refclock_dumbclock.c	\
164	refclock_fg.c		\
165	refclock_gpsvme.c	\
166	refclock_heath.c	\
167	refclock_hopfser.c	\
168	refclock_hopfpci.c	\
169	refclock_hpgps.c	\
170	refclock_irig.c		\
171	refclock_jjy.c		\
172	refclock_jupiter.c	\
173	refclock_leitch.c	\
174	refclock_local.c	\
175	refclock_mx4200.c	\
176	refclock_neoclock4x.c	\
177	refclock_nmea.c		\
178	refclock_oncore.c	\
179	refclock_palisade.c	\
180	refclock_palisade.h	\
181	refclock_parse.c	\
182	refclock_pcf.c		\
183	refclock_pst.c		\
184	refclock_ripencc.c	\
185	refclock_shm.c		\
186	refclock_tpro.c		\
187	refclock_true.c		\
188	refclock_tt560.c	\
189	refclock_ulink.c	\
190	refclock_wwv.c		\
191	refclock_wwvb.c		\
192	refclock_zyfer.c	\
193	$(NULL)
194
195ntp_keyword.out: keyword-gen
196	./keyword-gen $(srcdir)/ntp_parser.h > $@
197	grep -v diff_ignore_line < $(srcdir)/ntp_keyword.h > cmp1
198	grep -v diff_ignore_line < $@ > cmp2
199	cmp cmp1 cmp2 > /dev/null || cp $@ $(srcdir)/ntp_keyword.h
200	rm cmp1 cmp2
201
202ntp_keyword.dummy:
203	echo stamp > $@
204
205$(srcdir)/ntp_keyword.h: $(NTP_KEYWORD_OUT)
206	@: do-nothing action to avoid default SCCS get
207	@: .h updated if needed by ntp_keyword.out rule
208
209$(srcdir)/ntpd-opts.h: $(srcdir)/ntpd-opts.c
210	@: do-nothing action to avoid default SCCS get, .h built with .c
211
212$(srcdir)/ntpd-opts.c: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
213	$(run_ag) ntpd-opts.def
214
215$(srcdir)/ntpd.1: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
216	$(run_ag) -Tagman1.tpl -bntpd ntpd-opts.def
217
218$(srcdir)/ntpd-opts.texi $(srcdir)/ntpd-opts.menu: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
219	$(MAKE) ntpd	# aginfo.tpl runs the binary to extract --help usage text
220	$(run_ag) -Taginfo.tpl -DLEVEL=section ntpd-opts.def
221
222$(PROGRAMS): $(LDADD)
223
224compsave.conf: ntpd $(srcdir)/complete.conf
225	./ntpd --configfile $(srcdir)/complete.conf --saveconfigquit $@
226
227check-saveconfig: $(srcdir)/complete.conf compsave.conf
228	cmp $(srcdir)/complete.conf compsave.conf && echo stamp > $@
229
230../libntp/libntp.a:
231	cd ../libntp && $(MAKE) libntp.a
232
233../libparse/libparse.a:
234	cd ../libparse && $(MAKE)
235
236$(top_srcdir)/version :
237	cd $(top_srcdir) && $(MAKE) version
238
239version.o: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/version
240	env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpd
241	$(COMPILE) -c version.c
242
243include $(top_srcdir)/bincheck.mf
244include $(top_srcdir)/depsver.mf
245