From: Marko Kreen Date: Tue, 29 Nov 2011 19:48:17 +0000 (+0200) Subject: Update build system to use Antimake X-Git-Url: http://git.postgresql.org/gitweb/static/%7B%7Bpgdulink%28?a=commitdiff_plain;h=11482746f97b3376b47e227613719a93024aa99c;p=libusual.git Update build system to use Antimake Additional features: - install headers with filtering, to hide HAVE_* symbols - libusual.pc for pkg-config --- diff --git a/.gitignore b/.gitignore index 35e8f6e..489679a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,13 @@ test/regtest doc/html *.[oas] *.gc[odn][aov] + +install-sh +config.guess +config.sub +ltmain.sh +libtool +build.mk +.objs +.libs +.deps diff --git a/Makefile b/Makefile index 6c807f0..67eba46 100644 --- a/Makefile +++ b/Makefile @@ -1,126 +1,126 @@ --include config.mak - -# config -MKAR = $(AR) rcs -CFLAGS += $(WFLAGS) -CPPFLAGS = $(USUAL_CPPFLAGS) - -# sources -USUAL_DIR = . -USUAL_OBJDIR = obj -USUAL_MODULES = $(filter-out pgsocket, $(subst .h,, $(notdir $(wildcard $(USUAL_DIR)/usual/*.h)))) -include $(USUAL_DIR)/Setup.mk - -# tgz generation -FULL = libusual-$(shell date +%Y-%m-%d) -DIRS = usual m4 test -IGNORE = usual/config.h test/config.h test/test_config.h -FILES = $(filter-out $(IGNORE), $(wildcard usual/*.[ch] test/*.[ch])) \ - m4/usual.m4 configure configure.ac COPYRIGHT \ - Makefile README config.mak.in Setup.mk \ - find_modules.sh test/force_compat.sed test/Makefile - -# pgutil_kwlookup generation -PG_CONFIG ?= pg_config -KWLIST = $(shell $(PG_CONFIG) --includedir-server)/parser/kwlist.h -GPERF = gperf -m5 - -# full path for files -srcs = $(USUAL_SRCS) -hdrs = $(USUAL_HDRS) -objs = $(USUAL_OBJS) - -# Quiet by default, 'make V=1' shows commands -V=0 -ifeq ($(V), 0) -Q = @ -E = @echo -else -Q = -E = @true -endif - -# rules follow - -all: info libusual.a obj/testcompile - -libusual.a: $(objs) - $(E) " AR" $@ - $(Q) $(MKAR) $@ $(objs) - -$(USUAL_OBJDIR)/%.o: $(USUAL_DIR)/usual/%.c config.mak $(hdrs) - @mkdir -p $(USUAL_OBJDIR) - $(E) " CC" $< - $(Q) $(CC) -c -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $< - -$(USUAL_OBJDIR)/%.s: $(USUAL_DIR)/usual/%.c config.mak $(hdrs) - @mkdir -p $(USUAL_OBJDIR) - $(E) " CC -S" $< - $(Q) $(CC) -S -fverbose-asm -o - $(DEFS) $(CPPFLAGS) $(CFLAGS) $< \ - | cleanasm > $@ - -obj/testcompile: test/compile.c libusual.a config.mak $(hdrs) - $(E) " CHECK" $< - $(Q) $(CC) -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $< $(USUAL_LDFLAGS) $(USUAL_LIBS) $(LIBS) - -test/test_string: test/test_string.c libusual.a config.mak $(hdrs) - $(E) " TEST" $@ - $(Q) $(CC) -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $< $(USUAL_LDFLAGS) $(USUAL_LIBS) $(LIBS) - $(Q) ./$@ - -check: config.mak - mkdir -p test/usual - sed -f test/compat.sed usual/config.h > test/usual/config.h - make clean - make CPPFLAGS="-I./test $(CPPFLAGS)" all - make CPPFLAGS="-I./test $(CPPFLAGS)" test/test_string - -clean: - rm -f libusual.a obj/*.[os] obj/test* aclocal* config.log - rm -rf autom4te* - rm -f usual/pgutil_kwlookup.h.gp - -distclean: clean - rm -f config.mak usual/config.h config.status - -realclean: - rm -f usual/pgutil_kwlookup.h - -boot: - ./autogen.sh - -#config.mak: -# @echo "Config out-of-date, please run ./configure again" -# @exit 1 - -#usual/config.h: -# @echo "Please run ./configure first" -# @exit 1 +AM_CPPFLAGS = -I$(builddir) -I$(srcdir) + +# main target +lib_LTLIBRARIES = libusual.la + +# sources that are not always built +EXTRA_libusual_la_SOURCES = usual/pgsocket.h usual/pgsocket.c + +# sources not in tar.gz +nodist_libusual_la_SOURCES = usual/config.h + +# regular source files +libusual_la_SOURCES = usual/config.h.in \ + usual/aatree.h usual/aatree.c \ + usual/base.h usual/base.c usual/base_win32.h \ + usual/bits.h \ + usual/cbtree.h usual/cbtree.c \ + usual/cfparser.h usual/cfparser.c \ + usual/crc32.h usual/crc32.c \ + usual/ctype.h \ + usual/cxalloc.h usual/cxalloc.c \ + usual/cxextra.h usual/cxextra.c \ + usual/daemon.h usual/daemon.c \ + usual/endian.h \ + usual/err.h usual/err.c \ + usual/event.h usual/event.c \ + usual/fileutil.h usual/fileutil.c \ + usual/getopt.h usual/getopt.c \ + usual/hashtab-impl.h \ + usual/heap.h usual/heap.c \ + usual/list.h usual/list.c \ + usual/logging.h usual/logging.c \ + usual/lookup3.h usual/lookup3.c \ + usual/mbuf.h usual/mbuf.c \ + usual/md5.h usual/md5.c \ + usual/mdict.h usual/mdict.c \ + usual/mempool.h usual/mempool.c \ + usual/misc.h \ + usual/netdb.h usual/netdb.c \ + usual/pgutil.h usual/pgutil.c usual/pgutil_kwlookup.h \ + usual/pthread.h usual/pthread.c \ + usual/regex.h usual/regex.c \ + usual/safeio.h usual/safeio.c \ + usual/sha1.h usual/sha1.c \ + usual/shlist.h \ + usual/signal.h usual/signal.c \ + usual/slab.h usual/slab.c \ + usual/socket.h usual/socket.c usual/socket_ntop.c usual/socket_pton.c usual/socket_win32.h \ + usual/statlist.h \ + usual/string.h usual/string.c \ + usual/strpool.h usual/strpool.c \ + usual/time.h usual/time.c \ + usual/utf8.h usual/utf8.c + +# we want to filter headers, so cannot use usual install method via _HEADERS +USUAL_HEADERS = $(filter %.h,$(libusual_la_SOURCES) $(nodist_libusual_la_SOURCES)) + +# define aclocal destination +aclocaldir = ${datarootdir}/aclocal +AM_DESTINATIONS = aclocal + +# other files +dist_pkgdata_SCRIPTS = find_modules.sh +dist_pkgdata_DATA = Setup.mk +dist_aclocal_DATA = m4/usual.m4 m4/antimake.m4 + +# test program for link-test +noinst_PROGRAMS = test/compile +test_compile_SOURCES = test/compile.c +test_compile_LDADD = libusual.la + +# extra clean files +DISTCLEANFILES = config.log build.mk config.status libtool config.mak +MAINTAINERCLEANFILES = build.mk.in configure install-sh ltmain.sh config.sub config.guess + +# files for .tgz that are not mentioned in sources +EXTRA_DIST = $(MAINTAINERCLEANFILES) + +# we dont build test subdir by default, but want to include in .tgz +DIST_SUBDIRS = test + +# non-recursive subdir +EMBED_SUBDIRS = mk + +# +# Launch Antimake +# +include build.mk + +# filter headers when installing +install-local: + @$(MKDIR_P) $(DESTDIR)$(includedir)/usual + @for hdr in $(USUAL_HEADERS); do \ + echo Filtering $$hdr; \ + $(SED) -f mk/safe-headers.sed $$hdr \ + > $(DESTDIR)$(includedir)/usual/`basename $$hdr`; \ + done + +# Give proper error message +build.mk: + @echo "Please run ./configure first" + @exit 1 + +%.pc: %.pc.in config.status + ./config.status --file $@ # run sparse over code sparse: config.mak REAL_CC="$(CC)" \ $(MAKE) clean libusual.a CC="cgcc -Wsparse-all -Wno-transparent-union" -asms = $(objs:.o=.s) -asm: $(asms) - -dbg: flags - @echo srcs=$(srcs) - @echo objs=$(objs) - @echo hdrs=$(hdrs) - -flags: - @echo DEFS=$(DEFS) - @echo CFLAGS=$(CFLAGS) - @echo CPPFLAGS=$(CPPFLAGS) +# generate api documentation +dox: + doxygen doc/Doxyfile -info: - @echo CC: $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) - @echo LD: $(LD) $(USUAL_LDFLAGS) $(USUAL_LIBS) $(LIBS) +# +# rest is for pgutil_kwlookup generation +# -.PHONY: flags dbg info +PG_CONFIG ?= pg_config +KWLIST = $(shell $(PG_CONFIG) --includedir-server)/parser/kwlist.h +GPERF = gperf -m5 # requires 8.4+ kws: @@ -135,14 +135,3 @@ kwh: | sed '/^#line/d' \ > usual/pgutil_kwlookup.h -tgz: config.mak $(DISTFILES) - # create tarfile - rm -rf $(FULL) $(FULL).tgz usual/config.h - mkdir $(FULL) - (for f in $(DIRS) $(FILES); do echo $$f; done) | cpio -pm $(FULL) - tar czf $(FULL).tgz $(FULL) - rm -rf $(FULL) - -dox: - doxygen doc/Doxyfile - diff --git a/autogen.sh b/autogen.sh index 8d99888..bc61e12 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,14 +1,4 @@ #! /bin/sh -# get install-sh, config.* -rm -f config.sub config.guess install-sh ltmain.sh -libtoolize --install --copy -# ignore libtool itself -rm -f ltmain.sh - -rm -f usual/config.* configure -aclocal -I ./m4 -autoheader -autoconf -rm -rf autom4te* +./mk/std-autogen.sh . diff --git a/build.mk.in b/build.mk.in new file mode 100644 index 0000000..ce351ca --- /dev/null +++ b/build.mk.in @@ -0,0 +1,4 @@ + +include @abs_top_builddir@/config.mak +include $(abs_top_srcdir)/mk/antimake.mk + diff --git a/config.mak.in b/config.mak.in index f7b652f..fc74306 100644 --- a/config.mak.in +++ b/config.mak.in @@ -1,42 +1,57 @@ -PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ - +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PORTNAME = @PORTNAME@ - -DEFS = @DEFS@ -LIBS = @LIBS@ +EXEEXT = @EXEEXT@ +HAVE_CC_DEPFLAG = @HAVE_CC_DEPFLAG@ CC = @CC@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CFLAGS = @CFLAGS@ -LDFLAGS = @LDFLAGS@ +DEFS = @DEFS@ WFLAGS = @WFLAGS@ - +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ AR = @AR@ +ARFLAGS = @ARFLAGS@ +RANLIB = @RANLIB@ +LIBTOOL = @LIBTOOL@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_DATA = @INSTALL_DATA@ +MKDIR_P = @MKDIR_P@ +SED = @SED@ +AWK = @AWK@ +GREP = @GREP@ +EGREP = @EGREP@ STRIP = @STRIP@ - prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ +includedir = @includedir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ datarootdir = @datarootdir@ +datadir = @datadir@ sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ docdir = @docdir@ mandir = @mandir@ - -top_builddir = @top_builddir@ -srcdir = @srcdir@ -abs_srcdir = @abs_srcdir@ -top_srcdir = @top_srcdir@ -abs_top_srcdir = @abs_top_srcdir@ -builddir = @builddir@ -abs_builddir = @abs_builddir@ -abs_top_builddir = @abs_top_builddir@ - -# autoconf does not want to find 'install' -# if im not using automake... -INSTALL = @INSTALL@ -BININSTALL = @BININSTALL@ +libdir = @libdir@ +localedir = @localedir@ +pkgdatadir = @pkgdatadir@ +pkgconfigdir = @pkgconfigdir@ +abs_top_srcdir ?= @abs_top_srcdir@ +abs_top_builddir ?= @abs_top_builddir@ +nosub_top_srcdir ?= @top_srcdir@ +nosub_top_builddir ?= @top_builddir@ enable_debug = @enable_debug@ + diff --git a/configure.ac b/configure.ac index 063aa2a..cc797fa 100644 --- a/configure.ac +++ b/configure.ac @@ -1,14 +1,16 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(libusual, 0.1) +AC_INIT([libusual], [0.1], [https://libusual.github.com]) AC_CONFIG_SRCDIR(usual/base.h) AC_CONFIG_HEADER(usual/config.h) AC_PREREQ([2.59]) -AC_USUAL_PORT_CHECK +AC_USUAL_INIT AC_USUAL_PROGRAM_CHECK +LT_INIT + AC_USUAL_HEADER_CHECK AC_USUAL_TYPE_CHECK @@ -34,5 +36,5 @@ AC_SEARCH_LIBS(gethostbyname, nsl) AC_SEARCH_LIBS(hstrerror, resolv) dnl Output findings -AC_OUTPUT([config.mak]) +AC_OUTPUT([config.mak mk/libusual.pc build.mk]) diff --git a/m4/usual.m4 b/m4/usual.m4 index 14c54da..b03ce88 100644 --- a/m4/usual.m4 +++ b/m4/usual.m4 @@ -1,6 +1,6 @@ dnl Those depend on correct order: -dnl AC_USUAL_PORT_CHECK +dnl AC_USUAL_INIT dnl AC_USUAL_PROGRAM_CHECK dnl AC_USUAL_HEADER_CHECK dnl AC_USUAL_TYPE_CHECK @@ -10,13 +10,22 @@ dnl AC_USUAL_CASSERT dnl AC_USUAL_WERROR dnl AC_USUAL_DEBUG + dnl -dnl AC_USUAL_PORT_CHECK: Sets PORTNAME=win32/unix +dnl AC_USUAL_INIT: +dnl - Sets PORTNAME=win32/unix +dnl - If building from separate dir, writes top-level Makefile (antimake) dnl dnl Also defines port-specific flags: dnl _GNU_SOURCE, _WIN32_WINNT, WIN32_LEAN_AND_MEAN dnl -AC_DEFUN([AC_USUAL_PORT_CHECK], [ +AC_DEFUN([AC_USUAL_INIT], [ + +# if building separately from srcdir, write top-level makefile +if test "$srcdir" != "."; then + echo "include $srcdir/Makefile" > Makefile +fi + AC_MSG_CHECKING([target host type]) xhost="$host_alias" if test "x$xhost" = "x"; then @@ -38,8 +47,15 @@ else AC_DEFINE([_GNU_SOURCE], [1], [Define to get working glibc.]) fi +dnl Package-specific data +AC_SUBST([pkgdatadir], ['${datarootdir}'/${PACKAGE_TARNAME}]) +dnl pkgconfig files +AC_SUBST([pkgconfigdir], ['${libdir}/pkgconfig']) + ]) +dnl Old name for initial checks +AC_DEFUN([AC_USUAL_PORT_CHECK], [AC_USUAL_INIT]) dnl dnl AC_USUAL_PROGRAM_CHECK: Simple C environment: CC, CPP, INSTALL @@ -65,6 +81,27 @@ if test "$GCC" = "yes"; then [AC_MSG_RESULT([no]) LDFLAGS="$old_LDFLAGS"])]) fi + +dnl Check if compiler supports gcc-style dependencies +AC_MSG_CHECKING([whether compiler supports dependency generation]) +old_CFLAGS="$CFLAGS" +HAVE_CC_DEPFLAG=no +DEPFLAG="" +for flg in '-Wp,-MMD,' '-Wp,-MD,'; do + CFLAGS="$flg,conftest.d" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([void foo(void){}])], + [WFLAGS="$WFLAGS $f"]) + if test "$HAVE_CC_DEPFLAG" = "yes"; then + DEPFLAG="$flg" + break + fi +done +rm -f conftest.d +CFLAGS="$old_CFLAGS" +AC_MSG_RESULT([$HAVE_CC_DEPFLAG]) +AC_SUBST(HAVE_CC_DEPFLAG) +AC_SUBST(DEPFLAG) + dnl Pick good warning flags for gcc WFLAGS="" if test x"$GCC" = xyes; then @@ -91,14 +128,20 @@ if test x"$GCC" = xyes; then CFLAGS="$good_CFLAGS" AC_MSG_RESULT([done]) fi -# autoconf does not want to find 'install', if not using automake... -INSTALL=install -BININSTALL="$INSTALL" -AC_SUBST(INSTALL) AC_SUBST(WFLAGS) -AC_SUBST(BININSTALL) + +AC_PROG_INSTALL +AC_PROG_MKDIR_P +AC_PROG_LN_S +AC_PROG_SED +AC_PROG_EGREP +AC_PROG_AWK + AC_CHECK_TOOL([STRIP], [strip]) +AC_CHECK_TOOL([RANLIB], [ranlib], [true]) AC_CHECK_TOOL([AR], [ar]) +ARFLAGS=rcu +AC_SUBST(ARFLAGS) ]) diff --git a/mk/Makefile.am b/mk/Makefile.am new file mode 100644 index 0000000..b3b2d08 --- /dev/null +++ b/mk/Makefile.am @@ -0,0 +1,8 @@ + +pkgconfig_DATA = libusual.pc +dist_pkgdata_SCRIPTS = antimake.mk std-autogen.sh + +DISTCLEANFILES = libusual.pc + +EXTRA_DIST = antimake.txt safe-headers.sed + diff --git a/mk/libusual.pc.in b/mk/libusual.pc.in new file mode 100644 index 0000000..cc6c97e --- /dev/null +++ b/mk/libusual.pc.in @@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +pkgdatadir=@pkgdatadir@ +antimake=@pkgdatadir@/antimake.mk + +Name: libusual +Description: Usual utility library for C +Version: @PACKAGE_VERSION@ +Cflags: -I${includedir} +Libs: -L${libdir} -lusual diff --git a/mk/safe-headers.sed b/mk/safe-headers.sed new file mode 100644 index 0000000..5de57ec --- /dev/null +++ b/mk/safe-headers.sed @@ -0,0 +1,6 @@ +s/HAVE_/USUAL_&/g +s/PACKAGE_/USUAL_&/g +s/LT_OBJ/USUAL_&/g +s/STRERROR_/USUAL_&/g +s/CASSERT/USUAL_&/g +s/WORDS_BIGENDIAN/USUAL_&/g diff --git a/mk/std-autogen.sh b/mk/std-autogen.sh new file mode 100755 index 0000000..91764d2 --- /dev/null +++ b/mk/std-autogen.sh @@ -0,0 +1,31 @@ +#! /bin/sh + +USUAL_DIR="$1" +test -n "${USUAL_DIR}" || USUAL_DIR="." + +test -f "${USUAL_DIR}/m4/usual.m4" || { + echo usage: $0 USUAL_DIR + exit 1 +} + +# +# workaround for libtoolize bug - it does not update +# the file if they dont exist +rm -f config.guess config.sub install-sh ltmain.sh libtool +if libtoolize --help | grep "[-][-]install" > /dev/null; then + libtoolize -i -q +else + libtoolize +fi + +# drop ltmain.sh if libtool is not used +grep -qE 'LT_INIT|LIBTOOL' configure.ac || rm -f ltmain.sh + +# Now generate configure & config.h +aclocal -I${USUAL_DIR}/m4 +autoheader +autoconf + +# clean junk +rm -rf autom4te.* aclocal* + diff --git a/test/Makefile b/test/Makefile index 953d252..e997343 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,84 +1,39 @@ +SUBLOC = test +DIST_SUBDIRS = attregex -SRCS = test_string.c test_crypto.c test_aatree.c test_heap.c \ - test_common.c test_list.c tinytest.c test_cbtree.c \ - test_utf8.c test_strpool.c test_pgutil.c test_regex.c \ - test_cxalloc.c test_bits.c test_base.c test_netdb.c \ - test_cfparser.c test_endian.c test_hashtab.c test_mdict.c \ - test_shlist.c test_time.c test_hashing.c test_fileutil.c \ - test_socket.c test_getopt.c test_ctype.c +USUAL_DIR = $(top_srcdir) -OBJS = $(addprefix obj/, $(SRCS:.c=.o)) -HDRS = test_common.h test_config.h tinytest.h tinytest_macros.h -LIBS = +regtest_system_SOURCES = \ + test_string.c test_crypto.c test_aatree.c test_heap.c \ + test_common.c test_list.c tinytest.c test_cbtree.c \ + test_utf8.c test_strpool.c test_pgutil.c test_regex.c \ + test_cxalloc.c test_bits.c test_base.c test_netdb.c \ + test_cfparser.c test_endian.c test_hashtab.c test_mdict.c \ + test_shlist.c test_time.c test_hashing.c test_fileutil.c \ + test_socket.c test_getopt.c test_ctype.c \ + test_common.h tinytest.h tinytest_macros.h -USUAL_DIR = .. -USUAL_OBJDIR = obj -USUAL_LOCAL_SRCS = $(SRCS) $(HDRS) -include $(USUAL_DIR)/Setup.mk -include ../config.mak +regtest_compat_SOURCES = $(regtest_system_SOURCES) +nodist_regtest_compat_SOURCES = test_config.h -DEFS += -DUSUAL_TEST_CONFIG -CPPFLAGS += -I.. -I. +regtest_compat_EMBED_LIBUSUAL = 1 +regtest_system_EMBED_LIBUSUAL = 1 -hdrs = $(HDRS) $(USUAL_HDRS) -objs = $(OBJS) $(USUAL_OBJS) +regtest_system_LDADD = -lanl +regtest_system_LDFLAGS = -pthread -.SUFFIXES: +regtest_system_CPPFLAGS = -I$(USUAL_DIR) -I$(top_builddir) -I$(srcdir) -I$(builddir) +regtest_compat_CPPFLAGS = $(regtest_system_CPPFLAGS) -DUSUAL_TEST_CONFIG +regtest_compat_LDFLAGS = -pthread -# Quiet by default, 'make V=1' shows commands -V=0 -ifeq ($(V), 0) -Q = @ -E = @echo -else -Q = -E = @true -endif +EXTRA_DIST = Makefile tinytest_demo.c force_compat.sed test_cfparser.ini -all: regtest +noinst_PROGRAMS = regtest_system regtest_compat -obj/%.o: %.c $(hdrs) - @mkdir -p obj - $(E) " CC" $< - $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS) $(WFLAGS) +include ../build.mk -obj/%.o: $(USUAL_DIR)/usual/%.c $(hdrs) - @mkdir -p obj - $(E) " CC" $< - $(Q) $(CC) -c -o $@ $< $(DEFS) $(CFLAGS) $(CPPFLAGS) $(WFLAGS) - -regtest: $(objs) - $(E) " LD" $@ - $(Q) $(CC) -o $@ $(LDFLAGS) $(objs) $(LIBS) - -clean: - rm -f libusual.a obj/* *.o regtest *.gcov - rm -f config.test usual/config.h test_config.h - rm -f regtest.compat regtest.system - rm -f libusual_compat.a libusual_system.a - -config.mak: ../config.mak - cp ../config.mak . - -test_config.h: ../usual/config.h force_compat.sed - $(E) " GEN-COMPAT" $< - $(Q) sed -f force_compat.sed $< > test_config.h - -sys: ../usual/config.h - rm -f test_config.h - cp ../usual/config.h test_config.h - make - -test: regtest - ./regtest - -vcheck: regtest - valgrind --leak-check=full ./regtest - -BADGC = ../usual/base.c ../usual/signal.c -gc: - make clean all CC="$(CC) -fprofile-arcs -ftest-coverage" - ./regtest - gcov -f -o obj $(SRCS) $(filter-out $(BADGC), $(USUAL_SRCS)) > gc.log +$(builddir)/test_config.h: $(srcdir)/force_compat.sed $(top_builddir)/usual/config.h + $(E) " GEN-COMPAT" $@ + $(Q) sed -f $^ > $@ diff --git a/test/attregex/Makefile b/test/attregex/Makefile index 89ab498..4f6ee9b 100644 --- a/test/attregex/Makefile +++ b/test/attregex/Makefile @@ -1,29 +1,29 @@ +SUBLOC = test/attregex -include ../../config.mak +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) +VPATH = $(top_srcdir) +USUAL_DIR = $(top_srcdir) -DEFS += -DUSUAL -DUSE_INTERNAL_REGEX -CPPFLAGS += -I../.. -OBJS = testregex.o regex.o mempool.o +EXTRA_PROGRAMS = testregex.usual testregex.libc -all: testregex.usual testregex.libc +testregex_usual_SOURCES = testregex.c +testregex_usual_DEFS = -DUSUAL -DUSE_INTERNAL_REGEX +testregex_usual_EMBED_LIBUSUAL = 1 -testregex.usual: $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) +testregex_libc_SOURCES = testregex.c -testregex.o: testregex.c - $(CC) $(DEFS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< +EXTRA_DIST = Makefile run.sh \ + data/basic.dat \ + data/categorize.dat \ + data/forcedassoc.dat \ + data/interpretation.dat \ + data/leftassoc.dat \ + data/nullsubexpr.dat \ + data/repetition.dat \ + data/rightassoc.dat -regex.o: ../../usual/regex.c ../../usual/regex.h - $(CC) $(DEFS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< +test: $(EXTRA_PROGRAMS) -mempool.o: ../../usual/mempool.c ../../usual/mempool.h - $(CC) $(DEFS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< - -testregex.libc: testregex.c - $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< - - -clean: - rm -f testregex *.o testregex.usual testregex.libc +include ../../build.mk