Skip to content

Commit

Permalink
Add soname and release build traget, default make target is debug
Browse files Browse the repository at this point in the history
  • Loading branch information
RafalGoslawski committed May 19, 2015
1 parent 74fd52a commit bbce65b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
PREFIX = /usr
INCLUDE_DIR = ${PREFIX}/include/reactcpp
LIBRARY_DIR = ${PREFIX}/lib
export LIBRARY_NAME = reactcpp-curl
export SONAME = 1.0
export VERSION = 1.0.0

all:
$(MAKE) -C src all

release:
$(MAKE) -C src release

static:
$(MAKE) -C src static

Expand All @@ -19,5 +25,8 @@ install:
mkdir -p ${LIBRARY_DIR}
cp -f curl.h ${INCLUDE_DIR}
cp -fr include/* ${INCLUDE_DIR}/curl
cp -f src/libreactcpp-curl.so ${LIBRARY_DIR}
cp -f src/libreactcpp-curl.a ${LIBRARY_DIR}
cp -f src/lib$(LIBRARY_NAME).so.$(VERSION) ${LIBRARY_DIR}
cp -f src/lib$(LIBRARY_NAME).a.$(VERSION) ${LIBRARY_DIR}
ln -s -f $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so.$(SONAME)
ln -s -f $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).so
ln -s -f $(LIBRARY_DIR)/lib$(LIBRARY_NAME).a.$(VERSION) $(LIBRARY_DIR)/lib$(LIBRARY_NAME).a
25 changes: 16 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
CPP = g++
RM = rm -f
CPPFLAGS = -Wall -c -I. -O2 -flto -std=c++11 -g
LD = g++
LD_FLAGS = -Wall -shared -O2
SHARED_LIB = libreactcpp-curl.so
STATIC_LIB = $(SHARED_LIB:%.so=%.a)
SOURCES = $(wildcard *.cpp */*.cpp)
CPP = g++
RM = rm -f
CPPFLAGS = -Wall -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)
SHARED_OBJECTS = $(SOURCES:%.cpp=%.o)
STATIC_OBJECTS = $(SOURCES:%.cpp=%.s.o)


all: CPPFLAGS += -g
all: LD_FLAGS += -g
all: shared static

release: CPPFLAGS += -O2
release: LD_FLAGS += -O2
release: shared static

shared: ${SHARED_OBJECTS} ${SHARED_LIB}

static: ${STATIC_OBJECTS} ${STATIC_LIB}

${SHARED_LIB}: ${SHARED_OBJECTS}
${LD} ${LD_FLAGS} -o $@ ${SHARED_OBJECTS} -lcurl
${LD} ${LD_FLAGS} -Wl,-soname,lib$(LIBRARY_NAME).so.$(SONAME) -o $@ ${SHARED_OBJECTS} -lcurl

${STATIC_LIB}: ${STATIC_OBJECTS}
ar rcs ${STATIC_LIB} ${STATIC_OBJECTS}
Expand Down

0 comments on commit bbce65b

Please sign in to comment.