aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2017-03-23 23:39:50 +0100
committerRobin Krahl <me@robin-krahl.de>2017-03-23 23:39:50 +0100
commitcbe3dc9f40aaab8a2ff641ce824766b41d1d407c (patch)
treeeb17bcf5f21f82ea3493c3d9ca2f1041eda2eac2 /Makefile
parent400bdee335656eb873d6cd60f9cbc1be76a2810a (diff)
downloadsqlitepp-cbe3dc9f40aaab8a2ff641ce824766b41d1d407c.tar.gz
sqlitepp-cbe3dc9f40aaab8a2ff641ce824766b41d1d407c.tar.bz2
Move from CMake to a plain Makefile
The Makefile contains the rules to build both the library and the test binary, and to create the HTML and LaTeX documentation. Settings like library paths and compiler options are set in config.mk.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile70
1 files changed, 70 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3882de1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,70 @@
+include config.mk
+
+INCLUDE_DIR := include
+SOURCE_DIR := src
+OBJECT_DIR := obj
+LIBRARY_DIR := lib
+BINARY_DIR := bin
+DOCUMENTATION_DIR := doc
+
+SOURCE_NAMES_LIB := sqlitepp.cc
+SOURCE_NAMES_TEST := sqlitepp_test.cc
+TARGETS := $(LIBRARY_DIR)/libsqlitepp.so $(BINARY_DIR)/sqlitepp_test
+
+SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/sqlitepp/$(source))
+OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cc=$(OBJECT_DIR)/%.o)
+DEPENDS_LIB := $(OBJECTS_LIB:.o=.d)
+
+SOURCES_TEST := $(foreach source,$(SOURCE_NAMES_TEST),$(SOURCE_DIR)/sqlitepp/$(source))
+OBJECTS_TEST := $(SOURCES_TEST:$(SOURCE_DIR)/%.cc=$(OBJECT_DIR)/%.o)
+DEPENDS_TEST := $(OBJECTS_TEST:.o=.d)
+
+INCLUDES := $(INCLUDE_DIR)/sqlitepp/sqlitepp.h
+OBJECTS := $(OBJECTS_LIB) $(OBJECTS_TEST)
+DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST)
+
+CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR)
+CXXFLAGS += -fPIC
+LDFLAGS += $(LDFLAGS_SQLITE3)
+LDFLAGS_TEST += -L$(LIBRARY_DIR) -lsqlitepp $(LDFLAGS_GTEST)
+
+ifdef VERBOSE
+ QUIET :=
+else
+ QUIET := @
+endif
+
+.PHONY = all clean doc
+
+all: $(TARGETS)
+
+clean:
+ $(info (RM) $(OBJECT_DIR))
+ $(QUIET)$(RM) -r $(OBJECT_DIR)
+ $(info (RM) $(LIBRARY_DIR))
+ $(QUIET)$(RM) -r $(LIBRARY_DIR)
+ $(info (RM) $(BINARY_DIR))
+ $(QUIET)$(RM) -r $(BINARY_DIR)
+ $(info (RM) $(DOCUMENTATION_DIR))
+ $(QUIET)$(RM) -r $(DOCUMENTATION_DIR)
+
+doc: $(INCLUDES)
+ doxygen
+
+$(LIBRARY_DIR)/libsqlitepp.so: $(OBJECTS_LIB)
+ $(info (CXX) $@)
+ $(QUIET)mkdir -p $(LIBRARY_DIR)
+ $(QUIET)$(CXX) -shared $(LDFLAGS) $(LDFLAGS_LIB) -o $@ $^
+
+$(BINARY_DIR)/sqlitepp_test: $(OBJECTS_TEST)
+ $(info (CXX) $@)
+ $(QUIET)mkdir -p $(BINARY_DIR)
+ $(QUIET)$(CXX) $(LDFLAGS) $(LDFLAGS_TEST) $< -o $@
+
+$(OBJECTS): $(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cc
+ $(info (CXX) $@)
+ $(QUIET)mkdir -p $(OBJECT_DIR)
+ $(QUIET)mkdir -p $(OBJECT_DIR)/sqlitepp
+ $(QUIET)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+
+-include $(DEPENDS)