Index: pjproject/trunk/pjsip/build/Makefile
===================================================================
--- pjproject/trunk/pjsip/build/Makefile	(revision 4637)
+++ pjproject/trunk/pjsip/build/Makefile	(revision 4656)
@@ -8,16 +8,30 @@
 include $(PJDIR)/build/common.mak
 
+export LIBDIR := ../lib
+export BINDIR := ../bin
+
 RULES_MAK := $(PJDIR)/build/rules.mak
 
 PJLIB_LIB:=../../pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
 PJLIB_UTIL_LIB:=../../pjlib-util/lib/libpjlib-util-$(TARGET_NAME)$(LIBEXT)
+PJNATH_LIB:=../../pjnath/lib/libpjnath-$(TARGET_NAME)$(LIBEXT)
 PJMEDIA_LIB:=../../pjmedia/lib/libpjmedia-$(TARGET_NAME)$(LIBEXT)
-PJMEDIA_CODEC_LIB:=../../pjmedia/lib/libpjmedia-codec-$(TARGET_NAME)$(LIBEXT)
-
-export PJSIP_LIB:=../lib/libpjsip-$(TARGET_NAME)$(LIBEXT)
-export PJSIP_UA_LIB:=../lib/libpjsip-ua-$(TARGET_NAME)$(LIBEXT)
-export PJSIP_SIMPLE_LIB:=../lib/libpjsip-simple-$(TARGET_NAME)$(LIBEXT)
-export PJSUA_LIB_LIB=../lib/libpjsua-$(TARGET_NAME)$(LIBEXT)
-
+
+export PJSIP_LIB:=libpjsip-$(TARGET_NAME)$(LIBEXT)
+export PJSIP_UA_LIB:=libpjsip-ua-$(TARGET_NAME)$(LIBEXT)
+export PJSIP_SIMPLE_LIB:=libpjsip-simple-$(TARGET_NAME)$(LIBEXT)
+export PJSUA_LIB_LIB:=libpjsua-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export PJSIP_SONAME := libpjsip.$(SHLIB_SUFFIX)
+export PJSIP_SHLIB := $(PJSIP_SONAME).$(PJ_VERSION_MAJOR)
+export PJSIP_UA_SONAME := libpjsip-ua.$(SHLIB_SUFFIX)
+export PJSIP_UA_SHLIB := $(PJSIP_UA_SONAME).$(PJ_VERSION_MAJOR)
+export PJSIP_SIMPLE_SONAME := libpjsip-simple.$(SHLIB_SUFFIX)
+export PJSIP_SIMPLE_SHLIB := $(PJSIP_SIMPLE_SONAME).$(PJ_VERSION_MAJOR)
+export PJSUA_LIB_SONAME := libpjsua.$(SHLIB_SUFFIX)
+export PJSUA_LIB_SHLIB := $(PJSUA_LIB_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -32,4 +46,8 @@
 export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
 		   $(HOST_CXXFLAGS) $(CXXFLAGS)
+export _LDFLAGS := $(APP_THIRD_PARTY_LIBS) \
+		   $(APP_THIRD_PARTY_EXT) \
+		   $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
+		   $(APP_LDFLAGS) $(LDFLAGS) 
 
 ###############################################################################
@@ -50,4 +68,7 @@
 export PJSIP_CFLAGS += $(_CFLAGS)
 export PJSIP_CXXFLAGS += $(_CXXFLAGS)
+export PJSIP_LDFLAGS += $(PJLIB_UTIL_LDLIB) \
+			$(PJLIB_LDLIB) \
+			$(_LDFLAGS)
 
 ###############################################################################
@@ -60,4 +81,10 @@
 export PJSIP_UA_CFLAGS += $(_CFLAGS)
 export PJSIP_UA_CXXFLAGS += $(_CXXFLAGS)
+export PJSIP_UA_LDFLAGS += $(PJSIP_SIMPLE_LDLIB) \
+			   $(PJSIP_LDLIB) \
+			   $(PJMEDIA_LDLIB) \
+			   $(PJLIB_UTIL_LDLIB) \
+			   $(PJLIB_LDLIB) \
+			   $(_LDFLAGS)
 
 
@@ -72,4 +99,8 @@
 export PJSIP_SIMPLE_CFLAGS += $(_CFLAGS)
 export PJSIP_SIMPLE_CXXFLAGS += $(_CXXFLAGS)
+export PJSIP_SIMPLE_LDFLAGS += $(PJSIP_LDLIB) \
+			       $(PJLIB_UTIL_LDLIB) \
+			       $(PJLIB_LDLIB) \
+			       $(_LDFLAGS)
 
 
@@ -84,4 +115,15 @@
 export PJSUA_LIB_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS)
 export PJSUA_LIB_CXXFLAGS += $(_CXXFLAGS) $(PJ_VIDEO_CFLAGS)
