Build: Overhaul build system.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 27 Dec 2008 00:08:35 +0000 (00:08 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 27 Dec 2008 14:28:31 +0000 (14:28 +0000)
This has now moved a lot of the way towards the mLib-3 build system,
using appending and Automake conditionals.  The whole thing looks much
cleaner now.

.links
Makefile.am
bres-adns.c
bres.c
configure.ac [new file with mode: 0644]
configure.in [deleted file]
crc-mktab.c
unihash-mkstatic.c

diff --git a/.links b/.links
index f37dca9..7277314 100644 (file)
--- a/.links
+++ b/.links
@@ -1,4 +1,6 @@
 config/maninst
+config/auto-version
+config/confsubst
 mdwopt.c
 mdwopt.h
 COPYING
index 131a94c..5c0fd2b 100644 (file)
-## -*-Makefile-*-
-##
-## $Id$
-##
-## Building the distribution
-##
-## (c) 1998 Straylight/Edgeware
-##
-
-##----- Licensing notice ----------------------------------------------------
-##
-## This file is part of the mLib utilities library.
-##
-## mLib is free software; you can redistribute it and/or modify
-## it under the terms of the GNU Library General Public License as
-## published by the Free Software Foundation; either version 2 of the
-## License, or (at your option) any later version.
-##
-## mLib is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU Library General Public License for more details.
-##
-## You should have received a copy of the GNU Library General Public
-## License along with mLib; if not, write to the Free
-## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-## MA 02111-1307, USA.
-
-## --- Options ---
-
-AUTOMAKE_OPTIONS = foreign
-
-## --- What to build ---
-
-SUBDIRS = man
-bin_PROGRAMS = crc-mktab unihash-mkstatic
-
-lib_LTLIBRARIES = libmLib.la
-pkglibexecdir = $(libexecdir)/$(PACKAGE)
-pkglibexec_PROGRAMS = @BRES_LIBEXEC@
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = mLib.pc
-EXTRA_PROGRAMS = bres
-
-pkginclude_HEADERS = \
-       align.h alloc.h arena.h bits.h buf.h exc.h macros.h quis.h \
-         report.h sub.h \
-       trace.h track.h unihash.h \
-       pool.h \
-       atom.h assoc.h darray.h dstr.h dspool.h hash.h sym.h crc32.h \
-       daemonize.h versioncmp.h \
-       env.h fdflags.h fdpass.h fwatch.h lock.h \
-       bres.h conn.h lbuf.h ident.h pkbuf.h sel.h selbuf.h selpk.h sig.h \
-       tv.h \
-       base64.h base32.h hex.h mdwopt.h str.h testrig.h url.h
-
-## --- Things to put in the library ---
-
-libmLib_la_LDFLAGS = -version-info 2:5:0
-## Middle number is the patchlevel.  Final number is the minor version.  The
-## difference between the first and last numbers is major version.
-
-libmLib_la_SOURCES = \
-       alloc.c arena.c buf.c exc.c quis.c pquis.c report.c sub.c trace.c \
-               traceopt.c track.c \
-       pool.c pool-file.c pool-sub.c \
-       atom.c assoc.c buf-dstr.c darray.c dstr.c dputf.c dspool.c hash.c \
-         sym.c \
-       crc32.c crc32-tab.c \
-       unihash.c unihash-global.c \
-       daemonize.c versioncmp.c \
-       env.c fdflags.c fdpass.c fwatch.c lock.c \
-       @BRES_SOURCE@.c \
-       conn.c lbuf.c ident.c pkbuf.c sel.c selbuf.c selpk.c sig.c \
-       tv.c \
-       base64.c base32.c hex.c mdwopt.c str.c testrig.c url.c
-EXTRA_libmLib_la_SOURCES = bres.c bres-adns.c
-libmLib_la_LIBADD = @DEPLIBS@
-
-BUILT_SOURCES = crc32-tab.c unihash-global.c
+### -*-Makefile-*-
+###
+### Building the distribution
+###
+### (c) 1998 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the mLib utilities library.
+###
+### mLib is free software; you can redistribute it and/or modify
+### it under the terms of the GNU Library General Public License as
+### published by the Free Software Foundation; either version 2 of the
+### License, or (at your option) any later version.
+###
+### mLib is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU Library General Public License for more details.
+###
+### You should have received a copy of the GNU Library General Public
+### License along with mLib; if not, write to the Free
+### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+### MA 02111-1307, USA.
+
+pkglibexecdir           = $(libexecdir)/$(PACKAGE)
+
+SUBDIRS                         =
+BUILT_SOURCES           =
+bin_PROGRAMS            =
+noinst_PROGRAMS                 =
+lib_LTLIBRARIES                 =
+noinst_LTLIBRARIES      =
+pkglibexec_PROGRAMS     =
+pkginclude_HEADERS      =
+EXTRA_DIST              =
+CLEANFILES              =
+DISTCLEANFILES          =
+
+confsubst               = $(top_srcdir)/config/confsubst
+
+SUBSTITUTIONS = \
+       prefix=$(prefix) exec_prefix=$(exec_prefix) \
+       libdir=$(libdir) includedir=$(includedir) \
+       bindir=$(bindir) sbindir=$(sbindir) \
+       PACKAGE=$(PACKAGE) VERSION=$(VERSION)
+
+###--------------------------------------------------------------------------
+### Library.
+
+lib_LTLIBRARIES                += libmLib.la
+libmLib_la_LDFLAGS      = -version-info $(LIBTOOL_VERSION_INFO)
+libmLib_la_SOURCES      =
+libmLib_la_LIBADD       =
+
+pkgconfigdir            = $(libdir)/pkgconfig
+pkgconfig_DATA          = mLib.pc
+EXTRA_DIST             += mLib.pc.in
+CLEANFILES             += mLib.pc
+
+mLib.pc: mLib.pc.in Makefile
+       $(confsubst) $(srcdir)/mLib.pc.in >$@.new $(SUBSTITUTIONS) && \
+               mv $@.new $@
+
+###--------------------------------------------------------------------------
+### Testing.
+
+check: tests
+.PHONY: check tests
+
+TEST_CPPFLAGS           = -DTEST_RIG -DSRCDIR="\"(srcdir)\"" $(AM_CPPFLAGS)
+
+LDADD                   = libmLib.la
+
+###--------------------------------------------------------------------------
+### Utilities.
+
+noinst_LTLIBRARIES     += libutils.la
+libutils_la_SOURCES     =
+libutils_la_LIBADD      =
+libmLib_la_LIBADD      += libutils.la
+
+## Utility macros.
+pkginclude_HEADERS     += macros.h
+
+## Alignment.
+pkginclude_HEADERS     += align.h
+
+## Bit manipulation.
+pkginclude_HEADERS     += bits.h
+
+EXTRA_DIST             += bits.in bits-testgen.c
+tests:: bits.t bits.in
+       ./bits.t -f $(srcdir)/bits.in
 
-crc32-tab.c: crc-mktab$(EXEEXT)
-       ./crc-mktab \
-               -p0x04c11db7 -b32 -B8 -r \
-               -c -scrc32_table -icrc32.h -tuint32 -ocrc32-tab.c.new
-       mv crc32-tab.c.new crc32-tab.c
+noinst_PROGRAMS                += bits.t
+bits_t_SOURCES          = bits.c
+bits_t_CPPFLAGS                 = $(TEST_CPPFLAGS)
+bits_t_LDFLAGS          = -static
+
+## Exceptions.
+pkginclude_HEADERS     += exc.h
+libmLib_la_SOURCES     += exc.c
+
+## String handling.
+pkginclude_HEADERS     += str.h
+libutils_la_SOURCES    += str.c
+
+## Version comparison.
+pkginclude_HEADERS     += versioncmp.h
+libmLib_la_SOURCES     += versioncmp.c
+
+EXTRA_DIST             += versioncmp.in
+tests:: versioncmp.t versioncmp.in
+       ./versioncmp.t -f $(srcdir)/versioncmp.in
+
+noinst_PROGRAMS                += versioncmp.t
+versioncmp_t_SOURCES    = versioncmp-test.c
+versioncmp_t_CPPFLAGS   = $(TEST_CPPFLAGS)
+versioncmp_t_LDFLAGS    = -static
+
+###--------------------------------------------------------------------------
+### Memory allocation.
+
+## Memory allocation.
+pkginclude_HEADERS     += alloc.h arena.h sub.h
+libmLib_la_SOURCES     += alloc.c arena.c sub.c
+
+## Pool allocator.
+pkginclude_HEADERS     += pool.h
+libmLib_la_SOURCES     += pool.c pool-file.c pool-sub.c
 
+###--------------------------------------------------------------------------
+### Hashing.
+
+## CRC32.
+pkginclude_HEADERS     += crc32.h
+libmLib_la_SOURCES     += crc32.c crc32-tab.c
+
+bin_PROGRAMS           += crc-mktab
+crc_mktab_SOURCES       = crc-mktab.c $(UTIL_SOURCES)
+crc_mktab_LDADD                 = libutils.la
+
+BUILT_SOURCES          += crc32-tab.c
+CLEANFILES             += crc32-tab.c
+crc32-tab.c: crc-mktab$(EXEEXT)
+       ./crc-mktab -o $@.new \
+               -p0x04c11db7 -b32 -B8 -r -c \
+               -scrc32_table -icrc32.h -tuint32 && \
+       mv $@.new $@
+
+## Universal hashing.
+pkginclude_HEADERS     += unihash.h
+libutils_la_SOURCES    += unihash.c
+libmLib_la_SOURCES     += unihash-global.c
+BUILT_SOURCES          += unihash-global.c
+
+bin_PROGRAMS           += unihash-mkstatic
+unihash_mkstatic_SOURCES = unihash-mkstatic.c
+unihash_mkstatic_LDADD  = libutils.la
+
+BUILT_SOURCES          += unihash-global.c
+CLEANFILES             += unihash-global.c
 unihash-global.c: unihash-mkstatic$(EXEEXT)
-       ./unihash-mkstatic \
-               -c -sunihash_global -iunihash.h -ounihash-global.c.new
-       mv unihash-global.c.new unihash-global.c
-
-crc_mktab_SOURCES = \
-       crc-mktab.c \
-       mdwopt.c quis.c pquis.c report.c str.c
-crc_mktab_CFLAGS = $(AM_CFLAGS)
-unihash_mkstatic_SOURCES = \
-       unihash-mkstatic.c \
-       mdwopt.c quis.c pquis.c report.c str.c unihash.c
-unihash_mkstatic_CFLAGS = $(AM_CFLAGS)
-
-## --- Test code ---
-
-noinst_PROGRAMS = da.t sym.t assoc.t bits.t versioncmp.t
-
-check: \
-       da.test sym.test assoc.test bits.test base64.test hex.test \
-       base32.test versioncmp.test \
-       unihash.test
-
-da_t_SOURCES = da-test.c
-da_t_LDADD = libmLib.la
-da_t_LDFLAGS = -static
-da.in: $(srcdir)/da-gtest
-       perl $(srcdir)/da-gtest 10000 >da.in.new
-       mv da.in.new da.in
-da.ref: da.in $(srcdir)/da-ref
-       perl $(srcdir)/da-ref <da.in >da.ref.new
-       mv da.ref.new da.ref
-da.test: da.t da.in da.ref
-       ./da.t <da.in >da.out
+       ./unihash-mkstatic -c -sunihash_global -iunihash.h -o$@.new && \
+               mv $@.new $@
+
+noinst_PROGRAMS                += unihash.t
+unihash_t_SOURCES       = unihash.c
+unihash_t_CPPFLAGS      = $(TEST_CPPFLAGS)
+unihash_t_LDFLAGS       = -static
+
+tests:: unihash.t unihash.in
+       ./unihash.t -f unihash.in
+
+EXTRA_DIST             += unihash-check.pl
+CLEANFILES             += unihash.in
+unihash.in: unihash-check.pl
+       perl $(srcdir)/unihash-check.pl >$@.new && mv $@.new $@
+
+###--------------------------------------------------------------------------
+### Data structures.
+
+## Dynamic strings.
+pkginclude_HEADERS     += dstr.h dspool.h
+libmLib_la_SOURCES     += dstr.c dputf.c dspool.c
+
+## Buffers.
+pkginclude_HEADERS     += buf.h
+libmLib_la_SOURCES     += buf.c buf-dstr.c
+
+## Dynamic arrays.
+pkginclude_HEADERS     += darray.h
+libmLib_la_SOURCES     += darray.c
+
+CLEANFILES             += da.out
+tests:: darray.t da.in da.ref
+       ./darray.t <da.in >da.out
        cmp da.out da.ref
-       @echo "darray tested OK."
-
-sym_t_SOURCES = sym-test.c
-sym_t_LDADD = libmLib.la
-sym_t_LDFLAGS = -static
-sym.in: $(srcdir)/sym-gtest
-       perl $(srcdir)/sym-gtest 10000 >sym.in.new
-       mv sym.in.new sym.in
-sym.ref: sym.in $(srcdir)/sym-ref
-       perl $(srcdir)/sym-ref <sym.in >sym.ref.new
-       mv sym.ref.new sym.ref
-sym.test: sym.t sym.in sym.ref
+       @echo "darray OK"
+
+noinst_PROGRAMS                += darray.t
+darray_t_SOURCES        = da-test.c
+darray_t_CPPFLAGS       = $(TEST_CPPFLAGS)
+darray_t_LDFLAGS        = -static
+
+EXTRA_DIST             += da-gtest
+CLEANFILES             += da.in
+da.in: da-gtest
+       perl $(srcdir)/da-gtest 10000 >$@.new && mv $@.new $@
+
+EXTRA_DIST             += da-ref
+CLEANFILES             += da.ref
+da.ref: da-ref da.in
+       perl $(srcdir)/da-ref <da.in >$@.new && mv $@.new $@
+
+## Hash tables.
+pkginclude_HEADERS     += hash.h
+libmLib_la_SOURCES     += hash.c
+
+## Symbol tables.
+pkginclude_HEADERS     += sym.h
+libmLib_la_SOURCES     += sym.c
+
+CLEANFILES             += sym.out
+tests:: sym.t sym.in sym.ref
        ./sym.t <sym.in >sym.out
        cmp sym.out sym.ref
-       @echo "sym tested OK."
+       @echo "sym OK"
+
+noinst_PROGRAMS                += sym.t
+sym_t_SOURCES           = sym-test.c
+sym_t_CPPFLAGS          = $(TEST_CPPFLAGS)
+sym_t_LDFLAGS           = -static
 
-assoc_t_SOURCES = assoc-test.c
-assoc_t_LDADD = libmLib.la
-assoc_t_LDFLAGS = -static
-assoc.test: assoc.t sym.in sym.ref
+EXTRA_DIST             += sym-gtest
+CLEANFILES             += sym.in
+sym.in: sym-gtest
+       perl $(srcdir)/sym-gtest 10000 >$@.new && mv $@.new $@
+
+EXTRA_DIST             += sym-ref
+CLEANFILES             += sym.ref
+sym.ref: sym-ref sym.in
+       perl $(srcdir)/sym-ref <sym.in >$@.new && mv $@.new $@
+
+## Atoms.
+pkginclude_HEADERS     += atom.h
+libmLib_la_SOURCES     += atom.c
+
+## Association tables.
+pkginclude_HEADERS     += assoc.h
+libmLib_la_SOURCES     += assoc.c
+
+CLEANFILES             += assoc.out
+tests:: assoc.t sym.in sym.ref
        ./assoc.t <sym.in >assoc.out
        cmp assoc.out sym.ref
-       @echo "assoc tested OK."
-
-bits_t_SOURCES = bits.c
-bits_t_LDADD = libmLib.la
-bits_t_LDFLAGS = -static
-bits.o: bits.c
-       $(COMPILE) -c -DSRCDIR="\"$(srcdir)\"" $(srcdir)/bits.c -o bits.o
-bits.test: bits.t
-       ./bits.t -f $(srcdir)/bits.in
+       @echo "sym OK"
 
-versioncmp_t_SOURCES = versioncmp-test.c
-versioncmp_t_LDADD = libmLib.la
-versioncmp_t_LDFLAGS = -static
-versioncmp-test.o: versioncmp-test.c
-       $(COMPILE) -c -DSRCDIR="\"$(srcdir)\"" $(srcdir)/versioncmp-test.c -o $@
-versioncmp.test: versioncmp.t
-       ./versioncmp.t -f $(srcdir)/versioncmp.in
+noinst_PROGRAMS                += assoc.t
+assoc_t_SOURCES                 = assoc-test.c
+assoc_t_CPPFLAGS        = $(TEST_CPPFLAGS)
+assoc_t_LDFLAGS                 = -static
+
+###--------------------------------------------------------------------------
+### User interface.
+
+## Option parsing.
+noinst_LTLIBRARIES     += libmdwopt.la
+pkginclude_HEADERS     += mdwopt.h
+libmdwopt_la_SOURCES    = mdwopt.c
+libmdwopt_la_CPPFLAGS   = $(AM_CPPFLAGS) -DBUILDING_MLIB
+libutils_la_LIBADD     += libmdwopt.la
+
+## Program naming.
+pkginclude_HEADERS     += quis.h
+libutils_la_SOURCES    += quis.c pquis.c
+
+## Error reporting.
+pkginclude_HEADERS     += report.h
+libutils_la_SOURCES    += report.c
 
-base64.to: base64.c
-       $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" \
-               $(srcdir)/base64.c -o base64.to
-base64.t: base64.to base64.o libmLib.la
-       $(CC) $(CFLAGS) $(LDFLAGS) \
-               base64.to .libs/libmLib.a $(LIBS) -o base64.t
-base64.test: base64.t base64.in base64.ref
+###--------------------------------------------------------------------------
+### Encoding and decoding.
+
+## form-urlencoded
+pkginclude_HEADERS     += url.h
+libmLib_la_SOURCES     += url.c
+
+## base64
+pkginclude_HEADERS     += base64.h
+libmLib_la_SOURCES     += base64.c
+
+EXTRA_DIST             += base64.in base64.ref
+CLEANFILES             += base64.out
+tests:: base64.t base64.in base64.ref
        ./base64.t <$(srcdir)/base64.in >base64.out
        cmp base64.out $(srcdir)/base64.ref
        ./base64.t -d <$(srcdir)/base64.ref >base64.out
        cmp base64.out $(srcdir)/base64.in
-       @echo "base64 tested OK."
-
-base32.to: base32.c
-       $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" \
-               $(srcdir)/base32.c -o base32.to
-base32.t: base32.to base32.o libmLib.la
-       $(CC) $(CFLAGS) $(LDFLAGS) \
-               base32.to .libs/libmLib.a $(LIBS) -o base32.t
-base32.test: base32.t base32.in base32.ref
+       @echo "base64 OK"
+
+noinst_PROGRAMS                += base64.t
+base64_t_SOURCES        = base64.c
+base64_t_CPPFLAGS       = $(TEST_CPPFLAGS)
+base64_t_LDFLAGS        = -static
+
+## base32
+pkginclude_HEADERS     += base32.h
+libmLib_la_SOURCES     += base32.c
+
+EXTRA_DIST             += base32.in base32.ref
+CLEANFILES             += base32.out
+tests:: base32.t base32.in base32.ref
        ./base32.t <$(srcdir)/base32.in >base32.out
        cmp base32.out $(srcdir)/base32.ref
        ./base32.t -d <$(srcdir)/base32.ref >base32.out
        cmp base32.out $(srcdir)/base32.in
-       @echo "base32 tested OK."
-
-hex.to: hex.c
-       $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" \
-               $(srcdir)/hex.c -o hex.to
-hex.t: hex.to hex.o libmLib.la
-       $(CC) $(CFLAGS) $(LDFLAGS) \
-               hex.to .libs/libmLib.a $(LIBS) -o hex.t
-hex.test: hex.t hex.in hex.ref
+       @echo "base32 OK"
+
+noinst_PROGRAMS                += base32.t
+base32_t_SOURCES        = base32.c
+base32_t_CPPFLAGS       = $(TEST_CPPFLAGS)
+base32_t_LDFLAGS        = -static
+
+## hex
+pkginclude_HEADERS     += hex.h
+libmLib_la_SOURCES     += hex.c
+
+EXTRA_DIST             += hex.in hex.ref
+CLEANFILES             += hex.out
+tests:: hex.t hex.in hex.ref
        ./hex.t <$(srcdir)/hex.in >hex.out
        cmp hex.out $(srcdir)/hex.ref
        ./hex.t -d <$(srcdir)/hex.ref >hex.out
        cmp hex.out $(srcdir)/hex.in
-       @echo "hex tested OK."
-
-unihash.to: unihash.c
-       $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" \
-               $(srcdir)/unihash.c -o unihash.to
-unihash.t: unihash.to libmLib.la
-       $(CC) $(CFLAGS) $(LDFLAGS) \
-               unihash.to .libs/libmLib.a $(LIBS) -o unihash.t
-unihash.in: unihash-check.pl
-       perl $(srcdir)/unihash-check.pl >unihash.in.new
-       mv unihash.in.new $(srcdir)/unihash.in
-unihash.test: unihash.t unihash.in
-       ./unihash.t -f $(srcdir)/unihash.in
-
-TEST_CLEAN = \
-       *.t *.to assoc.out \
-       da.in da.ref da.out \
-       sym.in sym.ref sym.out \
-       base64.out base32.out hex.out unihash.in
-
-TEST_DIST = \
-       da-gtest da-ref \
-       sym-gtest sym-ref \
-       bits.in bits-testgen.c \
-       unihash-check.pl unihash.in \
-       versioncmp.in \
-       base64.in base64.ref base32.in base32.ref hex.in hex.ref
-
-## --- Background resolver ---
-##
-## I must (a) build the standalone version, and (b) inform the client library
-## where the standalone version is.
-
-bres_SOURCES = bres.c
-bres_CFLAGS = -DBRES_STANDALONE
-
-bres.lo: $(srcdir)/bres.c
-       $(LTCOMPILE) -c -DBRES_SERVER="\"$(libexecdir)/$(PACKAGE)/`echo bres|sed '$(transform)'`\"" $(srcdir)/bres.c
-
-## --- Other useful rules ---
+       @echo "hex OK"
+
+noinst_PROGRAMS                += hex.t
+hex_t_SOURCES           = hex.c
+hex_t_CPPFLAGS          = $(TEST_CPPFLAGS)
+hex_t_LDFLAGS           = -static
+
+###--------------------------------------------------------------------------
+### System utilities.
+
+## Daemons.
+pkginclude_HEADERS     += daemonize.h
+libmLib_la_SOURCES     += daemonize.c
+
+## Environment variables.
+pkginclude_HEADERS     += env.h
+libmLib_la_SOURCES     += env.c
+
+## File and descriptor flags.
+pkginclude_HEADERS     += fdflags.h
+libmLib_la_SOURCES     += fdflags.c
+
+## File descriptor passing.
+pkginclude_HEADERS     += fdpass.h
+libmLib_la_SOURCES     += fdpass.c
+
+## Watching files for modification.
+pkginclude_HEADERS     += fwatch.h
+libmLib_la_SOURCES     += fwatch.c
+
+## File locking.
+pkginclude_HEADERS     += lock.h
+libmLib_la_SOURCES     += lock.c
+
+## Time arithmetic.
+pkginclude_HEADERS     += tv.h
+libmLib_la_SOURCES     += tv.c
+
+###--------------------------------------------------------------------------
+### Buffering.
+
+## Line buffering.
+pkginclude_HEADERS     += lbuf.h
+libmLib_la_SOURCES     += lbuf.c
+
+## Packet buffering.
+pkginclude_HEADERS     += pkbuf.h
+libmLib_la_SOURCES     += pkbuf.c
+
+###--------------------------------------------------------------------------
+### Network utilities.
+
+## Core event selection.
+pkginclude_HEADERS     += sel.h
+libmLib_la_SOURCES     += sel.c
+
+## Waiting for buffers to fill.
+pkginclude_HEADERS     += selbuf.h selpk.h
+libmLib_la_SOURCES     += selbuf.c selpk.c
+
+## RFC931 identification.
+pkginclude_HEADERS     += ident.h
+libmLib_la_SOURCES     += ident.c
+
+## Nonblocking connections.
+pkginclude_HEADERS     += conn.h
+libmLib_la_SOURCES     += conn.c
+
+## Signal handling
+pkginclude_HEADERS     += sig.h
+libmLib_la_SOURCES     += sig.c
+
+## Name resolution.
+pkginclude_HEADERS     += bres.h
+
+if WITH_ADNS
+libmLib_la_SOURCES     += bres-adns.c
+else
+libmLib_la_SOURCES     += bres.c
+pkglibexec_PROGRAMS    += bres
+bres_SOURCES            = bres.c
+bres_CPPFLAGS           = -DBRES_STANDALONE $(AM_CPPFLAGS)
+bres_LDADD              =
+endif
+
+###--------------------------------------------------------------------------
+### Testing and debugging.
+
+## Tracing.
+pkginclude_HEADERS     += trace.h
+libmLib_la_SOURCES     += trace.c traceopt.c
+
+## Memory tracking.
+pkginclude_HEADERS     += track.h
+libmLib_la_SOURCES     += track.c
+
+## Testing.
+pkginclude_HEADERS     += testrig.h
+libmLib_la_SOURCES     += testrig.c
+
+###--------------------------------------------------------------------------
+### Manual.
+
+SUBDIRS                        += man
 
 install-man:
        (cd man && $(MAKE) install-man)
 uninstall-man:
        (cd man && $(MAKE) uninstall-man)
+.PHONY: install-man uninstall-man
+
+
+###--------------------------------------------------------------------------
+### Distribution.
+
+## Release number.
+dist-hook::
+       echo $(VERSION) >$(distdir)/RELEASE
+
+## Additional build tools.
+EXTRA_DIST             += config/confsubst
+EXTRA_DIST             += config/auto-version
+EXTRA_DIST             += config/maninst
+
+###--------------------------------------------------------------------------
+### Debian.
 
-CLEANFILES = $(TEST_CLEAN) crc32-tab.c unihash-global.c
-DISTCLEANFILES = libtool
-EXTRA_DIST = \
-       $(TEST_DIST) config/maninst \
-       debian/rules debian/copyright debian/control debian/changelog
+## General stuff.
+EXTRA_DIST             += debian/rules debian/copyright
+EXTRA_DIST             += debian/control debian/changelog
+EXTRA_DIST             += debian/mlib2.install
+EXTRA_DIST             += debian/mlib2-adns.install
+EXTRA_DIST             += debian/mlib-dev.install
+EXTRA_DIST             += debian/mlib-bin.install
 
 ##----- That's all, folks ---------------------------------------------------
index 0679207..039ca69 100644 (file)
@@ -39,6 +39,8 @@
  * must be licensed under the full GPL.
  */
 
+#include "config.h"
+
 #ifndef HAVE_ADNS
 #  error "You need the ADNS library to compile this file."
 #endif
diff --git a/bres.c b/bres.c
index 385a427..8a73aaf 100644 (file)
--- a/bres.c
+++ b/bres.c
@@ -29,6 +29,8 @@
 
 /*----- Header files ------------------------------------------------------*/
 
+#include "config.h"
+
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..52db7c7
--- /dev/null
@@ -0,0 +1,106 @@
+dnl -*-autoconf-*-
+dnl
+dnl Configuration script for mLib
+dnl
+dnl (c) 2008 Straylight/Edgeware
+dnl
+
+dnl ----- Licensing notice --------------------------------------------------
+dnl
+dnl This file is part of the mLib utilities library.
+dnl
+dnl mLib is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU Library General Public License as
+dnl published by the Free Software Foundation; either version 2 of the
+dnl License, or (at your option) any later version.
+dnl
+dnl mLib is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU Library General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Library General Public
+dnl License along with mLib; if not, write to the Free
+dnl Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+dnl MA 02111-1307, USA.
+
+dnl--------------------------------------------------------------------------
+dnl Initialization.
+
+mdw_AUTO_VERSION
+AC_INIT([mLib], AUTO_VERSION, [mdw@distorted.org.uk])
+AC_CONFIG_SRCDIR([mLib.pc.in])
+AC_CONFIG_AUX_DIR([config])
+AM_INIT_AUTOMAKE([foreign])
+
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_LIBTOOL
+AX_CFLAGS_WARN_ALL
+mdw_LIBTOOL_VERSION_INFO
+
+mdw_MANEXT
+
+AC_DEFINE_UNQUOTED([SRCDIR], ["$(cd $srcdir && pwd)"],
+                  [absolute pathname for the source directory.])
+
+dnl--------------------------------------------------------------------------
+dnl C programming environment.
+
+dnl Headers.
+AC_CHECK_HEADERS([float.h])
+
+dnl Libraries.
+AC_SEARCH_LIBS([socket], [socket])
+AC_SEARCH_LIBS([gethostbyname], [nsl resolv])
+
+dnl Which version of struct msghdr do we have?
+AC_CHECK_MEMBERS([struct msgdr.msg_control],,, [
+#include <sys/types.h>
+#include <sys/socket.h>
+])
+
+dnl--------------------------------------------------------------------------
+dnl Name resolution.
+
+AC_ARG_WITH([adns],
+  AS_HELP_STRING([--with-adns],
+                [use ADNS library for background name resolution]),
+  [want_adns=$withval],
+  [want_adns=auto])
+
+case $want_adns in
+  no) ;;
+  *) AC_SEARCH_LIBS([adns_init], [adns], [have_adns=yes], [have_adns=no]) ;;
+esac
+case $want_adns,$have_adns in
+  yes,no)
+    AC_MSG_ERROR([ADNS library not found but explicitly requested])
+    ;;
+  yes,yes | auto,yes)
+    use_adns=yes
+    AC_DEFINE([HAVE_ADNS], [1],
+             [define if you have (and want to use) the ADNS library.])
+    ;;
+  no,* | auto,no)
+    use_adns=no
+    mdw_DEFINE_PATHS([
+      AC_DEFINE_UNQUOTED([BRES_SERVER],
+                        ["mdw_PATH($libexecdir)/$PACKAGE/mdw_PROG(bres)"],
+                        [pathname to the standalone `bres' binary.'])
+    ])
+    ;;
+esac
+AM_CONDITIONAL([WITH_ADNS], [test "$use_adns" = yes])
+
+dnl--------------------------------------------------------------------------
+dnl Output.
+
+AC_CONFIG_HEADER([config/config.h])
+
+AC_CONFIG_FILES(
+  [Makefile]
+  [man/Makefile])
+AC_OUTPUT
+
+dnl ----- That's all, folks -------------------------------------------------
diff --git a/configure.in b/configure.in
deleted file mode 100644 (file)
index 528dafb..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-dnl -*-m4-*-
-dnl
-dnl $Id$
-dnl
-dnl Configuration script for mLib
-dnl
-dnl (c) 1998 Straylight/Edgeware
-dnl
-
-dnl ----- Licensing notice --------------------------------------------------
-dnl
-dnl This file is part of the mLib utilities library.
-dnl
-dnl mLib is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU Library General Public License as
-dnl published by the Free Software Foundation; either version 2 of the
-dnl License, or (at your option) any later version.
-dnl
-dnl mLib is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-dnl GNU Library General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Library General Public
-dnl License along with mLib; if not, write to the Free
-dnl Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-dnl MA 02111-1307, USA.
-
-AC_INIT(exc.c)
-AC_CONFIG_AUX_DIR(config)
-AM_INIT_AUTOMAKE(mLib, 2.0.5)
-
-AC_PROG_CC
-AM_PROG_LIBTOOL
-AX_CFLAGS_WARN_ALL
-mdw_MANEXT
-
-AC_CHECK_HEADERS(float.h)
-
-AC_SEARCH_LIBS(socket, socket)
-AC_SEARCH_LIBS(gethostbyname, nsl resolv)
-
-DEPLIBS=$LIBS AC_SUBST(DEPLIBS)
-BRES_LIBEXEC="bres\$(EXEEXT)" BRES_SOURCE="bres"
-AC_SUBST(BRES_LIBEXEC) AC_SUBST(BRES_SOURCE)
-AC_ARG_WITH(adns,
-[  --with-adns            use ADNS library for background name resolution],
-[want_adns=$withval], [want_adns=auto])
-if test $want_adns != no; then
-  save_LIBS=$LIBS
-  LIBS=$DEPLIBS
-  AC_SEARCH_LIBS(adns_init, adns, [have_adns=yes], [have_adns=no])
-  DEPLIBS=$LIBS
-  LIBS=$save_LIBS
-  if test $have_adns = yes; then
-    AC_DEFINE(HAVE_ADNS)
-    BRES_LIBEXEC=""
-    BRES_SOURCE="bres-adns"
-  elif test $want_adns = yes; then
-    AC_MSG_ERROR([ADNS library not found, but explicitly requested])
-  fi
-fi
-
-AC_CACHE_CHECK([for msg_control], [mdw_cv_msg_control],
-[AC_TRY_COMPILE(
-[#include <sys/types.h>
-#include <sys/socket.h>],
-[struct msghdr msg;
-msg.msg_control = 0;],
-[mdw_cv_msg_control=yes],
-[mdw_cv_msg_control=no])])
-if test $mdw_cv_msg_control = no; then
-  AC_DEFINE([HAVE_MSG_ACCRIGHTS])
-fi
-
-AC_DEFINE(BUILDING_MLIB)
-
-AC_OUTPUT(Makefile man/Makefile mLib.pc)
index 532805a..200ed32 100644 (file)
@@ -29,6 +29,8 @@
 
 /*----- Header files ------------------------------------------------------*/
 
+#include "config.h"
+
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
index 24e49df..f168227 100644 (file)
@@ -29,6 +29,8 @@
 
 /*----- Header files ------------------------------------------------------*/
 
+#include "config.h"
+
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>