summaryrefslogtreecommitdiff
path: root/build/Makefile.common
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-05-01 16:36:27 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-05-01 16:36:27 +0000
commit72c39e3522c5781d1e7dc8abad77d96141c5d49b (patch)
treee16497caaa0bf20771ef34787de02fc95e5993bf /build/Makefile.common
downloadlibcss-72c39e3522c5781d1e7dc8abad77d96141c5d49b.tar.gz
libcss-72c39e3522c5781d1e7dc8abad77d96141c5d49b.tar.bz2
Import beginnings of a CSS parsing library.
Currently comprises a lexer. svn path=/trunk/libcss/; revision=4112
Diffstat (limited to 'build/Makefile.common')
-rw-r--r--build/Makefile.common119
1 files changed, 119 insertions, 0 deletions
diff --git a/build/Makefile.common b/build/Makefile.common
new file mode 100644
index 0000000..2e320e6
--- /dev/null
+++ b/build/Makefile.common
@@ -0,0 +1,119 @@
+# 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 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/libcss
+ @$(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/libcss $(filter %.h, $(wildcard include/libcss/*))
+
+uninstall:
+ @$(RM) $(RMFLAGS) $(PREFIX)/lib/$(COMPONENT).a
+ @$(RM) $(RMFLAGS) $(PREFIX)/lib/pkgconfig/$(COMPONENT).pc
+ @$(RM) $(RMFLAGS) -r $(PREFIX)/include/libcss
+
+# 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)))))
+