+export PJSUA_LIB_LDFLAGS += $(PJSIP_UA_LDLIB) \
+			    $(PJSIP_SIMPLE_LDLIB) \
+			    $(PJSIP_LDLIB) \
+			    $(PJMEDIA_AUDIODEV_LDLIB) \
+			    $(PJMEDIA_VIDEODEV_LDLIB) \
+			    $(PJMEDIA_CODEC_LDLIB) \
+			    $(PJMEDIA_LDLIB) \
+			    $(PJNATH_LDLIB) \
+			    $(PJLIB_UTIL_LDLIB) \
+			    $(PJLIB_LDLIB) \
+			    $(_LDFLAGS)
 
 
@@ -101,6 +143,17 @@
 export TEST_CFLAGS += $(_CFLAGS)
 export TEST_CXXFLAGS += $(_CXXFLAGS)
-export TEST_LDFLAGS += $(PJ_LDFLAGS) $(PJ_LDLIBS) $(LDFLAGS)
-export TEST_EXE := ../bin/pjsip-test-$(TARGET_NAME)$(HOST_EXE)
+export TEST_LDFLAGS += $(PJSIP_LDLIB) \
+		       $(PJSIP_UA_LDLIB) \
+		       $(PJSIP_SIMPLE_LDLIB) \
+		       $(PJSUA_LDLIB) \
+		       $(PJMEDIA_CODEC_LDLIB) \
+		       $(PJMEDIA_VIDEODEV_LDLIB) \
+		       $(PJMEDIA_LDLIB) \
+		       $(PJMEDIA_AUDIODEV_LDLIB) \
+		       $(PJLIB_LDLIB) \
+		       $(PJLIB_UTIL_LDLIB) \
+		       $(PJNATH_LDLIB) \
+		       $(_LDFLAGS)
+export TEST_EXE := pjsip-test-$(TARGET_NAME)$(HOST_EXE)
 
 	
@@ -110,5 +163,9 @@
 #
 #
-TARGETS := pjsip pjsip-ua pjsip-simple pjsua-lib pjsip-test
+TARGETS := $(PJSIP_LIB) $(PJSIP_SONAME) \
+	   $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME) \
+	   $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME) \
+	   $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME) \
+	   $(TEST_EXE)
 
 all: $(TARGETS)
@@ -128,47 +185,59 @@
 distclean: realclean
 
-.PHONY: dep depend clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
 .PHONY: $(TARGETS)
-.PHONY: $(PJSIP_LIB) $(PJSIP_UA_LIB) $(PJSIP_SIMPLE_LIB) $(PJSUA_LIB_LIB) $(TEST_EXE)
+.PHONY: $(PJSIP_LIB) $(PJSIP_SONAME)
+.PHONY: $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
+.PHONY: $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME)
+.PHONY: $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME)
+.PHONY: $(TEST_EXE)
 
 pjsip: $(PJSIP_LIB)
