ソースを参照

Add version information to the Makefile and to sqlitepp.h

master
Robin Krahl 2年前
コミット
c57df19053
3個のファイルの変更34行の追加3行の削除
  1. 12
    3
      Makefile
  2. 4
    0
      config.mk
  3. 18
    0
      include/sqlitepp/sqlitepp.h

+ 12
- 3
Makefile ファイルの表示

@@ -11,7 +11,8 @@ SOURCE_NAMES_LIB := sqlitepp.cpp
11 11
 SOURCE_NAMES_TEST := sqlitepp_test.cpp
12 12
 
13 13
 TARGET_NAME_LIB := sqlitepp
14
-TARGET_LIB := $(LIBRARY_DIR)/lib$(TARGET_NAME_LIB).so
14
+TARGET_LIB_BASE := $(LIBRARY_DIR)/lib$(TARGET_NAME_LIB).so
15
+TARGET_LIB := $(TARGET_LIB_BASE).$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
15 16
 SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/$(source))
16 17
 OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o)
17 18
 DEPENDS_LIB := $(OBJECTS_LIB:.o=.d)
@@ -21,14 +22,18 @@ SOURCES_TEST := $(foreach source,$(SOURCE_NAMES_TEST),$(SOURCE_DIR)/$(source))
21 22
 OBJECTS_TEST := $(SOURCES_TEST:$(SOURCE_DIR)/%.cpp=$(OBJECT_DIR)/%.o)
22 23
 DEPENDS_TEST := $(OBJECTS_TEST:.o=.d)
23 24
 
24
-TARGETS := $(TARGET_LIB) $(TARGET_TEST)
25
+TARGETS := $(TARGET_LIB) $(TARGET_LIB_BASE) $(TARGET_TEST)
25 26
 INCLUDES := $(INCLUDE_DIR)/sqlitepp/sqlitepp.h
26 27
 OBJECTS := $(OBJECTS_LIB) $(OBJECTS_TEST)
27 28
 DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST)
28 29
 
29 30
 CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR)
31
+CPPFLAGS += -DSQLITEPP_VERSION_MAJOR=$(VERSION_MAJOR) \
32
+	    -DSQLITEPP_VERSION_MINOR=$(VERSION_MINOR) \
33
+	    -DSQLITEPP_VERSION_PATCH=$(VERSION_PATCH)
30 34
 CXXFLAGS += -fPIC
31 35
 LDFLAGS += $(LDFLAGS_SQLITE3)
36
+LDFLAGS_LIB += -Wl,-soname,lib$(TARGET_NAME_LIB).so.$(VERSION_MAJOR)
32 37
 LDFLAGS_TEST += -L$(LIBRARY_DIR) -l$(TARGET_NAME_LIB) $(LDFLAGS_GTEST) -Wl,-rpath,$(LIBRARY_DIR)
33 38
 
34 39
 ifdef VERBOSE
@@ -60,12 +65,16 @@ memcheck: $(TARGET_TEST)
60 65
 test: $(TARGET_TEST)
61 66
 	./$(TARGET_TEST)
62 67
 
68
+$(TARGET_LIB_BASE): $(TARGET_LIB)
69
+	$(info (LN)    $@)
70
+	$(QUIET)ln -sr $^ $@
71
+
63 72
 $(TARGET_LIB): $(OBJECTS_LIB)
64 73
 	$(info (CXX)   $@)
65 74
 	$(QUIET)mkdir -p $(LIBRARY_DIR)
66 75
 	$(QUIET)$(CXX) -shared $(LDFLAGS) $(LDFLAGS_LIB) -o $@ $^
67 76
 
68
-$(TARGET_TEST): $(OBJECTS_TEST) $(TARGET_LIB)
77
+$(TARGET_TEST): $(OBJECTS_TEST) $(TARGET_LIB) $(TARGET_LIB_BASE)
69 78
 	$(info (CXX)   $@)
70 79
 	$(QUIET)mkdir -p $(BINARY_DIR)
71 80
 	$(QUIET)$(CXX) $(LDFLAGS) $(LDFLAGS_TEST) $(OBJECTS_TEST) -o $@

+ 4
- 0
config.mk ファイルの表示

@@ -1,3 +1,7 @@
1
+VERSION_MAJOR := 0
2
+VERSION_MINOR := 1
3
+VERSION_PATCH := 0
4
+
1 5
 LDFLAGS_SQLITE3 += -lsqlite3
2 6
 LDFLAGS_GTEST += -lgtest -lgtest_main
3 7
 

+ 18
- 0
include/sqlitepp/sqlitepp.h ファイルの表示

@@ -105,6 +105,24 @@
105 105
 /// are destroyed. You can force them to free their resources using the
106 106
 /// `close` methods.
107 107
 
108
+#ifndef SQLITEPP_VERSION_MAJOR
109
+/// \brief The major version of sqlitepp (part x of version number x.y.z).
110
+#define SQLITEPP_VERSION_MAJOR 0
111
+#endif
112
+
113
+#ifndef SQLITEPP_VERSION_MINOR
114
+/// \brief The minor version of sqlitepp (part y of version number x.y.z).
115
+#define SQLITEPP_VERSION_MINOR 0
116
+#endif
117
+
118
+#ifndef SQLITEPP_VERSION_PATCH
119
+/// \brief The patch version of sqlitepp (part z of version number x.y.z).
120
+#define SQLITEPP_VERSION_PATCH 0
121
+#endif
122
+
123
+/// \brief The sqlitepp version in the format MAJOR.MINOR.PATCH.
124
+const std::string version = "0.1.0";
125
+
108 126
 /// \brief Contains all classes of the sqlitepp library.
109 127
 namespace sqlitepp {
110 128
 

読み込み中…
キャンセル
保存