Skip to content

Commit 4646e43

Browse files
author
Toon Schoenmakers
committed
Added a static fpic target which will allow us to statically link this library into other shared libraries
For this exact reason we also got rid of -flto, which is pretty useless inside libraries anyway.
1 parent fdb55d4 commit 4646e43

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*.d
88

99
# Compiled Dynamic libraries
10-
*.so
10+
*.so*
1111
*.dylib
1212

1313
# Compiled Static libraries
1414
*.lai
1515
*.la
16-
*.a
16+
*.a*

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ static:
1717
shared:
1818
$(MAKE) -C src shared
1919

20+
static_fpic:
21+
$(MAKE) -C src static_fpic
22+
2023
clean:
2124
$(MAKE) -C src clean
2225

@@ -33,8 +36,9 @@ install:
3336
cp -f include/net/*.h ${INCLUDE_DIR}/$(LIBRARY_NAME)/net
3437
cp -f include/tcp/*.h ${INCLUDE_DIR}/$(LIBRARY_NAME)/tcp
3538
cp -f include/watchers/*.h ${INCLUDE_DIR}/$(LIBRARY_NAME)/watchers
36-
cp -f src/lib$(LIBRARY_NAME).so.$(VERSION) ${LIBRARY_DIR}
37-
cp -f src/lib$(LIBRARY_NAME).a.$(VERSION) ${LIBRARY_DIR}
39+
-cp -f src/lib$(LIBRARY_NAME).so.$(VERSION) ${LIBRARY_DIR}
40+
-cp -f src/lib$(LIBRARY_NAME).a.$(VERSION) ${LIBRARY_DIR}
41+
-cp -f src/lib$(LIBRARY_NAME)_fpic.a ${LIBRARY_DIR}
3842
ln -s -f lib$(LIBRARY_NAME).so.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so.$(SONAME)
3943
ln -s -f lib$(LIBRARY_NAME).so.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so
4044
ln -s -f lib$(LIBRARY_NAME).a.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).a

src/Makefile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
CPP = g++
2-
RM = rm -f
3-
CPPFLAGS = -Wall -MMD -c -I. -flto -std=c++11
4-
LD = g++
5-
LD_FLAGS = -Wall -shared
6-
SHARED_LIB = lib$(LIBRARY_NAME).so.$(VERSION)
7-
STATIC_LIB = lib$(LIBRARY_NAME).a.$(VERSION)
8-
SOURCES = $(wildcard *.cpp */*.cpp)
1+
CPP = g++
2+
RM = rm -f
3+
CPPFLAGS = -Wall -MMD -c -I. -std=c++11
4+
LD = g++
5+
LD_FLAGS = -Wall -shared
6+
SHARED_LIB = lib$(LIBRARY_NAME).so.$(VERSION)
7+
STATIC_LIB = lib$(LIBRARY_NAME).a.$(VERSION)
8+
STATIC_FPIC_LIB = lib$(LIBRARY_NAME)_fpic.a
9+
SOURCES = $(wildcard *.cpp */*.cpp)
910
DEPENDENCIES = $(SOURCES:%.cpp=%.d)
1011
SHARED_OBJECTS = $(SOURCES:%.cpp=%.o)
1112
STATIC_OBJECTS = $(SOURCES:%.cpp=%.s.o)
@@ -22,6 +23,8 @@ release: shared static
2223

2324
shared: ${SHARED_OBJECTS} ${SHARED_LIB}
2425

26+
static_fpic: ${SHARED_OBJECTS} ${STATIC_FPIC_LIB}
27+
2528
static: ${STATIC_OBJECTS} ${STATIC_LIB}
2629

2730
${SHARED_LIB}: ${SHARED_OBJECTS}
@@ -30,6 +33,9 @@ ${SHARED_LIB}: ${SHARED_OBJECTS}
3033
${STATIC_LIB}: ${STATIC_OBJECTS}
3134
ar rcs ${STATIC_LIB} ${STATIC_OBJECTS}
3235

36+
${STATIC_FPIC_LIB}: ${SHARED_OBJECTS}
37+
ar rcs ${STATIC_FPIC_LIB} ${SHARED_OBJECTS}
38+
3339
clean:
3440
${RM} *.obj *~* ${SHARED_OBJECTS} ${STATIC_OBJECTS} ${SHARED_LIB} ${STATIC_LIB}
3541

0 commit comments

Comments
 (0)