summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-03-26 12:11:12 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2009-03-26 12:11:12 (GMT)
commitefa2584f3052c520e12f91cb74090735ae75e9be (patch)
tree08b8374ace3f1a191b63c48c318fcc0a40e442cd
parentce231ac3f456d2e92730d344cda1578eaf1d8add (diff)
downloadiconv-efa2584f3052c520e12f91cb74090735ae75e9be.tar.gz
iconv-efa2584f3052c520e12f91cb74090735ae75e9be.tar.bz2
First attempt at using the core buildsystem
svn path=/trunk/iconv/; revision=6897
-rw-r--r--Makefile94
-rw-r--r--Makefile-riscos80
-rw-r--r--Makefile-ronative59
-rw-r--r--Makefile.config (renamed from build/Makefile.config)0
-rw-r--r--aliases/Makefile65
-rw-r--r--build/Makefile.common158
-rw-r--r--module/Makefile104
-rw-r--r--src/Makefile49
-rw-r--r--test/GNU/Makefile392
-rw-r--r--test/Makefile103
10 files changed, 220 insertions, 884 deletions
diff --git a/Makefile b/Makefile
index 372eb1e..c8bae83 100644
--- a/Makefile
+++ b/Makefile
@@ -1,47 +1,57 @@
-# Toolchain definitions for building on the destination platform
-HOST_CC := gcc
-
-CC := gcc
-AR := ar
-LD := gcc
-
-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
+# Component settings
+COMPONENT := iconv
+# Default to a static library
+COMPONENT_TYPE ?= lib-static
+
+# 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)
-RELEASECFLAGS = $(CFLAGS) -DNDEBUG -O0 -g
-DEBUGCFLAGS = $(CFLAGS) -O0 -g
-ARFLAGS := -cru
-LDFLAGS = -L$(TOP)/ -L$(TOP)/unicode/lib/
-
-CPFLAGS :=
-RMFLAGS := -f
-MKDIRFLAGS := -p
-MVFLAGS :=
-ECHOFLAGS :=
-MAKEFLAGS :=
-PKGCONFIGFLAGS :=
-TOUCHFLAGS :=
-
-EXEEXT :=
-
-# Default installation prefix
-PREFIX ?= /usr/local
-
-
-include build/Makefile.common
+CFLAGS := $(CFLAGS) -std=c99 -D_BSD_SOURCE -I$(CURDIR)/include/ \
+ -I$(CURDIR)/src $(WARNFLAGS)
+
+ifeq ($(TARGET),riscos)
+ LDFLAGS := $(LDFLAGS) -L$(CURDIR)/unicode/libro
+else
+ LDFLAGS := $(LDFLAGS) -L$(CURDIR)/unicode/lib
+endif
+
+include build/makefiles/Makefile.top
+
+# Extra installation rules
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/iconv:include/iconv/iconv.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /lib/pkgconfig:lib$(COMPONENT).pc.in
+INSTALL_ITEMS := $(INSTALL_ITEMS) /lib:$(BUILDDIR)/lib$(COMPONENT)$(LIBEXT)
+
+ifeq ($(TARGET),riscos)
+ # And the RISC OS-specific targets
+
+ DISTCLEAN_ITEMS := $(DISTCLEAN_ITEMS) iconv.zip iconv-pkg.zip
+
+ .PHONY: riscos-dist
+
+ riscos-dist: all
+ @svn export riscos riscos-dist
+ @$(CP) $(CPFLAGS) riscos/!Boot/Resources/!Unicode/Files/Aliases \
+ riscos-dist/!Boot/Resources/!Unicode/Files/
+ @$(CP) $(CPFLAGS) Iconv,ffa riscos-dist/!System/310/Modules/
+ @svn export doc riscos-dist/doc
+ @$(RM) $(RMFLAGS) -r riscos-dist/doc/Standards
+ @$(CP) $(CPFLAGS) include/iconv/iconv.h riscos-dist/stubs/
+ @(cd riscos-dist ; $(GCCSDK_INSTALL_ENV)/bin/zip -9r, ../iconv.zip *)
+ @$(MV) $(MVFLAGS) riscos-dist/!Boot/Resources riscos-dist
+ @$(RM) $(RMFLAGS) -r riscos-dist/!Boot
+ @$(MV) $(MVFLAGS) riscos-dist/!System riscos-dist/System
+ @$(RM) $(RMFLAGS) -r riscos-dist/doc riscos-dist/stubs
+ @$(RM) $(RMFLAGS) riscos-dist/ReadMe
+ @svn export riscpkg/RiscPkg riscos-dist/RiscPkg
+ @$(CP) $(CPFLAGS) COPYING riscos-dist/RiscPkg/Copyright
+ @(cd riscos-dist ; $(GCCSDK_INSTALL_ENV)/bin/zip -9r, ../iconv-pkg.zip *)
+ @$(RM) $(RMFLAGS) -r riscos-dist
+
+endif
diff --git a/Makefile-riscos b/Makefile-riscos
deleted file mode 100644
index 9011964..0000000
--- a/Makefile-riscos
+++ b/dev/null
@@ -1,80 +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
-
-HOST_CC := gcc
-
-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
-# Filthy hack, as cmunge has the gcc binary name hardcoded, but only looks
-# for gcc in the current path, and not in GCCSDK_INSTALL_CROSSBIN.
-CMHG := PATH="$(GCCSDK_INSTALL_CROSSBIN):${PATH}" $(GCCSDK_INSTALL_CROSSBIN)/cmunge
-
-# 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 -mmodule
-RELEASECFLAGS = $(CFLAGS) -DNDEBUG -O2
-DEBUGCFLAGS = $(CFLAGS) -O0 -g
-ARFLAGS := -cru
-LDFLAGS = -mmodule -L$(TOP)/ -L$(TOP)/unicode/libro
-
-CPFLAGS :=
-RMFLAGS := -f
-MKDIRFLAGS := -p
-MVFLAGS :=
-ECHOFLAGS :=
-MAKEFLAGS :=
-PKGCONFIGFLAGS :=
-TOUCHFLAGS :=
-CMHGFLAGS := -p -tgcc -32bit
-
-EXEEXT := ,ffa
-
-# Default installation prefix
-PREFIX ?= $(GCCSDK_INSTALL_ENV)
-
-TARGET := riscos
-
-include build/Makefile.common
-
-# And the RISC OS distribution targets
-
-ITEMS_DISTCLEAN := $(ITEMS_DISTCLEAN) iconv.zip iconv-pkg.zip
-
-riscos-dist: module aliases
- @svn export riscos riscos-dist
- @$(CP) $(CPFLAGS) riscos/!Boot/Resources/!Unicode/Files/Aliases \
- riscos-dist/!Boot/Resources/!Unicode/Files/
- @$(CP) $(CPFLAGS) Iconv,ffa riscos-dist/!System/310/Modules/
- @svn export doc riscos-dist/doc
- @$(RM) $(RMFLAGS) -r riscos-dist/doc/Standards
- @$(CP) $(CPFLAGS) include/iconv/iconv.h riscos-dist/stubs/
- @(cd riscos-dist ; $(GCCSDK_INSTALL_ENV)/bin/zip -9r, ../iconv.zip *)
- @$(MV) $(MVFLAGS) riscos-dist/!Boot/Resources riscos-dist
- @$(RM) $(RMFLAGS) -r riscos-dist/!Boot
- @$(MV) $(MVFLAGS) riscos-dist/!System riscos-dist/System
- @$(RM) $(RMFLAGS) -r riscos-dist/doc riscos-dist/stubs
- @$(RM) $(RMFLAGS) riscos-dist/ReadMe
- @svn export riscpkg/RiscPkg riscos-dist/RiscPkg
- @$(CP) $(CPFLAGS) COPYING riscos-dist/RiscPkg/Copyright
- @(cd riscos-dist ; $(GCCSDK_INSTALL_ENV)/bin/zip -9r, ../iconv-pkg.zip *)
- @$(RM) $(RMFLAGS) -r riscos-dist
-
diff --git a/Makefile-ronative b/Makefile-ronative
deleted file mode 100644
index 64fbed9..0000000
--- a/Makefile-ronative
+++ b/dev/null
@@ -1,59 +0,0 @@
-# Toolchain definitions for building on RISC OS
-GCCSDK_INSTALL_ENV ?= <NSLibs$$Dir>
-
-HOST_CC := gcc
-
-CC := gcc
-AR := ar
-LD := gcc
-
-CP := cp
-RM := rm
-MKDIR := mkdir
-MV := mv
-ECHO := echo
-MAKE := make
-PERL := perl
-PKGCONFIG := echo
-INSTALL := echo
-SED := sed
-TOUCH := touch
-LCOV := echo
-GENHTML := echo
-
-# 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
-RELEASECFLAGS = $(CFLAGS) -DNDEBUG -O2
-DEBUGCFLAGS = $(CFLAGS) -O0 -g
-ARFLAGS := -cru
-LDFLAGS = -L$(TOP)/
-
-CPFLAGS :=
-RMFLAGS := -f
-MKDIRFLAGS := -p
-MVFLAGS :=
-ECHOFLAGS :=
-MAKEFLAGS :=
-PKGCONFIGFLAGS :=
-TOUCHFLAGS :=
-
-EXEEXT :=
-
-# Default installation prefix
-PREFIX ?= $(GCCSDK_INSTALL_ENV)
-
-# This is nasty, but needed because $(CURDIR) will
-# contain colons, and thus confuse make mightily
-$(shell SetMacro Alias$$Iconvpwd Set %0 <FileSwitch$$CurrentFilingSystem>:|<FileSwitch$$<FileSwitch$$CurrentFilingSystem>$$CSD>|mUnset Alias$$Iconvpwd)
-$(shell Iconvpwd Iconv$$Dir)
-TOP := <Iconv$$Dir>
-
-# Tell everyone that we're building on RISC OS, so they can work around things.
-TARGET := riscos
-HOST := riscos
-
-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/aliases/Makefile b/aliases/Makefile
index e5bef95..2251de2 100644
--- a/aliases/Makefile
+++ b/aliases/Makefile
@@ -1,66 +1,25 @@
-# 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
+makealiases_SRCS := makealiases.c
-# Push parent directory onto the directory stack
-sp := $(sp).x
-dirstack_$(sp) := $(d)
-d := $(DIR)
+aliases_DATA := aliases-top character-sets aliases-bottom
-# Extend toolchain settings
-CFLAGS := $(CFLAGS) -I$(TOP)/src -I$(d)
+aliases := $(CURDIR)/riscos/!Boot/Resources/!Unicode/Files/Aliases
-SRCS_$(d) := makealiases.c
+makealiases := $(addprefix $(BUILDDIR)/$(DIR), makealiases)
-DATA_$(d) := aliases-top character-sets aliases-bottom
-
-ALIASES := $(TOP)/riscos/!Boot/Resources/!Unicode/Files/Aliases
-
-MAKEALIASES := $(addprefix $(d), makealiases)
-
-# Items for top-level makefile to use
-ITEMS_CLEAN := $(ITEMS_CLEAN) $(MAKEALIASES)
-
-ITEMS_DISTCLEAN := $(ITEMS_DISTCLEAN) $(ALIASES)
+DISTCLEAN_ITEMS := $(DISTCLEAN_ITEMS) $(aliases)
.PHONY: aliases
# Target for building aliases file
-aliases: $(MAKEALIASES) $(addprefix $(d)data/, $(DATA_$(d)))
- @$(MAKEALIASES) $(wordlist 2,$(words $^),$^) $(ALIASES)
+aliases: $(makealiases) $(addprefix $(DIR)data/, $(aliases_DATA))
+ @$(makealiases) $(wordlist 2,$(words $^),$^) $(aliases)
# Target for building makealiases binary
-$(MAKEALIASES): $(addprefix $(d), $(SRCS_$(d)))
+$(makealiases): $(addprefix $(DIR), $(makealiases_SRCS))
@$(HOST_CC) $(HOST_CCFLAGS) -o $@ $^
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+ifeq ($(MAKECMDGOALS),riscos-dist)
+ POST_TARGETS := $(POST_TARGETS) aliases
+endif
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/build/Makefile.common b/build/Makefile.common
deleted file mode 100644
index 7da0315..0000000
--- a/build/Makefile.common
+++ b/dev/null
@@ -1,158 +0,0 @@
-# Top-level Makefile fragment
-
-# Default target
-all: release
-
-# Name of component
-COMPONENT := libiconv
-
-# Environment
-TOP ?= $(CURDIR)
-EXPORT := $(TOP)/dist
-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/iconv
- @$(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/iconv/*)) $(DESTDIR)$(PREFIX)/include/iconv
-
-uninstall:
- $(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/$(COMPONENT).a
- $(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/pkgconfig/$(COMPONENT).pc
- $(RM) $(RMFLAGS) -r $(DESTDIR)$(PREFIX)/include/iconv
-
-$(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/module/Makefile b/module/Makefile
index 0b1ef05..04c515e 100644
--- a/module/Makefile
+++ b/module/Makefile
@@ -1,103 +1,7 @@
-# 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)
-
-# Module filename
-MODULE := Iconv$(EXEEXT)
-HEADER := $(addprefix $(d), header.o)
-
-# Sources for module
-SRCS_$(d) := module.c menu.c wrapper.c
-
-# Objects for module
-OBJS_$(d) := $(HEADER) $(addprefix $(d), $(subst .c,.o,$(SRCS_$(d))))
-
-# Items for top-level makefile to use
-ITEMS_CLEAN := $(ITEMS_CLEAN) \
- $(OBJS_$(d)) \
- $(addprefix $(d), $(subst .c,.d,$(SRCS_$(d))))
-
-ITEMS_DISTCLEAN := $(ITEMS_DISTCLEAN) $(MODULE)
-
-# Target for building module
-# Please excuse the sick use of wordlist to get hold of the objects to link
-# We can't use $(OBJS_$(d)), as $(d) will be different when the rule is run
-module: release $(OBJS_$(d))
- @$(LD) -o $(MODULE) $(wordlist 2,$(words $^),$^) $(LDFLAGS) -liconv -lunicode
-
-# Target for building module header (mildly hacky)
-$(HEADER): $(addprefix $(d), header.cmhg)
ifeq ($(TARGET),riscos)
- @$(CMHG) $(CMHGFLAGS) $< -o $@ -d $(subst .o,.h,$@)
-else
- @$(TOUCH) $@
+ ifeq ($(COMPONENT_TYPE),binary)
+ DIR_SOURCES := header.cmhg module.c menu.c wrapper.c
+ endif
endif
-DEP_$(d) :=
-
-define dep_module
-DEP_$(d) += $(2)
-$(2): $(1)
- @$$(ECHO) $$(ECHOFLAGS) "DEP $(1)"
- @$$(RM) $$(RMFLAGS) $(2)
- @$$(CC) $$(DEBUGCFLAGS) -MM -MT '$(2) $(3)' -MF $(2) $(1)
-
-endef
-
-# Build rules for each module object
-define compile_module
-$(2): aliases $(1)
- @$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
- @$$(CC) -c $$(RELEASECFLAGS) -o $$@ $(1)
-
-endef
-
-$(eval $(foreach SOURCE,$(addprefix $(d), $(SRCS_$(d))), \
- $(call dep_module,$(SOURCE),$(SOURCE:.c=.d),$(SOURCE:.c=.o))))
-
-ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
--include $(sort $(DEP_$(d)))
-endif
-
-$(eval $(foreach SOURCE,$(addprefix $(d), $(SRCS_$(d))), \
- $(call compile_module,$(SOURCE),$(SOURCE:.c=.o))))
-
-# 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/Makefile b/src/Makefile
index f9d136b..533c878 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) := alias.c aliases.c eightbit.c iconv.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 := alias.c aliases.c eightbit.c iconv.c utils.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir
diff --git a/test/GNU/Makefile b/test/GNU/Makefile
index e770181..75d893f 100644
--- a/test/GNU/Makefile
+++ b/test/GNU/Makefile
@@ -1,259 +1,163 @@
-# Makefile fragment for GNU libiconv tests
-#
-# 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) := table-from table-to genutf8 gengb18030z
-TESTS_$(d) := $(TESTS_$(d))
-
-# Items for top-level makefile to use
-ITEMS_CLEAN := $(ITEMS_CLEAN) \
- $(addprefix $(d), $(addsuffix $(EXEEXT), $(TESTS_$(d)))) \
- $(addprefix $(d), tmp-*) \
- $(addprefix $(d), UTF-8.TXT) \
- $(addprefix $(d), GB18030.TXT) \
- $(addprefix $(d), $(addsuffix .gcda, $(TESTS_$(d)))) \
- $(addprefix $(d), $(addsuffix .gcno, $(TESTS_$(d)))) \
- $(addprefix $(d), $(addsuffix .d, $(TESTS_$(d))))
+DIR_TEST_ITEMS := table-from table-to genutf8 gengb18030z
-# 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)))
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ASCII
+testGNU: $(DIR)
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ASCII
# /* General multi-byte encodings */
-# $(TOP)/$<genutf8 > $(TOP)/$<UTF-8.TXT && $(TOP)/$<check-stateless $(TOP) $(TOP)/$< UTF-8
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UCS-2BE
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UCS-2LE
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UCS-4BE
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UCS-4LE
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UTF-16
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UTF-16BE
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UTF-16LE
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UTF-32
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UTF-32BE
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UTF-32LE
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< UTF-7
+# $(CURDIR)/$<genutf8 > $(CURDIR)/$<UTF-8.TXT && $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< UTF-8
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UCS-2BE
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UCS-2LE
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UCS-4BE
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UCS-4LE
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UTF-16
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UTF-16BE
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UTF-16LE
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UTF-32
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UTF-32BE
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UTF-32LE
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< UTF-7
# /* 8-bit encodings */
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-1
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-2
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-3
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-4
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-5
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-6
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-7
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-8
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-9
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-10
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-11
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-13
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-14
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-15
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-8859-16
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< KOI8-R
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< KOI8-U
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< KOI8-RU
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1250
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1251
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1252
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1253
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1254
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1255
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< CP1255
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1256
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1257
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1258
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< CP1258
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP850
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP862
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP866
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacRoman
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacCentralEurope
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacIceland
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacCroatian
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacRomania
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacCyrillic
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacUkraine
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacGreek
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacTurkish
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacHebrew
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacArabic
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MacThai
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< HP-ROMAN8
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< NEXTSTEP
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ARMSCII-8
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< Georgian-Academy
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< Georgian-PS
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< KOI8-T
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< PT154
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< RK1048
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< MuleLao-1
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1133
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< TIS-620
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP874
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< VISCII
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< TCVN
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< TCVN
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-1
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-2
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-3
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-4
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-5
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-6
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-7
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-8
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-9
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-10
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-11
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-13
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-14
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-15
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-8859-16
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< KOI8-R
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< KOI8-U
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< KOI8-RU
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1250
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1251
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1252
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1253
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1254
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1255
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< CP1255
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1256
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1257
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1258
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< CP1258
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP850
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP862
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP866
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacRoman
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacCentralEurope
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacIceland
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacCroatian
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacRomania
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacCyrillic
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacUkraine
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacGreek
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacTurkish
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacHebrew
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacArabic
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MacThai
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< HP-ROMAN8
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< NEXTSTEP
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ARMSCII-8
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< Georgian-Academy
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< Georgian-PS
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< KOI8-T
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< PT154
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< RK1048
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< MuleLao-1
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1133
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< TIS-620
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP874
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< VISCII
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< TCVN
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< TCVN
# /* CJK character sets */
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO646-JP
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< JIS_X0201
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< JIS_X0208 # redundant, see EUC-JP
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< JIS_X0212 # redundant, see EUC-JP
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO646-CN
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< GB_2312-80 # redundant, see EUC-CN
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ISO-IR-165
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< KSC_5601 # redundant, see EUC-KR
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO646-JP
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< JIS_X0201
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< JIS_X0208 # redundant, see EUC-JP
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< JIS_X0212 # redundant, see EUC-JP
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO646-CN
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< GB_2312-80 # redundant, see EUC-CN
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ISO-IR-165
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< KSC_5601 # redundant, see EUC-KR
# /* CJK encodings */
- -$(TOP)/$<check-stateless $(TOP) $(TOP)/$< EUC-JP
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< SHIFT_JIS
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP932
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< ISO-2022-JP
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< ISO-2022-JP-2
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< ISO-2022-JP-1
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< EUC-CN
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< GBK
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP936
-# { cat $(TOP)/$<GB18030-BMP.TXT ; $(TOP)/$<gengb18030z ; } | sort > $(TOP)/$<GB18030.TXT && $(TOP)/$<check-stateless $(TOP) $(TOP)/$< GB18030
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< ISO-2022-CN
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< ISO-2022-CN-EXT
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< HZ
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< EUC-TW
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< BIG5
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP950
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< BIG5-HKSCS:1999
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< BIG5-HKSCS:1999
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< BIG5-HKSCS:2001
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< BIG5-HKSCS:2001
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< BIG5-HKSCS:2004
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< BIG5-HKSCS:2004
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< EUC-KR
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP949
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< JOHAB
- $(TOP)/$<check-stateful $(TOP) $(TOP)/$< ISO-2022-KR
+ -$(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< EUC-JP
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< SHIFT_JIS
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP932
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< ISO-2022-JP
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< ISO-2022-JP-2
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< ISO-2022-JP-1
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< EUC-CN
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< GBK
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP936
+# { cat $(CURDIR)/$<GB18030-BMP.TXT ; $(CURDIR)/$<gengb18030z ; } | sort > $(CURDIR)/$<GB18030.TXT && $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< GB18030
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< ISO-2022-CN
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< ISO-2022-CN-EXT
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< HZ
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< EUC-TW
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< BIG5
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP950
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< BIG5-HKSCS:1999
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< BIG5-HKSCS:1999
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< BIG5-HKSCS:2001
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< BIG5-HKSCS:2001
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< BIG5-HKSCS:2004
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< BIG5-HKSCS:2004
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< EUC-KR
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP949
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< JOHAB
+ $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< ISO-2022-KR
# /* transliteration */
-# $(TOP)/$<check-translit $(TOP)/$< Quotes UTF-8 ISO-8859-1
-# $(TOP)/$<check-translit $(TOP)/$< Quotes UTF-8 ASCII
-# $(TOP)/$<check-translit $(TOP)/$< Translit1 ISO-8859-1 ASCII
-# $(TOP)/$<check-translitfailure $(TOP)/$< TranslitFail1 ISO-8859-1 ASCII
+# $(CURDIR)/$<check-translit $(CURDIR)/$< Quotes UTF-8 ISO-8859-1
+# $(CURDIR)/$<check-translit $(CURDIR)/$< Quotes UTF-8 ASCII
+# $(CURDIR)/$<check-translit $(CURDIR)/$< Translit1 ISO-8859-1 ASCII
+# $(CURDIR)/$<check-translitfailure $(CURDIR)/$< TranslitFail1 ISO-8859-1 ASCII
# /* substitution */
-# $(TOP)/$<check-subst
+# $(CURDIR)/$<check-subst
# /* system dependent and extra encodings */
# /* AIX specific encodings */
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP856
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP922
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP943
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1046
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1124
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1129
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1161
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1162
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1163
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP856
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP922
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP943
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1046
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1124
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1129
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1161
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1162
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1163
# /* OSF/1 specific encodings */
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< DEC-KANJI
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< DEC-HANYU
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< DEC-KANJI
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< DEC-HANYU
# /* DOS specific encodings */
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP437
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP737
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP775
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP852
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP853
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP855
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP857
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP858
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP860
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP861
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP863
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP864
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP865
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP869
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< CP1125
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP437
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP737
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP775
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP852
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP853
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP855
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP857
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP858
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP860
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP861
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP863
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP864
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP865
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP869
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< CP1125
# /* Extra encodings */
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< EUC-JISX0213
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< SHIFT_JISX0213
-# $(TOP)/$<check-stateful $(TOP) $(TOP)/$< ISO-2022-JP-3
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< BIG5-2003
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< TDS565
-# $(TOP)/$<check-stateless $(TOP) $(TOP)/$< ATARIST
- $(TOP)/$<check-stateless $(TOP) $(TOP)/$< X-ACORN-LATIN1
-
-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
-# Except when building on RISC OS, of course because then make utterly fails to
-# detect that the debug library exists.
-define compile_test
-ifeq ($(HOST),riscos)
-$(2): $(1)
-else
-$(2): $$(TOP)/$$(COMPONENT)-debug.a module aliases $(1)
-endif
- @$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
- @$$(CC) -c -g $$(DEBUGCFLAGS) -o $$@.o $(1)
- @$$(LD) -g -o $$@ $$@.o $$(LDFLAGS) -liconv-debug -lunicode
- @$$(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))))
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< EUC-JISX0213
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< SHIFT_JISX0213
+# $(CURDIR)/$<check-stateful $(CURDIR) $(CURDIR)/$< ISO-2022-JP-3
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< BIG5-2003
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< TDS565
+# $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< ATARIST
+ $(CURDIR)/$<check-stateless $(CURDIR) $(CURDIR)/$< X-ACORN-LATIN1
-# Now include any children we may have
-MAKE_INCLUDES := $(wildcard $(d)*/Makefile)
-$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC))))
+TEST_TARGETS := $(TEST_TARGETS) testGNU
-# 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 a11f948..a1a8c08 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,103 +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)
-
-# Extend toolchain settings
-CFLAGS := $(CFLAGS) -I$(TOP)/src/ -I$(d)
-
# Tests
-TESTS_$(d) := iconv
-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
-# Except when building on RISC OS, of course because then make utterly fails to
-# detect that the debug library exists.
-define compile_test
-ifeq ($(HOST),riscos)
-$(2): $(1)
-else
-$(2): $$(TOP)/$$(COMPONENT)-debug.a aliases $(1)
-endif
- @$$(ECHO) $$(ECHOFLAGS) "==> $(1)"
- @$$(CC) -c -g $$(DEBUGCFLAGS) -o $$@.o $(1)
- @$$(LD) -g -o $$@ $$@.o $$(LDFLAGS) -liconv-debug -lunicode
- @$$(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_ITEMS := iconv:iconv.c
-# Finally, pop off the directory stack
-d := $(dirstack_$(sp))
-sp := $(basename $(sp))
+include build/makefiles/Makefile.subdir