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)