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.8KB

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