From 90b089d7fd6454771b23fdcebb78d3b1a469c3f5 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 7 Apr 2008 02:11:49 +0000 Subject: Rework buildsystem so that it no longer calls make recursively and rebuilds the testcases when the library changes. svn path=/trunk/hubbub/; revision=4077 --- src/Makefile | 109 +++++++++++++++++-------------------------------- src/charset/Makefile | 79 ++++++++++++++++------------------- src/input/Makefile | 79 ++++++++++++++++------------------- src/tokeniser/Makefile | 79 ++++++++++++++++------------------- src/utils/Makefile | 79 ++++++++++++++++------------------- 5 files changed, 182 insertions(+), 243 deletions(-) (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 7af11a4..1c733f7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,82 +1,49 @@ -# Makefile for libhubbub +# Child makefile fragment for libhubbub # -# Toolchain is exported by top-level makefile +# Toolchain is provided by top-level makefile # -# Top-level makefile also exports the following variables: +# Variables provided by top-level makefile # -# COMPONENT Name of component -# EXPORT Absolute path of export directory -# TOP Absolute path of source tree root +# 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 # -# The top-level makefile requires the following targets to exist: +# do_include Canned command sequence to include a child makefile # -# clean Clean source tree -# debug Create a debug binary -# distclean Fully clean source tree, back to pristine condition -# export Export distributable components to ${EXPORT} -# release Create a release binary -# setup Perform any setup required prior to compilation -# test Execute any test cases - -# Manipulate include paths -CFLAGS += -I$(CURDIR) - -# Release output -RELEASE = ${TOP}/${COMPONENT}.a - -# Debug output -DEBUG = ${TOP}/${COMPONENT}-debug.a - -# Objects -OBJS = hubbub parser - -.PHONY: clean debug distclean export release setup test - -# Targets -release: $(addprefix Release/, $(addsuffix .o, $(OBJS))) - @${MAKE} -C charset release - @${MAKE} -C input release - @${MAKE} -C tokeniser release - @${MAKE} -C treebuilder release - @${MAKE} -C utils release - @${AR} ${ARFLAGS} $(RELEASE) Release/* - -debug: $(addprefix Debug/, $(addsuffix .o, $(OBJS))) - @${MAKE} -C charset debug - @${MAKE} -C input debug - @${MAKE} -C tokeniser debug - @${MAKE} -C treebuilder debug - @${MAKE} -C utils debug - @${AR} ${ARFLAGS} $(DEBUG) Debug/* - -clean: - @${MAKE} -C charset clean - @${MAKE} -C input clean - @${MAKE} -C tokeniser clean - @${MAKE} -C treebuilder clean - @${MAKE} -C utils clean - -@${RM} ${RMFLAGS} $(addprefix Release/, $(addsuffix .o, ${OBJS})) - -@${RM} ${RMFLAGS} $(addprefix Debug/, $(addsuffix .o, ${OBJS})) - -@${RM} ${RMFLAGS} $(RELEASE) $(DEBUG) +# 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 -distclean: - -@${RM} ${RMFLAGS} -r Release - -@${RM} ${RMFLAGS} -r Debug +# Push parent directory onto the directory stack +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(DIR) -setup: - @${MKDIR} ${MKDIRFLAGS} Release - @${MKDIR} ${MKDIRFLAGS} Debug +# Manipulate include paths +CFLAGS := $(CFLAGS) -I$(d) -export: - @${CP} ${CPFLAGS} $(RELEASE) ${EXPORT}/lib/ +# Sources +SRCS_$(d) := hubbub.c parser.c -test: +# Append to sources for component +SOURCES += $(addprefix $(d), $(SRCS_$(d))) -# Pattern rules -Release/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $< +# Now include any children we may have +MAKE_INCLUDES := $(wildcard $(d)*/Makefile) +$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC)))) -Debug/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c -g ${CFLAGS} -o $@ $< +# Finally, pop off the directory stack +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/src/charset/Makefile b/src/charset/Makefile index c0a00b3..2e76730 100644 --- a/src/charset/Makefile +++ b/src/charset/Makefile @@ -1,53 +1,46 @@ -# Makefile for libhubbub +# Child makefile fragment for libhubbub # -# Toolchain is exported by top-level makefile +# Toolchain is provided by top-level makefile # -# Top-level makefile also exports the following variables: +# Variables provided by top-level makefile # -# COMPONENT Name of component -# EXPORT Absolute path of export directory -# TOP Absolute path of source tree root +# 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 # -# The top-level makefile requires the following targets to exist: +# do_include Canned command sequence to include a child makefile # -# clean Clean source tree -# debug Create a debug binary -# distclean Fully clean source tree, back to pristine condition -# export Export distributable components to ${EXPORT} -# release Create a release binary -# setup Perform any setup required prior to compilation -# test Execute any test cases - -# Manipulate include paths -CFLAGS += -I$(CURDIR) - -# Objects -OBJS = aliases codec codec_iconv codec_utf8 codec_utf16 detect - -.PHONY: clean debug distclean export release setup test - -# Targets -release: $(addprefix ../Release/, $(addsuffix .o, $(OBJS))) - -debug: $(addprefix ../Debug/, $(addsuffix .o, $(OBJS))) - -clean: - -@${RM} ${RMFLAGS} $(addprefix ../Release/, $(addsuffix .o, ${OBJS})) - -@${RM} ${RMFLAGS} $(addprefix ../Debug/, $(addsuffix .o, ${OBJS})) - -distclean: +# 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 -setup: +# Push parent directory onto the directory stack +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(DIR) -export: +# Sources +SRCS_$(d) := aliases.c codec.c codec_iconv.c codec_utf8.c codec_utf16.c detect.c -test: +# Append to sources for component +SOURCES += $(addprefix $(d), $(SRCS_$(d))) -# Pattern rules -../Release/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $< +# Now include any children we may have +MAKE_INCLUDES := $(wildcard $(d)*/Makefile) +$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC)))) -../Debug/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c -g ${CFLAGS} -o $@ $< +# Finally, pop off the directory stack +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/src/input/Makefile b/src/input/Makefile index 06f8ee4..3b9206f 100644 --- a/src/input/Makefile +++ b/src/input/Makefile @@ -1,53 +1,46 @@ -# Makefile for libhubbub +# Child makefile fragment for libhubbub # -# Toolchain is exported by top-level makefile +# Toolchain is provided by top-level makefile # -# Top-level makefile also exports the following variables: +# Variables provided by top-level makefile # -# COMPONENT Name of component -# EXPORT Absolute path of export directory -# TOP Absolute path of source tree root +# 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 # -# The top-level makefile requires the following targets to exist: +# do_include Canned command sequence to include a child makefile # -# clean Clean source tree -# debug Create a debug binary -# distclean Fully clean source tree, back to pristine condition -# export Export distributable components to ${EXPORT} -# release Create a release binary -# setup Perform any setup required prior to compilation -# test Execute any test cases - -# Manipulate include paths -CFLAGS += -I$(CURDIR) - -# Objects -OBJS = filter inputstream utf8_stream utf16_stream - -.PHONY: clean debug distclean export release setup test - -# Targets -release: $(addprefix ../Release/, $(addsuffix .o, $(OBJS))) - -debug: $(addprefix ../Debug/, $(addsuffix .o, $(OBJS))) - -clean: - -@${RM} ${RMFLAGS} $(addprefix ../Release/, $(addsuffix .o, ${OBJS})) - -@${RM} ${RMFLAGS} $(addprefix ../Debug/, $(addsuffix .o, ${OBJS})) - -distclean: +# 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 -setup: +# Push parent directory onto the directory stack +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(DIR) -export: +# Sources +SRCS_$(d) := filter.c inputstream.c utf8_stream.c utf16_stream.c -test: +# Append to sources for component +SOURCES += $(addprefix $(d), $(SRCS_$(d))) -# Pattern rules -../Release/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $< +# Now include any children we may have +MAKE_INCLUDES := $(wildcard $(d)*/Makefile) +$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC)))) -../Debug/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c -g ${CFLAGS} -o $@ $< +# Finally, pop off the directory stack +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/src/tokeniser/Makefile b/src/tokeniser/Makefile index 539625f..be0699c 100644 --- a/src/tokeniser/Makefile +++ b/src/tokeniser/Makefile @@ -1,53 +1,46 @@ -# Makefile for libhubbub +# Child makefile fragment for libhubbub # -# Toolchain is exported by top-level makefile +# Toolchain is provided by top-level makefile # -# Top-level makefile also exports the following variables: +# Variables provided by top-level makefile # -# COMPONENT Name of component -# EXPORT Absolute path of export directory -# TOP Absolute path of source tree root +# 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 # -# The top-level makefile requires the following targets to exist: +# do_include Canned command sequence to include a child makefile # -# clean Clean source tree -# debug Create a debug binary -# distclean Fully clean source tree, back to pristine condition -# export Export distributable components to ${EXPORT} -# release Create a release binary -# setup Perform any setup required prior to compilation -# test Execute any test cases - -# Manipulate include paths -CFLAGS += -I$(CURDIR) - -# Objects -OBJS = entities tokeniser - -.PHONY: clean debug distclean export release setup test - -# Targets -release: $(addprefix ../Release/, $(addsuffix .o, $(OBJS))) - -debug: $(addprefix ../Debug/, $(addsuffix .o, $(OBJS))) - -clean: - -@${RM} ${RMFLAGS} $(addprefix ../Release/, $(addsuffix .o, ${OBJS})) - -@${RM} ${RMFLAGS} $(addprefix ../Debug/, $(addsuffix .o, ${OBJS})) - -distclean: +# 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 -setup: +# Push parent directory onto the directory stack +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(DIR) -export: +# Sources +SRCS_$(d) := entities.c tokeniser.c -test: +# Append to sources for component +SOURCES += $(addprefix $(d), $(SRCS_$(d))) -# Pattern rules -../Release/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $< +# Now include any children we may have +MAKE_INCLUDES := $(wildcard $(d)*/Makefile) +$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC)))) -../Debug/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c -g ${CFLAGS} -o $@ $< +# Finally, pop off the directory stack +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/src/utils/Makefile b/src/utils/Makefile index 53341cf..c9cd076 100644 --- a/src/utils/Makefile +++ b/src/utils/Makefile @@ -1,53 +1,46 @@ -# Makefile for libhubbub +# Child makefile fragment for libhubbub # -# Toolchain is exported by top-level makefile +# Toolchain is provided by top-level makefile # -# Top-level makefile also exports the following variables: +# Variables provided by top-level makefile # -# COMPONENT Name of component -# EXPORT Absolute path of export directory -# TOP Absolute path of source tree root +# 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 # -# The top-level makefile requires the following targets to exist: +# do_include Canned command sequence to include a child makefile # -# clean Clean source tree -# debug Create a debug binary -# distclean Fully clean source tree, back to pristine condition -# export Export distributable components to ${EXPORT} -# release Create a release binary -# setup Perform any setup required prior to compilation -# test Execute any test cases - -# Manipulate include paths -CFLAGS += -I$(CURDIR) - -# Objects -OBJS = dict errors utf8 utf16 - -.PHONY: clean debug distclean export release setup test - -# Targets -release: $(addprefix ../Release/, $(addsuffix .o, $(OBJS))) - -debug: $(addprefix ../Debug/, $(addsuffix .o, $(OBJS))) - -clean: - -@${RM} ${RMFLAGS} $(addprefix ../Release/, $(addsuffix .o, ${OBJS})) - -@${RM} ${RMFLAGS} $(addprefix ../Debug/, $(addsuffix .o, ${OBJS})) - -distclean: +# 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 -setup: +# Push parent directory onto the directory stack +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(DIR) -export: +# Sources +SRCS_$(d) := dict.c errors.c utf8.c utf16.c -test: +# Append to sources for component +SOURCES += $(addprefix $(d), $(SRCS_$(d))) -# Pattern rules -../Release/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $< +# Now include any children we may have +MAKE_INCLUDES := $(wildcard $(d)*/Makefile) +$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC)))) -../Debug/%.o: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c -g ${CFLAGS} -o $@ $< +# Finally, pop off the directory stack +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) -- cgit v1.2.3