summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2013-02-12 14:00:13 -0600
committerJason Parker <jparker@digium.com>2013-03-11 15:24:21 -0500
commit9e5b6c43b13a561b09908d2a57edb6c96e4fedaf (patch)
tree9a63bb6b422698f6cbf4a8bde776c7e457afb892 /pjlib
parent74ce69c77a8ed993870e6cc22582a1dea8e918e6 (diff)
Add support for building and using shared libraries.
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/build/Makefile53
-rw-r--r--pjlib/build/os-auto.mak.in5
-rw-r--r--pjlib/build/os-darwinos.mak2
-rw-r--r--pjlib/build/os-linux-kernel.mak2
-rw-r--r--pjlib/build/os-linux.mak2
-rw-r--r--pjlib/build/os-rtems.mak2
-rw-r--r--pjlib/build/os-sunos.mak2
-rw-r--r--pjlib/build/os-win32.mak2
8 files changed, 44 insertions, 26 deletions
diff --git a/pjlib/build/Makefile b/pjlib/build/Makefile
index 272206d..926fea2 100644
--- a/pjlib/build/Makefile
+++ b/pjlib/build/Makefile
@@ -2,10 +2,20 @@ include ../../build.mak
include ../../version.mak
include $(PJDIR)/build/common.mak
+export LIBDIR := ../lib
+export BINDIR := ../bin
+
RULES_MAK := $(PJDIR)/build/rules.mak
+export PJLIB_LIB := libpj-$(TARGET_NAME)$(LIBEXT)
-export PJLIB_LIB := ../lib/libpj-$(TARGET_NAME)$(LIBEXT)
+ifeq ($(PJ_SHARED_LIBRARIES),)
+PJLIB_LDLIB := -lpj-$(TARGET_NAME)
+else
+PJLIB_LDLIB := -lpj
+export PJLIB_SONAME := libpj.$(SHLIB_SUFFIX)
+export PJLIB_SHLIB := $(PJLIB_SONAME).$(PJ_VERSION_MAJOR)
+endif
###############################################################################
# Gather all flags.
@@ -14,9 +24,9 @@ export _CFLAGS := $(CC_CFLAGS) $(OS_CFLAGS) $(HOST_CFLAGS) $(M_CFLAGS) \
$(CFLAGS) $(CC_INC)../include
export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
$(HOST_CXXFLAGS) $(CXXFLAGS)
-export _LDFLAGS := $(subst /,$(HOST_PSEP),$(PJLIB_LIB)) \
- $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
- $(LDFLAGS)
+export _LDFLAGS := $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
+ $(APP_LDFLAGS) $(LDFLAGS)
+
###############################################################################
# Defines for building PJLIB library
@@ -44,10 +54,10 @@ export TEST_OBJS += activesock.o atomic.o echo_clt.o errno.o exception.o \
udp_echo_srv_sync.o udp_echo_srv_ioqueue.o \
util.o
export TEST_CFLAGS += $(_CFLAGS)
-export TEST_LDFLAGS += $(_LDFLAGS)
-export TEST_EXE := ../bin/pjlib-test-$(TARGET_NAME)$(HOST_EXE)
+export TEST_LDFLAGS += $(PJLIB_LDLIB) $(_LDFLAGS)
+export TEST_EXE := pjlib-test-$(TARGET_NAME)$(HOST_EXE)
+
-
export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
###############################################################################
# Main entry
@@ -74,34 +84,39 @@ print:
depend: ../include/pj/config_site.h
$(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib depend
$(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test depend
- echo '$(TEST_EXE): $(PJLIB_LIB)' >> .pjlib-test-$(TARGET_NAME).depend
+ echo '$(BINDIR)/$(TEST_EXE): $(LIBDIR)/$(PJLIB_LIB)' >> .pjlib-test-$(TARGET_NAME).depend
-.PHONY: dep depend clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
.PHONY: $(TARGETS)
-.PHONY: $(PJLIB_LIB) $(TEST_EXE)
+.PHONY: $(PJLIB_LIB) $(PJLIB_SHLIB) $(PJLIB_SONAME)
+.PHONY: $(TEST_EXE)
dep: depend
pjlib: $(PJLIB_LIB)
$(PJLIB_LIB): ../include/pj/config_site.h
- $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $(PJLIB_LIB)
+
+$(PJLIB_SHLIB): $(PJLIB_SONAME)
+$(PJLIB_SONAME): $(PJLIB_LIB)
+$(PJLIB_LIB) $(PJLIB_SHLIB) $(PJLIB_SONAME):
+ $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
../include/pj/config_site.h:
touch ../include/pj/config_site.h
pjlib-test: $(TEST_EXE)
-$(TEST_EXE): $(PJLIB_LIB)
- $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test $(TEST_EXE)
+$(TEST_EXE): $(PJLIB_LIB) $(PJLIB_SONAME)
+ $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
-.PHONY: ../lib/pjlib.ko
-../lib/pjlib.ko:
+.PHONY: pjlib.ko
+pjlib.ko:
echo Making $@
- $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $@
+ $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
-.PHONY: ../lib/pjlib-test.ko
-../lib/pjlib-test.ko:
- $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test $@
+.PHONY: pjlib-test.ko
+pjlib-test.ko:
+ $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
clean:
$(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib clean
diff --git a/pjlib/build/os-auto.mak.in b/pjlib/build/os-auto.mak.in
index a4a2b8a..8640255 100644
--- a/pjlib/build/os-auto.mak.in
+++ b/pjlib/build/os-auto.mak.in
@@ -29,7 +29,10 @@ export TEST_LDFLAGS += @LDFLAGS@ @LIBS@
# TARGETS are make targets in the Makefile, to be executed for this given
# operating system.
#
-export TARGETS = pjlib pjlib-test
+export TARGETS = $(PJLIB_LIB) $(TEST_EXE)
+ifneq ($(PJ_SHARED_LIBRARIES),)
+export TARGETS += $(PJLIB_SONAME)
+endif
diff --git a/pjlib/build/os-darwinos.mak b/pjlib/build/os-darwinos.mak
index ee83dec..a0d99e7 100644
--- a/pjlib/build/os-darwinos.mak
+++ b/pjlib/build/os-darwinos.mak
@@ -33,5 +33,5 @@ export TEST_LDFLAGS += -lm
# TARGETS are make targets in the Makefile, to be executed for this given
# operating system.
#
-export TARGETS = pjlib pjlib-test
+export TARGETS = $(PJLIB_LIB) $(PJLIB_SONAME) $(TEST_EXE)
diff --git a/pjlib/build/os-linux-kernel.mak b/pjlib/build/os-linux-kernel.mak
index 934c889..28cfbc7 100644
--- a/pjlib/build/os-linux-kernel.mak
+++ b/pjlib/build/os-linux-kernel.mak
@@ -42,6 +42,6 @@ export TEST_LDFLAGS += -lgcc
# TARGETS are make targets in the Makefile, to be executed for this given
# operating system.
#
-export TARGETS := ../lib/pjlib.ko ../lib/pjlib-test.ko
+export TARGETS := pjlib.ko pjlib-test.ko
diff --git a/pjlib/build/os-linux.mak b/pjlib/build/os-linux.mak
index 11c6fa7..78123ef 100644
--- a/pjlib/build/os-linux.mak
+++ b/pjlib/build/os-linux.mak
@@ -35,5 +35,5 @@ export TEST_LDFLAGS += -lm
# TARGETS are make targets in the Makefile, to be executed for this given
# operating system.
#
-export TARGETS = pjlib pjlib-test
+export TARGETS = $(PJLIB_LIB) $(PJLIB_SONAME) $(TEST_EXE)
diff --git a/pjlib/build/os-rtems.mak b/pjlib/build/os-rtems.mak
index 1501dd9..30a81f9 100644
--- a/pjlib/build/os-rtems.mak
+++ b/pjlib/build/os-rtems.mak
@@ -40,7 +40,7 @@ export TEST_LDFLAGS +=
# TARGETS are make targets in the Makefile, to be executed for this given
# operating system.
#
-export TARGETS = pjlib pjlib-test
+export TARGETS = $(PJLIB_LIB) $(TEST_EXE)
diff --git a/pjlib/build/os-sunos.mak b/pjlib/build/os-sunos.mak
index f0043ad..7aa658d 100644
--- a/pjlib/build/os-sunos.mak
+++ b/pjlib/build/os-sunos.mak
@@ -32,5 +32,5 @@ export TEST_LDFLAGS += -lm
# TARGETS are make targets in the Makefile, to be executed for this given
# operating system.
#
-export TARGETS = pjlib pjlib-test
+export TARGETS = $(PJLIB_LIB) $(PJLIB_SONAME) $(TEST_EXE)
diff --git a/pjlib/build/os-win32.mak b/pjlib/build/os-win32.mak
index 0290fea..5be3c8e 100644
--- a/pjlib/build/os-win32.mak
+++ b/pjlib/build/os-win32.mak
@@ -29,5 +29,5 @@ export TEST_OBJS += main.o
# TARGETS are make targets in the Makefile, to be executed for this given
# operating system.
#
-export TARGETS = pjlib pjlib-test
+export TARGETS = $(PJLIB_LIB) $(TEST_EXE)