From cbe3dc9f40aaab8a2ff641ce824766b41d1d407c Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 23 Mar 2017 23:39:50 +0100 Subject: 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. --- Makefile | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Makefile (limited to 'Makefile') 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) -- cgit v1.2.3