chiark / gitweb /
Build: Overhaul build system.
[mLib] / Makefile.am
CommitLineData
a0150d8d
MW
1### -*-Makefile-*-
2###
3### Building the distribution
4###
5### (c) 1998 Straylight/Edgeware
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This file is part of the mLib utilities library.
11###
12### mLib is free software; you can redistribute it and/or modify
13### it under the terms of the GNU Library General Public License as
14### published by the Free Software Foundation; either version 2 of the
15### License, or (at your option) any later version.
16###
17### mLib is distributed in the hope that it will be useful,
18### but WITHOUT ANY WARRANTY; without even the implied warranty of
19### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20### GNU Library General Public License for more details.
21###
22### You should have received a copy of the GNU Library General Public
23### License along with mLib; if not, write to the Free
24### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25### MA 02111-1307, USA.
26
27pkglibexecdir = $(libexecdir)/$(PACKAGE)
28
29SUBDIRS =
30BUILT_SOURCES =
31bin_PROGRAMS =
32noinst_PROGRAMS =
33lib_LTLIBRARIES =
34noinst_LTLIBRARIES =
35pkglibexec_PROGRAMS =
36pkginclude_HEADERS =
37EXTRA_DIST =
38CLEANFILES =
39DISTCLEANFILES =
40
41confsubst = $(top_srcdir)/config/confsubst
42
43SUBSTITUTIONS = \
44 prefix=$(prefix) exec_prefix=$(exec_prefix) \
45 libdir=$(libdir) includedir=$(includedir) \
46 bindir=$(bindir) sbindir=$(sbindir) \
47 PACKAGE=$(PACKAGE) VERSION=$(VERSION)
48
49###--------------------------------------------------------------------------
50### Library.
51
52lib_LTLIBRARIES += libmLib.la
53libmLib_la_LDFLAGS = -version-info $(LIBTOOL_VERSION_INFO)
54libmLib_la_SOURCES =
55libmLib_la_LIBADD =
56
57pkgconfigdir = $(libdir)/pkgconfig
58pkgconfig_DATA = mLib.pc
59EXTRA_DIST += mLib.pc.in
60CLEANFILES += mLib.pc
61
62mLib.pc: mLib.pc.in Makefile
63 $(confsubst) $(srcdir)/mLib.pc.in >$@.new $(SUBSTITUTIONS) && \
64 mv $@.new $@
65
66###--------------------------------------------------------------------------
67### Testing.
68
69check: tests
70.PHONY: check tests
71
72TEST_CPPFLAGS = -DTEST_RIG -DSRCDIR="\"(srcdir)\"" $(AM_CPPFLAGS)
73
74LDADD = libmLib.la
75
76###--------------------------------------------------------------------------
77### Utilities.
78
79noinst_LTLIBRARIES += libutils.la
80libutils_la_SOURCES =
81libutils_la_LIBADD =
82libmLib_la_LIBADD += libutils.la
83
84## Utility macros.
85pkginclude_HEADERS += macros.h
86
87## Alignment.
88pkginclude_HEADERS += align.h
89
90## Bit manipulation.
91pkginclude_HEADERS += bits.h
92
93EXTRA_DIST += bits.in bits-testgen.c
94tests:: bits.t bits.in
95 ./bits.t -f $(srcdir)/bits.in
b7580524 96
a0150d8d
MW
97noinst_PROGRAMS += bits.t
98bits_t_SOURCES = bits.c
99bits_t_CPPFLAGS = $(TEST_CPPFLAGS)
100bits_t_LDFLAGS = -static
101
102## Exceptions.
103pkginclude_HEADERS += exc.h
104libmLib_la_SOURCES += exc.c
105
106## String handling.
107pkginclude_HEADERS += str.h
108libutils_la_SOURCES += str.c
109
110## Version comparison.
111pkginclude_HEADERS += versioncmp.h
112libmLib_la_SOURCES += versioncmp.c
113
114EXTRA_DIST += versioncmp.in
115tests:: versioncmp.t versioncmp.in
116 ./versioncmp.t -f $(srcdir)/versioncmp.in
117
118noinst_PROGRAMS += versioncmp.t
119versioncmp_t_SOURCES = versioncmp-test.c
120versioncmp_t_CPPFLAGS = $(TEST_CPPFLAGS)
121versioncmp_t_LDFLAGS = -static
122
123###--------------------------------------------------------------------------
124### Memory allocation.
125
126## Memory allocation.
127pkginclude_HEADERS += alloc.h arena.h sub.h
128libmLib_la_SOURCES += alloc.c arena.c sub.c
129
130## Pool allocator.
131pkginclude_HEADERS += pool.h
132libmLib_la_SOURCES += pool.c pool-file.c pool-sub.c
b7580524 133
a0150d8d
MW
134###--------------------------------------------------------------------------
135### Hashing.
136
137## CRC32.
138pkginclude_HEADERS += crc32.h
139libmLib_la_SOURCES += crc32.c crc32-tab.c
140
141bin_PROGRAMS += crc-mktab
142crc_mktab_SOURCES = crc-mktab.c $(UTIL_SOURCES)
143crc_mktab_LDADD = libutils.la
144
145BUILT_SOURCES += crc32-tab.c
146CLEANFILES += crc32-tab.c
147crc32-tab.c: crc-mktab$(EXEEXT)
148 ./crc-mktab -o $@.new \
149 -p0x04c11db7 -b32 -B8 -r -c \
150 -scrc32_table -icrc32.h -tuint32 && \
151 mv $@.new $@
152
153## Universal hashing.
154pkginclude_HEADERS += unihash.h
155libutils_la_SOURCES += unihash.c
156libmLib_la_SOURCES += unihash-global.c
157BUILT_SOURCES += unihash-global.c
158
159bin_PROGRAMS += unihash-mkstatic
160unihash_mkstatic_SOURCES = unihash-mkstatic.c
161unihash_mkstatic_LDADD = libutils.la
162
163BUILT_SOURCES += unihash-global.c
164CLEANFILES += unihash-global.c
1a6043f9 165unihash-global.c: unihash-mkstatic$(EXEEXT)
a0150d8d
MW
166 ./unihash-mkstatic -c -sunihash_global -iunihash.h -o$@.new && \
167 mv $@.new $@
168
169noinst_PROGRAMS += unihash.t
170unihash_t_SOURCES = unihash.c
171unihash_t_CPPFLAGS = $(TEST_CPPFLAGS)
172unihash_t_LDFLAGS = -static
173
174tests:: unihash.t unihash.in
175 ./unihash.t -f unihash.in
176
177EXTRA_DIST += unihash-check.pl
178CLEANFILES += unihash.in
179unihash.in: unihash-check.pl
180 perl $(srcdir)/unihash-check.pl >$@.new && mv $@.new $@
181
182###--------------------------------------------------------------------------
183### Data structures.
184
185## Dynamic strings.
186pkginclude_HEADERS += dstr.h dspool.h
187libmLib_la_SOURCES += dstr.c dputf.c dspool.c
188
189## Buffers.
190pkginclude_HEADERS += buf.h
191libmLib_la_SOURCES += buf.c buf-dstr.c
192
193## Dynamic arrays.
194pkginclude_HEADERS += darray.h
195libmLib_la_SOURCES += darray.c
196
197CLEANFILES += da.out
198tests:: darray.t da.in da.ref
199 ./darray.t <da.in >da.out
d5679ed0 200 cmp da.out da.ref
a0150d8d
MW
201 @echo "darray OK"
202
203noinst_PROGRAMS += darray.t
204darray_t_SOURCES = da-test.c
205darray_t_CPPFLAGS = $(TEST_CPPFLAGS)
206darray_t_LDFLAGS = -static
207
208EXTRA_DIST += da-gtest
209CLEANFILES += da.in
210da.in: da-gtest
211 perl $(srcdir)/da-gtest 10000 >$@.new && mv $@.new $@
212
213EXTRA_DIST += da-ref
214CLEANFILES += da.ref
215da.ref: da-ref da.in
216 perl $(srcdir)/da-ref <da.in >$@.new && mv $@.new $@
217
218## Hash tables.
219pkginclude_HEADERS += hash.h
220libmLib_la_SOURCES += hash.c
221
222## Symbol tables.
223pkginclude_HEADERS += sym.h
224libmLib_la_SOURCES += sym.c
225
226CLEANFILES += sym.out
227tests:: sym.t sym.in sym.ref
d5679ed0 228 ./sym.t <sym.in >sym.out
229 cmp sym.out sym.ref
a0150d8d
MW
230 @echo "sym OK"
231
232noinst_PROGRAMS += sym.t
233sym_t_SOURCES = sym-test.c
234sym_t_CPPFLAGS = $(TEST_CPPFLAGS)
235sym_t_LDFLAGS = -static
21c22b5c 236
a0150d8d
MW
237EXTRA_DIST += sym-gtest
238CLEANFILES += sym.in
239sym.in: sym-gtest
240 perl $(srcdir)/sym-gtest 10000 >$@.new && mv $@.new $@
241
242EXTRA_DIST += sym-ref
243CLEANFILES += sym.ref
244sym.ref: sym-ref sym.in
245 perl $(srcdir)/sym-ref <sym.in >$@.new && mv $@.new $@
246
247## Atoms.
248pkginclude_HEADERS += atom.h
249libmLib_la_SOURCES += atom.c
250
251## Association tables.
252pkginclude_HEADERS += assoc.h
253libmLib_la_SOURCES += assoc.c
254
255CLEANFILES += assoc.out
256tests:: assoc.t sym.in sym.ref
d5679ed0 257 ./assoc.t <sym.in >assoc.out
258 cmp assoc.out sym.ref
a0150d8d 259 @echo "sym OK"
d5679ed0 260
a0150d8d
MW
261noinst_PROGRAMS += assoc.t
262assoc_t_SOURCES = assoc-test.c
263assoc_t_CPPFLAGS = $(TEST_CPPFLAGS)
264assoc_t_LDFLAGS = -static
265
266###--------------------------------------------------------------------------
267### User interface.
268
269## Option parsing.
270noinst_LTLIBRARIES += libmdwopt.la
271pkginclude_HEADERS += mdwopt.h
272libmdwopt_la_SOURCES = mdwopt.c
273libmdwopt_la_CPPFLAGS = $(AM_CPPFLAGS) -DBUILDING_MLIB
274libutils_la_LIBADD += libmdwopt.la
275
276## Program naming.
277pkginclude_HEADERS += quis.h
278libutils_la_SOURCES += quis.c pquis.c
279
280## Error reporting.
281pkginclude_HEADERS += report.h
282libutils_la_SOURCES += report.c
3048fcf9 283
a0150d8d
MW
284###--------------------------------------------------------------------------
285### Encoding and decoding.
286
287## form-urlencoded
288pkginclude_HEADERS += url.h
289libmLib_la_SOURCES += url.c
290
291## base64
292pkginclude_HEADERS += base64.h
293libmLib_la_SOURCES += base64.c
294
295EXTRA_DIST += base64.in base64.ref
296CLEANFILES += base64.out
297tests:: base64.t base64.in base64.ref
d5679ed0 298 ./base64.t <$(srcdir)/base64.in >base64.out
299 cmp base64.out $(srcdir)/base64.ref
300 ./base64.t -d <$(srcdir)/base64.ref >base64.out
301 cmp base64.out $(srcdir)/base64.in
a0150d8d
MW
302 @echo "base64 OK"
303
304noinst_PROGRAMS += base64.t
305base64_t_SOURCES = base64.c
306base64_t_CPPFLAGS = $(TEST_CPPFLAGS)
307base64_t_LDFLAGS = -static
308
309## base32
310pkginclude_HEADERS += base32.h
311libmLib_la_SOURCES += base32.c
312
313EXTRA_DIST += base32.in base32.ref
314CLEANFILES += base32.out
315tests:: base32.t base32.in base32.ref
1c4fa429 316 ./base32.t <$(srcdir)/base32.in >base32.out
317 cmp base32.out $(srcdir)/base32.ref
318 ./base32.t -d <$(srcdir)/base32.ref >base32.out
319 cmp base32.out $(srcdir)/base32.in
a0150d8d
MW
320 @echo "base32 OK"
321
322noinst_PROGRAMS += base32.t
323base32_t_SOURCES = base32.c
324base32_t_CPPFLAGS = $(TEST_CPPFLAGS)
325base32_t_LDFLAGS = -static
326
327## hex
328pkginclude_HEADERS += hex.h
329libmLib_la_SOURCES += hex.c
330
331EXTRA_DIST += hex.in hex.ref
332CLEANFILES += hex.out
333tests:: hex.t hex.in hex.ref
d5679ed0 334 ./hex.t <$(srcdir)/hex.in >hex.out
335 cmp hex.out $(srcdir)/hex.ref
336 ./hex.t -d <$(srcdir)/hex.ref >hex.out
337 cmp hex.out $(srcdir)/hex.in
a0150d8d
MW
338 @echo "hex OK"
339
340noinst_PROGRAMS += hex.t
341hex_t_SOURCES = hex.c
342hex_t_CPPFLAGS = $(TEST_CPPFLAGS)
343hex_t_LDFLAGS = -static
344
345###--------------------------------------------------------------------------
346### System utilities.
347
348## Daemons.
349pkginclude_HEADERS += daemonize.h
350libmLib_la_SOURCES += daemonize.c
351
352## Environment variables.
353pkginclude_HEADERS += env.h
354libmLib_la_SOURCES += env.c
355
356## File and descriptor flags.
357pkginclude_HEADERS += fdflags.h
358libmLib_la_SOURCES += fdflags.c
359
360## File descriptor passing.
361pkginclude_HEADERS += fdpass.h
362libmLib_la_SOURCES += fdpass.c
363
364## Watching files for modification.
365pkginclude_HEADERS += fwatch.h
366libmLib_la_SOURCES += fwatch.c
367
368## File locking.
369pkginclude_HEADERS += lock.h
370libmLib_la_SOURCES += lock.c
371
372## Time arithmetic.
373pkginclude_HEADERS += tv.h
374libmLib_la_SOURCES += tv.c
375
376###--------------------------------------------------------------------------
377### Buffering.
378
379## Line buffering.
380pkginclude_HEADERS += lbuf.h
381libmLib_la_SOURCES += lbuf.c
382
383## Packet buffering.
384pkginclude_HEADERS += pkbuf.h
385libmLib_la_SOURCES += pkbuf.c
386
387###--------------------------------------------------------------------------
388### Network utilities.
389
390## Core event selection.
391pkginclude_HEADERS += sel.h
392libmLib_la_SOURCES += sel.c
393
394## Waiting for buffers to fill.
395pkginclude_HEADERS += selbuf.h selpk.h
396libmLib_la_SOURCES += selbuf.c selpk.c
397
398## RFC931 identification.
399pkginclude_HEADERS += ident.h
400libmLib_la_SOURCES += ident.c
401
402## Nonblocking connections.
403pkginclude_HEADERS += conn.h
404libmLib_la_SOURCES += conn.c
405
406## Signal handling
407pkginclude_HEADERS += sig.h
408libmLib_la_SOURCES += sig.c
409
410## Name resolution.
411pkginclude_HEADERS += bres.h
412
413if WITH_ADNS
414libmLib_la_SOURCES += bres-adns.c
415else
416libmLib_la_SOURCES += bres.c
417pkglibexec_PROGRAMS += bres
418bres_SOURCES = bres.c
419bres_CPPFLAGS = -DBRES_STANDALONE $(AM_CPPFLAGS)
420bres_LDADD =
421endif
422
423###--------------------------------------------------------------------------
424### Testing and debugging.
425
426## Tracing.
427pkginclude_HEADERS += trace.h
428libmLib_la_SOURCES += trace.c traceopt.c
429
430## Memory tracking.
431pkginclude_HEADERS += track.h
432libmLib_la_SOURCES += track.c
433
434## Testing.
435pkginclude_HEADERS += testrig.h
436libmLib_la_SOURCES += testrig.c
437
438###--------------------------------------------------------------------------
439### Manual.
440
441SUBDIRS += man
c255a2ee 442
443install-man:
a9f61b5f 444 (cd man && $(MAKE) install-man)
c3b137c8 445uninstall-man:
446 (cd man && $(MAKE) uninstall-man)
a0150d8d
MW
447.PHONY: install-man uninstall-man
448
449
450###--------------------------------------------------------------------------
451### Distribution.
452
453## Release number.
454dist-hook::
455 echo $(VERSION) >$(distdir)/RELEASE
456
457## Additional build tools.
458EXTRA_DIST += config/confsubst
459EXTRA_DIST += config/auto-version
460EXTRA_DIST += config/maninst
461
462###--------------------------------------------------------------------------
463### Debian.
c255a2ee 464
a0150d8d
MW
465## General stuff.
466EXTRA_DIST += debian/rules debian/copyright
467EXTRA_DIST += debian/control debian/changelog
468EXTRA_DIST += debian/mlib2.install
469EXTRA_DIST += debian/mlib2-adns.install
470EXTRA_DIST += debian/mlib-dev.install
471EXTRA_DIST += debian/mlib-bin.install
21c22b5c 472
8f207948 473##----- That's all, folks ---------------------------------------------------