C++ binding for the SQLite library https://code.ireas.org/sqlitepp/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. include config.mk
  2. INCLUDE_DIR := include
  3. SOURCE_DIR := src
  4. OBJECT_DIR := obj
  5. LIBRARY_DIR := lib
  6. BINARY_DIR := bin
  7. DOCUMENTATION_DIR := doc
  8. SOURCE_NAMES_LIB := sqlitepp.cpp
  9. SOURCE_NAMES_TEST := sqlitepp_test.cpp
  10. TARGET_NAME_LIB := sqlitepp
  11. TARGET_LIB_BASE := $(LIBRARY_DIR)/lib$(TARGET_NAME_LIB).so
  12. TARGET_LIB := $(TARGET_LIB_BASE).$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
  13. SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/$(source))
  14. OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o)
  15. DEPENDS_LIB := $(OBJECTS_LIB:.o=.d)
  16. TARGET_TEST := $(BINARY_DIR)/sqlitepp_test
  17. SOURCES_TEST := $(foreach source,$(SOURCE_NAMES_TEST),$(SOURCE_DIR)/$(source))
  18. OBJECTS_TEST := $(SOURCES_TEST:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o)
  19. DEPENDS_TEST := $(OBJECTS_TEST:.o=.d)
  20. TARGETS := $(TARGET_LIB) $(TARGET_LIB_BASE) $(TARGET_TEST)
  21. INCLUDES := $(INCLUDE_DIR)/sqlitepp/sqlitepp.h
  22. OBJECTS := $(OBJECTS_LIB) $(OBJECTS_TEST)
  23. DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST)
  24. CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR)
  25. CPPFLAGS += -DSQLITEPP_VERSION_MAJOR=$(VERSION_MAJOR) \
  26. -DSQLITEPP_VERSION_MINOR=$(VERSION_MINOR) \
  27. -DSQLITEPP_VERSION_PATCH=$(VERSION_PATCH)
  28. CXXFLAGS += -fPIC
  29. LDFLAGS += $(LDFLAGS_SQLITE3)
  30. LDFLAGS_LIB += -Wl,-soname,lib$(TARGET_NAME_LIB).so.$(VERSION_MAJOR)
  31. LDFLAGS_TEST += -L$(LIBRARY_DIR) -l$(TARGET_NAME_LIB) $(LDFLAGS_GTEST) -Wl,-rpath,$(LIBRARY_DIR)
  32. ifdef VERBOSE
  33. QUIET :=
  34. else
  35. QUIET := @
  36. endif
  37. .PHONY = all clean doc memcheck test
  38. all: $(TARGETS)
  39. clean:
  40. $(info (RM) $(OBJECT_DIR))
  41. $(QUIET)$(RM) -r $(OBJECT_DIR)
  42. $(info (RM) $(LIBRARY_DIR))
  43. $(QUIET)$(RM) -r $(LIBRARY_DIR)
  44. $(info (RM) $(BINARY_DIR))
  45. $(QUIET)$(RM) -r $(BINARY_DIR)
  46. $(info (RM) $(DOCUMENTATION_DIR))
  47. $(QUIET)$(RM) -r $(DOCUMENTATION_DIR)
  48. doc: $(INCLUDES)
  49. doxygen
  50. memcheck: $(TARGET_TEST)
  51. valgrind --tool=memcheck ./$(TARGET_TEST)
  52. test: $(TARGET_TEST)
  53. ./$(TARGET_TEST)
  54. $(TARGET_LIB_BASE): $(TARGET_LIB)
  55. $(info (LN) $@)
  56. $(QUIET)ln -sr $^ $@
  57. $(TARGET_LIB): $(OBJECTS_LIB)
  58. $(info (CXX) $@)
  59. $(QUIET)mkdir -p $(LIBRARY_DIR)
  60. $(QUIET)$(CXX) -shared $(LDFLAGS) $(LDFLAGS_LIB) -o $@ $^
  61. $(TARGET_TEST): $(OBJECTS_TEST) $(TARGET_LIB) $(TARGET_LIB_BASE)
  62. $(info (CXX) $@)
  63. $(QUIET)mkdir -p $(BINARY_DIR)
  64. $(QUIET)$(CXX) $(LDFLAGS) $(LDFLAGS_TEST) $(OBJECTS_TEST) -o $@
  65. $(OBJECTS): $(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cpp
  66. $(info (CXX) $@)
  67. $(QUIET)mkdir -p $(OBJECT_DIR)
  68. $(QUIET)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
  69. -include $(DEPENDS)