summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-05-01 16:34:46 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-05-01 16:34:46 +0000
commit2777a04ed2ba4fd36138b991d66a32a283361f7e (patch)
treeb0c3730533c36ca41402b6d0c5b98413f0a57bee /build
downloadlibparserutils-2777a04ed2ba4fd36138b991d66a32a283361f7e.tar.gz
libparserutils-2777a04ed2ba4fd36138b991d66a32a283361f7e.tar.bz2
Import parser construction utility library
svn path=/trunk/libparserutils/; revision=4111
Diffstat (limited to 'build')
-rw-r--r--build/Makefile.common129
-rw-r--r--build/Makefile.config8
2 files changed, 137 insertions, 0 deletions
diff --git a/build/Makefile.common b/build/Makefile.common
new file mode 100644
index 0000000..418a5a8
--- /dev/null
+++ b/build/Makefile.common
@@ -0,0 +1,129 @@
+# Top-level Makefile fragment
+
+# Default target
+all: release
+
+# Name of component
+COMPONENT := libparserutils
+
+# 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 $(RELEASEDIR)/*
+
+debug: setup $(addprefix $(DEBUGDIR)/,$(OBJECTS))
+ @$(AR) $(ARFLAGS) $(COMPONENT)-debug.a $(DEBUGDIR)/*
+
+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)
+ @$(MKDIR) $(MKDIRFLAGS) $(DEBUGDIR)
+ @$(MKDIR) $(MKDIRFLAGS) $(COVERAGEDIR)
+
+export: release
+ @$(MKDIR) $(MKDIRFLAGS) $(TOP)/dist/lib
+ @$(CP) $(CPFLAGS) -r include $(EXPORT)/
+ @${CP} ${CPFLAGS} $(COMPONENT).a ${EXPORT}/lib/
+
+install: release
+ @$(MKDIR) $(MKDIRFLAGS) -p $(PREFIX)/lib/pkgconfig
+ @$(MKDIR) $(MKDIRFLAGS) -p $(PREFIX)/include/parserutils
+ @$(MKDIR) $(MKDIRFLAGS) -p $(PREFIX)/include/parserutils/charset
+ @$(MKDIR) $(MKDIRFLAGS) -p $(PREFIX)/include/parserutils/input
+ @$(MKDIR) $(MKDIRFLAGS) -p $(PREFIX)/include/parserutils/utils
+ @$(SED) -e 's#PREFIX#$(PREFIX)#' $(COMPONENT).pc.in >$(COMPONENT).pc
+ @$(INSTALL) --mode=644 -t $(PREFIX)/lib $(COMPONENT).a
+ @$(INSTALL) --mode=644 -t $(PREFIX)/lib/pkgconfig $(COMPONENT).pc
+ @$(INSTALL) --mode=644 -t $(PREFIX)/include/parserutils $(filter %.h, $(wildcard include/parserutils/*))
+ @$(INSTALL) --mode=644 -t $(PREFIX)/include/parserutils/charset $(filter %.h, $(wildcard include/parserutils/charset/*))
+ @$(INSTALL) --mode=644 -t $(PREFIX)/include/parserutils/input $(filter %.h, $(wildcard include/parserutils/input/*))
+ @$(INSTALL) --mode=644 -t $(PREFIX)/include/parserutils/utils $(filter %.h, $(wildcard include/parserutils/utils/*))
+
+
+uninstall:
+ @$(RM) $(RMFLAGS) $(PREFIX)/lib/$(COMPONENT).a
+ @$(RM) $(RMFLAGS) $(PREFIX)/lib/pkgconfig/$(COMPONENT).pc
+ @$(RM) $(RMFLAGS) -r $(PREFIX)/include/parserutils
+
+# 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_compile,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)))))
+
diff --git a/build/Makefile.config b/build/Makefile.config
new file mode 100644
index 0000000..b6560c1
--- /dev/null
+++ b/build/Makefile.config
@@ -0,0 +1,8 @@
+# Configuration Makefile fragment
+
+# Build the iconv codec
+# override CFLAGS += -DWITH_ICONV_CODEC
+
+# Use iconv directly in the input filter
+# override CFLAGS += -DWITH_ICONV_FILTER
+