Index: pjproject/trunk/Makefile
===================================================================
--- pjproject/trunk/Makefile	(revision 4653)
+++ pjproject/trunk/Makefile	(revision 4656)
@@ -106,18 +106,18 @@
 	cd tests/pjsua && python runall.py
 
-prefix = $(ac_prefix)
-
 install:
-	mkdir -p $(DESTDIR)$(prefix)/lib
-	cp -f $(APP_LIB_FILES) $(DESTDIR)$(prefix)/lib/
-	mkdir -p $(DESTDIR)$(prefix)/include
+	mkdir -p $(DESTDIR)$(libdir)/
+	cp -af $(APP_LIB_FILES) $(DESTDIR)$(libdir)/
+	mkdir -p $(DESTDIR)$(includedir)/
 	for d in pjlib pjlib-util pjnath pjmedia pjsip; do \
-		cp -RLf $$d/include/* $(DESTDIR)$(prefix)/include/; \
+		cp -RLf $$d/include/* $(DESTDIR)$(includedir)/; \
 	done
-	mkdir -p $(DESTDIR)$(prefix)/lib/pkgconfig
-	sed -e "s!@PREFIX@!$(DESTDIR)$(prefix)!" libpjproject.pc.in | \
+	mkdir -p $(DESTDIR)$(libdir)/pkgconfig
+	sed -e "s!@PREFIX@!$(prefix)!" libpjproject.pc.in | \
+		sed -e "s!@INCLUDEDIR@!$(includedir)!" | \
+		sed -e "s!@LIBDIR@!$(libdir)!" | \
 		sed -e "s/@PJ_VERSION@/$(PJ_VERSION)/" | \
 		sed -e "s!@PJ_LDLIBS@!$(PJ_LDLIBS)!" | \
-		sed -e "s!@PJ_INSTALL_CFLAGS@!$(PJ_INSTALL_CFLAGS)!" > $(DESTDIR)/$(prefix)/lib/pkgconfig/libpjproject.pc
+		sed -e "s!@PJ_INSTALL_CFLAGS@!$(PJ_INSTALL_CFLAGS)!" > $(DESTDIR)/$(libdir)/pkgconfig/libpjproject.pc
 
 uninstall:
Index: pjproject/trunk/aconfigure
===================================================================
--- pjproject/trunk/aconfigure	(revision 4653)
+++ pjproject/trunk/aconfigure	(revision 4656)
@@ -1,8 +1,10 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for pjproject 2.x.
+# Generated by GNU Autoconf 2.68 for pjproject 2.x.
 #
 #
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+# Foundation, Inc.
 #
 #
@@ -133,29 +135,4 @@
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
-# Use a proper internal environment variable to ensure we don't fall
-  # into an infinite loop, continuously re-executing ourselves.
-  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
-    _as_can_reexec=no; export _as_can_reexec;
-    # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
-  fi
-  # We don't want this to propagate to other subprocesses.
-          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
@@ -191,6 +168,5 @@
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1
-test -x / || exit 1"
+test x\$exitcode = x0 || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
@@ -237,23 +213,19 @@
 
       if test "x$CONFIG_SHELL" != x; then :
-  export CONFIG_SHELL
-             # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-exit 255
+  # We cannot yet assume a decent shell, so we have to provide a
+	# neutralization value for shells without unset; and this also
+	# works around shells that cannot unset nonexistent variables.
+	# Preserve -v and -x to the replacement shell.
+	BASH_ENV=/dev/null
+	ENV=/dev/null
+	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+	export CONFIG_SHELL
+	case $- in # ((((
+	  *v*x* | *x*v* ) as_opts=-vx ;;
+	  *v* ) as_opts=-v ;;
+	  *x* ) as_opts=-x ;;
+	  * ) as_opts= ;;
+	esac
+	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
 fi
 
@@ -357,12 +329,4 @@
 
 } # as_fn_mkdir_p
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
@@ -486,8 +450,4 @@
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
-  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
-  # already done that, so ensure we don't try to do so again and fall
-  # in an infinite loop.  This has already happened in practice.
-  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
@@ -524,14 +484,14 @@
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
@@ -545,6 +505,26 @@
 fi
 
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
 
 # Sed expression to map a string onto a valid CPP name.
@@ -673,4 +653,5 @@
 ac_external_gsm
 ac_external_speex
+ac_shared_libraries
 ac_os_objs
 EGREP
@@ -759,4 +740,5 @@
 enable_floating_point
 enable_epoll
+enable_shared
 with_external_speex
 with_external_gsm
@@ -1263,4 +1245,6 @@
   if test "x$build_alias" = x; then
     cross_compiling=maybe
+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
@@ -1425,4 +1409,5 @@
                           Disable floating point where possible
   --enable-epoll          Use /dev/epoll ioqueue on Linux (experimental)
+  --enable-shared         Build shared libraries
   --disable-sound         Exclude sound (i.e. use null sound)
   --disable-oss           Disable OSS audio (default: not disabled)
@@ -1570,7 +1555,7 @@
   cat <<\_ACEOF
 pjproject configure 2.x
-generated by GNU Autoconf 2.69
-
-Copyright (C) 2012 Free Software Foundation, Inc.
+generated by GNU Autoconf 2.68
+
+Copyright (C) 2010 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
@@ -1686,5 +1671,5 @@
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
+	 $as_test_x conftest$ac_exeext
        }; then :
   ac_retval=0
@@ -1973,5 +1958,5 @@
 
 It was created by pjproject $as_me 2.x, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2498,5 +2483,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -2538,5 +2523,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -2591,5 +2576,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -2632,5 +2617,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
@@ -2690,5 +2675,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -2734,5 +2719,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -3180,5 +3165,6 @@
 #include <stdarg.h>
 #include <stdio.h>
-struct stat;
+#include <sys/types.h>
+#include <sys/stat.h>
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
@@ -3293,5 +3279,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -3337,5 +3323,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CXX="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -3546,5 +3532,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -3586,5 +3572,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -3640,5 +3626,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -3684,5 +3670,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -4455,5 +4441,5 @@
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
@@ -4521,5 +4507,5 @@
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
@@ -5642,4 +5628,20 @@
 	        { $as_echo "$as_me:${as_lineno-$LINENO}: result: select()" >&5
 $as_echo "select()" >&6; }
+
+fi
+
+
+
+# Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; if test "$enable_shared" = "yes"; then
+		ac_shared_libraries=1
+		CFLAGS="$CFLAGS -fPIC"
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Building shared libraries... yes" >&5
+$as_echo "Building shared libraries... yes" >&6; }
+	       fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: Building shared libraries... no" >&5
+$as_echo "Building shared libraries... no" >&6; }
 
 fi
@@ -6325,5 +6327,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -6371,5 +6373,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -6476,5 +6478,5 @@
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_PKG_CONFIG="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
@@ -8158,14 +8160,14 @@
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
@@ -8227,14 +8229,26 @@
 fi
 
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
 
 # Sed expression to map a string onto a valid CPP name.
@@ -8258,5 +8272,5 @@
 ac_log="
 This file was extended by pjproject $as_me 2.x, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -8320,8 +8334,8 @@
 ac_cs_version="\\
 pjproject config.status 2.x
-configured by $0, generated by GNU Autoconf 2.69,
+configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
@@ -8411,5 +8425,5 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
Index: pjproject/trunk/aconfigure.ac
===================================================================
--- pjproject/trunk/aconfigure.ac	(revision 4653)
+++ pjproject/trunk/aconfigure.ac	(revision 4656)
@@ -424,4 +424,16 @@
 	      ])
 
+AC_SUBST(ac_shared_libraries)
+AC_ARG_ENABLE(shared,
+	      AC_HELP_STRING([--enable-shared],
+			     [Build shared libraries]),
+	      [if test "$enable_shared" = "yes"; then
+		[ac_shared_libraries=1]
+		CFLAGS="$CFLAGS -fPIC"
+		AC_MSG_RESULT([Building shared libraries... yes])
+	       fi],
+	      AC_MSG_RESULT([Building shared libraries... no])
+	      )
+
 
 dnl ######################
@@ -825,5 +837,4 @@
 	     )
 
-dnl # Include libsamplerate
 AC_SUBST(ac_resample_dll)
 AC_ARG_ENABLE(resample_dll,
Index: pjproject/trunk/build.mak.in
===================================================================
--- pjproject/trunk/build.mak.in	(revision 4653)
+++ pjproject/trunk/build.mak.in	(revision 4656)
@@ -13,20 +13,39 @@
 export SHLIB_SUFFIX := @ac_shlib_suffix@
 
-export ac_prefix := @prefix@
+export prefix := @prefix@
+export exec_prefix := @exec_prefix@
+export includedir := @includedir@
+export libdir := @libdir@
 
 LIB_SUFFIX = $(TARGET_NAME).a
 
+ifeq (@ac_shared_libraries@,1)
+export PJ_SHARED_LIBRARIES := 1
+endif
+
 # Determine which party libraries to use
-export APP_THIRD_PARTY_LIBS := -lmilenage-$(TARGET_NAME) -lsrtp-$(TARGET_NAME)
 export APP_THIRD_PARTY_EXT :=
+export APP_THIRD_PARTY_LIBS :=
 export APP_THIRD_PARTY_LIB_FILES := $(PJ_DIR)/third_party/lib/libmilenage-$(LIB_SUFFIX) $(PJ_DIR)/third_party/lib/libsrtp-$(LIB_SUFFIX)
-
+ifeq ($(PJ_SHARED_LIBRARIES),)
+APP_THIRD_PARTY_LIBS += -lmilenage-$(TARGET_NAME) -lsrtp-$(TARGET_NAME)
+else
+APP_THIRD_PARTY_LIBS += -lmilenage -lsrtp
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libmilenage.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libmilenage.$(SHLIB_SUFFIX) \
+			     $(PJ_DIR)/third_party/lib/libsrtp.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libsrtp.$(SHLIB_SUFFIX)
+endif
+
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample-$(LIB_SUFFIX)
+ifeq ($(PJ_SHARED_LIBRARIES),)
 ifeq (@ac_resample_dll@,1)
 export PJ_RESAMPLE_DLL := 1
-export APP_THIRD_PARTY_LIBS := -lresample $(APP_THIRD_PARTY_LIBS)
-export APP_THIRD_PARTY_LIB_FILES := $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX) $(APP_THIRD_PARTY_LIB_FILES)
-else
-export APP_THIRD_PARTY_LIBS := -lresample-$(TARGET_NAME) $(APP_THIRD_PARTY_LIBS)
-export APP_THIRD_PARTY_LIB_FILES := $(PJ_DIR)/third_party/lib/libresample-$(LIB_SUFFIX) $(APP_THIRD_PARTY_LIB_FILES)
+APP_THIRD_PARTY_LIBS += -lresample
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX)
+else
+APP_THIRD_PARTY_LIBS += -lresample-$(TARGET_NAME)
+endif
+else
+APP_THIRD_PARTY_LIBS += -lresample
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFIX)
 endif
 
@@ -36,6 +55,11 @@
 APP_THIRD_PARTY_EXT += -lgsm
 else
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libgsmcodec-$(LIB_SUFFIX)
+ifeq ($(PJ_SHARED_LIBRARIES),)
 APP_THIRD_PARTY_LIBS += -lgsmcodec-$(TARGET_NAME)
-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libgsmcodec-$(LIB_SUFFIX)
+else
+APP_THIRD_PARTY_LIBS += -lgsmcodec
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libgsmcodec.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libgsmcodec.$(SHLIB_SUFFIX)
+endif
 endif
 endif
@@ -45,17 +69,32 @@
 APP_THIRD_PARTY_EXT += -lspeex -lspeexdsp
 else
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libspeex-$(LIB_SUFFIX)
+ifeq ($(PJ_SHARED_LIBRARIES),)
 APP_THIRD_PARTY_LIBS += -lspeex-$(TARGET_NAME)
-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libspeex-$(LIB_SUFFIX)
+else
+APP_THIRD_PARTY_LIBS += -lspeex
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libspeex.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libspeex.$(SHLIB_SUFFIX)
+endif
 endif
 endif
 
 ifneq (@ac_no_ilbc_codec@,1)
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libilbccodec-$(LIB_SUFFIX)
+ifeq ($(PJ_SHARED_LIBRARIES),)
 APP_THIRD_PARTY_LIBS += -lilbccodec-$(TARGET_NAME)
-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libilbccodec-$(LIB_SUFFIX)
+else
+APP_THIRD_PARTY_LIBS += -lilbccodec
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libilbccodec.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libilbccodec.$(SHLIB_SUFFIX)
+endif
 endif
 
 ifneq (@ac_no_g7221_codec@,1)
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libg7221codec-$(LIB_SUFFIX)
+ifeq ($(PJ_SHARED_LIBRARIES),)
 APP_THIRD_PARTY_LIBS += -lg7221codec-$(TARGET_NAME)
-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libg7221codec-$(LIB_SUFFIX)
+else
+APP_THIRD_PARTY_LIBS += -lg7221codec
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libg7221codec.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libg7221codec.$(SHLIB_SUFFIX)
+endif
 endif
 
@@ -65,6 +104,11 @@
 APP_THIRD_PARTY_EXT += -lportaudio
 else
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libportaudio-$(LIB_SUFFIX)
+ifeq ($(PJ_SHARED_LIBRARIES),)
 APP_THIRD_PARTY_LIBS += -lportaudio-$(TARGET_NAME)
-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libportaudio-$(LIB_SUFFIX)
+else
+APP_THIRD_PARTY_LIBS += -lportaudio
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libportaudio.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libportaudio.$(SHLIB_SUFFIX)
+endif
 endif
 endif
@@ -123,19 +167,4 @@
 	$(PJ_VIDEO_LDFLAGS) \
 	@LDFLAGS@
-export APP_LDLIBS := -lpjsua-$(TARGET_NAME)\
-	-lpjsip-ua-$(TARGET_NAME)\
-	-lpjsip-simple-$(TARGET_NAME)\
-	-lpjsip-$(TARGET_NAME)\
-	-lpjmedia-codec-$(TARGET_NAME)\
-	-lpjmedia-videodev-$(TARGET_NAME)\
-	-lpjmedia-$(TARGET_NAME)\
-	-lpjmedia-audiodev-$(TARGET_NAME)\
-	-lpjmedia-$(TARGET_NAME)\
-	-lpjnath-$(TARGET_NAME)\
-	-lpjlib-util-$(TARGET_NAME)\
-	$(APP_THIRD_PARTY_LIBS)\
-	$(APP_THIRD_PARTY_EXT)\
-	-lpj-$(TARGET_NAME)\
-	@LIBS@
 export APP_LIB_FILES = $(PJ_DIR)/pjsip/lib/libpjsua-$(LIB_SUFFIX) \
 	$(PJ_DIR)/pjsip/lib/libpjsip-ua-$(LIB_SUFFIX) \
@@ -151,4 +180,57 @@
 	$(PJ_DIR)/pjlib/lib/libpj-$(LIB_SUFFIX)
 
+ifeq ($(PJ_SHARED_LIBRARIES),)
+export PJLIB_LDLIB := -lpj-$(TARGET_NAME)
+export PJLIB_UTIL_LDLIB := -lpjlib-util-$(TARGET_NAME)
+export PJNATH_LDLIB := -lpjnath-$(TARGET_NAME)
+export PJMEDIA_AUDIODEV_LDLIB := -lpjmedia-audiodev-$(TARGET_NAME)
+export PJMEDIA_VIDEODEV_LDLIB := -lpjmedia-videodev-$(TARGET_NAME)
+export PJMEDIA_LDLIB := -lpjmedia-$(TARGET_NAME)
+export PJMEDIA_CODEC_LDLIB := -lpjmedia-codec-$(TARGET_NAME)
+export PJSIP_LDLIB := -lpjsip-$(TARGET_NAME)
+export PJSIP_SIMPLE_LDLIB := -lpjsip-simple-$(TARGET_NAME)
+export PJSIP_UA_LDLIB := -lpjsip-ua-$(TARGET_NAME)
+export PJSUA_LIB_LDLIB := -lpjsua-$(TARGET_NAME)
+else
+export PJLIB_LDLIB := -lpj
+export PJLIB_UTIL_LDLIB := -lpjlib-util
+export PJNATH_LDLIB := -lpjnath
+export PJMEDIA_AUDIODEV_LDLIB := -lpjmedia-audiodev
+export PJMEDIA_VIDEODEV_LDLIB := -lpjmedia-videodev
+export PJMEDIA_LDLIB := -lpjmedia
+export PJMEDIA_CODEC_LDLIB := -lpjmedia-codec
+export PJSIP_LDLIB := -lpjsip
+export PJSIP_SIMPLE_LDLIB := -lpjsip-simple
+export PJSIP_UA_LDLIB := -lpjsip-ua
+export PJSUA_LIB_LDLIB := -lpjsua
+
+APP_LIB_FILES += $(PJ_DIR)/pjsip/lib/libpjsua.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjsip/lib/libpjsua.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjsip/lib/libpjsip-ua.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjsip/lib/libpjsip-ua.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjsip/lib/libpjsip-simple.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjsip/lib/libpjsip-simple.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjsip/lib/libpjsip.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjsip/lib/libpjsip.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjmedia/lib/libpjmedia-codec.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjmedia/lib/libpjmedia-codec.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjmedia/lib/libpjmedia-videodev.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjmedia/lib/libpjmedia-videodev.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjmedia/lib/libpjmedia.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjmedia/lib/libpjmedia.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjmedia/lib/libpjmedia-audiodev.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjmedia/lib/libpjmedia-audiodev.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjnath/lib/libpjnath.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjnath/lib/libpjnath.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjlib-util/lib/libpjlib-util.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjlib-util/lib/libpjlib-util.$(SHLIB_SUFFIX) \
+	$(PJ_DIR)/pjlib/lib/libpj.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/pjlib/lib/libpj.$(SHLIB_SUFFIX)
+endif
+
+export APP_LDLIBS := $(PJSUA_LIB_LDLIB) \
+	$(PJSIP_UA_LDLIB) \
+	$(PJSIP_SIMPLE_LDLIB) \
+	$(PJSIP_LDLIB) \
+	$(PJMEDIA_CODEC_LDLIB) \
+	$(PJMEDIA_LDLIB) \
+	$(PJMEDIA_VIDEODEV_LDLIB) \
+	$(PJMEDIA_AUDIODEV_LDLIB) \
+	$(PJNATH_LDLIB) \
+	$(PJLIB_UTIL_LDLIB) \
+	$(APP_THIRD_PARTY_LIBS)\
+	$(APP_THIRD_PARTY_EXT)\
+	$(PJLIB_LDLIB) \
+	@LIBS@
+
 # Here are the variabels to use if application is using the library
 # from within the source distribution
@@ -164,6 +246,6 @@
 # library from the install location (i.e. --prefix)
 export PJ_INSTALL_DIR := @prefix@
-export PJ_INSTALL_INC_DIR := $(PJ_INSTALL_DIR)/include
-export PJ_INSTALL_LIB_DIR := $(PJ_INSTALL_DIR)/lib
+export PJ_INSTALL_INC_DIR := @includedir@
+export PJ_INSTALL_LIB_DIR := @libdir@
 export PJ_INSTALL_CFLAGS := -I$(PJ_INSTALL_INC_DIR) -DPJ_AUTOCONF=1	@CFLAGS@
 export PJ_INSTALL_CXXFLAGS := $(PJ_INSTALL_CFLAGS)
Index: pjproject/trunk/build/rules.mak
===================================================================
--- pjproject/trunk/build/rules.mak	(revision 4653)
+++ pjproject/trunk/build/rules.mak	(revision 4656)
@@ -7,15 +7,20 @@
 
 #
-# The full path of output lib file (e.g. ../lib/libapp.a).
-#
-LIB = $($(APP)_LIB)
-
-#
-# The full path of output lib file (e.g. ../lib/libapp.a).
-#
+# The name(s) of output lib file(s) (e.g. libapp.a).
+#
+LIB := $($(APP)_LIB)
 SHLIB = $($(APP)_SHLIB)
-
-#
-# The full path of output executable file (e.g. ../bin/app.exe).
+SONAME = $($(APP)_SONAME)
+
+ifeq ($(SHLIB_SUFFIX),so)
+SHLIB_OPT := -shared -Wl,-soname,$(SHLIB)
+else ifeq ($(SHLIB_SUFFIX),dylib)
+SHLIB_OPT := -dynamiclib -undefined dynamic_lookup -flat_namespace
+else
+SHLIB_OPT := 
+endif
+
+#
+# The name of output executable file (e.g. app.exe).
 #
 EXE = $($(APP)_EXE)
@@ -77,25 +82,44 @@
 
 print_bin: print_common
-	@echo EXE=$(EXE)
+	@echo EXE=$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE))
 	@echo BINDIR=$(BINDIR)
-
+ 
 print_lib: print_common
-	@echo LIB=$(LIB)
+ifneq ($(LIB),)
+	@echo LIB=$(subst /,$(HOST_PSEP),$(LIBDIR)/$(LIB))
+endif
+ifneq ($(SHLIB),)
+	@echo SHLIB=$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB))
+endif
+ifneq ($(SONAME),)
+	@echo SONAME=$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SONAME))
+endif
 	@echo LIBDIR=$(LIBDIR)
 
-$(LIB): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
+ifneq ($(LIB),)
+$(subst /,$(HOST_PSEP),$(LIBDIR)/$(LIB)): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
 	if test ! -d $(LIBDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR)); fi
-	$(AR) $(AR_FLAGS) $(LIB) $(OBJS)
-	$(RANLIB) $(LIB)
-
-$(SHLIB): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
+	$(AR) $(AR_FLAGS) $@ $(OBJS)
+	$(RANLIB) $@
+endif
+
+ifneq ($(SHLIB),)
+$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB)): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
 	if test ! -d $(LIBDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR)); fi
-	$(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(SHLIB)) \
+	$(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$@) \
+	    $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS) $(SHLIB_OPT)
+endif
+ 
+ifneq ($(SONAME),)
+$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SONAME)): $(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB))
+	ln -sf $(SHLIB) $@
+endif
+
+ifneq ($(EXE),)
+$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE)): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
+	if test ! -d $(BINDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)); fi
+	$(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE)) \
 	    $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS)
-
-$(EXE): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
-	if test ! -d $(BINDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR)); fi
-	$(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$(EXE)) \
-	    $(subst /,$(HOST_PSEP),$(OBJS)) $($(APP)_LDFLAGS)
+endif
 
 $(OBJDIR)/$(app).o: $(OBJDIRS) $(OBJS)
@@ -148,11 +172,11 @@
 
 $(OBJDIRS):
-	$(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR)) 
+	$(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR))
 
 $(LIBDIR):
-	$(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR))
+	$(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR))
 
 $(BINDIR):
-	$(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)),$(HOST_MKDIR))
+	$(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR))
 
 clean:
@@ -169,5 +193,16 @@
 
 realclean: clean
-	$(subst @@,$(subst /,$(HOST_PSEP),$(LIB)) $(subst /,$(HOST_PSEP),$(EXE)),$(HOST_RM))
+ifneq ($(LIB),)
+	$(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)/$(LIB)),$(HOST_RM))
+endif
+ifneq ($(SHLIB),)
+	$(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SHLIB)),$(HOST_RM))
+endif
+ifneq ($(SONAME),)
+	$(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)/$(SONAME)),$(HOST_RM))
+endif
+ifneq ($(EXE),)
+	$(subst @@,$(subst /,$(HOST_PSEP),$(BINDIR)/$(EXE)),$(HOST_RM))
+endif
 	$(subst @@,$(DEP_FILE),$(HOST_RM))
 ifeq ($(OS_NAME),linux-kernel)
Index: pjproject/trunk/libpjproject.pc.in
===================================================================
--- pjproject/trunk/libpjproject.pc.in	(revision 4653)
+++ pjproject/trunk/libpjproject.pc.in	(revision 4656)
@@ -3,6 +3,6 @@
 prefix=@PREFIX@
 exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
 
 Name: libpjproject
Index: pjproject/trunk/pjlib-util/build/Makefile
===================================================================
--- pjproject/trunk/pjlib-util/build/Makefile	(revision 4653)
+++ pjproject/trunk/pjlib-util/build/Makefile	(revision 4656)
@@ -7,8 +7,18 @@
 include $(PJDIR)/build/common.mak
 
+export LIBDIR := ../lib
+export BINDIR := ../bin
+
 RULES_MAK := $(PJDIR)/build/rules.mak
 
 PJLIB_LIB:=$(PJDIR)/pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
-export PJLIB_UTIL_LIB:=../lib/libpjlib-util-$(TARGET_NAME)$(LIBEXT)
+
+export PJLIB_UTIL_LIB := libpjlib-util-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export PJLIB_UTIL_SONAME := libpjlib-util.$(SHLIB_SUFFIX)
+export PJLIB_UTIL_SHLIB := $(PJLIB_UTIL_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -19,8 +29,6 @@
 export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
 		   $(HOST_CXXFLAGS) $(CXXFLAGS)
-export _LDFLAGS := $(subst /,$(HOST_PSEP),$(PJLIB_UTIL_LIB)) \
-		   $(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)
 
 ###############################################################################
@@ -36,4 +44,5 @@
 export PJLIB_UTIL_CFLAGS += $(_CFLAGS)
 export PJLIB_UTIL_CXXFLAGS += $(_CXXFLAGS)
+export PJLIB_UTIL_LDFLAGS += $(PJLIB_LDLIB) $(_LDFLAGS)
 
 ###############################################################################
@@ -45,6 +54,6 @@
 export UTIL_TEST_CFLAGS += $(_CFLAGS)
 export UTIL_TEST_CXXFLAGS += $(_CXXFLAGS)
-export UTIL_TEST_LDFLAGS += $(_LDFLAGS)
-export UTIL_TEST_EXE:=../bin/pjlib-util-test-$(TARGET_NAME)$(HOST_EXE)
+export UTIL_TEST_LDFLAGS += $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
+export UTIL_TEST_EXE:=pjlib-util-test-$(TARGET_NAME)$(HOST_EXE)
 
 	
@@ -55,5 +64,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := pjlib-util pjlib-util-test
+TARGETS := $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME) $(UTIL_TEST_EXE)
 
 all: $(TARGETS)
@@ -73,24 +82,26 @@
 distclean: realclean
 
-.PHONY: dep depend clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
 .PHONY: $(TARGETS)
-.PHONY: $(PJLIB_UTIL_LIB) $(UTIL_TEST_EXE)
+.PHONY: $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
+.PHONY: $(UTIL_TEST_EXE)
 
-pjlib-util: $(PJLIB_UTIL_LIB)
-$(PJLIB_UTIL_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $(PJLIB_UTIL_LIB)
+pjlib-util: $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
+$(PJLIB_UTIL_SONAME): $(PJLIB_UTIL_LIB)
+$(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME): $(PJLIB_LIB) $(PJLIB_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjlib-util-test: $(UTIL_TEST_EXE)
-$(UTIL_TEST_EXE): $(PJLIB_UTIL_LIB)
-	$(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $(UTIL_TEST_EXE)
+$(UTIL_TEST_EXE): $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
 
-.PHONY: ../lib/pjlib-util.ko
-../lib/pjlib-util.ko:
+.PHONY: pjlib-util.ko
+pjlib-util.ko:
 	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $@
+	$(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
-.PHONY: ../lib/pjlib-util-test.ko
-../lib/pjlib-util-test.ko:
-	$(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $@
+.PHONY: pjlib-util-test.ko
+pjlib-util-test.ko:
+	$(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean:
@@ -107,5 +118,4 @@
 	$(MAKE) -f $(RULES_MAK) APP=PJLIB_UTIL app=pjlib-util $@
 	$(MAKE) -f $(RULES_MAK) APP=UTIL_TEST app=pjlib-util-test $@
-	echo '$(UTIL_TEST_EXE): $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjlib-util-test-$(TARGET_NAME).depend; \
+	echo '$(BINDIR)/$(UTIL_TEST_EXE): $(LIBDIR)/$(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjlib-util-test-$(TARGET_NAME).depend; \
 
-
Index: pjproject/trunk/pjlib/build/Makefile
===================================================================
--- pjproject/trunk/pjlib/build/Makefile	(revision 4653)
+++ pjproject/trunk/pjlib/build/Makefile	(revision 4656)
@@ -3,8 +3,16 @@
 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),)
+else
+export PJLIB_SONAME := libpj.$(SHLIB_SUFFIX)
+export PJLIB_SHLIB := $(PJLIB_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -15,7 +23,7 @@
 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) 
+
 
 ###############################################################################
@@ -32,4 +40,5 @@
 export PJLIB_CFLAGS += $(_CFLAGS)
 export PJLIB_CXXFLAGS += $(_CXXFLAGS)
+export PJLIB_LDFLAGS += $(_LDFLAGS)
 
 ###############################################################################
@@ -47,8 +56,8 @@
 export TEST_CFLAGS += $(_CFLAGS)
 export TEST_CXXFLAGS += $(_CXXFLAGS)
-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 
 ###############################################################################
@@ -77,10 +86,11 @@
 	$(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_SONAME)
+.PHONY: $(TEST_EXE)
 
 dep: depend
@@ -88,5 +98,8 @@
 pjlib: $(PJLIB_LIB)
 $(PJLIB_LIB): ../include/pj/config_site.h
-	$(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $(PJLIB_LIB)
+
+$(PJLIB_SONAME): $(PJLIB_LIB)
+$(PJLIB_LIB) $(PJLIB_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 ../include/pj/config_site.h:
@@ -94,15 +107,15 @@
 
 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:
Index: pjproject/trunk/pjlib/build/os-auto.mak.in
===================================================================
--- pjproject/trunk/pjlib/build/os-auto.mak.in	(revision 4653)
+++ pjproject/trunk/pjlib/build/os-auto.mak.in	(revision 4656)
@@ -30,5 +30,5 @@
 # operating system.
 #
-export TARGETS	    =	pjlib pjlib-test
+export TARGETS	    =	$(PJLIB_LIB) $(PJLIB_SONAME) $(TEST_EXE)
 
 
Index: pjproject/trunk/pjlib/build/os-darwinos.mak
===================================================================
--- pjproject/trunk/pjlib/build/os-darwinos.mak	(revision 4653)
+++ pjproject/trunk/pjlib/build/os-darwinos.mak	(revision 4656)
@@ -34,4 +34,4 @@
 # operating system.
 #
-export TARGETS	    =	pjlib pjlib-test
+export TARGETS	    =	$(PJLIB_LIB) $(PJLIB_SONAME) $(TEST_EXE)
 
Index: pjproject/trunk/pjlib/build/os-linux-kernel.mak
===================================================================
--- pjproject/trunk/pjlib/build/os-linux-kernel.mak	(revision 4653)
+++ pjproject/trunk/pjlib/build/os-linux-kernel.mak	(revision 4656)
@@ -43,5 +43,5 @@
 # operating system.
 #
-export TARGETS :=	../lib/pjlib.ko ../lib/pjlib-test.ko
+export TARGETS :=	pjlib.ko pjlib-test.ko
 
 
Index: pjproject/trunk/pjlib/build/os-linux.mak
===================================================================
--- pjproject/trunk/pjlib/build/os-linux.mak	(revision 4653)
+++ pjproject/trunk/pjlib/build/os-linux.mak	(revision 4656)
@@ -36,4 +36,4 @@
 # operating system.
 #
-export TARGETS	    =	pjlib pjlib-test
+export TARGETS	    =	$(PJLIB_LIB) $(PJLIB_SONAME) $(TEST_EXE)
 
Index: pjproject/trunk/pjlib/build/os-rtems.mak
===================================================================
--- pjproject/trunk/pjlib/build/os-rtems.mak	(revision 4653)
+++ pjproject/trunk/pjlib/build/os-rtems.mak	(revision 4656)
@@ -41,5 +41,5 @@
 # operating system.
 #
-export TARGETS	    =	pjlib pjlib-test
+export TARGETS	    =	$(PJLIB_LIB) $(TEST_EXE)
 
 
Index: pjproject/trunk/pjlib/build/os-sunos.mak
===================================================================
--- pjproject/trunk/pjlib/build/os-sunos.mak	(revision 4653)
+++ pjproject/trunk/pjlib/build/os-sunos.mak	(revision 4656)
@@ -33,4 +33,4 @@
 # operating system.
 #
-export TARGETS	    =	pjlib pjlib-test
+export TARGETS	    =	$(PJLIB_LIB) $(PJLIB_SONAME) $(TEST_EXE)
 
Index: pjproject/trunk/pjlib/build/os-win32.mak
===================================================================
--- pjproject/trunk/pjlib/build/os-win32.mak	(revision 4653)
+++ pjproject/trunk/pjlib/build/os-win32.mak	(revision 4656)
@@ -30,4 +30,4 @@
 # operating system.
 #
-export TARGETS	    =	pjlib pjlib-test
+export TARGETS	    =	$(PJLIB_LIB) $(TEST_EXE)
 
Index: pjproject/trunk/pjmedia/build/Makefile
===================================================================
--- pjproject/trunk/pjmedia/build/Makefile	(revision 4653)
+++ pjproject/trunk/pjmedia/build/Makefile	(revision 4656)
@@ -10,4 +10,7 @@
 include $(PJDIR)/build/common.mak
 
+export LIBDIR := ../lib
+export BINDIR := ../bin
+
 RULES_MAK := $(PJDIR)/build/rules.mak
 
@@ -16,9 +19,23 @@
 PJNATH_LIB:=$(PJDIR)/pjnath/lib/libpjnath-$(TARGET_NAME)$(LIBEXT)
 
-export PJMEDIA_LIB:=../lib/libpjmedia-$(TARGET_NAME)$(LIBEXT)
-export PJMEDIA_CODEC_LIB:=../lib/libpjmedia-codec-$(TARGET_NAME)$(LIBEXT)
-export PJSDP_LIB:=../lib/libpjsdp-$(TARGET_NAME)$(LIBEXT)
-export PJMEDIA_AUDIODEV_LIB:=../lib/libpjmedia-audiodev-$(TARGET_NAME)$(LIBEXT)
-export PJMEDIA_VIDEODEV_LIB:=../lib/libpjmedia-videodev-$(TARGET_NAME)$(LIBEXT)
+export PJMEDIA_LIB:=libpjmedia-$(TARGET_NAME)$(LIBEXT)
+export PJMEDIA_CODEC_LIB:=libpjmedia-codec-$(TARGET_NAME)$(LIBEXT)
+export PJSDP_LIB:=libpjsdp-$(TARGET_NAME)$(LIBEXT)
+export PJMEDIA_AUDIODEV_LIB:=libpjmedia-audiodev-$(TARGET_NAME)$(LIBEXT)
+export PJMEDIA_VIDEODEV_LIB:=libpjmedia-videodev-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export PJMEDIA_SONAME:=libpjmedia.$(SHLIB_SUFFIX)
+export PJMEDIA_SHLIB:=$(PJMEDIA_SONAME).$(PJ_VERSION_MAJOR)
+export PJMEDIA_CODEC_SONAME:=libpjmedia-codec.$(SHLIB_SUFFIX)
+export PJMEDIA_CODEC_SHLIB:=$(PJMEDIA_CODEC_SONAME).$(PJ_VERSION_MAJOR)
+export PJSDP_SONAME:=libpjsdp.$(SHLIB_SUFFIX)
+export PJSDP_SHLIB:=$(PJSDP_SONAME).$(PJ_VERSION_MAJOR)
+export PJMEDIA_AUDIODEV_SONAME:=libpjmedia-audiodev.$(SHLIB_SUFFIX)
+export PJMEDIA_AUDIODEV_SHLIB:=$(PJMEDIA_AUDIODEV_SONAME).$(PJ_VERSION_MAJOR)
+export PJMEDIA_VIDEODEV_SONAME:=libpjmedia-videodev.$(SHLIB_SUFFIX)
+export PJMEDIA_VIDEODEV_SHLIB:=$(PJMEDIA_VIDEODEV_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 
@@ -36,16 +53,9 @@
 export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
 		   $(HOST_CXXFLAGS) $(CXXFLAGS)
-export _LDFLAGS := $(subst /,$(HOST_PSEP),$(PJMEDIA_VIDEODEV_LIB)) \
-		   $(subst /,$(HOST_PSEP),$(PJMEDIA_CODEC_LIB)) \
-		   $(subst /,$(HOST_PSEP),$(PJMEDIA_LIB)) \
-		   $(subst /,$(HOST_PSEP),$(PJMEDIA_AUDIODEV_LIB)) \
-		   $(subst /,$(HOST_PSEP),$(PJLIB_LIB)) \
-		   $(subst /,$(HOST_PSEP),$(PJLIB_UTIL_LIB)) \
-		   $(subst /,$(HOST_PSEP),$(PJNATH_LIB)) \
-		   -L$(PJDIR)/third_party/lib \
-		   $(APP_THIRD_PARTY_LIBS) \
+
+export _LDFLAGS := $(APP_THIRD_PARTY_LIBS) \
 		   $(APP_THIRD_PARTY_EXT) \
 		   $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
-		   $(LDFLAGS) 
+		   $(APP_LDFLAGS) $(LDFLAGS) 
 
 ###############################################################################
@@ -75,4 +85,10 @@
 export PJMEDIA_CFLAGS += $(_CFLAGS)
 export PJMEDIA_CXXFLAGS += $(_CXXFLAGS)
+export PJMEDIA_LDFLAGS += $(PJMEDIA_VIDEODEV_LDLIB) \
+			  $(PJMEDIA_AUDIODEV_LDLIB) \
+			  $(PJLIB_LDLIB) \
+			  $(PJLIB_UTIL_LDLIB) \
+			  $(PJNATH_LDLIB) \
+			  $(_LDFLAGS)
 
 
@@ -87,4 +103,6 @@
 export PJMEDIA_AUDIODEV_CFLAGS += $(_CFLAGS)
 export PJMEDIA_AUDIODEV_CXXFLAGS += $(_CXXFLAGS)
+export PJMEDIA_AUDIODEV_LDFLAGS += $(PJLIB_LDLIB) \
+				   $(_LDFLAGS)
 
 
@@ -97,4 +115,6 @@
 export PJMEDIA_VIDEODEV_CFLAGS += $(_CFLAGS)
 export PJMEDIA_VIDEODEV_CXXFLAGS += $(_CXXFLAGS)
+export PJMEDIA_VIDEODEV_LDFLAGS += $(PJLIB_LDLIB) \
+				   $(_LDFLAGS)
 
 
@@ -110,4 +130,8 @@
 export PJSDP_CFLAGS += $(_CFLAGS)
 export PJSDP_CXXFLAGS += $(_CXXFLAGS)
+export PJSDP_LDFLAGS += $(PJMEDIA_LDLIB) \
+			$(PJLIB_LDLIB) \
+			$(PJLIB_UTIL_LDLIB) \
+			$(_LDFLAGS)
 
 
@@ -125,5 +149,7 @@
 export PJMEDIA_CODEC_CXXFLAGS += $(_CXXFLAGS) $(GSM_CFLAGS) $(SPEEX_CFLAGS) \
 			$(ILBC_CFLAGS) $(IPP_CFLAGS) $(G7221_CFLAGS)
-
+export PJMEDIA_CODEC_LDFLAGS += $(PJMEDIA_LDLIB) \
+				$(PJLIB_LDLIB) \
+				$(_LDFLAGS)
 
 ###############################################################################
@@ -137,6 +163,13 @@
 export PJMEDIA_TEST_CFLAGS += $(_CFLAGS)
 export PJMEDIA_TEST_CXXFLAGS += $(_CXXFLAGS)
-export PJMEDIA_TEST_LDFLAGS += $(_LDFLAGS)
-export PJMEDIA_TEST_EXE:=../bin/pjmedia-test-$(TARGET_NAME)$(HOST_EXE)
+export PJMEDIA_TEST_LDFLAGS += $(PJMEDIA_CODEC_LDLIB) \
+			       $(PJMEDIA_VIDEODEV_LDLIB) \
+			       $(PJMEDIA_LDLIB) \
+			       $(PJMEDIA_AUDIODEV_LDLIB) \
+			       $(PJLIB_LDLIB) \
+			       $(PJLIB_UTIL_LDLIB) \
+			       $(PJNATH_LDLIB) \
+			       $(_LDFLAGS)
+export PJMEDIA_TEST_EXE:=pjmedia-test-$(TARGET_NAME)$(HOST_EXE)
 
 	
@@ -147,5 +180,10 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := pjmedia pjmedia-videodev pjmedia-audiodev pjmedia-codec pjsdp pjmedia-test
+TARGETS := $(PJMEDIA_LIB) $(PJMEDIA_SONAME) \
+	   $(PJMEDIA_CODEC_LIB) $(PJMEDIA_CODEC_SONAME)\
+	   $(PJMEDIA_VIDEODEV_LIB) $(PJMEDIA_VIDEODEV_SONAME) \
+	   $(PJMEDIA_AUDIODEV_LIB) $(PJMEDIA_AUDIODEV_SONAME) \
+	   $(PJSDP_LIB) $(PJSDP_SONAME) \
+	   $(PJMEDIA_TEST_EXE)
 
 all: $(TARGETS)
@@ -165,45 +203,59 @@
 distclean: realclean
 
-.PHONY: dep depend clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
 .PHONY: $(TARGETS)
-.PHONY: $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB) $(PJMEDIA_VIDEODEV_LIB) $(PJMEDIA_AUDIODEV_LIB) $(PJSDP_LIB) $(PJMEDIA_TEST_EXE)
+.PHONY: $(PJMEDIA_LIB) $(PJMEDIA_SONAME)
+.PHONY: $(PJMEDIA_CODEC_LIB) $(PJMEDIA_CODEC_SONAME)
+.PHONY: $(PJMEDIA_VIDEODEV_LIB) $(PJMEDIA_VIDEODEV_SONAME)
+.PHONY: $(PJMEDIA_AUDIODEV_LIB) $(PJMEDIA_AUDIODEV_SONAME)
+.PHONY: $(PJSDP_LIB) $(PJSDP_SONAME)
+.PHONY: $(PJMEDIA_TEST_EXE)
 
 pjmedia: $(PJMEDIA_LIB)
-$(PJMEDIA_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA app=pjmedia $(PJMEDIA_LIB)
+$(PJMEDIA_SONAME): $(PJMEDIA_LIB)
+$(PJMEDIA_LIB) $(PJMEDIA_SONAME): $(PJMEDIA_AUDIODEV_LIB) $(PJMEDIA_AUDIODEV_SONAME) $(PJMEDIA_VIDEODEV_LIB) $(PJMEDIA_VIDEODEV_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA app=pjmedia $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjmedia-codec: $(PJMEDIA_CODEC_LIB)
-$(PJMEDIA_CODEC_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_CODEC app=pjmedia-codec $(PJMEDIA_CODEC_LIB)
+$(PJMEDIA_CODEC_SONAME): $(PJMEDIA_CODEC_LIB)
+$(PJMEDIA_CODEC_LIB) $(PJMEDIA_CODEC_SONAME): $(PJMEDIA_LIB) $(PJMEDIA_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_CODEC app=pjmedia-codec $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjmedia-videodev: $(PJMEDIA_VIDEODEV_LIB)
-$(PJMEDIA_VIDEODEV_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_VIDEODEV app=pjmedia-videodev $(PJMEDIA_VIDEODEV_LIB)
+$(PJMEDIA_VIDEODEV_SONAME): $(PJMEDIA_VIDEODEV_LIB)
+$(PJMEDIA_VIDEODEV_LIB) $(PJMEDIA_VIDEODEV_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_VIDEODEV app=pjmedia-videodev $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjmedia-audiodev: $(PJMEDIA_AUDIODEV_LIB)
-$(PJMEDIA_AUDIODEV_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_AUDIODEV app=pjmedia-audiodev $(PJMEDIA_AUDIODEV_LIB)
+$(PJMEDIA_AUDIODEV_SONAME): $(PJMEDIA_AUDIODEV_LIB)
+$(PJMEDIA_AUDIODEV_LIB) $(PJMEDIA_AUDIODEV_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_AUDIODEV app=pjmedia-audiodev $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjsdp: $(PJSDP_LIB)
-$(PJSDP_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJSDP app=pjsdp $(PJSDP_LIB)
+$(PJSDP_SONAME): $(PJSDP_LIB)
+$(PJSDP_LIB) $(PJSDP_SONAME): $(PJMEDIA_LIB) $(PJMEDIA_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJSDP app=pjsdp $(LIBDIR)/$@
 
 pjmedia-test: $(PJMEDIA_TEST_EXE)
-$(PJMEDIA_TEST_EXE): $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB)
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_TEST app=pjmedia-test $(PJMEDIA_TEST_EXE)
-
-.PHONY: ../lib/pjmedia.ko
-../lib/pjmedia.ko:
+$(PJMEDIA_TEST_EXE): $(PJMEDIA_LIB) $(PJMEDIA_SONAME)
+$(PJMEDIA_TEST_EXE): $(PJMEDIA_AUDIODEV_LIB) $(PJMEDIA_AUDIODEV_SONAME)
+$(PJMEDIA_TEST_EXE): $(PJMEDIA_VIDEODEV_LIB) $(PJMEDIA_VIDEODEV_SONAME)
+$(PJMEDIA_TEST_EXE): $(PJMEDIA_CODEC_LIB) $(PJMEDIA_CODEC_SONAME)
+$(PJMEDIA_TEST_EXE):
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_TEST app=pjmedia-test $(BINDIR)/$@
+
+.PHONY: pjmedia.ko
+pjmedia.ko:
 	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA app=pjmedia $@
-
-.PHONY: ../lib/pjmedia-codec.ko
-../lib/pjmedia-codec.ko:
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA app=pjmedia $(LIBDIR)/$@
+
+.PHONY: pjmedia-codec.ko
+pjmedia-codec.ko:
 	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_CODEC app=pjmedia-codec $@
-
-.PHONY: ../lib/pjmedia-test.ko
-../lib/pjmedia-test.ko:
-	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_TEST app=pjmedia-test $@
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_CODEC app=pjmedia-codec $(LIBDIR)/$@
+
+.PHONY: pjmedia-test.ko
+pjmedia-test.ko:
+	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_TEST app=pjmedia-test $(LIBDIR)/$@
 
 clean:
@@ -237,5 +289,5 @@
 	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_TEST app=pjmedia-test $@
 	$(MAKE) -f $(RULES_MAK) APP=PJSDP app=pjsdp $@
-	echo '$(PJMEDIA_TEST_EXE): $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB) $(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjmedia-test-$(TARGET_NAME).depend
-
-
+	echo '$(BINDIR)/$(PJMEDIA_TEST_EXE): $(LIBDIR)/$(PJMEDIA_LIB) $(LIBDIR)/$(PJMEDIA_CODEC_LIB) $(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjmedia-test-$(TARGET_NAME).depend
+
+
Index: pjproject/trunk/pjmedia/include/pjmedia-videodev/config.h
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia-videodev/config.h	(revision 4653)
+++ pjproject/trunk/pjmedia/include/pjmedia-videodev/config.h	(revision 4656)
@@ -53,4 +53,6 @@
 
 
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+
 /**
  * This setting controls whether SDL support should be included.
@@ -145,4 +147,6 @@
 #endif
 
+#endif /* defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) */
+
 /**
  * @}
Index: pjproject/trunk/pjnath/build/Makefile
===================================================================
--- pjproject/trunk/pjnath/build/Makefile	(revision 4653)
+++ pjproject/trunk/pjnath/build/Makefile	(revision 4656)
@@ -7,9 +7,19 @@
 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)
-export PJNATH_LIB:=../lib/libpjnath-$(TARGET_NAME)$(LIBEXT)
+
+export PJNATH_LIB:=libpjnath-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export PJNATH_SONAME := libpjnath.$(SHLIB_SUFFIX)
+export PJNATH_SHLIB := $(PJNATH_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -21,9 +31,6 @@
 export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
 		   $(HOST_CXXFLAGS) $(CXXFLAGS)
-export _LDFLAGS := $(subst /,$(HOST_PSEP),$(PJNATH_LIB)) \
-		   $(subst /,$(HOST_PSEP),$(PJLIB_UTIL_LIB)) \
-		   $(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) 
 
 ###############################################################################
@@ -37,4 +44,5 @@
 export PJNATH_CFLAGS += $(_CFLAGS)
 export PJNATH_CXXFLAGS += $(_CXXFLAGS)
+export PJNATH_LDFLAGS += $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
 
 ###############################################################################
@@ -46,6 +54,6 @@
 export PJNATH_TEST_CFLAGS += $(_CFLAGS)
 export PJNATH_TEST_CXXFLAGS += $(_CXXFLAGS)
-export PJNATH_TEST_LDFLAGS += $(_LDFLAGS)
-export PJNATH_TEST_EXE:=../bin/pjnath-test-$(TARGET_NAME)$(HOST_EXE)
+export PJNATH_TEST_LDFLAGS += $(PJNATH_LDLIB) $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
+export PJNATH_TEST_EXE:=pjnath-test-$(TARGET_NAME)$(HOST_EXE)
 
 	
@@ -57,6 +65,6 @@
 export PJTURN_CLIENT_CFLAGS += $(_CFLAGS)
 export PJTURN_CLIENT_CXXFLAGS += $(_CXXFLAGS)
-export PJTURN_CLIENT_LDFLAGS += $(_LDFLAGS)
-export PJTURN_CLIENT_EXE:=../bin/pjturn-client-$(TARGET_NAME)$(HOST_EXE)
+export PJTURN_CLIENT_LDFLAGS += $(PJNATH_LDLIB) $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
+export PJTURN_CLIENT_EXE:=pjturn-client-$(TARGET_NAME)$(HOST_EXE)
 
 ###############################################################################
@@ -68,6 +76,6 @@
 export PJTURN_SRV_CFLAGS += $(_CFLAGS)
 export PJTURN_SRV_CXXFLAGS += $(_CXXFLAGS)
-export PJTURN_SRV_LDFLAGS += $(_LDFLAGS)
-export PJTURN_SRV_EXE:=../bin/pjturn-srv-$(TARGET_NAME)$(HOST_EXE)
+export PJTURN_SRV_LDFLAGS += $(PJNATH_LDLIB) $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS)
+export PJTURN_SRV_EXE:=pjturn-srv-$(TARGET_NAME)$(HOST_EXE)
 
 	
@@ -79,5 +87,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := pjnath pjnath-test pjturn-client pjturn-srv
+TARGETS := $(PJNATH_LIB) $(PJNATH_SONAME) $(PJNATH_TEST_EXE) $(PJTURN_CLIENT_EXE) $(PJTURN_SRV_EXE)
 
 all: $(TARGETS)
@@ -97,32 +105,34 @@
 distclean: realclean
 
-.PHONY: dep depend clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
 .PHONY: $(TARGETS)
-.PHONY: $(PJNATH_LIB) $(PJNATH_TEST_EXE) $(PJTURN_CLIENT_EXE) $(PJTURN_SRV_EXE)
+.PHONY: $(PJNATH_LIB) $(PJNATH_SONAME)
+.PHONY: $(PJNATH_TEST_EXE) $(PJTURN_CLIENT_EXE) $(PJTURN_SRV_EXE)
 
 pjnath: $(PJNATH_LIB)
-$(PJNATH_LIB):
-	$(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $(PJNATH_LIB)
+$(PJNATH_SONAME): $(PJNATH_LIB)
+$(PJNATH_LIB) $(PJNATH_SONAME): $(PJLIB_LIB) $(PJLIB_SONAME) $(PJLIB_UTIL_LIB) $(PJLIB_UTIL_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 pjnath-test: $(PJNATH_TEST_EXE)
-$(PJNATH_TEST_EXE): $(PJNATH_LIB)
-	$(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $(PJNATH_TEST_EXE)
+$(PJNATH_TEST_EXE): $(PJNATH_LIB) $(PJNATH_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
 
 pjturn-client: $(PJTURN_CLIENT_EXE)
-$(PJTURN_CLIENT_EXE): $(PJNATH_LIB)
-	$(MAKE) -f $(RULES_MAK) APP=PJTURN_CLIENT app=pjturn-client $(PJTURN_CLIENT_EXE)
+$(PJTURN_CLIENT_EXE): $(PJNATH_LIB) $(PJNATH_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJTURN_CLIENT app=pjturn-client $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
 
 pjturn-srv: $(PJTURN_SRV_EXE)
-$(PJTURN_SRV_EXE): $(PJNATH_LIB)
-	$(MAKE) -f $(RULES_MAK) APP=PJTURN_SRV app=pjturn-srv $(PJTURN_SRV_EXE)
+$(PJTURN_SRV_EXE): $(PJNATH_LIB) $(PJNATH_SONAME)
+	$(MAKE) -f $(RULES_MAK) APP=PJTURN_SRV app=pjturn-srv $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
 
-.PHONY: ../lib/pjnath.ko
-../lib/pjnath.ko:
+.PHONY: pjnath.ko
+pjnath.ko:
 	echo Making $@
-	$(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $@
+	$(MAKE) -f $(RULES_MAK) APP=PJNATH app=pjnath $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
-.PHONY: ../lib/pjnath-test.ko
-../lib/pjnath-test.ko:
-	$(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $@
+.PHONY: pjnath-test.ko
+pjnath-test.ko:
+	$(MAKE) -f $(RULES_MAK) APP=PJNATH_TEST app=pjnath-test $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean:
@@ -147,7 +157,7 @@
 	$(MAKE) -f $(RULES_MAK) APP=PJTURN_CLIENT app=pjturn-client $@
 	$(MAKE) -f $(RULES_MAK) APP=PJTURN_SRV app=pjturn-srv $@
-	echo '$(PJNATH_TEST_EXE): $(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjnath-test-$(TARGET_NAME).depend
-	echo '$(PJTURN_CLIENT_EXE): $(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjturn-client-$(TARGET_NAME).depend
-	echo '$(PJTURN_SRV_EXE): $(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjturn-srv-$(TARGET_NAME).depend
+	echo '$(BINDIR)/$(PJNATH_TEST_EXE): $(LIBDIR)/$(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjnath-test-$(TARGET_NAME).depend
+	echo '$(BINDIR)/$(PJTURN_CLIENT_EXE): $(LIBDIR)/$(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjturn-client-$(TARGET_NAME).depend
+	echo '$(BINDIR)/$(PJTURN_SRV_EXE): $(LIBDIR)/$(PJNATH_LIB) $(PJLIB_UTIL_LIB) $(PJLIB_LIB)' >> .pjturn-srv-$(TARGET_NAME).depend
 
 
Index: pjproject/trunk/pjsip-apps/build/Makefile
===================================================================
--- pjproject/trunk/pjsip-apps/build/Makefile	(revision 4653)
+++ pjproject/trunk/pjsip-apps/build/Makefile	(revision 4656)
@@ -2,4 +2,6 @@
 include $(PJDIR)/build/common.mak
 
+export LIBDIR := ../lib
+export BINDIR := ../bin
 
 RULES_MAK := $(PJDIR)/build/rules.mak
@@ -28,4 +30,6 @@
 export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
 		   $(HOST_CXXFLAGS) $(CXXFLAGS)
+export _LDFLAGS := $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
+		   $(APP_LDFLAGS) $(APP_LDLIBS) $(LDFLAGS) 
 
 ###############################################################################
@@ -38,6 +42,6 @@
 export PJSUA_CFLAGS += $(_CFLAGS)
 export PJSUA_CXXFLAGS += $(_CXXFLAGS)
-export PJSUA_LDFLAGS += $(APP_LDFLAGS) $(APP_LDLIBS) $(LDFLAGS)
-export PJSUA_EXE:=../bin/pjsua-$(TARGET_NAME)$(HOST_EXE)
+export PJSUA_LDFLAGS += $(_LDFLAGS)
+export PJSUA_EXE:=pjsua-$(TARGET_NAME)$(HOST_EXE)
 
 
@@ -50,6 +54,6 @@
 export PJSYSTEST_CFLAGS += $(_CFLAGS)
 export PJSYSTEST_CXXFLAGS += $(_CXXFLAGS)
-export PJSYSTEST_LDFLAGS += $(APP_LDFLAGS) $(APP_LDLIBS) $(LDFLAGS)
-export PJSYSTEST_EXE:=../bin/pjsystest-$(TARGET_NAME)$(HOST_EXE)
+export PJSYSTEST_LDFLAGS += $(_LDFLAGS)
+export PJSYSTEST_EXE:=pjsystest-$(TARGET_NAME)$(HOST_EXE)
 
 
@@ -59,5 +63,5 @@
 #
 #
-TARGETS := pjsua pjsystest samples
+TARGETS := $(BINDIR)/$(PJSUA_EXE) $(BINDIR)/$(PJSYSTEST_EXE) samples
 
 all: $(TARGETS)
@@ -68,5 +72,5 @@
 distclean: realclean
 
-.PHONY: dep depend clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
 .PHONY: $(TARGETS)
 .PHONY: $(PJSUA_EXE) $(PJSYSTEST_EXE)
@@ -74,16 +78,16 @@
 pjsua: $(PJSUA_EXE)
 $(PJSUA_EXE):
-	$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(PJSUA_EXE)
+	$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
 
 pjsystest: $(PJSYSTEST_EXE)
 $(PJSYSTEST_EXE):
-	$(MAKE) -f $(RULES_MAK) APP=PJSYSTEST app=pjsystest $(PJSYSTEST_EXE)
+	$(MAKE) -f $(RULES_MAK) APP=PJSYSTEST app=pjsystest $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
 
 samples:
 	$(MAKE) -f Samples.mak
 
-.PHONY: ../lib/pjsua.ko
-../lib/pjsua.ko:
-	$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $@
+.PHONY: pjsua.ko
+pjsua.ko:
+	$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean depend realclean:
@@ -92,6 +96,6 @@
 	$(MAKE) -f Samples.mak $@
 	@if test "$@" = "depend"; then \
-	  echo '$(PJSUA_EXE): $(APP_LIB_FILES)' >> .pjsua-$(TARGET_NAME).depend; \
-	  echo '$(PJSYSTEST_EXE): $(APP_LIB_FILES)' >> .pjsystest-$(TARGET_NAME).depend; \
+	  echo '$(BINDIR)/$(PJSUA_EXE): $(APP_LIB_FILES)' >> .pjsua-$(TARGET_NAME).depend; \
+	  echo '$(BINDIR)/$(PJSYSTEST_EXE): $(APP_LIB_FILES)' >> .pjsystest-$(TARGET_NAME).depend; \
 	fi
 
Index: pjproject/trunk/pjsip-apps/build/Samples.mak
===================================================================
--- pjproject/trunk/pjsip-apps/build/Samples.mak	(revision 4653)
+++ pjproject/trunk/pjsip-apps/build/Samples.mak	(revision 4656)
@@ -1,5 +1,7 @@
-
+include ../../build.mak
+include ../../version.mak
 include ../../build/common.mak
 
+RULES_MAK := $(PJDIR)/build/rules.mak
 
 ###############################################################################
@@ -17,5 +19,4 @@
 	   aviplay \
 	   aectest \
-	   aviplay \
 	   clidemo \
 	   confsample \
@@ -46,34 +47,21 @@
 	   vid_streamutil
 
-EXES := $(foreach file, $(SAMPLES), $(BINDIR)/$(file)$(HOST_EXE))
+EXES := $(foreach file, $(SAMPLES), $(file)$(HOST_EXE))
 
-all: $(BINDIR) $(OBJDIR) $(EXES)
+.PHONY: $(EXES)
 
-$(BINDIR)/%$(HOST_EXE): $(OBJDIR)/%$(OBJEXT) $(PJ_LIB_FILES)
-	$(LD) $(LDOUT)$(subst /,$(HOST_PSEP),$@) \
-	    $(subst /,$(HOST_PSEP),$<) \
-	    $(_LDFLAGS)
+all: $(EXES)
 
-$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c
-	$(CC) $(_CFLAGS) \
-	  $(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
-	  $(subst /,$(HOST_PSEP),$<) 
-
-$(OBJDIR):
-	$(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR)) 
-
-$(BINDIR):
-	$(subst @@,$(subst /,$(HOST_PSEP),$@),$(HOST_MKDIR)) 
+$(EXES):
+	$(MAKE) --no-print-directory -f $(RULES_MAK) SAMPLE_SRCDIR=$(SRCDIR) SAMPLE_OBJS=$@.o SAMPLE_CFLAGS="$(_CFLAGS)" SAMPLE_LDFLAGS="$(_LDFLAGS)" SAMPLE_EXE=$@ APP=SAMPLE app=sample $(subst /,$(HOST_PSEP),$(BINDIR)/$@)
 
 depend:
 
 clean:
-	$(subst @@,$(subst /,$(HOST_PSEP),$(OBJDIR)/*),$(HOST_RMR))
-	$(subst @@,$(subst /,$(HOST_PSEP),$(OBJDIR)),$(HOST_RMDIR))
+	$(MAKE) -f $(RULES_MAK) APP=SAMPLE app=sample $@
 	$(subst @@,$(EXES),$(HOST_RM))
-	rm -rf $(BINDIR)
+	$(subst @@,$(BINDIR),$(HOST_RMDIR))
 
 distclean realclean: clean
-#	$(subst @@,$(subst /,$(HOST_PSEP),$(EXES)) $(subst /,$(HOST_PSEP),$(EXES)),$(HOST_RM))
-#	$(subst @@,$(DEP_FILE),$(HOST_RM))
+	$(MAKE) -f $(RULES_MAK) APP=SAMPLE app=sample $@
 
Index: pjproject/trunk/pjsip/build/Makefile
===================================================================
--- pjproject/trunk/pjsip/build/Makefile	(revision 4653)
+++ 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:
Index: pjproject/trunk/third_party/build/g7221/Makefile
===================================================================
--- pjproject/trunk/third_party/build/g7221/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/g7221/Makefile	(revision 4656)
@@ -6,5 +6,11 @@
 RULES_MAK := $(PJDIR)/build/rules.mak
 
-export G7221_CODEC_LIB := ../../lib/libg7221codec-$(TARGET_NAME)$(LIBEXT)
+export G7221_CODEC_LIB := libg7221codec-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export G7221_CODEC_SONAME := libg7221codec.$(SHLIB_SUFFIX)
+export G7221_CODEC_SHLIB := $(G7221_CODEC_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -35,5 +41,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := libg7221codec
+TARGETS := $(G7221_CODEC_LIB) $(G7221_CODEC_SONAME)
 
 all: $(TARGETS)
@@ -45,8 +51,12 @@
 distclean: realclean
 
-.PHONY: dep depend libg7221codec clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONY: $(G7221_CODEC_LIB) $(G7221_CODEC_SONAME)
 
-libg7221codec:
-	$(MAKE) -f $(RULES_MAK) APP=G7221_CODEC app=libg7221codec $(G7221_CODEC_LIB)
+libg7221codec: $(G7221_CODEC_LIB)
+$(G7221_CODEC_SONAME): $(G7221_CODEC_LIB)
+$(G7221_CODEC_LIB) $(G7221_CODEC_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=G7221_CODEC app=libg7221codec $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean print_lib:
Index: pjproject/trunk/third_party/build/gsm/Makefile
===================================================================
--- pjproject/trunk/third_party/build/gsm/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/gsm/Makefile	(revision 4656)
@@ -6,5 +6,11 @@
 RULES_MAK := $(PJDIR)/build/rules.mak
 
-export GSM_CODEC_LIB := ../../lib/libgsmcodec-$(TARGET_NAME)$(LIBEXT)
+export GSM_CODEC_LIB := libgsmcodec-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export GSM_CODEC_SONAME := libgsmcodec.$(SHLIB_SUFFIX)
+export GSM_CODEC_SHLIB := $(GSM_CODEC_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -36,5 +42,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := libgsmcodec
+TARGETS := $(GSM_CODEC_LIB) $(GSM_CODEC_SONAME)
 
 all: $(TARGETS)
@@ -46,8 +52,12 @@
 distclean: realclean
 
-.PHONY: dep depend libgsmcodec clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONE: $(GSM_CODEC_LIB) $(GSM_CODEC_SONAME)
 
-libgsmcodec:
-	$(MAKE) -f $(RULES_MAK) APP=GSM_CODEC app=libgsmcodec $(GSM_CODEC_LIB)
+libgsmcodec: $(GSM_CODEC_LIB)
+$(GSM_CODEC_SONAME): $(GSM_CODEC_LIB)
+$(GSM_CODEC_LIB) $(GSM_CODEC_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=GSM_CODEC app=libgsmcodec $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean print_lib:
Index: pjproject/trunk/third_party/build/ilbc/Makefile
===================================================================
--- pjproject/trunk/third_party/build/ilbc/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/ilbc/Makefile	(revision 4656)
@@ -6,5 +6,11 @@
 RULES_MAK := $(PJDIR)/build/rules.mak
 
-export ILBC_LIB := ../../lib/libilbccodec-$(TARGET_NAME)$(LIBEXT)
+export ILBC_LIB := libilbccodec-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export ILBC_SONAME := libilbccodec.$(SHLIB_SUFFIX)
+export ILBC_SHLIB := $(ILBC_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -37,5 +43,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := libilbccodec
+TARGETS := $(ILBC_LIB) $(ILBC_SONAME)
 
 all: $(TARGETS)
@@ -47,8 +53,12 @@
 distclean: realclean
 
-.PHONY: dep depend libilbccodec clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONY: $(ILBC_LIB) $(ILBC_SONAME)
 
-libilbccodec:
-	$(MAKE) -f $(RULES_MAK) APP=ILBC app=libilbccodec $(ILBC_LIB)
+libilbccodec: $(ILBC_LIB)
+$(ILBC_SONAME): $(ILBC_LIB)
+$(ILBC_LIB) $(ILBC_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=ILBC app=libilbccodec $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean print_lib:
Index: pjproject/trunk/third_party/build/milenage/Makefile
===================================================================
--- pjproject/trunk/third_party/build/milenage/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/milenage/Makefile	(revision 4656)
@@ -6,5 +6,11 @@
 RULES_MAK := $(PJDIR)/build/rules.mak
 
-export MILENAGE_LIB := ../../lib/libmilenage-$(TARGET_NAME)$(LIBEXT)
+export MILENAGE_LIB := libmilenage-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export MILENAGE_SONAME := libmilenage.$(SHLIB_SUFFIX)
+export MILENAGE_SHLIB := $(MILENAGE_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -30,5 +36,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := libmilenage
+TARGETS := $(MILENAGE_LIB) $(MILENAGE_SONAME)
 
 all: $(TARGETS)
@@ -40,8 +46,12 @@
 distclean: realclean
 
-.PHONY: dep depend libmilenage clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONY: $(MILENAGE_LIB) $(MILENAGE_SONAME)
 
-libmilenage:
-	$(MAKE) -f $(RULES_MAK) APP=MILENAGE app=libmilenage $(MILENAGE_LIB)
+libmilenage: $(MILENAGE_LIB)
+$(MILENAGE_SONAME): $(MILENAGE_LIB)
+$(MILENAGE_LIB) $(MILENAGE_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=MILENAGE app=libmilenage $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean print_lib:
Index: pjproject/trunk/third_party/build/portaudio/Makefile
===================================================================
--- pjproject/trunk/third_party/build/portaudio/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/portaudio/Makefile	(revision 4656)
@@ -7,5 +7,11 @@
 RULES_MAK := $(PJDIR)/build/rules.mak
 
-export PORTAUDIO_LIB:=../../lib/libportaudio-$(TARGET_NAME)$(LIBEXT)
+export PORTAUDIO_LIB:=libportaudio-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export PORTAUDIO_SONAME := libportaudio.$(SHLIB_SUFFIX)
+export PORTAUDIO_SHLIB := $(PORTAUDIO_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 PORTAUDIO_OBJS += pa_allocation.o \
@@ -44,5 +50,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := libportaudio
+TARGETS := $(PORTAUDIO_LIB) $(PORTAUDIO_SONAME)
 
 all: $(TARGETS)
@@ -51,8 +57,12 @@
 distclean: realclean
 
-.PHONY: dep depend libportaudio clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONY: $(PORTAUDIO_LIB) $(PORTAUDIO_SONAME)
 
-libportaudio:
-	$(MAKE) -f $(RULES_MAK) APP=PORTAUDIO app=libportaudio $(PORTAUDIO_LIB)
+libportaudio: $(PORTAUDIO_LIB)
+$(PORTAUDIO_SONAME): $(PORTAUDIO_LIB)
+$(PORTAUDIO_LIB) $(PORTAUDIO_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=PORTAUDIO app=libportaudio $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean:
Index: pjproject/trunk/third_party/build/resample/Makefile
===================================================================
--- pjproject/trunk/third_party/build/resample/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/resample/Makefile	(revision 4656)
@@ -22,7 +22,11 @@
 export RESAMPLE_CFLAGS = $(_CFLAGS)
 
-SHLIB_NAME := libresample.$(SHLIB_SUFFIX)
-export RESAMPLE_SHLIB := ../../lib/$(SHLIB_NAME).$(PJ_VERSION_MAJOR)
-export RESAMPLE_LIB := ../../lib/libresample-$(TARGET_NAME)$(LIBEXT)
+export RESAMPLE_LIB := libresample-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export RESAMPLE_SONAME := libresample.$(SHLIB_SUFFIX)
+export RESAMPLE_SHLIB := $(RESAMPLE_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT 
@@ -32,15 +36,10 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-ifeq ($(PJ_RESAMPLE_DLL),1)
-TARGETS := ../../lib/$(SHLIB_NAME)
-ifeq ($(SHLIB_SUFFIX),so)
-SHLIB_OPT := -Wl,-soname,$(SHLIB_NAME).$(PJ_VERSION_MAJOR)
+TARGETS := $(RESAMPLE_LIB) $(RESAMPLE_SONAME)
+ifneq ($(PJ_SHARED_LIBRARIES),)
 else
-SHLIB_OPT := 
+ifneq ($(PJ_RESAMPLE_DLL),)
+export RESAMPLE_CFLAGS := -fPIC $(RESAMPLE_CFLAGS)
 endif
-export RESAMPLE_CFLAGS := -fPIC $(RESAMPLE_CFLAGS)
-export RESAMPLE_LDFLAGS := -shared $(SHLIB_OPT) $(RESAMPLE_LDFLAGS)
-else
-TARGETS := libresample
 endif
 
@@ -53,21 +52,19 @@
 distclean: realclean
 
-.PHONY: dep depend libresample clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONY: $(RESAMPLE_LIB) $(RESAMPLE_SONAME)
 
-libresample:
-	$(MAKE) -f $(RULES_MAK) APP=RESAMPLE app=libresample $(RESAMPLE_LIB)
+dep: depend
 
-../../lib/$(SHLIB_NAME): $(RESAMPLE_SHLIB)
-	ln -s $(SHLIB_NAME).$(PJ_VERSION_MAJOR) $@
+libresample: $(RESAMPLE_LIB)
+$(RESAMPLE_SONAME): $(RESAMPLE_LIB)
+$(RESAMPLE_LIB) $(RESAMPLE_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=RESAMPLE app=libresample $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
-$(RESAMPLE_SHLIB):
-	$(MAKE) -f $(RULES_MAK) APP=RESAMPLE app=libresample $(RESAMPLE_SHLIB)
-	
 clean print_lib:
 	$(MAKE) -f $(RULES_MAK) APP=RESAMPLE app=libresample $@
 
 realclean:
-	$(subst @@,$(subst /,$(HOST_PSEP),../../lib/$(SHLIB_NAME)),$(HOST_RMR))
-	$(subst @@,$(subst /,$(HOST_PSEP),$(RESAMPLE_SHLIB)),$(HOST_RMR))
 	$(MAKE) -f $(RULES_MAK) APP=RESAMPLE app=libresample $@
 
Index: pjproject/trunk/third_party/build/speex/Makefile
===================================================================
--- pjproject/trunk/third_party/build/speex/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/speex/Makefile	(revision 4656)
@@ -6,5 +6,11 @@
 RULES_MAK := $(PJDIR)/build/rules.mak
 
-export SPEEX_LIB := ../../lib/libspeex-$(TARGET_NAME)$(LIBEXT)
+export SPEEX_LIB := libspeex-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export SPEEX_SONAME := libspeex.$(SHLIB_SUFFIX)
+export SPEEX_SHLIB := $(SPEEX_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -45,5 +51,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := libspeex
+TARGETS := $(SPEEX_LIB) $(SPEEX_SONAME)
 
 all: $(TARGETS)
@@ -55,8 +61,12 @@
 distclean: realclean
 
-.PHONY: dep depend libspeex clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONY: $(SPEEX_LIB) $(SPEEX_SONAME)
 
-libspeex:
-	$(MAKE) -f $(RULES_MAK) APP=SPEEX app=libspeex $(SPEEX_LIB)
+libspeex: $(SPEEX_LIB)
+$(SPEEX_SONAME): $(SPEEX_LIB)
+$(SPEEX_LIB) $(SPEEX_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=SPEEX app=libspeex $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean print_lib:
Index: pjproject/trunk/third_party/build/srtp/Makefile
===================================================================
--- pjproject/trunk/third_party/build/srtp/Makefile	(revision 4653)
+++ pjproject/trunk/third_party/build/srtp/Makefile	(revision 4656)
@@ -6,5 +6,11 @@
 RULES_MAK := $(PJDIR)/build/rules.mak
 
-export SRTP_LIB := ../../lib/libsrtp-$(TARGET_NAME)$(LIBEXT)
+export SRTP_LIB := libsrtp-$(TARGET_NAME)$(LIBEXT)
+
+ifeq ($(PJ_SHARED_LIBRARIES),)
+else
+export SRTP_SONAME := libsrtp.$(SHLIB_SUFFIX)
+export SRTP_SHLIB := $(SRTP_SONAME).$(PJ_VERSION_MAJOR)
+endif
 
 ###############################################################################
@@ -58,5 +64,5 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := libsrtp
+TARGETS := $(SRTP_LIB) $(SRTP_SONAME)
 
 all: $(TARGETS)
@@ -68,8 +74,12 @@
 distclean: realclean
 
-.PHONY: dep depend libsrtp clean realclean distclean
+.PHONY: all dep depend clean realclean distclean
+.PHONY: $(TARGETS)
+.PHONY: $(SRTP_LIB) $(SRTP_SONAME)
 
-libsrtp:
-	$(MAKE) -f $(RULES_MAK) APP=SRTP app=libsrtp $(SRTP_LIB)
+libsrtp: $(SRTP_LIB)
+$(SRTP_SONAME): $(SRTP_LIB)
+$(SRTP_LIB) $(SRTP_SONAME):
+	$(MAKE) -f $(RULES_MAK) APP=SRTP app=libsrtp $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
 
 clean print_lib:
