1 From 4c83dd96d1f92627ecdb6b6ed80b8c278aea82f7 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
3 Date: Fri, 20 Nov 2015 19:51:50 +0100
4 Subject: [PATCH] Allow building shared or static library only
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
11 Makefile | 19 ++++++++++++++++---
12 1 file changed, 16 insertions(+), 3 deletions(-)
14 diff --git a/Makefile b/Makefile
15 index 7d63077..90c7059 100644
18 @@ -57,6 +57,9 @@ LIBRARY_ARCHIVE = lib$(LIBRARY_NAME).a
19 CLIENT_TARGET = $(LIBRARY_NAME)
20 TESTS_TARGET = $(LIBRARY_NAME)-tests
26 ifeq ($(CONFIG),debug)
27 CONFIG_FLAGS = -g -fno-inline -ftemplate-depth-1000
28 @@ -71,7 +74,7 @@ ifneq (,$(findstring $(CONFIG),release loadtest))
29 CONFIG_FLAGS = -O3 -funroll-loops -ffast-math -finline-functions -fomit-frame-pointer -DNO_DEBUG_LOG -DNO_TRACE_LOG -DNDEBUG
32 -COMMON_FLAGS = -MMD -std=c++0x -pipe -Wall -fPIC \
33 +COMMON_FLAGS = -MMD -std=c++0x -pipe -Wall \
34 -DBUILD_ENV=$(CONFIG) \
35 -DBUILD_VERSION='"$(APP_VERSION)"' \
36 -DBUILD_VERSION_MAJOR=$(VERSION_MAJOR) \
37 @@ -82,6 +85,15 @@ COMMON_FLAGS = -MMD -std=c++0x -pipe -Wall -fPIC \
38 -DBUILD_CLIENT_NAME='"$(CLIENT_TARGET)"' \
41 +ifeq ($(BUILD_SHARED),yes)
42 +COMMON_FLAGS += -fPIC
43 +LIBRARY_TARGETS += $(LIBRARY_SHARED)
46 +ifeq ($(BUILD_STATIC),yes)
47 +LIBRARY_TARGETS += $(LIBRARY_ARCHIVE)
53 @@ -125,9 +137,11 @@ check: $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE) test
56 install -m 644 $(ALL_LIBRARY_INCLUDES) $(INCLUDEDIR)/$(LIBRARY_DIR)
57 +ifeq ($(BUILD_SHARED),yes)
58 install -m 755 $(BUILD_PATH)/$(LIBRARY_SHARED).$(VERSION_MAJOR) $(LIBDIR)/$(LIBRARY_SHARED).$(APP_VERSION)
59 ln -sf $(LIBRARY_SHARED).$(APP_VERSION) $(LIBDIR)/$(LIBRARY_SHARED).$(VERSION_MAJOR)
60 ln -sf $(LIBRARY_SHARED).$(APP_VERSION) $(LIBDIR)/$(LIBRARY_SHARED)
62 if [ -f $(BUILD_PATH)/$(CLIENT_TARGET) ]; then install -m 755 $(BUILD_PATH)/$(CLIENT_TARGET) $(BINDIR); fi
64 @echo "use make installcheck to test the install"
65 @@ -148,7 +162,7 @@ clean:
67 client: $(CLIENT_TARGET)
69 -library: $(LIBRARY_SHARED) $(LIBRARY_ARCHIVE)
70 +library: $(LIBRARY_TARGETS)
74 @@ -187,4 +201,3 @@ test: $(TESTS_TARGET)
75 $(OBJECT_PATH)/%.o: $(SRC_PATH)/%.cpp
77 $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COMMON_FLAGS) $(CONFIG_FLAGS) -c -o $@ $<