-$(PJSIP_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJSIP app=pjsip $(PJSIP_LIB)
+$(PJSIP_SONAME): $(PJSIP_LIB)
+$(PJSIP_LIB) $(PJSIP_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=PJSIP app=pjsip $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjsip-ua: $(PJSIP_UA_LIB)
-$(PJSIP_UA_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJSIP_UA app=pjsip-ua $(PJSIP_UA_LIB)
+$(PJSIP_UA_SONAME): $(PJSIP_UA_LIB)
+$(PJSIP_UA_LIB) $(PJSIP_UA_SONAME): $(PJSIP_LIB) $(PJSIP_SONAME) $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJSIP_UA app=pjsip-ua $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjsip-simple: $(PJSIP_SIMPLE_LIB)
-$(PJSIP_SIMPLE_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJSIP_SIMPLE app=pjsip-simple $(PJSIP_SIMPLE_LIB)
+$(PJSIP_SIMPLE_SONAME): $(PJSIP_SIMPLE_LIB)
+$(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME): $(PJSIP_LIB) $(PJSIP_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJSIP_SIMPLE app=pjsip-simple $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjsua-lib: $(PJSUA_LIB_LIB)
-$(PJSUA_LIB_LIB): 
-	$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $(PJSUA_LIB_LIB)
+$(PJSUA_LIB_SONAME): $(PJSUA_LIB_LIB)
+$(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME): $(PJSIP_LIB) $(PJSIP_SONAME) $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME) $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjsip-test: $(TEST_EXE)
-$(TEST_EXE): $(PJSUA_LIB_LIB) $(PJSIP_SIMPLE_LIB) $(PJSIP_UA_LIB) $(PJSIP_LIB)
-	$(MAKE) -f $(RULES_MAK) APP=TEST app=pjsip-test $(TEST_EXE)
-
-.PHONY: ../lib/pjsip.ko
-../lib/pjsip.ko:
-	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJSIP app=pjsip $@
-
-.PHONY: ../lib/pjsip-ua.ko
-../lib/pjsip-ua.ko:
-	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJSIP_UA app=pjsip-ua $@
-
-.PHONY: ../lib/pjsip-simple.ko
-../lib/pjsip-simple.ko:
-	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJSIP_SIMPLE app=pjsip-simple $@
-
-.PHONY: ../lib/pjsua-lib.ko
-../lib/pjsua-lib.ko:
-	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $@
+$(TEST_EXE): $(PJSIP_LIB) $(PJSIP_SONAME)
+$(TEST_EXE): $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
+$(TEST_EXE): $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME)
+$(TEST_EXE): $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME)
+$(TEST_EXE):
+	$(MAKE) -f $(RULES_MAK) APP=TEST app=pjsip-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
+
+.PHONY: pjsip.ko
+pjsip.ko:
+	echo Making $@
+	$(MAKE) -f $(RULES_MAK) APP=PJSIP app=pjsip $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
+
+.PHONY: pjsip-ua.ko
+pjsip-ua.ko:
+	echo Making $@
+	$(MAKE) -f $(RULES_MAK) APP=PJSIP_UA app=pjsip-ua $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
+
+.PHONY: pjsip-simple.ko
+pjsip-simple.ko:
+	echo Making $@
+	$(MAKE) -f $(RULES_MAK) APP=PJSIP_SIMPLE app=pjsip-simple $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
+
+.PHONY: pjsua-lib.ko
+pjsua-lib.ko:
+	echo Making $@
+	$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean:
@@ -185,5 +254,5 @@
 	$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $@
 	$(MAKE) -f $(RULES_MAK) APP=TEST app=pjsip-test $@
-	echo '$(TEST_EXE): $(PJMEDIA_LIB) $(PJSUA_LIB_LIB) $(PJSIP_SIMPLE_LIB) $(PJSIP_UA_LIB) $(PJSIP_LIB) $(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjsip-test-$(TARGET_NAME).depend
+	echo '$(BINDIR)/$(TEST_EXE): $(PJMEDIA_LIB) $(LIBDIR)/$(PJSUA_LIB_LIB) $(LIBDIR)/$(PJSIP_SIMPLE_LIB) $(LIBDIR)/$(PJSIP_UA_LIB) $(LIBDIR)/$(PJSIP_LIB) $(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjsip-test-$(TARGET_NAME).depend
 
 realclean:
