From c57df190537a73d0cb784bfe149ff22aca884db0 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 27 Mar 2017 23:36:28 +0200 Subject: Add version information to the Makefile and to sqlitepp.h --- Makefile | 15 ++++++++++++--- config.mk | 4 ++++ include/sqlitepp/sqlitepp.h | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b3ad02f..a905f08 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ SOURCE_NAMES_LIB := sqlitepp.cpp SOURCE_NAMES_TEST := sqlitepp_test.cpp TARGET_NAME_LIB := sqlitepp -TARGET_LIB := $(LIBRARY_DIR)/lib$(TARGET_NAME_LIB).so +TARGET_LIB_BASE := $(LIBRARY_DIR)/lib$(TARGET_NAME_LIB).so +TARGET_LIB := $(TARGET_LIB_BASE).$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/$(source)) OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o) DEPENDS_LIB := $(OBJECTS_LIB:.o=.d) @@ -21,14 +22,18 @@ SOURCES_TEST := $(foreach source,$(SOURCE_NAMES_TEST),$(SOURCE_DIR)/$(source)) OBJECTS_TEST := $(SOURCES_TEST:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o) DEPENDS_TEST := $(OBJECTS_TEST:.o=.d) -TARGETS := $(TARGET_LIB) $(TARGET_TEST) +TARGETS := $(TARGET_LIB) $(TARGET_LIB_BASE) $(TARGET_TEST) INCLUDES := $(INCLUDE_DIR)/sqlitepp/sqlitepp.h OBJECTS := $(OBJECTS_LIB) $(OBJECTS_TEST) DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST) CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR) +CPPFLAGS += -DSQLITEPP_VERSION_MAJOR=$(VERSION_MAJOR) \ + -DSQLITEPP_VERSION_MINOR=$(VERSION_MINOR) \ + -DSQLITEPP_VERSION_PATCH=$(VERSION_PATCH) CXXFLAGS += -fPIC LDFLAGS += $(LDFLAGS_SQLITE3) +LDFLAGS_LIB += -Wl,-soname,lib$(TARGET_NAME_LIB).so.$(VERSION_MAJOR) LDFLAGS_TEST += -L$(LIBRARY_DIR) -l$(TARGET_NAME_LIB) $(LDFLAGS_GTEST) -Wl,-rpath,$(LIBRARY_DIR) ifdef VERBOSE @@ -60,12 +65,16 @@ memcheck: $(TARGET_TEST) test: $(TARGET_TEST) ./$(TARGET_TEST) +$(TARGET_LIB_BASE): $(TARGET_LIB) + $(info (LN) $@) + $(QUIET)ln -sr $^ $@ + $(TARGET_LIB): $(OBJECTS_LIB) $(info (CXX) $@) $(QUIET)mkdir -p $(LIBRARY_DIR) $(QUIET)$(CXX) -shared $(LDFLAGS) $(LDFLAGS_LIB) -o $@ $^ -$(TARGET_TEST): $(OBJECTS_TEST) $(TARGET_LIB) +$(TARGET_TEST): $(OBJECTS_TEST) $(TARGET_LIB) $(TARGET_LIB_BASE) $(info (CXX) $@) $(QUIET)mkdir -p $(BINARY_DIR) $(QUIET)$(CXX) $(LDFLAGS) $(LDFLAGS_TEST) $(OBJECTS_TEST) -o $@ diff --git a/config.mk b/config.mk index f7ef033..160bb74 100644 --- a/config.mk +++ b/config.mk @@ -1,3 +1,7 @@ +VERSION_MAJOR := 0 +VERSION_MINOR := 1 +VERSION_PATCH := 0 + LDFLAGS_SQLITE3 += -lsqlite3 LDFLAGS_GTEST += -lgtest -lgtest_main diff --git a/include/sqlitepp/sqlitepp.h b/include/sqlitepp/sqlitepp.h index ad09b6b..1e7f322 100644 --- a/include/sqlitepp/sqlitepp.h +++ b/include/sqlitepp/sqlitepp.h @@ -105,6 +105,24 @@ /// are destroyed. You can force them to free their resources using the /// `close` methods. +#ifndef SQLITEPP_VERSION_MAJOR +/// \brief The major version of sqlitepp (part x of version number x.y.z). +#define SQLITEPP_VERSION_MAJOR 0 +#endif + +#ifndef SQLITEPP_VERSION_MINOR +/// \brief The minor version of sqlitepp (part y of version number x.y.z). +#define SQLITEPP_VERSION_MINOR 0 +#endif + +#ifndef SQLITEPP_VERSION_PATCH +/// \brief The patch version of sqlitepp (part z of version number x.y.z). +#define SQLITEPP_VERSION_PATCH 0 +#endif + +/// \brief The sqlitepp version in the format MAJOR.MINOR.PATCH. +const std::string version = "0.1.0"; + /// \brief Contains all classes of the sqlitepp library. namespace sqlitepp { -- cgit v1.2.3