From efa2584f3052c520e12f91cb74090735ae75e9be Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 26 Mar 2009 12:11:12 +0000 Subject: First attempt at using the core buildsystem svn path=/trunk/iconv/; revision=6897 --- Makefile | 94 ++++++------ Makefile-riscos | 80 ----------- Makefile-ronative | 59 -------- Makefile.config | 4 + aliases/Makefile | 65 ++------- build/Makefile.common | 158 -------------------- build/Makefile.config | 4 - module/Makefile | 104 +------------- src/Makefile | 49 +------ test/GNU/Makefile | 392 +++++++++++++++++++------------------------------- test/Makefile | 103 +------------ 11 files changed, 224 insertions(+), 888 deletions(-) delete mode 100644 Makefile-riscos delete mode 100644 Makefile-ronative create mode 100644 Makefile.config delete mode 100644 build/Makefile.common delete mode 100644 build/Makefile.config 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 +++ /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 +++ /dev/null @@ -1,59 +0,0 @@ -# Toolchain definitions for building on RISC OS -GCCSDK_INSTALL_ENV ?= - -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 :|$$CSD>|mUnset Alias$$Iconvpwd) -$(shell Iconvpwd Iconv$$Dir) -TOP := - -# 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/Makefile.config b/Makefile.config new file mode 100644 index 0000000..1d27350 --- /dev/null +++ b/Makefile.config @@ -0,0 +1,4 @@ +# Configuration Makefile fragment + +# Cater for local configuration changes +-include build/Makefile.config.override 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 +++ /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/build/Makefile.config b/build/Makefile.config deleted file mode 100644 index 1d27350..0000000 --- a/build/Makefile.config +++ /dev/null @@ -1,4 +0,0 @@ -# Configuration Makefile fragment - -# Cater for local configuration changes --include build/Makefile.config.override 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)/$ $(TOP)/$ $(CURDIR)/$ $(TOP)/$ $(CURDIR)/$ $(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)/$ $(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 -- cgit v1.2.3