Makefile.am revision 285169
1## Makefile.am for JMK's SNTP, by Harlan Stenn
2
3ACLOCAL_AMFLAGS = -I m4 -I libevent/m4 -I libopts/m4
4
5NULL =
6
7AM_CFLAGS = $(CFLAGS_NTP)
8
9AM_CPPFLAGS  = $(SNTP_INCS)
10AM_CPPFLAGS += $(LIBOPTS_CFLAGS)
11AM_CPPFLAGS += $(CPPFLAGS_LIBEVENT)
12AM_CPPFLAGS += $(CPPFLAGS_NTP)
13
14AM_LDFLAGS = $(LDFLAGS_NTP)
15
16LDADD  = version.o
17LDADD += libsntp.a
18LDADD += $(LIBOPTS_LDADD)
19LDADD += $(LDADD_LIBEVENT)
20LDADD += ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM)
21LDADD += $(PTHREAD_LIBS)
22LDADD += $(LDADD_NTP)
23
24run_ag =	cd $(srcdir) &&	env PATH="$(abs_builddir):$(PATH)" AUTOGEN_DNE_DATE=-D	\
25		autogen -L include -L ag-tpl --writable
26std_def_list =						\
27	$(srcdir)/include/debug-opt.def			\
28	$(srcdir)/include/autogen-version.def 		\
29	$(srcdir)/include/copyright.def 		\
30	$(srcdir)/include/homerc.def 			\
31	$(srcdir)/include/ntp.lic 			\
32	$(srcdir)/include/version.def			\
33	$(NULL)
34
35EXTRA_PROGRAMS = sntp
36
37bin_PROGRAMS =		@SNTP_DB@
38libexec_PROGRAMS =	@SNTP_DL@
39sbin_PROGRAMS =		@SNTP_DS@
40
41##
42## DIST_SUBDIRS is typically automatically derived by automake including
43## all possible SUBDIRS values, as even items which are not built are
44## typically distributed.
45##
46## To allow us to avoid configuring the libevent tearoff entirely when
47## it is not needed, we define DIST_SUBDIRS manually excluding libevent
48## when not building it, and in that case arrange for its distribution
49## with EXTRA_DIST copying the entire directory and libevent-dist-hook
50## cleaning unwanted VCS remnants.
51##
52## When we are building libevent, it is distributed conventionally, by
53## recursive make dist in sntp including libevent.
54##
55
56SUBDIRS = include scripts unity
57DIST_SUBDIRS = include scripts unity
58
59if BUILD_LIBEVENT
60SUBDIRS += libevent
61DIST_SUBDIRS += libevent
62endif
63
64if NEED_LIBOPTS
65SUBDIRS += libopts
66endif
67
68if BUILD_SNTP
69noinst_LIBRARIES = libsntp.a
70SUBDIRS += tests
71endif
72
73DIST_SUBDIRS += libopts tests
74
75libsntp_a_SOURCES =		\
76	crypto.c		\
77	kod_management.c	\
78	log.c			\
79	main.c			\
80	networking.c		\
81	sntp-opts.c		\
82	utilities.c		\
83	$(NULL)
84
85sntp_SOURCES =		\
86	sntp.c		\
87	$(NULL)
88
89noinst_HEADERS =		\
90	crypto.h		\
91	data_formats.h		\
92	kod_management.h	\
93	log.h			\
94	main.h			\
95	networking.h		\
96	sntp-opts.h		\
97	tests_main.h		\
98	utilities.h		\
99	$(NULL)
100
101DISTCLEANFILES =			\
102	.version			\
103	version.c			\
104	config.log			\
105	$(man_MANS)			\
106	$(NULL)
107
108EXTRA_DIST =				\
109	$(srcdir)/COPYRIGHT		\
110	ag-tpl				\
111	deps-ver			\
112	invoke-sntp.menu		\
113	invoke-sntp.texi		\
114	@NTP_FORCE_LIBEVENT_DIST@	\
115	libpkgver 			\
116	loc				\
117	sntp-opts.def			\
118	sntp.1sntpman			\
119	sntp.1sntpmdoc			\
120	sntp.man.in			\
121	sntp.mdoc.in			\
122	sntp.html			\
123	sntp.texi			\
124	unity/auto			\
125	$(srcdir)/scm-rev		\
126	$(srcdir)/m4/version.m4		\
127	$(NULL)
128
129BUILT_SOURCES =				\
130	$(srcdir)/COPYRIGHT		\
131	libtool				\
132	$(srcdir)/sntp-opts.c		\
133	$(srcdir)/sntp-opts.h		\
134	check-scm-rev			\
135	$(srcdir)/include/version.def	\
136	$(srcdir)/m4/version.m4		\
137	$(srcdir)/include/version.texi	\
138	$(NULL)
139
140CLEANFILES =				\
141	built-sources-only		\
142	check-COPYRIGHT-submake		\
143	$(NULL)
144
145man1_MANS=
146man8_MANS=
147man_MANS=	sntp.$(SNTP_MS)
148
149## HMS: Real Soon Now...
150##info_TEXINFOS=	sntp.texi
151##sntp_TEXINFOS=	invoke-sntp.texi
152
153html_DATA=				\
154	$(srcdir)/sntp.html		\
155	$(NULL)
156
157noinst_DATA=				\
158	$(srcdir)/invoke-sntp.menu	\
159	$(srcdir)/invoke-sntp.texi	\
160	$(srcdir)/sntp.man.in		\
161	$(srcdir)/sntp.mdoc.in		\
162	$(NULL)
163
164install-data-local: install-html
165
166FRC:
167	@: do-nothing action to prevent default SCCS get
168	@: FRC "force" depends on nothing and is not a file, so is
169	@: always out-of-date causing targets which depend on it to
170	@: similarly always be outdated causing their rules to fire
171	@: each time they or a dependent is built.
172
173$(PROGRAMS): version.o
174
175## We probably need something about libevent, too
176## That is probably not possible since LDADD_LIBEVENT may be
177## non-file "-levent_core".
178
179version.c: $(sntp_OBJECTS) ../libntp/libntp.a Makefile $(srcdir)/scm-rev
180	env CSET=`cat $(srcdir)/scm-rev` $(top_builddir)/../scripts/build/mkver sntp
181
182version.o: version.c
183	env CCACHE_DISABLE=1 $(COMPILE) -c version.c -o version.o
184
185check-autogen-version.def: FRC
186	@cd $(srcdir)							\
187	&& test -r ../include/autogen-version.def			\
188	&& ( if cmp -s ../include/autogen-version.def autogen-version.def; \
189	   then : ;							\
190	   else cp ../include/autogen-version.def autogen-version.def;	 \
191		echo "Installing new sntp/autogen-version.def file";	\
192	   fi )
193
194$(srcdir)/autogen-version.def:
195	$(MAKE) $(AM_MAKEFLAGS) check-autogen-version.def
196
197built-sources-only: $(BUILT_SOURCES)
198	@: do-nothing action to avoid default SCCS get
199
200## HMS: The next bit is still suboptimal.  We'll get an error if this is
201## a bk repo and srcdir or scm-rev is unwritable.
202
203check-scm-rev: $(srcdir)/scm-rev
204	@: do-nothing
205
206$(srcdir)/scm-rev:
207	-test -r $(srcdir)/../SCCS/s.ChangeSet &&		\
208	    (bk version) >/dev/null 2>&1 &&			\
209	    cd $(srcdir)/.. &&					\
210	    x=`bk -R prs -hr+ -nd:I: ChangeSet` &&		\
211	    y=`cat sntp/scm-rev 2>/dev/null` || true &&		\
212	    case "$$x" in ''|$$y) ;; *) echo $$x > sntp/scm-rev ;; esac
213
214$(srcdir)/m4/version.m4: $(srcdir)/../packageinfo.sh
215	TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
216	../scripts/build/genver m4/version.m4
217
218$(srcdir)/include/version.def: $(srcdir)/../packageinfo.sh
219	TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
220	../scripts/build/genver include/version.def
221
222$(srcdir)/include/version.texi: $(srcdir)/../packageinfo.sh
223	TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
224	../scripts/build/genver include/version.texi
225
226$(srcdir)/../COPYRIGHT:
227	cd .. && $(MAKE) $(AM_MAKEFLAGS) COPYRIGHT-please
228
229check-COPYRIGHT-submake: $(srcdir)/../COPYRIGHT
230	@cmp -s $(srcdir)/../COPYRIGHT $(srcdir)/COPYRIGHT	\
231	 || { cp $(srcdir)/../COPYRIGHT $(srcdir)		\
232	      && echo 'updated sntp/COPYRIGHT installed' ;}
233	@echo 'submake avoided if this file is newer than parent COPYRIGHT' > $@
234
235check-COPYRIGHT: FRC
236	[ ! -r $(srcdir)/../COPYRIGHT ]					\
237	|| [ check-COPYRIGHT-submake -nt $(srcdir)/../COPYRIGHT ]	\
238	|| $(MAKE) $(AM_MAKEFLAGS) check-COPYRIGHT-submake
239
240$(srcdir)/COPYRIGHT: check-COPYRIGHT
241	@: do-nothing action to prevent any default
242
243$(srcdir)/sntp-opts.h: $(srcdir)/sntp-opts.c
244	@: do-nothing action to avoid default SCCS get, .h built with .c
245
246$(srcdir)/sntp-opts.c: $(srcdir)/sntp-opts.def $(std_def_list)
247	$(run_ag) sntp-opts.def
248
249###
250
251$(srcdir)/sntp.1sntpman: $(srcdir)/sntp-opts.def $(std_def_list)
252	$(run_ag) -DMAN_SECTION=1sntpman -Tagman-cmd.tpl sntp-opts.def
253
254$(srcdir)/sntp.man.in: $(srcdir)/sntp.1sntpman $(srcdir)/scripts/mansec2subst.sed
255	sed -f $(srcdir)/scripts/mansec2subst.sed $(srcdir)/sntp.1sntpman > $(srcdir)/sntp.man.in+
256	mv $(srcdir)/sntp.man.in+ $(srcdir)/sntp.man.in
257
258###
259
260$(srcdir)/sntp.1sntpmdoc: $(srcdir)/sntp-opts.def $(std_def_list)
261	$(run_ag) -DMAN_SECTION=1sntpmdoc -Tagmdoc-cmd.tpl sntp-opts.def
262
263$(srcdir)/sntp.mdoc.in: $(srcdir)/sntp.1sntpmdoc $(srcdir)/scripts/mansec2subst.sed
264	sed -f $(srcdir)/scripts/mansec2subst.sed $(srcdir)/sntp.1sntpmdoc > $(srcdir)/sntp.mdoc.in+
265	mv $(srcdir)/sntp.mdoc.in+ $(srcdir)/sntp.mdoc.in
266
267###
268
269sntp.$(SNTP_MS): $(srcdir)/sntp.$(MANTAGFMT).in $(top_builddir)/config.status
270	$(top_builddir)/config.status --file=sntp.$(SNTP_MS)+:$(srcdir)/sntp.$(MANTAGFMT).in
271	mv sntp.$(SNTP_MS)+ sntp.$(SNTP_MS)
272
273###
274
275$(srcdir)/invoke-sntp.menu: $(srcdir)/invoke-sntp.texi
276	@: do-nothing action to avoid default SCCS get, .menu built with .texi
277
278$(srcdir)/invoke-sntp.texi: $(srcdir)/sntp-opts.def $(std_def_list)
279	$(run_ag) -Tagtexi-cmd.tpl -DLEVEL=section sntp-opts.def
280	$(top_srcdir)/../scripts/build/check--help $@
281
282$(srcdir)/sntp.html: $(srcdir)/invoke-sntp.menu $(srcdir)/invoke-sntp.texi $(srcdir)/sntp.texi $(srcdir)/include/version.texi
283	cd $(srcdir) && ( makeinfo --force --html --no-split -o sntp.html sntp.texi || true )
284
285libtool: $(LIBTOOL_DEPS)
286	./config.status --recheck
287
288libevent-dist-hook:
289	if test -n "$(NTP_FORCE_LIBEVENT_DIST)" ; then rm -rf $(distdir)/libevent/autom4te.cache $(distdir)/libevent/config.h.in~ ; find $(distdir)/libevent -type d -name SCCS -print | xargs rm -rf ; fi
290
291dist-hook: libevent-dist-hook
292	@: do-nothing action to avoid default SCCS get
293
294include $(top_srcdir)/bincheck.mf
295include $(top_srcdir)/check-libntp.mf
296include $(top_srcdir)/check-libopts.mf
297include $(top_srcdir)/depsver.mf
298include $(top_srcdir)/includes.mf
299