Index: /pjproject/trunk/pjsip-apps/build/Makefile
===================================================================
--- /pjproject/trunk/pjsip-apps/build/Makefile	(revision 4752)
+++ /pjproject/trunk/pjsip-apps/build/Makefile	(revision 4753)
@@ -40,7 +40,7 @@
             main.o pjsua_app.o pjsua_app_cli.o pjsua_app_common.o \
             pjsua_app_config.o pjsua_app_legacy.o
-export PJSUA_CFLAGS += $(PJ_CFLAGS)
-export PJSUA_CXXFLAGS += $(PJ_CXXFLAGS)
-export PJSUA_LDFLAGS += $(PJ_LDFLAGS) $(PJ_LDLIBS)
+export PJSUA_CFLAGS += $(PJ_CFLAGS) $(CFLAGS)
+export PJSUA_CXXFLAGS += $(PJ_CXXFLAGS) $(CFLAGS)
+export PJSUA_LDFLAGS += $(PJ_LDFLAGS) $(PJ_LDLIBS) $(LDFLAGS)
 export PJSUA_EXE:=pjsua-$(TARGET_NAME)$(HOST_EXE)
 
@@ -52,7 +52,7 @@
 export PJSYSTEST_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
 			systest.o main_console.o
-export PJSYSTEST_CFLAGS += $(PJ_CFLAGS)
-export PJSYSTEST_CXXFLAGS += $(PJ_CXXFLAGS)
-export PJSYSTEST_LDFLAGS += $(PJ_LDFLAGS) $(PJ_LDLIBS)
+export PJSYSTEST_CFLAGS += $(PJ_CFLAGS) $(CFLAGS)
+export PJSYSTEST_CXXFLAGS += $(PJ_CXXFLAGS) $(CFLAGS)
+export PJSYSTEST_LDFLAGS += $(PJ_LDFLAGS) $(PJ_LDLIBS) $(LDFLAGS)
 export PJSYSTEST_EXE:=pjsystest-$(TARGET_NAME)$(HOST_EXE)
 
Index: /pjproject/trunk/pjsip-apps/build/Samples.mak
===================================================================
--- /pjproject/trunk/pjsip-apps/build/Samples.mak	(revision 4752)
+++ /pjproject/trunk/pjsip-apps/build/Samples.mak	(revision 4753)
@@ -9,5 +9,5 @@
 #
 export _CFLAGS 	:= $(PJ_CFLAGS) $(CFLAGS)
-export _CXXFLAGS:= $(PJ_CXXFLAGS)
+export _CXXFLAGS:= $(PJ_CXXFLAGS) $(CFLAGS)
 export _LDFLAGS := $(PJ_LDFLAGS) $(PJ_LDLIBS) $(LDFLAGS)
 export _LDXXFLAGS := $(PJ_LDXXFLAGS) $(PJ_LDXXLIBS) $(LDFLAGS)
Index: /pjproject/trunk/pjsip-apps/src/swig/python/helper.mak
===================================================================
--- /pjproject/trunk/pjsip-apps/src/swig/python/helper.mak	(revision 4752)
+++ /pjproject/trunk/pjsip-apps/src/swig/python/helper.mak	(revision 4753)
@@ -1,17 +1,13 @@
 include ../../../../build.mak
+include $(PJDIR)/build/common.mak
 
-lib_dir:
-	@for token in `echo $(APP_LDFLAGS)`; do \
-		echo $$token | grep \\-L | sed 's/-L//'; \
+ldflags:
+	@for token in `echo $(PJ_LDXXLIBS) $(PJ_LDXXFLAGS) $(LDFLAGS)`; do \
+		echo $$token; \
 	done
 
-inc_dir:
-	@for token in `echo $(APP_CFLAGS)`; do \
-		echo $$token | grep \\-I | sed 's/-I//'; \
-	done
-
-libs:
-	@for token in `echo $(APP_LDLIBS)`; do \
-		echo $$token | grep \\-l | sed 's/-l//'; \
+cflags:
+	@for token in `echo $(PJ_CXXFLAGS) $(CFLAGS)`; do \
+		echo $$token; \
 	done
 
Index: /pjproject/trunk/pjsip-apps/src/swig/python/setup.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/swig/python/setup.py	(revision 4752)
+++ /pjproject/trunk/pjsip-apps/src/swig/python/setup.py	(revision 4753)
@@ -67,35 +67,17 @@
 f.close()
 
-# Fill in pj_inc_dirs
-pj_inc_dirs = []
-f = os.popen("make --no-print-directory -f helper.mak inc_dir")
+# Fill in extra_compile_args
+extra_compile_args = []
+f = os.popen("make --no-print-directory -f helper.mak cflags")
 for line in f:
-    pj_inc_dirs.append(line.rstrip("\r\n"))
+    extra_compile_args.append(line.rstrip("\r\n"))
 f.close()
 
-# Fill in pj_lib_dirs
-pj_lib_dirs = []
-f = os.popen("make --no-print-directory -f helper.mak lib_dir")
+# Fill in extra_link_args
+extra_link_args = []
+f = os.popen("make --no-print-directory -f helper.mak ldflags")
 for line in f:
-    pj_lib_dirs.append(line.rstrip("\r\n"))
+    extra_link_args.append(line.rstrip("\r\n"))
 f.close()
-
-# Fill in pj_libs
-pj_libs = ['pjsua2-' + pj_target_name]
-f = os.popen("make --no-print-directory -f helper.mak libs")
-for line in f:
-    pj_libs.append(line.rstrip("\r\n"))
-f.close()
-
-# Fill in extra link args
-extra_link_args = []
-if platform.system() == 'Darwin':
-    # Mac OS X depedencies
-    extra_link_args += ["-framework", "CoreFoundation", 
-                        "-framework", "AudioToolbox",
-			"-framework", "QTKit"]
-    # OS X Lion support
-    if platform.mac_ver()[0].startswith("10.7"):
-        extra_link_args += ["-framework", "AudioUnit"]
 
 # MinGW specific action: put current working dir to PATH, so Python distutils
@@ -110,8 +92,5 @@
       ext_modules = [Extension("_pjsua2", 
                                ["pjsua2_wrap.cpp"], 
-                               define_macros=[('PJ_AUTOCONF', '1'),],
-                               include_dirs=pj_inc_dirs, 
-                               library_dirs=pj_lib_dirs, 
-                               libraries=pj_libs,
+                               extra_compile_args=extra_compile_args,
                                extra_link_args=extra_link_args
                               )
