summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-03-24 18:11:31 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-03-24 18:11:31 +0000
commite3d8b0db2cae189f290cb82c30b6ce22667668c0 (patch)
treee567c2bb0150dade3d6ef6eb3d2a03fae8a5fa22
parentc7e62664467b2834b2a980b02effb7a9fc82fbeb (diff)
downloadlibcss-e3d8b0db2cae189f290cb82c30b6ce22667668c0.tar.gz
libcss-e3d8b0db2cae189f290cb82c30b6ce22667668c0.tar.bz2
Port to new buildsystem
svn path=/trunk/libcss/; revision=6856
-rw-r--r--Makefile68
-rw-r--r--Makefile-riscos53
-rw-r--r--Makefile.config (renamed from build/Makefile.config)0
-rw-r--r--build/Makefile.common158
-rw-r--r--src/Makefile49
-rw-r--r--src/bytecode/Makefile48
-rw-r--r--src/charset/Makefile46
-rw-r--r--src/lex/Makefile49
-rw-r--r--src/parse/Makefile49
-rw-r--r--src/select/Makefile49
-rw-r--r--src/utils/Makefile46
-rw-r--r--test/Makefile99
12 files changed, 47 insertions, 667 deletions
diff --git a/Makefile b/Makefile
index ce2d84b..838167d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,46 +1,40 @@
-# Toolchain definitions for building on the destination platform
-CC := gcc
-AR := ar
-LD := gcc
+# Component settings
+COMPONENT := css
+# Default to a static library
+COMPONENT_TYPE ?= lib-static
-CP := cp
-RM := rm
-MKDIR := mkdir
-MV := mv
-ECHO := echo
-MAKE := make
-PERL := perl
-PKGCONFIG := pkg-config
-INSTALL := install
-SED := sed
-TOUCH := touch
-LCOV := lcov
-GENHTML := genhtml
+# Setup the tooling
+include build/makefiles/Makefile.tools
+
+TESTRUNNER := $(PERL) build/testtools/testrunner.pl
# Toolchain flags
WARNFLAGS := -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wnested-externs -Werror -pedantic
-CFLAGS += -std=c99 -D_BSD_SOURCE -I$(TOP)/include/ $(WARNFLAGS) \
- `$(PKGCONFIG) --cflags libparserutils libwapcaplet`
-RELEASECFLAGS = $(CFLAGS) -DNDEBUG -O2
-DEBUGCFLAGS = $(CFLAGS) -O0 -g
-ARFLAGS := -cru
-LDFLAGS += `$(PKGCONFIG) --libs libparserutils libwapcaplet` -L$(TOP)/
-
-CPFLAGS :=
-RMFLAGS := -f
-MKDIRFLAGS := -p
-MVFLAGS :=
-ECHOFLAGS :=
-MAKEFLAGS :=
-PKGCONFIGFLAGS :=
-TOUCHFLAGS :=
-
-EXEEXT :=
+CFLAGS := $(CFLAGS) -std=c99 -D_BSD_SOURCE -I$(CURDIR)/include/ \
+ -I$(CURDIR)/src $(WARNFLAGS)
-# Default installation prefix
-PREFIX ?= /usr/local
+# Parserutils
+ifneq ($(PKGCONFIG),)
+ CFLAGS := $(CFLAGS) $(shell $(PKGCONFIG) libparserutils --cflags)
+ LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) libparserutils --libs)
+else
+ LDFLAGS := $(LDFLAGS) -lparserutils
+endif
+include build/makefiles/Makefile.top
-include build/Makefile.common
+# Extra installation rules
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/computed.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/errors.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/fpmath.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/functypes.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/hint.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/libcss.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/properties.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/select.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/stylesheet.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libcss:include/libcss/types.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /lib/pkgconfig:lib$(COMPONENT).pc.in
+INSTALL_ITEMS := $(INSTALL_ITEMS) /lib:$(BUILDDIR)/lib$(COMPONENT)$(LIBEXT)
diff --git a/Makefile-riscos b/Makefile-riscos
deleted file mode 100644
index 9070588..0000000
--- a/Makefile-riscos
+++ /dev/null
@@ -1,53 +0,0 @@
-# Toolchain definitions for building for RISC OS using the GCCSDK cross-compiler
-GCCSDK_INSTALL_CROSSBIN ?= /home/riscos/cross/bin
-GCCSDK_INSTALL_ENV ?= /home/riscos/env
-
-CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
-AR := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*ar)
-LD := $(CC)
-
-CP := cp
-RM := rm
-MKDIR := mkdir
-MV := mv
-ECHO := echo
-MAKE := make
-PERL := perl
-PKGCONFIG := $(GCCSDK_INSTALL_ENV)/ro-pkg-config
-INSTALL := install
-SED := sed
-TOUCH := touch
-LCOV := echo
-GENHTML := echo
-DOXYGEN := doxygen
-
-# Toolchain flags
-WARNFLAGS := -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
- -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
- -Wmissing-declarations -Wnested-externs -Werror -pedantic
-CFLAGS += -std=c99 -D_BSD_SOURCE -I$(TOP)/include/ $(WARNFLAGS) \
- -mpoke-function-name `$(PKGCONFIG) --cflags libparserutils`
-RELEASECFLAGS = $(CFLAGS) -DNDEBUG -O2
-DEBUGCFLAGS = $(CFLAGS) -O0 -g
-ARFLAGS := -cru
-LDFLAGS += `$(PKGCONFIG) --libs libparserutils` -L$(TOP)/
-
-CPFLAGS :=
-RMFLAGS := -f
-MKDIRFLAGS := -p
-MVFLAGS :=
-ECHOFLAGS :=
-MAKEFLAGS :=
-PKGCONFIGFLAGS :=
-TOUCHFLAGS :=
-
-ifneq (,$(findstring arm-unknown-riscos-gcc,$(CC)))
- EXEEXT := ,e1f
-else
- EXEEXT := ,ff8
-endif
-
-# Default installation prefix
-PREFIX ?= $(GCCSDK_INSTALL_ENV)
-
-include build/Makefile.common
diff --git a/build/Makefile.config b/Makefile.config
index 1d27350..1d27350 100644
--- a/build/Makefile.config
+++ b/Makefile.config
diff --git a/build/Makefile.common b/build/Makefile.common
deleted file mode 100644
index 73a4880..0000000
--- a/build/Makefile.common
+++ /dev/null
@@ -1,158 +0,0 @@
-# Top-level Makefile fragment
-
-# Default target
-all: release
-
-# Name of component
-COMPONENT := libcss
-
-# Environment
-EXPORT := $(CURDIR)/dist
-TOP := $(CURDIR)
-RELEASEDIR := build/Release
-DEBUGDIR := build/Debug
-COVERAGEDIR := build/coverage
-
-# List of items to delete on clean
-ITEMS_CLEAN :=
-# List of items to delete on distclean
-ITEMS_DISTCLEAN :=
-
-# List of targets to run for testing
-TARGET_TESTS :=
-
-# Source files
-SOURCES :=
-
-# Include configuration Makefile fragment
-include build/Makefile.config
-
-# Include Makefile fragments in subdirectories
-
-define do_include
-DIR := $$(dir $(1))
-include $(1)
-
-endef
-
-MAKE_INCLUDES := $(wildcard */Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
-
-# Calculate objects to build
-OBJECTS := $(subst /,_,$(subst .c,.o,$(SOURCES)))
-
-.PHONY: release debug test coverage profile \
- clean distclean setup export install uninstall
-
-# Rules
-release: setup $(addprefix $(RELEASEDIR)/,$(OBJECTS))
- @$(AR) $(ARFLAGS) $(COMPONENT).a $(addprefix $(RELEASEDIR)/,$(OBJECTS))
-
-debug: setup $(addprefix $(DEBUGDIR)/,$(OBJECTS))
- @$(AR) $(ARFLAGS) $(COMPONENT)-debug.a \
- $(addprefix $(DEBUGDIR)/,$(OBJECTS))
-
-test: debug $(TARGET_TESTS)
-
-coverage: clean
- @$(LCOV) --directory . --zerocounters
- @$(MAKE) test CFLAGS="$(CFLAGS) -fprofile-arcs -ftest-coverage" \
- LDFLAGS="$(LDFLAGS) -lgcov"
- @$(LCOV) --directory $(DEBUGDIR) --base-directory $(TOP) \
- --capture --output-file $(COVERAGEDIR)/$(COMPONENT)_tmp.info
- @$(LCOV) --extract $(COVERAGEDIR)/$(COMPONENT)_tmp.info "$(TOP)/src*" \
- -o $(COVERAGEDIR)/$(COMPONENT).info
- @$(RM) $(RMFLAGS) $(COVERAGEDIR)/$(COMPONENT)_tmp.info
- @$(GENHTML) -o $(COVERAGEDIR) --num-spaces 2 \
- $(COVERAGEDIR)/$(COMPONENT).info
-
-profile: clean
- @$(MAKE) test CFLAGS="$(CFLAGS) -pg" LDFLAGS="-pg $(LDFLAGS)"
-
-clean:
- -@$(RM) $(RMFLAGS) $(ITEMS_CLEAN)
- -@$(RM) $(RMFLAGS) gmon.out
- -@$(RM) $(RMFLAGS) -r $(COVERAGEDIR)
- -@$(RM) $(RMFLAGS) -r $(RELEASEDIR)
- -@$(RM) $(RMFLAGS) -r $(DEBUGDIR)
- -@$(RM) $(RMFLAGS) $(COMPONENT).a
- -@$(RM) $(RMFLAGS) $(COMPONENT)-debug.a
- -@$(RM) $(RMFLAGS) $(COMPONENT).pc
-
-distclean: clean
- -@$(RM) $(RMFLAGS) $(ITEMS_DISTCLEAN)
- -@$(RM) $(RMFLAGS) -r $(TOP)/dist
-
-setup:
- @$(MKDIR) $(MKDIRFLAGS) $(RELEASEDIR)/deps
- @$(MKDIR) $(MKDIRFLAGS) $(DEBUGDIR)/deps
- @$(MKDIR) $(MKDIRFLAGS) $(COVERAGEDIR)
-
-export:
- @$(MKDIR) $(MKDIRFLAGS) -p $(TOP)/dist
- @$(MAKE) install PREFIX="$(TOP)/dist"
-
-install: release
- @$(MKDIR) $(MKDIRFLAGS) -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
- @$(MKDIR) $(MKDIRFLAGS) -p $(DESTDIR)$(PREFIX)/include/libcss
- @$(SED) -e 's#PREFIX#$(PREFIX)#' $(COMPONENT).pc.in >$(COMPONENT).pc
- $(INSTALL) -m 644 $(COMPONENT).a $(DESTDIR)$(PREFIX)/lib
- $(INSTALL) -m 644 $(COMPONENT).pc $(DESTDIR)$(PREFIX)/lib/pkgconfig
- $(INSTALL) -m 644 $(filter %.h, $(wildcard include/libcss/*)) $(DESTDIR)$(PREFIX)/include/libcss
-
-uninstall:
- $(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/$(COMPONENT).a
- $(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/pkgconfig/$(COMPONENT).pc
- $(RM) $(RMFLAGS) -r $(DESTDIR)$(PREFIX)/include/libcss
-
-$(RELEASEDIR)/deps/created:
- @$(MKDIR) $(MKDIRFLAGS) $(RELEASEDIR)/deps
- @$(TOUCH) $(TOUCHFLAGS) $(RELEASEDIR)/deps/created
-
-$(DEBUGDIR)/deps/created:
- @$(MKDIR) $(MKDIRFLAGS) $(DEBUGDIR)/deps
- @$(TOUCH) $(TOUCHFLAGS) $(DEBUGDIR)/deps/created
-
-DEPFILES :=
-
-define do_dep
-DEPFILES += $(2)
-$$(RELEASEDIR)/deps/$(2): $$(RELEASEDIR)/deps/created $(1)
- @$$(ECHO) $$(ECHOFLAGS) "DEP $(1)"
- @$$(RM) $$(RMFLAGS) $$(RELEASEDIR)/deps/$(2)
- @$$(CC) $$(RELEASECFLAGS) -MM -MT \
- '$$(RELEASEDIR)/deps/$(2) $$(RELEASEDIR)/$(3)' \
- -MF $$(RELEASEDIR)/deps/$(2) $(1)
-
-$$(DEBUGDIR)/deps/$(2): $$(DEBUGDIR)/deps/created $(1)
- @$$(ECHO) $$(ECHOFLAGS) "DEP $(1)"
- @$$(RM) $$(RMFLAGS) $$(DEBUGDIR)/deps/$(2)
- @$$(CC) $$(DEBUGCFLAGS) -MM -MT \
- '$$(DEBUGDIR)/deps/$(2) $$(DEBUGDIR)/$(3)' \
- -MF $$(DEBUGDIR)/deps/$(2) $(1)
-
-endef
-
-# Finally, build rules for compilation
-define do_compile
-$$(RELEASEDIR)/$(2): $(1)
- @$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
- @$$(CC) -c $$(RELEASECFLAGS) -o $$@ $(1)
-
-$$(DEBUGDIR)/$(2): $(1)
- @$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
- @$$(CC) -c $$(DEBUGCFLAGS) -o $$@ $(1)
-
-endef
-
-$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
- $(call do_dep,$(SOURCE),$(subst /,_,$(SOURCE:.c=.d)),$(subst /,_,$(SOURCE:.c=.o)))))
-
-ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
--include $(sort $(addprefix $(RELEASEDIR)/deps/,$(DEPFILES)))
--include $(sort $(addprefix $(DEBUGDIR)/deps/,$(DEPFILES)))
-endif
-
-$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
- $(call do_compile,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)))))
-
diff --git a/src/Makefile b/src/Makefile
index 75b6515..5e17355 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,49 +1,4 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
-# Manipulate include paths
-CFLAGS := $(CFLAGS) -I$(d)
-
# Sources
-SRCS_$(d) := libcss.c stylesheet.c
-
-# Append to sources for component
-SOURCES += $(addprefix $(d), $(SRCS_$(d)))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+DIR_SOURCES := libcss.c stylesheet.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/src/bytecode/Makefile b/src/bytecode/Makefile
index 143df29..b322cde 100644
--- a/src/bytecode/Makefile
+++ b/src/bytecode/Makefile
@@ -1,49 +1,3 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
-# Manipulate include paths
-CFLAGS := $(CFLAGS) -I$(d)
-
# Sources
-SRCS_$(d) :=
-
-# Append to sources for component
-SOURCES += $(addprefix $(d), $(SRCS_$(d)))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/src/charset/Makefile b/src/charset/Makefile
index dda58c1..7cc517e 100644
--- a/src/charset/Makefile
+++ b/src/charset/Makefile
@@ -1,46 +1,4 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
# Sources
-SRCS_$(d) := detect.c
-
-# Append to sources for component
-SOURCES += $(addprefix $(d), $(SRCS_$(d)))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+DIR_SOURCES := detect.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/src/lex/Makefile b/src/lex/Makefile
index 73f8ecf..a14073a 100644
--- a/src/lex/Makefile
+++ b/src/lex/Makefile
@@ -1,49 +1,4 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
-# Manipulate include paths
-CFLAGS := $(CFLAGS) -I$(d)
-
# Sources
-SRCS_$(d) := lex.c
-
-# Append to sources for component
-SOURCES += $(addprefix $(d), $(SRCS_$(d)))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+DIR_SOURCES := lex.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/src/parse/Makefile b/src/parse/Makefile
index 7d42214..4d0603f 100644
--- a/src/parse/Makefile
+++ b/src/parse/Makefile
@@ -1,49 +1,4 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
-# Manipulate include paths
-CFLAGS := $(CFLAGS) -I$(d)
-
# Sources
-SRCS_$(d) := parse.c language.c
-
-# Append to sources for component
-SOURCES += $(addprefix $(d), $(SRCS_$(d)))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+DIR_SOURCES := parse.c language.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/src/select/Makefile b/src/select/Makefile
index ea105fe..0fe1a5e 100644
--- a/src/select/Makefile
+++ b/src/select/Makefile
@@ -1,49 +1,4 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
-# Manipulate include paths
-CFLAGS := $(CFLAGS) -I$(d)
-
# Sources
-SRCS_$(d) := computed.c dispatch.c hash.c properties.c select.c
-
-# Append to sources for component
-SOURCES += $(addprefix $(d), $(SRCS_$(d)))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+DIR_SOURCES := computed.c dispatch.c hash.c properties.c select.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/src/utils/Makefile b/src/utils/Makefile
index 71d9817..ab5e2c7 100644
--- a/src/utils/Makefile
+++ b/src/utils/Makefile
@@ -1,46 +1,4 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
# Sources
-SRCS_$(d) := errors.c utils.c
-
-# Append to sources for component
-SOURCES += $(addprefix $(d), $(SRCS_$(d)))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+DIR_SOURCES := errors.c utils.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/test/Makefile b/test/Makefile
index 67c81fe..c876014 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,98 +1,5 @@
-# Child makefile fragment
-#
-# Toolchain is provided by top-level makefile
-#
-# Variables provided by top-level makefile
-#
-# COMPONENT The name of the component
-# EXPORT The location of the export directory
-# TOP The location of the source tree root
-# RELEASEDIR The place to put release objects
-# DEBUGDIR The place to put debug objects
-#
-# do_include Canned command sequence to include a child makefile
-#
-# Variables provided by parent makefile:
-#
-# DIR The name of the directory we're in, relative to $(TOP)
-#
-# Variables we can manipulate:
-#
-# ITEMS_CLEAN The list of items to remove for "make clean"
-# ITEMS_DISTCLEAN The list of items to remove for "make distclean"
-# TARGET_TESTS The list of target names to run for "make test"
-#
-# SOURCES The list of sources to build for $(COMPONENT)
-#
-# Plus anything from the toolchain
-
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
-
-# Extend toolchain settings
-CFLAGS := $(CFLAGS) -I$(TOP)/src/ -I$(d)
-
# Tests
-TESTS_$(d) := csdetect css21 lex lex-auto libcss number parse parse-auto \
- parse2-auto select-auto
-TESTS_$(d) := $(TESTS_$(d))
-
-# Items for top-level makefile to use
-ITEMS_CLEAN := $(ITEMS_CLEAN) \
- $(addprefix $(d), $(addsuffix $(EXEEXT), $(TESTS_$(d)))) \
- $(addprefix $(d), $(addsuffix .gcda, $(TESTS_$(d)))) \
- $(addprefix $(d), $(addsuffix .gcno, $(TESTS_$(d)))) \
- $(addprefix $(d), $(addsuffix .d, $(TESTS_$(d))))
-ITEMS_DISTCLEAN := $(ITEMS_DISTCLEAN) $(d)log
-
-# Targets for top-level makefile to run
-TARGET_TESTS := $(TARGET_TESTS) test_$(d)
-
-# Now we get to hack around so that we know what directory we're in.
-# $(d) no longer exists when running the commands for a target, so we can't
-# simply use it verbatim. Assigning to a variable doesn't really help, as
-# there's no guarantee that someone else hasn't overridden that variable.
-# So, what we do is make the target depend on $(d), then pick it out of the
-# dependency list when running commands. This isn't pretty, but is effective.
-test_$(d): $(d) $(addprefix $(d), $(TESTS_$(d)))
- @$(PERL) $(TOP)/$<testrunner.pl $(TOP)/$< $(EXEEXT)
-
-DEP_$(d) :=
-
-define dep_test
-DEP_$(d) += $(2)
-$(2): $(1)
- @$$(RM) $$(RMFLAGS) $(2)
- @$$(CC) $$(DEBUGCFLAGS) -MM -MT '$(2) $(3)' -MF $(2) $(1)
-
-endef
-
-# Build rules for each test binary -- they all depend on the debug library
-define compile_test
-$(2): $$(TOP)/$$(COMPONENT)-debug.a $(1)
- @$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
- @$$(CC) -c -g $$(DEBUGCFLAGS) -o $$@.o $(1)
- @$$(LD) -g -o $$@ $$@.o -lcss-debug $$(LDFLAGS)
- @$$(RM) $$(RMFLAGS) $$@.o
-
-endef
-
-$(eval $(foreach TEST,$(addprefix $(d), $(TESTS_$(d))), \
- $(call dep_test,$(addsuffix .c, $(TEST)),$(addsuffix .d, $(TEST)),$(TEST))))
-
-ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
--include $(sort $(DEP_$(d)))
-endif
-
-$(eval $(foreach TEST,$(addprefix $(d), $(TESTS_$(d))), \
- $(call compile_test,$(addsuffix .c, $(TEST)),$(TEST))))
-
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+DIR_TEST_SOURCES := csdetect.c css21.c lex.c lex-auto.c libcss.c \
+ number.c parse.c parse-auto.c parse2-auto.c select-auto.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir