Makefile.am revision 290001
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
41SUBDIRS = include scripts unity
42DIST_FAIL =
43
44if BUILD_LIBEVENT
45SUBDIRS += libevent
46else
47DIST_FAIL += "--enable-local-libevent"
48endif
49
50if NEED_LIBOPTS
51SUBDIRS += libopts
52endif
53
54if BUILD_SNTP
55noinst_LIBRARIES = libsntp.a
56SUBDIRS += tests
57endif
58
59libsntp_a_SOURCES =		\
60	crypto.c		\
61	kod_management.c	\
62	log.c			\
63	main.c			\
64	networking.c		\
65	sntp-opts.c		\
66	utilities.c		\
67	$(NULL)
68
69sntp_SOURCES =		\
70	sntp.c		\
71	$(NULL)
72
73noinst_HEADERS =		\
74	crypto.h		\
75	data_formats.h		\
76	kod_management.h	\
77	log.h			\
78	main.h			\
79	networking.h		\
80	sntp-opts.h		\
81	utilities.h		\
82	$(NULL)
83
84DISTCLEANFILES =			\
85	.version			\
86	version.c			\
87	config.log			\
88	$(man_MANS)			\
89	$(NULL)
90
91EXTRA_DIST =				\
92	$(srcdir)/COPYRIGHT		\
93	ag-tpl				\
94	deps-ver			\
95	invoke-sntp.menu		\
96	invoke-sntp.texi		\
97	@NTP_FORCE_LIBEVENT_DIST@	\
98	libpkgver 			\
99	loc				\
100	sntp-opts.def			\
101	sntp.1sntpman			\
102	sntp.1sntpmdoc			\
103	sntp.man.in			\
104	sntp.mdoc.in			\
105	sntp.html			\
106	sntp.texi			\
107	unity/auto			\
108	$(srcdir)/scm-rev		\
109	$(srcdir)/m4/version.m4		\
110	$(NULL)
111
112BUILT_SOURCES =				\
113	$(srcdir)/COPYRIGHT		\
114	libtool				\
115	$(srcdir)/sntp-opts.c		\
116	$(srcdir)/sntp-opts.h		\
117	check-scm-rev			\
118	$(srcdir)/include/version.def	\
119	$(srcdir)/m4/version.m4		\
120	$(srcdir)/include/version.texi	\
121	$(NULL)
122
123CLEANFILES =				\
124	built-sources-only		\
125	check-COPYRIGHT-submake		\
126	$(NULL)
127
128man1_MANS=
129man8_MANS=
130man_MANS=	sntp.$(SNTP_MS)
131
132## HMS: Real Soon Now...
133##info_TEXINFOS=	sntp.texi
134##sntp_TEXINFOS=	invoke-sntp.texi
135
136html_DATA=				\
137	$(srcdir)/sntp.html		\
138	$(NULL)
139
140noinst_DATA=				\
141	$(srcdir)/invoke-sntp.menu	\
142	$(srcdir)/invoke-sntp.texi	\
143	$(srcdir)/sntp.man.in		\
144	$(srcdir)/sntp.mdoc.in		\
145	$(NULL)
146
147install-data-local: install-html
148
149FRC:
150	@: do-nothing action to prevent default SCCS get
151	@: FRC "force" depends on nothing and is not a file, so is
152	@: always out-of-date causing targets which depend on it to
153	@: similarly always be outdated causing their rules to fire
154	@: each time they or a dependent is built.
155
156$(PROGRAMS): version.o
157
158## We probably need something about libevent, too
159## That is probably not possible since LDADD_LIBEVENT may be
160## non-file "-levent_core".
161
162version.c: $(sntp_OBJECTS) ../libntp/libntp.a Makefile $(srcdir)/scm-rev
163	env CSET=`cat $(srcdir)/scm-rev` $(top_builddir)/../scripts/build/mkver sntp
164
165version.o: version.c
166	env CCACHE_DISABLE=1 $(COMPILE) -c version.c -o version.o
167
168check-autogen-version.def: FRC
169	@cd $(srcdir)							\
170	&& test -r ../include/autogen-version.def			\
171	&& ( if cmp -s ../include/autogen-version.def autogen-version.def; \
172	   then : ;							\
173	   else cp ../include/autogen-version.def autogen-version.def;	 \
174		echo "Installing new sntp/autogen-version.def file";	\
175	   fi )
176
177$(srcdir)/autogen-version.def:
178	$(MAKE) $(AM_MAKEFLAGS) check-autogen-version.def
179
180built-sources-only: $(BUILT_SOURCES)
181	@: do-nothing action to avoid default SCCS get
182
183## HMS: The next bit is still suboptimal.  We'll get an error if this is
184## a bk repo and srcdir or scm-rev is unwritable.
185
186check-scm-rev: $(srcdir)/scm-rev
187	@: do-nothing
188
189$(srcdir)/scm-rev:
190	-test -r $(srcdir)/../SCCS/s.ChangeSet &&		\
191	    (bk version) >/dev/null 2>&1 &&			\
192	    cd $(srcdir)/.. &&					\
193	    x=`bk -R prs -hr+ -nd:I: ChangeSet` &&		\
194	    y=`cat sntp/scm-rev 2>/dev/null` || true &&		\
195	    case "$$x" in ''|$$y) ;; *) echo $$x > sntp/scm-rev ;; esac
196
197$(srcdir)/m4/version.m4: $(srcdir)/../packageinfo.sh
198	TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
199	../scripts/build/genver m4/version.m4
200
201$(srcdir)/include/version.def: $(srcdir)/../packageinfo.sh
202	TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
203	../scripts/build/genver include/version.def
204
205$(srcdir)/include/version.texi: $(srcdir)/../packageinfo.sh
206	TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
207	../scripts/build/genver include/version.texi
208
209$(srcdir)/../COPYRIGHT:
210	cd .. && $(MAKE) $(AM_MAKEFLAGS) COPYRIGHT-please
211
212check-COPYRIGHT-submake: $(srcdir)/../COPYRIGHT
213	@cmp -s $(srcdir)/../COPYRIGHT $(srcdir)/COPYRIGHT	\
214	 || { cp $(srcdir)/../COPYRIGHT $(srcdir)		\
215	      && echo 'updated sntp/COPYRIGHT installed' ;}
216	@echo 'submake avoided if this file is newer than parent COPYRIGHT' > $@
217
218check-COPYRIGHT: FRC
219	[ ! -r $(srcdir)/../COPYRIGHT ]					\
220	|| [ check-COPYRIGHT-submake -nt $(srcdir)/../COPYRIGHT ]	\
221	|| $(MAKE) $(AM_MAKEFLAGS) check-COPYRIGHT-submake
222
223$(srcdir)/COPYRIGHT: check-COPYRIGHT
224	@: do-nothing action to prevent any default
225
226$(srcdir)/sntp-opts.h: $(srcdir)/sntp-opts.c
227	@: do-nothing action to avoid default SCCS get, .h built with .c
228
229$(srcdir)/sntp-opts.c: $(srcdir)/sntp-opts.def $(std_def_list)
230	$(run_ag) sntp-opts.def
231
232###
233
234$(srcdir)/sntp.1sntpman: $(srcdir)/sntp-opts.def $(std_def_list)
235	$(run_ag) -DMAN_SECTION=1sntpman -Tagman-cmd.tpl sntp-opts.def
236
237$(srcdir)/sntp.man.in: $(srcdir)/sntp.1sntpman $(srcdir)/scripts/mansec2subst.sed
238	sed -f $(srcdir)/scripts/mansec2subst.sed $(srcdir)/sntp.1sntpman > $(srcdir)/sntp.man.in+
239	mv $(srcdir)/sntp.man.in+ $(srcdir)/sntp.man.in
240
241###
242
243$(srcdir)/sntp.1sntpmdoc: $(srcdir)/sntp-opts.def $(std_def_list)
244	$(run_ag) -DMAN_SECTION=1sntpmdoc -Tagmdoc-cmd.tpl sntp-opts.def
245
246$(srcdir)/sntp.mdoc.in: $(srcdir)/sntp.1sntpmdoc $(srcdir)/scripts/mansec2subst.sed
247	sed -f $(srcdir)/scripts/mansec2subst.sed $(srcdir)/sntp.1sntpmdoc > $(srcdir)/sntp.mdoc.in+
248	mv $(srcdir)/sntp.mdoc.in+ $(srcdir)/sntp.mdoc.in
249
250###
251
252sntp.$(SNTP_MS): $(srcdir)/sntp.$(MANTAGFMT).in $(top_builddir)/config.status
253	$(top_builddir)/config.status --file=sntp.$(SNTP_MS)+:$(srcdir)/sntp.$(MANTAGFMT).in
254	mv sntp.$(SNTP_MS)+ sntp.$(SNTP_MS)
255
256###
257
258$(srcdir)/invoke-sntp.menu: $(srcdir)/invoke-sntp.texi
259	@: do-nothing action to avoid default SCCS get, .menu built with .texi
260
261$(srcdir)/invoke-sntp.texi: $(srcdir)/sntp-opts.def $(std_def_list)
262	$(run_ag) -Tagtexi-cmd.tpl -DLEVEL=section sntp-opts.def
263	$(top_srcdir)/../scripts/build/check--help $@
264
265$(srcdir)/sntp.html: $(srcdir)/invoke-sntp.menu $(srcdir)/invoke-sntp.texi $(srcdir)/sntp.texi $(srcdir)/include/version.texi
266	cd $(srcdir) && ( makeinfo --force --html --no-split -o sntp.html sntp.texi || true )
267
268libtool: $(LIBTOOL_DEPS)
269	./config.status --recheck
270
271# HMS: libevent/ is a target if it's in EXTRA_DIST via NTP_FORCE_LIBEVENT_DIST.
272# Note that libevent/ is already in DIST_SUBDIRS (implicit in Makefile.am
273# but explicit in Makefile.in).  This check doesn't help with distclean.
274libevent: distdir-pre-check
275
276# HMS: Stops the build for gmake or pmake
277distdir-pre-check:
278	case "$(DIST_FAIL)" in	\
279	 '')  ;;		\
280	 *) $(error re-run configure adding $(DIST_FAIL) if you want to make a distribution.);	\
281	    echo "re-run configure adding $(DIST_FAIL) if you want to make a distribution.";	\
282	    exit 1 ;;		\
283	esac
284
285include $(top_srcdir)/bincheck.mf
286include $(top_srcdir)/check-libntp.mf
287include $(top_srcdir)/check-libopts.mf
288include $(top_srcdir)/depsver.mf
289include $(top_srcdir)/includes.mf
290