summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-03-25 14:25:19 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2009-03-25 14:25:19 (GMT)
commit5f1057c8cdc74263f109d05fb674367d70062210 (patch)
treeaa2614dd601bfaa496902a0162ad12570e9c8f70
parent751e77d0b31ff335d1575217388ffe8469dc862d (diff)
downloadlibwapcaplet-5f1057c8cdc74263f109d05fb674367d70062210.tar.gz
libwapcaplet-5f1057c8cdc74263f109d05fb674367d70062210.tar.bz2
First cut at a port to core buildsystem.
svn path=/trunk/libwapcaplet/; revision=6873
-rw-r--r--Makefile128
-rw-r--r--src/Makefile3
-rw-r--r--test/Makefile3
3 files changed, 30 insertions, 104 deletions
diff --git a/Makefile b/Makefile
index 949eff2..3793751 100644
--- a/Makefile
+++ b/Makefile
@@ -1,104 +1,24 @@
-# Simple Makefile for libwapcaplet
-
-LIB := libwapcaplet.a
-
-SRCS := libwapcaplet.c
-HDRS := libwapcaplet/libwapcaplet.h
-
-PREFIX ?= /usr/local
-
-TESTSRCS := testmain.c basictests.c memorytests.c
-
-TARGET ?= debug
-
-BUILDDIR := build-$(TARGET)
-
-MKDIR ?= mkdir -p
-SED ?= sed
-INSTALL ?= install
-
-all: $(BUILDDIR)/$(LIB)
-
-test: $(BUILDDIR)/testrunner
- $(BUILDDIR)/testrunner
-
-install: all
- $(MKDIR) $(PREFIX)/lib/pkgconfig $(PREFIX)/include/libwapcaplet
- $(SED) -e 's#PREFIX#$(PREFIX)#' libwapcaplet.pc.in >libwapcaplet.pc
- $(INSTALL) -m 644 libwapcaplet.pc $(PREFIX)/lib/pkgconfig
- $(INSTALL) -m 644 $(BUILDDIR)/$(LIB) $(PREFIX)/lib/$(LIB)
- for F in $(HDRS); do \
- $(INSTALL) -m 644 include/$$F $(PREFIX)/include/libwapcaplet; \
- done
-
-CFLAGS := -Iinclude -Wall -Werror
-
-ifeq ($(TARGET),debug)
-CFLAGS += -O0 -g
-else
-CFLAGS += -O2 -DNDEBUG
-endif
-
-
-clean:
- rm -fr build-*
-
-$(BUILDDIR)/stamp:
- mkdir -p $(BUILDDIR)
- touch $(BUILDDIR)/stamp
-
-define srcfile
-src/$1
-endef
-
-define objfile
-$(BUILDDIR)/$(1:.c=.o)
-endef
-
-define depfile
-$(BUILDDIR)/$(1:.c=.d)
-endef
-
-DEPS :=
-OBJS :=
-
-define _depandbuild
-
-$2: $1 $(BUILDDIR)/stamp
- $(CC) -MMD -MP $($5) -o $2 -c $1
-
-$4 += $2
-DEPS += $3
-
-endef
-
-define depandbuild
-$(call _depandbuild,$(call srcfile,$1),$(call objfile,$1),$(call depfile,$1),OBJS,CFLAGS)
-endef
-
-$(eval $(foreach SOURCE,$(SRCS),$(call depandbuild,$(SOURCE))))
-
-ifneq ($(MAKECMDGOALS),clean)
--include $(DEPS)
-endif
-
-$(BUILDDIR)/$(LIB): $(BUILDDIR)/stamp $(OBJS)
- $(AR) cru $@ $^
-
-define testsrc
-test/$1
-endef
-
-define depandbuildtest
-$(call _depandbuild,$(call testsrc,$1),$(call objfile,test-$1),$(call depfile,test-$1),TOBJS,TESTCFLAGS)
-endef
-
-TOBJS :=
-
-TESTCFLAGS := $(CFLAGS) $(shell pkg-config --cflags check)
-TESTLDFLAGS := $(LDFLAGS) $(shell pkg-config --libs check)
-
-$(eval $(foreach TESTSRC,$(TESTSRCS),$(call depandbuildtest,$(TESTSRC))))
-
-$(BUILDDIR)/testrunner: $(BUILDDIR)/stamp $(TOBJS) $(BUILDDIR)/$(LIB)
- $(CC) -o $@ $(TOBJS) $(BUILDDIR)/$(LIB) $(TESTLDFLAGS)
+# Component settings
+COMPONENT := wapcaplet
+# Default to a static library
+COMPONENT_TYPE ?= lib-static
+
+# Setup the tooling
+include build/makefiles/Makefile.tools
+
+# Reevaluate when used, as BUILDDIR won't be defined yet
+TESTRUNNER = $(BUILDDIR)/test_testrunner$(EXEEXT)
+
+# Toolchain flags
+WARNFLAGS := -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
+ -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
+ -Wmissing-declarations -Wnested-externs -Werror -pedantic
+CFLAGS := $(CFLAGS) -std=c99 -D_BSD_SOURCE -I$(CURDIR)/include/ \
+ -I$(CURDIR)/src $(WARNFLAGS)
+
+include build/makefiles/Makefile.top
+
+# Extra installation rules
+INSTALL_ITEMS := $(INSTALL_ITEMS) /include/libwapcaplet:include/libwapcaplet/libwapcaplet.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /lib/pkgconfig:lib$(COMPONENT).pc.in
+INSTALL_ITEMS := $(INSTALL_ITEMS) /lib:$(BUILDDIR)/lib$(COMPONENT)$(LIBEXT)
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..e0251a3
--- a/dev/null
+++ b/src/Makefile
@@ -0,0 +1,3 @@
+DIR_SOURCES := libwapcaplet.c
+
+include build/makefiles/Makefile.subdir
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..9ce2c1c
--- a/dev/null
+++ b/test/Makefile
@@ -0,0 +1,3 @@
+DIR_TEST_ITEMS := testrunner:testmain.c;basictests.c;memorytests.c
+
+include build/makefiles/Makefile.subdir