Skip to content

Commit

Permalink
Added a static fpic target which will allow us to statically link thi…
Browse files Browse the repository at this point in the history
…s library into other shared libraries

For this exact reason we also got rid of -flto, which is pretty useless inside libraries anyway.
  • Loading branch information
Toon Schoenmakers committed Oct 30, 2015
1 parent fdb55d4 commit 4646e43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*.d

# Compiled Dynamic libraries
*.so
*.so*
*.dylib

# Compiled Static libraries
*.lai
*.la
*.a
*.a*
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ static:
shared:
$(MAKE) -C src shared

static_fpic:
$(MAKE) -C src static_fpic

clean:
$(MAKE) -C src clean

Expand All @@ -33,8 +36,9 @@ install:
cp -f include/net/*.h ${INCLUDE_DIR}/$(LIBRARY_NAME)/net
cp -f include/tcp/*.h ${INCLUDE_DIR}/$(LIBRARY_NAME)/tcp
cp -f include/watchers/*.h ${INCLUDE_DIR}/$(LIBRARY_NAME)/watchers
cp -f src/lib$(LIBRARY_NAME).so.$(VERSION) ${LIBRARY_DIR}
cp -f src/lib$(LIBRARY_NAME).a.$(VERSION) ${LIBRARY_DIR}
-cp -f src/lib$(LIBRARY_NAME).so.$(VERSION) ${LIBRARY_DIR}
-cp -f src/lib$(LIBRARY_NAME).a.$(VERSION) ${LIBRARY_DIR}
-cp -f src/lib$(LIBRARY_NAME)_fpic.a ${LIBRARY_DIR}
ln -s -f lib$(LIBRARY_NAME).so.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so.$(SONAME)
ln -s -f lib$(LIBRARY_NAME).so.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so
ln -s -f lib$(LIBRARY_NAME).a.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).a
22 changes: 14 additions & 8 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
CPP = g++
RM = rm -f
CPPFLAGS = -Wall -MMD -c -I. -flto -std=c++11
LD = g++
LD_FLAGS = -Wall -shared
SHARED_LIB = lib$(LIBRARY_NAME).so.$(VERSION)
STATIC_LIB = lib$(LIBRARY_NAME).a.$(VERSION)
SOURCES = $(wildcard *.cpp */*.cpp)
CPP = g++
RM = rm -f
CPPFLAGS = -Wall -MMD -c -I. -std=c++11
LD = g++
LD_FLAGS = -Wall -shared
SHARED_LIB = lib$(LIBRARY_NAME).so.$(VERSION)
STATIC_LIB = lib$(LIBRARY_NAME).a.$(VERSION)
STATIC_FPIC_LIB = lib$(LIBRARY_NAME)_fpic.a
SOURCES = $(wildcard *.cpp */*.cpp)
DEPENDENCIES = $(SOURCES:%.cpp=%.d)
SHARED_OBJECTS = $(SOURCES:%.cpp=%.o)
STATIC_OBJECTS = $(SOURCES:%.cpp=%.s.o)
Expand All @@ -22,6 +23,8 @@ release: shared static

shared: ${SHARED_OBJECTS} ${SHARED_LIB}

static_fpic: ${SHARED_OBJECTS} ${STATIC_FPIC_LIB}

static: ${STATIC_OBJECTS} ${STATIC_LIB}

${SHARED_LIB}: ${SHARED_OBJECTS}
Expand All @@ -30,6 +33,9 @@ ${SHARED_LIB}: ${SHARED_OBJECTS}
${STATIC_LIB}: ${STATIC_OBJECTS}
ar rcs ${STATIC_LIB} ${STATIC_OBJECTS}

${STATIC_FPIC_LIB}: ${SHARED_OBJECTS}
ar rcs ${STATIC_FPIC_LIB} ${SHARED_OBJECTS}

clean:
${RM} *.obj *~* ${SHARED_OBJECTS} ${STATIC_OBJECTS} ${SHARED_LIB} ${STATIC_LIB}

Expand Down

0 comments on commit 4646e43

Please sign in to comment.