[Freeswitch-svn] [commit] r4308 - in freeswitch/trunk/libs: sofia-sip sofia-sip/docs sofia-sip/libsofia-sip-ua sofia-sip/libsofia-sip-ua-glib sofia-sip/libsofia-sip-ua-glib/su-glib sofia-sip/libsofia-sip-ua-glib/su-glib/sofia-sip sofia-sip/libsofia-sip-ua/bnf sofia-sip/libsofia-sip-ua/docs sofia-sip/libsofia-sip-ua/features sofia-sip/libsofia-sip-ua/http sofia-sip/libsofia-sip-ua/http/sofia-sip sofia-sip/libsofia-sip-ua/ipt sofia-sip/libsofia-sip-ua/ipt/sofia-sip sofia-sip/libsofia-sip-ua/iptsec sofia-sip/libsofia-sip-ua/iptsec/sofia-sip sofia-sip/libsofia-sip-ua/msg sofia-sip/libsofia-sip-ua/msg/sofia-sip sofia-sip/libsofia-sip-ua/nea sofia-sip/libsofia-sip-ua/nta sofia-sip/libsofia-sip-ua/nta/sofia-sip sofia-sip/libsofia-sip-ua/nth sofia-sip/libsofia-sip-ua/nua sofia-sip/libsofia-sip-ua/nua/sofia-sip sofia-sip/libsofia-sip-ua/sdp sofia-sip/libsofia-sip-ua/sip sofia-sip/libsofia-sip-ua/sip/sofia-sip sofia-sip/libsofia-sip-ua/soa sofia-sip/libsofia-sip-ua/sresolv sofia-sip/libsofia-sip-ua/stun sofia-sip/libsofia-sip-ua/su sofia-sip/libsofia-sip-ua/su/sofia-sip sofia-sip/libsofia-sip-ua/tport sofia-sip/libsofia-sip-ua/tport/sofia-sip sofia-sip/libsofia-sip-ua/url sofia-sip/libsofia-sip-ua/url/sofia-sip sofia-sip/m4 sofia-sip/packages sofia-sip/rules sofia-sip/utils sofia-sip/win32 sofia-sip/win32/libsofia-sip-ua sofia-sip/win32/libsofia-sip-ua-static sofia-sip/win32/tests/test_htable sofia-sip/win32/tests/test_memmem sofia-sip/win32/tests/test_nta sofia-sip/win32/tests/test_nua sofia-sip/win32/tests/test_su sofia-sip/win32/tests/test_tport sofia-sip/win32/tests/torture_rbtree sofia-sip/win32/tests/torture_su sofia-sip/win32/tests/torture_su_alloc sofia-sip/win32/tests/torture_su_bm sofia-sip/win32/tests/torture_su_port sofia-sip/win32/tests/torture_su_root sofia-sip/win32/tests/torture_su_tag sofia-sip/win32/tests/torture_su_time sofia-sip/win32/tests/torture_su_timer sofia-sip/win32/utils/localinfo sofia-sip/win32/utils/sip_dig sofia-sip/win32/utils/sip_options sofia-sip/win32/utils/sip_options_static sofia-sip/win32/utils/stunc win32/sofia

Freeswitch SVN mikej at freeswitch.org
Sat Feb 17 01:25:22 EST 2007


Author: mikej
Date: Sat Feb 17 01:25:21 2007
New Revision: 4308

Removed:
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/torture_su_glib_timer.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/poll.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_base_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_epoll_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_poll_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_pthread_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_select_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_socket_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_win32_port.c
   freeswitch/trunk/libs/sofia-sip/packages/sofia-sip-1.12.5.spec
   freeswitch/trunk/libs/sofia-sip/rules/
   freeswitch/trunk/libs/sofia-sip/win32/SofiaSIP.sln
   freeswitch/trunk/libs/sofia-sip/win32/libsofia-sip-ua-static/libsofia_sip_ua_static.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/libsofia-sip-ua/libsofia_sip_ua.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/test_htable/test_htable.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/test_memmem/test_memmem.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/test_nta/test_nta.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/test_nua/test_nua.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/test_su/test_su.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/test_tport/test_tport.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_rbtree/torture_rbtree.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su/torture_su.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su_alloc/torture_su_alloc.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su_bm/torture_su_bm.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su_port/torture_su_port.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su_root/torture_su_root.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su_tag/torture_su_tag.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su_time/torture_su_time.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/tests/torture_su_timer/torture_su_timer.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/utils/localinfo/localinfo.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/utils/sip_dig/sip_dig.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/utils/sip_options/sip_options.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/utils/sip_options_static/sip_options_static.vcproj
   freeswitch/trunk/libs/sofia-sip/win32/utils/stunc/stunc.vcproj
Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/AUTHORS
   freeswitch/trunk/libs/sofia-sip/COPYRIGHTS
   freeswitch/trunk/libs/sofia-sip/Makefile.am
   freeswitch/trunk/libs/sofia-sip/Makefile.in
   freeswitch/trunk/libs/sofia-sip/README
   freeswitch/trunk/libs/sofia-sip/RELEASE
   freeswitch/trunk/libs/sofia-sip/RELEASE.template
   freeswitch/trunk/libs/sofia-sip/aclocal.m4
   freeswitch/trunk/libs/sofia-sip/config.h.in
   freeswitch/trunk/libs/sofia-sip/configure
   freeswitch/trunk/libs/sofia-sip/configure.ac
   freeswitch/trunk/libs/sofia-sip/docs/build_system.txt
   freeswitch/trunk/libs/sofia-sip/docs/devel_platform_notes.txt
   freeswitch/trunk/libs/sofia-sip/docs/release_management.txt
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/sofia-sip/su_glib.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ChangeLog
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Doxyfile.aliases
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/sofia-sip/http_header.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/test_http.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/sofia-sip/base64.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_delayed.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/sofia-sip/auth_plugin.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.awk
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_parser.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/nea_server.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/http-server.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_server.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.docs
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_basic_call.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_hold.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_extension.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_proxy.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_refer.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_sip_events.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/   (props changed)
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_basic.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra_headers.txt
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_parser.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_header.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_date.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_sip_msg.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/validator.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sresolv.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/test_sresolv.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/   (props changed)
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/addrinfo.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/run_test_su
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_bm.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_configure.h.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_tag.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc_lock.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_os_nw.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_osx_runloop.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_root.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_wait.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/tag_dll.awk
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/test_su.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_alloc.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_bm.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_port.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_root.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_timer.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_stub_stun.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_sctp.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.am
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.in
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/url.c
   freeswitch/trunk/libs/sofia-sip/ltmain.sh
   freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4
   freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4
   freeswitch/trunk/libs/sofia-sip/packages/Makefile.in
   freeswitch/trunk/libs/sofia-sip/packages/sofia-sip.spec.in
   freeswitch/trunk/libs/sofia-sip/utils/Makefile.in
   freeswitch/trunk/libs/sofia-sip/utils/sip-options.c
   freeswitch/trunk/libs/sofia-sip/win32/Makefile.am
   freeswitch/trunk/libs/sofia-sip/win32/Makefile.in
   freeswitch/trunk/libs/sofia-sip/win32/build_sources.cmd
   freeswitch/trunk/libs/sofia-sip/win32/check.cmd
   freeswitch/trunk/libs/sofia-sip/win32/config.h.in
   freeswitch/trunk/libs/sofia-sip/win32/version_files.cmd
   freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj

Log:
Temporarily reverting sofia-sip library back to prior to the changes merged on 2/7/2007 due to ongoing unresolved issues in the new code.  Will re-commit these changes once we receive fixes from the sofia-sip tree for these outstanding issues.  Make sure recommended.

Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Sat Feb 17 01:25:21 2007
@@ -1 +1 @@
-Thu Feb 15 00:08:41 EST 2007
+Sat Feb 17 01:18:56 EST 2007

Modified: freeswitch/trunk/libs/sofia-sip/AUTHORS
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/AUTHORS	(original)
+++ freeswitch/trunk/libs/sofia-sip/AUTHORS	Sat Feb 17 01:25:21 2007
@@ -10,8 +10,6 @@
 
 Chan, Tat <first.surname at nokia.com>
 Ciarkowski, Andrzej <wp-voigtkampff -at users -dot sourceforge -dot net>
-Denis-Courmont, Remi <first.surname at nokia.com>
-Filonenko Roman <shkoder -at ua -dot fm>
 Haataja, Mikko <first.surname at nokia.com>
 Jacobs, Remeres <first.surname at nokia.com>
 Jalava, Teemu <first.surname at nokia.com>
@@ -28,7 +26,9 @@
 Whittaker, Colin <colinw -at occamnetworks -dot com>
 Zabaluev, Mikhail <first.surname at nokia.com>
 
+
 Note: for details on who did what, see the version control 
       system change history, and release notes for past releases at
       http://sofia-sip.sourceforge.net/relnotes/
- 
\ No newline at end of file
+
+      
\ No newline at end of file

Modified: freeswitch/trunk/libs/sofia-sip/COPYRIGHTS
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/COPYRIGHTS	(original)
+++ freeswitch/trunk/libs/sofia-sip/COPYRIGHTS	Sat Feb 17 01:25:21 2007
@@ -221,31 +221,3 @@
 been advised of the possibility of such damages.
 
 ----------------------------------------------------------------------------
-
-libsofia-sip-ua/su/poll.c
-
-The package also contains files from GNU C Library by Free Software
-Foundation.
-
-These files are distributed with the following copyright notice:
-
-Copyright (C) 1994,1996,1997,1998,1999,2001,2002
-Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with the GNU C Library; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-----------------------------------------------------------------------------

Modified: freeswitch/trunk/libs/sofia-sip/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -27,10 +27,6 @@
 EXTRA_DIST += 	m4/sac-general.m4 m4/sac-su.m4 \
 		m4/sac-su2.m4 m4/sac-tport.m4 m4/sac-openssl.m4
 
-EXTRA_DIST +=   docs/build_system.txt \
-		docs/devel_platform_notes.txt \
-		docs/release_management.txt
-
 dist_man_MANS = man/man1/sip-date.1 man/man1/sip-options.1 \
 		man/man1/localinfo.1 man/man1/addrinfo.1 \
 		man/man1/stunc.1 man/man1/sip-dig.1
@@ -48,7 +44,7 @@
 
 CLEANFILES = $(dist_man_MANS)
 
-coverage built-sources clean-built-sources valcheck doxygen:
+coverage built-sources clean-built-sources doxygen:
 	for i in libsofia-sip-ua $(GLIB_SUBDIRS) ; do $(MAKE) $(AM_MAKEFLAGS) -C $$i $@ ; done
 
 .PHONY: coverage built-sources clean-built-sources doxygen manpages

Modified: freeswitch/trunk/libs/sofia-sip/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -91,7 +91,6 @@
 distcleancheck_listfiles = find . -type f -print
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = -I m4
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -138,12 +137,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -187,7 +182,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -251,9 +245,7 @@
 @HAVE_GLIB_TRUE at GLIB_SUBDIRS = libsofia-sip-ua-glib
 EXTRA_DIST = AUTHORS COPYING COPYRIGHTS ChangeLog.ext-trees README \
 	README.developers RELEASE TODO m4/sac-general.m4 m4/sac-su.m4 \
-	m4/sac-su2.m4 m4/sac-tport.m4 m4/sac-openssl.m4 \
-	docs/build_system.txt docs/devel_platform_notes.txt \
-	docs/release_management.txt
+	m4/sac-su2.m4 m4/sac-tport.m4 m4/sac-openssl.m4
 dist_man_MANS = man/man1/sip-date.1 man/man1/sip-options.1 \
 		man/man1/localinfo.1 man/man1/addrinfo.1 \
 		man/man1/stunc.1 man/man1/sip-dig.1
@@ -504,7 +496,7 @@
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
 	mkdir $(distdir)
-	$(mkdir_p) $(distdir)/docs $(distdir)/libsofia-sip-ua/docs $(distdir)/libsofia-sip-ua/features/sofia-sip $(distdir)/libsofia-sip-ua/su/sofia-sip $(distdir)/m4 $(distdir)/man/man1 $(distdir)/packages $(distdir)/utils $(distdir)/win32
+	$(mkdir_p) $(distdir)/libsofia-sip-ua/docs $(distdir)/libsofia-sip-ua/features/sofia-sip $(distdir)/libsofia-sip-ua/su/sofia-sip $(distdir)/m4 $(distdir)/man/man1 $(distdir)/packages $(distdir)/utils $(distdir)/win32
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -757,7 +749,7 @@
 @HAVE_DOXYGEN_TRUE@	@rm -f man/man1/_*.1
 @HAVE_DOXYGEN_FALSE@	-touch $(dist_man_MANS)
 
-coverage built-sources clean-built-sources valcheck doxygen:
+coverage built-sources clean-built-sources doxygen:
 	for i in libsofia-sip-ua $(GLIB_SUBDIRS) ; do $(MAKE) $(AM_MAKEFLAGS) -C $$i $@ ; done
 
 .PHONY: coverage built-sources clean-built-sources doxygen manpages

Modified: freeswitch/trunk/libs/sofia-sip/README
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/README	(original)
+++ freeswitch/trunk/libs/sofia-sip/README	Sat Feb 17 01:25:21 2007
@@ -46,6 +46,7 @@
 - localinfo (libsofia-sip-ua/su), prints information about
   local network interfaces 
 
+
 References
 ----------
 

Modified: freeswitch/trunk/libs/sofia-sip/RELEASE
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/RELEASE	(original)
+++ freeswitch/trunk/libs/sofia-sip/RELEASE	Sat Feb 17 01:25:21 2007
@@ -6,8 +6,7 @@
 --------------------------
 
 <changes since last written in freshmeat.net "Changes:" style;
- and in less than 10 lines, written in 3rd person English, with
- complete sentences />
+ and in less than 10 lines />
 
 Bugs in blaa and foo have been fixed. The stack now supports
 use of foobar...
@@ -25,36 +24,54 @@
 
 libsofia-sip-ua:
 - **template**: Added foobar() function (sofia-sip/foobar.h).
+- Added sip_is_allowed() function and k_bitmap field to the 
+  sip_allow_t structure 
+- Added SIP header Refer-Sub and related functions
+- Added <sofia-sip/sip_extra.h> include file
+- Added auc_info() function (sofia-sip/auth_client.h)
 - This release is ABI/API compatible with applications linked against 
   any 1.12.x release. However, applications built against this release won't 
   work against an older library. The ABI has been tested with the nua module 
   unit test (test_nua) built against original 1.12.0 release.
 
 libsofia-sip-ua-glib:
-- No ABI/API changes, compatible with 1.12.0. Note, libsofia-sip-ua-glib
-  interface is not considered stable and may change in a future 1.12.x
-  release.
+- The 'nua-glib' module has been removed from the library and moved
+  to a separate package 'sofia-nua-glib'. The remaining library (su-glib) 
+  is now considered stable and will be API/ABI compatible with later 
+  releases in the 1.12.x series.
+- ABI has been modified and applications built against 1.12.4 and earlier 
+  releases need to be rebuilt.
 
 Contributors to this release
 ----------------------------
 
 <list of people who contributed to _this_ release
  - update as people's patches are added, or when you commit stuff
- - current development team members (see AUTHORS) may be omitted,
-   or listed at the end of the contribur list (depending on the scope 
-   of the work done since the last release)
+ - current development team members (see AUTHORS) may be omitted
  - name of the contributor should be enough (email addresses in AUTHORS),
-   plus a _brief_ description of what was contributed
+   plus a brief description of what was contributed
  - roughly sorted by number of patches accepted
 /> 
 
 - **template**: First Surname (patch to nua/soa/msg)
+- Petteri Puolakka (patch to stun)
+- Mikhail Zabluev (patch to su-glib mainloop integration)
 
 See the AUTHORS file in the distribution package.
 
 Notes on new features
 ---------------------
 
+RFC 4488 defines the Refer-Sub header. Its datatypes, related functions and
+methods declared in <sofia-sip/sip_extra.h> include file. The Refer-Sub
+header structure can be accessed from sip_t structure with sip_refer_sub()
+method, e.g.,
+
+  if (sip_refer_sub(sip) && 
+      strcasecmp("false", sip_refer_sub(sip)->rs_value) == 0) {
+     /* Do not create implicit subscription */ 
+  }
+
 <information about major new features
  - new/changed/removed functionality
  - links to further documentation
@@ -71,3 +88,15 @@
 />
 
 - **template**: #9499652 sf.net bug item title
+
+- Fixed crash when nua_bye() was called while a NOTIFY client transaction
+  was in progress. Problem reported by Anthony Minnessale.
+- Not using close() with sockets in sres.c. Problem reported by
+  Roman Filonenko.
+- Bug in zero-padding STUN messages with a message integrity 
+  attribute. Patch by Petteri Puolakka.
+- Fixed a severe problem with timer accuracy, when sofia-sip timers 
+  where used under glib's mainloop.
+- Improved glib mainloop integration to avoid warnings about already
+  active mainloop context, and potentially other issue. Patch by 
+  Mikhail Zabaluev. Closes sf.net item #1606786.

Modified: freeswitch/trunk/libs/sofia-sip/RELEASE.template
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/RELEASE.template	(original)
+++ freeswitch/trunk/libs/sofia-sip/RELEASE.template	Sat Feb 17 01:25:21 2007
@@ -6,8 +6,7 @@
 --------------------------
 
 <changes since last written in freshmeat.net "Changes:" style;
- and in less than 10 lines, written in 3rd person English, with
- complete sentences />
+ and in less than 10 lines />
 
 Bugs in blaa and foo have been fixed. The stack now supports
 use of foobar...
@@ -40,11 +39,9 @@
 
 <list of people who contributed to _this_ release
  - update as people's patches are added, or when you commit stuff
- - current development team members (see AUTHORS) may be omitted,
-   or listed at the end of the contribur list (depending on the scope 
-   of the work done since the last release)
+ - current development team members (see AUTHORS) may be omitted
  - name of the contributor should be enough (email addresses in AUTHORS),
-   plus a _brief_ description of what was contributed
+   plus a brief description of what was contributed
  - roughly sorted by number of patches accepted
 /> 
 

Modified: freeswitch/trunk/libs/sofia-sip/aclocal.m4
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/aclocal.m4	(original)
+++ freeswitch/trunk/libs/sofia-sip/aclocal.m4	Sat Feb 17 01:25:21 2007
@@ -13,7 +13,7 @@
 
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 
-# serial 48 AC_PROG_LIBTOOL
+# serial 47 AC_PROG_LIBTOOL
 
 
 # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
@@ -123,7 +123,7 @@
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed='sed -e s/^X//'
 [sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
 
 # Same as above, but do not quote variable references.
@@ -143,7 +143,7 @@
 default_ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a `.a' archive for static linking (except M$VC,
 # which needs '.lib').
 libext=a
 ltmain="$ac_aux_dir/ltmain.sh"
@@ -163,7 +163,6 @@
 test -z "$AS" && AS=as
 test -z "$CC" && CC=cc
 test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$DLLTOOL" && DLLTOOL=dlltool
 test -z "$LD" && LD=ld
 test -z "$LN_S" && LN_S="ln -s"
@@ -183,17 +182,15 @@
 if test -n "$RANLIB"; then
   case $host_os in
   openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
     ;;
   *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
     ;;
   esac
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
 fi
 
-_LT_CC_BASENAME([$compiler])
-
 # Only perform the check for file, if the check method requires it
 case $deplibs_check_method in
 file_magic*)
@@ -234,56 +231,11 @@
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
 # Allow CC to be a program name with arguments.
 compiler=$CC
 ])# _LT_AC_SYS_COMPILER
 
 
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
-AC_DEFUN([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-])
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_LINKER_BOILERPLATE
-
-
 # _LT_AC_SYS_LIBPATH_AIX
 # ----------------------
 # Links a minimal program and checks the executable
@@ -356,15 +308,15 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 if test -z "$ECHO"; then
 if test "X${echo_test_string+set}" != Xset; then
 # find a string as large as possible, as long as the shell can cope with it
   for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
     # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
-       echo_test_string=`eval $cmd` &&
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
        (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
     then
       break
@@ -533,7 +485,7 @@
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
+    case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       case $host in
         x86_64-*linux*)
@@ -584,22 +536,6 @@
     CFLAGS="$SAVE_CFLAGS"
   fi
   ;;
-sparc*-*solaris*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if AC_TRY_EVAL(ac_compile); then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*) LD="${LD-ld} -m elf64_sparc" ;;
-      *)    LD="${LD-ld} -64" ;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
 AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
 [*-*-cygwin* | *-*-mingw* | *-*-pw32*)
   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
@@ -631,7 +567,7 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
@@ -641,10 +577,8 @@
    echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        $2=yes
      fi
    fi
@@ -670,16 +604,11 @@
    LDFLAGS="$LDFLAGS $3"
    printf "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
+     # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&AS_MESSAGE_LOG_FD
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         $2=yes
-       fi
      else
        $2=yes
      fi
@@ -738,55 +667,11 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
-
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ 	]]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
+ *)
     # If test is not a shell built-in, we'll probably end up computing a
     # maximum length that is only half of the actual maximum length, but
     # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+    while (test "X"`$CONFIG_SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
 	       = "XX$teststring") >/dev/null 2>&1 &&
 	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
 	    lt_cv_sys_max_cmd_len=$new_result &&
@@ -812,7 +697,7 @@
 
 
 # _LT_AC_CHECK_DLFCN
-# ------------------
+# --------------------
 AC_DEFUN([_LT_AC_CHECK_DLFCN],
 [AC_CHECK_HEADERS(dlfcn.h)dnl
 ])# _LT_AC_CHECK_DLFCN
@@ -820,7 +705,7 @@
 
 # _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
 #                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ---------------------------------------------------------------------
+# ------------------------------------------------------------------
 AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
 [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
 if test "$cross_compiling" = yes; then :
@@ -886,19 +771,17 @@
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
-  else
-    puts (dlerror ());
 
     exit (status);
 }]
 EOF
   if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) $1 ;;
       x$lt_dlneed_uscore) $2 ;;
-      x$lt_dlunknown|x*) $3 ;;
+      x$lt_unknown|x*) $3 ;;
     esac
   else :
     # compilation failed
@@ -910,7 +793,7 @@
 
 
 # AC_LIBTOOL_DLOPEN_SELF
-# ----------------------
+# -------------------
 AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
 [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
 if test "x$enable_dlopen" != xyes; then
@@ -981,7 +864,7 @@
     test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
     save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
     save_LIBS="$LIBS"
     LIBS="$lt_cv_dlopen_libs $LIBS"
@@ -994,7 +877,7 @@
     ])
 
     if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      LDFLAGS="$LDFLAGS $link_static_flag"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
     	  lt_cv_dlopen_self_static, [dnl
 	  _LT_AC_TRY_DLOPEN_SELF(
@@ -1042,7 +925,7 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
    (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
@@ -1054,13 +937,11 @@
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
      fi
    fi
-   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -1124,8 +1005,8 @@
 [AC_MSG_CHECKING([how to hardcode library paths into programs])
 _LT_AC_TAGVAR(hardcode_action, $1)=
 if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
-   test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
-   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+   test -n "$_LT_AC_TAGVAR(runpath_var $1)" || \
+   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
@@ -1292,7 +1173,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[[45]]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -1320,8 +1201,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -1351,7 +1231,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -1374,7 +1254,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -1409,17 +1289,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[[123]]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -1437,19 +1308,14 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+  freebsd3.[01]* | freebsdelf3.[01]*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
-  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
-  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+  *) # from 3.2 on
     shlibpath_overrides_runpath=no
     hardcode_into_libs=yes
     ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
   esac
   ;;
 
@@ -1469,7 +1335,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -1509,18 +1375,6 @@
   postinstall_cmds='chmod 555 $lib'
   ;;
 
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
 irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
@@ -1578,10 +1432,27 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+    if AC_TRY_EVAL(ac_compile); then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -1642,13 +1513,8 @@
 
 openbsd*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -1686,6 +1552,13 @@
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
 solaris*)
   version_type=linux
   need_lib_prefix=no
@@ -1711,7 +1584,7 @@
   need_version=yes
   ;;
 
-sysv4 | sysv4.3*)
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -1744,29 +1617,6 @@
   fi
   ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
 uts4*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -1780,11 +1630,6 @@
 esac
 AC_MSG_RESULT([$dynamic_linker])
 test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
 ])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
 
 
@@ -1809,9 +1654,6 @@
       AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
     fi
   fi
-  if test -z "$LTCFLAGS"; then
-    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
-  fi
 
   # Extract list of available tagged configurations in $ofile.
   # Note that this assumes the entire list is on one line.
@@ -1838,9 +1680,7 @@
 
       case $tagname in
       CXX)
-	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-	    (test "X$CXX" != "Xg++"))) ; then
+	if test -n "$CXX" && test "X$CXX" != "Xno"; then
 	  AC_LIBTOOL_LANG_CXX_CONFIG
 	else
 	  tagname=""
@@ -1902,7 +1742,7 @@
 
 # AC_LIBTOOL_WIN32_DLL
 # --------------------
-# declare package support for building win32 DLLs
+# declare package support for building win32 dll's
 AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
 [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
 ])# AC_LIBTOOL_WIN32_DLL
@@ -1940,7 +1780,7 @@
 
 # AC_DISABLE_SHARED
 # -----------------
-# set the default shared flag to --disable-shared
+#- set the default shared flag to --disable-shared
 AC_DEFUN([AC_DISABLE_SHARED],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
 AC_ENABLE_SHARED(no)
@@ -2076,7 +1916,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -2186,7 +2026,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -2218,7 +2058,7 @@
 AC_DEFUN([AC_PROG_LD_GNU],
 [AC_REQUIRE([AC_PROG_EGREP])dnl
 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -2245,15 +2085,6 @@
 *) reload_flag=" $reload_flag" ;;
 esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
 ])# AC_PROG_LD_RELOAD_FLAG
 
 
@@ -2287,7 +2118,7 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-bsdi[[45]]*)
+bsdi4*)
   lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
   lt_cv_file_magic_cmd='/usr/bin/file -L'
   lt_cv_file_magic_test_file=/shlib/libc.so
@@ -2310,13 +2141,13 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | kfreebsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
       # Not sure whether the presence of OpenBSD here was a mistake.
       # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library'
       lt_cv_file_magic_cmd=/usr/bin/file
       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
@@ -2332,7 +2163,7 @@
 
 hpux10.20* | hpux11*)
   lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
     lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
@@ -2348,11 +2179,6 @@
   esac
   ;;
 
-interix3*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
-  ;;
-
 irix5* | irix6* | nonstopux*)
   case $LD in
   *-32|*"-32 ") libmagic=32-bit;;
@@ -2365,6 +2191,15 @@
 
 # This must be Linux ELF.
 linux*)
+  case $host_cpu in
+  alpha*|hppa*|i*86|ia64*|m68*|mips*|powerpc*|sparc*|s390*|sh*|x86_64*)
+    lt_cv_deplibs_check_method=pass_all ;;
+  *)
+    # glibc up to 2.1.1 does not perform some relocations on ARM
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -2387,10 +2222,12 @@
   ;;
 
 openbsd*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
   if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object'
   else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
   fi
   ;;
 
@@ -2398,11 +2235,15 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
 solaris*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sysv4 | sysv4.3*)
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   case $host_vendor in
   motorola)
     lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
@@ -2423,13 +2264,10 @@
   siemens)
     lt_cv_deplibs_check_method=pass_all
     ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
   esac
   ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 esac
@@ -2449,43 +2287,36 @@
   # Let the user override the test.
   lt_cv_path_NM="$NM"
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then 
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+      */dev/null* | *'Invalid file or object type'*)
+	lt_cv_path_NM="$tmp_nm -B"
+	break
+        ;;
+      *)
+	case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	*/dev/null*)
+	  lt_cv_path_NM="$tmp_nm -p"
 	  break
 	  ;;
 	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
+	  lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	  continue # so that we can try to find one that supports BSD flags
 	  ;;
 	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
+      esac
+    fi
   done
+  IFS="$lt_save_ifs"
   test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
 fi])
 NM="$lt_cv_path_NM"
@@ -2517,13 +2348,13 @@
 # -----------------------------------
 # sets LIBLTDL to the link flags for the libltdl convenience library and
 # LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-convenience to the configure arguments.  Note that
-# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
-# it is assumed to be `libltdl'.  LIBLTDL will be prefixed with
-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
-# (note the single quotes!).  If your package is not flat and you're not
-# using automake, define top_builddir and top_srcdir appropriately in
-# the Makefiles.
+# --enable-ltdl-convenience to the configure arguments.  Note that LIBLTDL
+# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If
+# DIRECTORY is not provided, it is assumed to be `libltdl'.  LIBLTDL will
+# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
 AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
   case $enable_ltdl_convenience in
@@ -2542,13 +2373,13 @@
 # -----------------------------------
 # sets LIBLTDL to the link flags for the libltdl installable library and
 # LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-install to the configure arguments.  Note that
-# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
-# and an installed libltdl is not found, it is assumed to be `libltdl'.
-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
-# '${top_srcdir}/' (note the single quotes!).  If your package is not
-# flat and you're not using automake, define top_builddir and top_srcdir
-# appropriately in the Makefiles.
+# --enable-ltdl-install to the configure arguments.  Note that LIBLTDL
+# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If
+# DIRECTORY is not provided and an installed libltdl is not found, it is
+# assumed to be `libltdl'.  LIBLTDL will be prefixed with '${top_builddir}/'
+# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single
+# quotes!).  If your package is not flat and you're not using automake,
+# define top_builddir and top_srcdir appropriately in the Makefiles.
 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
 AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
@@ -2586,21 +2417,10 @@
 # ---------------
 AC_DEFUN([_LT_AC_LANG_CXX],
 [AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+AC_REQUIRE([AC_PROG_CXXCPP])
 _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
 ])# _LT_AC_LANG_CXX
 
-# _LT_AC_PROG_CXXCPP
-# ------------------
-AC_DEFUN([_LT_AC_PROG_CXXCPP],
-[
-AC_REQUIRE([AC_PROG_CXX])
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  AC_PROG_CXXCPP
-fi
-])# _LT_AC_PROG_CXXCPP
 
 # AC_LIBTOOL_F77
 # --------------
@@ -2640,7 +2460,7 @@
 
 
 # AC_LIBTOOL_RC
-# -------------
+# --------------
 # enable support for Windows resource files
 AC_DEFUN([AC_LIBTOOL_RC],
 [AC_REQUIRE([LT_AC_PROG_RC])
@@ -2673,9 +2493,36 @@
 
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
+#
+# Check for any special shared library compilation flags.
+#
+_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)=
+if test "$GCC" = no; then
+  case $host_os in
+  sco3.2v5*)
+    _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf'
+    ;;
+  esac
+fi
+if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then
+  AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries])
+  if echo "$old_CC $old_CFLAGS " | grep "[[ 	]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ 	]]" >/dev/null; then :
+  else
+    AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure])
+    _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no
+  fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works],
+  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+  $_LT_AC_TAGVAR(lt_prog_compiler_static, $1),
+  [],
+  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+
 
 AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
 AC_LIBTOOL_PROG_COMPILER_PIC($1)
@@ -2685,9 +2532,9 @@
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
 AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF
+AC_LIBTOOL_DLOPEN_SELF($1)
 
-# Report which library types will actually be built
+# Report which librarie types wil actually be built
 AC_MSG_CHECKING([if libtool supports shared libraries])
 AC_MSG_RESULT([$can_build_shared])
 
@@ -2696,7 +2543,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case $host_os in
+case "$host_os" in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -2709,6 +2556,43 @@
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
+  ;;
+  darwin* | rhapsody*)
+  if test "$GCC" = yes; then
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    case "$host_os" in
+    rhapsody* | darwin1.[[012]])
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[[012]])
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+      ;;
+    esac
+    output_verbose_link_cmd='echo'
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring'
+    _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag  -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+  else
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+  fi
     ;;
 esac
 AC_MSG_RESULT([$enable_shared])
@@ -2734,7 +2618,7 @@
 AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
 [AC_LANG_PUSH(C++)
 AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+AC_REQUIRE([AC_PROG_CXXCPP])
 
 _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
 _LT_AC_TAGVAR(allow_undefined_flag, $1)=
@@ -2746,7 +2630,6 @@
 _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
 _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
 _LT_AC_TAGVAR(hardcode_automatic, $1)=no
 _LT_AC_TAGVAR(module_cmds, $1)=
 _LT_AC_TAGVAR(module_expsym_cmds, $1)=
@@ -2764,7 +2647,7 @@
 _LT_AC_TAGVAR(compiler_lib_search_path, $1)=
 
 # Source file extension for C++ test sources.
-ac_ext=cpp
+ac_ext=cc
 
 # Object file extension for compiled C++ test sources.
 objext=o
@@ -2774,15 +2657,11 @@
 lt_simple_compile_test_code="int some_variable = 0;\n"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
+lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_LD=$LD
@@ -2793,18 +2672,18 @@
 if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
   lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
 else
-  $as_unset lt_cv_prog_gnu_ld
+  unset lt_cv_prog_gnu_ld
 fi
 if test -n "${lt_cv_path_LDCXX+set}"; then
   lt_cv_path_LD=$lt_cv_path_LDCXX
 else
-  $as_unset lt_cv_path_LD
+  unset lt_cv_path_LD
 fi
 test -z "${LDCXX+set}" || LD=$LDCXX
 CC=${CXX-"c++"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 # We don't want -fno-exception wen compiling C++ code, so set the
 # no_builtin_flag separately
@@ -2893,7 +2772,6 @@
 	    ;;
 	  esac
 	done
-	;;
       esac
 
       exp_sym_flag='-bexport'
@@ -2912,7 +2790,7 @@
     _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
     if test "$GXX" = yes; then
-      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+      case $host_os in aix4.[012]|aix4.[012].*)
       # We only want to do this on AIX 4.2 and lower, the check
       # below for broken collect2 doesn't work under 4.3+
 	collect2name=`${CC} -print-prog-name=collect2`
@@ -2931,12 +2809,8 @@
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 	fi
-	;;
       esac
       shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-	shared_flag="$shared_flag "'${wl}-G'
-      fi
     else
       # not using gcc
       if test "$host_cpu" = ia64; then
@@ -2963,12 +2837,12 @@
       _LT_AC_SYS_LIBPATH_AIX
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
 
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
      else
       if test "$host_cpu" = ia64; then
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
       else
 	# Determine the default libpath from the value encoded in an empty executable.
 	_LT_AC_SYS_LIBPATH_AIX
@@ -2977,26 +2851,16 @@
 	# -berok will link without error, but may produce a broken library.
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	# -bexpall does not export symbols beginning with underscore (_)
+	_LT_AC_TAGVAR(always_export_symbols, $1)=yes
 	# Exported symbols can be pulled into shared objects from archives
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-	# This is similar to how AIX traditionally builds its shared libraries.
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	# This is similar to how AIX traditionally builds it's shared libraries.
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
     ;;
-
-  beos*)
-    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-      # support --undefined.  This deserves some investigation.  FIXME
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-    else
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    fi
-    ;;
-
   chorus*)
     case $cc_basename in
       *)
@@ -3015,7 +2879,7 @@
     _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
     if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
       # If the export-symbols file already is a .def file (1st line
       # is EXPORTS), use it as is; otherwise, prepend...
       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -3024,81 +2888,70 @@
 	echo EXPORTS > $output_objdir/$soname.def;
 	cat $export_symbols >> $output_objdir/$soname.def;
       fi~
-      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
     else
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
   ;;
-      darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
-      output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
-      fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+  darwin* | rhapsody*)
+  if test "$GXX" = yes; then
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    case "$host_os" in
+    rhapsody* | darwin1.[[012]])
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
       else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-          ;;
-      esac
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[[012]])
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+            ;;
+        esac
       fi
-        ;;
+      ;;
+    esac
+    lt_int_apple_cc_single_mod=no
+    output_verbose_link_cmd='echo'
+    if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+      lt_int_apple_cc_single_mod=yes
+    fi
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    else
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    fi
+    _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+  else
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+  fi
+    ;;
 
   dgux*)
     case $cc_basename in
-      ec++*)
+      ec++)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      ghcx*)
+      ghcx)
 	# Green Hills C++ Compiler
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3109,14 +2962,14 @@
 	;;
     esac
     ;;
-  freebsd[[12]]*)
+  freebsd[12]*)
     # C++ shared libraries reported to be fairly broken before switch to ELF
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
   freebsd-elf*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | kfreebsd*-gnu)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     _LT_AC_TAGVAR(ld_shlibs, $1)=yes
@@ -3133,11 +2986,11 @@
 				# location of the library.
 
     case $cc_basename in
-    CC*)
+    CC)
       # FIXME: insert proper C++ library support
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
       ;;
-    aCC*)
+    aCC)
       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
@@ -3147,7 +3000,7 @@
       # explicitly linking system object files so we need to strip them
       # from the output so that they don't get included in the library
       # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
       ;;
     *)
       if test "$GXX" = yes; then
@@ -3161,22 +3014,33 @@
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-      case $host_cpu in
-      hppa*64*|ia64*)
+      case "$host_cpu" in
+      hppa*64*)
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+        ;;
+      ia64*)
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         ;;
       *)
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         ;;
       esac
     fi
-    case $host_cpu in
-    hppa*64*|ia64*)
+    case "$host_cpu" in
+    hppa*64*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+    ia64*)
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+					      # but as the default
+					      # location of the library.
       ;;
     *)
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
@@ -3187,17 +3051,14 @@
     esac
 
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      aCC*)
-	case $host_cpu in
-	hppa*64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	  ;;
-	ia64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+      aCC)
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	  ;;
 	*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -3216,12 +3077,9 @@
       *)
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
-	    case $host_cpu in
-	    hppa*64*)
-	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      ;;
-	    ia64*)
-	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    case "$host_cpu" in
+	    ia64*|hppa*64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	      ;;
 	    *)
 	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -3235,25 +3093,11 @@
 	;;
     esac
     ;;
-  interix3*)
-    _LT_AC_TAGVAR(hardcode_direct, $1)=no
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-    # Instead, shared libraries are loaded at an image base (0x10000000 by
-    # default) and relocated if they conflict, which is a slow very memory
-    # consuming and fragmenting process.  To avoid this, we pick a random,
-    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    ;;
   irix5* | irix6*)
     case $cc_basename in
-      CC*)
+      CC)
 	# SGI C++
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	# Archives containing C++ object files must be created using
 	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -3264,7 +3108,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test "$with_gnu_ld" = no; then
-	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 	  else
 	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
 	  fi
@@ -3277,7 +3121,7 @@
     ;;
   linux*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3302,41 +3146,17 @@
 	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
 	;;
-      icpc*)
+      icpc)
 	# Intel C++
 	with_gnu_ld=yes
-	# version 8.0 and above of icpc choke on multiply defined symbols
-	# if we add $predep_objects and $postdep_objects, however 7.1 and
-	# earlier do not add the objects themselves.
-	case `$CC -V 2>&1` in
-	*"Version 7."*)
-  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-  	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	*)  # Version 8.0 or newer
-	  tmp_idyn=
-	  case $host_cpu in
-	    ia64*) tmp_idyn=' -i_dynamic';;
-	  esac
-  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	esac
 	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
-        # Portland Group C++ compiler
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-  	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
+      cxx)
 	# Compaq C++
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
@@ -3367,7 +3187,7 @@
     ;;
   mvs*)
     case $cc_basename in
-      cxx*)
+      cxx)
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
@@ -3388,25 +3208,9 @@
     # Workaround some broken pre-1.5 toolchains
     output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
     ;;
-  openbsd2*)
-    # C++ shared libraries are fairly broken
-    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    ;;
-  openbsd*)
-    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    fi
-    output_verbose_link_cmd='echo'
-    ;;
   osf3*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3422,14 +3226,14 @@
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
 
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      cxx*)
+      cxx)
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3447,7 +3251,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3466,7 +3270,7 @@
     ;;
   osf4* | osf5*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -3481,17 +3285,17 @@
 	# the KAI C++ compiler.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      cxx*)
+      cxx)
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
 	  echo "-hidden">> $lib.exp~
-	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry $objdir/so_locations -o $lib~
 	  $rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -3510,7 +3314,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
@@ -3531,14 +3335,27 @@
     # FIXME: insert proper C++ library support
     _LT_AC_TAGVAR(ld_shlibs, $1)=no
     ;;
+  sco*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    case $cc_basename in
+      CC)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
   sunos4*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.x
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	;;
-      lcc*)
+      lcc)
 	# Lucid
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3551,33 +3368,36 @@
     ;;
   solaris*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.2, 5.x and Centerline C++
-        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
 	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	case $host_os in
-	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  solaris2.[0-5] | solaris2.[0-5].*) ;;
 	  *)
 	    # The C++ compiler is used as linker so we must use $wl
 	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # linker.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
 	    ;;
 	esac
 	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
-	output_verbose_link_cmd='echo'
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
 
 	# Archives containing C++ object files must be created using
 	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
@@ -3585,7 +3405,7 @@
 	# in the archive.
 	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
 	;;
-      gcx*)
+      gcx)
 	# Green Hills C++ Compiler
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
@@ -3623,63 +3443,12 @@
 	;;
     esac
     ;;
-  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    runpath_var='LD_RUN_PATH'
-
-    case $cc_basename in
-      CC*)
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-      *)
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-    esac
-    ;;
-  sysv5* | sco3.2v5* | sco5v6*)
-    # Note: We can NOT use -z defs as we might desire, because we do not
-    # link with -lc, and that would cause any symbols used from libc to
-    # always be unresolved, which means just about no library would
-    # ever link correctly.  If we're not using GNU ld we use -z text
-    # though, which does catch some bad symbols but isn't as heavy-handed
-    # as -z defs.
-    # For security reasons, it is highly recommended that you always
-    # use absolute paths for naming shared libraries, and exclude the
-    # DT_RUNPATH tag from executables and libraries.  But doing so
-    # requires that you compile everything twice, which is a pain.
-    # So that behaviour is only enabled if SCOABSPATH is set to a
-    # non-empty value in the environment.  Most likely only useful for
-    # creating official distributions of packages.
-    # This is a hack until libtool officially supports absolute path
-    # names for shared libraries.
-    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-    _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+  sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*)
     _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
-    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
-    runpath_var='LD_RUN_PATH'
-
-    case $cc_basename in
-      CC*)
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-      *)
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-    esac
     ;;
   tandem*)
     case $cc_basename in
-      NCC*)
+      NCC)
 	# NonStop-UX NCC 3.20
 	# FIXME: insert proper C++ library support
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
@@ -3712,6 +3481,8 @@
 AC_LIBTOOL_PROG_LD_SHLIBS($1)
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
 
 AC_LIBTOOL_CONFIG($1)
 
@@ -3729,7 +3500,7 @@
 ])# AC_LIBTOOL_LANG_CXX_CONFIG
 
 # AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------------------
+# ------------------------
 # Figure out "hidden" library dependencies from verbose
 # compiler output when linking a shared library.
 # Parse the compiler output and extract the necessary
@@ -3783,7 +3554,7 @@
   # The `*' in the case matches for architectures that use `case' in
   # $output_verbose_cmd can trigger glob expansion during the loop
   # eval without this substitution.
-  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
 
   for p in `eval $output_verbose_link_cmd`; do
     case $p in
@@ -3859,37 +3630,13 @@
 
 $rm -f confest.$objext
 
-# PORTME: override above test on systems where it is broken
-ifelse([$1],[CXX],
-[case $host_os in
-interix3*)
-  # Interix 3.5 installs completely hosed .la files for C++, so rather than
-  # hack all around it, let's just trust "g++" to DTRT.
-  _LT_AC_TAGVAR(predep_objects,$1)=
-  _LT_AC_TAGVAR(postdep_objects,$1)=
-  _LT_AC_TAGVAR(postdeps,$1)=
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC*)
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
-    ;;
-  esac
-  ;;
-esac
-])
-
 case " $_LT_AC_TAGVAR(postdeps, $1) " in
 *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
 esac
 ])# AC_LIBTOOL_POSTDEP_PREDEP
 
 # AC_LIBTOOL_LANG_F77_CONFIG
-# --------------------------
+# ------------------------
 # Ensure that the configuration vars for the C compiler are
 # suitably defined.  Those variables are subsequently used by
 # AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
@@ -3933,16 +3680,12 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${F77-"f77"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 AC_MSG_CHECKING([if libtool supports shared libraries])
 AC_MSG_RESULT([$can_build_shared])
@@ -3952,7 +3695,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case $host_os in
+case "$host_os" in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -3961,9 +3704,7 @@
   fi
   ;;
 aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
+  test "$enable_shared" = yes && enable_static=no
   ;;
 esac
 AC_MSG_RESULT([$enable_shared])
@@ -3973,6 +3714,8 @@
 test "$enable_shared" = yes || enable_static=yes
 AC_MSG_RESULT([$enable_static])
 
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
 _LT_AC_TAGVAR(GCC, $1)="$G77"
 _LT_AC_TAGVAR(LD, $1)="$LD"
 
@@ -3982,6 +3725,8 @@
 AC_LIBTOOL_PROG_LD_SHLIBS($1)
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+
 
 AC_LIBTOOL_CONFIG($1)
 
@@ -4010,27 +3755,20 @@
 lt_simple_compile_test_code="class foo {}\n"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${GCJ-"gcj"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
 _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
 
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-
 AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
 AC_LIBTOOL_PROG_COMPILER_PIC($1)
 AC_LIBTOOL_PROG_CC_C_O($1)
@@ -4038,6 +3776,8 @@
 AC_LIBTOOL_PROG_LD_SHLIBS($1)
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
 
 AC_LIBTOOL_CONFIG($1)
 
@@ -4047,7 +3787,7 @@
 
 
 # AC_LIBTOOL_LANG_RC_CONFIG
-# -------------------------
+# --------------------------
 # Ensure that the configuration vars for the Windows resource compiler are
 # suitably defined.  Those variables are subsequently used by
 # AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
@@ -4071,16 +3811,11 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_AC_SYS_COMPILER
 
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${RC-"windres"}
 compiler=$CC
 _LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
 _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
 
 AC_LIBTOOL_CONFIG($1)
@@ -4110,7 +3845,7 @@
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -4216,7 +3951,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -4227,11 +3962,11 @@
 SED=$lt_SED
 
 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
+Xsed="$SED -e s/^X//"
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 # The names of the tagged configurations supported by this script.
 available_tags=
@@ -4262,12 +3997,6 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
 
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
@@ -4279,9 +4008,6 @@
 # A C compiler.
 LTCC=$lt_LTCC
 
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
 # A language-specific compiler.
 CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
 
@@ -4347,7 +4073,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -4621,6 +4347,9 @@
 # Regexp to match symbols that can be accessed directly from C.
 sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
 
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
 # Transform an extracted symbol line into a proper C declaration
 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
 
@@ -4642,31 +4371,15 @@
   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
   lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
   ;;
-linux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[[ABCDGIRSTW]]'
-    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  fi
-  ;;
 irix* | nonstopux*)
   symcode='[[BCDEGRST]]'
   ;;
 osf*)
   symcode='[[BCDEGQRST]]'
   ;;
-solaris*)
+solaris* | sysv5*)
   symcode='[[BDRT]]'
   ;;
-sco3.2v5*)
-  symcode='[[DT]]'
-  ;;
-sysv4.2uw2*)
-  symcode='[[DT]]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[[ABDT]]'
-  ;;
 sysv4)
   symcode='[[DFNSTU]]'
   ;;
@@ -4689,11 +4402,8 @@
 # Try without a prefix undercore, then with it.
 for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
   # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
 
   # Check to see that the pipe works correctly.
   pipe_works=no
@@ -4849,10 +4559,6 @@
       # DJGPP does not support shared libraries at all
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
       ;;
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
     sysv4*MP*)
       if test -d /usr/nec; then
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
@@ -4861,7 +4567,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	;;
       *)
@@ -4886,28 +4592,18 @@
 	;;
       chorus*)
 	case $cc_basename in
-	cxch68*)
+	cxch68)
 	  # Green Hills C++ Compiler
 	  # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
 	  ;;
 	esac
 	;;
-       darwin*)
-         # PIC is the default on this platform
-         # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
-           xlc*)
-           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
-           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-           ;;
-         esac
-       ;;
       dgux*)
 	case $cc_basename in
-	  ec++*)
+	  ec++)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    ;;
-	  ghcx*)
+	  ghcx)
 	    # Green Hills C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
@@ -4915,22 +4611,22 @@
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | kfreebsd*-gnu)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    if test "$host_cpu" != ia64; then
 	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
-	  aCC*)
+	  aCC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    case $host_cpu in
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    case "$host_cpu" in
 	    hppa*64*|ia64*)
 	      # +Z the default
 	      ;;
@@ -4943,13 +4639,9 @@
 	    ;;
 	esac
 	;;
-      interix*)
-	# This is c89, which is MS Visual C++ (no shared libs)
-	# Anyone wants to do a port?
-	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
 	    # CC pic flag -KPIC is the default.
@@ -4960,24 +4652,18 @@
 	;;
       linux*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    # KAI C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
-	  icpc* | ecpc*)
+	  icpc)
 	    # Intel C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
 	    ;;
-	  pgCC*)
-	    # Portland Group C++ compiler.
-	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	    ;;
-	  cxx*)
+	  cxx)
 	    # Compaq C++
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
 	    # Linux and Compaq Tru64 Unix objects are PIC.
@@ -4994,7 +4680,7 @@
 	;;
       mvs*)
 	case $cc_basename in
-	  cxx*)
+	  cxx)
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
 	    ;;
 	  *)
@@ -5005,14 +4691,14 @@
 	;;
       osf3* | osf4* | osf5*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
 	    ;;
-	  RCC*)
+	  RCC)
 	    # Rational C++ 2.4.1
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
-	  cxx*)
+	  cxx)
 	    # Digital/Compaq C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
@@ -5026,15 +4712,24 @@
 	;;
       psos*)
 	;;
+      sco*)
+	case $cc_basename in
+	  CC)
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
       solaris*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.2, 5.x and Centerline C++
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
 	    ;;
-	  gcx*)
+	  gcx)
 	    # Green Hills C++ Compiler
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	    ;;
@@ -5044,12 +4739,12 @@
 	;;
       sunos4*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.x
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	    ;;
-	  lcc*)
+	  lcc)
 	    # Lucid
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
 	    ;;
@@ -5059,7 +4754,7 @@
 	;;
       tandem*)
 	case $cc_basename in
-	  NCC*)
+	  NCC)
 	    # NonStop-UX NCC 3.20
 	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    ;;
@@ -5067,14 +4762,7 @@
 	    ;;
 	esac
 	;;
-      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-	case $cc_basename in
-	  CC*)
-	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-	    ;;
-	esac
+      unixware*)
 	;;
       vxworks*)
 	;;
@@ -5121,11 +4809,6 @@
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
       ;;
 
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
     msdosdjgpp*)
       # Just because we use GCC doesn't mean we suddenly get shared libraries
       # on systems that don't support them.
@@ -5142,7 +4825,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -5168,16 +4851,6 @@
 	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
-         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-         ;;
-       esac
-       ;;
 
     mingw* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
@@ -5189,7 +4862,7 @@
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -5213,19 +4886,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
-	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-        ;;
       ccc*)
         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         # All Alpha code is PIC.
@@ -5240,15 +4906,15 @@
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
       ;;
 
+    sco3.2v5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn'
+      ;;
+
     solaris*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
-      *)
-	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -5257,7 +4923,7 @@
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3*)
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
@@ -5270,17 +4936,6 @@
       fi
       ;;
 
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
-      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
-      ;;
-
-    unicos*)
-      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
-      ;;
-
     uts4*)
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
@@ -5308,7 +4963,7 @@
     [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
@@ -5317,16 +4972,6 @@
     _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
     ;;
 esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
-  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
-  $lt_tmp_static_flag,
-  [],
-  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
 ])
 
 
@@ -5351,7 +4996,7 @@
     _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
@@ -5394,8 +5039,7 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  _LT_CC_BASENAME([$compiler])
+
   case $host_os in
   cygwin* | mingw* | pw32*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
@@ -5405,10 +5049,6 @@
       with_gnu_ld=no
     fi
     ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
   openbsd*)
     with_gnu_ld=no
     ;;
@@ -5419,27 +5059,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -5490,10 +5109,10 @@
       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_AC_TAGVAR(always_export_symbols, $1)=no
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
 	# If the export-symbols file already is a .def file (1st line
 	# is EXPORTS), use it as is; otherwise, prepend...
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -5502,55 +5121,9 @@
 	  echo EXPORTS > $output_objdir/$soname.def;
 	  cat $export_symbols >> $output_objdir/$soname.def;
 	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-      fi
-      ;;
-
-    interix3*)
-      _LT_AC_TAGVAR(hardcode_direct, $1)=no
-      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	ld_shlibs=no
       fi
       ;;
 
@@ -5564,7 +5137,7 @@
       fi
       ;;
 
-    solaris*)
+    solaris* | sysv5*)
       if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
 	cat <<EOF 1>&2
@@ -5585,33 +5158,6 @@
       fi
       ;;
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) 
-	_LT_AC_TAGVAR(ld_shlibs, $1)=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-	;;
-	*)
-	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-	  else
-	    _LT_AC_TAGVAR(ld_shlibs, $1)=no
-	  fi
-	;;
-      esac
-      ;;
-
     sunos4*)
       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       wlarc=
@@ -5619,6 +5165,31 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ [01].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds"
+      fi
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -5629,11 +5200,16 @@
       ;;
     esac
 
-    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
-      runpath_var=
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then
+      runpath_var=LD_RUN_PATH
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -5645,7 +5221,7 @@
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
@@ -5679,7 +5255,6 @@
   	    break
   	  fi
 	  done
-	  ;;
 	esac
 
 	exp_sym_flag='-bexport'
@@ -5698,7 +5273,7 @@
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -5717,12 +5292,8 @@
   	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
   	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
 	  fi
-	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -5730,11 +5301,11 @@
   	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
+  	if test "$aix_use_runtimelinking" = yes; then
 	    shared_flag='${wl}-G'
 	  else
 	    shared_flag='${wl}-bM:SRE'
-	  fi
+  	fi
 	fi
       fi
 
@@ -5748,12 +5319,12 @@
        # Determine the default libpath from the value encoded in an empty executable.
        _LT_AC_SYS_LIBPATH_AIX
        _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
        else
 	if test "$host_cpu" = ia64; then
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an empty executable.
 	 _LT_AC_SYS_LIBPATH_AIX
@@ -5762,11 +5333,13 @@
 	  # -berok will link without error, but may produce a broken library.
 	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
 	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	  # -bexpall does not export symbols beginning with underscore (_)
+	  _LT_AC_TAGVAR(always_export_symbols, $1)=yes
 	  # Exported symbols can be pulled into shared objects from archives
-	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
 	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
       ;;
@@ -5779,7 +5352,7 @@
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
       ;;
 
-    bsdi[[45]]*)
+    bsdi4*)
       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
       ;;
 
@@ -5800,57 +5373,57 @@
       _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
       # FIXME: Should let the user specify the lib program.
       _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[[012]])
-         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[[012]])
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
+    if test "$GXX" = yes ; then
       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      case "$host_os" in
+      rhapsody* | darwin1.[[012]])
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[[012]])
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+	;;
+      esac
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience'
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         _LT_AC_TAGVAR(ld_shlibs, $1)=no
-          ;;
-      esac
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
       ;;
 
@@ -5884,7 +5457,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
@@ -5907,62 +5480,47 @@
       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
       ;;
 
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
-	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	_LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-      fi
-      ;;
-
-    hpux11*)
+    hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
+	case "$host_cpu" in
+	hppa*64*|ia64*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
-	ia64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
 	*)
 	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
-	case $host_cpu in
-	hppa*64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
 	*)
-	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
-	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
-	case $host_cpu in
-	hppa*64*|ia64*)
+	case "$host_cpu" in
+	hppa*64*)
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
 	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
 	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+	  ;;
 	*)
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
 	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
 
@@ -6010,7 +5568,6 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
 	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
       else
@@ -6056,7 +5613,7 @@
 	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -6064,15 +5621,21 @@
       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
+    sco3.2v5*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
     solaris*)
       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -6081,18 +5644,8 @@
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       case $host_os in
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
       esac
       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
       ;;
@@ -6149,45 +5702,36 @@
       fi
       ;;
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
-      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    sysv4.2uw2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      runpath_var='LD_RUN_PATH'
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
 
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[[78]]* | unixware7*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text'
       if test "$GCC" = yes; then
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
+      runpath_var='LD_RUN_PATH'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
 
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
-      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    sysv5*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+  		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
-      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
       runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
       ;;
 
     uts4*)
@@ -6205,6 +5749,11 @@
 AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
 test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
 
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
 #
 # Do we need to explicitly link libc?
 #
@@ -6232,7 +5781,6 @@
         libobjs=conftest.$ac_objext
         deplibs=
         wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
-	pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
         compiler_flags=-v
         linker_flags=-v
         verstring=
@@ -6358,7 +5906,7 @@
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f $lt_ac_sed && break
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -6383,8 +5931,8 @@
     fi
   done
 done
-])
 SED=$lt_cv_path_SED
+])
 AC_MSG_RESULT([$SED])
 ])
 

Modified: freeswitch/trunk/libs/sofia-sip/config.h.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/config.h.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/config.h.in	Sat Feb 17 01:25:21 2007
@@ -1,13 +1,5 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
-   systems. This function is required for `alloca.c' support on those systems.
-   */
-#undef CRAY_STACKSEG_END
-
-/* Define to 1 if using `alloca.c'. */
-#undef C_ALLOCA
-
 /* Define to the random number source name. */
 #undef DEV_URANDOM
 
@@ -17,13 +9,6 @@
 /* Define to 1 if you have the `alarm' function. */
 #undef HAVE_ALARM
 
-/* Define to 1 if you have `alloca', as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
-   */
-#undef HAVE_ALLOCA_H
-
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 #undef HAVE_ARPA_INET_H
 
@@ -208,9 +193,6 @@
 /* Define to 1 if you have the `poll' function. */
 #undef HAVE_POLL
 
-/* Define to 1 if you use poll in su_port. */
-#undef HAVE_POLL_PORT
-
 /* Define to 1 if you have /proc/net/if_inet6 control file */
 #undef HAVE_PROC_NET_IF_INET6
 
@@ -239,9 +221,6 @@
 /* Define to 1 if you have the <sigcomp.h> header file. */
 #undef HAVE_SIGCOMP_H
 
-/* Define to 1 if you have the `signal' function. */
-#undef HAVE_SIGNAL
-
 /* Define to 1 if you have SIGPIPE */
 #undef HAVE_SIGPIPE
 
@@ -254,9 +233,6 @@
 /* Define to 1 if you have the `socketpair' function. */
 #undef HAVE_SOCKETPAIR
 
-/* Define to 1 if we use NTH library */
-#undef HAVE_SOFIA_NTH
-
 /* Define to 1 if we use NTLM library */
 #undef HAVE_SOFIA_NTLM
 
@@ -302,9 +278,6 @@
 /* Define to 1 if your CC supports C99 struct initialization */
 #undef HAVE_STRUCT_KEYWORDS
 
-/* Define to 1 if you have the <sys/epoll.h> header file. */
-#undef HAVE_SYS_EPOLL_H
-
 /* Define to 1 if you have the <sys/filio.h> header file. */
 #undef HAVE_SYS_FILIO_H
 
@@ -389,14 +362,6 @@
 /* Define as the return type of signal handlers (`int' or `void'). */
 #undef RETSIGTYPE
 
-/* If using the C implementation of alloca, define if you know the
-   direction of stack growth for your system; otherwise it will be
-   automatically deduced at run-time.
-	STACK_DIRECTION > 0 => grows toward higher addresses
-	STACK_DIRECTION < 0 => grows toward lower addresses
-	STACK_DIRECTION = 0 => direction of growth unknown */
-#undef STACK_DIRECTION
-
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 

Modified: freeswitch/trunk/libs/sofia-sip/configure
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/configure	(original)
+++ freeswitch/trunk/libs/sofia-sip/configure	Sat Feb 17 01:25:21 2007
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for sofia-sip 1.12.5.
+# Generated by GNU Autoconf 2.59 for sofia-sip 1.12.4work.
 #
 # Copyright (C) 2003 Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
@@ -278,15 +278,15 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 if test -z "$ECHO"; then
 if test "X${echo_test_string+set}" != Xset; then
 # find a string as large as possible, as long as the shell can cope with it
   for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
     # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
-       echo_test_string=`eval $cmd` &&
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
        (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
     then
       break
@@ -421,8 +421,8 @@
 # Identity of this package.
 PACKAGE_NAME='sofia-sip'
 PACKAGE_TARNAME='sofia-sip'
-PACKAGE_VERSION='1.12.5'
-PACKAGE_STRING='sofia-sip 1.12.5'
+PACKAGE_VERSION='1.12.4work'
+PACKAGE_STRING='sofia-sip 1.12.4work'
 PACKAGE_BUGREPORT=''
 
 ac_unique_file="libsofia-sip-ua/sip/sofia-sip/sip.h"
@@ -463,7 +463,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VER_LIBSOFIA_SIP_UA_MAJOR_MINOR include_sofiadir LIBVER_SOFIA_SIP_UA_CUR LIBVER_SOFIA_SIP_UA_REV LIBVER_SOFIA_SIP_UA_AGE LIBVER_SOFIA_SIP_UA_SOVER LIBVER_SOFIA_SIP_UA_GLIB_CUR LIBVER_SOFIA_SIP_UA_GLIB_REV LIBVER_SOFIA_SIP_UA_GLIB_AGE LIBVER_SOFIA_SIP_UA_GLIB_SOVER build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE MINGW_ENVIRONMENT HAVE_MINGW32_TRUE HAVE_MINGW32_FALSE CWFLAG SOFIA_CFLAGS SOFIA_COVERAGE ENABLE_COVERAGE_TRUE ENABLE_COVERAGE_FALSE MOSTLYCLEANFILES CPP ETAGS AR ac_ct_AR LD ac_ct_LD EGREP LN_S ECHO RANLIB ac_ct_RANLIB CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL NDEBUG_TRUE NDEBUG_FALSE TESTS_ENVIRONMENT EXPENSIVE_CHECKS_TRUE EXPENSIVE_CHECKS_FALSE ACLOCAL_AMFLAGS DOXYGEN HAVE_DOXYGEN_TRUE HAVE_DOXYGEN_FALSE COREFOUNDATION_TRUE COREFOUNDATION_FALSE PKG_CONFIG GLIB_CFLAGS GLIB_LIBS HAVE_GLIB_TRUE HAVE_GLIB_FALSE GLIB_VERSION SOFIA_GLIB_PKG_REQUIRES ALLOCA REPLACE_LIBADD HAVE_TLS_TRUE HAVE_TLS_FALSE HAVE_STUN_TRUE HAVE_STUN_FALSE HAVE_NTH_TRUE HAVE_NTH_FALSE HAVE_NTLM_TRUE HAVE_NTLM_FALSE LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VER_LIBSOFIA_SIP_UA_MAJOR_MINOR include_sofiadir LIBVER_SOFIA_SIP_UA_CUR LIBVER_SOFIA_SIP_UA_REV LIBVER_SOFIA_SIP_UA_AGE LIBVER_SOFIA_SIP_UA_SOVER LIBVER_SOFIA_SIP_UA_GLIB_CUR LIBVER_SOFIA_SIP_UA_GLIB_REV LIBVER_SOFIA_SIP_UA_GLIB_AGE LIBVER_SOFIA_SIP_UA_GLIB_SOVER build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE MINGW_ENVIRONMENT HAVE_MINGW32_TRUE HAVE_MINGW32_FALSE CWFLAG SOFIA_CFLAGS ENABLE_COVERAGE_TRUE ENABLE_COVERAGE_FALSE MOSTLYCLEANFILES CPP ETAGS AR ac_ct_AR LD ac_ct_LD EGREP LN_S ECHO RANLIB ac_ct_RANLIB CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL NDEBUG_TRUE NDEBUG_FALSE TESTS_ENVIRONMENT EXPENSIVE_CHECKS_TRUE EXPENSIVE_CHECKS_FALSE ACLOCAL_AMFLAGS DOXYGEN HAVE_DOXYGEN_TRUE HAVE_DOXYGEN_FALSE COREFOUNDATION_TRUE COREFOUNDATION_FALSE PKG_CONFIG GLIB_CFLAGS GLIB_LIBS HAVE_GLIB_TRUE HAVE_GLIB_FALSE GLIB_VERSION SOFIA_GLIB_PKG_REQUIRES REPLACE_LIBADD HAVE_TLS_TRUE HAVE_TLS_FALSE HAVE_NTLM_TRUE HAVE_NTLM_FALSE LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -956,7 +956,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures sofia-sip 1.12.5 to adapt to many kinds of systems.
+\`configure' configures sofia-sip 1.12.4work to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1023,7 +1023,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of sofia-sip 1.12.5:";;
+     short | recursive ) echo "Configuration of sofia-sip 1.12.4work:";;
    esac
   cat <<\_ACEOF
 
@@ -1044,14 +1044,9 @@
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --enable-ndebug             compile with NDEBUG (disabled)
   --enable-expensive-checks   run also expensive checks (disabled)
-  --enable-experimental       enable experimental features (disabled)
   --disable-size-compat            use compatibility size_t types (enabled)
   --enable-corefoundation     compile with OSX COREFOUNDATION (disabled)
-  --disable-poll-port              disable su_poll_port (enabled)
-                                   Use this option in systems emulating poll
-                                   with select
   --disable-stun              disable stun module (enabled)
-  --disable-nth              disable nth and http modules (enabled)
   --enable-ntlm               enable NTLM support (disabled)
 
 Optional Packages:
@@ -1183,7 +1178,7 @@
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-sofia-sip configure 1.12.5
+sofia-sip configure 1.12.4work
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1197,7 +1192,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by sofia-sip $as_me 1.12.5, which was
+It was created by sofia-sip $as_me 1.12.4work, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1538,11 +1533,11 @@
 
 include_sofiadir='${includedir}/sofia-sip-1.12'
 
-LIBVER_SOFIA_SIP_UA_CUR=4
+LIBVER_SOFIA_SIP_UA_CUR=3
 
 LIBVER_SOFIA_SIP_UA_REV=0
 
-LIBVER_SOFIA_SIP_UA_AGE=4
+LIBVER_SOFIA_SIP_UA_AGE=3
 
 LIBVER_SOFIA_SIP_UA_SOVER=0
  # CUR-AGE
@@ -1977,7 +1972,7 @@
 
 # Define the identity of the package.
  PACKAGE='sofia-sip'
- VERSION='1.12.5'
+ VERSION='1.12.4work'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -4390,8 +4385,7 @@
 if test X$enable_coverage != Xno ; then
 case "${CC-cc}" in
   *gcc*)
-	SOFIA_COVERAGE="-fprofile-arcs -ftest-coverage"
-
+	SOFIA_CFLAGS="$SOFIA_CFLAGS -fprofile-arcs -ftest-coverage"
 	;;
   *) { { echo "$as_me:$LINENO: error: --enable-coverage requires gcc" >&5
 echo "$as_me: error: --enable-coverage requires gcc" >&2;}
@@ -5019,7 +5013,7 @@
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f $lt_ac_sed && break
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -5044,10 +5038,10 @@
     fi
   done
 done
+SED=$lt_cv_path_SED
 
 fi
 
-SED=$lt_cv_path_SED
 echo "$as_me:$LINENO: result: $SED" >&5
 echo "${ECHO_T}$SED" >&6
 
@@ -5124,7 +5118,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -5158,7 +5152,7 @@
 if test "${lt_cv_prog_gnu_ld+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -5188,15 +5182,6 @@
 *) reload_flag=" $reload_flag" ;;
 esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
 
 echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
 echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
@@ -5207,43 +5192,36 @@
   # Let the user override the test.
   lt_cv_path_NM="$NM"
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+      */dev/null* | *'Invalid file or object type'*)
+	lt_cv_path_NM="$tmp_nm -B"
+	break
+        ;;
+      *)
+	case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	*/dev/null*)
+	  lt_cv_path_NM="$tmp_nm -p"
 	  break
 	  ;;
 	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
+	  lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	  continue # so that we can try to find one that supports BSD flags
 	  ;;
 	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
+      esac
+    fi
   done
+  IFS="$lt_save_ifs"
   test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
 fi
 fi
@@ -5290,7 +5268,7 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-bsdi[45]*)
+bsdi4*)
   lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
   lt_cv_file_magic_cmd='/usr/bin/file -L'
   lt_cv_file_magic_test_file=/shlib/libc.so
@@ -5313,13 +5291,13 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu | dragonfly*)
+freebsd* | kfreebsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
       # Not sure whether the presence of OpenBSD here was a mistake.
       # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
       lt_cv_file_magic_cmd=/usr/bin/file
       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
@@ -5335,7 +5313,7 @@
 
 hpux10.20* | hpux11*)
   lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
     lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
@@ -5351,11 +5329,6 @@
   esac
   ;;
 
-interix3*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
-  ;;
-
 irix5* | irix6* | nonstopux*)
   case $LD in
   *-32|*"-32 ") libmagic=32-bit;;
@@ -5368,6 +5341,15 @@
 
 # This must be Linux ELF.
 linux*)
+  case $host_cpu in
+  alpha*|hppa*|i*86|ia64*|m68*|mips*|powerpc*|sparc*|s390*|sh*|x86_64*)
+    lt_cv_deplibs_check_method=pass_all ;;
+  *)
+    # glibc up to 2.1.1 does not perform some relocations on ARM
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
   lt_cv_deplibs_check_method=pass_all
   ;;
 
@@ -5390,10 +5372,12 @@
   ;;
 
 openbsd*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
   if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
   else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+    lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
   fi
   ;;
 
@@ -5401,11 +5385,15 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
 solaris*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-sysv4 | sysv4.3*)
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   case $host_vendor in
   motorola)
     lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
@@ -5426,13 +5414,10 @@
   siemens)
     lt_cv_deplibs_check_method=pass_all
     ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
   esac
   ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 esac
@@ -5450,9 +5435,6 @@
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
 # Allow CC to be a program name with arguments.
 compiler=$CC
 
@@ -5488,7 +5470,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 5491 "configure"' > conftest.$ac_ext
+  echo '#line 5473 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -5531,7 +5513,7 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-    case `/usr/bin/file conftest.o` in
+    case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       case $host in
         x86_64-*linux*)
@@ -5644,26 +5626,6 @@
     CFLAGS="$SAVE_CFLAGS"
   fi
   ;;
-sparc*-*solaris*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*) LD="${LD-ld} -m elf64_sparc" ;;
-      *)    LD="${LD-ld} -64" ;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
 
 esac
 
@@ -6523,12 +6485,7 @@
 fi
 
 
-
-
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  ac_ext=cc
+ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -6758,8 +6715,6 @@
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-fi
-
 
 ac_ext=f
 ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
@@ -6853,7 +6808,7 @@
 
 
 # Provide some information about the compiler.
-echo "$as_me:6856:" \
+echo "$as_me:6811:" \
      "checking for Fortran 77 compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
 { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -7043,55 +6998,11 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
-
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ 	]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
+ *)
     # If test is not a shell built-in, we'll probably end up computing a
     # maximum length that is only half of the actual maximum length, but
     # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
+    while (test "X"`$CONFIG_SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
 	       = "XX$teststring") >/dev/null 2>&1 &&
 	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
 	    lt_cv_sys_max_cmd_len=$new_result &&
@@ -7137,6 +7048,9 @@
 # Regexp to match symbols that can be accessed directly from C.
 sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
 
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
 # Transform an extracted symbol line into a proper C declaration
 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
 
@@ -7158,31 +7072,15 @@
   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
   lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
   ;;
-linux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[ABCDGIRSTW]'
-    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  fi
-  ;;
 irix* | nonstopux*)
   symcode='[BCDEGRST]'
   ;;
 osf*)
   symcode='[BCDEGQRST]'
   ;;
-solaris*)
+solaris* | sysv5*)
   symcode='[BDRT]'
   ;;
-sco3.2v5*)
-  symcode='[DT]'
-  ;;
-sysv4.2uw2*)
-  symcode='[DT]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[ABDT]'
-  ;;
 sysv4)
   symcode='[DFNSTU]'
   ;;
@@ -7205,11 +7103,8 @@
 # Try without a prefix undercore, then with it.
 for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
   # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
 
   # Check to see that the pipe works correctly.
   pipe_works=no
@@ -7371,7 +7266,7 @@
 
 # Sed substitution that helps us do robust quoting.  It backslashifies
 # metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
+Xsed='sed -e s/^X//'
 sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
 
 # Same as above, but do not quote variable references.
@@ -7391,7 +7286,7 @@
 default_ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a `.a' archive for static linking (except M$VC,
 # which needs '.lib').
 libext=a
 ltmain="$ac_aux_dir/ltmain.sh"
@@ -7648,7 +7543,6 @@
 test -z "$AS" && AS=as
 test -z "$CC" && CC=cc
 test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$DLLTOOL" && DLLTOOL=dlltool
 test -z "$LD" && LD=ld
 test -z "$LN_S" && LN_S="ln -s"
@@ -7668,26 +7562,15 @@
 if test -n "$RANLIB"; then
   case $host_os in
   openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
     ;;
   *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
     ;;
   esac
   old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
 fi
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
 # Only perform the check for file, if the check method requires it
 case $deplibs_check_method in
 file_magic*)
@@ -7713,7 +7596,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -7775,7 +7658,7 @@
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
 	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
@@ -7870,25 +7753,68 @@
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
 # Allow CC to be a program name with arguments.
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+#
+# Check for any special shared library compilation flags.
+#
+lt_prog_cc_shlib=
+if test "$GCC" = no; then
+  case $host_os in
+  sco3.2v5*)
+    lt_prog_cc_shlib='-belf'
+    ;;
+  esac
+fi
+if test -n "$lt_prog_cc_shlib"; then
+  { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5
+echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;}
+  if echo "$old_CC $old_CFLAGS " | grep "[ 	]$lt_prog_cc_shlib[ 	]" >/dev/null; then :
+  else
+    { echo "$as_me:$LINENO: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5
+echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;}
+    lt_cv_prog_cc_can_build_shared=no
+  fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+echo "$as_me:$LINENO: checking if $compiler static flag $lt_prog_compiler_static works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_prog_compiler_static works... $ECHO_C" >&6
+if test "${lt_prog_compiler_static_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_prog_compiler_static"
+   printf "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+     else
+       lt_prog_compiler_static_works=yes
+     fi
+   fi
+   $rm conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
+echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
+
+if test x"$lt_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
 
 
 
@@ -7913,20 +7839,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7919: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7845: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7923: \$? = $ac_status" >&5
+   echo "$as_me:7849: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_cv_prog_compiler_rtti_exceptions=yes
      fi
    fi
@@ -7987,11 +7911,6 @@
       lt_prog_compiler_pic='-fno-common'
       ;;
 
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
     msdosdjgpp*)
       # Just because we use GCC doesn't mean we suddenly get shared libraries
       # on systems that don't support them.
@@ -8008,7 +7927,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -8034,16 +7953,6 @@
 	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic='-qnocommon'
-         lt_prog_compiler_wl='-Wl,'
-         ;;
-       esac
-       ;;
 
     mingw* | pw32* | os2*)
       # This hack is so that the source file can tell whether it is being
@@ -8055,7 +7964,7 @@
       lt_prog_compiler_wl='-Wl,'
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	# +Z the default
 	;;
@@ -8079,19 +7988,12 @@
       ;;
 
     linux*)
-      case $cc_basename in
+      case $CC in
       icc* | ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
 	lt_prog_compiler_static='-static'
         ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fpic'
-	lt_prog_compiler_static='-Bstatic'
-        ;;
       ccc*)
         lt_prog_compiler_wl='-Wl,'
         # All Alpha code is PIC.
@@ -8106,15 +8008,15 @@
       lt_prog_compiler_static='-non_shared'
       ;;
 
+    sco3.2v5*)
+      lt_prog_compiler_pic='-Kpic'
+      lt_prog_compiler_static='-dn'
+      ;;
+
     solaris*)
+      lt_prog_compiler_wl='-Wl,'
       lt_prog_compiler_pic='-KPIC'
       lt_prog_compiler_static='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl='-Wl,';;
-      esac
       ;;
 
     sunos4*)
@@ -8123,7 +8025,7 @@
       lt_prog_compiler_static='-Bstatic'
       ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3*)
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
       lt_prog_compiler_wl='-Wl,'
       lt_prog_compiler_pic='-KPIC'
       lt_prog_compiler_static='-Bstatic'
@@ -8136,17 +8038,6 @@
       fi
       ;;
 
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    unicos*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_can_build_shared=no
-      ;;
-
     uts4*)
       lt_prog_compiler_pic='-pic'
       lt_prog_compiler_static='-Bstatic'
@@ -8181,20 +8072,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8187: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8078: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8191: \$? = $ac_status" >&5
+   echo "$as_me:8082: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works=yes
      fi
    fi
@@ -8215,7 +8104,7 @@
 fi
 
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
@@ -8225,48 +8114,6 @@
     ;;
 esac
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works=yes
-       fi
-     else
-       lt_prog_compiler_static_works=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
-
-if test x"$lt_prog_compiler_static_works" = xyes; then
-    :
-else
-    lt_prog_compiler_static=
-fi
-
-
 echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
 if test "${lt_cv_prog_compiler_c_o+set}" = set; then
@@ -8285,25 +8132,23 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8291: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8138: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8295: \$? = $ac_status" >&5
+   echo "$as_me:8142: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o=yes
      fi
    fi
-   chmod u+w . 2>&5
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -8379,16 +8224,6 @@
   # rely on this symbol name, it's probably fine to never include it in
   # preloaded symbol tables.
   extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
   case $host_os in
   cygwin* | mingw* | pw32*)
@@ -8399,10 +8234,6 @@
       with_gnu_ld=no
     fi
     ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
   openbsd*)
     with_gnu_ld=no
     ;;
@@ -8413,27 +8244,6 @@
     # If archive_cmds runs LD, not CC, wlarc should be empty
     wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
     # See if GNU ld supports shared libraries.
     case $host_os in
     aix3* | aix4* | aix5*)
@@ -8484,10 +8294,10 @@
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
-      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
       if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
 	# If the export-symbols file already is a .def file (1st line
 	# is EXPORTS), use it as is; otherwise, prepend...
 	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -8496,53 +8306,7 @@
 	  echo EXPORTS > $output_objdir/$soname.def;
 	  cat $export_symbols >> $output_objdir/$soname.def;
 	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
-    interix3*)
-      hardcode_direct=no
-      hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
       else
 	ld_shlibs=no
       fi
@@ -8558,7 +8322,7 @@
       fi
       ;;
 
-    solaris*)
+    solaris* | sysv5*)
       if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
 	ld_shlibs=no
 	cat <<EOF 1>&2
@@ -8579,33 +8343,6 @@
       fi
       ;;
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-	;;
-	*)
-	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-	  else
-	    ld_shlibs=no
-	  fi
-	;;
-      esac
-      ;;
-
     sunos4*)
       archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       wlarc=
@@ -8613,6 +8350,31 @@
       hardcode_shlibpath_var=no
       ;;
 
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds="$tmp_archive_cmds"
+      fi
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
     *)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
 	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
@@ -8623,11 +8385,16 @@
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec=
-      export_dynamic_flag_spec=
-      whole_archive_flag_spec=
+    if test "$ld_shlibs" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec=
+      fi
     fi
   else
     # PORTME fill in a description of your system's linker (not GNU ld)
@@ -8639,7 +8406,7 @@
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	hardcode_direct=unsupported
@@ -8673,7 +8440,6 @@
   	    break
   	  fi
 	  done
-	  ;;
 	esac
 
 	exp_sym_flag='-bexport'
@@ -8692,7 +8458,7 @@
       link_all_deplibs=yes
 
       if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
+	case $host_os in aix4.012|aix4.012.*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
 	  collect2name=`${CC} -print-prog-name=collect2`
@@ -8711,12 +8477,8 @@
   	  hardcode_libdir_flag_spec='-L$libdir'
   	  hardcode_libdir_separator=
 	  fi
-	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -8724,11 +8486,11 @@
   	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
+  	if test "$aix_use_runtimelinking" = yes; then
 	    shared_flag='${wl}-G'
 	  else
 	    shared_flag='${wl}-bM:SRE'
-	  fi
+  	fi
 	fi
       fi
 
@@ -8793,12 +8555,12 @@
 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-	archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+	archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
        else
 	if test "$host_cpu" = ia64; then
 	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
 	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an empty executable.
 	 cat >conftest.$ac_ext <<_ACEOF
@@ -8858,11 +8620,13 @@
 	  # -berok will link without error, but may produce a broken library.
 	  no_undefined_flag=' ${wl}-bernotok'
 	  allow_undefined_flag=' ${wl}-berok'
+	  # -bexpall does not export symbols beginning with underscore (_)
+	  always_export_symbols=yes
 	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec='$convenience'
+	  whole_archive_flag_spec=' '
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
 	fi
       fi
       ;;
@@ -8875,7 +8639,7 @@
       ld_shlibs=no
       ;;
 
-    bsdi[45]*)
+    bsdi4*)
       export_dynamic_flag_spec=-rdynamic
       ;;
 
@@ -8901,52 +8665,52 @@
       ;;
 
     darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
+    if test "$GXX" = yes ; then
       archive_cmds_need_lc=no
-      hardcode_direct=no
-      hardcode_automatic=yes
+      case "$host_os" in
+      rhapsody* | darwin1.[012])
+	allow_undefined_flag='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+	;;
+      esac
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  archive_cmds='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        archive_cmds='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      module_cmds='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      hardcode_direct=no
+      hardcode_automatic=yes
       hardcode_shlibpath_var=unsupported
-      whole_archive_flag_spec=''
+      whole_archive_flag_spec='-all_load $convenience'
       link_all_deplibs=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
     else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs=no
-          ;;
-      esac
+      ld_shlibs=no
     fi
       ;;
 
@@ -8980,7 +8744,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
+    freebsd* | kfreebsd*-gnu)
       archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
@@ -9003,62 +8767,47 @@
       export_dynamic_flag_spec='${wl}-E'
       ;;
 
-    hpux10*)
+    hpux10* | hpux11*)
       if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator=:
-
-	hardcode_direct=yes
-	export_dynamic_flag_spec='${wl}-E'
-
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L=yes
-      fi
-      ;;
-
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
+	case "$host_cpu" in
+	hppa*64*|ia64*)
 	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
-	ia64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
 	*)
 	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
 	*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 	  ;;
 	esac
       fi
       if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator=:
-
-	case $host_cpu in
-	hppa*64*|ia64*)
+	case "$host_cpu" in
+	hppa*64*)
+	  hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
 	  hardcode_libdir_flag_spec_ld='+b $libdir'
+	  hardcode_libdir_separator=:
+	  hardcode_direct=no
+	  hardcode_shlibpath_var=no
+	  ;;
+	ia64*)
+	  hardcode_libdir_flag_spec='-L$libdir'
 	  hardcode_direct=no
 	  hardcode_shlibpath_var=no
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L=yes
 	  ;;
 	*)
+	  hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_separator=:
 	  hardcode_direct=yes
 	  export_dynamic_flag_spec='${wl}-E'
 
@@ -9106,7 +8855,6 @@
       hardcode_shlibpath_var=no
       if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
 	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
 	hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
 	export_dynamic_flag_spec='${wl}-E'
       else
@@ -9152,7 +8900,7 @@
 	allow_undefined_flag=' -expect_unresolved \*'
 	archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -9160,15 +8908,21 @@
       hardcode_libdir_separator=:
       ;;
 
+    sco3.2v5*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
     solaris*)
       no_undefined_flag=' -z text'
       if test "$GCC" = yes; then
-	wlarc='${wl}'
 	archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
 	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
       else
-	wlarc=''
 	archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
   	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
@@ -9177,18 +8931,8 @@
       hardcode_shlibpath_var=no
       case $host_os in
       solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
       esac
       link_all_deplibs=yes
       ;;
@@ -9245,45 +8989,36 @@
       fi
       ;;
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
-      no_undefined_flag='${wl}-z,text'
-      archive_cmds_need_lc=no
+    sysv4.2uw2*)
+      archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=no
       hardcode_shlibpath_var=no
-      runpath_var='LD_RUN_PATH'
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
 
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
+      no_undefined_flag='${wl}-z ${wl}text'
       if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
       ;;
 
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
-      archive_cmds_need_lc=no
+    sysv5*)
+      no_undefined_flag=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+  		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      hardcode_libdir_flag_spec=
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      hardcode_libdir_separator=':'
-      link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
       runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
       ;;
 
     uts4*)
@@ -9302,6 +9037,11 @@
 echo "${ECHO_T}$ld_shlibs" >&6
 test "$ld_shlibs" = no && can_build_shared=no
 
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
 #
 # Do we need to explicitly link libc?
 #
@@ -9334,7 +9074,6 @@
         libobjs=conftest.$ac_objext
         deplibs=
         wl=$lt_prog_compiler_wl
-	pic_flag=$lt_prog_compiler_pic
         compiler_flags=-v
         linker_flags=-v
         verstring=
@@ -9467,7 +9206,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[45]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -9495,8 +9234,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -9526,7 +9264,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -9549,7 +9287,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -9584,17 +9322,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -9612,19 +9341,14 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+  *) # from 3.2 on
     shlibpath_overrides_runpath=no
     hardcode_into_libs=yes
     ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
   esac
   ;;
 
@@ -9644,7 +9368,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -9684,18 +9408,6 @@
   postinstall_cmds='chmod 555 $lib'
   ;;
 
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
 irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
@@ -9753,10 +9465,31 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 9472 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -9817,13 +9550,8 @@
 
 openbsd*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -9861,6 +9589,13 @@
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
 solaris*)
   version_type=linux
   need_lib_prefix=no
@@ -9886,7 +9621,7 @@
   need_version=yes
   ;;
 
-sysv4 | sysv4.3*)
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -9919,29 +9654,6 @@
   fi
   ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
 uts4*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -9957,17 +9669,12 @@
 echo "${ECHO_T}$dynamic_linker" >&6
 test "$dynamic_linker" = no && can_build_shared=no
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
 echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" || \
-   test -n "$runpath_var" || \
-   test "X$hardcode_automatic" = "Xyes" ; then
+   test -n "$runpath_var " || \
+   test "X$hardcode_automatic"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$hardcode_direct" != no &&
@@ -10617,7 +10324,7 @@
     test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
     save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
     save_LIBS="$LIBS"
     LIBS="$lt_cv_dlopen_libs $LIBS"
@@ -10633,7 +10340,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10636 "configure"
+#line 10343 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10690,8 +10397,6 @@
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
-  else
-    puts (dlerror ());
 
     exit (status);
 }
@@ -10701,12 +10406,12 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
       x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
     esac
   else :
     # compilation failed
@@ -10721,7 +10426,7 @@
 echo "${ECHO_T}$lt_cv_dlopen_self" >&6
 
     if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      LDFLAGS="$LDFLAGS $link_static_flag"
       echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
 if test "${lt_cv_dlopen_self_static+set}" = set; then
@@ -10733,7 +10438,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10736 "configure"
+#line 10441 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10790,8 +10495,6 @@
       else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
       /* dlclose (self); */
     }
-  else
-    puts (dlerror ());
 
     exit (status);
 }
@@ -10801,12 +10504,12 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
+    (./conftest; exit; ) 2>/dev/null
     lt_status=$?
     case x$lt_status in
       x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
       x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
     esac
   else :
     # compilation failed
@@ -10839,7 +10542,7 @@
 fi
 
 
-# Report which library types will actually be built
+# Report which librarie types wil actually be built
 echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
 echo "$as_me:$LINENO: result: $can_build_shared" >&5
@@ -10851,7 +10554,7 @@
 
 # On AIX, shared libraries and static libraries use the same namespace, and
 # are all built from PIC.
-case $host_os in
+case "$host_os" in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
   if test -n "$RANLIB"; then
@@ -10864,6 +10567,43 @@
   if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
     test "$enable_shared" = yes && enable_static=no
   fi
+  ;;
+  darwin* | rhapsody*)
+  if test "$GCC" = yes; then
+    archive_cmds_need_lc=no
+    case "$host_os" in
+    rhapsody* | darwin1.[012])
+      allow_undefined_flag='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+      ;;
+    esac
+    output_verbose_link_cmd='echo'
+    archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring'
+    module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag  -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    hardcode_direct=no
+    hardcode_automatic=yes
+    hardcode_shlibpath_var=unsupported
+    whole_archive_flag_spec='-all_load $convenience'
+    link_all_deplibs=yes
+  else
+    ld_shlibs=no
+  fi
     ;;
 esac
 echo "$as_me:$LINENO: result: $enable_shared" >&5
@@ -10889,7 +10629,7 @@
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -10993,7 +10733,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -11004,11 +10744,11 @@
 SED=$lt_SED
 
 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
+Xsed="$SED -e s/^X//"
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 # The names of the tagged configurations supported by this script.
 available_tags=
@@ -11038,12 +10778,6 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
 
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
@@ -11055,9 +10789,6 @@
 # A C compiler.
 LTCC=$lt_LTCC
 
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
 # A language-specific compiler.
 CC=$lt_compiler
 
@@ -11123,7 +10854,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -11388,9 +11119,6 @@
 echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
     fi
   fi
-  if test -z "$LTCFLAGS"; then
-    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
-  fi
 
   # Extract list of available tagged configurations in $ofile.
   # Note that this assumes the entire list is on one line.
@@ -11421,9 +11149,7 @@
 
       case $tagname in
       CXX)
-	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-	    (test "X$CXX" != "Xg++"))) ; then
+	if test -n "$CXX" && test "X$CXX" != "Xno"; then
 	  ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -11443,7 +11169,6 @@
 hardcode_libdir_flag_spec_ld_CXX=
 hardcode_libdir_separator_CXX=
 hardcode_minus_L_CXX=no
-hardcode_shlibpath_var_CXX=unsupported
 hardcode_automatic_CXX=no
 module_cmds_CXX=
 module_expsym_cmds_CXX=
@@ -11461,7 +11186,7 @@
 compiler_lib_search_path_CXX=
 
 # Source file extension for C++ test sources.
-ac_ext=cpp
+ac_ext=cc
 
 # Object file extension for compiled C++ test sources.
 objext=o
@@ -11471,34 +11196,17 @@
 lt_simple_compile_test_code="int some_variable = 0;\n"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
+lt_simple_link_test_code='int main(int, char *) { return(0); }\n'
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
 # Allow CC to be a program name with arguments.
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_LD=$LD
@@ -11509,27 +11217,18 @@
 if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
   lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
 else
-  $as_unset lt_cv_prog_gnu_ld
+  unset lt_cv_prog_gnu_ld
 fi
 if test -n "${lt_cv_path_LDCXX+set}"; then
   lt_cv_path_LD=$lt_cv_path_LDCXX
 else
-  $as_unset lt_cv_path_LD
+  unset lt_cv_path_LD
 fi
 test -z "${LDCXX+set}" || LD=$LDCXX
 CC=${CXX-"c++"}
 compiler=$CC
 compiler_CXX=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
 # We don't want -fno-exception wen compiling C++ code, so set the
 # no_builtin_flag separately
@@ -11600,7 +11299,7 @@
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       lt_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
@@ -11634,7 +11333,7 @@
 if test "${lt_cv_prog_gnu_ld+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
   lt_cv_prog_gnu_ld=yes
@@ -11725,7 +11424,6 @@
 	    ;;
 	  esac
 	done
-	;;
       esac
 
       exp_sym_flag='-bexport'
@@ -11744,7 +11442,7 @@
     link_all_deplibs_CXX=yes
 
     if test "$GXX" = yes; then
-      case $host_os in aix4.[012]|aix4.[012].*)
+      case $host_os in aix4.012|aix4.012.*)
       # We only want to do this on AIX 4.2 and lower, the check
       # below for broken collect2 doesn't work under 4.3+
 	collect2name=`${CC} -print-prog-name=collect2`
@@ -11763,12 +11461,8 @@
 	  hardcode_libdir_flag_spec_CXX='-L$libdir'
 	  hardcode_libdir_separator_CXX=
 	fi
-	;;
       esac
       shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-	shared_flag="$shared_flag "'${wl}-G'
-      fi
     else
       # not using gcc
       if test "$host_cpu" = ia64; then
@@ -11846,12 +11540,12 @@
 
       hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
 
-      archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
      else
       if test "$host_cpu" = ia64; then
 	hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
 	allow_undefined_flag_CXX="-z nodefs"
-	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
       else
 	# Determine the default libpath from the value encoded in an empty executable.
 	cat >conftest.$ac_ext <<_ACEOF
@@ -11911,26 +11605,16 @@
 	# -berok will link without error, but may produce a broken library.
 	no_undefined_flag_CXX=' ${wl}-bernotok'
 	allow_undefined_flag_CXX=' ${wl}-berok'
+	# -bexpall does not export symbols beginning with underscore (_)
+	always_export_symbols_CXX=yes
 	# Exported symbols can be pulled into shared objects from archives
-	whole_archive_flag_spec_CXX='$convenience'
+	whole_archive_flag_spec_CXX=' '
 	archive_cmds_need_lc_CXX=yes
-	# This is similar to how AIX traditionally builds its shared libraries.
-	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	# This is similar to how AIX traditionally builds it's shared libraries.
+	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
     ;;
-
-  beos*)
-    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-      allow_undefined_flag_CXX=unsupported
-      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-      # support --undefined.  This deserves some investigation.  FIXME
-      archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-    else
-      ld_shlibs_CXX=no
-    fi
-    ;;
-
   chorus*)
     case $cc_basename in
       *)
@@ -11949,7 +11633,7 @@
     enable_shared_with_static_runtimes_CXX=yes
 
     if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-      archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
       # If the export-symbols file already is a .def file (1st line
       # is EXPORTS), use it as is; otherwise, prepend...
       archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
@@ -11958,81 +11642,70 @@
 	echo EXPORTS > $output_objdir/$soname.def;
 	cat $export_symbols >> $output_objdir/$soname.def;
       fi~
-      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
     else
       ld_shlibs_CXX=no
     fi
   ;;
-      darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
-      archive_cmds_need_lc_CXX=no
-      hardcode_direct_CXX=no
-      hardcode_automatic_CXX=yes
-      hardcode_shlibpath_var_CXX=unsupported
-      whole_archive_flag_spec_CXX=''
-      link_all_deplibs_CXX=yes
 
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
-      output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
-      fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-          archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-          module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_CXX=no
-          ;;
-      esac
+  darwin* | rhapsody*)
+  if test "$GXX" = yes; then
+    archive_cmds_need_lc_CXX=no
+    case "$host_os" in
+    rhapsody* | darwin1.[012])
+      allow_undefined_flag_CXX='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag_CXX='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag_CXX='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag_CXX='-undefined dynamic_lookup'
+            ;;
+        esac
       fi
-        ;;
+      ;;
+    esac
+    lt_int_apple_cc_single_mod=no
+    output_verbose_link_cmd='echo'
+    if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+      lt_int_apple_cc_single_mod=yes
+    fi
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    else
+      archive_cmds_CXX='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    fi
+    module_cmds_CXX='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+
+    # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+    if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+      archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    hardcode_direct_CXX=no
+    hardcode_automatic_CXX=yes
+    hardcode_shlibpath_var_CXX=unsupported
+    whole_archive_flag_spec_CXX='-all_load $convenience'
+    link_all_deplibs_CXX=yes
+  else
+    ld_shlibs_CXX=no
+  fi
+    ;;
 
   dgux*)
     case $cc_basename in
-      ec++*)
+      ec++)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      ghcx*)
+      ghcx)
 	# Green Hills C++ Compiler
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -12043,14 +11716,14 @@
 	;;
     esac
     ;;
-  freebsd[12]*)
+  freebsd12*)
     # C++ shared libraries reported to be fairly broken before switch to ELF
     ld_shlibs_CXX=no
     ;;
   freebsd-elf*)
     archive_cmds_need_lc_CXX=no
     ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
+  freebsd* | kfreebsd*-gnu)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     ld_shlibs_CXX=yes
@@ -12067,11 +11740,11 @@
 				# location of the library.
 
     case $cc_basename in
-    CC*)
+    CC)
       # FIXME: insert proper C++ library support
       ld_shlibs_CXX=no
       ;;
-    aCC*)
+    aCC)
       archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
@@ -12081,7 +11754,7 @@
       # explicitly linking system object files so we need to strip them
       # from the output so that they don't get included in the library
       # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
       ;;
     *)
       if test "$GXX" = yes; then
@@ -12095,22 +11768,33 @@
     ;;
   hpux10*|hpux11*)
     if test $with_gnu_ld = no; then
-      hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_CXX=:
-
-      case $host_cpu in
-      hppa*64*|ia64*)
+      case "$host_cpu" in
+      hppa*64*)
+	hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
 	hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
+	hardcode_libdir_separator_CXX=:
+        ;;
+      ia64*)
+	hardcode_libdir_flag_spec_CXX='-L$libdir'
         ;;
       *)
+	hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_CXX=:
 	export_dynamic_flag_spec_CXX='${wl}-E'
         ;;
       esac
     fi
-    case $host_cpu in
-    hppa*64*|ia64*)
+    case "$host_cpu" in
+    hppa*64*)
+      hardcode_direct_CXX=no
+      hardcode_shlibpath_var_CXX=no
+      ;;
+    ia64*)
       hardcode_direct_CXX=no
       hardcode_shlibpath_var_CXX=no
+      hardcode_minus_L_CXX=yes # Not in the search PATH,
+					      # but as the default
+					      # location of the library.
       ;;
     *)
       hardcode_direct_CXX=yes
@@ -12121,17 +11805,14 @@
     esac
 
     case $cc_basename in
-      CC*)
+      CC)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      aCC*)
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+      aCC)
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	  ;;
 	*)
 	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -12150,12 +11831,9 @@
       *)
 	if test "$GXX" = yes; then
 	  if test $with_gnu_ld = no; then
-	    case $host_cpu in
-	    hppa*64*)
-	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      ;;
-	    ia64*)
-	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    case "$host_cpu" in
+	    ia64*|hppa*64*)
+	      archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
 	      ;;
 	    *)
 	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
@@ -12169,25 +11847,11 @@
 	;;
     esac
     ;;
-  interix3*)
-    hardcode_direct_CXX=no
-    hardcode_shlibpath_var_CXX=no
-    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-    export_dynamic_flag_spec_CXX='${wl}-E'
-    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-    # Instead, shared libraries are loaded at an image base (0x10000000 by
-    # default) and relocated if they conflict, which is a slow very memory
-    # consuming and fragmenting process.  To avoid this, we pick a random,
-    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-    archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    ;;
   irix5* | irix6*)
     case $cc_basename in
-      CC*)
+      CC)
 	# SGI C++
-	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	# Archives containing C++ object files must be created using
 	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -12198,7 +11862,7 @@
       *)
 	if test "$GXX" = yes; then
 	  if test "$with_gnu_ld" = no; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 	  else
 	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
 	  fi
@@ -12211,7 +11875,7 @@
     ;;
   linux*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -12236,41 +11900,17 @@
 	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
 	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
 	;;
-      icpc*)
+      icpc)
 	# Intel C++
 	with_gnu_ld=yes
-	# version 8.0 and above of icpc choke on multiply defined symbols
-	# if we add $predep_objects and $postdep_objects, however 7.1 and
-	# earlier do not add the objects themselves.
-	case `$CC -V 2>&1` in
-	*"Version 7."*)
-  	  archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-  	  archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	*)  # Version 8.0 or newer
-	  tmp_idyn=
-	  case $host_cpu in
-	    ia64*) tmp_idyn=' -i_dynamic';;
-	  esac
-  	  archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	  archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	esac
 	archive_cmds_need_lc_CXX=no
+	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
 	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 	whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
 	;;
-      pgCC*)
-        # Portland Group C++ compiler
-	archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-  	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-	hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
+      cxx)
 	# Compaq C++
 	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
 	archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
@@ -12301,7 +11941,7 @@
     ;;
   mvs*)
     case $cc_basename in
-      cxx*)
+      cxx)
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
@@ -12322,25 +11962,9 @@
     # Workaround some broken pre-1.5 toolchains
     output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
     ;;
-  openbsd2*)
-    # C++ shared libraries are fairly broken
-    ld_shlibs_CXX=no
-    ;;
-  openbsd*)
-    hardcode_direct_CXX=yes
-    hardcode_shlibpath_var_CXX=no
-    archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      export_dynamic_flag_spec_CXX='${wl}-E'
-      whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    fi
-    output_verbose_link_cmd='echo'
-    ;;
   osf3*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -12356,14 +11980,14 @@
 	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
 
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      cxx*)
+      cxx)
 	allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 
 	hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	hardcode_libdir_separator_CXX=:
@@ -12381,7 +12005,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	  hardcode_libdir_separator_CXX=:
@@ -12400,7 +12024,7 @@
     ;;
   osf4* | osf5*)
     case $cc_basename in
-      KCC*)
+      KCC)
 	# Kuck and Associates, Inc. (KAI) C++ Compiler
 
 	# KCC will only create a shared library if the output file
@@ -12415,17 +12039,17 @@
 	# the KAI C++ compiler.
 	old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
 	;;
-      RCC*)
+      RCC)
 	# Rational C++ 2.4.1
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      cxx*)
+      cxx)
 	allow_undefined_flag_CXX=' -expect_unresolved \*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
 	archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
 	  echo "-hidden">> $lib.exp~
-	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry $objdir/so_locations -o $lib~
 	  $rm $lib.exp'
 
 	hardcode_libdir_flag_spec_CXX='-rpath $libdir'
@@ -12444,7 +12068,7 @@
       *)
 	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
 	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
 
 	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
 	  hardcode_libdir_separator_CXX=:
@@ -12465,14 +12089,27 @@
     # FIXME: insert proper C++ library support
     ld_shlibs_CXX=no
     ;;
+  sco*)
+    archive_cmds_need_lc_CXX=no
+    case $cc_basename in
+      CC)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+    esac
+    ;;
   sunos4*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.x
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
 	;;
-      lcc*)
+      lcc)
 	# Lucid
 	# FIXME: insert proper C++ library support
 	ld_shlibs_CXX=no
@@ -12485,33 +12122,36 @@
     ;;
   solaris*)
     case $cc_basename in
-      CC*)
+      CC)
 	# Sun C++ 4.2, 5.x and Centerline C++
-        archive_cmds_need_lc_CXX=yes
 	no_undefined_flag_CXX=' -zdefs'
-	archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+	$CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
 
 	hardcode_libdir_flag_spec_CXX='-R$libdir'
 	hardcode_shlibpath_var_CXX=no
 	case $host_os in
-	  solaris2.[0-5] | solaris2.[0-5].*) ;;
+	  solaris2.0-5 | solaris2.0-5.*) ;;
 	  *)
 	    # The C++ compiler is used as linker so we must use $wl
 	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
+	    # linker.
 	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
 	    ;;
 	esac
 	link_all_deplibs_CXX=yes
 
-	output_verbose_link_cmd='echo'
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[LR]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
 
 	# Archives containing C++ object files must be created using
 	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
@@ -12519,7 +12159,7 @@
 	# in the archive.
 	old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
 	;;
-      gcx*)
+      gcx)
 	# Green Hills C++ Compiler
 	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
@@ -12557,66 +12197,15 @@
 	;;
     esac
     ;;
-  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-    no_undefined_flag_CXX='${wl}-z,text'
+  sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
     archive_cmds_need_lc_CXX=no
-    hardcode_shlibpath_var_CXX=no
-    runpath_var='LD_RUN_PATH'
-
+    ;;
+  tandem*)
     case $cc_basename in
-      CC*)
-	archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-      *)
-	archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-    esac
-    ;;
-  sysv5* | sco3.2v5* | sco5v6*)
-    # Note: We can NOT use -z defs as we might desire, because we do not
-    # link with -lc, and that would cause any symbols used from libc to
-    # always be unresolved, which means just about no library would
-    # ever link correctly.  If we're not using GNU ld we use -z text
-    # though, which does catch some bad symbols but isn't as heavy-handed
-    # as -z defs.
-    # For security reasons, it is highly recommended that you always
-    # use absolute paths for naming shared libraries, and exclude the
-    # DT_RUNPATH tag from executables and libraries.  But doing so
-    # requires that you compile everything twice, which is a pain.
-    # So that behaviour is only enabled if SCOABSPATH is set to a
-    # non-empty value in the environment.  Most likely only useful for
-    # creating official distributions of packages.
-    # This is a hack until libtool officially supports absolute path
-    # names for shared libraries.
-    no_undefined_flag_CXX='${wl}-z,text'
-    allow_undefined_flag_CXX='${wl}-z,nodefs'
-    archive_cmds_need_lc_CXX=no
-    hardcode_shlibpath_var_CXX=no
-    hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-    hardcode_libdir_separator_CXX=':'
-    link_all_deplibs_CXX=yes
-    export_dynamic_flag_spec_CXX='${wl}-Bexport'
-    runpath_var='LD_RUN_PATH'
-
-    case $cc_basename in
-      CC*)
-	archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-      *)
-	archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-    esac
-    ;;
-  tandem*)
-    case $cc_basename in
-      NCC*)
-	# NonStop-UX NCC 3.20
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
+      NCC)
+	# NonStop-UX NCC 3.20
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
 	;;
       *)
 	# FIXME: insert proper C++ library support
@@ -12666,7 +12255,7 @@
   # The `*' in the case matches for architectures that use `case' in
   # $output_verbose_cmd can trigger glob expansion during the loop
   # eval without this substitution.
-  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
 
   for p in `eval $output_verbose_link_cmd`; do
     case $p in
@@ -12742,29 +12331,6 @@
 
 $rm -f confest.$objext
 
-# PORTME: override above test on systems where it is broken
-case $host_os in
-interix3*)
-  # Interix 3.5 installs completely hosed .la files for C++, so rather than
-  # hack all around it, let's just trust "g++" to DTRT.
-  predep_objects_CXX=
-  postdep_objects_CXX=
-  postdeps_CXX=
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC*)
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    postdeps_CXX='-lCstd -lCrun'
-    ;;
-  esac
-  ;;
-esac
-
-
 case " $postdeps_CXX " in
 *" -lc "*) archive_cmds_need_lc_CXX=no ;;
 esac
@@ -12812,10 +12378,6 @@
       # DJGPP does not support shared libraries at all
       lt_prog_compiler_pic_CXX=
       ;;
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
     sysv4*MP*)
       if test -d /usr/nec; then
 	lt_prog_compiler_pic_CXX=-Kconform_pic
@@ -12824,7 +12386,7 @@
     hpux*)
       # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
       # not for PA HP-UX.
-      case $host_cpu in
+      case "$host_cpu" in
       hppa*64*|ia64*)
 	;;
       *)
@@ -12849,28 +12411,18 @@
 	;;
       chorus*)
 	case $cc_basename in
-	cxch68*)
+	cxch68)
 	  # Green Hills C++ Compiler
 	  # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
 	  ;;
 	esac
 	;;
-       darwin*)
-         # PIC is the default on this platform
-         # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
-           xlc*)
-           lt_prog_compiler_pic_CXX='-qnocommon'
-           lt_prog_compiler_wl_CXX='-Wl,'
-           ;;
-         esac
-       ;;
       dgux*)
 	case $cc_basename in
-	  ec++*)
+	  ec++)
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    ;;
-	  ghcx*)
+	  ghcx)
 	    # Green Hills C++ Compiler
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
@@ -12878,22 +12430,22 @@
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
+      freebsd* | kfreebsd*-gnu)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
 	    if test "$host_cpu" != ia64; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
-	  aCC*)
+	  aCC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    case $host_cpu in
+	    lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+	    case "$host_cpu" in
 	    hppa*64*|ia64*)
 	      # +Z the default
 	      ;;
@@ -12906,13 +12458,9 @@
 	    ;;
 	esac
 	;;
-      interix*)
-	# This is c89, which is MS Visual C++ (no shared libs)
-	# Anyone wants to do a port?
-	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_static_CXX='-non_shared'
 	    # CC pic flag -KPIC is the default.
@@ -12923,24 +12471,18 @@
 	;;
       linux*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    # KAI C++ Compiler
 	    lt_prog_compiler_wl_CXX='--backend -Wl,'
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
-	  icpc* | ecpc*)
+	  icpc)
 	    # Intel C++
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
 	    ;;
-	  pgCC*)
-	    # Portland Group C++ compiler.
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-fpic'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	  cxx*)
+	  cxx)
 	    # Compaq C++
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
 	    # Linux and Compaq Tru64 Unix objects are PIC.
@@ -12957,7 +12499,7 @@
 	;;
       mvs*)
 	case $cc_basename in
-	  cxx*)
+	  cxx)
 	    lt_prog_compiler_pic_CXX='-W c,exportall'
 	    ;;
 	  *)
@@ -12968,14 +12510,14 @@
 	;;
       osf3* | osf4* | osf5*)
 	case $cc_basename in
-	  KCC*)
+	  KCC)
 	    lt_prog_compiler_wl_CXX='--backend -Wl,'
 	    ;;
-	  RCC*)
+	  RCC)
 	    # Rational C++ 2.4.1
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
-	  cxx*)
+	  cxx)
 	    # Digital/Compaq C++
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    # Make sure the PIC flag is empty.  It appears that all Alpha
@@ -12989,15 +12531,24 @@
 	;;
       psos*)
 	;;
+      sco*)
+	case $cc_basename in
+	  CC)
+	    lt_prog_compiler_pic_CXX='-fPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
       solaris*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.2, 5.x and Centerline C++
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-Bstatic'
 	    lt_prog_compiler_wl_CXX='-Qoption ld '
 	    ;;
-	  gcx*)
+	  gcx)
 	    # Green Hills C++ Compiler
 	    lt_prog_compiler_pic_CXX='-PIC'
 	    ;;
@@ -13007,12 +12558,12 @@
 	;;
       sunos4*)
 	case $cc_basename in
-	  CC*)
+	  CC)
 	    # Sun C++ 4.x
 	    lt_prog_compiler_pic_CXX='-pic'
 	    lt_prog_compiler_static_CXX='-Bstatic'
 	    ;;
-	  lcc*)
+	  lcc)
 	    # Lucid
 	    lt_prog_compiler_pic_CXX='-pic'
 	    ;;
@@ -13022,7 +12573,7 @@
 	;;
       tandem*)
 	case $cc_basename in
-	  NCC*)
+	  NCC)
 	    # NonStop-UX NCC 3.20
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    ;;
@@ -13030,14 +12581,7 @@
 	    ;;
 	esac
 	;;
-      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	esac
+      unixware*)
 	;;
       vxworks*)
 	;;
@@ -13070,20 +12614,18 @@
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13076: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12620: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13080: \$? = $ac_status" >&5
+   echo "$as_me:12624: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
        lt_prog_compiler_pic_works_CXX=yes
      fi
    fi
@@ -13104,7 +12646,7 @@
 fi
 
 fi
-case $host_os in
+case "$host_os" in
   # For platforms which do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_CXX=
@@ -13114,48 +12656,6 @@
     ;;
 esac
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works_CXX=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_CXX=yes
-       fi
-     else
-       lt_prog_compiler_static_works_CXX=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6
-
-if test x"$lt_prog_compiler_static_works_CXX" = xyes; then
-    :
-else
-    lt_prog_compiler_static_CXX=
-fi
-
-
 echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
 if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
@@ -13174,25 +12674,23 @@
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13180: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12680: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13184: \$? = $ac_status" >&5
+   echo "$as_me:12684: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+     if test ! -s out/conftest.err; then
        lt_cv_prog_compiler_c_o_CXX=yes
      fi
    fi
-   chmod u+w . 2>&5
+   chmod u+w .
    $rm conftest*
    # SGI C++ compiler will create directory out/ii_files/ for
    # template instantiation
@@ -13247,7 +12745,7 @@
     export_symbols_cmds_CXX="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
-    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
   *)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
@@ -13258,6 +12756,11 @@
 echo "${ECHO_T}$ld_shlibs_CXX" >&6
 test "$ld_shlibs_CXX" = no && can_build_shared=no
 
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
 #
 # Do we need to explicitly link libc?
 #
@@ -13290,7 +12793,6 @@
         libobjs=conftest.$ac_objext
         deplibs=
         wl=$lt_prog_compiler_wl_CXX
-	pic_flag=$lt_prog_compiler_pic_CXX
         compiler_flags=-v
         linker_flags=-v
         verstring=
@@ -13423,7 +12925,7 @@
   shlibpath_var=LIBRARY_PATH
   ;;
 
-bsdi[45]*)
+bsdi4*)
   version_type=linux
   need_version=no
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -13451,8 +12953,7 @@
       dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
+      $install_prog $dir/$dlname \$dldir/$dlname'
     postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
       dlpath=$dir/\$dldll~
        $rm \$dlpath'
@@ -13482,7 +12983,7 @@
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
       ;;
     esac
     ;;
@@ -13505,7 +13006,7 @@
   soname_spec='${libname}${release}${major}$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
   # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
   if test "$GCC" = yes; then
     sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
@@ -13540,17 +13041,8 @@
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
@@ -13568,19 +13060,14 @@
   freebsd2*)
     shlibpath_overrides_runpath=yes
     ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
+  freebsd3.01* | freebsdelf3.01*)
     shlibpath_overrides_runpath=yes
     hardcode_into_libs=yes
     ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+  *) # from 3.2 on
     shlibpath_overrides_runpath=no
     hardcode_into_libs=yes
     ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
   esac
   ;;
 
@@ -13600,7 +13087,7 @@
   version_type=sunos
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
+  case "$host_cpu" in
   ia64*)
     shrext_cmds='.so'
     hardcode_into_libs=yes
@@ -13640,18 +13127,6 @@
   postinstall_cmds='chmod 555 $lib'
   ;;
 
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
 irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
@@ -13709,10 +13184,31 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 13191 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -13773,13 +13269,8 @@
 
 openbsd*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
+  need_version=yes
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
@@ -13817,6 +13308,13 @@
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
 solaris*)
   version_type=linux
   need_lib_prefix=no
@@ -13842,7 +13340,7 @@
   need_version=yes
   ;;
 
-sysv4 | sysv4.3*)
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
   soname_spec='${libname}${release}${shared_ext}$major'
@@ -13875,29 +13373,6 @@
   fi
   ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
 uts4*)
   version_type=linux
   library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
@@ -13913,17 +13388,12 @@
 echo "${ECHO_T}$dynamic_linker" >&6
 test "$dynamic_linker" = no && can_build_shared=no
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
 echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" || \
-   test -n "$runpath_var_CXX" || \
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+   test -n "$runpath_var CXX" || \
+   test "X$hardcode_automatic_CXX"="Xyes" ; then
 
   # We can hardcode non-existant directories.
   if test "$hardcode_direct_CXX" != no &&
@@ -13955,4053 +13425,4097 @@
   enable_fast_install=needless
 fi
 
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    compiler_CXX \
-    CC_CXX \
-    LD_CXX \
-    lt_prog_compiler_wl_CXX \
-    lt_prog_compiler_pic_CXX \
-    lt_prog_compiler_static_CXX \
-    lt_prog_compiler_no_builtin_flag_CXX \
-    export_dynamic_flag_spec_CXX \
-    thread_safe_flag_spec_CXX \
-    whole_archive_flag_spec_CXX \
-    enable_shared_with_static_runtimes_CXX \
-    old_archive_cmds_CXX \
-    old_archive_from_new_cmds_CXX \
-    predep_objects_CXX \
-    postdep_objects_CXX \
-    predeps_CXX \
-    postdeps_CXX \
-    compiler_lib_search_path_CXX \
-    archive_cmds_CXX \
-    archive_expsym_cmds_CXX \
-    postinstall_cmds_CXX \
-    postuninstall_cmds_CXX \
-    old_archive_from_expsyms_cmds_CXX \
-    allow_undefined_flag_CXX \
-    no_undefined_flag_CXX \
-    export_symbols_cmds_CXX \
-    hardcode_libdir_flag_spec_CXX \
-    hardcode_libdir_flag_spec_ld_CXX \
-    hardcode_libdir_separator_CXX \
-    hardcode_automatic_CXX \
-    module_cmds_CXX \
-    module_expsym_cmds_CXX \
-    lt_cv_prog_compiler_c_o_CXX \
-    exclude_expsyms_CXX \
-    include_expsyms_CXX; do
-
-    case $var in
-    old_archive_cmds_CXX | \
-    old_archive_from_new_cmds_CXX | \
-    archive_cmds_CXX | \
-    archive_expsym_cmds_CXX | \
-    module_cmds_CXX | \
-    module_expsym_cmds_CXX | \
-    old_archive_from_expsyms_cmds_CXX | \
-    export_symbols_cmds_CXX | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\$0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+       else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+       ;;
+   *)
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
     ;;
   esac
+fi
 
-cfgfile="$ofile"
-
-  cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_CXX
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
 
-# A C compiler.
-LTCC=$lt_LTCC
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
 
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
 
-# A language-specific compiler.
-CC=$lt_compiler_CXX
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
 
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_CXX
+  darwin*)
+  # if libdl is installed we need to link against it
+    echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-# An ERE matcher.
-EGREP=$lt_EGREP
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# The linker used to build libraries.
-LD=$lt_LD_CXX
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
 
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
 
-# A BSD-compatible nm program.
-NM=$lt_NM
+fi
 
-# A symbol stripping program
-STRIP=$lt_STRIP
+   ;;
 
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
+  *)
+    echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
+if test "${ac_cv_func_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define shl_load innocuous_shl_load
 
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shl_load (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
 
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 
-# Used on cygwin: assembler.
-AS="$AS"
+#undef shl_load
 
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
+#endif
 
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
+int
+main ()
+{
+return f != shl_load;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_CXX
+ac_cv_func_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6
+if test $ac_cv_func_shl_load = yes; then
+  lt_cv_dlopen="shl_load"
+else
+  echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_CXX
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shl_load ();
+int
+main ()
+{
+shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dld_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
+ac_cv_lib_dld_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
+if test $ac_cv_lib_dld_shl_load = yes; then
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+  echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
+if test "${ac_cv_func_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define dlopen innocuous_dlopen
 
-# Do we need a version for libraries?
-need_version=$need_version
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlopen (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
 
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
+#undef dlopen
 
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
+#endif
 
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_CXX
+int
+main ()
+{
+return f != dlopen;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+ac_cv_func_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6
+if test $ac_cv_func_dlopen = yes; then
+  lt_cv_dlopen="dlopen"
+else
+  echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_svld_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# Library versioning type.
-version_type=$version_type
+ac_cv_lib_svld_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
+if test $ac_cv_lib_svld_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dld_link ();
+int
+main ()
+{
+dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dld_dld_link=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
+ac_cv_lib_dld_dld_link=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
+if test $ac_cv_lib_dld_dld_link = yes; then
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
 
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
 
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_CXX
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
+fi
 
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
 
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+fi
 
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_CXX
-archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
 
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_CXX
-module_expsym_cmds=$lt_module_expsym_cmds_CXX
+fi
 
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
 
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_CXX
+fi
 
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_CXX
 
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_CXX
+fi
 
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_CXX
+    ;;
+  esac
 
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
 
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_CXX
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
 
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_CXX
+    echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 14062 "configure"
+#include "confdefs.h"
 
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
+#include <stdio.h>
 
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
 
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
 
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
 
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_CXX
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_CXX
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_CXX
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_CXX
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_CXX
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
 
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+    exit (status);
+}
+EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
 
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
 
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_CXX"
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6
 
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_CXX
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 14160 "configure"
+#include "confdefs.h"
 
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_CXX
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
+#include <stdio.h>
 
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_CXX
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
 
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_CXX
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
-# ### END LIBTOOL TAG CONFIG: $tagname
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
 
-__EOF__
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
 
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
 
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
+    exit (status);
+}
+EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
   fi
 fi
+rm -fr conftest*
 
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-
-	else
-	  tagname=""
-	fi
-	;;
-
-      F77)
-	if test -n "$F77" && test "X$F77" != "Xno"; then
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-archive_cmds_need_lc_F77=no
-allow_undefined_flag_F77=
-always_export_symbols_F77=no
-archive_expsym_cmds_F77=
-export_dynamic_flag_spec_F77=
-hardcode_direct_F77=no
-hardcode_libdir_flag_spec_F77=
-hardcode_libdir_flag_spec_ld_F77=
-hardcode_libdir_separator_F77=
-hardcode_minus_L_F77=no
-hardcode_automatic_F77=no
-module_cmds_F77=
-module_expsym_cmds_F77=
-link_all_deplibs_F77=unknown
-old_archive_cmds_F77=$old_archive_cmds
-no_undefined_flag_F77=
-whole_archive_flag_spec_F77=
-enable_shared_with_static_runtimes_F77=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
+    fi
 
-# Object file extension for compiled f77 test sources.
-objext=o
-objext_F77=$objext
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
 
-# Code to be used in simple link tests
-lt_simple_link_test_code="      program t\n      end\n"
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
 
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_CXX \
+    CC_CXX \
+    LD_CXX \
+    lt_prog_compiler_wl_CXX \
+    lt_prog_compiler_pic_CXX \
+    lt_prog_compiler_static_CXX \
+    lt_prog_compiler_no_builtin_flag_CXX \
+    export_dynamic_flag_spec_CXX \
+    thread_safe_flag_spec_CXX \
+    whole_archive_flag_spec_CXX \
+    enable_shared_with_static_runtimes_CXX \
+    old_archive_cmds_CXX \
+    old_archive_from_new_cmds_CXX \
+    predep_objects_CXX \
+    postdep_objects_CXX \
+    predeps_CXX \
+    postdeps_CXX \
+    compiler_lib_search_path_CXX \
+    archive_cmds_CXX \
+    archive_expsym_cmds_CXX \
+    postinstall_cmds_CXX \
+    postuninstall_cmds_CXX \
+    old_archive_from_expsyms_cmds_CXX \
+    allow_undefined_flag_CXX \
+    no_undefined_flag_CXX \
+    export_symbols_cmds_CXX \
+    hardcode_libdir_flag_spec_CXX \
+    hardcode_libdir_flag_spec_ld_CXX \
+    hardcode_libdir_separator_CXX \
+    hardcode_automatic_CXX \
+    module_cmds_CXX \
+    module_expsym_cmds_CXX \
+    lt_cv_prog_compiler_c_o_CXX \
+    exclude_expsyms_CXX \
+    include_expsyms_CXX; do
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+    case $var in
+    old_archive_cmds_CXX | \
+    old_archive_from_new_cmds_CXX | \
+    archive_cmds_CXX | \
+    archive_expsym_cmds_CXX | \
+    module_cmds_CXX | \
+    module_expsym_cmds_CXX | \
+    old_archive_from_expsyms_cmds_CXX | \
+    export_symbols_cmds_CXX | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
 
+cfgfile="$ofile"
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
 
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-compiler_F77=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
 
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
 
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
 
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
 
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
-  test "$enable_shared" = yes && enable_static=no
-  if test -n "$RANLIB"; then
-    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-    postinstall_cmds='$RANLIB $lib'
-  fi
-  ;;
-aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
-  ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
 
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
 
-GCC_F77="$G77"
-LD_F77="$LD"
+# The host system.
+host_alias=$host_alias
+host=$host
 
-lt_prog_compiler_wl_F77=
-lt_prog_compiler_pic_F77=
-lt_prog_compiler_static_F77=
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
 
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
 
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl_F77='-Wl,'
-    lt_prog_compiler_static_F77='-static'
+# A C compiler.
+LTCC=$lt_LTCC
 
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_F77='-Bstatic'
-      fi
-      ;;
+# A language-specific compiler.
+CC=$lt_compiler_CXX
 
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
-      ;;
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_CXX
 
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
+# An ERE matcher.
+EGREP=$lt_EGREP
 
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
-      ;;
+# The linker used to build libraries.
+LD=$lt_LD_CXX
 
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_F77='-fno-common'
-      ;;
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
 
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
+# A BSD-compatible nm program.
+NM=$lt_NM
 
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared_F77=no
-      enable_shared=no
-      ;;
+# A symbol stripping program
+STRIP=$lt_STRIP
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_F77=-Kconform_pic
-      fi
-      ;;
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
 
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_F77='-fPIC'
-	;;
-      esac
-      ;;
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
 
-    *)
-      lt_prog_compiler_pic_F77='-fPIC'
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_F77='-Bstatic'
-      else
-	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic_F77='-qnocommon'
-         lt_prog_compiler_wl_F77='-Wl,'
-         ;;
-       esac
-       ;;
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
 
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
-      ;;
+# Used on cygwin: assembler.
+AS="$AS"
 
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_F77='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
-      ;;
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
 
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static_F77='-non_shared'
-      ;;
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
 
-    newsos6)
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
 
-    linux*)
-      case $cc_basename in
-      icc* | ecc*)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-KPIC'
-	lt_prog_compiler_static_F77='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-fpic'
-	lt_prog_compiler_static_F77='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl_F77='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static_F77='-non_shared'
-        ;;
-      esac
-      ;;
+# Object file suffix (normally "o").
+objext="$ac_objext"
 
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static_F77='-non_shared'
-      ;;
+# Old archive suffix (normally "a").
+libext="$libext"
 
-    solaris*)
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_F77='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_F77='-Wl,';;
-      esac
-      ;;
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
 
-    sunos4*)
-      lt_prog_compiler_wl_F77='-Qoption ld '
-      lt_prog_compiler_pic_F77='-PIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
+# Executable file suffix (normally "").
+exeext="$exeext"
 
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+pic_mode=$pic_mode
 
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic_F77='-Kconform_pic'
-	lt_prog_compiler_static_F77='-Bstatic'
-      fi
-      ;;
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
 
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
 
-    unicos*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
 
-    uts4*)
-      lt_prog_compiler_pic_F77='-pic'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
 
-    *)
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
-    esac
-  fi
+# Do we need a version for libraries?
+need_version=$need_version
 
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
 
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_F77"; then
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
 
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_pic_works_F77=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_F77"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14750: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:14754: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_F77=yes
-     fi
-   fi
-   $rm conftest*
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
 
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
 
-if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
-    case $lt_prog_compiler_pic_F77 in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
-     esac
-else
-    lt_prog_compiler_pic_F77=
-     lt_prog_compiler_can_build_shared_F77=no
-fi
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
 
-fi
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_F77=
-    ;;
-  *)
-    lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
-    ;;
-esac
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works_F77=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_F77=yes
-       fi
-     else
-       lt_prog_compiler_static_works_F77=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
 
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
 
-if test x"$lt_prog_compiler_static_works_F77" = xyes; then
-    :
-else
-    lt_prog_compiler_static_F77=
-fi
+# Library versioning type.
+version_type=$version_type
 
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
 
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_c_o_F77=no
-   $rm -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14854: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:14858: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_F77=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $rm conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
-   $rm out/* && rmdir out
-   cd ..
-   rmdir conftest
-   $rm conftest*
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
 
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_CXX
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
 
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
-  if test "$hard_links" = no; then
-    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
 
-  runpath_var=
-  allow_undefined_flag_F77=
-  enable_shared_with_static_runtimes_F77=no
-  archive_cmds_F77=
-  archive_expsym_cmds_F77=
-  old_archive_From_new_cmds_F77=
-  old_archive_from_expsyms_cmds_F77=
-  export_dynamic_flag_spec_F77=
-  whole_archive_flag_spec_F77=
-  thread_safe_flag_spec_F77=
-  hardcode_libdir_flag_spec_F77=
-  hardcode_libdir_flag_spec_ld_F77=
-  hardcode_libdir_separator_F77=
-  hardcode_direct_F77=no
-  hardcode_minus_L_F77=no
-  hardcode_shlibpath_var_F77=unsupported
-  link_all_deplibs_F77=unknown
-  hardcode_automatic_F77=no
-  module_cmds_F77=
-  module_expsym_cmds_F77=
-  always_export_symbols_F77=no
-  export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms_F77=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
 
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
 
-  ld_shlibs_F77=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_F77=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_CXX
 
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix3* | aix4* | aix5*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs_F77=no
-	cat <<EOF 1>&2
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_CXX
 
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_CXX
 
-EOF
-      fi
-      ;;
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_CXX
 
-    amigaos*)
-      archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_minus_L_F77=yes
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
 
-      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
-      # that the semantics of dynamic libraries on AmigaOS, at least up
-      # to version 4, is to share data among multiple programs linked
-      # with the same dynamic library.  Since this doesn't match the
-      # behavior of shared libraries on other platforms, we can't use
-      # them.
-      ld_shlibs_F77=no
-      ;;
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
 
-    beos*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag_F77=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
 
-    cygwin* | mingw* | pw32*)
-      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      allow_undefined_flag_F77=unsupported
-      always_export_symbols_F77=no
-      enable_shared_with_static_runtimes_F77=yes
-      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
 
-      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
 
-    interix3*)
-      hardcode_direct_F77=no
-      hardcode_shlibpath_var_F77=no
-      hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec_F77='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
 
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
 
-    solaris*)
-      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
-	ld_shlibs_F77=no
-	cat <<EOF 1>&2
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
 
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
 
-EOF
-      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs_F77=no
-	cat <<_LT_EOF 1>&2
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
 
-_LT_EOF
-	;;
-	*)
-	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-	    archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-	    archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-	  else
-	    ld_shlibs_F77=no
-	  fi
-	;;
-      esac
-      ;;
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
 
-    sunos4*)
-      archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 
-    *)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-    esac
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
 
-    if test "$ld_shlibs_F77" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_F77=
-      export_dynamic_flag_spec_F77=
-      whole_archive_flag_spec_F77=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag_F77=unsupported
-      always_export_symbols_F77=yes
-      archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L_F77=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct_F77=unsupported
-      fi
-      ;;
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
-    aix4* | aix5*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-	  export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_CXX
 
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
-	  for ld_flag in $LDFLAGS; do
-  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-  	    aix_use_runtimelinking=yes
-  	    break
-  	  fi
-	  done
-	  ;;
-	esac
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
 
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
 
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_CXX
 
-      archive_cmds_F77=''
-      hardcode_direct_F77=yes
-      hardcode_libdir_separator_F77=':'
-      link_all_deplibs_F77=yes
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
 
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" && \
-  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
-	  then
-  	  # We have reworked collect2
-  	  hardcode_direct_F77=yes
-	  else
-  	  # We have old collect2
-  	  hardcode_direct_F77=unsupported
-  	  # It fails to find uninstalled libraries when the uninstalled
-  	  # path is not listed in the libpath.  Setting hardcode_minus_L
-  	  # to unsupported forces relinking
-  	  hardcode_minus_L_F77=yes
-  	  hardcode_libdir_flag_spec_F77='-L$libdir'
-  	  hardcode_libdir_separator_F77=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-  	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
 
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols_F77=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag_F77='-berok'
-       # Determine the default libpath from the value encoded in an empty executable.
-       cat >conftest.$ac_ext <<_ACEOF
-      program main
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
 
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_CXX"
 
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
 
-       hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
-	archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag_F77="-z nodefs"
-	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an empty executable.
-	 cat >conftest.$ac_ext <<_ACEOF
-      program main
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
 
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
 
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
 
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
 
-	 hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag_F77=' ${wl}-bernotok'
-	  allow_undefined_flag_F77=' ${wl}-berok'
-	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec_F77='$convenience'
-	  archive_cmds_need_lc_F77=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
+# ### END LIBTOOL TAG CONFIG: $tagname
 
-    amigaos*)
-      archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_minus_L_F77=yes
-      # see comment about different semantics on the GNU ld section
-      ld_shlibs_F77=no
-      ;;
+__EOF__
 
-    bsdi[45]*)
-      export_dynamic_flag_spec_F77=-rdynamic
-      ;;
 
-    cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      hardcode_libdir_flag_spec_F77=' '
-      allow_undefined_flag_F77=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      old_archive_From_new_cmds_F77='true'
-      # FIXME: Should let the user specify the lib program.
-      old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
-      enable_shared_with_static_runtimes_F77=yes
-      ;;
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
 
-    darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
-      archive_cmds_need_lc_F77=no
-      hardcode_direct_F77=no
-      hardcode_automatic_F77=yes
-      hardcode_shlibpath_var_F77=unsupported
-      whole_archive_flag_spec_F77=''
-      link_all_deplibs_F77=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_F77=no
-          ;;
-      esac
-    fi
-      ;;
 
-    dgux*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_shlibpath_var_F77=no
-      ;;
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-    freebsd1*)
-      ld_shlibs_F77=no
-      ;;
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
 
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
+	else
+	  tagname=""
+	fi
+	;;
 
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_F77=yes
-      hardcode_minus_L_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
+      F77)
+	if test -n "$F77" && test "X$F77" != "Xno"; then
 
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
-      archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
 
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      hardcode_direct_F77=yes
 
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L_F77=yes
-      export_dynamic_flag_spec_F77='${wl}-E'
-      ;;
+archive_cmds_need_lc_F77=no
+allow_undefined_flag_F77=
+always_export_symbols_F77=no
+archive_expsym_cmds_F77=
+export_dynamic_flag_spec_F77=
+hardcode_direct_F77=no
+hardcode_libdir_flag_spec_F77=
+hardcode_libdir_flag_spec_ld_F77=
+hardcode_libdir_separator_F77=
+hardcode_minus_L_F77=no
+hardcode_automatic_F77=no
+module_cmds_F77=
+module_expsym_cmds_F77=
+link_all_deplibs_F77=unknown
+old_archive_cmds_F77=$old_archive_cmds
+no_undefined_flag_F77=
+whole_archive_flag_spec_F77=
+enable_shared_with_static_runtimes_F77=no
 
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_F77=:
+# Source file extension for f77 test sources.
+ac_ext=f
 
-	hardcode_direct_F77=yes
-	export_dynamic_flag_spec_F77='${wl}-E'
+# Object file extension for compiled f77 test sources.
+objext=o
+objext_F77=$objext
 
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L_F77=yes
-      fi
-      ;;
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
 
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_F77=:
+# Code to be used in simple link tests
+lt_simple_link_test_code="      program t\n      end\n"
 
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_libdir_flag_spec_ld_F77='+b $libdir'
-	  hardcode_direct_F77=no
-	  hardcode_shlibpath_var_F77=no
-	  ;;
-	*)
-	  hardcode_direct_F77=yes
-	  export_dynamic_flag_spec_F77='${wl}-E'
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L_F77=yes
-	  ;;
-	esac
-      fi
-      ;;
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
-      fi
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      link_all_deplibs_F77=yes
-      ;;
+# Allow CC to be a program name with arguments.
+compiler=$CC
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    newsos6)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_F77=yes
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      hardcode_shlibpath_var_F77=no
-      ;;
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+compiler_F77=$CC
+cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
 
-    openbsd*)
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_F77='${wl}-E'
-      else
-       case $host_os in
-	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	   archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   hardcode_libdir_flag_spec_F77='-R$libdir'
-	   ;;
-	 *)
-	   archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-	   ;;
-       esac
-      fi
-      ;;
+echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $can_build_shared" >&5
+echo "${ECHO_T}$can_build_shared" >&6
 
-    os2*)
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_minus_L_F77=yes
-      allow_undefined_flag_F77=unsupported
-      archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
+echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
+test "$can_build_shared" = "no" && enable_shared=no
 
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag_F77=' -expect_unresolved \*'
-	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+aix4* | aix5*)
+  test "$enable_shared" = yes && enable_static=no
+  ;;
+esac
+echo "$as_me:$LINENO: result: $enable_shared" >&5
+echo "${ECHO_T}$enable_shared" >&6
+
+echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+echo "$as_me:$LINENO: result: $enable_static" >&5
+echo "${ECHO_T}$enable_static" >&6
+
+test "$ld_shlibs_F77" = no && can_build_shared=no
+
+GCC_F77="$G77"
+LD_F77="$LD"
+
+lt_prog_compiler_wl_F77=
+lt_prog_compiler_pic_F77=
+lt_prog_compiler_static_F77=
+
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_F77='-Wl,'
+    lt_prog_compiler_static_F77='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
       fi
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
       ;;
 
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag_F77=' -expect_unresolved \*'
-	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
+      ;;
 
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec_F77='-rpath $libdir'
-      fi
-      hardcode_libdir_separator_F77=:
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
       ;;
 
-    solaris*)
-      no_undefined_flag_F77=' -z text'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
-      else
-	wlarc=''
-	archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_F77='-fno-common'
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_F77=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_F77=-Kconform_pic
       fi
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_shlibpath_var_F77=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case "$host_cpu" in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
       *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
+	lt_prog_compiler_pic_F77='-fPIC'
+	;;
       esac
-      link_all_deplibs_F77=yes
       ;;
 
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+    *)
+      lt_prog_compiler_pic_F77='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
       else
-	archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
       fi
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_direct_F77=yes
-      hardcode_minus_L_F77=yes
-      hardcode_shlibpath_var_F77=no
       ;;
 
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_F77=yes # is this really true???
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case "$host_cpu" in
+      hppa*64*|ia64*)
+	# +Z the default
 	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds_F77='$CC -r -o $output$reload_objs'
-	  hardcode_direct_F77=no
-        ;;
-	motorola)
-	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
+      *)
+	lt_prog_compiler_pic_F77='+Z'
 	;;
       esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var_F77=no
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
       ;;
 
-    sysv4.3*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var_F77=no
-      export_dynamic_flag_spec_F77='-Bexport'
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_F77='-non_shared'
       ;;
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var_F77=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs_F77=yes
-      fi
+    newsos6)
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
       ;;
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
-      no_undefined_flag_F77='${wl}-z,text'
-      archive_cmds_need_lc_F77=no
-      hardcode_shlibpath_var_F77=no
-      runpath_var='LD_RUN_PATH'
+    linux*)
+      case $CC in
+      icc* | ecc*)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-KPIC'
+	lt_prog_compiler_static_F77='-static'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_F77='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_F77='-non_shared'
+        ;;
+      esac
+      ;;
 
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_F77='-non_shared'
       ;;
 
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag_F77='${wl}-z,text'
-      allow_undefined_flag_F77='${wl}-z,nodefs'
-      archive_cmds_need_lc_F77=no
-      hardcode_shlibpath_var_F77=no
-      hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      hardcode_libdir_separator_F77=':'
-      link_all_deplibs_F77=yes
-      export_dynamic_flag_spec_F77='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
+    sco3.2v5*)
+      lt_prog_compiler_pic_F77='-Kpic'
+      lt_prog_compiler_static_F77='-dn'
+      ;;
 
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+    solaris*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl_F77='-Qoption ld '
+      lt_prog_compiler_pic_F77='-PIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_F77='-Kconform_pic'
+	lt_prog_compiler_static_F77='-Bstatic'
       fi
       ;;
 
     uts4*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_shlibpath_var_F77=no
+      lt_prog_compiler_pic_F77='-pic'
+      lt_prog_compiler_static_F77='-Bstatic'
       ;;
 
     *)
-      ld_shlibs_F77=no
+      lt_prog_compiler_can_build_shared_F77=no
       ;;
     esac
   fi
 
-echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
-echo "${ECHO_T}$ld_shlibs_F77" >&6
-test "$ld_shlibs_F77" = no && can_build_shared=no
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6
 
 #
-# Do we need to explicitly link libc?
+# Check to make sure the PIC flag actually works.
 #
-case "x$archive_cmds_need_lc_F77" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_F77=yes
+if test -n "$lt_prog_compiler_pic_F77"; then
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_F77 in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
-      $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_prog_compiler_pic_works_F77=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_F77"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:14987: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:14991: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
+       lt_prog_compiler_pic_works_F77=yes
+     fi
+   fi
+   $rm conftest*
 
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl_F77
-	pic_flag=$lt_prog_compiler_pic_F77
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag_F77
-        allow_undefined_flag_F77=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc_F77=no
-        else
-	  archive_cmds_need_lc_F77=yes
-        fi
-        allow_undefined_flag_F77=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $rm conftest*
-      echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6
-      ;;
-    esac
-  fi
-  ;;
-esac
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6
 
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
+if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
+    case $lt_prog_compiler_pic_F77 in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
+     esac
 else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+    lt_prog_compiler_pic_F77=
+     lt_prog_compiler_can_build_shared_F77=no
 fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
+fi
+case "$host_os" in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_F77=
+    ;;
+  *)
+    lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
+    ;;
+esac
 
-aix4* | aix5*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o_F77=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-  ;;
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:15047: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:15051: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test ! -s out/conftest.err; then
+       lt_cv_prog_compiler_c_o_F77=yes
+     fi
+   fi
+   chmod u+w .
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
 
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6
 
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
 
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+  if test "$hard_links" = no; then
+    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
 
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $rm \$dlpath'
-    shlibpath_overrides_runpath=yes
+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    ;;
+  runpath_var=
+  allow_undefined_flag_F77=
+  enable_shared_with_static_runtimes_F77=no
+  archive_cmds_F77=
+  archive_expsym_cmds_F77=
+  old_archive_From_new_cmds_F77=
+  old_archive_from_expsyms_cmds_F77=
+  export_dynamic_flag_spec_F77=
+  whole_archive_flag_spec_F77=
+  thread_safe_flag_spec_F77=
+  hardcode_libdir_flag_spec_F77=
+  hardcode_libdir_flag_spec_ld_F77=
+  hardcode_libdir_separator_F77=
+  hardcode_direct_F77=no
+  hardcode_minus_L_F77=no
+  hardcode_shlibpath_var_F77=unsupported
+  link_all_deplibs_F77=unknown
+  hardcode_automatic_F77=no
+  module_cmds_F77=
+  module_expsym_cmds_F77=
+  always_export_symbols_F77=no
+  export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_F77=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
 
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
     ;;
   esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
+  ld_shlibs_F77=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
 
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_F77=no
+	cat <<EOF 1>&2
 
-freebsd1*)
-  dynamic_linker=no
-  ;;
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
 
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
+EOF
+      fi
+      ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
+    amigaos*)
+      archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+
+      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      ld_shlibs_F77=no
       ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_F77=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
       ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=no
+      enable_shared_with_static_runtimes_F77=yes
+      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_F77=no
+	cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    sunos4*)
+      archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds_F77="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+      else
+        archive_expsym_cmds_F77="$tmp_archive_cmds"
+      fi
     else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      ld_shlibs_F77=no
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-   hppa*64*)
-     shrext_cmds='.sl'
-     hardcode_into_libs=yes
-     dynamic_linker="$host_os dld.sl"
-     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-     soname_spec='${libname}${release}${shared_ext}$major'
-     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-     ;;
-   *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
     ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
     esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
+    if test "$ld_shlibs_F77" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec_F77='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec_F77=
+      fi
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=yes
+      archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_F77=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_F77=unsupported
+      fi
+      ;;
 
-# This must be Linux ELF.
-linux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+	  export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+	  for ld_flag in $LDFLAGS; do
+  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+  	    aix_use_runtimelinking=yes
+  	    break
+  	  fi
+	  done
+	esac
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
 
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
+      archive_cmds_F77=''
+      hardcode_direct_F77=yes
+      hardcode_libdir_separator_F77=':'
+      link_all_deplibs_F77=yes
 
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
+      if test "$GCC" = yes; then
+	case $host_os in aix4.012|aix4.012.*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" && \
+  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	  then
+  	  # We have reworked collect2
+  	  hardcode_direct_F77=yes
+	  else
+  	  # We have old collect2
+  	  hardcode_direct_F77=unsupported
+  	  # It fails to find uninstalled libraries when the uninstalled
+  	  # path is not listed in the libpath.  Setting hardcode_minus_L
+  	  # to unsupported forces relinking
+  	  hardcode_minus_L_F77=yes
+  	  hardcode_libdir_flag_spec_F77='-L$libdir'
+  	  hardcode_libdir_separator_F77=
+	  fi
+	esac
+	shared_flag='-shared'
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+  	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+  	if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+  	fi
+	fi
+      fi
 
-nto-qnx*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_F77=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag_F77='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat >conftest.$ac_ext <<_ACEOF
+      program main
 
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_f77_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
 
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
+       hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+	archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_F77="-z nodefs"
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+      program main
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_f77_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
 
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      export_dynamic_flag_spec='${wl}-Blargedynsym'
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_F77=' ${wl}-bernotok'
+	  allow_undefined_flag_F77=' ${wl}-berok'
+	  # -bexpall does not export symbols beginning with underscore (_)
+	  always_export_symbols_F77=yes
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec_F77=' '
+	  archive_cmds_need_lc_F77=yes
+	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
       ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+
+    amigaos*)
+      archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs_F77=no
       ;;
-  esac
-  ;;
 
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
+    bsdi4*)
+      export_dynamic_flag_spec_F77=-rdynamic
+      ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec_F77=' '
+      allow_undefined_flag_F77=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_From_new_cmds_F77='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_F77=yes
+      ;;
 
-*)
-  dynamic_linker=no
-  ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
+    darwin* | rhapsody*)
+    if test "$GXX" = yes ; then
+      archive_cmds_need_lc_F77=no
+      case "$host_os" in
+      rhapsody* | darwin1.[012])
+	allow_undefined_flag_F77='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag_F77='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag_F77='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag_F77='-undefined dynamic_lookup'
+            ;;
+        esac
+      fi
+	;;
+      esac
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  archive_cmds_F77='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        archive_cmds_F77='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      module_cmds_F77='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      hardcode_direct_F77=no
+      hardcode_automatic_F77=yes
+      hardcode_shlibpath_var_F77=unsupported
+      whole_archive_flag_spec_F77='-all_load $convenience'
+      link_all_deplibs_F77=yes
+    else
+      ld_shlibs_F77=no
+    fi
+      ;;
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
+    dgux*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_F77=
-if test -n "$hardcode_libdir_flag_spec_F77" || \
-   test -n "$runpath_var_F77" || \
-   test "X$hardcode_automatic_F77" = "Xyes" ; then
+    freebsd1*)
+      ld_shlibs_F77=no
+      ;;
 
-  # We can hardcode non-existant directories.
-  if test "$hardcode_direct_F77" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
-     test "$hardcode_minus_L_F77" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_F77=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_F77=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_F77=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
-echo "${ECHO_T}$hardcode_action_F77" >&6
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-if test "$hardcode_action_F77" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu)
+      archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    compiler_F77 \
-    CC_F77 \
-    LD_F77 \
-    lt_prog_compiler_wl_F77 \
-    lt_prog_compiler_pic_F77 \
-    lt_prog_compiler_static_F77 \
-    lt_prog_compiler_no_builtin_flag_F77 \
-    export_dynamic_flag_spec_F77 \
-    thread_safe_flag_spec_F77 \
-    whole_archive_flag_spec_F77 \
-    enable_shared_with_static_runtimes_F77 \
-    old_archive_cmds_F77 \
-    old_archive_from_new_cmds_F77 \
-    predep_objects_F77 \
-    postdep_objects_F77 \
-    predeps_F77 \
-    postdeps_F77 \
-    compiler_lib_search_path_F77 \
-    archive_cmds_F77 \
-    archive_expsym_cmds_F77 \
-    postinstall_cmds_F77 \
-    postuninstall_cmds_F77 \
-    old_archive_from_expsyms_cmds_F77 \
-    allow_undefined_flag_F77 \
-    no_undefined_flag_F77 \
-    export_symbols_cmds_F77 \
-    hardcode_libdir_flag_spec_F77 \
-    hardcode_libdir_flag_spec_ld_F77 \
-    hardcode_libdir_separator_F77 \
-    hardcode_automatic_F77 \
-    module_cmds_F77 \
-    module_expsym_cmds_F77 \
-    lt_cv_prog_compiler_c_o_F77 \
-    exclude_expsyms_F77 \
-    include_expsyms_F77; do
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_direct_F77=yes
 
-    case $var in
-    old_archive_cmds_F77 | \
-    old_archive_from_new_cmds_F77 | \
-    archive_cmds_F77 | \
-    archive_expsym_cmds_F77 | \
-    module_cmds_F77 | \
-    module_expsym_cmds_F77 | \
-    old_archive_from_expsyms_cmds_F77 | \
-    export_symbols_cmds_F77 | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_F77=yes
+      export_dynamic_flag_spec_F77='${wl}-E'
       ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\$0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
-    ;;
-  esac
 
-cfgfile="$ofile"
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	case "$host_cpu" in
+	hppa*64*)
+	  hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_flag_spec_ld_F77='+b $libdir'
+	  hardcode_libdir_separator_F77=:
+	  hardcode_direct_F77=no
+	  hardcode_shlibpath_var_F77=no
+	  ;;
+	ia64*)
+	  hardcode_libdir_flag_spec_F77='-L$libdir'
+	  hardcode_direct_F77=no
+	  hardcode_shlibpath_var_F77=no
 
-  cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_F77=yes
+	  ;;
+	*)
+	  hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_separator_F77=:
+	  hardcode_direct_F77=yes
+	  export_dynamic_flag_spec_F77='${wl}-E'
 
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_F77=yes
+	  ;;
+	esac
+      fi
+      ;;
 
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      link_all_deplibs_F77=yes
+      ;;
 
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
+    newsos6)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_F77
+    openbsd*)
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	export_dynamic_flag_spec_F77='${wl}-E'
+      else
+       case $host_os in
+	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	   archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	   hardcode_libdir_flag_spec_F77='-R$libdir'
+	   ;;
+	 *)
+	   archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	   hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	   ;;
+       esac
+      fi
+      ;;
 
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
+    os2*)
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+      allow_undefined_flag_F77=unsupported
+      archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
 
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      ;;
 
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
 
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_F77='-rpath $libdir'
+      fi
+      hardcode_libdir_separator_F77=:
+      ;;
 
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
+    sco3.2v5*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_F77=no
+      export_dynamic_flag_spec_F77='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
 
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
+    solaris*)
+      no_undefined_flag_F77=' -z text'
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+	archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_shlibpath_var_F77=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
+      esac
+      link_all_deplibs_F77=yes
+      ;;
 
-# A C compiler.
-LTCC=$lt_LTCC
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_F77='$CC -r -o $output$reload_objs'
+	  hardcode_direct_F77=no
+        ;;
+	motorola)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-# A language-specific compiler.
-CC=$lt_compiler_F77
+    sysv4.3*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_F77=no
+      export_dynamic_flag_spec_F77='-Bexport'
+      ;;
 
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_F77
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_F77=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_F77=yes
+      fi
+      ;;
 
-# An ERE matcher.
-EGREP=$lt_EGREP
+    sysv4.2uw2*)
+      archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=no
+      hardcode_shlibpath_var_F77=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
 
-# The linker used to build libraries.
-LD=$lt_LD_F77
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
+      no_undefined_flag_F77='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
+    sysv5*)
+      no_undefined_flag_F77=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+  		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      hardcode_libdir_flag_spec_F77=
+      hardcode_shlibpath_var_F77=no
+      runpath_var='LD_RUN_PATH'
+      ;;
 
-# A BSD-compatible nm program.
-NM=$lt_NM
+    uts4*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-# A symbol stripping program
-STRIP=$lt_STRIP
+    *)
+      ld_shlibs_F77=no
+      ;;
+    esac
+  fi
 
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
+echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
+echo "${ECHO_T}$ld_shlibs_F77" >&6
+test "$ld_shlibs_F77" = no && can_build_shared=no
 
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
 
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_F77" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_F77=yes
 
-# Used on cygwin: assembler.
-AS="$AS"
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_F77 in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
+      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_F77
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_F77
+        allow_undefined_flag_F77=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_F77=no
+        else
+	  archive_cmds_need_lc_F77=yes
+        fi
+        allow_undefined_flag_F77=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6
+      ;;
+    esac
+  fi
+  ;;
+esac
 
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_F77
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
 
-# Object file suffix (normally "o").
-objext="$ac_objext"
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
 
-# Old archive suffix (normally "a").
-libext="$libext"
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
 
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
 
-# Executable file suffix (normally "").
-exeext="$exeext"
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
 
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_F77
-pic_mode=$pic_mode
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
 
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
 
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
+bsdi4*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
 
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
 
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
 
-# Do we need a version for libraries?
-need_version=$need_version
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
 
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
 
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_F77
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
+freebsd1*)
+  dynamic_linker=no
+  ;;
 
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
 
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.01* | freebsdelf3.01*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
 
-# Library versioning type.
-version_type=$version_type
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
 
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case "$host_cpu" in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
 
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
 
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
 
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_F77
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
 
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 16361 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
 
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+  fi
 
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_F77
-archive_expsym_cmds=$lt_archive_expsym_cmds_F77
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
 
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_F77
-module_expsym_cmds=$lt_module_expsym_cmds_F77
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
 
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
 
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_F77
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
 
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_F77
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
 
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_F77
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_F77
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_F77
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_F77
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=yes
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
 
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_F77
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
 
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
 
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
 
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
 
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_F77
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
 
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_F77
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
 
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_F77
+*)
+  dynamic_linker=no
+  ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
 
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action_F77=
+if test -n "$hardcode_libdir_flag_spec_F77" || \
+   test -n "$runpath_var F77" || \
+   test "X$hardcode_automatic_F77"="Xyes" ; then
 
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_F77
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct_F77" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
+     test "$hardcode_minus_L_F77" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_F77=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_F77=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_F77=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
+echo "${ECHO_T}$hardcode_action_F77" >&6
 
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+if test "$hardcode_action_F77" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
 
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+       else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+       ;;
+   *)
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+    ;;
+  esac
+fi
 
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_F77"
 
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_F77
 
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_F77
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_F77 \
+    CC_F77 \
+    LD_F77 \
+    lt_prog_compiler_wl_F77 \
+    lt_prog_compiler_pic_F77 \
+    lt_prog_compiler_static_F77 \
+    lt_prog_compiler_no_builtin_flag_F77 \
+    export_dynamic_flag_spec_F77 \
+    thread_safe_flag_spec_F77 \
+    whole_archive_flag_spec_F77 \
+    enable_shared_with_static_runtimes_F77 \
+    old_archive_cmds_F77 \
+    old_archive_from_new_cmds_F77 \
+    predep_objects_F77 \
+    postdep_objects_F77 \
+    predeps_F77 \
+    postdeps_F77 \
+    compiler_lib_search_path_F77 \
+    archive_cmds_F77 \
+    archive_expsym_cmds_F77 \
+    postinstall_cmds_F77 \
+    postuninstall_cmds_F77 \
+    old_archive_from_expsyms_cmds_F77 \
+    allow_undefined_flag_F77 \
+    no_undefined_flag_F77 \
+    export_symbols_cmds_F77 \
+    hardcode_libdir_flag_spec_F77 \
+    hardcode_libdir_flag_spec_ld_F77 \
+    hardcode_libdir_separator_F77 \
+    hardcode_automatic_F77 \
+    module_cmds_F77 \
+    module_expsym_cmds_F77 \
+    lt_cv_prog_compiler_c_o_F77 \
+    exclude_expsyms_F77 \
+    include_expsyms_F77; do
 
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_F77
+    case $var in
+    old_archive_cmds_F77 | \
+    old_archive_from_new_cmds_F77 | \
+    archive_cmds_F77 | \
+    archive_expsym_cmds_F77 | \
+    module_cmds_F77 | \
+    module_expsym_cmds_F77 | \
+    old_archive_from_expsyms_cmds_F77 | \
+    export_symbols_cmds_F77 | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
 
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_F77
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
 
-# ### END LIBTOOL TAG CONFIG: $tagname
+cfgfile="$ofile"
 
-__EOF__
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
 
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
-  fi
-fi
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
 
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
 
-CC="$lt_save_CC"
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_F77
 
-	else
-	  tagname=""
-	fi
-	;;
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
 
-      GCJ)
-	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
 
+# The host system.
+host_alias=$host_alias
+host=$host
 
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
 
-# Source file extension for Java test sources.
-ac_ext=java
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
 
-# Object file extension for compiled Java test sources.
-objext=o
-objext_GCJ=$objext
+# A C compiler.
+LTCC=$lt_LTCC
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
+# A language-specific compiler.
+CC=$lt_compiler_F77
 
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_F77
 
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+# An ERE matcher.
+EGREP=$lt_EGREP
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
+# The linker used to build libraries.
+LD=$lt_LD_F77
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
+# A BSD-compatible nm program.
+NM=$lt_NM
 
+# A symbol stripping program
+STRIP=$lt_STRIP
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
 
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
 
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-compiler_GCJ=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
 
+# Used on cygwin: assembler.
+AS="$AS"
 
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-archive_cmds_need_lc_GCJ=no
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
 
-old_archive_cmds_GCJ=$old_archive_cmds
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
 
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_F77
 
-lt_prog_compiler_no_builtin_flag_GCJ=
+# Object file suffix (normally "o").
+objext="$ac_objext"
 
-if test "$GCC" = yes; then
-  lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
+# Old archive suffix (normally "a").
+libext="$libext"
 
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
 
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_rtti_exceptions=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17057: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:17061: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_rtti_exceptions=yes
-     fi
-   fi
-   $rm conftest*
+# Executable file suffix (normally "").
+exeext="$exeext"
 
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_F77
+pic_mode=$pic_mode
 
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
-    lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
-else
-    :
-fi
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
 
-fi
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
 
-lt_prog_compiler_wl_GCJ=
-lt_prog_compiler_pic_GCJ=
-lt_prog_compiler_static_GCJ=
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
 
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
 
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl_GCJ='-Wl,'
-    lt_prog_compiler_static_GCJ='-static'
+# Do we need a version for libraries?
+need_version=$need_version
 
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_GCJ='-Bstatic'
-      fi
-      ;;
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
 
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
-      ;;
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
 
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
 
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
-      ;;
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_F77
 
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_GCJ='-fno-common'
-      ;;
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
 
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
 
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared_GCJ=no
-      enable_shared=no
-      ;;
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_GCJ=-Kconform_pic
-      fi
-      ;;
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
 
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_GCJ='-fPIC'
-	;;
-      esac
-      ;;
+# Library versioning type.
+version_type=$version_type
 
-    *)
-      lt_prog_compiler_pic_GCJ='-fPIC'
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_GCJ='-Bstatic'
-      else
-	lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic_GCJ='-qnocommon'
-         lt_prog_compiler_wl_GCJ='-Wl,'
-         ;;
-       esac
-       ;;
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
 
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
-      ;;
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
 
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_GCJ='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
-      ;;
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
 
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static_GCJ='-non_shared'
-      ;;
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_F77
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
 
-    newsos6)
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
 
-    linux*)
-      case $cc_basename in
-      icc* | ecc*)
-	lt_prog_compiler_wl_GCJ='-Wl,'
-	lt_prog_compiler_pic_GCJ='-KPIC'
-	lt_prog_compiler_static_GCJ='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_GCJ='-Wl,'
-	lt_prog_compiler_pic_GCJ='-fpic'
-	lt_prog_compiler_static_GCJ='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl_GCJ='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static_GCJ='-non_shared'
-        ;;
-      esac
-      ;;
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
 
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static_GCJ='-non_shared'
-      ;;
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_F77
+archive_expsym_cmds=$lt_archive_expsym_cmds_F77
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
 
-    solaris*)
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_GCJ='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_GCJ='-Wl,';;
-      esac
-      ;;
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_F77
+module_expsym_cmds=$lt_module_expsym_cmds_F77
 
-    sunos4*)
-      lt_prog_compiler_wl_GCJ='-Qoption ld '
-      lt_prog_compiler_pic_GCJ='-PIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
 
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_F77
 
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic_GCJ='-Kconform_pic'
-	lt_prog_compiler_static_GCJ='-Bstatic'
-      fi
-      ;;
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_F77
 
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_F77
 
-    unicos*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_can_build_shared_GCJ=no
-      ;;
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_F77
 
-    uts4*)
-      lt_prog_compiler_pic_GCJ='-pic'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_F77
 
-    *)
-      lt_prog_compiler_can_build_shared_GCJ=no
-      ;;
-    esac
-  fi
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
 
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
 
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_GCJ"; then
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_F77
 
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_pic_works_GCJ=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17325: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:17329: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_GCJ=yes
-     fi
-   fi
-   $rm conftest*
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_F77
 
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
 
-if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
-    case $lt_prog_compiler_pic_GCJ in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
-     esac
-else
-    lt_prog_compiler_pic_GCJ=
-     lt_prog_compiler_can_build_shared_GCJ=no
-fi
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
 
-fi
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_GCJ=
-    ;;
-  *)
-    lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
-    ;;
-esac
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works_GCJ=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_GCJ=yes
-       fi
-     else
-       lt_prog_compiler_static_works_GCJ=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_F77
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_F77
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_F77
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_F77
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_F77
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_F77"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_F77
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_F77
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_F77
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_F77
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
 
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6
 
-if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then
-    :
 else
-    lt_prog_compiler_static_GCJ=
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
 fi
 
 
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+	else
+	  tagname=""
+	fi
+	;;
+
+      GCJ)
+	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+
+
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+objext_GCJ=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String argv) {}; }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+compiler_GCJ=$CC
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+archive_cmds_need_lc_GCJ=no
+
+
+lt_prog_compiler_no_builtin_flag_GCJ=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
+
+
+echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_cv_prog_compiler_c_o_GCJ=no
-   $rm -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
+  lt_cv_prog_compiler_rtti_exceptions=no
+  ac_outfile=conftest.$ac_objext
    printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
    # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
    lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17429: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
+   (eval echo "\"\$as_me:17102: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:17433: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
+   cat conftest.err >&5
+   echo "$as_me:17106: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_GCJ=yes
+     if test ! -s conftest.err; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
      fi
    fi
-   chmod u+w . 2>&5
-   $rm conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
-   $rm out/* && rmdir out
-   cd ..
-   rmdir conftest
    $rm conftest*
 
 fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6
-
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
-  if test "$hard_links" = no; then
-    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
 else
-  need_locks=no
+    :
 fi
 
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+fi
 
-  runpath_var=
-  allow_undefined_flag_GCJ=
-  enable_shared_with_static_runtimes_GCJ=no
-  archive_cmds_GCJ=
-  archive_expsym_cmds_GCJ=
-  old_archive_From_new_cmds_GCJ=
-  old_archive_from_expsyms_cmds_GCJ=
-  export_dynamic_flag_spec_GCJ=
-  whole_archive_flag_spec_GCJ=
-  thread_safe_flag_spec_GCJ=
-  hardcode_libdir_flag_spec_GCJ=
-  hardcode_libdir_flag_spec_ld_GCJ=
-  hardcode_libdir_separator_GCJ=
-  hardcode_direct_GCJ=no
-  hardcode_minus_L_GCJ=no
-  hardcode_shlibpath_var_GCJ=unsupported
-  link_all_deplibs_GCJ=unknown
-  hardcode_automatic_GCJ=no
-  module_cmds_GCJ=
-  module_expsym_cmds_GCJ=
-  always_export_symbols_GCJ=no
-  export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms_GCJ=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
+lt_prog_compiler_wl_GCJ=
+lt_prog_compiler_pic_GCJ=
+lt_prog_compiler_static_GCJ=
 
-  ld_shlibs_GCJ=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_GCJ=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_GCJ='-Wl,'
+    lt_prog_compiler_static_GCJ='-static'
 
-    # See if GNU ld supports shared libraries.
     case $host_os in
-    aix3* | aix4* | aix5*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs_GCJ=no
-	cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_GCJ='-Bstatic'
       fi
       ;;
 
     amigaos*)
-      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_minus_L_GCJ=yes
-
-      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
-      # that the semantics of dynamic libraries on AmigaOS, at least up
-      # to version 4, is to share data among multiple programs linked
-      # with the same dynamic library.  Since this doesn't match the
-      # behavior of shared libraries on other platforms, we can't use
-      # them.
-      ld_shlibs_GCJ=no
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
       ;;
 
-    beos*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag_GCJ=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs_GCJ=no
-      fi
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
       ;;
 
-    cygwin* | mingw* | pw32*)
-      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      allow_undefined_flag_GCJ=unsupported
-      always_export_symbols_GCJ=no
-      enable_shared_with_static_runtimes_GCJ=yes
-      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
-      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs_GCJ=no
-      fi
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
       ;;
 
-    interix3*)
-      hardcode_direct_GCJ=no
-      hardcode_shlibpath_var_GCJ=no
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec_GCJ='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_GCJ='-fno-common'
       ;;
 
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_GCJ=no
-      fi
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_GCJ=no
+      enable_shared=no
       ;;
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_GCJ=-Kconform_pic
       fi
       ;;
 
-    solaris*)
-      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
-	ld_shlibs_GCJ=no
-	cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case "$host_cpu" in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_GCJ='-fPIC'
+	;;
+      esac
+      ;;
 
-EOF
-      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    *)
+      lt_prog_compiler_pic_GCJ='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_GCJ='-Bstatic'
       else
-	ld_shlibs_GCJ=no
+	lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs_GCJ=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+      ;;
 
-_LT_EOF
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case "$host_cpu" in
+      hppa*64*|ia64*)
+	# +Z the default
 	;;
-	*)
-	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-	    archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-	    archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-	  else
-	    ld_shlibs_GCJ=no
-	  fi
+      *)
+	lt_prog_compiler_pic_GCJ='+Z'
 	;;
       esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
       ;;
 
-    sunos4*)
-      archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_GCJ='-non_shared'
       ;;
 
-    *)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_GCJ=no
-      fi
+    newsos6)
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
       ;;
-    esac
 
-    if test "$ld_shlibs_GCJ" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_GCJ=
-      export_dynamic_flag_spec_GCJ=
-      whole_archive_flag_spec_GCJ=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag_GCJ=unsupported
-      always_export_symbols_GCJ=yes
-      archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L_GCJ=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct_GCJ=unsupported
-      fi
+    linux*)
+      case $CC in
+      icc* | ecc*)
+	lt_prog_compiler_wl_GCJ='-Wl,'
+	lt_prog_compiler_pic_GCJ='-KPIC'
+	lt_prog_compiler_static_GCJ='-static'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_GCJ='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_GCJ='-non_shared'
+        ;;
+      esac
       ;;
 
-    aix4* | aix5*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-	  export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
 
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
-	  for ld_flag in $LDFLAGS; do
-  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-  	    aix_use_runtimelinking=yes
-  	    break
-  	  fi
-	  done
-	  ;;
-	esac
+    sco3.2v5*)
+      lt_prog_compiler_pic_GCJ='-Kpic'
+      lt_prog_compiler_static_GCJ='-dn'
+      ;;
 
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
+    solaris*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
 
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+    sunos4*)
+      lt_prog_compiler_wl_GCJ='-Qoption ld '
+      lt_prog_compiler_pic_GCJ='-PIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
 
-      archive_cmds_GCJ=''
-      hardcode_direct_GCJ=yes
-      hardcode_libdir_separator_GCJ=':'
-      link_all_deplibs_GCJ=yes
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
 
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" && \
-  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
-	  then
-  	  # We have reworked collect2
-  	  hardcode_direct_GCJ=yes
-	  else
-  	  # We have old collect2
-  	  hardcode_direct_GCJ=unsupported
-  	  # It fails to find uninstalled libraries when the uninstalled
-  	  # path is not listed in the libpath.  Setting hardcode_minus_L
-  	  # to unsupported forces relinking
-  	  hardcode_minus_L_GCJ=yes
-  	  hardcode_libdir_flag_spec_GCJ='-L$libdir'
-  	  hardcode_libdir_separator_GCJ=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-  	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_GCJ='-Kconform_pic'
+	lt_prog_compiler_static_GCJ='-Bstatic'
       fi
+      ;;
 
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols_GCJ=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag_GCJ='-berok'
-       # Determine the default libpath from the value encoded in an empty executable.
-       cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+    uts4*)
+      lt_prog_compiler_pic_GCJ='-pic'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
 
-int
-main ()
-{
+    *)
+      lt_prog_compiler_can_build_shared_GCJ=no
+      ;;
+    esac
+  fi
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6
 
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_GCJ"; then
+
+echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  lt_prog_compiler_pic_works_GCJ=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:17335: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:17339: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test ! -s conftest.err; then
+       lt_prog_compiler_pic_works_GCJ=yes
+     fi
+   fi
+   $rm conftest*
 
 fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6
 
-       hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
-	archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag_GCJ="-z nodefs"
-	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an empty executable.
-	 cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
+    case $lt_prog_compiler_pic_GCJ in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
+     esac
+else
+    lt_prog_compiler_pic_GCJ=
+     lt_prog_compiler_can_build_shared_GCJ=no
+fi
 
-int
-main ()
-{
+fi
+case "$host_os" in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_GCJ=
+    ;;
+  *)
+    lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
+    ;;
+esac
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  lt_cv_prog_compiler_c_o_GCJ=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:17395: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:17399: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test ! -s out/conftest.err; then
+       lt_cv_prog_compiler_c_o_GCJ=yes
+     fi
+   fi
+   chmod u+w .
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
 
 fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6
 
-	 hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag_GCJ=' ${wl}-bernotok'
-	  allow_undefined_flag_GCJ=' ${wl}-berok'
-	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec_GCJ='$convenience'
-	  archive_cmds_need_lc_GCJ=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+  if test "$hard_links" = no; then
+    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+  runpath_var=
+  allow_undefined_flag_GCJ=
+  enable_shared_with_static_runtimes_GCJ=no
+  archive_cmds_GCJ=
+  archive_expsym_cmds_GCJ=
+  old_archive_From_new_cmds_GCJ=
+  old_archive_from_expsyms_cmds_GCJ=
+  export_dynamic_flag_spec_GCJ=
+  whole_archive_flag_spec_GCJ=
+  thread_safe_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_ld_GCJ=
+  hardcode_libdir_separator_GCJ=
+  hardcode_direct_GCJ=no
+  hardcode_minus_L_GCJ=no
+  hardcode_shlibpath_var_GCJ=unsupported
+  link_all_deplibs_GCJ=unknown
+  hardcode_automatic_GCJ=no
+  module_cmds_GCJ=
+  module_expsym_cmds_GCJ=
+  always_export_symbols_GCJ=no
+  export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_GCJ=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs_GCJ=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_GCJ=no
+	cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
       fi
       ;;
 
@@ -18009,1132 +17523,2279 @@
       archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
       hardcode_libdir_flag_spec_GCJ='-L$libdir'
       hardcode_minus_L_GCJ=yes
-      # see comment about different semantics on the GNU ld section
+
+      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
       ld_shlibs_GCJ=no
       ;;
 
-    bsdi[45]*)
-      export_dynamic_flag_spec_GCJ=-rdynamic
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_GCJ=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs_GCJ=no
+      fi
       ;;
 
     cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      hardcode_libdir_flag_spec_GCJ=' '
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
       allow_undefined_flag_GCJ=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      old_archive_From_new_cmds_GCJ='true'
-      # FIXME: Should let the user specify the lib program.
-      old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
+      always_export_symbols_GCJ=no
       enable_shared_with_static_runtimes_GCJ=yes
+      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+	ld_shlibs=no
+      fi
       ;;
 
-    darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
-      archive_cmds_need_lc_GCJ=no
-      hardcode_direct_GCJ=no
-      hardcode_automatic_GCJ=yes
-      hardcode_shlibpath_var_GCJ=unsupported
-      whole_archive_flag_spec_GCJ=''
-      link_all_deplibs_GCJ=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_GCJ=no
-          ;;
-      esac
-    fi
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
       ;;
 
-    dgux*)
-      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    freebsd1*)
-      ld_shlibs_GCJ=no
-      ;;
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_GCJ=no
+	cat <<EOF 1>&2
 
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_GCJ=yes
-      hardcode_minus_L_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_GCJ=no
+      fi
       ;;
 
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
-      archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+    sunos4*)
+      archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
       hardcode_direct_GCJ=yes
       hardcode_shlibpath_var_GCJ=no
       ;;
 
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+  linux*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds_GCJ="$tmp_archive_cmds"
+      supports_anon_versioning=no
+      case `$LD -v 2>/dev/null` in
+        *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+        *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+        *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+        *\ 2.11.*) ;; # other 2.11 versions
+        *) supports_anon_versioning=yes ;;
+      esac
+      if test $supports_anon_versioning = yes; then
+        archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
+cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+$echo "local: *; };" >> $output_objdir/$libname.ver~
+        $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
       else
-	archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+        archive_expsym_cmds_GCJ="$tmp_archive_cmds"
       fi
-      hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      hardcode_direct_GCJ=yes
-
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L_GCJ=yes
-      export_dynamic_flag_spec_GCJ='${wl}-E'
-      ;;
+    else
+      ld_shlibs_GCJ=no
+    fi
+    ;;
 
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
       else
-	archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_GCJ=:
-
-	hardcode_direct_GCJ=yes
-	export_dynamic_flag_spec_GCJ='${wl}-E'
-
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L_GCJ=yes
+	ld_shlibs_GCJ=no
       fi
       ;;
+    esac
 
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
+    if test "$ld_shlibs_GCJ" = yes; then
+      runpath_var=LD_RUN_PATH
+      hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
+      export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+ 	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
       else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
+  	whole_archive_flag_spec_GCJ=
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_GCJ=:
-
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
-	  hardcode_direct_GCJ=no
-	  hardcode_shlibpath_var_GCJ=no
-	  ;;
-	*)
-	  hardcode_direct_GCJ=yes
-	  export_dynamic_flag_spec_GCJ='${wl}-E'
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L_GCJ=yes
-	  ;;
-	esac
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_GCJ=unsupported
+      always_export_symbols_GCJ=yes
+      archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_GCJ=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_GCJ=unsupported
       fi
       ;;
 
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
       else
-	archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
-      fi
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      link_all_deplibs_GCJ=yes
-      ;;
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+	  export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+	  for ld_flag in $LDFLAGS; do
+  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+  	    aix_use_runtimelinking=yes
+  	    break
+  	  fi
+	  done
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
       fi
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
 
-    newsos6)
-      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_GCJ=yes
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      hardcode_shlibpath_var_GCJ=no
-      ;;
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
-    openbsd*)
+      archive_cmds_GCJ=''
       hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_GCJ='${wl}-E'
-      else
-       case $host_os in
-	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	   archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   hardcode_libdir_flag_spec_GCJ='-R$libdir'
-	   ;;
-	 *)
-	   archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
-	   ;;
-       esac
-      fi
-      ;;
-
-    os2*)
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_minus_L_GCJ=yes
-      allow_undefined_flag_GCJ=unsupported
-      archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
+      hardcode_libdir_separator_GCJ=':'
+      link_all_deplibs_GCJ=yes
 
-    osf3*)
       if test "$GCC" = yes; then
-	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	case $host_os in aix4.012|aix4.012.*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" && \
+  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	  then
+  	  # We have reworked collect2
+  	  hardcode_direct_GCJ=yes
+	  else
+  	  # We have old collect2
+  	  hardcode_direct_GCJ=unsupported
+  	  # It fails to find uninstalled libraries when the uninstalled
+  	  # path is not listed in the libpath.  Setting hardcode_minus_L
+  	  # to unsupported forces relinking
+  	  hardcode_minus_L_GCJ=yes
+  	  hardcode_libdir_flag_spec_GCJ='-L$libdir'
+  	  hardcode_libdir_separator_GCJ=
+	  fi
+	esac
+	shared_flag='-shared'
       else
-	allow_undefined_flag_GCJ=' -expect_unresolved \*'
-	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+  	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+  	if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+  	fi
+	fi
       fi
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      ;;
 
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag_GCJ=' -expect_unresolved \*'
-	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_GCJ=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag_GCJ='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
-      fi
-      hardcode_libdir_separator_GCJ=:
-      ;;
+int
+main ()
+{
 
-    solaris*)
-      no_undefined_flag_GCJ=' -z text'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
-      else
-	wlarc=''
-	archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+	archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_GCJ="-z nodefs"
+	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_GCJ=' ${wl}-bernotok'
+	  allow_undefined_flag_GCJ=' ${wl}-berok'
+	  # -bexpall does not export symbols beginning with underscore (_)
+	  always_export_symbols_GCJ=yes
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec_GCJ=' '
+	  archive_cmds_need_lc_GCJ=yes
+	  # This is similar to how AIX traditionally builds it's shared libraries.
+	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
       fi
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
-      hardcode_shlibpath_var_GCJ=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
-      esac
-      link_all_deplibs_GCJ=yes
       ;;
 
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
+    amigaos*)
+      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
       hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_direct_GCJ=yes
       hardcode_minus_L_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_GCJ=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds_GCJ='$CC -r -o $output$reload_objs'
-	  hardcode_direct_GCJ=no
-        ;;
-	motorola)
-	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var_GCJ=no
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs_GCJ=no
       ;;
 
-    sysv4.3*)
-      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var_GCJ=no
-      export_dynamic_flag_spec_GCJ='-Bexport'
+    bsdi4*)
+      export_dynamic_flag_spec_GCJ=-rdynamic
       ;;
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var_GCJ=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs_GCJ=yes
-      fi
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec_GCJ=' '
+      allow_undefined_flag_GCJ=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_From_new_cmds_GCJ='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_GCJ=yes
       ;;
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
-      no_undefined_flag_GCJ='${wl}-z,text'
+    darwin* | rhapsody*)
+    if test "$GXX" = yes ; then
       archive_cmds_need_lc_GCJ=no
-      hardcode_shlibpath_var_GCJ=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      case "$host_os" in
+      rhapsody* | darwin1.[012])
+	allow_undefined_flag_GCJ='-undefined suppress'
+	;;
+      *) # Darwin 1.3 on
+      if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+      	allow_undefined_flag_GCJ='-flat_namespace -undefined suppress'
+      else
+        case ${MACOSX_DEPLOYMENT_TARGET} in
+          10.[012])
+            allow_undefined_flag_GCJ='-flat_namespace -undefined suppress'
+            ;;
+          10.*)
+            allow_undefined_flag_GCJ='-undefined dynamic_lookup'
+            ;;
+        esac
       fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag_GCJ='${wl}-z,text'
-      allow_undefined_flag_GCJ='${wl}-z,nodefs'
-      archive_cmds_need_lc_GCJ=no
-      hardcode_shlibpath_var_GCJ=no
-      hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      hardcode_libdir_separator_GCJ=':'
+	;;
+      esac
+    	lt_int_apple_cc_single_mod=no
+    	output_verbose_link_cmd='echo'
+    	if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
+    	  lt_int_apple_cc_single_mod=yes
+    	fi
+    	if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+    	  archive_cmds_GCJ='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+    	else
+        archive_cmds_GCJ='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      fi
+      module_cmds_GCJ='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
+        if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+          archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        else
+          archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+        fi
+          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      hardcode_direct_GCJ=no
+      hardcode_automatic_GCJ=yes
+      hardcode_shlibpath_var_GCJ=unsupported
+      whole_archive_flag_spec_GCJ='-all_load $convenience'
       link_all_deplibs_GCJ=yes
-      export_dynamic_flag_spec_GCJ='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
+    else
+      ld_shlibs_GCJ=no
+    fi
       ;;
 
-    uts4*)
+    dgux*)
       archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       hardcode_libdir_flag_spec_GCJ='-L$libdir'
       hardcode_shlibpath_var_GCJ=no
       ;;
 
-    *)
+    freebsd1*)
       ld_shlibs_GCJ=no
       ;;
-    esac
-  fi
 
-echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
-echo "${ECHO_T}$ld_shlibs_GCJ" >&6
-test "$ld_shlibs_GCJ" = no && can_build_shared=no
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
 
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_GCJ" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_GCJ=yes
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_GCJ in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu)
+      archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
       ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
-      $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl_GCJ
-	pic_flag=$lt_prog_compiler_pic_GCJ
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
-        allow_undefined_flag_GCJ=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc_GCJ=no
-        else
-	  archive_cmds_need_lc_GCJ=yes
-        fi
-        allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       else
-        cat conftest.err 1>&5
+	archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       fi
-      $rm conftest*
-      echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6
-      ;;
-    esac
-  fi
-  ;;
-esac
+      hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_direct_GCJ=yes
 
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_GCJ=yes
+      export_dynamic_flag_spec_GCJ='${wl}-E'
+      ;;
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case "$host_cpu" in
+	hppa*64*|ia64*)
+	  archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  ;;
+	*)
+	  archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	case "$host_cpu" in
+	hppa*64*)
+	  hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
+	  hardcode_libdir_separator_GCJ=:
+	  hardcode_direct_GCJ=no
+	  hardcode_shlibpath_var_GCJ=no
+	  ;;
+	ia64*)
+	  hardcode_libdir_flag_spec_GCJ='-L$libdir'
+	  hardcode_direct_GCJ=no
+	  hardcode_shlibpath_var_GCJ=no
 
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_GCJ=yes
+	  ;;
+	*)
+	  hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_separator_GCJ=:
+	  hardcode_direct_GCJ=yes
+	  export_dynamic_flag_spec_GCJ='${wl}-E'
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_GCJ=yes
+	  ;;
+	esac
+      fi
+      ;;
 
-aix4* | aix5*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
-	:
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
       else
-	can_build_shared=no
+	archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
       fi
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      link_all_deplibs_GCJ=yes
       ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
 
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-  ;;
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
 
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
+    newsos6)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_shlibpath_var_GCJ=no
+      ;;
 
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+    openbsd*)
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+	export_dynamic_flag_spec_GCJ='${wl}-E'
+      else
+       case $host_os in
+	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	   archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	   hardcode_libdir_flag_spec_GCJ='-R$libdir'
+	   ;;
+	 *)
+	   archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	   hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+	   ;;
+       esac
+      fi
+      ;;
 
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $rm \$dlpath'
-    shlibpath_overrides_runpath=yes
+    os2*)
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+      allow_undefined_flag_GCJ=unsupported
+      archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag_GCJ=' -expect_unresolved \*'
+	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
       ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
       else
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+	allow_undefined_flag_GCJ=' -expect_unresolved \*'
+	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
       fi
+      hardcode_libdir_separator_GCJ=:
       ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+    sco3.2v5*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_GCJ=no
+      export_dynamic_flag_spec_GCJ='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
       ;;
-    esac
-    ;;
 
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
+    solaris*)
+      no_undefined_flag_GCJ=' -z text'
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+	archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+	whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
+      esac
+      link_all_deplibs_GCJ=yes
+      ;;
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
 
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_GCJ=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_GCJ='$CC -r -o $output$reload_objs'
+	  hardcode_direct_GCJ=no
+        ;;
+	motorola)
+	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
 
-freebsd1*)
-  dynamic_linker=no
-  ;;
+    sysv4.3*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_GCJ=no
+      export_dynamic_flag_spec_GCJ='-Bexport'
+      ;;
 
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_GCJ=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_GCJ=yes
+      fi
+      ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
+    sysv4.2uw2*)
+      archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=no
+      hardcode_shlibpath_var_GCJ=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
       ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
+
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
+      no_undefined_flag_GCJ='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_GCJ=no
       ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+    sysv5*)
+      no_undefined_flag_GCJ=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+  		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      hardcode_libdir_flag_spec_GCJ=
+      hardcode_shlibpath_var_GCJ=no
+      runpath_var='LD_RUN_PATH'
+      ;;
+
+    uts4*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    *)
+      ld_shlibs_GCJ=no
+      ;;
+    esac
+  fi
+
+echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
+echo "${ECHO_T}$ld_shlibs_GCJ" >&6
+test "$ld_shlibs_GCJ" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_GCJ" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_GCJ=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_GCJ in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_GCJ
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
+        allow_undefined_flag_GCJ=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_GCJ=no
+        else
+	  archive_cmds_need_lc_GCJ=yes
+        fi
+        allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
   soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
   ;;
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
+aix4* | aix5*)
+  version_type=linux
   need_lib_prefix=no
   need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
     shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
     else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-   hppa*64*)
-     shrext_cmds='.sl'
-     hardcode_into_libs=yes
-     dynamic_linker="$host_os dld.sl"
-     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-     soname_spec='${libname}${release}${shared_ext}$major'
-     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-     ;;
-   *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi4*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
   ;;
 
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.01* | freebsdelf3.01*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case "$host_cpu" in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # find out which ABI we are using
+  libsuff=
+  case "$host_cpu" in
+  x86_64*|s390x*|powerpc64*)
+    echo '#line 18729 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *64-bit*)
+        libsuff=64
+        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+        ;;
+      esac
+    fi
+    rm -rf conftest*
+    ;;
+  esac
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=yes
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action_GCJ=
+if test -n "$hardcode_libdir_flag_spec_GCJ" || \
+   test -n "$runpath_var GCJ" || \
+   test "X$hardcode_automatic_GCJ"="Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct_GCJ" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
+     test "$hardcode_minus_L_GCJ" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_GCJ=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_GCJ=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_GCJ=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
+echo "${ECHO_T}$hardcode_action_GCJ" >&6
+
+if test "$hardcode_action_GCJ" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+       else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+       ;;
+   *)
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+    ;;
+  esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+   ;;
+
+  *)
+    echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
+if test "${ac_cv_func_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define shl_load innocuous_shl_load
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shl_load (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef shl_load
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != shl_load;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6
+if test $ac_cv_func_shl_load = yes; then
+  lt_cv_dlopen="shl_load"
+else
+  echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shl_load ();
+int
+main ()
+{
+shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dld_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
+if test $ac_cv_lib_dld_shl_load = yes; then
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+  echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
+if test "${ac_cv_func_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define dlopen innocuous_dlopen
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlopen (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef dlopen
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != dlopen;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6
+if test $ac_cv_func_dlopen = yes; then
+  lt_cv_dlopen="dlopen"
+else
+  echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_svld_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_svld_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
+if test $ac_cv_lib_svld_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dld_link ();
+int
+main ()
+{
+dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dld_dld_link=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_dld_link=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
+if test $ac_cv_lib_dld_dld_link = yes; then
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
+fi
 
-# This must be Linux ELF.
-linux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
+fi
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
 
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
+fi
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
 
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
+fi
 
-nto-qnx*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
 
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
+fi
+
+    ;;
   esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
   else
-    shlibpath_overrides_runpath=yes
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 19600 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
   fi
-  ;;
+fi
+rm -fr conftest*
 
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6
 
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 19698 "configure"
+#include "confdefs.h"
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      export_dynamic_flag_spec='${wl}-Blargedynsym'
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
+#include <stdio.h>
 
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
 
-*)
-  dynamic_linker=no
-  ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
 fi
+rm -fr conftest*
 
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_GCJ=
-if test -n "$hardcode_libdir_flag_spec_GCJ" || \
-   test -n "$runpath_var_GCJ" || \
-   test "X$hardcode_automatic_GCJ" = "Xyes" ; then
 
-  # We can hardcode non-existant directories.
-  if test "$hardcode_direct_GCJ" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
-     test "$hardcode_minus_L_GCJ" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_GCJ=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_GCJ=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_GCJ=unsupported
 fi
-echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
-echo "${ECHO_T}$hardcode_action_GCJ" >&6
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
+    fi
 
-if test "$hardcode_action_GCJ" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
 fi
 
 
@@ -19151,7 +19812,7 @@
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -19252,12 +19913,6 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
 
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
@@ -19269,9 +19924,6 @@
 # A C compiler.
 LTCC=$lt_LTCC
 
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
 # A language-specific compiler.
 CC=$lt_compiler_GCJ
 
@@ -19337,7 +19989,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -19581,42 +20233,15 @@
 # If no C compiler was specified, use CC.
 LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
 # Allow CC to be a program name with arguments.
 compiler=$CC
 
 
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${RC-"windres"}
 compiler=$CC
 compiler_RC=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
 lt_cv_prog_compiler_c_o_RC=yes
 
 # The else clause should only fire when bootstrapping the
@@ -19632,7 +20257,7 @@
   # Now quote all the things that may contain metacharacters while being
   # careful not to overquote the AC_SUBSTed values.  We take copies of the
   # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
     SED SHELL STRIP \
     libname_spec library_names_spec soname_spec extract_expsyms_cmds \
     old_striplib striplib file_magic_cmd finish_cmds finish_eval \
@@ -19733,12 +20358,6 @@
 # The host system.
 host_alias=$host_alias
 host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
 
 # An echo program that does not interpret backslashes.
 echo=$lt_echo
@@ -19750,9 +20369,6 @@
 # A C compiler.
 LTCC=$lt_LTCC
 
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
 # A language-specific compiler.
 CC=$lt_compiler_RC
 
@@ -19818,7 +20434,7 @@
 # Does compiler simultaneously support -c and -o options?
 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
 
-# Must we lock files when doing compilation?
+# Must we lock files when doing compilation ?
 need_locks=$lt_need_locks
 
 # Do we need the lib prefix for modules?
@@ -20113,6 +20729,7 @@
   NDEBUG_FALSE=
 fi
 
+SOFIA_CFLAGS="$SOFIA_CFLAGS -DNDEBUG"
 
 
 # Check whether --enable-expensive-checks or --disable-expensive-checks was given.
@@ -20453,7 +21070,7 @@
 int
 main ()
 {
-const char *s = __func__;
+char *s = __func__;
 
   ;
   return 0;
@@ -21342,17 +21959,7 @@
 echo "${ECHO_T}$ac_cv_header_pthread_h" >&6
 
 fi
-if test $ac_cv_header_pthread_h = yes; then
-  HAVE_PTHREADS=1;
-
-cat >>confdefs.h <<\_AXEOF
-#define SU_HAVE_PTHREADS 1
-_AXEOF
-
-fi
-
-
-else
+if test $ac_cv_header_pthread_h = yes; then
   HAVE_PTHREADS=1;
 
 cat >>confdefs.h <<\_AXEOF
@@ -21361,18 +21968,12 @@
 
 fi
 
-# Check whether --enable-experimental or --disable-experimental was given.
-if test "${enable_experimental+set}" = set; then
-  enableval="$enable_experimental"
 
 else
-  enable_experimental=no
-fi;
-
-if test $enable_experimental = yes ; then
+  HAVE_PTHREADS=1;
 
 cat >>confdefs.h <<\_AXEOF
-#define SU_HAVE_EXPERIMENTAL 1
+#define SU_HAVE_PTHREADS 1
 _AXEOF
 
 fi
@@ -21521,6 +22122,11 @@
 ### Test if we have stack suitable for handling tags directly
 ###
 
+test -z "$ac_cv_tagstack" &&
+case "$target" in
+i?86-*-* ) ac_cv_tagstack=yes ;;
+esac
+
 echo "$as_me:$LINENO: checking for stack suitable for tags" >&5
 echo $ECHO_N "checking for stack suitable for tags... $ECHO_C" >&6
 if test "${ac_cv_tagstack+set}" = set; then
@@ -21530,19 +22136,9 @@
 ac_cv_tagstack=no
 
 if test "$cross_compiling" = yes; then
-
-case "$target" in
-i?86-*-* ) ac_cv_tagstack=yes ;;
-* ) ac_cv_tagstack=no ;;
-esac
-
+  ac_cv_tagstack=no
 else
   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
 
 #if HAVE_INTTYPES_H
 #include <inttypes.h>
@@ -21550,7 +22146,6 @@
 #if HAVE_STDINT_H
 #include <stdint.h>
 #endif
-
 #include <stdarg.h>
 
 typedef void *tp;
@@ -22371,7 +22966,6 @@
 else
 
 
-
 cat >>confdefs.h <<\_AXEOF
 #define SU_HAVE_BSDSOCK 1
 _AXEOF
@@ -22381,9 +22975,8 @@
 
 
 
-
 for ac_header in sys/socket.h sys/ioctl.h sys/filio.h sys/sockio.h \
-		  sys/select.h sys/epoll.h
+		  sys/select.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -24032,301 +24625,12 @@
 extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char getaddrinfo ();
-int
-main ()
-{
-getaddrinfo ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_search_getaddrinfo="-l$ac_lib"
-break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-  done
-fi
-LIBS=$ac_func_search_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_search_getaddrinfo" >&5
-echo "${ECHO_T}$ac_cv_search_getaddrinfo" >&6
-if test "$ac_cv_search_getaddrinfo" != no; then
-  test "$ac_cv_search_getaddrinfo" = "none required" || LIBS="$ac_cv_search_getaddrinfo $LIBS"
-
-fi
-
-
-# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
-# for constant arguments.  Useless!
-echo "$as_me:$LINENO: checking for working alloca.h" >&5
-echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6
-if test "${ac_cv_working_alloca_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <alloca.h>
-int
-main ()
-{
-char *p = (char *) alloca (2 * sizeof (int));
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_working_alloca_h=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_working_alloca_h=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5
-echo "${ECHO_T}$ac_cv_working_alloca_h" >&6
-if test $ac_cv_working_alloca_h = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_ALLOCA_H 1
-_ACEOF
-
-fi
-
-echo "$as_me:$LINENO: checking for alloca" >&5
-echo $ECHO_N "checking for alloca... $ECHO_C" >&6
-if test "${ac_cv_func_alloca_works+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __GNUC__
-# define alloca __builtin_alloca
-#else
-# ifdef _MSC_VER
-#  include <malloc.h>
-#  define alloca _alloca
-# else
-#  if HAVE_ALLOCA_H
-#   include <alloca.h>
-#  else
-#   ifdef _AIX
- #pragma alloca
-#   else
-#    ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-#    endif
-#   endif
-#  endif
-# endif
-#endif
-
-int
-main ()
-{
-char *p = (char *) alloca (1);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_alloca_works=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_alloca_works=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5
-echo "${ECHO_T}$ac_cv_func_alloca_works" >&6
-
-if test $ac_cv_func_alloca_works = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_ALLOCA 1
-_ACEOF
-
-else
-  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
-# that cause trouble.  Some versions do not even contain alloca or
-# contain a buggy version.  If you still want to use their alloca,
-# use ar to extract alloca.o from them instead of compiling alloca.c.
-
-ALLOCA=alloca.$ac_objext
-
-cat >>confdefs.h <<\_ACEOF
-#define C_ALLOCA 1
-_ACEOF
-
-
-echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5
-echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6
-if test "${ac_cv_os_cray+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#if defined(CRAY) && ! defined(CRAY2)
-webecray
-#else
-wenotbecray
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "webecray" >/dev/null 2>&1; then
-  ac_cv_os_cray=yes
-else
-  ac_cv_os_cray=no
-fi
-rm -f conftest*
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5
-echo "${ECHO_T}$ac_cv_os_cray" >&6
-if test $ac_cv_os_cray = yes; then
-  for ac_func in _getb67 GETB67 getb67; do
-    as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
+   builtin and then its argument prototype would still apply.  */
+char getaddrinfo ();
 int
 main ()
 {
-return f != $ac_func;
+getaddrinfo ();
   ;
   return 0;
 }
@@ -24353,94 +24657,23 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+  ac_cv_search_getaddrinfo="-l$ac_lib"
+break
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-eval "$as_ac_var=no"
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define CRAY_STACKSEG_END $ac_func
-_ACEOF
-
-    break
-fi
-
   done
 fi
-
-echo "$as_me:$LINENO: checking stack direction for C alloca" >&5
-echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6
-if test "${ac_cv_c_stack_direction+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
-  ac_cv_c_stack_direction=0
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-int
-find_stack_direction ()
-{
-  static char *addr = 0;
-  auto char dummy;
-  if (addr == 0)
-    {
-      addr = &dummy;
-      return find_stack_direction ();
-    }
-  else
-    return (&dummy > addr) ? 1 : -1;
-}
-
-int
-main ()
-{
-  exit (find_stack_direction () < 0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_c_stack_direction=1
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_c_stack_direction=-1
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
+LIBS=$ac_func_search_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5
-echo "${ECHO_T}$ac_cv_c_stack_direction" >&6
-
-cat >>confdefs.h <<_ACEOF
-#define STACK_DIRECTION $ac_cv_c_stack_direction
-_ACEOF
-
+echo "$as_me:$LINENO: result: $ac_cv_search_getaddrinfo" >&5
+echo "${ECHO_T}$ac_cv_search_getaddrinfo" >&6
+if test "$ac_cv_search_getaddrinfo" != no; then
+  test "$ac_cv_search_getaddrinfo" = "none required" || LIBS="$ac_cv_search_getaddrinfo $LIBS"
 
 fi
 
@@ -24468,11 +24701,9 @@
 
 
 
-
-for ac_func in gettimeofday strerror random initstate tcsetattr flock \
+for ac_func in gettimeofday strerror random initstate tcsetattr flock alarm \
                 socketpair gethostname gethostbyname getipnodebyname \
                 poll epoll_create select if_nameindex \
-		signal alarm \
 	        getaddrinfo getnameinfo freeaddrinfo gai_strerror getifaddrs \
                 getline getdelim getpass
 do
@@ -24585,8 +24816,7 @@
 
 fi
 
-if test $ac_cv_func_epoll_create = yes && test $ac_cv_header_sys_epoll_h = yes
-then
+if test $ac_cv_func_epoll_create = yes ; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_EPOLL 1
@@ -24717,9 +24947,8 @@
 
 
 
-
 for ac_func in memmem memccpy memspn memcspn strcasestr strtoull \
-		   inet_ntop inet_pton poll
+		   inet_ntop inet_pton
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -24832,104 +25061,6 @@
 :
 
 
-if test $ac_cv_func_signal = yes ; then
-echo "$as_me:$LINENO: checking whether SIGPIPE is declared" >&5
-echo $ECHO_N "checking whether SIGPIPE is declared... $ECHO_C" >&6
-if test "${ac_cv_have_decl_SIGPIPE+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-#include <signal.h>
-
-
-int
-main ()
-{
-#ifndef SIGPIPE
-  char *p = (char *) SIGPIPE;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_have_decl_SIGPIPE=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_have_decl_SIGPIPE=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_have_decl_SIGPIPE" >&5
-echo "${ECHO_T}$ac_cv_have_decl_SIGPIPE" >&6
-if test $ac_cv_have_decl_SIGPIPE = yes; then
-
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SIGPIPE 1
-_ACEOF
-
-fi
-
-fi
-
-# ===========================================================================
-# Check how to implement su_port
-# ===========================================================================
-
-# Check whether --enable-poll-port or --disable-poll-port was given.
-if test "${enable_poll_port+set}" = set; then
-  enableval="$enable_poll_port"
-
-else
-  enable_poll_port=maybe
-fi;
-
-if test $enable_poll_port = maybe ; then
-  if test $ac_cv_func_poll = yes ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_POLL_PORT 1
-_ACEOF
-
-  fi
-elif test $enable_poll_port = yes ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_POLL_PORT 1
-_ACEOF
-
-fi
 
 # ===========================================================================
 # Check pthread_rwlock_unlock()
@@ -26016,41 +26147,6 @@
 
 fi
 
-
-if test "x$enable_stun" = xyes; then
-  HAVE_STUN_TRUE=
-  HAVE_STUN_FALSE='#'
-else
-  HAVE_STUN_TRUE='#'
-  HAVE_STUN_FALSE=
-fi
-
-
-# Check whether --enable-nth or --disable-nth was given.
-if test "${enable_nth+set}" = set; then
-  enableval="$enable_nth"
-
-else
-  enable_nth=yes
-fi;
-
-
-if test "x$enable_nth" = xyes; then
-  HAVE_NTH_TRUE=
-  HAVE_NTH_FALSE='#'
-else
-  HAVE_NTH_TRUE='#'
-  HAVE_NTH_FALSE=
-fi
-
-if test x$enable_nth = xyes ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SOFIA_NTH 1
-_ACEOF
-
-fi
-
 # Check whether --enable-ntlm or --disable-ntlm was given.
 if test "${enable_ntlm+set}" = set; then
   enableval="$enable_ntlm"
@@ -26260,6 +26356,74 @@
 
 ### checks for declarations
 ### -----------------------
+echo "$as_me:$LINENO: checking whether SIGPIPE is declared" >&5
+echo $ECHO_N "checking whether SIGPIPE is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_SIGPIPE+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <signal.h>
+
+
+int
+main ()
+{
+#ifndef SIGPIPE
+  char *p = (char *) SIGPIPE;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_have_decl_SIGPIPE=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_SIGPIPE=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_SIGPIPE" >&5
+echo "${ECHO_T}$ac_cv_have_decl_SIGPIPE" >&6
+if test $ac_cv_have_decl_SIGPIPE = yes; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SIGPIPE 1
+_ACEOF
+
+fi
+
 
 ### checks for types
 ### ----------------
@@ -26933,7 +27097,7 @@
 int
 main ()
 {
-const char *s = __func__;
+char *s = __func__;
 
   ;
   return 0;
@@ -27566,20 +27730,6 @@
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
-if test -z "${HAVE_STUN_TRUE}" && test -z "${HAVE_STUN_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"HAVE_STUN\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"HAVE_STUN\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-if test -z "${HAVE_NTH_TRUE}" && test -z "${HAVE_NTH_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"HAVE_NTH\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"HAVE_NTH\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
-   { (exit 1); exit 1; }; }
-fi
 if test -z "${HAVE_NTLM_TRUE}" && test -z "${HAVE_NTLM_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"HAVE_NTLM\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -27858,7 +28008,7 @@
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by sofia-sip $as_me 1.12.5, which was
+This file was extended by sofia-sip $as_me 1.12.4work, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -27921,7 +28071,7 @@
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-sofia-sip config.status 1.12.5
+sofia-sip config.status 1.12.4work
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -28223,7 +28373,6 @@
 s, at HAVE_MINGW32_FALSE@,$HAVE_MINGW32_FALSE,;t t
 s, at CWFLAG@,$CWFLAG,;t t
 s, at SOFIA_CFLAGS@,$SOFIA_CFLAGS,;t t
-s, at SOFIA_COVERAGE@,$SOFIA_COVERAGE,;t t
 s, at ENABLE_COVERAGE_TRUE@,$ENABLE_COVERAGE_TRUE,;t t
 s, at ENABLE_COVERAGE_FALSE@,$ENABLE_COVERAGE_FALSE,;t t
 s, at MOSTLYCLEANFILES@,$MOSTLYCLEANFILES,;t t
@@ -28267,14 +28416,9 @@
 s, at HAVE_GLIB_FALSE@,$HAVE_GLIB_FALSE,;t t
 s, at GLIB_VERSION@,$GLIB_VERSION,;t t
 s, at SOFIA_GLIB_PKG_REQUIRES@,$SOFIA_GLIB_PKG_REQUIRES,;t t
-s, at ALLOCA@,$ALLOCA,;t t
 s, at REPLACE_LIBADD@,$REPLACE_LIBADD,;t t
 s, at HAVE_TLS_TRUE@,$HAVE_TLS_TRUE,;t t
 s, at HAVE_TLS_FALSE@,$HAVE_TLS_FALSE,;t t
-s, at HAVE_STUN_TRUE@,$HAVE_STUN_TRUE,;t t
-s, at HAVE_STUN_FALSE@,$HAVE_STUN_FALSE,;t t
-s, at HAVE_NTH_TRUE@,$HAVE_NTH_TRUE,;t t
-s, at HAVE_NTH_FALSE@,$HAVE_NTH_FALSE,;t t
 s, at HAVE_NTLM_TRUE@,$HAVE_NTLM_TRUE,;t t
 s, at HAVE_NTLM_FALSE@,$HAVE_NTLM_FALSE,;t t
 s, at LIBOBJS@,$LIBOBJS,;t t

Modified: freeswitch/trunk/libs/sofia-sip/configure.ac
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/configure.ac	(original)
+++ freeswitch/trunk/libs/sofia-sip/configure.ac	Sat Feb 17 01:25:21 2007
@@ -11,14 +11,14 @@
 dnl ---------------------------
 
 dnl update both the version for AC_INIT and the LIBSOFIA_SIP_UA_MAJOR_MINOR
-AC_INIT([sofia-sip], [1.12.5work])
+AC_INIT([sofia-sip], [1.12.4work])
 AC_CONFIG_SRCDIR([libsofia-sip-ua/sip/sofia-sip/sip.h])
 AC_SUBST(VER_LIBSOFIA_SIP_UA_MAJOR_MINOR, [1.12])
 dnl Includedir specific to this sofia version
 AC_SUBST(include_sofiadir, '${includedir}/sofia-sip-1.12')
-AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [4])
+AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [3])
 AC_SUBST(LIBVER_SOFIA_SIP_UA_REV, [0])
-AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [4])
+AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [3])
 AC_SUBST(LIBVER_SOFIA_SIP_UA_SOVER, [0]) # CUR-AGE
 AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_CUR, [3])
 AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_REV, [0])
@@ -83,15 +83,6 @@
 else
   AC_DEFINE([HAVE_SOFIA_STUN], 1, [Define to 1 if we use STUN library])
 fi
-AM_CONDITIONAL([HAVE_STUN], [test "x$enable_stun" = xyes])
-
-AC_ARG_ENABLE(nth,
-[  --disable-nth              disable nth and http modules (enabled)],
- , enable_nth=yes)
-AM_CONDITIONAL([HAVE_NTH], [test "x$enable_nth" = xyes])
-if test x$enable_nth = xyes ; then
-  AC_DEFINE([HAVE_SOFIA_NTH], 1, [Define to 1 if we use NTH library])
-fi
 
 dnl Disable NTLM support by default
 AC_ARG_ENABLE(ntlm,
@@ -113,6 +104,10 @@
 
 ### checks for declarations
 ### -----------------------
+AC_CHECK_DECL([SIGPIPE], [
+AC_DEFINE([HAVE_SIGPIPE], 1, [Define to 1 if you have SIGPIPE])],,[
+#include <signal.h>
+])
 
 ### checks for types
 ### ----------------

Modified: freeswitch/trunk/libs/sofia-sip/docs/build_system.txt
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/docs/build_system.txt	(original)
+++ freeswitch/trunk/libs/sofia-sip/docs/build_system.txt	Sat Feb 17 01:25:21 2007
@@ -38,11 +38,6 @@
   separately in ``DIST_SOURCES`` variable (otherwise ``make dist``
   will fail)
 
-Makefile fragments
-------------------
-
-Some common makefile rules are in 'rules' subdirectory.
-
 Maintainer mode
 ---------------
 
@@ -59,16 +54,13 @@
 Running tests
 =============
 
-Sofia-SIP has quite complete suite of test cases. It is prudent to run
-them while making changes and before committing them to revision control
-system. However, running certain tests takes quite a long time to
-execture. Therefore, they are run only if the environment variable
+Sofia-SIP has quite complete suite of test cases. It is prudent to
+run them while making changes and before committing them to revision
+control system. However, running certain tests takes quite a long
+time. Therefore, they are run only if the environment variable
 EXPENSIVE_CHECKS has been set. EXPENSIVE_CHECKS is also set by the build
 system if configure option '--enable-expensive-checks' has been used.
 
-On hosts with i386 architecture, it is possible to run tests under
-valgrind. Use the make target 'valcheck' for that purpose.
-
 Code-tree layout
 ================
 

Modified: freeswitch/trunk/libs/sofia-sip/docs/devel_platform_notes.txt
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/docs/devel_platform_notes.txt	(original)
+++ freeswitch/trunk/libs/sofia-sip/docs/devel_platform_notes.txt	Sat Feb 17 01:25:21 2007
@@ -11,30 +11,14 @@
 be at least 1.7. You can avoid running autoreconf explicitly if you use
 ./configure option --enable-maintainer-mode.
 
-Notes to distributors
-----------------------
-
-Build options such as "--disable-stun" (HAVE_SOFIA_STUN) and 
-"--disable-nth" (HAVE_SOFIA_NTH) modify the public library API/ABI,
-by omitting certain interfaces from the resulting library and installed
-header files.
-
-Options such as '--disable-size-compat' modify the library
-ABI by changing the types used in public library function 
-signatures.
-
 Generic POSIX (GNU/Linux, BSD, ...) 
 -----------------------------------
 
 Sofia-SIP should compile out-of-the-box on generic POSIX
 machines. Use the standard GNU autotool 'configure+make'
-procedure to build the software. See top-level README file
+procedure to build the software. See top-level INSTALL
 for more information.
 
-The configure script accepts various options. See "./configure --help"
-for the full list.
-
-
 Mac OS X 
 --------
 

Modified: freeswitch/trunk/libs/sofia-sip/docs/release_management.txt
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/docs/release_management.txt	(original)
+++ freeswitch/trunk/libs/sofia-sip/docs/release_management.txt	Sat Feb 17 01:25:21 2007
@@ -61,8 +61,7 @@
     sh> cvs tag rel-sofia-sip-x_y_z
 - take a fresh checkout of the release using the release tag
     sh> darcs get http://sofia-sip.org/repos/sofia-sip --tag=rel-sofia-sip-1_yy_z
-- create the release tarball with "make distcheck" (make sure depcomp et
-  al libtool scripts are correctly created)
+- create the release tarball with "make distcheck"
 - calculate md5 and sha1 hashes using md5sum and sha1sum utilities,
   and copy the values to the release-notes (see below)
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -31,6 +31,16 @@
 	     docs/Doxyfile.conf \
 	     docs/Doxyfile.version
 
+built-sources: built-sources-recursive 
+clean-built-sources: clean-built-sources-recursive
+
+built-sources-recursive clean-built-sources-recursive:
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $@ in $$subdir"; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
+	done;
+
 doxygen: built-sources
 	@cd ${srcdir} ;\
 	mkdir -p docs docs/html &&\
@@ -43,6 +53,4 @@
 	done
 	cd ${srcdir}/docs/html && ../../${top_srcdir}/libsofia-sip-ua/docs/hide_emails.sh
 
-include $(top_srcdir)/rules/recursive.am
-
 .PHONY: built-sources built-sources-am doxygen 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -22,9 +22,6 @@
 # Licensed under LGPL. See file COPYING.
 #
 
-# Recursive Makefile targets
-# --------------------------
-
 SOURCES = $(libsofia_sip_ua_glib_la_SOURCES)
 
 srcdir = @srcdir@
@@ -51,9 +48,8 @@
 host_triplet = @host@
 target_triplet = @target@
 @HAVE_GLIB_TRUE at am__append_1 = libsofia-sip-ua-glib.la
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(top_srcdir)/rules/recursive.am ChangeLog
 subdir = libsofia-sip-ua-glib
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
 	$(top_srcdir)/m4/sac-openssl.m4 $(top_srcdir)/m4/sac-su.m4 \
@@ -104,7 +100,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -151,12 +146,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -200,7 +191,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -271,19 +261,10 @@
 	     docs/Doxyfile.conf \
 	     docs/Doxyfile.version
 
- at ENABLE_COVERAGE_TRUE@COVERAGE_RECURSIVE = coverage-recursive
-SOFIA_RECURSIVE = \
-	valcheck-recursive \
-	$(COVERAGE_RECURSIVE)
-
-SOFIA_DIST_RECURSIVE = \
-	built-sources-recursive \
-	clean-built-sources-recursive
-
 all: all-recursive
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/recursive.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -479,7 +460,7 @@
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../rules $(distdir)/docs
+	$(mkdir_p) $(distdir)/docs
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -621,6 +602,16 @@
 	uninstall-info-am uninstall-libLTLIBRARIES
 
 
+built-sources: built-sources-recursive 
+clean-built-sources: clean-built-sources-recursive
+
+built-sources-recursive clean-built-sources-recursive:
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $@ in $$subdir"; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
+	done;
+
 doxygen: built-sources
 	@cd ${srcdir} ;\
 	mkdir -p docs docs/html &&\
@@ -632,44 +623,6 @@
           && popd > /dev/null ; \
 	done
 	cd ${srcdir}/docs/html && ../../${top_srcdir}/libsofia-sip-ua/docs/hide_emails.sh
- at ENABLE_COVERAGE_TRUE@coverage: $(COVERAGE_RECURSIVE)
-
-all-recursive: built-sources-recursive
-built-sources: built-sources-recursive 
-clean-built-sources: clean-built-sources-recursive
-valcheck: valcheck-recursive
-
-$(SOFIA_RECURSIVE):
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  echo "Making $$target in $$subdir"; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
-	  || eval $$failcom; \
-	done; \
-	test -z "$$fail"
-
-$(SOFIA_DIST_RECURSIVE):
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	target=`echo $@ | sed s/-recursive//`; \
-	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  echo "Making $$target in $$subdir"; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
-	  || eval $$failcom; \
-	done; \
-	test -z "$$fail"
 
 .PHONY: built-sources built-sources-am doxygen 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -58,4 +58,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../../libsofia-sip-ua/sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -25,36 +25,11 @@
 # ----------------------------------------------------------------------
 # Headers
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
-# 
-# run tests with valgrind
-#
 
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SOURCES = $(libsu_glib_la_SOURCES) su_source_test.c torture_su_glib_timer.c
+SOURCES = $(libsu_glib_la_SOURCES) su_source_test.c
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
@@ -79,18 +54,14 @@
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-check_PROGRAMS = su_source_test$(EXEEXT) \
-	torture_su_glib_timer$(EXEEXT)
+check_PROGRAMS = su_source_test$(EXEEXT)
 @HAVE_GLIB_TRUE at am__append_1 = \
 @HAVE_GLIB_TRUE@			sofia-sip/su_source.h \
 @HAVE_GLIB_TRUE@			sofia-sip/su_glib.h
 
 DIST_COMMON = $(am__nobase_include_sofia_HEADERS_DIST) \
-	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_2 = -DNDEBUG
+	$(srcdir)/../../libsofia-sip-ua/sofia.am $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
 subdir = libsofia-sip-ua-glib/su-glib
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -113,11 +84,6 @@
 am__DEPENDENCIES_1 =
 su_source_test_DEPENDENCIES = libsu-glib.la \
 	../../libsofia-sip-ua/libsofia-sip-ua.la $(am__DEPENDENCIES_1)
-torture_su_glib_timer_SOURCES = torture_su_glib_timer.c
-torture_su_glib_timer_OBJECTS = torture_su_glib_timer.$(OBJEXT)
-torture_su_glib_timer_LDADD = $(LDADD)
-torture_su_glib_timer_DEPENDENCIES = libsu-glib.la \
-	../../libsofia-sip-ua/libsofia-sip-ua.la $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/libsofia-sip-ua/su/sofia-sip
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
@@ -129,10 +95,8 @@
 CCLD = $(CC)
 LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(libsu_glib_la_SOURCES) su_source_test.c \
-	torture_su_glib_timer.c
-DIST_SOURCES = $(libsu_glib_la_SOURCES) su_source_test.c \
-	torture_su_glib_timer.c
+SOURCES = $(libsu_glib_la_SOURCES) su_source_test.c
+DIST_SOURCES = $(libsu_glib_la_SOURCES) su_source_test.c
 am__nobase_include_sofia_HEADERS_DIST = sofia-sip/su_source.h \
 	sofia-sip/su_glib.h
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -148,7 +112,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -195,12 +158,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -244,7 +203,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -309,7 +267,7 @@
 
 # ----------------------------------------------------------------------
 # Tests
-TESTS = su_source_test torture_su_glib_timer
+TESTS = su_source_test
 
 # ----------------------------------------------------------------------
 # Rules for building the targets
@@ -330,8 +288,7 @@
 # ----------------------------------------------------------------------
 # Automake options
 AUTOMAKE_OPTIONS = foreign
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_2)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -357,13 +314,11 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../libsofia-sip-ua/sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -413,9 +368,6 @@
 su_source_test$(EXEEXT): $(su_source_test_OBJECTS) $(su_source_test_DEPENDENCIES) 
 	@rm -f su_source_test$(EXEEXT)
 	$(LINK) $(su_source_test_LDFLAGS) $(su_source_test_OBJECTS) $(su_source_test_LDADD) $(LIBS)
-torture_su_glib_timer$(EXEEXT): $(torture_su_glib_timer_OBJECTS) $(torture_su_glib_timer_DEPENDENCIES) 
-	@rm -f torture_su_glib_timer$(EXEEXT)
-	$(LINK) $(torture_su_glib_timer_LDFLAGS) $(torture_su_glib_timer_OBJECTS) $(torture_su_glib_timer_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -425,7 +377,6 @@
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_source.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_source_test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/torture_su_glib_timer.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@@ -599,7 +550,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/../../libsofia-sip-ua $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -747,92 +698,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/sofia-sip/su_glib.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/sofia-sip/su_glib.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/sofia-sip/su_glib.h	Sat Feb 17 01:25:21 2007
@@ -43,7 +43,6 @@
 
 SOFIAPUBFUN su_root_t *su_glib_root_create(su_root_magic_t *) __attribute__((__malloc__));
 SOFIAPUBFUN GSource *su_glib_root_gsource(su_root_t *);
-SOFIAPUBFUN void su_glib_prefer_gsource(void);
 
 SOFIA_END_DECLS
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/su-glib/su_source.c	Sat Feb 17 01:25:21 2007
@@ -25,11 +25,7 @@
 /**
  * @file su_source.c
  * @brief Wrapper for glib GSource.
- *  
- * Refs: 
- *  - http://sofia-sip.sourceforge.net/refdocs/su/group__su__wait.html
- *  - http://developer.gnome.org/doc/API/glib/glib-the-main-event-loop.html
- *
+ * *  
  * @author Pekka Pessi <Pekka.Pessi at nokia.com>.
  * 
  * @date Created: Thu Mar  4 15:15:15 2004 ppessi
@@ -40,6 +36,12 @@
 #include "config.h"
 #endif
 
+#include <stdlib.h>
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
 #include <glib.h>
 
 #define SU_PORT_IMPLEMENTATION 1
@@ -55,26 +57,16 @@
 #include "su_port.h"
 #include "sofia-sip/su_alloc.h"
 
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-
-#if 1
-#define PORT_LOCK_DEBUG(x)  ((void)0)
-#else
-#define PORT_LOCK_DEBUG(x)  printf x
-#endif
-
-static su_port_t *su_source_port_create(void) __attribute__((__malloc__));
+static su_port_t *su_source_create(void) __attribute__((__malloc__));
 static gboolean su_source_prepare(GSource *gs, gint *return_tout);
 static gboolean su_source_check(GSource *gs);
 static gboolean su_source_dispatch(GSource *gs,
-				   GSourceFunc callback,
-				   gpointer user_data);
+			    GSourceFunc callback,
+			    gpointer user_data);
 static void su_source_finalize(GSource *source);
 
+static int su_source_getmsgs(su_port_t *self);
+
 static
 GSourceFuncs su_source_funcs[1] = {{
     su_source_prepare,
@@ -114,22 +106,21 @@
 static su_duration_t su_source_step(su_port_t *self, su_duration_t tout);
 static int su_source_own_thread(su_port_t const *port);
 static int su_source_add_prepoll(su_port_t *port,
-				 su_root_t *root, 
-				 su_prepoll_f *, 
-				 su_prepoll_magic_t *);
+			       su_root_t *root, 
+			       su_prepoll_f *, 
+			       su_prepoll_magic_t *);
 static int su_source_remove_prepoll(su_port_t *port,
 				  su_root_t *root);
+static su_timer_t **su_source_timers(su_port_t *port);
 static int su_source_multishot(su_port_t *self, int multishot);
+static int su_source_threadsafe(su_port_t *port);
 
-static char const *su_source_name(su_port_t const *self);
-
-static 
-su_port_vtable_t const su_source_port_vtable[1] =
+static
+su_port_vtable_t const su_source_vtable[1] =
   {{
-      /* su_vtable_size: */ sizeof su_source_port_vtable,
+      /* su_vtable_size: */ sizeof su_source_vtable,
       su_source_lock,
       su_source_unlock,
-
       su_source_incref,
       su_source_decref,
 
@@ -147,23 +138,11 @@
       su_source_own_thread,
       su_source_add_prepoll,
       su_source_remove_prepoll,
-      su_base_port_timers,
+      su_source_timers,
       su_source_multishot,
-      su_base_port_threadsafe,
-      /*su_source_yield*/ NULL,
-      /*su_source_wait_events*/ NULL,
-      su_base_port_getmsgs,
-      su_base_port_getmsgs_from,
-      su_source_name,
-      su_base_port_start_shared,
-      su_base_port_wait,
-      NULL,
-    }};
+      su_source_threadsafe
 
-static char const *su_source_name(su_port_t const *self)
-{
-  return "GSource";
-}
+    }};
 
 /** 
  * Port is a per-thread reactor.  
@@ -171,14 +150,20 @@
  * Multiple root objects executed by single thread share a su_port_t object. 
  */
 struct su_source_s {
-  su_base_port_t   sup_base[1];
+  su_home_t        sup_home[1];
+  su_port_vtable_t const *sup_vtable;
   
   GThread         *sup_tid;
   GStaticMutex     sup_mutex[1];
+  GStaticRWLock    sup_ref[1];
 
-  GSource         *sup_source;	/**< Backpointer to source */
-  GMainLoop       *sup_main_loop; /**< Reference to mainloop while running */
+  GSource         *sup_source;
+  GMainLoop       *sup_main_loop;
   
+  /* Message list - this is protected by lock  */
+  su_msg_t        *sup_head;
+  su_msg_t       **sup_tail;
+
   /* Waits */
   unsigned         sup_registers; /** Counter incremented by 
 				      su_port_register() or 
@@ -192,6 +177,9 @@
   su_wakeup_f     *sup_wait_cbs; 
   su_wakeup_arg_t**sup_wait_args; 
   su_root_t      **sup_wait_roots; 
+
+  /* Timer list */
+  su_timer_t      *sup_timers;
 };
 
 typedef struct _SuSource
@@ -206,6 +194,10 @@
 #define SU_SOURCE_INCREF(p, f)    (g_source_ref(p->sup_source))
 #define SU_SOURCE_DECREF(p, f)    (g_source_unref(p->sup_source))
 
+#define SU_SOURCE_INITLOCK(p)     (g_static_mutex_init((p)->sup_mutex))
+#define SU_SOURCE_LOCK(p, f)      (g_static_mutex_lock((p)->sup_mutex))
+#define SU_SOURCE_UNLOCK(p, f)    (g_static_mutex_unlock((p)->sup_mutex))
+
 #else
 
 /* Debugging versions */
@@ -213,6 +205,15 @@
 #define SU_SOURCE_DECREF(p, f)    do { printf("decref(%p) by %s\n", (p), f), \
   g_source_unref(p->sup_source); } while(0)
 
+#define SU_SOURCE_INITLOCK(p) \
+   (g_static_mutex_init((p)->sup_mutex), printf("init_lock(%p)\n", p))
+
+#define SU_SOURCE_LOCK(p, f)    \
+   (printf("%ld at %s locking(%p)...", g_thread_self(), f, p), g_static_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", g_thread_self(), f, p))
+
+#define SU_SOURCE_UNLOCK(p, f)  \
+  (g_static_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", g_thread_self(), f, p))
+
 #endif
 
 #if HAVE_FUNC
@@ -228,7 +229,7 @@
 /** Create a root that uses GSource as reactor */
 su_root_t *su_glib_root_create(su_root_magic_t *magic)
 {
-  return su_root_create_with_port(magic, su_source_port_create());
+  return su_root_create_with_port(magic, su_source_create());
 }
 
 /** Deprecated */
@@ -237,15 +238,6 @@
   return su_glib_root_create(magic);
 }
 
-/** 
- * Returns a GSource object for the root 
- *
- * Note that you need to unref the GSource with g_source_unref() 
- * before destroying the root object.
- *
- * @return NULL on error (for instance if root was not created with 
- *         su_glib_root_create())
- */
 GSource *su_glib_root_gsource(su_root_t *root)
 {
   g_assert(root);
@@ -254,20 +246,41 @@
 
 /*=============== Private function definitions ===============*/
 
-/** Initialize source port */
-int su_source_port_init(su_port_t *self,
-			GSource *gs,
-			su_port_vtable_t const *vtable)
+/**@internal
+ *
+ * Allocates and initializes a reactor and message port object.
+ *
+ * @return
+ *   If successful a pointer to the new message port is returned, otherwise
+ *   NULL is returned.  
+ */
+su_port_t *su_source_create(void)
 {
-  if (su_base_port_init(self, vtable) < 0)
-    return -1;
+  SuSource *ss;
 
-  self->sup_source = gs;
-  self->sup_tid = g_thread_self();
+  SU_DEBUG_9(("su_source_create() called\n"));
 
-  g_static_mutex_init(self->sup_mutex);
-  
-  return 0;
+  ss = (SuSource *)g_source_new(su_source_funcs, (sizeof *ss));
+
+  if (ss) {
+    su_port_t *self = ss->ss_port;
+
+    self->sup_vtable = su_source_vtable;
+    self->sup_source = ss->ss_source;
+    
+    SU_SOURCE_INITLOCK(self);
+
+    self->sup_tail = &self->sup_head;
+    self->sup_tid = g_thread_self();
+
+    SU_DEBUG_9(("su_source_with_main_context() returns %p\n", self));
+
+    return self;
+  } else {
+    su_perror("su_source_with_main_context(): su_home_clone");
+    SU_DEBUG_9(("su_source_with_main_context() fails\n"));
+    return NULL;
+  }
 }
 
 /** @internal Destroy a port. */
@@ -281,70 +294,23 @@
 
   SU_DEBUG_9(("su_source_finalize() called\n"));
 
-  g_static_mutex_free(self->sup_mutex);
-
-  su_base_port_deinit(self);
-
-  su_home_deinit(self->sup_base->sup_home);
-}
-
-void su_source_port_lock(su_port_t *self, char const *who)
-{
-  PORT_LOCK_DEBUG(("%p at %s locking(%p)...",
-		   (void *)g_thread_self(), who, self));
-
-  g_static_mutex_lock(self->sup_mutex);
-
-  PORT_LOCK_DEBUG((" ...%p at %s locked(%p)...", 
-		   (void *)g_thread_self(), who, self));
-}
-
-void su_source_port_unlock(su_port_t *self, char const *who)
-{
-  g_static_mutex_unlock(self->sup_mutex);
-
-  PORT_LOCK_DEBUG((" ...%p at %s unlocked(%p)\n", 
-		   (void *)g_thread_self(), who, self));
-}
-
-/** @internal Send a message to the port. */
-int su_source_send(su_port_t *self, su_msg_r rmsg)
-{
-  int wakeup = su_base_port_send(self, rmsg);
-  GMainContext *gmc;
-
-  if (wakeup < 0)
-    return -1;
-  if (wakeup == 0)
-    return 0;
-
-  gmc = g_source_get_context(self->sup_source);
-
-  if (gmc)
-    g_main_context_wakeup(gmc);
+  if (self->sup_waits) 
+    free(self->sup_waits), self->sup_waits = NULL;
+  if (self->sup_wait_cbs)
+    free(self->sup_wait_cbs), self->sup_wait_cbs = NULL;
+  if (self->sup_wait_args)
+    free(self->sup_wait_args), self->sup_wait_args = NULL;
+  if (self->sup_wait_roots)
+    free(self->sup_wait_roots), self->sup_wait_roots = NULL;
+  if (self->sup_indices)
+    free(self->sup_indices), self->sup_indices = NULL;
 
-  return 0;
+  su_home_deinit(self->sup_home);
 }
 
-/** @internal
- * Checks if the calling thread owns the port object.
- *
- * @param self pointer to a port object
- *
- * @retval true (nonzero) if the calling thread owns the port,
- * @retval false (zero) otherwise.
- */
-int su_source_own_thread(su_port_t const *self)
-{
-  return self == NULL || SU_SOURCE_OWN_THREAD(self);
-}
-
-/* -- Registering and unregistering ------------------------------------- */
-
 /* Seconds from 1.1.1900 to 1.1.1970 */
 #define NTP_EPOCH 2208988800UL 
 
-/** Prepare to wait - calculate time to next timer */
 static
 gboolean su_source_prepare(GSource *gs, gint *return_tout)
 {
@@ -353,12 +319,12 @@
 
   enter;
   
-  if (self->sup_base->sup_head) {
+  if (self->sup_head) {
     *return_tout = 0;
     return TRUE;
   }
 
-  if (self->sup_base->sup_timers) {
+  if (self->sup_timers) {
     su_time_t now;
     GTimeVal  gtimeval;
     su_duration_t tout;
@@ -367,7 +333,7 @@
     now.tv_sec = gtimeval.tv_sec + 2208988800UL;
     now.tv_usec = gtimeval.tv_usec;
 
-    tout = su_timer_next_expires(self->sup_base->sup_timers, now);
+    tout = su_timer_next_expires(self->sup_timers, now);
 
     *return_tout = (tout < 0 || tout > (su_duration_t)G_MAXINT)?
 	-1 : (gint)tout;
@@ -410,10 +376,10 @@
 
   enter;
 
-  if (self->sup_base->sup_head)
-    su_base_port_getmsgs(self);
+  if (self->sup_head)
+    su_source_getmsgs(self);
 
-  if (self->sup_base->sup_timers) {
+  if (self->sup_timers) {
     su_time_t now;
     GTimeVal  gtimeval;
     su_duration_t tout;
@@ -426,7 +392,7 @@
     now.tv_sec = gtimeval.tv_sec + 2208988800UL;
     now.tv_usec = gtimeval.tv_usec;
 
-    timers = su_timer_expire(&self->sup_base->sup_timers, &tout, now);
+    timers = su_timer_expire(&self->sup_timers, &tout, now);
   }
 
 #if SU_HAVE_POLL
@@ -458,20 +424,12 @@
 
 static void su_source_lock(su_port_t *self, char const *who)
 {
-  PORT_LOCK_DEBUG(("%p at %s locking(%p)...",
-		   (void *)g_thread_self(), who, self));
-  g_static_mutex_lock(self->sup_mutex);
-
-  PORT_LOCK_DEBUG((" ...%p at %s locked(%p)...", 
-		   (void *)g_thread_self(), who, self));
+  SU_SOURCE_LOCK(self, who);
 }
 
 static void su_source_unlock(su_port_t *self, char const *who)
 {
-  g_static_mutex_unlock(self->sup_mutex);
-
-  PORT_LOCK_DEBUG((" ...%p at %s unlocked(%p)\n", 
-		   (void *)g_thread_self(), who, self));
+  SU_SOURCE_UNLOCK(self, who);
 }
 
 static void su_source_incref(su_port_t *self, char const *who)
@@ -490,6 +448,81 @@
   return self->sup_source;
 }
 
+/** @internal Send a message to the port. */
+int su_source_send(su_port_t *self, su_msg_r rmsg)
+{
+  enter;
+  
+  if (self) {
+    su_msg_t *msg;
+    GMainContext *gmc;
+
+    SU_SOURCE_LOCK(self, "su_source_send");
+    
+    msg = rmsg[0]; rmsg[0] = NULL;
+    *self->sup_tail = msg;
+    self->sup_tail = &msg->sum_next;
+
+    SU_SOURCE_UNLOCK(self, "su_source_send");
+
+    gmc = g_source_get_context(self->sup_source);
+
+    if (gmc)
+      g_main_context_wakeup(gmc);
+
+    return 0;
+  }
+  else {
+    su_msg_destroy(rmsg);
+    return -1;
+  }
+}
+
+/** @internal
+ * Execute the messages in the incoming queue until the queue is empty..
+ *
+ * @param self - pointer to a port object
+ *
+ * @retval 0 if there was a signal to handle, 
+ * @retval -1 otherwise.
+ */
+static
+int su_source_getmsgs(su_port_t *self)
+{
+  enter;
+  
+  if (self && self->sup_head) {
+    su_root_t *root;
+    su_msg_f f;
+
+    SU_SOURCE_INCREF(self, "su_source_getmsgs");
+    SU_SOURCE_LOCK(self, "su_source_getmsgs");
+
+    while (self->sup_head) {
+      su_msg_t *msg = self->sup_head;
+      self->sup_head = msg->sum_next;
+      if (!self->sup_head) {
+	assert(self->sup_tail == &msg->sum_next);
+	self->sup_tail = &self->sup_head;
+      }
+      root = msg->sum_to->sut_root;
+      f = msg->sum_func;
+      SU_SOURCE_UNLOCK(self, "su_source_getmsgs");
+      if (f) 
+	f(su_root_magic(root), &msg, msg->sum_data);
+      su_msg_delivery_report(&msg);
+      SU_SOURCE_LOCK(self, "su_source_getmsgs");
+    }
+
+    SU_SOURCE_UNLOCK(self, "su_source_getmsgs");
+    SU_SOURCE_DECREF(self, "su_source_getmsgs");
+
+    return 0;
+  }
+  else
+    return -1;
+}
+
 /** @internal
  *
  *  Register a @c su_wait_t object. The wait object, a callback function and
@@ -881,6 +914,13 @@
     return (errno = EINVAL), -1;
 }
 
+/** @internal Enable threadsafe operation. */
+static
+int su_source_threadsafe(su_port_t *port)
+{
+  return su_home_threadsafe(port->sup_home);
+}
+
 
 /** @internal Main loop.
  * 
@@ -979,19 +1019,18 @@
   return 0;
 }
 
-static int su_source_add_prepoll(su_port_t *port,
-				 su_root_t *root, 
-				 su_prepoll_f *prepoll, 
-				 su_prepoll_magic_t *magic)
-{
-  /* We could call prepoll in su_source_prepare()?? */
-  return -1;
-}
 
-static int su_source_remove_prepoll(su_port_t *port,
-				  su_root_t *root)
+/** @internal
+ * Checks if the calling thread owns the port object.
+ *
+ * @param self pointer to a port object
+ *
+ * @retval true (nonzero) if the calling thread owns the port,
+ * @retval false (zero) otherwise.
+ */
+int su_source_own_thread(su_port_t const *self)
 {
-  return -1;
+  return self == NULL || SU_SOURCE_OWN_THREAD(self);
 }
 
 #if 0
@@ -1022,44 +1061,52 @@
 
 #endif
 
-/**@internal
- *
- * Allocates and initializes a reactor and message port object.
- *
- * @return
- *   If successful a pointer to the new message port is returned, otherwise
- *   NULL is returned.  
+/* =========================================================================
+ * Pre-poll() callback
  */
-static su_port_t *su_source_port_create(void)
+
+int su_source_add_prepoll(su_port_t *port,
+			su_root_t *root, 
+			su_prepoll_f *callback, 
+			su_prepoll_magic_t *magic)
 {
-  SuSource *ss;
-  su_port_t *self = NULL;
+#if 0
+  if (port->sup_prepoll)
+    return -1;
 
-  SU_DEBUG_9(("su_source_port_create() called\n"));
+  port->sup_prepoll = callback;
+  port->sup_pp_magic = magic;
+  port->sup_pp_root = root;
 
-  ss = (SuSource *)g_source_new(su_source_funcs, (sizeof *ss));
+  return 0;
+#else
+  return -1;
+#endif
+}
 
-  if (ss) {
-    self = ss->ss_port;
-    if (su_source_port_init(self, ss->ss_source, su_source_port_vtable) < 0)
-      g_source_unref(ss->ss_source), self = NULL;
-  } else {
-    su_perror("su_source_port_create(): g_source_new");
-  }
+int su_source_remove_prepoll(su_port_t *port,
+			   su_root_t *root)
+{
+#if 0
+  if (port->sup_pp_root != root)
+    return -1;
 
-  SU_DEBUG_1(("su_source_port_create() returns %p\n", (void *)self));
+  port->sup_prepoll = NULL;
+  port->sup_pp_magic = NULL;
+  port->sup_pp_root = NULL;
 
-  return self;
+  return 0;
+#else
+  return -1;
+#endif
 }
 
-/* No su_source_port_start */
-
-/** Use su_source implementation when su_root_create() is called.
- *
- * @NEW_1_12_5
+/* =========================================================================
+ * Timers
  */
-void su_glib_prefer_gsource(void)
+
+static
+su_timer_t **su_source_timers(su_port_t *self)
 {
-  su_port_prefer(su_source_port_create, NULL);
+  return &self->sup_timers;
 }
-

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ChangeLog
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ChangeLog	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ChangeLog	Sat Feb 17 01:25:21 2007
@@ -1,11 +1,3 @@
-2007-02-09  Kai Vehmanen  <kai.vehmanen at nokia.com>
-
-	* libsofia-sip-ua interface v4 frozen (4:0:4) for the 1.12.5 release
-
-2006-10-12  Kai Vehmanen  <kai.vehmanen at nokia.com>
-
-	* libsofia-sip-ua interface v3 frozen (3:0:3) for the 1.12.3 release
-	
 2006-09-26  Kai Vehmanen  <kai.vehmanen at nokia.com>
 
 	* libsofia-sip-ua interface v2 frozen (2:0:2) for the 1.12.2 release

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -9,25 +9,12 @@
 
 AUTOMAKE_OPTIONS = foreign
 
-# select whicn optional sofia-sip modules have been enabled
-# in the build
-OPT_LIBADD =
-OPT_SUBDIRS_STUN =
-OPT_SUBDIRS_NTH =
-if HAVE_STUN
-OPT_LIBADD += stun/libstun.la 
-OPT_SUBDIRS_STUN += stun
-endif
-if HAVE_NTH
-OPT_LIBADD += nth/libnth.la http/libhttp.la
-OPT_SUBDIRS_NTH += nth http
-endif
-
 # note: order does matter in the subdir list
-SUBDIRS = su features bnf sresolv sdp url msg sip $(OPT_SUBDIRS_STUN) ipt soa \
-	  tport nta nea iptsec $(OPT_SUBDIRS_NTH) nua
+SUBDIRS = su features bnf sresolv sdp url msg sip stun ipt soa \
+	  tport http nta nea iptsec nth nua
 DIST_SUBDIRS = $(SUBDIRS) docs
 
+EXTRA_DIST = sofia.am
 DOXYGEN = doxygen
 
 lib_LTLIBRARIES = libsofia-sip-ua.la
@@ -40,22 +27,37 @@
 				msg/libmsg.la \
 				nea/libnea.la \
 				nta/libnta.la \
+				nth/libnth.la \
 				nua/libnua.la \
+				http/libhttp.la \
 				sdp/libsdp.la \
 				sip/libsip.la \
 				soa/libsoa.la \
 				sresolv/libsresolv.la \
 				su/libsu.la \
+				stun/libstun.la \
 				tport/libtport.la \
-				url/liburl.la \
-				$(OPT_LIBADD)
-
+				url/liburl.la
 # set the libtool version info version:revision:age for libsofia-sip-ua
 # - soname to 'libsofia-sip-ua.so.(CUR-AGE)'
 libsofia_sip_ua_la_LDFLAGS = \
 	-version-info $(LIBVER_SOFIA_SIP_UA_CUR):$(LIBVER_SOFIA_SIP_UA_REV):$(LIBVER_SOFIA_SIP_UA_AGE)
 
-include $(top_srcdir)/rules/recursive.am
+if ENABLE_COVERAGE
+COVERAGE_RECURSIVE = coverage-recursive
+coverage: $(COVERAGE_RECURSIVE)
+endif
+
+all-recursive: built-sources-recursive
+built-sources: built-sources-recursive 
+clean-built-sources: clean-built-sources-recursive
+
+built-sources-recursive clean-built-sources-recursive $(COVERAGE_RECURSIVE):
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $@ in $$subdir"; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
+	done;
 
 doxygen: built-sources
 	@echo Generating empty doxytags

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -23,9 +23,6 @@
 #
 # ref: http://www.gnu.org/software/automake/manual/automake.html
 
-# Recursive Makefile targets
-# --------------------------
-
 SOURCES = $(libsofia_sip_ua_la_SOURCES)
 
 srcdir = @srcdir@
@@ -51,13 +48,8 @@
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
- at HAVE_STUN_TRUE@am__append_1 = stun/libstun.la 
- at HAVE_STUN_TRUE@am__append_2 = stun
- at HAVE_NTH_TRUE@am__append_3 = nth/libnth.la http/libhttp.la
- at HAVE_NTH_TRUE@am__append_4 = nth http
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(top_srcdir)/rules/recursive.am ChangeLog
 subdir = libsofia-sip-ua
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
 	$(top_srcdir)/m4/sac-openssl.m4 $(top_srcdir)/m4/sac-su.m4 \
@@ -78,15 +70,12 @@
 am__installdirs = "$(DESTDIR)$(libdir)"
 libLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(lib_LTLIBRARIES)
- at HAVE_STUN_TRUE@am__DEPENDENCIES_1 = stun/libstun.la
- at HAVE_NTH_TRUE@am__DEPENDENCIES_2 = nth/libnth.la http/libhttp.la
-am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
 libsofia_sip_ua_la_DEPENDENCIES = bnf/libbnf.la \
 	features/libfeatures.la ipt/libipt.la iptsec/libiptsec.la \
-	msg/libmsg.la nea/libnea.la nta/libnta.la nua/libnua.la \
-	sdp/libsdp.la sip/libsip.la soa/libsoa.la \
-	sresolv/libsresolv.la su/libsu.la tport/libtport.la \
-	url/liburl.la $(am__DEPENDENCIES_3)
+	msg/libmsg.la nea/libnea.la nta/libnta.la nth/libnth.la \
+	nua/libnua.la http/libhttp.la sdp/libsdp.la sip/libsip.la \
+	soa/libsoa.la sresolv/libsresolv.la su/libsu.la \
+	stun/libstun.la tport/libtport.la url/liburl.la
 am_libsofia_sip_ua_la_OBJECTS =
 libsofia_sip_ua_la_OBJECTS = $(am_libsofia_sip_ua_la_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/libsofia-sip-ua/su/sofia-sip
@@ -110,7 +99,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -157,12 +145,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -206,7 +190,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -263,17 +246,12 @@
 target_vendor = @target_vendor@
 AUTOMAKE_OPTIONS = foreign
 
-# select whicn optional sofia-sip modules have been enabled
-# in the build
-OPT_LIBADD = $(am__append_1) $(am__append_3)
-OPT_SUBDIRS_STUN = $(am__append_2)
-OPT_SUBDIRS_NTH = $(am__append_4)
-
 # note: order does matter in the subdir list
-SUBDIRS = su features bnf sresolv sdp url msg sip $(OPT_SUBDIRS_STUN) ipt soa \
-	  tport nta nea iptsec $(OPT_SUBDIRS_NTH) nua
+SUBDIRS = su features bnf sresolv sdp url msg sip stun ipt soa \
+	  tport http nta nea iptsec nth nua
 
 DIST_SUBDIRS = $(SUBDIRS) docs
+EXTRA_DIST = sofia.am
 lib_LTLIBRARIES = libsofia-sip-ua.la
 libsofia_sip_ua_la_SOURCES = 
 libsofia_sip_ua_la_LIBADD = bnf/libbnf.la \
@@ -283,16 +261,17 @@
 				msg/libmsg.la \
 				nea/libnea.la \
 				nta/libnta.la \
+				nth/libnth.la \
 				nua/libnua.la \
+				http/libhttp.la \
 				sdp/libsdp.la \
 				sip/libsip.la \
 				soa/libsoa.la \
 				sresolv/libsresolv.la \
 				su/libsu.la \
+				stun/libstun.la \
 				tport/libtport.la \
-				url/liburl.la \
-				$(OPT_LIBADD)
-
+				url/liburl.la
 
 # set the libtool version info version:revision:age for libsofia-sip-ua
 # - soname to 'libsofia-sip-ua.so.(CUR-AGE)'
@@ -300,18 +279,10 @@
 	-version-info $(LIBVER_SOFIA_SIP_UA_CUR):$(LIBVER_SOFIA_SIP_UA_REV):$(LIBVER_SOFIA_SIP_UA_AGE)
 
 @ENABLE_COVERAGE_TRUE at COVERAGE_RECURSIVE = coverage-recursive
-SOFIA_RECURSIVE = \
-	valcheck-recursive \
-	$(COVERAGE_RECURSIVE)
-
-SOFIA_DIST_RECURSIVE = \
-	built-sources-recursive \
-	clean-built-sources-recursive
-
 all: all-recursive
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/recursive.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -507,7 +478,6 @@
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../rules
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -653,39 +623,13 @@
 all-recursive: built-sources-recursive
 built-sources: built-sources-recursive 
 clean-built-sources: clean-built-sources-recursive
-valcheck: valcheck-recursive
-
-$(SOFIA_RECURSIVE):
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  echo "Making $$target in $$subdir"; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
-	  || eval $$failcom; \
-	done; \
-	test -z "$$fail"
 
-$(SOFIA_DIST_RECURSIVE):
-	@failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+built-sources-recursive clean-built-sources-recursive $(COVERAGE_RECURSIVE):
 	target=`echo $@ | sed s/-recursive//`; \
 	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  echo "Making $$target in $$subdir"; \
+	  echo "Making $@ in $$subdir"; \
 	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target) \
-	  || eval $$failcom; \
-	done; \
-	test -z "$$fail"
+	done;
 
 doxygen: built-sources
 	@echo Generating empty doxytags
@@ -718,7 +662,7 @@
 	for d in $(DIST_SUBDIRS); do \
 	  test -r $$d/Doxyfile \
 	  && pushd $$d > /dev/null \
-	  && echo running ${DOXYGEN} second time in $$d \
+	  && echo running ${DOXYGEN} in second time in $$d \
           && ${DOXYGEN} 2>&1 \
 	   | egrep -v -i -e 'Warning: Unsupported (xml/)?html tag' \
           ; popd > /dev/null ; \

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -43,5 +43,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libbnf_la_SOURCES) torture_bnf.c
@@ -79,12 +54,8 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = torture_bnf$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/bnf
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -131,7 +102,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -178,12 +148,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -227,7 +193,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -303,8 +268,7 @@
 # ----------------------------------------------------------------------
 # Tests
 TESTS = torture_bnf
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -330,13 +294,11 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -568,7 +530,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -716,92 +678,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/bnf/bnf.c	Sat Feb 17 01:25:21 2007
@@ -825,9 +825,9 @@
 {
   size_t len;
   int canonize = 0;
-  char buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
 
 #if SU_HAVE_IN6
+  char buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
 
   len = span_ip6_reference(s);
   if (len) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Doxyfile.aliases
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Doxyfile.aliases	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Doxyfile.aliases	Sat Feb 17 01:25:21 2007
@@ -45,5 +45,4 @@
  "VERSION_1_12_4=<a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.4.txt\">1.12.4</a>" \
  "VERSION_1_12_5=<a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.5.txt\">1.12.5</a>" \
  "NEW_1_12_5=@since New in <a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.5.txt\">1.12.5</a>" \
- "EXP_1_12_5=@since Experimental in <a href=\"http://sofia-sip.sf.net/relnotes/relnotes-sofia-sip-1.12.5.txt\">1.12.5</a>, available if --enable-experimental configuration option is given" \
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -47,4 +47,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
\ No newline at end of file

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -14,33 +14,8 @@
 
 @SET_MAKE@
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -64,13 +39,9 @@
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(srcdir)/Doxyfile.version.in $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(srcdir)/sofia-footer.html.in \
-	$(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am \
-	ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(srcdir)/../sofia.am $(srcdir)/Doxyfile.version.in \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/sofia-footer.html.in ChangeLog
 subdir = libsofia-sip-ua/docs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -88,7 +59,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -135,12 +105,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -184,7 +150,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -270,8 +235,7 @@
 
 BUILT_SOURCES = Doxyfile.rfc
 CLEANFILES = Doxyfile.rfc
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -297,13 +261,11 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -354,7 +316,7 @@
 
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/pictures
+	$(mkdir_p) $(distdir)/.. $(distdir)/pictures
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -505,92 +467,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -31,5 +31,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/features/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libfeatures_la_SOURCES)
@@ -78,12 +53,8 @@
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/features
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -126,7 +97,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -173,12 +143,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -222,7 +188,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -293,8 +258,7 @@
 # ----------------------------------------------------------------------
 # Install and distribution rules
 EXTRA_DIST = Doxyfile features.docs
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -320,13 +284,11 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -474,7 +436,7 @@
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -619,92 +581,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -64,7 +64,7 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 TAG_DLL_FLAGS = DLLREF=1
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libhttp_la_SOURCES) test_http.c
@@ -79,12 +54,8 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = test_http$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/http
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -135,7 +106,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -182,12 +152,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -231,7 +197,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -330,8 +295,7 @@
 			http_parser_table.c.in \
 			http_tag.c.in
 
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -357,8 +321,6 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -370,7 +332,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -610,7 +572,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -761,92 +723,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 sofia-sip/http_tag.h: sofia-sip/http_tag.h.in $(MSG_PARSER_AWK)
 sofia-sip/http_protos.h: sofia-sip/http_protos.h.in $(MSG_PARSER_AWK)
 http_tag.c: http_tag.c.in $(MSG_PARSER_AWK)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c	Sat Feb 17 01:25:21 2007
@@ -61,9 +61,9 @@
 /** HTTP version 0.9 is an empty string. */
 char const http_version_0_9[] = "";
 
-msg_mclass_t const *http_default_mclass(void)
+msg_mclass_t *http_default_mclass(void)
 {
-  extern msg_mclass_t const http_mclass[];
+  extern msg_mclass_t http_mclass[];
 
   return http_mclass;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/sofia-sip/http_header.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/sofia-sip/http_header.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/sofia-sip/http_header.h	Sat Feb 17 01:25:21 2007
@@ -95,7 +95,7 @@
  */
 
 /** HTTP parser description. */
-SOFIAPUBFUN msg_mclass_t const *http_default_mclass(void);
+SOFIAPUBFUN msg_mclass_t *http_default_mclass(void);
 
 /** Complete a HTTP request. */
 SOFIAPUBFUN int http_request_complete(msg_t *msg);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/test_http.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/test_http.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/test_http.c	Sat Feb 17 01:25:21 2007
@@ -76,7 +76,7 @@
 static int test_query_parser(void);
 
 static msg_t *read_message(char const string[]);
-msg_mclass_t const *test_mclass = NULL;
+msg_mclass_t *test_mclass = NULL;
 
 void usage(void)
 {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -51,5 +51,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libipt_la_SOURCES) torture_base64.c
@@ -79,12 +54,8 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = torture_base64$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/ipt
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -132,7 +103,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -179,12 +149,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -228,7 +194,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -310,8 +275,7 @@
 			../su/libsu.la
 
 torture_base64_LDFLAGS = -static
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -337,13 +301,11 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -577,7 +539,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -725,92 +687,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/sofia-sip/base64.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/sofia-sip/base64.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/ipt/sofia-sip/base64.h	Sat Feb 17 01:25:21 2007
@@ -57,9 +57,6 @@
 /** Calculate size of n bytes encoded in base64 */
 #define BASE64_SIZE(n) ((((n) + 2) / 3) * 4)
 
-/** Calculate size of n bytes encoded in base64 sans trailing =. @NEW_1_12_5 */
-#define BASE64_MINSIZE(n) ((n * 4 + 2) / 3)
-
 SOFIA_END_DECLS
 
 #endif /* !BASE_64 */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -35,18 +35,29 @@
 			sofia-sip/auth_common.h \
 			sofia-sip/auth_client.h sofia-sip/auth_digest.h \
 			sofia-sip/auth_module.h sofia-sip/auth_plugin.h \
-			sofia-sip/auth_client_plugin.h
+			sofia-sip/auth_client_plugin.h \
+			$(NTLM_HEADER)
 
 libiptsec_la_SOURCES = 	iptsec_debug.h \
 			auth_client.c auth_common.c auth_digest.c \
 			auth_module.c auth_tag.c auth_tag_ref.c \
 			auth_plugin.c auth_plugin_delayed.c \
-			auth_module_sip.c \
+			auth_module_http.c auth_module_sip.c \
+			$(NTLM_SOURCE) \
 			iptsec_debug.c
 
+NTLM_HEADER = 		sofia-sip/auth_ntlm.h
+if HAVE_NTLM
+NTLM_SOURCE = 		auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
+endif
+
+EXTRA_libiptsec_la_SOURCES = \
+			auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
+
 COVERAGE_INPUT = 	$(libiptsec_la_SOURCES) $(include_sofia_HEADERS)
 
 LDADD = 		libiptsec.la \
+			../http/libhttp.la \
 			../nta/libnta.la \
 			../sip/libsip.la \
 			../msg/libmsg.la \
@@ -57,31 +68,13 @@
 
 test_auth_digest_LDFLAGS = -static
 
-if HAVE_NTLM
-nobase_include_sofia_HEADERS += $(NTLM_HEADER)
-libiptsec_la_SOURCES += $(NTLM_SOURCE)
-endif
-
-if HAVE_NTH
-libiptsec_la_SOURCES += $(HTTP_SOURCE)
-LDADD +=		../http/libhttp.la
-endif
-
-HTTP_SOURCE =		auth_module_http.c
-
-NTLM_HEADER = 		sofia-sip/auth_ntlm.h
-NTLM_SOURCE = 		auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
-
-EXTRA_libiptsec_la_SOURCES = \
-			$(NTLM_HEADER) $(NTLM_SOURCE) $(HTTP_SOURCE)
-
 # ----------------------------------------------------------------------
 # Install and distribution rules
 
-EXTRA_DIST = 		Doxyfile iptsec.docs testpasswd $(BUILT_SOURCES)
+EXTRA_DIST = 		Doxyfile iptsec.docs testpasswd \
+			auth_module_sip.c auth_module_http.c $(BUILT_SOURCES)
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libiptsec_la_SOURCES) $(EXTRA_libiptsec_la_SOURCES) test_auth_digest.c
@@ -79,17 +54,8 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = test_auth_digest$(EXEEXT)
- at HAVE_NTLM_TRUE@am__append_1 = $(NTLM_HEADER)
- at HAVE_NTLM_TRUE@am__append_2 = $(NTLM_SOURCE)
- at HAVE_NTH_TRUE@am__append_3 = $(HTTP_SOURCE)
- at HAVE_NTH_TRUE@am__append_4 = ../http/libhttp.la
-DIST_COMMON = $(am__nobase_include_sofia_HEADERS_DIST) \
-	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am \
-	ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_5 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/iptsec
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -107,25 +73,22 @@
 am__libiptsec_la_SOURCES_DIST = iptsec_debug.h auth_client.c \
 	auth_common.c auth_digest.c auth_module.c auth_tag.c \
 	auth_tag_ref.c auth_plugin.c auth_plugin_delayed.c \
-	auth_module_sip.c iptsec_debug.c auth_ntlm.c \
-	auth_client_ntlm.c auth_plugin_ntlm.c auth_module_http.c
-am__objects_1 = auth_ntlm.lo auth_client_ntlm.lo auth_plugin_ntlm.lo
- at HAVE_NTLM_TRUE@am__objects_2 = $(am__objects_1)
-am__objects_3 = auth_module_http.lo
- at HAVE_NTH_TRUE@am__objects_4 = $(am__objects_3)
+	auth_module_http.c auth_module_sip.c auth_ntlm.c \
+	auth_client_ntlm.c auth_plugin_ntlm.c iptsec_debug.c
+ at HAVE_NTLM_TRUE@am__objects_1 = auth_ntlm.lo auth_client_ntlm.lo \
+ at HAVE_NTLM_TRUE@	auth_plugin_ntlm.lo
 am_libiptsec_la_OBJECTS = auth_client.lo auth_common.lo auth_digest.lo \
 	auth_module.lo auth_tag.lo auth_tag_ref.lo auth_plugin.lo \
-	auth_plugin_delayed.lo auth_module_sip.lo iptsec_debug.lo \
-	$(am__objects_2) $(am__objects_4)
+	auth_plugin_delayed.lo auth_module_http.lo auth_module_sip.lo \
+	$(am__objects_1) iptsec_debug.lo
 libiptsec_la_OBJECTS = $(am_libiptsec_la_OBJECTS)
 test_auth_digest_SOURCES = test_auth_digest.c
 test_auth_digest_OBJECTS = test_auth_digest.$(OBJEXT)
 test_auth_digest_LDADD = $(LDADD)
- at HAVE_NTH_TRUE@am__DEPENDENCIES_1 = ../http/libhttp.la
-test_auth_digest_DEPENDENCIES = libiptsec.la ../nta/libnta.la \
-	../sip/libsip.la ../msg/libmsg.la ../url/liburl.la \
-	../bnf/libbnf.la ../ipt/libipt.la ../su/libsu.la \
-	$(am__DEPENDENCIES_1)
+test_auth_digest_DEPENDENCIES = libiptsec.la ../http/libhttp.la \
+	../nta/libnta.la ../sip/libsip.la ../msg/libmsg.la \
+	../url/liburl.la ../bnf/libbnf.la ../ipt/libipt.la \
+	../su/libsu.la
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/libsofia-sip-ua/su/sofia-sip
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
@@ -141,10 +104,6 @@
 	test_auth_digest.c
 DIST_SOURCES = $(am__libiptsec_la_SOURCES_DIST) \
 	$(EXTRA_libiptsec_la_SOURCES) test_auth_digest.c
-am__nobase_include_sofia_HEADERS_DIST = sofia-sip/auth_common.h \
-	sofia-sip/auth_client.h sofia-sip/auth_digest.h \
-	sofia-sip/auth_module.h sofia-sip/auth_plugin.h \
-	sofia-sip/auth_client_plugin.h sofia-sip/auth_ntlm.h
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -158,7 +117,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -205,12 +163,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -254,7 +208,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -327,31 +280,45 @@
 # ----------------------------------------------------------------------
 # Rules for building the targets
 BUILT_SOURCES = auth_tag_ref.c
-nobase_include_sofia_HEADERS = sofia-sip/auth_common.h \
-	sofia-sip/auth_client.h sofia-sip/auth_digest.h \
-	sofia-sip/auth_module.h sofia-sip/auth_plugin.h \
-	sofia-sip/auth_client_plugin.h $(am__append_1)
-libiptsec_la_SOURCES = iptsec_debug.h auth_client.c auth_common.c \
-	auth_digest.c auth_module.c auth_tag.c auth_tag_ref.c \
-	auth_plugin.c auth_plugin_delayed.c auth_module_sip.c \
-	iptsec_debug.c $(am__append_2) $(am__append_3)
-COVERAGE_INPUT = $(libiptsec_la_SOURCES) $(include_sofia_HEADERS)
-LDADD = libiptsec.la ../nta/libnta.la ../sip/libsip.la \
-	../msg/libmsg.la ../url/liburl.la ../bnf/libbnf.la \
-	../ipt/libipt.la ../su/libsu.la $(am__append_4)
-test_auth_digest_LDFLAGS = -static
-HTTP_SOURCE = auth_module_http.c
+nobase_include_sofia_HEADERS = \
+			sofia-sip/auth_common.h \
+			sofia-sip/auth_client.h sofia-sip/auth_digest.h \
+			sofia-sip/auth_module.h sofia-sip/auth_plugin.h \
+			sofia-sip/auth_client_plugin.h \
+			$(NTLM_HEADER)
+
+libiptsec_la_SOURCES = iptsec_debug.h \
+			auth_client.c auth_common.c auth_digest.c \
+			auth_module.c auth_tag.c auth_tag_ref.c \
+			auth_plugin.c auth_plugin_delayed.c \
+			auth_module_http.c auth_module_sip.c \
+			$(NTLM_SOURCE) \
+			iptsec_debug.c
+
 NTLM_HEADER = sofia-sip/auth_ntlm.h
-NTLM_SOURCE = auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
+ at HAVE_NTLM_TRUE@NTLM_SOURCE = auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
 EXTRA_libiptsec_la_SOURCES = \
-			$(NTLM_HEADER) $(NTLM_SOURCE) $(HTTP_SOURCE)
+			auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
 
+COVERAGE_INPUT = $(libiptsec_la_SOURCES) $(include_sofia_HEADERS)
+LDADD = libiptsec.la \
+			../http/libhttp.la \
+			../nta/libnta.la \
+			../sip/libsip.la \
+			../msg/libmsg.la \
+			../url/liburl.la \
+			../bnf/libbnf.la \
+			../ipt/libipt.la \
+			../su/libsu.la
+
+test_auth_digest_LDFLAGS = -static
 
 # ----------------------------------------------------------------------
 # Install and distribution rules
-EXTRA_DIST = Doxyfile iptsec.docs testpasswd $(BUILT_SOURCES)
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_5)
+EXTRA_DIST = Doxyfile iptsec.docs testpasswd \
+			auth_module_sip.c auth_module_http.c $(BUILT_SOURCES)
+
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -377,14 +344,12 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -629,7 +594,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -780,92 +745,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c	Sat Feb 17 01:25:21 2007
@@ -210,8 +210,6 @@
  * @retval number of challenges to updated
  * @retval 0 when there was no challenge to update
  * @retval -1 upon an error
- *
- * @NEW_1_12_5
  */
 int auc_info(auth_client_t **auc_list,
 	     msg_auth_info_t const *ai,
@@ -497,8 +495,6 @@
  * 
  * @retval 1 when authorization can proceed
  * @retval 0 when there is not enough credentials
- *
- * @NEW_1_12_5
  */
 int auc_has_authorization(auth_client_t **auc_list)
 {
@@ -770,13 +766,22 @@
   if (ac->ac_qop && (cda->cda_cnonce == NULL || ac->ac_stale)) {
     su_guid_t guid[1];
     char *cnonce;
-    size_t b64len = BASE64_MINSIZE(sizeof(guid)) + 1;
+    char *e;
+
     if (cda->cda_cnonce != NULL)
       /* Free the old one if we are updating after stale=true */
       su_free(home, (void *)cda->cda_cnonce);
     su_guid_generate(guid);
-    cda->cda_cnonce = cnonce = su_alloc(home, b64len);
-    base64_e(cnonce, b64len, guid, sizeof(guid));
+    cda->cda_cnonce = cnonce = su_alloc(home, BASE64_SIZE(sizeof(guid)) + 1);
+    base64_e(cnonce, BASE64_SIZE(sizeof(guid)) + 1, guid, sizeof(guid));
+    /* somewhere else in the code the '=' chars are stripped in the header 
+       we need to strip it now before the digest is created or we're in trouble
+       cos they won't match.....
+    */
+    e = cnonce + strlen(cnonce) - 1;
+    while(*e == '=') {
+       *e-- = '\0';
+    }
     cda->cda_ncount = 0;
   }
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c	Sat Feb 17 01:25:21 2007
@@ -76,7 +76,6 @@
 
 char const auth_internal_server_error[] = "Internal server error";
 
-static void auth_call_scheme_destructor(void *);
 static void auth_md5_hmac_key(auth_mod_t *am);
 
 HTABLE_PROTOS_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
@@ -95,7 +94,7 @@
 
   if ((am = su_home_new(scheme->asch_size))) {
     am->am_scheme = scheme;
-    su_home_destructor(am->am_home, auth_call_scheme_destructor);
+    am->am_refcount = 1;
   }
 
   return am;
@@ -247,14 +246,10 @@
 /** Destroy (a reference to) an authentication module. */
 void auth_mod_destroy(auth_mod_t *am)
 {
-  su_home_unref(am->am_home);
-}
-
-/** Call scheme-specific destructor function. */
-static void auth_call_scheme_destructor(void *arg)
-{
-  auth_mod_t *am = arg;
-  am->am_scheme->asch_destroy(am);
+  if (am && am->am_refcount != 0 && --am->am_refcount == 0) {
+    am->am_scheme->asch_destroy(am);
+    su_home_zap(am->am_home);
+  }
 }
 
 /** Do-nothing destroy function.
@@ -269,13 +264,18 @@
 /** Create a new reference to authentication module. */
 auth_mod_t *auth_mod_ref(auth_mod_t *am)
 {
-  return (auth_mod_t *)su_home_ref(am->am_home);
+  if (!am || am->am_refcount == 0)
+    return NULL;
+
+  am->am_refcount++;
+
+  return am;
 }
 
 /** Destroy a reference to an authentication module. */
 void auth_mod_unref(auth_mod_t *am)
 {
-  su_home_unref(am->am_home);
+  auth_mod_destroy(am);
 }
 
 /** Get authenticatin module name. @NEW_1_12_4. */
@@ -608,7 +608,7 @@
   uint8_t    digest[6];
 };
 
-#define AUTH_DIGEST_NONCE_LEN (BASE64_MINSIZE(sizeof (struct nonce)) + 1)
+#define AUTH_DIGEST_NONCE_LEN (BASE64_SIZE(sizeof (struct nonce)) + 1)
 
 /** Authenticate a request with @b Digest authentication scheme.
  *
@@ -950,8 +950,7 @@
 #include <sys/file.h>
 #endif
 
-/* This is just a magic value */
-#define auth_apw_local ((void *)(intptr_t)auth_readdb_internal)
+#define auth_apw_local auth_readdb_internal
 
 /** Read authentication database */
 static

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_delayed.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_delayed.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_delayed.c	Sat Feb 17 01:25:21 2007
@@ -126,7 +126,7 @@
 
 struct auth_splugin_t 
 {
-  void const      *asp_cookie;
+  void const      *asp_tag;
   auth_splugin_t  *asp_next;
   auth_splugin_t **asp_prev;
   auth_mod_t      *asp_am;
@@ -136,8 +136,6 @@
   int              asp_canceled;
 };
 
-/* This is unique identifier */
-#define delayed_asp_cookie ((void const *)(intptr_t)delayed_auth_cancel)
 
 static void delayed_auth_method_recv(su_root_magic_t *rm,
 				     su_msg_r msg,
@@ -164,7 +162,7 @@
 
   asp = su_msg_data(mamc); assert(asp);
 
-  asp->asp_cookie = delayed_asp_cookie;
+  asp->asp_tag = delayed_auth_cancel;
   asp->asp_am = am;
   asp->asp_as = as;
   asp->asp_header = auth;
@@ -218,7 +216,7 @@
 
   (void)ap;			/* xyzzy */
   
-  if (as->as_plugin && as->as_plugin->asp_cookie == delayed_asp_cookie)
+  if (as->as_plugin && as->as_plugin->asp_tag == delayed_auth_cancel)
     as->as_plugin->asp_canceled = 1;
 
   as->as_status = 500, as->as_phrase = "Authentication canceled";

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/sofia-sip/auth_plugin.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/sofia-sip/auth_plugin.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/sofia-sip/auth_plugin.h	Sat Feb 17 01:25:21 2007
@@ -105,7 +105,7 @@
 typedef struct
 {
   unsigned        apw_index;	/**< Key to hash table */
-  void const     *apw_type;	/**< Magic identifier */
+  void const     *apw_type;	/**< Magic pointer */
 
   char const   	 *apw_user;	/**< Username */
   char const     *apw_realm;	/**< Realm */
@@ -124,7 +124,7 @@
 struct auth_mod_t
 {
   su_home_t      am_home[1];
-  unsigned       _am_refcount;	/**< Not used */
+  unsigned       am_refcount;	/**< Number of references to this module */
 
   /* User database / cache */
   char const    *am_db;		/**< User database file name */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c	Sat Feb 17 01:25:21 2007
@@ -769,6 +769,8 @@
     {
       char const *nonce1, *nextnonce, *nonce2;
 
+      reinit_as(as); auth_mod_destroy(am); aucs = NULL;
+
       TEST_1(am = auth_mod_create(NULL, 
 				  AUTHTAG_METHOD("Digest"),
 				  AUTHTAG_REALM("ims3.so.noklab.net"),

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -77,7 +77,7 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 MSG_PARSER_AWK = $(srcdir)/msg_parser.awk
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 
@@ -82,12 +57,8 @@
 target_triplet = @target@
 check_PROGRAMS = msg_name_hash$(EXEEXT) test_msg$(EXEEXT)
 DIST_COMMON = $(dist_pkgdata_SCRIPTS) $(nobase_include_sofia_HEADERS) \
-	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am \
-	ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+	$(srcdir)/../sofia.am $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/msg
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -155,7 +126,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -202,12 +172,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -251,7 +217,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -362,8 +327,7 @@
 # ----------------------------------------------------------------------
 # Tests
 TESTS = test_msg
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -389,8 +353,6 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -401,7 +363,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -677,7 +639,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -831,92 +793,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 test_protos.h: test_protos.h.in $(MSG_PARSER_AWK)
 test_table.c: test_table.c.in $(MSG_PARSER_AWK)
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.awk
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.awk	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.awk	Sat Feb 17 01:25:21 2007
@@ -54,13 +54,11 @@
   split("", NAMES);
   split("", Comments);
   split("", COMMENTS);
-  split("", experimental);
 
   # indexed by the C name of the header
   split("", Since);		# Non-NUL if extra
   split("", Extra);		# Offset in extra headers
 
-  without_experimental = 0;
   template="";
   template1="";
   template2="";
@@ -157,24 +155,11 @@
     Extra[name] = extra++;
   }
 
-  expr = (without_experimental > 0 && do_hash);
-  if (expr) {
-    printf "%s is experimental\n", Comment;
-  }    
-  
-  experimental[N] = expr;
-
   if (PR) {
-    if (expr) {
-      print "#if SU_HAVE_EXPERIMENTAL" > PR;
-    }
     replace(template, hash, name, NAME, comment, Comment, COMMENT, since);
     replace(template1, hash, name, NAME, comment, Comment, COMMENT, since);
     replace(template2, hash, name, NAME, comment, Comment, COMMENT, since);
     replace(template3, hash, name, NAME, comment, Comment, COMMENT, since);
-    if (expr) {
-      print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
-    }
   }
 }
 
@@ -225,19 +210,8 @@
   for (i = 1; i <= n; i++) {
     l = lines[i];
     if (match(tolower(l), /#(xxxxxx(x_xxxxxxx)?|hash)#/)) {
-      expr = 0;
-
       for (j = 1; j <= N; j++) {
 	l = lines[i];
-	if (expr != experimental[j]) {
-	  expr = experimental[j];
-	  if (expr) {
-	    print "#if SU_HAVE_EXPERIMENTAL" > PR;
-	  }
-	  else {
-	    print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
-	  }
-	}
 	gsub(/#hash#/, hashes[j], l);
 	gsub(/#xxxxxxx_xxxxxxx#/, comments[j], l);
 	gsub(/#Xxxxxxx_Xxxxxxx#/, Comments[j], l);
@@ -246,10 +220,6 @@
 	gsub(/#XXXXXX#/, NAMES[j], l);
 	print l > PR;
       }
-
-      if (expr) {
-	print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
-      }
     } else {
       print l > PR;
     }
@@ -363,11 +333,10 @@
 }
 
 /^#### EXTRA HEADER LIST STARTS HERE ####$/ { HLIST=1; templates(); }
-HLIST && /^#### EXPERIMENTAL HEADER LIST STARTS HERE ####$/ { 
-  without_experimental=total; }
 HLIST && /^[a-z]/ { protos($1, $0, 0, $2); headers[total++] = $1; }
 /^#### EXTRA HEADER LIST ENDS HERE ####$/ { HLIST=0;  }
 
+
 /^ *\/\* === Headers start here \*\// { in_header_list=1;  templates(); }
 /^ *\/\* === Headers end here \*\// { in_header_list=0; }
 
@@ -397,13 +366,10 @@
 END {
   if (failed) { exit };
 
-  if (without_experimental == 0)
-    without_experimental = total;
-
   if (!NO_LAST) {
     protos("unknown", "/**< Unknown headers */", -3);
     protos("error", "/**< Erroneous headers */", -4);
-    protos("separator", "/**< Separator line between headers and body */", -5);
+    protos("separator", "/**< Separator line between headers and payload */", -5);
     protos("payload", "/**< Message payload */", -6);
     if (multipart)
       protos("multipart", "/**< Multipart payload */", -7);
@@ -460,16 +426,7 @@
     if (extra > 0) {
       printf("struct %s {\n", extra_struct) > PT;
       printf("  %s base;\n", module_struct) > PT;
-      if (total - without_experimental < extra) {
-	printf("  msg_header_t *extra[%u];\n", 
-	       extra - (total - without_experimental)) > PT;
-      }
-      if (total - without_experimental > 0) {
-	print "#if SU_HAVE_EXPERIMENTAL" > PT;
-	printf("  msg_header_t *experimental[%u];\n", 
-	       total - without_experimental) > PT;
-	print "#endif" > PT;
-      }
+      printf("  msg_header_t *extra[%u];\n", extra) > PT;
       printf("};\n\n") > PT;
       module_struct = "struct " extra_struct;
     }
@@ -508,13 +465,7 @@
     else {
       printf("  NULL, \n") > PT;
     }
-    printf("  %d, \n", MC_HASH_SIZE) > PT;
-    printf ("#if SU_HAVE_EXPERIMENTAL\n" \
-	    "  %d,\n" \
-	    "#else\n" \
-	    "  %d,\n" \
-	    "#endif\n", \
-	    total, without_experimental) > PT;
+    printf("  %d, %d, \n", MC_HASH_SIZE, total) > PT;
     printf("  {\n") > PT;
 
     for (i = 0; i < total; i++) {
@@ -533,7 +484,6 @@
       }
 
       header_hash[j] = n;
-      experimental2[j] = (i >= without_experimental);
     }
 
     for (i = 0; i < MC_HASH_SIZE; i++) {
@@ -542,23 +492,14 @@
 	n = header_hash[i];
         flags = header_flags[n]; if (flags) flags = ",\n      " flags;
 
-	if (experimental2[i]) {
-	  print "#if SU_HAVE_EXPERIMENTAL" > PT;
-	}
-
 	if (Since[n]) {
-	  printf("    { %s_%s_class,\n" \
-		 "      offsetof(struct %s, extra[%u])%s }%s\n", 
+	  printf("    { %s_%s_class, offsetof(struct %s, extra[%u])%s }%s\n", 
 		 tprefix, n, extra_struct, Extra[n], flags, c) > PT;
 	}
 	else {
 	  printf("    { %s_%s_class, offsetof(%s_t, %s_%s)%s }%s\n", 
 		 tprefix, n, module, prefix, n, flags, c) > PT;
 	}
-
-	if (experimental2[i]) {
-	  printf("#else\n    { NULL, 0 }%s\n#endif\n", c) > PT;
-	}
       }
       else {
 	printf("    { NULL, 0 }%s\n", c) > PT;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_parser.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_parser.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/sofia-sip/msg_parser.h	Sat Feb 17 01:25:21 2007
@@ -56,8 +56,7 @@
  * 1) Header class definitions.
  */
 
-/* Do not use keywords until you fix msg_kind_foo_critical thing! */ \
-#if HAVE_STRUCT_KEYWORDS && 0
+#if HAVE_STRUCT_KEYWORDS
 /** Define a header class */
 #define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd)	\
   {{								\
@@ -75,7 +74,6 @@
     hc_kind:	msg_kind_##kind,				\
   }}
 #else
-/** Define a header class */
 #define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd)	\
   {{ \
      pr##c##_hash, \

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -59,5 +59,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libnea_la_SOURCES)
@@ -78,12 +53,8 @@
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/nea
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -127,7 +98,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -174,12 +144,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -223,7 +189,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -321,8 +286,7 @@
 # ----------------------------------------------------------------------
 # Install and distribution rules
 EXTRA_DIST = Doxyfile nea.docs $(BUILT_SOURCES)
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -348,14 +312,12 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -581,7 +543,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -731,92 +693,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/nea_server.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/nea_server.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nea/nea_server.c	Sat Feb 17 01:25:21 2007
@@ -496,14 +496,14 @@
 	nes->nes_eventity_uri &&
 	(nes->nes_leg || leg == NULL) &&
 	nes->nes_timer) {
-      SU_DEBUG_5(("nea_server_create(%p): success\n", (void *)nes));
+      SU_DEBUG_5(("nea_server_create(%p): success\n", nes));
       su_timer_set(nes->nes_timer, nes_event_timer, nes);
 
       nes->nes_callback = callback;
       nes->nes_context = context;
     }
     else {
-      SU_DEBUG_5(("nea_server_create(%p): failed\n", (void *)nes));
+      SU_DEBUG_5(("nea_server_create(%p): failed\n", nes));
       nea_server_destroy(nes), nes = NULL;
     }
   }
@@ -551,11 +551,11 @@
     return 500;
 
   if (nes->nes_in_callback) {
-    SU_DEBUG_5(("nea_server_shutdown(%p) while in callback\n", (void *)nes));
+    SU_DEBUG_5(("nea_server_shutdown(%p) while in callback\n", nes));
     return 100;
   }
   
-  SU_DEBUG_5(("nea_server_shutdown(%p)\n", (void *)nes));
+  SU_DEBUG_5(("nea_server_shutdown(%p)\n", nes));
 
   in_callback = nes->nes_in_callback; nes->nes_in_callback = 1;
 
@@ -585,12 +585,12 @@
     return;
 
   if (nes->nes_in_callback) {
-    SU_DEBUG_5(("nea_server_destroy(%p) while in callback\n", (void *)nes));
+    SU_DEBUG_5(("nea_server_destroy(%p) while in callback\n", nes));
     nes->nes_pending_destroy = 1;
     return;
   }
   
-  SU_DEBUG_5(("nea_server_destroy(%p)\n", (void *)nes));
+  SU_DEBUG_5(("nea_server_destroy(%p)\n", nes));
   
   nta_leg_destroy(nes->nes_leg), nes->nes_leg = NULL;
   
@@ -837,8 +837,8 @@
   if (evq->evq_content_type)
     nea_view_queue(nes, evv, evq);
 
-  SU_DEBUG_7(("nea_server_update(%p): %s (%s)\n", (void *)nes,
-	      ev->ev_event->o_type, evv->evv_content_type->c_type));
+  SU_DEBUG_7(("nea_server_update(%p): %s (%s)\n", 
+	      nes, ev->ev_event->o_type, evv->evv_content_type->c_type));
 
   return 1;
 }
@@ -1019,8 +1019,7 @@
   nea_sub_t *s;
   int notified = 0, throttled = nes->nes_throttled;
 
-  SU_DEBUG_7(("nea_server_notify(%p): %s\n", (void *)nes,
-	      ev ? ev->ev_event->o_type: ""));
+  SU_DEBUG_7(("nea_server_notify(%p): %s\n", nes, ev ? ev->ev_event->o_type: ""));
 
   ++nes->nes_in_list;
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -73,7 +73,7 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 # Generate list of nta tags
 TAG_DLL_FLAGS = 	LIST=nta_tag_list
\ No newline at end of file

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 
@@ -82,12 +57,8 @@
 check_PROGRAMS = test_nta_api$(EXEEXT) test_nta$(EXEEXT) \
 	portbind$(EXEEXT)
 DIST_COMMON = $(dist_noinst_SCRIPTS) $(nobase_include_sofia_HEADERS) \
-	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am \
-	ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+	$(srcdir)/../sofia.am $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/nta
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -157,7 +128,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -204,12 +174,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -253,7 +219,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = $(SHELL) 
@@ -360,8 +325,7 @@
 			agent.pem cafile.pem \
 			invite.msc $(BUILT_SOURCES) 
 
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -387,8 +351,6 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -400,7 +362,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -646,7 +608,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -796,92 +758,6 @@
  ../sresolv/libsresolv.la ../stun/libstun.la ../su/libsu.la \
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
-
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	Sat Feb 17 01:25:21 2007
@@ -225,7 +225,7 @@
 static inline int incoming_merge(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
 				 tport_t *tport);
 static inline int incoming_timestamp(nta_incoming_t *, msg_t *, sip_t *);
-static inline su_duration_t incoming_timer(nta_agent_t *, su_duration_t);
+static inline int incoming_timer(nta_agent_t *, su_duration_t);
 
 static nta_reliable_t *reliable_mreply(nta_incoming_t *,
 				       nta_prack_f *, nta_reliable_magic_t *,
@@ -259,7 +259,7 @@
 				     sip_via_t const *v);
 static int outgoing_recv(nta_outgoing_t *orq, int status, msg_t *, sip_t *);
 static void outgoing_default_recv(nta_outgoing_t *, int, msg_t *, sip_t *);
-static inline su_duration_t outgoing_timer(nta_agent_t *, su_duration_t);
+static inline int outgoing_timer(nta_agent_t *, su_duration_t);
 static int outgoing_recv_reliable(nta_outgoing_t *orq, msg_t *msg, sip_t *sip);
 
 /* Internal message passing */
@@ -369,10 +369,8 @@
     agent->sa_flags = MSG_DO_CANONIC;
 
     agent->sa_maxsize         = 2 * 1024 * 1024; /* 2 MB */
-    agent->sa_bad_req_mask    = 
-      (unsigned) ~(sip_mask_response | sip_mask_proxy);
-    agent->sa_bad_resp_mask   = 
-      (unsigned) ~(sip_mask_request | sip_mask_proxy);
+    agent->sa_bad_req_mask    = (unsigned)(~(sip_mask_response | sip_mask_proxy));
+    agent->sa_bad_resp_mask   = (unsigned)(~(sip_mask_request | sip_mask_proxy));
     agent->sa_t1 	      = NTA_SIP_T1;
     agent->sa_t2 	      = NTA_SIP_T2;
     agent->sa_t4              = NTA_SIP_T4;
@@ -669,108 +667,53 @@
 static
 int agent_timer_init(nta_agent_t *agent)
 {
-  agent->sa_timer = su_timer_create(su_root_task(agent->sa_root),
-				    NTA_SIP_T1 / 8);
-#if 0
-  return su_timer_set(agent->sa_timer,
+  return su_timer_set(agent->sa_timer =
+		      su_timer_create(su_root_task(agent->sa_root),
+				      NTA_SIP_T1 / 8),
 		      agent_timer,
 		      agent);
-#endif
-  return -(agent->sa_timer == NULL);
 }
 
-#define NEXT_TIMEOUT(next, p, f, now) \
-  (p && p->f - (next) < 0 ? (p->f - (now) > 0 ? p->f : (now)) : (next))
-
 /**
  * Agent timer routine.
  */
 static
 void agent_timer(su_root_magic_t *rm, su_timer_t *timer, nta_agent_t *agent)
 {
-  su_time_t stamp = su_now();
-  su_duration_t now = su_time_ms(stamp), next;
+  su_duration_t now = su_time_ms(agent->sa_now = su_now());
+  int again;
 
   now += now == 0;
 
-  agent->sa_now = stamp;
   agent->sa_millisec = now;
-  agent->sa_next = 0;
-  agent->sa_in_timer = 1;
 
-  next = now + SU_DURATION_MAX;
-  next = outgoing_timer(agent, next);
-  next = incoming_timer(agent, next);
+  again = outgoing_timer(agent, now);
+  again = incoming_timer(agent, now) || again;
 
   agent->sa_millisec = 0;
-  agent->sa_in_timer = 0;
 
-  if (agent->sa_next)
-    next = NEXT_TIMEOUT(next, agent, sa_next, now);
-
-  if (next == now + SU_DURATION_MAX) {
-    /* Do not set timer */
-    SU_DEBUG_9(("nta: timer not set\n"));
-    assert(!agent->sa_out.completed->q_head);
-    assert(!agent->sa_out.trying->q_head);
-    assert(!agent->sa_out.inv_calling->q_head);
-    assert(!agent->sa_out.re_list);
-    assert(!agent->sa_in.inv_confirmed->q_head);
-    assert(!agent->sa_in.preliminary->q_head);
-    assert(!agent->sa_in.completed->q_head);
-    assert(!agent->sa_in.inv_completed->q_head);
-    assert(!agent->sa_in.re_list);
-    return;
-  }
-
-  if (next == now) if (++next == 0) ++next;
-
-  SU_DEBUG_9(("nta: timer %s to %ld ms\n", "set next", (long)(next - now)));
-
-  agent->sa_next = next;
-
-  su_timer_set_at(timer, agent_timer, agent, su_time_add(stamp, next - now));
+  if (again)
+    su_timer_set_at(timer, agent_timer, agent, su_time_add(su_now(), 1));
+  else
+    su_timer_set(timer, agent_timer, agent);
 }
 
-/** Calculate nonzero value for timeout.
- *
- * Sets or adjusts agent timer when needed.
- *
- * @retval 0 if offset is 0
- * @retval timeout (millisecond counter) otherwise
- */
-static
-su_duration_t set_timeout(nta_agent_t *agent, su_duration_t offset)
+/** Calculate nonzero value for timer */
+static inline
+su_duration_t set_timeout(nta_agent_t const *agent, su_duration_t offset)
 {
-  su_time_t now;
-  su_duration_t next, ms;
+  su_duration_t now;
 
-  if (offset == 0)
-    return 0;
-
-  if (agent->sa_millisec) /* Avoid expensive call to su_timer_ms() */
-    now = agent->sa_now, ms = agent->sa_millisec;
+#if 0
+  if (agent->sa_millisec)
+    now = agent->sa_millisec;
   else
-    now = su_now(), ms = (su_duration_t)su_time_ms(now);
-  
-  next = ms + offset; if (next == 0) next = 1;
-
-  if (agent->sa_in_timer)
-    return next;
+#endif
+    now = (su_duration_t)su_time_ms(su_now());
 
-  if (agent->sa_next == 0 || agent->sa_next - next - 5L > 0) {
-    /* Set timer */
-    if (agent->sa_next)
-      SU_DEBUG_9(("nta: timer %s to %ld ms\n", "shortened", (long)offset));
-    else
-      SU_DEBUG_9(("nta: timer %s to %ld ms\n", "set", (long)offset));
-      
-    su_timer_set_at(agent->sa_timer, agent_timer, agent, 
-		    su_time_add(now, offset));
-    agent->sa_next = next;
-  }
+  now += offset;
 
-  return next;
+  return now ? now : 1;
 }
 
 
@@ -890,7 +833,7 @@
   unsigned threadpool      = agent->sa_tport_threadpool;
   char const *sigcomp = agent->sa_sigcomp_options;
   char const *algorithm = NONE;
-  msg_mclass_t const *mclass = NONE;
+  msg_mclass_t *mclass = NONE;
   sip_contact_t const *aliases = NONE;
   url_string_t const *proxy = NONE;
   tport_t *tport;
@@ -1532,7 +1475,7 @@
 	(nta_compressor_vtable == NULL || 
 	 strcasecmp(tpn->tpn_comp, nta_compressor_vtable->ncv_name) != 0)) {
       SU_DEBUG_1(("nta(%p): comp=%s not supported for " URL_PRINT_FORMAT "\n",
-		  (void *)self, tpn->tpn_comp, URL_PRINT_ARGS(url)));
+		  self, tpn->tpn_comp, URL_PRINT_ARGS(url)));
     }
   }
 
@@ -2017,8 +1960,7 @@
   }
   else {
     /* XXX - we should do something else? */
-    SU_DEBUG_3(("%s(%p): %s\n", "nta", (void *)self, 
-		"transport address updated"));
+    SU_DEBUG_3(("nta(%p): transport address updated\n", self));
   }
 }
 
@@ -3479,7 +3421,7 @@
 
   leg_insert(agent, leg);
 
-  SU_DEBUG_9(("nta_leg_create(%p)\n", (void *)leg));
+  SU_DEBUG_9(("nta_leg_create(%p)\n", leg));
 
   return leg;
 
@@ -3529,7 +3471,7 @@
  */
 void nta_leg_destroy(nta_leg_t *leg)
 {
-  SU_DEBUG_9(("nta_leg_destroy(%p)\n", (void *)leg));
+  SU_DEBUG_9(("nta_leg_destroy(%p)\n", leg));
 
   if (leg) {
     leg_htable_t *leg_hash;
@@ -3624,7 +3566,6 @@
   if (tag) {
     if (sip_to_tag(leg->leg_home, leg->leg_local, tag) < 0)
       return NULL;
-    leg->leg_tagged = 1;
     return leg->leg_local->a_tag;
   }
 
@@ -3633,8 +3574,6 @@
   if (!tag || sip_to_add_param(leg->leg_home, leg->leg_local, tag) < 0)
     return NULL;
 
-  leg->leg_tagged = 1;
-
   return leg->leg_local->a_tag;
 }
 
@@ -3818,7 +3757,7 @@
 
   if (!(irq = incoming_create(agent, msg, sip, tport, tag))) {
     SU_DEBUG_3(("nta: leg_recv(%p): cannot create transaction for %s\n",
-		(void *)leg, method_name));
+		leg, method_name));
     nta_msg_treply(agent, msg,
 		   SIP_500_INTERNAL_SERVER_ERROR,
 		   NTATAG_TPORT(tport),
@@ -3844,12 +3783,12 @@
 
   if (status < 100 || status > 699) {
     SU_DEBUG_3(("nta_leg(%p): invalid status %03d from callback\n",
-		(void *)leg, status));
+		leg, status));
     status = 500;
   }
   else if (method == sip_method_invite && status >= 200 && status < 300) {
     SU_DEBUG_3(("nta_leg(%p): invalid INVITE status %03d from callback\n",
-		(void *)leg, status));
+		leg, status));
     status = 500;
   }
 
@@ -3983,14 +3922,6 @@
     /* Do not match if the incoming To has tag, but the local does not */
     if (!local_tag && to_tag)
       continue;
-
-    /*
-     * Do not match if incoming To has no tag and we have local tag
-     * and the tag has been there from the beginning.
-     */
-    if (local_tag && !to_tag && !leg->leg_tagged)
-      continue;
-
     /* Do not match if incoming From has no tag but remote has a tag */
     if (remote_tag && !from_tag)
       continue;
@@ -4222,7 +4153,7 @@
 static inline void incoming_remove(nta_incoming_t *irq);
 static inline void incoming_set_timer(nta_incoming_t *, unsigned interval);
 static inline void incoming_reset_timer(nta_incoming_t *);
-static inline size_t incoming_mass_destroy(nta_agent_t *, incoming_queue_t *);
+static inline size_t incoming_mass_destroy(nta_agent_t *sa, incoming_queue_t *q);
 
 static int incoming_set_params(nta_incoming_t *irq, tagi_t const *tags);
 static inline
@@ -4505,7 +4436,7 @@
 
     if (leg->leg_rseq > sip->sip_cseq->cs_seq) {
       SU_DEBUG_3(("nta_leg(%p): out-of-order %s (%u < %u)\n",
-		  (void *)leg, method_name, seq, leg->leg_rseq));
+		  leg, method_name, seq, leg->leg_rseq));
       return 500;
     }
 
@@ -4600,7 +4531,10 @@
 
   assert(*queue->q_tail == NULL);
 
-  irq->irq_timeout = set_timeout(irq->irq_agent, queue->q_timeout);
+  if (queue->q_timeout)
+    irq->irq_timeout = set_timeout(irq->irq_agent, queue->q_timeout);
+  else
+    irq->irq_timeout = 0;
 
   irq->irq_queue = queue;
   irq->irq_prev = queue->q_tail; 
@@ -4692,7 +4626,7 @@
 static
 void incoming_free(nta_incoming_t *irq)
 {
-  SU_DEBUG_9(("nta: incoming_free(%p)\n", (void *)irq));
+  SU_DEBUG_9(("nta: incoming_free(%p)\n", irq));
 
   incoming_cut_off(irq);
   incoming_reclaim(irq);
@@ -4772,8 +4706,7 @@
   incoming_queue_t *q = u->a_incoming_queue;
   nta_incoming_t *irq, *irq_next;
 
-  SU_DEBUG_9(("incoming_reclaim_all(%p, %p, %p)\n",
-	      (void *)rm, (void *)msg, (void *)u));
+  SU_DEBUG_9(("incoming_reclaim_all(%p, %p, %p)\n", rm, msg, u));
 
   for (irq = q->q_head; irq; irq = irq_next) {
     irq_next = irq->irq_next;
@@ -4983,16 +4916,15 @@
 nta_incoming_t *incoming_find(nta_agent_t const *agent,
 			      sip_t const *sip,
 			      sip_via_t const *v,
-			      nta_incoming_t **return_merge,
-			      nta_incoming_t **return_ack)
+			      nta_incoming_t **merge,
+			      nta_incoming_t **ack)
 {
   sip_cseq_t const *cseq = sip->sip_cseq;
   sip_call_id_t const *i = sip->sip_call_id;
   sip_to_t const *to = sip->sip_to;
   sip_from_t const *from = sip->sip_from;
   sip_request_t *rq = sip->sip_request;
-  int is_uas_ack = return_ack && 
-    agent->sa_is_a_uas && rq->rq_method == sip_method_ack;
+  int is_uas_ack = ack && agent->sa_is_a_uas && rq->rq_method == sip_method_ack;
   incoming_htable_t const *iht = agent->sa_incoming;
   hash_value_t hash = NTA_HASH(i, cseq->cs_seq);
 
@@ -5009,30 +4941,6 @@
       continue;
     if (str0casecmp(irq->irq_from->a_tag, from->a_tag))
       continue;
-
-    if (str0casecmp(irq->irq_via->v_branch, v->v_branch) != 0 ||
-	strcasecmp(irq->irq_via->v_host, v->v_host) != 0) {
-      if (!agent->sa_is_a_uas)
-	continue;
-      
-      if (is_uas_ack &&
-	  irq->irq_method == sip_method_invite && 
-	  200 <= irq->irq_status && irq->irq_status < 300 &&
-	  addr_match(irq->irq_to, to))
-	*return_ack = irq;
-      /* RFC3261 - section 8.2.2.2 Merged Requests */
-      else if (return_merge && agent->sa_merge_482 &&
-	       irq->irq_cseq->cs_method == cseq->cs_method &&
-	       (irq->irq_cseq->cs_method != sip_method_unknown ||
-		strcmp(irq->irq_cseq->cs_method_name, 
-		       cseq->cs_method_name) == 0)) {
-	*return_merge = irq;
-	continue;
-      }
-      else
-	continue;
-    }
-
     if (is_uas_ack) {
       if (!addr_match(irq->irq_to, to))
 	continue;
@@ -5045,6 +4953,16 @@
     else if (str0casecmp(irq->irq_to->a_tag, to->a_tag))
       continue;
 
+    if (str0casecmp(irq->irq_via->v_branch, v->v_branch) != 0) {
+      if (!agent->sa_is_a_uas)
+	continue;
+      if (is_uas_ack && irq->irq_status >= 200 && irq->irq_status < 300)
+	*ack = irq;
+      /* RFC3261 - section 8.2.2.2 Merged Requests */
+      else if (merge && !to->a_tag && agent->sa_merge_482)
+	*merge = irq;
+      continue;
+    }
     if (!is_uas_ack && url_cmp(irq->irq_rq->rq_url, rq->rq_url))
       continue;
 
@@ -5056,24 +4974,18 @@
     if (irq->irq_method == rq->rq_method)
       break;		/* found */
 
-    if (!return_ack)
-      continue;
-
-    if (irq->irq_method == sip_method_invite) {
-      if (rq->rq_method == sip_method_cancel)
-	*return_ack = irq;
-      else if (rq->rq_method == sip_method_ack)
-	*return_ack = irq;
-    }
-    else if (rq->rq_method == sip_method_cancel && !irq->irq_terminated)
-      *return_ack = irq;
+    if (ack && rq->rq_method == sip_method_cancel)
+      *ack = irq;
+    else if (ack && rq->rq_method == sip_method_ack && 
+	     irq->irq_method == sip_method_invite)
+      *ack = irq;
   }
 
   if (irq)
     return irq;
 
   /* Check PRACKed requests */
-  if (return_ack && rq->rq_method == sip_method_prack && sip->sip_rack) {
+  if (ack && rq->rq_method == sip_method_prack && sip->sip_rack) {
     sip_rack_t const *rack = sip->sip_rack;
     hash = NTA_HASH(i, rack->ra_cseq);
 
@@ -5093,7 +5005,7 @@
 	continue;
       if (!irq->irq_from->a_tag != !from->a_tag)
 	continue;
-      *return_ack = irq;
+      *ack = irq;
 
       return NULL;
     }
@@ -5185,18 +5097,10 @@
   nta_agent_t *agent = irq->irq_agent;
 
   /* Respond to the CANCEL */
+  nta_msg_treply(agent, msg_ref_create(msg), SIP_200_OK, 
+		 NTATAG_TPORT(tport),
+		 TAG_END());
 
-  if (200 <= irq->irq_status && irq->irq_status < 300) {
-    nta_msg_treply(agent, msg_ref_create(msg), SIP_481_NO_TRANSACTION, 
-		   NTATAG_TPORT(tport),
-		   TAG_END());
-  }
-  else
-    nta_msg_treply(agent, msg_ref_create(msg), SIP_200_OK, 
-		   NTATAG_TPORT(tport),
-		   TAG_END());
-
-  /* We have already sent final response */
   if (irq->irq_completed || irq->irq_method != sip_method_invite) {
     msg_destroy(msg);
     return 0;
@@ -5372,34 +5276,6 @@
   return 0;
 }
 
-/** Add essential headers to the response message */
-static int nta_incoming_response_headers(nta_incoming_t *irq, 
-					 msg_t *msg,
-					 sip_t *sip)
-{
-  int clone = 0;
-  su_home_t *home = msg_home(msg);
-
-  if (!sip->sip_from)
-    clone = 1, sip->sip_from = sip_from_copy(home, irq->irq_from);
-  if (!sip->sip_to)
-    clone = 1, sip->sip_to = sip_to_copy(home, irq->irq_to);
-  if (!sip->sip_call_id)
-    clone = 1, sip->sip_call_id = sip_call_id_copy(home, irq->irq_call_id);
-  if (!sip->sip_cseq)
-    clone = 1, sip->sip_cseq = sip_cseq_copy(home, irq->irq_cseq);
-  if (!sip->sip_via)
-    clone = 1, sip->sip_via = sip_via_copy(home, irq->irq_via);
-
-  if (clone)
-    msg_set_parent(msg, (msg_t *)irq->irq_home);
-
-  if (!sip->sip_from || !sip->sip_to || !sip->sip_call_id || !sip->sip_cseq || !sip->sip_via)
-    return -1;
-
-  return 0;
-}
-
 /** Complete a response message.
  *
  * @param irq     server transaction object
@@ -5421,6 +5297,7 @@
 {
   su_home_t *home = msg_home(msg);
   sip_t *sip = sip_object(msg);
+  int clone = 0;
   int retval;
   ta_list ta;
 
@@ -5430,7 +5307,7 @@
   if (status != 0 && (status < 100 || status > 699))
     return su_seterrno(EINVAL), -1;
 
-  if (status != 0 && !sip->sip_status)
+  if (!sip->sip_status)
     sip->sip_status = sip_status_create(home, status, phrase, NULL);
 
   ta_start(ta, tag, value);
@@ -5443,51 +5320,39 @@
   if (irq->irq_default)
     return sip_complete_message(msg);
 
+  if (!sip->sip_from)
+    clone = 1, sip->sip_from = sip_from_copy(home, irq->irq_from);
   if (status > 100 && !irq->irq_tag) {
     if (sip->sip_to)
       nta_incoming_tag(irq, sip->sip_to->a_tag);
     else
       nta_incoming_tag(irq, NULL);
   }
-
-  if (nta_incoming_response_headers(irq, msg, sip) < 0)
-    return -1;
-
+  if (!sip->sip_to)
+    clone = 1, sip->sip_to = sip_to_copy(home, irq->irq_to);
   if (sip->sip_status && sip->sip_status->st_status > 100 &&
       irq->irq_tag && sip->sip_to && !sip->sip_to->a_tag)
-    if (sip_to_tag(home, sip->sip_to, irq->irq_tag) < 0)
-      return -1;
-
-  if (status < 300 && !sip->sip_record_route && irq->irq_record_route)
-    if (sip_add_dup(msg, sip, (sip_header_t *)irq->irq_record_route) < 0)
-      return -1;
-
-  return sip_complete_message(msg);
-}
-
-
-/** Create a response message for request.
- *
- * @NEW_1_12_5.
- */
-msg_t *nta_incoming_create_response(nta_incoming_t *irq,
-				    int status, char const *phrase)
-{
-  msg_t *msg = NULL;
-  sip_t *sip;
+    sip_to_tag(home, sip->sip_to, irq->irq_tag);
+  if (!sip->sip_call_id)
+    clone = 1, sip->sip_call_id = sip_call_id_copy(home, irq->irq_call_id);
+  if (!sip->sip_cseq)
+    clone = 1, sip->sip_cseq = sip_cseq_copy(home, irq->irq_cseq);
+  if (!sip->sip_via)
+    clone = 1, sip->sip_via = sip_via_copy(home, irq->irq_via);
+  if (status < 300 && 
+      !sip->sip_record_route && irq->irq_record_route)
+    sip_add_dup(msg, sip, (sip_header_t *)irq->irq_record_route);
 
-  if (irq) {
-    msg = nta_msg_create(irq->irq_agent, 0);
-    sip = sip_object(msg);
+  if (clone)
+    msg_set_parent(msg, (msg_t *)irq->irq_home);
 
-    if (status != 0)
-      sip->sip_status = sip_status_create(msg_home(msg), status, phrase, NULL);
+  if (retval < 0 || !sip->sip_from || !sip->sip_to || !sip->sip_call_id
+      || !sip->sip_cseq || !sip->sip_via
+      || (status < 300 && irq->irq_record_route && !sip->sip_record_route &&
+	  sip->sip_cseq && sip->sip_cseq->cs_method != sip_method_register))
+    return -1;
 
-    if (nta_incoming_response_headers(irq, msg, sip) < 0)
-      msg_destroy(msg), msg = NULL;
-  }
-  
-  return msg;
+  return sip_complete_message(msg);
 }
 
 
@@ -5879,9 +5744,8 @@
 
 /** @internal Timer routine for the incoming request. */
 static inline
-su_duration_t incoming_timer(nta_agent_t *sa, su_duration_t next)
+int incoming_timer(nta_agent_t *sa, su_duration_t now)
 {
-  su_duration_t now = sa->sa_millisec;
   nta_incoming_t *irq, *irq_next;
   size_t retransmitted = 0, timeout = 0, terminated = 0, destroyed = 0;
   size_t unconfirmed = 
@@ -5898,9 +5762,8 @@
 
   /* Handle retry queue */
   while ((irq = sa->sa_in.re_list)) {
-    if (irq->irq_retry - now > 0)
-      break;
-    if (retransmitted >= timer_max_retransmit)
+    if ((irq->irq_retry && irq->irq_retry - now > 0) ||
+	retransmitted >= timer_max_retransmit) 
       break;
 
     if (irq->irq_method == sip_method_invite && irq->irq_status >= 200) {
@@ -5938,8 +5801,7 @@
 	retransmitted++;
 	incoming_retransmit_reply(irq, irq->irq_tport);
       }
-    }
-    else {
+    } else {
       /* Timer N1 */
       SU_DEBUG_5(("nta: timer N1 fired, sending %u %s\n", SIP_100_TRYING));
       incoming_reset_timer(irq);
@@ -5947,8 +5809,6 @@
     }
   }
 
-  next = NEXT_TIMEOUT(next, irq, irq_retry, now);
-
   while ((irq = sa->sa_in.final_failed->q_head)) {
     incoming_remove(irq);
     irq->irq_final_failed = 0;
@@ -5981,9 +5841,8 @@
     assert(irq->irq_status < 200);
     assert(irq->irq_timeout);
 
-    if (irq->irq_timeout - now > 0)
-      break;
-    if (timeout >= timer_max_timeout)
+    if (irq->irq_timeout - now > 0 
+	|| timeout >= timer_max_timeout)
       break;
 
     timeout++;
@@ -5996,8 +5855,6 @@
     reliable_timeout(irq, 1);
   }
 
-  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
   while ((irq = sa->sa_in.inv_completed->q_head)) {
     assert(irq->irq_status >= 200);
     assert(irq->irq_timeout);
@@ -6026,14 +5883,13 @@
     }
   } 
 
-  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
   while ((irq = sa->sa_in.inv_confirmed->q_head)) {
     assert(irq->irq_timeout);
     assert(irq->irq_status >= 200);
     assert(irq->irq_method == sip_method_invite);
 
-    if (irq->irq_timeout - now > 0 || terminated >= timer_max_terminate)
+    if (irq->irq_timeout - now > 0 || 
+	terminated >= timer_max_terminate)
       break;
     
     /* Timer I */
@@ -6049,14 +5905,13 @@
       incoming_free_queue(rq, irq);
   }
 
-  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
   while ((irq = sa->sa_in.completed->q_head)) {
     assert(irq->irq_status >= 200);
     assert(irq->irq_timeout);
     assert(irq->irq_method != sip_method_invite);
 
-    if (irq->irq_timeout - now > 0 || terminated >= timer_max_terminate)
+    if (irq->irq_timeout - now > 0 || 
+	terminated >= timer_max_terminate)
       break;
 
     /* Timer J */
@@ -6073,8 +5928,6 @@
       incoming_free_queue(rq, irq);
   }
 
-  next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
   for (irq = sa->sa_in.terminated->q_head; irq; irq = irq_next) {
     irq_next = irq->irq_next;
     if (irq->irq_destroyed)
@@ -6094,7 +5947,10 @@
 		terminated, unterminated, 
 		destroyed, total));
 
-  return next;
+  return 
+    retransmitted >= timer_max_retransmit
+    || timeout >= timer_max_timeout
+    || terminated >= timer_max_terminate;
 }
 
 /** Mass destroy server transactions */
@@ -6162,11 +6018,11 @@
 static inline void outgoing_set_timer(nta_outgoing_t *orq, unsigned interval);
 static inline void outgoing_reset_timer(nta_outgoing_t *orq);
 static size_t outgoing_timer_dk(outgoing_queue_t *q, 
-				char const *timer, 
-				su_duration_t now);
+			     char const *timer, 
+			     su_duration_t now);
 static size_t outgoing_timer_bf(outgoing_queue_t *q, 
-				char const *timer, 
-				su_duration_t now);
+			     char const *timer, 
+			     su_duration_t now);
 
 static void outgoing_ack(nta_outgoing_t *orq, msg_t *msg, sip_t *sip);
 static msg_t *outgoing_ackmsg(nta_outgoing_t *, sip_method_t, char const *,
@@ -6525,8 +6381,7 @@
     return;
 
   if (orq->orq_destroyed) {
-    SU_DEBUG_1(("%s(%p): %s\n", "nta_outgoing_destroy", (void *)orq, 
-		"already destroyed"));
+    SU_DEBUG_1(("nta_outgoing_destroy(%p): already destroyed\n", orq));
     return;
   }
 
@@ -7391,7 +7246,7 @@
   assert(*queue->q_tail == NULL);
 
   orq->orq_timeout = set_timeout(orq->orq_agent, queue->q_timeout);
-
+    
   orq->orq_queue = queue;
   orq->orq_prev = queue->q_tail; 
   *queue->q_tail = orq;
@@ -7450,7 +7305,6 @@
 
   orq->orq_retry = set_timeout(orq->orq_agent, orq->orq_interval = interval);
 
-  /* Shortcut into queue at SIP T1 */
   rq = orq->orq_agent->sa_out.re_t1;
 
   if (!(*rq) || (*rq)->orq_retry - orq->orq_retry > 0)
@@ -7489,7 +7343,7 @@
 static
 void outgoing_free(nta_outgoing_t *orq)
 {
-  SU_DEBUG_9(("nta: outgoing_free(%p)\n", (void *)orq));
+  SU_DEBUG_9(("nta: outgoing_free(%p)\n", orq));
   outgoing_cut_off(orq);
   outgoing_reclaim(orq);
 }
@@ -7556,8 +7410,7 @@
   outgoing_queue_t *q = u->a_outgoing_queue;
   nta_outgoing_t *orq, *orq_next;
 
-  SU_DEBUG_9(("outgoing_reclaim_all(%p, %p, %p)\n",
-	      (void *)rm, (void *)msg, (void *)u));
+  SU_DEBUG_9(("outgoing_reclaim_all(%p, %p, %p)\n", rm, msg, u));
 
   for (orq = q->q_head; orq; orq = orq_next) {
     orq_next = orq->orq_next;
@@ -7581,14 +7434,6 @@
   if (orq->orq_terminated || orq->orq_default) {
     outgoing_free(orq);
   }
-  /* We have to handle 200 OK statelessly => 
-     kill transaction immediately */
-  else if (orq->orq_method == sip_method_invite && !orq->orq_completed
-	   /* (unless we have to wait to send CANCEL) */
-	   && !orq->orq_cancel) {
-    orq->orq_destroyed = 1;
-    outgoing_terminate(orq);
-  }
   else {
     orq->orq_destroyed = 1;
     orq->orq_callback = outgoing_default_cb;
@@ -7596,29 +7441,24 @@
   }
 }
 
-/** @internal Outgoing transaction timer routine. 
- *
- */
-static inline 
-su_duration_t outgoing_timer(nta_agent_t *sa, su_duration_t next)
+/** @internal Outgoing transaction timer routine. */
+static
+int outgoing_timer(nta_agent_t *sa, su_duration_t now)
 {
-  su_duration_t now = sa->sa_millisec;
   nta_outgoing_t *orq;
   outgoing_queue_t rq[1];
   size_t retransmitted = 0, terminated = 0, timeout = 0, destroyed;
   size_t total = sa->sa_outgoing->oht_used;
   size_t trying = sa->sa_out.re_length;
-  size_t pending = sa->sa_out.trying->q_length + 
-    sa->sa_out.inv_calling->q_length;
+  size_t pending = sa->sa_out.trying->q_length + sa->sa_out.inv_calling->q_length;
   size_t completed = sa->sa_out.completed->q_length + 
     sa->sa_out.inv_completed->q_length;
 
   outgoing_queue_init(sa->sa_out.free = rq, 0);
 
   while ((orq = sa->sa_out.re_list)) {
-    if (orq->orq_retry - now > 0)
-      break;
-    if (retransmitted >= timer_max_retransmit)
+    if ((orq->orq_retry && orq->orq_retry - now > 0)
+	|| retransmitted >= timer_max_retransmit)
       break;
 
     if (orq->orq_reliable) {
@@ -7654,22 +7494,14 @@
       su_root_yield(sa->sa_root);	/* Handle received packets */
   }
 
-  next = NEXT_TIMEOUT(next, orq, orq_retry, now);
-
   terminated
     = outgoing_timer_dk(sa->sa_out.inv_completed, "D", now)
     + outgoing_timer_dk(sa->sa_out.completed, "K", now);
 
-  next = NEXT_TIMEOUT(next, sa->sa_out.inv_completed->q_head, orq_timeout, now);
-  next = NEXT_TIMEOUT(next, sa->sa_out.completed->q_head, orq_timeout, now);
-
   timeout
     = outgoing_timer_bf(sa->sa_out.inv_calling, "B", now)
     + outgoing_timer_bf(sa->sa_out.trying, "F", now);
 
-  next = NEXT_TIMEOUT(next, sa->sa_out.inv_calling->q_head, orq_timeout, now);
-  next = NEXT_TIMEOUT(next, sa->sa_out.trying->q_head, orq_timeout, now);
-
   destroyed = outgoing_mass_destroy(sa, rq);
 
   sa->sa_out.free = NULL;
@@ -7686,7 +7518,10 @@
 		destroyed, total));
   }
 
-  return next;
+  return 
+    retransmitted >= timer_max_retransmit || 
+    terminated >= timer_max_terminate || 
+    timeout >= timer_max_timeout;
 }
 
 /** @internal Retransmit the outgoing request. */
@@ -7723,12 +7558,16 @@
 			 char const *timer, 
 			 su_duration_t now)
 {
-  nta_outgoing_t *orq;
   size_t timeout = 0;
 
-  while ((orq = q->q_head)) {
-    if (orq->orq_timeout - now > 0 || timeout >= timer_max_timeout)
-      break;
+  for (;;) {
+    nta_outgoing_t *orq = q->q_head;
+
+    if (!orq 
+	|| !orq->orq_timeout
+	|| orq->orq_timeout - now > 0 
+	|| timeout >= timer_max_timeout)
+      return timeout;
 
     timeout++;
     
@@ -7740,8 +7579,6 @@
 
     assert(q->q_head != orq || orq->orq_timeout - now > 0);
   }
-
-  return timeout;
 }
 
 /** @internal Signal transaction timeout to the application. */
@@ -7750,8 +7587,7 @@
   nta_outgoing_t *cancel;
 
   if (outgoing_other_destinations(orq)) {
-    SU_DEBUG_5(("%s(%p): %s\n", "nta", (void *)orq,
-		"try next after timeout"));
+    SU_DEBUG_5(("nta(%p): try next after timeout\n", orq));
     outgoing_try_another(orq);
     return;
   }
@@ -7798,12 +7634,16 @@
 			 char const *timer, 
 			 su_duration_t now)
 {
-  nta_outgoing_t *orq;
   size_t terminated = 0;
 
-  while ((orq = q->q_head)) {
-    if (orq->orq_timeout - now > 0 || terminated >= timer_max_terminate)
-      break;
+  for (;;) {
+    nta_outgoing_t *orq = q->q_head;
+
+    if (!orq 
+	|| !orq->orq_timeout 
+	|| orq->orq_timeout - now > 0 
+	|| terminated >= timer_max_terminate)
+      return terminated;
 
     terminated++;
 
@@ -7812,8 +7652,6 @@
 
     outgoing_terminate(orq);
   }
-  
-  return terminated;
 }
 
 /** Terminate a client transaction. */
@@ -7997,16 +7835,6 @@
       outgoing_send(cancel, 0);
     else
       outgoing_reply(cancel, SIP_481_NO_TRANSACTION, 0);
-
-    if (status < 300 && orq->orq_destroyed && 
-	orq->orq_method == sip_method_invite) {
-      outgoing_terminate(orq);      /* We can now kill transaction */
-      if (status == 100) {
-	msg_destroy(msg);
-	return 0;
-      }
-      return -1;
-    }
   }
 
   if (orq->orq_pending) {
@@ -8339,8 +8167,7 @@
 
   if (orq->orq_method == sip_method_ack) {
     if (status != delayed)
-      SU_DEBUG_3(("nta(%p): responding %u %s to ACK!\n",
-		  (void *)orq, status, phrase));
+      SU_DEBUG_3(("nta(%p): responding %u %s to ACK!\n", orq, status, phrase));
     orq->orq_status = status;
     if (orq->orq_queue == NULL)
       outgoing_complete(orq);	/* Timer D/K */
@@ -8620,8 +8447,8 @@
 
     /* Nothing found */
     if (!sr->sr_tports[0]) {
-      SU_DEBUG_3(("nta(%p): transport %s is not supported%s%s\n", (void *)orq,
-		  tpname, ident ? " by interface " : "", ident ? ident : ""));
+      SU_DEBUG_3(("nta(%p): transport %s is not supported%s%s\n", orq, tpname,
+		  ident ? " by interface " : "", ident ? ident : ""));
       outgoing_resolving_error(orq, SIPDNS_503_ERROR);
       return;
     }
@@ -9235,10 +9062,10 @@
     inet_ntop(AF_INET6, &aaaa->aaaa_addr, addr, sizeof(addr));
 
     if (j == 0)
-      SU_DEBUG_5(("nta(%p): %s IN AAAA %s\n", (void *)orq, 
+      SU_DEBUG_5(("nta(%p): %s IN AAAA %s\n", orq, 
 		  aaaa->aaaa_record->r_name, addr));
     else
-      SU_DEBUG_5(("nta(%p):  AAAA %s\n", (void *)orq, addr));
+      SU_DEBUG_5(("nta(%p):  AAAA %s\n", orq, addr));
 
     assert(j < found);
     results[j++] = su_strdup(home, addr);
@@ -9320,7 +9147,7 @@
     if (j == 0)
       SU_DEBUG_5(("nta: %s IN A %s\n", a->a_record->r_name, addr));
     else
-      SU_DEBUG_5(("nta(%p):  A %s\n", (void *)orq, addr));
+      SU_DEBUG_5(("nta(%p):  A %s\n", orq, addr));
 
     assert(j < found);
     results[j++] = su_strdup(home, addr);
@@ -9344,7 +9171,7 @@
       sq->sq_type != sr->sr_a_aaaa2) {
     sq->sq_type = sr->sr_a_aaaa2;
 
-    SU_DEBUG_7(("nta(%p): %s %s record still unresolved\n", (void *)orq,
+    SU_DEBUG_7(("nta(%p): %s %s record still unresolved\n", orq,
 		sq->sq_domain, sq->sq_type == sres_type_a ? "A" : "AAAA"));
 
     /*
@@ -9665,9 +9492,8 @@
   status = rel->rel_callback(rel->rel_magic, rel, pr_irq, sip); rel = NULL;
   irq->irq_in_callback = pr_irq->irq_in_callback = 0;
 
-  if (pr_irq->irq_completed) {	/* Already sent final response */
-    if (pr_irq->irq_terminated && pr_irq->irq_destroyed)
-      incoming_free(pr_irq);
+  if (pr_irq->irq_destroyed && pr_irq->irq_terminated) {
+    incoming_free(pr_irq);
   }
   else if (status != 0) {
     if (status < 200 || status > 299) {
@@ -9805,7 +9631,7 @@
     return;
 
   if (rel->rel_callback == nta_reliable_destroyed)
-    SU_DEBUG_1(("%s(%p): %s\n", __func__, (void *)rel, "already destroyed"));
+    SU_DEBUG_1(("%s(%p): already destroyed\n", __func__, rel));
 
   rel->rel_callback = nta_reliable_destroyed;
 
@@ -9832,7 +9658,7 @@
 
   if (!*prev) {
     assert(*prev);
-    SU_DEBUG_1(("%s(%p): %s\n", __func__, (void *)rel, "not linked"));
+    SU_DEBUG_1(("%s(%p): not linked\n", __func__, rel));
     return 200;
   }
 
@@ -9913,8 +9739,7 @@
   if (orq == NULL || to_tag == NULL)
     return NULL;
   if (orq->orq_to->a_tag) {
-    SU_DEBUG_1(("%s: transaction %p already in dialog\n", __func__,
-		(void *)orq));
+    SU_DEBUG_1(("%s: transaction %p already in dialog\n", __func__, orq));
     return NULL;
   }
 
@@ -9930,9 +9755,6 @@
 
   tagged->orq_prev = NULL, tagged->orq_next = NULL, tagged->orq_queue = NULL;
   tagged->orq_rprev = NULL, tagged->orq_rnext = NULL;
-#if HAVE_SOFIA_SRESOLV
-  tagged->orq_resolver = NULL;
-#endif
 
   if (tagged->orq_cc)
     nta_compartment_ref(tagged->orq_cc);
@@ -10325,12 +10147,8 @@
 
   assert(orq); (void)tp;
 
-#if HAVE_SOFIA_STUN
   return tport_keepalive(orq->orq_tport, msg_addrinfo(orq->orq_request),
 			 TAG_END());
-#else
-  return -1;
-#endif
 }
 
 /** Close all transports. @since Experimental in @VERSION_1_12_2. */
@@ -10350,7 +10168,7 @@
       
       orq->orq_pending = 0;
       tport_unref(orq->orq_tport), orq->orq_tport = NULL;
-    }
+    }  
   
   
   for (i = iht->iht_size; i-- > 0;)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c	Sat Feb 17 01:25:21 2007
@@ -343,8 +343,8 @@
 /**Check @SessionExpires header.
  *
  * If the proposed session-expiration time is smaller than @MinSE or our
- * minimal session expiration time, respond with 422 containing shortest
- * acceptable session expiration time in @MinSE header.
+ * minimal session expiration time, respond with 422 containing our minimal
+ * session expiration time in @MinSE header.
  *
  * @param irq 	incoming transaction object (may be NULL).
  * @param sip 	contents of the SIP message
@@ -359,28 +359,26 @@
 			      sip_time_t my_min_se,
 			      tag_type_t tag, tag_value_t value, ...)
 {
-  unsigned long min_se = my_min_se;
-
-  if (sip->sip_min_se && min_se < sip->sip_min_se->min_delta)
-    min_se = sip->sip_min_se->min_delta;
-
-  if (sip->sip_session_expires->x_delta >= min_se)
-    return 0;
-
-  if (irq) {
+  if ((sip->sip_min_se &&
+       sip->sip_session_expires->x_delta < sip->sip_min_se->min_delta)
+      || sip->sip_session_expires->x_delta < my_min_se) {
     ta_list ta;
-    sip_min_se_t min_se0[1];
 
-    ta_start(ta, tag, value);
+    sip_min_se_t min_se[1];
+
+    sip_min_se_init(min_se)->min_delta = my_min_se;
 
-    sip_min_se_init(min_se0)->min_delta = min_se;
+    if (irq) {
+      ta_start(ta, tag, value);
+      nta_incoming_treply(irq,
+			  SIP_422_SESSION_TIMER_TOO_SMALL,
+			  SIPTAG_MIN_SE(min_se),
+			  ta_tags(ta));
+      ta_end(ta);
+    }
 
-    nta_incoming_treply(irq,
-			SIP_422_SESSION_TIMER_TOO_SMALL,
-			SIPTAG_MIN_SE(min_se0),
-			ta_tags(ta));
-    ta_end(ta);
+    return 422;
   }
 
-  return 422;
+  return 0;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h	Sat Feb 17 01:25:21 2007
@@ -98,17 +98,16 @@
   nta_agent_magic_t    *sa_magic;
   nta_message_f        *sa_callback;     
 
+  uint32_t              sa_nw_updates; /* Shall we enable network detector? */
+
   nta_update_magic_t   *sa_update_magic;
   nta_update_tport_f   *sa_update_tport;
 
-  su_duration_t         sa_next; /**< Timestamp for next agent_timer. */
-  su_time_t             sa_now;	 /**< Timestamp in microsecond resolution. */
+  su_time_t             sa_now;	/**< Timestamp in microsecond resolution. */
   uint32_t              sa_millisec; /**< Timestamp in milliseconds resolution. */
 
-  uint32_t              sa_nw_updates; /* Shall we enable network detector? */
-
   uint32_t              sa_flags;	/**< Message flags */
-  msg_mclass_t const   *sa_mclass;
+  msg_mclass_t         *sa_mclass;
 
   sip_contact_t        *sa_contact;
   sip_via_t            *sa_vias;   /**< @Via headers for all transports */
@@ -224,9 +223,6 @@
   /** If true, automatically create compartments */
   unsigned              sa_auto_comp:1;
 
-  /** Set when executing timer */
-  unsigned              sa_in_timer:1;
-
   unsigned              :0;
 
   /** Messages memory preload. */
@@ -346,11 +342,6 @@
   unsigned          leg_loose_route : 1; /**< Topmost route in set is LR */
 #endif
   unsigned          leg_local_is_to : 1; /**< Backwards-compatibility. */
-  unsigned          leg_tagged : 1; /**< Tagged after creation.
-				     *
-				     * Request missing To tag matches it
-				     * even after tagging.
-				     */
   unsigned:0;
   nta_request_f    *leg_callback;
   nta_leg_magic_t  *leg_magic;
@@ -472,17 +463,12 @@
 
   sip_method_t        	orq_method;
   char const           *orq_method_name;
-  url_t const          *orq_url;        /**< Original RequestURI */
-
   sip_from_t const     *orq_from;
   sip_to_t const       *orq_to;
-  char const           *orq_tag;        /**< Tag from final response. */
-
   sip_cseq_t const     *orq_cseq;
   sip_call_id_t const  *orq_call_id;
 
-  msg_t		       *orq_request;
-  msg_t                *orq_response;
+  char const           *orq_tag;        /**< Tag from final response. */
 
   su_time_t             orq_sent;       /**< When request was sent? */
   unsigned              orq_delay;      /**< RTT estimate */
@@ -515,9 +501,11 @@
   unsigned orq_sigcomp_new:1;	/**< Create compartment if needed */
   unsigned orq_sigcomp_zap:1;	/**< Reset SigComp after completing */
   unsigned orq_must_100rel : 1;
-  unsigned orq_timestamp : 1;	/**< Insert @Timestamp header. */
+  unsigned orq_timestamp : 1;	/**< insert @Timestamp header. */
   unsigned : 0;	/* pad */
 
+  uint32_t              orq_rseq;       /**< Latest incoming rseq */
+
 #if HAVE_SOFIA_SRESOLV
   sipdns_resolver_t    *orq_resolver;
 #endif
@@ -534,10 +522,12 @@
 
   char const           *orq_branch;	/**< Transaction branch */
   char const           *orq_via_branch;	/**< @Via branch */
+  url_t const          *orq_url;        /**< Original RequestURI */
 
-  nta_outgoing_t       *orq_cancel;     /**< CANCEL transaction */
+  msg_t		       *orq_request;
+  msg_t                *orq_response;
 
-  uint32_t              orq_rseq;       /**< Latest incoming rseq */
+  nta_outgoing_t       *orq_cancel;     /**< CANCEL transaction */
 };
 
 /* Virtual function table for plugging in SigComp */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c	Sat Feb 17 01:25:21 2007
@@ -110,38 +110,38 @@
 
 /* Status */
 
-tag_typedef_t ntatag_s_irq_hash =         USIZETAG_TYPEDEF(s_irq_hash);
-tag_typedef_t ntatag_s_orq_hash =         USIZETAG_TYPEDEF(s_orq_hash);
-tag_typedef_t ntatag_s_leg_hash =         USIZETAG_TYPEDEF(s_leg_hash);
-tag_typedef_t ntatag_s_irq_hash_used =    USIZETAG_TYPEDEF(s_irq_hash_used);
-tag_typedef_t ntatag_s_orq_hash_used =    USIZETAG_TYPEDEF(s_orq_hash_used);
-tag_typedef_t ntatag_s_leg_hash_used =    USIZETAG_TYPEDEF(s_leg_hash_used);
-tag_typedef_t ntatag_s_recv_msg =         USIZETAG_TYPEDEF(s_recv_msg);
-tag_typedef_t ntatag_s_recv_request =     USIZETAG_TYPEDEF(s_recv_request);
-tag_typedef_t ntatag_s_recv_response =    USIZETAG_TYPEDEF(s_recv_response);
-tag_typedef_t ntatag_s_bad_message =      USIZETAG_TYPEDEF(s_bad_message);
-tag_typedef_t ntatag_s_bad_request =      USIZETAG_TYPEDEF(s_bad_request);
-tag_typedef_t ntatag_s_bad_response =     USIZETAG_TYPEDEF(s_bad_response);
-tag_typedef_t ntatag_s_drop_request =     USIZETAG_TYPEDEF(s_drop_request);
-tag_typedef_t ntatag_s_drop_response =    USIZETAG_TYPEDEF(s_drop_response);
-tag_typedef_t ntatag_s_client_tr =        USIZETAG_TYPEDEF(s_client_tr);
-tag_typedef_t ntatag_s_server_tr =        USIZETAG_TYPEDEF(s_server_tr);
-tag_typedef_t ntatag_s_dialog_tr =        USIZETAG_TYPEDEF(s_dialog_tr);
-tag_typedef_t ntatag_s_acked_tr =         USIZETAG_TYPEDEF(s_acked_tr);
-tag_typedef_t ntatag_s_canceled_tr =      USIZETAG_TYPEDEF(s_canceled_tr);
-tag_typedef_t ntatag_s_trless_request =   USIZETAG_TYPEDEF(s_trless_request);
-tag_typedef_t ntatag_s_trless_to_tr =     USIZETAG_TYPEDEF(s_trless_to_tr);
-tag_typedef_t ntatag_s_trless_response =  USIZETAG_TYPEDEF(s_trless_response);
-tag_typedef_t ntatag_s_trless_200 =       USIZETAG_TYPEDEF(s_trless_200);
-tag_typedef_t ntatag_s_merged_request =   USIZETAG_TYPEDEF(s_merged_request);
-tag_typedef_t ntatag_s_sent_msg =      	  USIZETAG_TYPEDEF(s_sent_msg);
-tag_typedef_t ntatag_s_sent_request =  	  USIZETAG_TYPEDEF(s_sent_request);
-tag_typedef_t ntatag_s_sent_response = 	  USIZETAG_TYPEDEF(s_sent_response);
-tag_typedef_t ntatag_s_retry_request = 	  USIZETAG_TYPEDEF(s_retry_request);
-tag_typedef_t ntatag_s_retry_response =   USIZETAG_TYPEDEF(s_retry_response);
-tag_typedef_t ntatag_s_recv_retry =       USIZETAG_TYPEDEF(s_recv_retry);
-tag_typedef_t ntatag_s_tout_request =     USIZETAG_TYPEDEF(s_tout_request);
-tag_typedef_t ntatag_s_tout_response =    USIZETAG_TYPEDEF(s_tout_response);
+tag_typedef_t ntatag_s_irq_hash =         UINTTAG_TYPEDEF(s_irq_hash);
+tag_typedef_t ntatag_s_orq_hash =         UINTTAG_TYPEDEF(s_orq_hash);
+tag_typedef_t ntatag_s_leg_hash =         UINTTAG_TYPEDEF(s_leg_hash);
+tag_typedef_t ntatag_s_irq_hash_used =    UINTTAG_TYPEDEF(s_irq_hash_used);
+tag_typedef_t ntatag_s_orq_hash_used =    UINTTAG_TYPEDEF(s_orq_hash_used);
+tag_typedef_t ntatag_s_leg_hash_used =    UINTTAG_TYPEDEF(s_leg_hash_used);
+tag_typedef_t ntatag_s_recv_msg =         UINTTAG_TYPEDEF(s_recv_msg);
+tag_typedef_t ntatag_s_recv_request =     UINTTAG_TYPEDEF(s_recv_request);
+tag_typedef_t ntatag_s_recv_response =    UINTTAG_TYPEDEF(s_recv_response);
+tag_typedef_t ntatag_s_bad_message =      UINTTAG_TYPEDEF(s_bad_message);
+tag_typedef_t ntatag_s_bad_request =      UINTTAG_TYPEDEF(s_bad_request);
+tag_typedef_t ntatag_s_bad_response =     UINTTAG_TYPEDEF(s_bad_response);
+tag_typedef_t ntatag_s_drop_request =     UINTTAG_TYPEDEF(s_drop_request);
+tag_typedef_t ntatag_s_drop_response =    UINTTAG_TYPEDEF(s_drop_response);
+tag_typedef_t ntatag_s_client_tr =        UINTTAG_TYPEDEF(s_client_tr);
+tag_typedef_t ntatag_s_server_tr =        UINTTAG_TYPEDEF(s_server_tr);
+tag_typedef_t ntatag_s_dialog_tr =        UINTTAG_TYPEDEF(s_dialog_tr);
+tag_typedef_t ntatag_s_acked_tr =         UINTTAG_TYPEDEF(s_acked_tr);
+tag_typedef_t ntatag_s_canceled_tr =      UINTTAG_TYPEDEF(s_canceled_tr);
+tag_typedef_t ntatag_s_trless_request =   UINTTAG_TYPEDEF(s_trless_request);
+tag_typedef_t ntatag_s_trless_to_tr =     UINTTAG_TYPEDEF(s_trless_to_tr);
+tag_typedef_t ntatag_s_trless_response =  UINTTAG_TYPEDEF(s_trless_response);
+tag_typedef_t ntatag_s_trless_200 =       UINTTAG_TYPEDEF(s_trless_200);
+tag_typedef_t ntatag_s_merged_request =   UINTTAG_TYPEDEF(s_merged_request);
+tag_typedef_t ntatag_s_sent_msg =      	  UINTTAG_TYPEDEF(s_sent_msg);
+tag_typedef_t ntatag_s_sent_request =  	  UINTTAG_TYPEDEF(s_sent_request);
+tag_typedef_t ntatag_s_sent_response = 	  UINTTAG_TYPEDEF(s_sent_response);
+tag_typedef_t ntatag_s_retry_request = 	  UINTTAG_TYPEDEF(s_retry_request);
+tag_typedef_t ntatag_s_retry_response =   UINTTAG_TYPEDEF(s_retry_response);
+tag_typedef_t ntatag_s_recv_retry =       UINTTAG_TYPEDEF(s_recv_retry);
+tag_typedef_t ntatag_s_tout_request =     UINTTAG_TYPEDEF(s_tout_request);
+tag_typedef_t ntatag_s_tout_response =    UINTTAG_TYPEDEF(s_tout_response);
 
 /* Internal */
 tag_typedef_t ntatag_delay_sending = BOOLTAG_TYPEDEF(delay_sending);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h	Sat Feb 17 01:25:21 2007
@@ -300,9 +300,6 @@
 				   tag_type_t tag, tag_value_t value, ...);
 
 SOFIAPUBFUN
-msg_t *nta_incoming_create_response(nta_incoming_t *irq, int status, char const *phrase);
-
-SOFIAPUBFUN
 int nta_incoming_treply(nta_incoming_t *ireq, 
 			int status, char const *phrase, 
 			tag_type_t tag, tag_value_t value, ...);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h	Sat Feb 17 01:25:21 2007
@@ -59,10 +59,10 @@
 
 NTA_DLL extern tag_typedef_t ntatag_mclass;
 /** Message class used by NTA. @HI */
-#define NTATAG_MCLASS(x) ntatag_mclass, tag_cptr_v((x))
+#define NTATAG_MCLASS(x) ntatag_mclass, tag_ptr_v((x))
 
 NTA_DLL extern tag_typedef_t ntatag_mclass_ref;
-#define NTATAG_MCLASS_REF(x) ntatag_mclass_ref, tag_cptr_vr(&(x), (x))
+#define NTATAG_MCLASS_REF(x) ntatag_mclass_ref, tag_ptr_vr(&(x), (x))
 
 NTA_DLL extern tag_typedef_t ntatag_bad_req_mask;
 /** Mask for bad request messages. 
@@ -464,223 +464,223 @@
 /* Tags for statistics. */
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash;
-#define NTATAG_S_IRQ_HASH(x) ntatag_s_irq_hash, tag_usize_v(x)
+#define NTATAG_S_IRQ_HASH(x) ntatag_s_irq_hash, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash_ref;
-#define NTATAG_S_IRQ_HASH_REF(x) ntatag_s_irq_hash_ref, tag_usize_vr(&(x))
+#define NTATAG_S_IRQ_HASH_REF(x) ntatag_s_irq_hash_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash;
-#define NTATAG_S_ORQ_HASH(x) ntatag_s_orq_hash, tag_usize_v(x)
+#define NTATAG_S_ORQ_HASH(x) ntatag_s_orq_hash, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash_ref;
-#define NTATAG_S_ORQ_HASH_REF(x) ntatag_s_orq_hash_ref, tag_usize_vr(&(x))
+#define NTATAG_S_ORQ_HASH_REF(x) ntatag_s_orq_hash_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash;
-#define NTATAG_S_LEG_HASH(x) ntatag_s_leg_hash, tag_usize_v(x)
+#define NTATAG_S_LEG_HASH(x) ntatag_s_leg_hash, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash_ref;
-#define NTATAG_S_LEG_HASH_REF(x) ntatag_s_leg_hash_ref, tag_usize_vr(&(x))
+#define NTATAG_S_LEG_HASH_REF(x) ntatag_s_leg_hash_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash_used;
-#define NTATAG_S_IRQ_HASH_USED(x) ntatag_s_irq_hash_used, tag_usize_v(x)
+#define NTATAG_S_IRQ_HASH_USED(x) ntatag_s_irq_hash_used, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_irq_hash_used_ref;
 #define NTATAG_S_IRQ_HASH_USED_REF(x) \
-ntatag_s_irq_hash_used_ref, tag_usize_vr(&(x))
+ntatag_s_irq_hash_used_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash_used;
-#define NTATAG_S_ORQ_HASH_USED(x) ntatag_s_orq_hash_used, tag_usize_v(x)
+#define NTATAG_S_ORQ_HASH_USED(x) ntatag_s_orq_hash_used, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_orq_hash_used_ref;
 #define NTATAG_S_ORQ_HASH_USED_REF(x) \
-ntatag_s_orq_hash_used_ref, tag_usize_vr(&(x))
+ntatag_s_orq_hash_used_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash_used;
-#define NTATAG_S_LEG_HASH_USED(x) ntatag_s_leg_hash_used, tag_usize_v(x)
+#define NTATAG_S_LEG_HASH_USED(x) ntatag_s_leg_hash_used, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_leg_hash_used_ref;
 #define NTATAG_S_LEG_HASH_USED_REF(x) \
-ntatag_s_leg_hash_used_ref, tag_usize_vr(&(x))
+ntatag_s_leg_hash_used_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_msg;
-#define NTATAG_S_RECV_MSG(x) ntatag_s_recv_msg, tag_usize_v(x)
+#define NTATAG_S_RECV_MSG(x) ntatag_s_recv_msg, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_msg_ref;
-#define NTATAG_S_RECV_MSG_REF(x) ntatag_s_recv_msg_ref, tag_usize_vr(&(x))
+#define NTATAG_S_RECV_MSG_REF(x) ntatag_s_recv_msg_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_request;
-#define NTATAG_S_RECV_REQUEST(x) ntatag_s_recv_request, tag_usize_v(x)
+#define NTATAG_S_RECV_REQUEST(x) ntatag_s_recv_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_request_ref;
 #define NTATAG_S_RECV_REQUEST_REF(x)\
- ntatag_s_recv_request_ref, tag_usize_vr(&(x))
+ ntatag_s_recv_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_response;
-#define NTATAG_S_RECV_RESPONSE(x) ntatag_s_recv_response, tag_usize_v(x)
+#define NTATAG_S_RECV_RESPONSE(x) ntatag_s_recv_response, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_response_ref;
 #define NTATAG_S_RECV_RESPONSE_REF(x)\
- ntatag_s_recv_response_ref, tag_usize_vr(&(x))
+ ntatag_s_recv_response_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_message;
-#define NTATAG_S_BAD_MESSAGE(x) ntatag_s_bad_message, tag_usize_v(x)
+#define NTATAG_S_BAD_MESSAGE(x) ntatag_s_bad_message, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_message_ref;
 #define NTATAG_S_BAD_MESSAGE_REF(x)\
- ntatag_s_bad_message_ref, tag_usize_vr(&(x))
+ ntatag_s_bad_message_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_request;
-#define NTATAG_S_BAD_REQUEST(x) ntatag_s_bad_request, tag_usize_v(x)
+#define NTATAG_S_BAD_REQUEST(x) ntatag_s_bad_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_request_ref;
 #define NTATAG_S_BAD_REQUEST_REF(x)\
- ntatag_s_bad_request_ref, tag_usize_vr(&(x))
+ ntatag_s_bad_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_response;
-#define NTATAG_S_BAD_RESPONSE(x) ntatag_s_bad_response, tag_usize_v(x)
+#define NTATAG_S_BAD_RESPONSE(x) ntatag_s_bad_response, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_bad_response_ref;
 #define NTATAG_S_BAD_RESPONSE_REF(x)\
- ntatag_s_bad_response_ref, tag_usize_vr(&(x))
+ ntatag_s_bad_response_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_request;
-#define NTATAG_S_DROP_REQUEST(x) ntatag_s_drop_request, tag_usize_v(x)
+#define NTATAG_S_DROP_REQUEST(x) ntatag_s_drop_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_request_ref;
 #define NTATAG_S_DROP_REQUEST_REF(x)\
- ntatag_s_drop_request_ref, tag_usize_vr(&(x))
+ ntatag_s_drop_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_response;
-#define NTATAG_S_DROP_RESPONSE(x) ntatag_s_drop_response, tag_usize_v(x)
+#define NTATAG_S_DROP_RESPONSE(x) ntatag_s_drop_response, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_drop_response_ref;
 #define NTATAG_S_DROP_RESPONSE_REF(x)\
- ntatag_s_drop_response_ref, tag_usize_vr(&(x))
+ ntatag_s_drop_response_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_client_tr;
-#define NTATAG_S_CLIENT_TR(x) ntatag_s_client_tr, tag_usize_v(x)
+#define NTATAG_S_CLIENT_TR(x) ntatag_s_client_tr, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_client_tr_ref;
 #define NTATAG_S_CLIENT_TR_REF(x)\
- ntatag_s_client_tr_ref, tag_usize_vr(&(x))
+ ntatag_s_client_tr_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_server_tr;
-#define NTATAG_S_SERVER_TR(x) ntatag_s_server_tr, tag_usize_v(x)
+#define NTATAG_S_SERVER_TR(x) ntatag_s_server_tr, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_server_tr_ref;
 #define NTATAG_S_SERVER_TR_REF(x)\
- ntatag_s_server_tr_ref, tag_usize_vr(&(x))
+ ntatag_s_server_tr_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_dialog_tr;
-#define NTATAG_S_DIALOG_TR(x) ntatag_s_dialog_tr, tag_usize_v(x)
+#define NTATAG_S_DIALOG_TR(x) ntatag_s_dialog_tr, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_dialog_tr_ref;
 #define NTATAG_S_DIALOG_TR_REF(x)\
- ntatag_s_dialog_tr_ref, tag_usize_vr(&(x))
+ ntatag_s_dialog_tr_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_acked_tr;
-#define NTATAG_S_ACKED_TR(x) ntatag_s_acked_tr, tag_usize_v(x)
+#define NTATAG_S_ACKED_TR(x) ntatag_s_acked_tr, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_acked_tr_ref;
-#define NTATAG_S_ACKED_TR_REF(x) ntatag_s_acked_tr_ref, tag_usize_vr(&(x))
+#define NTATAG_S_ACKED_TR_REF(x) ntatag_s_acked_tr_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_canceled_tr;
-#define NTATAG_S_CANCELED_TR(x) ntatag_s_canceled_tr, tag_usize_v(x)
+#define NTATAG_S_CANCELED_TR(x) ntatag_s_canceled_tr, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_canceled_tr_ref;
 #define NTATAG_S_CANCELED_TR_REF(x)  \
- ntatag_s_canceled_tr_ref, tag_usize_vr(&(x))
+ ntatag_s_canceled_tr_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_request;
-#define NTATAG_S_TRLESS_REQUEST(x) ntatag_s_trless_request, tag_usize_v(x)
+#define NTATAG_S_TRLESS_REQUEST(x) ntatag_s_trless_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_request_ref;
 #define NTATAG_S_TRLESS_REQUEST_REF(x)\
- ntatag_s_trless_request_ref, tag_usize_vr(&(x))
+ ntatag_s_trless_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_to_tr;
-#define NTATAG_S_TRLESS_TO_TR(x) ntatag_s_trless_to_tr, tag_usize_v(x)
+#define NTATAG_S_TRLESS_TO_TR(x) ntatag_s_trless_to_tr, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_to_tr_ref;
 #define NTATAG_S_TRLESS_TO_TR_REF(x)\
- ntatag_s_trless_to_tr_ref, tag_usize_vr(&(x))
+ ntatag_s_trless_to_tr_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_response;
-#define NTATAG_S_TRLESS_RESPONSE(x) ntatag_s_trless_response, tag_usize_v(x)
+#define NTATAG_S_TRLESS_RESPONSE(x) ntatag_s_trless_response, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_response_ref;
 #define NTATAG_S_TRLESS_RESPONSE_REF(x)\
- ntatag_s_trless_response_ref, tag_usize_vr(&(x))
+ ntatag_s_trless_response_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_200;
-#define NTATAG_S_TRLESS_200(x) ntatag_s_trless_200, tag_usize_v(x)
+#define NTATAG_S_TRLESS_200(x) ntatag_s_trless_200, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_trless_200_ref;
 #define NTATAG_S_TRLESS_200_REF(x)\
- ntatag_s_trless_200_ref, tag_usize_vr(&(x))
+ ntatag_s_trless_200_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_merged_request;
-#define NTATAG_S_MERGED_REQUEST(x) ntatag_s_merged_request, tag_usize_v(x)
+#define NTATAG_S_MERGED_REQUEST(x) ntatag_s_merged_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_merged_request_ref;
 #define NTATAG_S_MERGED_REQUEST_REF(x)\
- ntatag_s_merged_request_ref, tag_usize_vr(&(x))
+ ntatag_s_merged_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_msg;
-#define NTATAG_S_SENT_MSG(x) ntatag_s_sent_msg, tag_usize_v(x)
+#define NTATAG_S_SENT_MSG(x) ntatag_s_sent_msg, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_msg_ref;
 #define NTATAG_S_SENT_MSG_REF(x)\
- ntatag_s_sent_msg_ref, tag_usize_vr(&(x))
+ ntatag_s_sent_msg_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_request;
-#define NTATAG_S_SENT_REQUEST(x) ntatag_s_sent_request, tag_usize_v(x)
+#define NTATAG_S_SENT_REQUEST(x) ntatag_s_sent_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_request_ref;
 #define NTATAG_S_SENT_REQUEST_REF(x)\
- ntatag_s_sent_request_ref, tag_usize_vr(&(x))
+ ntatag_s_sent_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_response;
-#define NTATAG_S_SENT_RESPONSE(x) ntatag_s_sent_response, tag_usize_v(x)
+#define NTATAG_S_SENT_RESPONSE(x) ntatag_s_sent_response, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_sent_response_ref;
 #define NTATAG_S_SENT_RESPONSE_REF(x)\
- ntatag_s_sent_response_ref, tag_usize_vr(&(x))
+ ntatag_s_sent_response_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_request;
-#define NTATAG_S_RETRY_REQUEST(x) ntatag_s_retry_request, tag_usize_v(x)
+#define NTATAG_S_RETRY_REQUEST(x) ntatag_s_retry_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_request_ref;
 #define NTATAG_S_RETRY_REQUEST_REF(x)\
- ntatag_s_retry_request_ref, tag_usize_vr(&(x))
+ ntatag_s_retry_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_response;
-#define NTATAG_S_RETRY_RESPONSE(x) ntatag_s_retry_response, tag_usize_v(x)
+#define NTATAG_S_RETRY_RESPONSE(x) ntatag_s_retry_response, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_retry_response_ref;
 #define NTATAG_S_RETRY_RESPONSE_REF(x)\
- ntatag_s_retry_response_ref, tag_usize_vr(&(x))
+ ntatag_s_retry_response_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_retry;
-#define NTATAG_S_RECV_RETRY(x) ntatag_s_recv_retry, tag_usize_v(x)
+#define NTATAG_S_RECV_RETRY(x) ntatag_s_recv_retry, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_recv_retry_ref;
 #define NTATAG_S_RECV_RETRY_REF(x)\
- ntatag_s_recv_retry_ref, tag_usize_vr(&(x))
+ ntatag_s_recv_retry_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_request;
-#define NTATAG_S_TOUT_REQUEST(x) ntatag_s_tout_request, tag_usize_v(x)
+#define NTATAG_S_TOUT_REQUEST(x) ntatag_s_tout_request, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_request_ref;
 #define NTATAG_S_TOUT_REQUEST_REF(x)\
- ntatag_s_tout_request_ref, tag_usize_vr(&(x))
+ ntatag_s_tout_request_ref, tag_uint_vr(&(x))
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_response;
-#define NTATAG_S_TOUT_RESPONSE(x) ntatag_s_tout_response, tag_usize_v(x)
+#define NTATAG_S_TOUT_RESPONSE(x) ntatag_s_tout_response, tag_uint_v(x)
 
 NTA_DLL extern tag_typedef_t ntatag_s_tout_response_ref;
 #define NTATAG_S_TOUT_RESPONSE_REF(x)\
- ntatag_s_tout_response_ref, tag_usize_vr(&(x))
+ ntatag_s_tout_response_ref, tag_uint_vr(&(x))
 
 SOFIA_END_DECLS
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c	Sat Feb 17 01:25:21 2007
@@ -654,7 +654,7 @@
 
   *contents = buffer;
 
-  return (int)len;
+  return len;
 }
 
 #if HAVE_DIRENT_H

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c	Sat Feb 17 01:25:21 2007
@@ -559,18 +559,18 @@
 
   nta_agent_t *nta;
 
-  usize_t irq_hash = -1, orq_hash = -1, leg_hash = -1;
-  usize_t recv_msg = -1, sent_msg = -1;
-  usize_t recv_request = -1, recv_response = -1;
-  usize_t bad_message = -1, bad_request = -1, bad_response = -1;
-  usize_t drop_request = -1, drop_response = -1;
-  usize_t client_tr = -1, server_tr = -1, dialog_tr = -1;
-  usize_t acked_tr = -1, canceled_tr = -1;
-  usize_t trless_request = -1, trless_to_tr = -1, trless_response = -1;
-  usize_t trless_200 = -1, merged_request = -1;
-  usize_t sent_request = -1, sent_response = -1;
-  usize_t retry_request = -1, retry_response = -1, recv_retry = -1;
-  usize_t tout_request = -1, tout_response = -1;
+  uint32_t irq_hash = -1, orq_hash = -1, leg_hash = -1;
+  uint32_t recv_msg = -1, sent_msg = -1;
+  uint32_t recv_request = -1, recv_response = -1;
+  uint32_t bad_message = -1, bad_request = -1, bad_response = -1;
+  uint32_t drop_request = -1, drop_response = -1;
+  uint32_t client_tr = -1, server_tr = -1, dialog_tr = -1;
+  uint32_t acked_tr = -1, canceled_tr = -1;
+  uint32_t trless_request = -1, trless_to_tr = -1, trless_response = -1;
+  uint32_t trless_200 = -1, merged_request = -1;
+  uint32_t sent_request = -1, sent_response = -1;
+  uint32_t retry_request = -1, retry_response = -1, recv_retry = -1;
+  uint32_t tout_request = -1, tout_response = -1;
 
   TEST_1(nta = nta_agent_create(ag->ag_root, (url_string_t *)"sip:*:*",
 				NULL, NULL, TAG_END()));
@@ -1301,10 +1301,10 @@
   }
 
   if (o_attach) {
-    char *response, line[10];
+    char line[10];
     printf("nua_test: pid %lu\n", (unsigned long)getpid());
     printf("<Press RETURN to continue>\n");
-    response = fgets(line, sizeof line, stdin);
+    fgets(line, sizeof line, stdin);
   }
 #if HAVE_ALARM
   else if (o_alarm) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -63,4 +63,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libnth_la_SOURCES) http-client.c http-server.c test_nth.c
@@ -80,12 +55,8 @@
 target_triplet = @target@
 check_PROGRAMS = test_nth$(EXEEXT) http-client$(EXEEXT) \
 	http-server$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/nth
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -154,7 +125,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -201,12 +171,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -250,7 +216,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -349,8 +314,7 @@
 EXTRA_DIST = Doxyfile nth.docs $(BUILT_SOURCES) \
 			agent.pem cafile.pem
 
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -376,14 +340,12 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -626,7 +588,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -777,92 +739,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/http-server.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/http-server.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/http-server.c	Sat Feb 17 01:25:21 2007
@@ -38,10 +38,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
-
-#if HAVE_SIGNAL
 #include <signal.h>
-#endif
 
 typedef struct context_s context_t;
 #define NTH_SITE_MAGIC_T context_t
@@ -80,10 +77,7 @@
 		   http_t const *http,
 		   char const *path);
 su_msg_r server_intr_msg = SU_MSG_R_INIT;
-
-#if HAVE_SIGNAL
 static RETSIGTYPE server_intr_handler(int signum);
-#endif
 static void server_break(context_t *c, su_msg_r msg, su_msg_arg_t *arg);
 
 static msg_payload_t *read_payload(su_home_t *home, char const *fname);
@@ -146,13 +140,13 @@
 		su_root_task(context->c_root),
 		server_break, 0);
 
-#if HAVE_SIGNAL
   signal(SIGINT, server_intr_handler);
-#if HAVE_SIGQUIT
+
+#ifndef _WIN32
+  signal(SIGPIPE, server_intr_handler);
   signal(SIGQUIT, server_intr_handler);
   signal(SIGHUP, server_intr_handler);
 #endif
-#endif
 
   if (context->c_root) {
     context->c_site =

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_client.c	Sat Feb 17 01:25:21 2007
@@ -1094,7 +1094,7 @@
 
   assert(status >= 400);
 
-  SU_DEBUG_5(("nth: hc_reply(%p, %u, %s)\n", (void *)hc, status, phrase));
+  SU_DEBUG_5(("nth: hc_reply(%p, %u, %s)\n", hc, status, phrase));
 
   if (hc->hc_pending) {
     tport_release(hc->hc_tport, hc->hc_pending, hc->hc_request, NULL, hc,

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_server.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_server.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nth/nth_server.c	Sat Feb 17 01:25:21 2007
@@ -704,7 +704,7 @@
 			tag_type_t tag, tag_value_t value, ...)
 {
   server_t *srv;
-  msg_mclass_t const *mclass = NULL;
+  msg_mclass_t *mclass = NULL;
   tp_name_t tpn[1] = {{ NULL }};
   su_root_t *root = NULL;
   http_server_t const *server = NULL;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -96,6 +96,6 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 TAG_DLL_FLAGS =		LIST=nua_tag_list

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libnua_la_SOURCES) $(test_nua_SOURCES)
@@ -79,12 +54,8 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = test_nua$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/nua
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -149,7 +120,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -196,12 +166,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -245,7 +211,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -376,8 +341,7 @@
 # ----------------------------------------------------------------------
 # Install and distribution rules
 EXTRA_DIST = Doxyfile nua.docs $(BUILT_SOURCES)
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -403,8 +367,6 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -414,7 +376,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -681,7 +643,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -832,92 +794,6 @@
  ../sresolv/libsresolv.la ../stun/libstun.la ../su/libsu.la \
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
-
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c	Sat Feb 17 01:25:21 2007
@@ -67,7 +67,7 @@
  *
  * The NUA_DEBUG environment variable is used to determine the debug logging
  * level for @nua module. The default level is 3.
- *
+ * 
  * @sa <sofia-sip/su_debug.h>, nua_log, SOFIA_DEBUG
  */
 extern char const NUA_DEBUG[];
@@ -76,8 +76,8 @@
 #define SU_DEBUG 3
 #endif
 
-/**Debug log for @nua module.
- *
+/**Debug log for @nua module. 
+ * 
  * The nua_log is the log object used by @nua module. The level of
  * #nua_log is set using #NUA_DEBUG environment variable.
  */
@@ -104,17 +104,16 @@
  *     NUTAG_UICC()             \n
  *     NUTAG_CERTIFICATE_DIR()  \n
  *     and all tags listed in nua_set_params(), \n
- *     and all relevant NTATAG_* are passed to NTA \n
- *     and all tport tags listed in <sofia-sip/tport_tag.h>
+ *     and all relevant NTATAG_* are passed to NTA.
  *
  * @note
- * From the @VERSION_1_12_2 all the nua_set_params() tags are processed.
+ * From the @VERSION_1_12_2 all the nua_set_params() tags are processed. 
  * Previously all nutags except NUTAG_SOA_NAME() and NUTAG_MEDIA_ENABLE()
  * were ignored.
  *
  * @note
  * Both the NUTAG_URL() and NUTAG_SIPS_URL() are used to pass arguments to
- * nta_agent_add_tport().
+ * nta_agent_add_tport(). 
  *
  * @par Events:
  *     none
@@ -188,9 +187,9 @@
 
 /** Destroy the @nua stack.
  *
- * Before calling nua_destroy() the application
+ * Before calling nua_destroy() the application 
  * should call nua_shutdown and wait for successful #nua_r_shutdown event.
- * Shuts down and destroys the @nua stack. Ongoing calls, registrations,
+ * Shuts down and destroys the @nua stack. Ongoing calls, registrations, 
  * and subscriptions are left as they are.
  *
  * @param nua         Pointer to @nua stack object
@@ -212,8 +211,7 @@
 
   if (nua) {
     if (!nua->nua_shutdown_final) {
-      SU_DEBUG_0(("nua_destroy(%p): FATAL: nua_shutdown not completed\n",
-		  (void *)nua));
+      SU_DEBUG_0(("nua_destroy(%p): FATAL: nua_shutdown not completed\n", nua));
       assert(nua->nua_shutdown);
       return;
     }
@@ -244,7 +242,7 @@
 
 /** Obtain default operation handle of the @nua stack object.
  *
- * A default operation can be used for operations where the
+ * A default operation can be used for operations where the 
  * ultimate result is not important or can be discarded.
  *
  * @param nua         Pointer to @nua stack object
@@ -264,7 +262,7 @@
   return nua ? nua->nua_handles : NULL;
 }
 
-/** Create an operation handle
+/** Create an operation handle 
  *
  * Allocates a new operation handle and associated storage.
  *
@@ -277,7 +275,7 @@
  *
  * @par Related tags:
  *     Duplicates the provided tags for use with every operation. Note that
- *     NUTAG_URL() is converted to SIPTAG_TO() if there is no SIPTAG_TO().
+ *     NUTAG_URL() is converted to SIPTAG_TO() if there is no SIPTAG_TO(). 
  *     And also vice versa, request-URI is taken from SIPTAG_TO() if there
  *     is no NUTAG_URL(). Note that certain SIP headers cannot be saved with
  *     the handle. They include @ContentLength, @CSeq, @RSeq, @RAck, and
@@ -304,7 +302,7 @@
     ta_start(ta, tag, value);
 
     nh = nh_create_handle(nua, hmagic, ta_args(ta));
-
+    
     if (nh)
       nh->nh_ref_by_user = 1;
 
@@ -314,7 +312,7 @@
   return nh;
 }
 
-/** Bind a callback context to an operation handle.
+/** Bind a callback context to an operation handle. 
  *
  * @param nh          Pointer to operation handle
  * @param hmagic      Pointer to callback context
@@ -336,7 +334,7 @@
     nh->nh_magic = hmagic;
 }
 
-/** Fetch a callback context from an operation handle.
+/** Fetch a callback context from an operation handle. 
  *
  * @param nh          Pointer to operation handle
  *
@@ -358,7 +356,7 @@
 
   if (NH_IS_VALID(nh))
     magic = nh->nh_magic;
-
+  
   return magic;
 }
 
@@ -371,8 +369,8 @@
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0 no invite in operation or operation handle is invalid
- * @retval 1 operation has invite
+ * @retval 0 no invite in operation or operation handle is invalid 
+ * @retval 1 operation has invite 
  *
  * @par Related tags:
  *     none
@@ -385,15 +383,15 @@
   return nh ? nh->nh_has_invite : 0;
 }
 
-/**Check if operation handle has active event subscriptions.
+/**Check if operation handle has active event subscriptions. 
  *
  * Active subscription can be established either by nua_subscribe() or
  * nua_refer() calls.
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0    no event subscriptions in operation or
- *              operation handle is invalid
+ * @retval 0    no event subscriptions in operation or 
+ *              operation handle is invalid 
  * @retval !=0  operation has event subscriptions
  *
  * @par Related tags:
@@ -418,7 +416,7 @@
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0 no active registration in operation or
+ * @retval 0 no active registration in operation or 
  *           operation handle is invalid
  * @retval 1 operation has registration
  *
@@ -435,12 +433,12 @@
   return nh && nh->nh_ds->ds_has_register;
 }
 
-/** Check if operation handle has been used with outgoing SUBSCRIBE of REFER request.
+/** Check if operation handle has been used with outgoing SUBSCRIBE of REFER request. 
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0 no active subscription in operation or
- *           operation handle is invalid
+ * @retval 0 no active subscription in operation or 
+ *           operation handle is invalid 
  * @retval 1 operation has subscription.
  *
  * @par Related tags:
@@ -472,7 +470,7 @@
   return nh ? nh->nh_has_register : 0;
 }
 
-/** Check if operation handle has an active call
+/** Check if operation handle has an active call 
  *
  * @param nh          Pointer to operation handle
  *
@@ -490,17 +488,17 @@
   return nh ? nh->nh_active_call : 0;
 }
 
-/** Check if operation handle has a call on hold
+/** Check if operation handle has a call on hold 
  *
- * Please note that this status is not affected by remote end putting
- * this end on hold. Remote end can put each media separately on hold
- * and status is reflected on SOATAG_ACTIVE_AUDIO(), SOATAG_ACTIVE_VIDEO()
+ * Please note that this status is not affected by remote end putting 
+ * this end on hold. Remote end can put each media separately on hold 
+ * and status is reflected on SOATAG_ACTIVE_AUDIO(), SOATAG_ACTIVE_VIDEO() 
  * and SOATAG_ACTIVE_CHAT() tag values in #nua_i_state event.
  *
  * @param nh          Pointer to operation handle
  *
- * @retval 0  if no call on hold in operation or operation handle is invalid
- * @retval 1  if operation has call on hold, for example nua_invite() or
+ * @retval 0  if no call on hold in operation or operation handle is invalid 
+ * @retval 1  if operation has call on hold, for example nua_invite() or 
  *            nua_update() has been called with SOATAG_HOLD() with non-NULL
  *            argument.
  *
@@ -517,14 +515,14 @@
 
 /** Get the remote address (From/To header) of operation handle
  *
- * Remote address is used as To header in outgoing operations and
+ * Remote address is used as To header in outgoing operations and 
  * derived from From: header in incoming operations.
  *
  * @param nh          Pointer to operation handle
  *
  * @retval NULL   no remote address for operation or operation handle invalid
  * @retval !=NULL pointer to remote address for operation
- *
+ *     
  * @par Related tags:
  *     none
  *
@@ -538,14 +536,14 @@
 
 /** Get the local address (From/To header) of operation handle
  *
- * Local address is used as From header in outgoing operations and
+ * Local address is used as From header in outgoing operations and 
  * derived from To: header in incoming operations.
  *
  * @param nh          Pointer to operation handle
  *
  * @retval NULL   no local address for operation or operation handle invalid
  * @retval !=NULL pointer to local address for operation
- *
+ *     
  * @par Related tags:
  *     none
  *
@@ -592,7 +590,7 @@
     ta_end(ta); \
   } \
   else { \
-    SU_DEBUG_1(("nua: " #event " with invalid handle %p\n", (void *)nh)); \
+    SU_DEBUG_1(("nua: " #event " with invalid handle %p\n", nh));	\
   }
 
 /* Documented with nua_stack_set_params() */
@@ -660,18 +658,18 @@
   NUA_SIGNAL(nh, nua_r_method, tag, value);
 }
 
-/** Send a chat message.
+/** Send a chat message. 
  *
- * A chat channel can be established during call setup using "message" media.
- * An active chat channel is indicated using #nua_i_state event containing
- * SOATAG_ACTIVE_CHAT() tag. Chat messages can be sent using this channel with
- * nua_chat() function. Currently this is implemented using SIP MESSAGE
+ * A chat channel can be established during call setup using "message" media. 
+ * An active chat channel is indicated using #nua_i_state event containing 
+ * SOATAG_ACTIVE_CHAT() tag. Chat messages can be sent using this channel with 
+ * nua_chat() function. Currently this is implemented using SIP MESSAGE 
  * requests but in future MSRP (message session protocol) will replace it.
 *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return
+ * @return 
  *    nothing
  *
  * @par Related Tags:
@@ -709,18 +707,18 @@
 
 /* nua_r_notify is documented with process_response_to_notify() */
 
-/** Create an event server.
+/** Create an event server. 
  *
- * This function create an event server taking care of sending NOTIFY
- * requests and responding to further SUBSCRIBE requests. The event
- * server can accept multiple subscriptions from several sources and
- * takes care for distributing the notifications. Unlike other functions
+ * This function create an event server taking care of sending NOTIFY 
+ * requests and responding to further SUBSCRIBE requests. The event 
+ * server can accept multiple subscriptions from several sources and 
+ * takes care for distributing the notifications. Unlike other functions 
  * this call only accepts the SIP tags listed below.
  *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return
+ * @return 
  *    nothing
  *
  * @par Related Tags:
@@ -738,7 +736,7 @@
   NUA_SIGNAL(nh, nua_r_notifier, tag, value);
 }
 
-/** Terminate an event server.
+/** Terminate an event server. 
  *
  * Terminate an event server with matching event and content type. The event
  * server was created earlier with nua_notifier() function.
@@ -746,7 +744,7 @@
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return
+ * @return 
  *    nothing
  *
  * @par Related Tags:
@@ -811,7 +809,7 @@
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return
+ * @return 
  *    nothing
  *
  * @par Related Tags:
@@ -829,7 +827,7 @@
  *
  * After creating a local presence server by nua_notifier(), an incoming
  * SUBSCRIBE request causes #nua_i_subscription event. Each subscriber is
- * identified with NEATAG_SUB() tag in the #nua_i_subscription event.
+ * identified with NEATAG_SUB() tag in the #nua_i_subscription event. 
  * Application can either authorize the subscriber with
  * NUTAG_SUBSTATE(#nua_substate_active) or terminate the subscription with
  * NUTAG_SUBSTATE(#nua_substate_terminated).
@@ -837,7 +835,7 @@
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
  *
- * @return
+ * @return 
  *    nothing
  *
  * @par Related Tags:
@@ -877,11 +875,11 @@
     ta_end(ta);
   }
   else {
-    SU_DEBUG_1(("nua: respond with invalid handle %p\n", (void *)nh));
+    SU_DEBUG_1(("nua: respond with invalid handle %p\n", nh));
   }
 }
 
-/** Destroy a handle
+/** Destroy a handle 
  *
  * Terminate the protocol state associated with an operation handle. The
  * stack discards resources and terminates the ongoing dialog usage,
@@ -895,7 +893,7 @@
  *
  * @param nh              Pointer to operation handle
  *
- * @return
+ * @return 
  *    nothing
  *
  * @par Related Tags:
@@ -956,14 +954,11 @@
     e->e_status = status;
     e->e_phrase = phrase;
 
-    SU_DEBUG_7(("nua(%p): signal %s\n", (void *)nh,
-		nua_event_name(event) + 4));
-
-    if (su_msg_send(sumsg) != 0 && event != nua_r_destroy)
+    if (su_msg_send(sumsg) != 0)
       nua_handle_unref(nh);
-  }
+  } 
   else {
-    /* XXX  - we should return error code to application but we just abort() */
+    /* XXX  - we should return error code to application */
     assert(ENOMEM == 0);
   }
 
@@ -986,16 +981,8 @@
   }
 
   if (!nh || !nh->nh_valid) {	/* Handle has been destroyed */
-    if (nua_log->log_level >= 7) {
-      char const *name = nua_event_name(e->e_event) + 4;
-      SU_DEBUG_7(("nua(%p): event %s dropped\n", (void *)nh, name));
-    }
     if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
-#if HAVE_NUA_HANDLE_DEBUG
-      SU_DEBUG_0(("nua(%p): freed by application\n", (void *)nh));
-#else
-      SU_DEBUG_9(("nua(%p): freed by application\n", (void *)nh));
-#endif
+      SU_DEBUG_9(("nua(%p): freed by application\n", nh));
     }
     if (e->e_msg)
       msg_destroy(e->e_msg), e->e_msg = NULL;
@@ -1024,11 +1011,7 @@
 		    e->e_tags);
 
   if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
-#if HAVE_NUA_HANDLE_DEBUG
-    SU_DEBUG_0(("nua(%p): freed by application\n", (void *)nh));
-#else
-    SU_DEBUG_9(("nua(%p): freed by application\n", (void *)nh));
-#endif
+    SU_DEBUG_9(("nua(%p): freed by application\n", nh));
   }
 
   if (!su_msg_is_non_null(nua->nua_current))
@@ -1083,7 +1066,7 @@
       msg_destroy(e->e_msg), e->e_msg = NULL;
 
     if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
-      SU_DEBUG_9(("nua(%p): freed by application\n", (void *)nh));
+      SU_DEBUG_9(("nua(%p): freed by application\n", nh));
     }
 
     su_msg_destroy(saved);
@@ -1111,35 +1094,20 @@
 
 /**Generate a @Replaces header for handle.
  *
- * A @Replaces header contains the @CallID value, @From and @To tags
- * corresponding to SIP dialog associated with handle @a nh. Note that the
- * @Replaces matches with dialog of the remote peer,
- * nua_handle_by_replaces() does not return same handle (unless you swap
- * rp_from_tag and rp_to_tag in @Replaces header).
- *
- * A @Replaces header is used in attended transfer, among other things.
- *
- * @param nh pointer to operation handle
- * @param home memory home used to allocate the header
- * @param early_only if true, include "early-only" parameter in @Replaces, too
- *
- * @return A newly created @Replaces header.
- *
  * @since New in @VERSION_1_12_4.
  *
- * @sa nua_handle_by_replaces(), @Replaces, @RFC3891, @RFC3515, nua_refer(),
- * #nua_i_refer(), @ReferTo, nta_leg_make_replaces(),
- * sip_headers_as_url_query()
+ * @sa nua_handle_by_replaces(), @Replaces, @RFC3891, nua_refer(),
+ * #nua_i_refer, @ReferTo, nta_leg_make_replaces()
  */
-sip_replaces_t *nua_handle_make_replaces(nua_handle_t *nh,
+sip_replaces_t *nua_handle_make_replaces(nua_handle_t *nh, 
 					 su_home_t *home,
 					 int early_only)
 {
   if (nh && nh->nh_valid && nh->nh_nua) {
     struct nua_stack_handle_make_replaces_args a = { NULL, nh, home, early_only };
 
-    if (su_task_execute(nh->nh_nua->nua_server,
-			nua_stack_handle_make_replaces_call, (void *)&a,
+    if (su_task_execute(nh->nh_nua->nua_server, 
+			nua_stack_handle_make_replaces_call, (void *)&a, 
 			NULL) == 0) {
       return a.retval;
     }
@@ -1166,9 +1134,9 @@
  *
  * @since New in @VERSION_1_12_4.
  *
- * @note
+ * @note 
  * You should release the reference with nua_handle_unref() when you are
- * done with the handle.
+ * done with handle.
  *
  * @sa nua_handle_make_replaces(), @Replaces, @RFC3891, nua_refer(),
  * #nua_i_refer, @ReferTo, nta_leg_by_replaces()
@@ -1178,8 +1146,8 @@
   if (nua) {
     struct nua_stack_handle_by_replaces_args a = { NULL, nua, r };
 
-    if (su_task_execute(nua->nua_server,
-			nua_stack_handle_by_replaces_call, (void *)&a,
+    if (su_task_execute(nua->nua_server, 
+			nua_stack_handle_by_replaces_call, (void *)&a, 
 			NULL) == 0) {
       nua_handle_t *nh = a.retval;
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.docs
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.docs	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.docs	Sat Feb 17 01:25:21 2007
@@ -1124,7 +1124,7 @@
     <td>terminating</td>
     <td>Process answer</td>
     <td>
-   If there was a failure in SDP negotiation or other failure with media,
+   If there was an failure in SDP negotiation or other failure with media,
    the stack will automatically terminate the call. The BYE follows
    immediatelhy after the ACK.
 </td></tr>
@@ -1262,7 +1262,7 @@
      |    +---------------|            |    :         |     :
      |    |               +------------+    :         |     :
      |    |                           |     :         |     :
-     |    |          nua_respond/18X (2a)   :         |     :
+     |    |          nua_respond/18X (2)    :         |     :
      |    |                           |     :         |     :
      |    |                           V     V         |     :
      |    |                          +------------+   |     :
@@ -2219,7 +2219,7 @@
  * @param nh     operation handle associated with the notifier
  * @param hmagic operation magic associated with the notifier
  * @param sip    response to MESSAGE request or NULL upon an error
- *               (error code and message are in status and phrase parameters)
+ *               (error code and message are in status an phrase parameters)
  * @param tags   empty
  *
  * @sa nua_chat(), #nua_r_message

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c	Sat Feb 17 01:25:21 2007
@@ -110,14 +110,13 @@
   assert(nua->nua_home);
 
   if ((nh = su_home_clone(nua->nua_home, sizeof(*nh)))) {
-    nh->nh_valid = nua_valid_handle_cookie;
+    nh->nh_valid = nua_handle;
     nh->nh_nua = nua;
     nh->nh_magic = hmagic;
     nh->nh_prefs = nua->nua_dhandle->nh_prefs;
 
     if (nua_handle_save_tags(nh, tags) < 0) {
-      SU_DEBUG_5(("nua(%p): creating handle %p failed\n",
-		  (void *)nua, (void *)nh));
+      SU_DEBUG_5(("nua(%p): creating handle %p failed\n", nua, nh));
       su_home_unref(nh->nh_home), nh = NULL;
     }
     
@@ -137,7 +136,7 @@
       } 
       else {
 	_handle_lifetime = 2;
-	SU_DEBUG_0(("nh_handle_create(%p)\n", (void *)nh));
+	SU_DEBUG_0(("nh_handle_create(%p)\n", nh));
 	su_home_destructor(nh->nh_home, nh_destructor);
       }
     }
@@ -160,11 +159,9 @@
 static void nh_destructor(void *arg)
 {
   nua_handle_t *nh = arg;
-  SU_DEBUG_0(("nh_destructor(%p)\n", (void *)nh));
-}
 
-#undef nua_handle_ref
-#undef nua_handle_unref
+  SU_DEBUG_0(("nh_destructor(%p)\n", nh));
+}
 
 /** Make a new reference to handle.
  *
@@ -183,6 +180,7 @@
   return (nua_handle_t *)su_home_ref(nh->nh_home);
 }
 
+
 /** Destroy reference to handle. 
  *
  * The handles use reference counting for memory management. In addition to
@@ -303,34 +301,3 @@
   default: return "UNKNOWN";
   }
 }
-
-/** Return name of subscription state. @NEW_1_12_5. */
-char const *nua_substate_name(enum nua_substate substate)
-{
-  switch (substate) {
-  case nua_substate_embryonic:
-      /*FALLTHROUGH*/
-  case nua_substate_pending:
-    return "pending";
-  case nua_substate_terminated:
-    return "terminated";
-  case nua_substate_active:
-      /*FALLTHROUGH*/
-  default:
-    return "active";
-  }
-}
-
-/** Convert string to enum nua_substate. @NEW_1_12_5. */
-enum nua_substate nua_substate_make(char const *sip_substate)
-{
-  if (sip_substate == NULL)
-    return nua_substate_active;
-  else if (strcasecmp(sip_substate, "terminated") == 0)
-    return nua_substate_terminated;
-  else if (strcasecmp(sip_substate, "pending") == 0)
-    return nua_substate_pending;
-  else /* if (strcasecmp(sip_substate, "active") == 0) */ 
-    return nua_substate_active;
-}
-

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c	Sat Feb 17 01:25:21 2007
@@ -269,7 +269,7 @@
     du = *prev_du;
     if (du) {		/* Already exists */
       SU_DEBUG_5(("nua(%p): adding already existing %s usage%s%s\n",
-		  (void *)own, nua_dialog_usage_name(du), 
+		  own, nua_dialog_usage_name(du), 
 		  event ? "  with event " : "", event ? event->o_type : ""));
       
       if (prev_du != &ds->ds_usage) {
@@ -297,7 +297,7 @@
       }
 	
       SU_DEBUG_5(("nua(%p): adding %s usage%s%s\n",
-		  (void *)own, nua_dialog_usage_name(du), 
+		  own, nua_dialog_usage_name(du), 
 		  o ? " with event " : "", o ? o->o_type :""));
 
       su_home_ref(own);
@@ -345,24 +345,6 @@
     nua_client_request_t *cr, *cr_next;
     nua_server_request_t *sr, *sr_next;
 
-    *at = du->du_next;
-
-    o = du->du_event;
-
-    SU_DEBUG_5(("nua(%p): removing %s usage%s%s\n",
-		(void *)own, nua_dialog_usage_name(du), 
-		o ? " with event " : "", o ? o->o_type :""));
-    du->du_class->usage_remove(own, ds, du);
-
-    /* Destroy saved client request */
-    if (nua_client_is_bound(du->du_cr)) {
-      nua_client_bind(cr = du->du_cr, NULL);
-      if (!nua_client_is_queued(cr) &&
-	  !nua_client_is_reporting(cr))
-	nua_client_request_destroy(cr);
-    }
-
-    /* Clean references from queued client requests */
     for (cr = ds->ds_cr; cr; cr = cr_next) {
       cr_next = cr->cr_next;
       if (cr->cr_usage == du)
@@ -375,20 +357,29 @@
 	nua_server_request_destroy(sr);
     }
 
+    *at = du->du_next;
+
+    o = du->du_event;
+
+    SU_DEBUG_5(("nua(%p): removing %s usage%s%s\n",
+		own, nua_dialog_usage_name(du), 
+		o ? " with event " : "", o ? o->o_type :""));
+    du->du_class->usage_remove(own, ds, du);
+    msg_destroy(du->du_msg), du->du_msg = NULL;
     su_home_unref(own);
     su_free(own, du);
   }
 
-  /* Zap dialog if there are no more usages */
-  if (ds->ds_terminated)
-    ;
-  else if (ds->ds_usage == NULL) {
-    nua_dialog_remove(own, ds, NULL);
+  /* Zap dialog if there is no more usages */
+  if (ds->ds_usage == NULL) {
+    nta_leg_destroy(ds->ds_leg), ds->ds_leg = NULL;
+    su_free(own, (void *)ds->ds_remote_tag), ds->ds_remote_tag = NULL;
+    ds->ds_route = 0;
     ds->ds_has_events = 0;
     ds->ds_terminated = 0;
     return;
   }
-  else {
+  else if (!ds->ds_terminated) {
     nua_dialog_log_usage(own, ds);
   }
 }
@@ -421,7 +412,7 @@
       }
     }
     
-    SU_DEBUG_3(("nua(%p): handle with %s%s%s\n", (void *)own,
+    SU_DEBUG_3(("nua(%p): handle with %s%s%s\n", own,
 		ds->ds_has_session ? "session and " : "", 
 		ds->ds_has_events ? "events " : "",
 		buffer));
@@ -439,11 +430,12 @@
 
 
 /** @internal Dialog has been terminated. Remove all usages. */
-void nua_dialog_remove_usages(nua_owner_t *own,
-			      struct nua_dialog_state *ds,
-			      int status,
-			      char const *phrase)
+void nua_dialog_terminated(nua_owner_t *own,
+			   struct nua_dialog_state *ds,
+			   int status,
+			   char const *phrase)
 {
+
   ds->ds_terminated = 1;
 
   while (ds->ds_usage) {
@@ -457,8 +449,6 @@
 #endif
     nua_dialog_usage_remove_at(own, ds, &ds->ds_usage);
   }
-
-  nua_dialog_remove(own, ds, NULL);
 }
 
 /**@internal
@@ -534,8 +524,7 @@
 /**@internal Do not refresh. */
 void nua_dialog_usage_reset_refresh(nua_dialog_usage_t *du)
 {
-  if (du)
-    du->du_refresh = 0;
+  du->du_refresh = 0;
 }
 
 /** @internal Refresh usage or shutdown usage if @a now is 0. */
@@ -548,45 +537,18 @@
     du->du_refresh = 0;
 
     if (now > 0) {
-      assert(du->du_class->usage_refresh);
-      du->du_class->usage_refresh(owner, ds, du, now);
+      if (du->du_class->usage_refresh) {
+	du->du_class->usage_refresh(owner, ds, du, now);
+	return;
+      }
     }
     else {
       du->du_shutdown = 1;
-      assert(du->du_class->usage_shutdown);
-      du->du_class->usage_shutdown(owner, ds, du);
-    }
-  }
-}
-
-/** Terminate all dialog usages gracefully. */
-int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds)
-{
-  nua_dialog_usage_t *du;
-
-  ds->ds_terminated = 1;
-
-  do {
-    for (du = ds->ds_usage; du; du = du->du_next) {
-      if (!du->du_shutdown) {
-	nua_dialog_usage_shutdown(owner, ds, du);
-	break;
+      if (du->du_class->usage_shutdown) {
+	du->du_class->usage_shutdown(owner, ds, du);
+	return;
       }
     }
-  } while (du);
-
-  return 1;
-}
-
-/** (Gracefully) terminate usage */
-void nua_dialog_usage_shutdown(nua_owner_t *owner,
-			       nua_dialog_state_t *ds,
-			       nua_dialog_usage_t *du)
-{
-  if (du) {
-    du->du_refresh = 0;
-    du->du_shutdown = 1;
-    assert(du->du_class->usage_shutdown);
-    du->du_class->usage_shutdown(owner, ds, du);
   }
 }
+

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h	Sat Feb 17 01:25:21 2007
@@ -48,74 +48,36 @@
 #include <sofia-sip/nta.h>
 #endif
 
-typedef su_msg_r nua_saved_signal_t;
-
 typedef struct nua_server_request nua_server_request_t; 
 typedef struct nua_client_request nua_client_request_t; 
 
-typedef struct {
-  sip_method_t sm_method; 
-  char const *sm_method_name;
-
-  int sm_event;
-
-  struct {
-    unsigned create_dialog:1, in_dialog:1, target_refresh:1, add_contact:1;
-    unsigned :0;
-  } sm_flags;
-
-  /** Initialize server-side request. */
-  int (*sm_init)(nua_server_request_t *sr);
-
-  /** Preprocess server-side request (after handle has been created). */
-  int (*sm_preprocess)(nua_server_request_t *sr);
+/** Respond to an incoming request. */
+typedef int nua_server_respond_f(nua_server_request_t *, tagi_t const *);
 
-  /** Update server-side request parameters */
-  int (*sm_params)(nua_server_request_t *sr, tagi_t const *tags);
-
-  /** Respond to server-side request. */
-  int (*sm_respond)(nua_server_request_t *sr, tagi_t const *tags);
-
-  /** Report server-side request to application. */
-  int (*sm_report)(nua_server_request_t *sr, tagi_t const *tags);
-
-} nua_server_methods_t;
+/** Restart an outgoing request. */
+typedef void nua_creq_restart_f(nua_owner_t *, tagi_t *tags);
 
 /** Server side transaction */
 struct nua_server_request {
   struct nua_server_request *sr_next, **sr_prev;
 
-  nua_server_methods_t const *sr_methods;
-
   nua_owner_t *sr_owner;	/**< Backpointer to handle */
   nua_dialog_usage_t *sr_usage;	/**< Backpointer to usage */
 
-  nta_incoming_t *sr_irq;	/**< Server transaction object */
+  /** When the application responds to an request with
+   * nua_respond(), the sr_respond() is called
+   */
+  nua_server_respond_f *sr_respond;
   
-  struct {
-    msg_t *msg;			/**< Request message */
-    sip_t const *sip;		/**< Headers in request message */
-  } sr_request;
-
-  struct {
-    msg_t *msg;			/**< Response message */
-    sip_t *sip;			/**< Headers in response message */
-  } sr_response;
+  nta_incoming_t *sr_irq;	/**< Server transaction object */
+  msg_t *sr_msg;		/**< Request message */
 
   sip_method_t sr_method;	/**< Request method */
-
-  int sr_application;		/**< Status by application */
-
   int sr_status;		/**< Status code */
   char const *sr_phrase;	/**< Status phrase */
 
-  unsigned sr_event:1;		/**< Reported to application */
+  unsigned sr_auto:1;		/**< Autoresponse - no event has been sent */
   unsigned sr_initial:1;	/**< Handle was created by this request */
-  unsigned sr_add_contact:1;	/**< Add Contact header to the response */
-  unsigned sr_terminating:1;	/**< Terminate usage after final response */
-  unsigned sr_gracefully:1;	/**< Terminate usage gracefully */
-
-  unsigned sr_neutral:1;	/**< No effect on session or other usage */
 
   /* Flags used with offer-answer */
   unsigned sr_offer_recv:1;	/**< We have received an offer */
@@ -123,12 +85,13 @@
 
   unsigned sr_offer_sent:1;	/**< We have offered SDP */
   unsigned sr_answer_recv:1;	/**< We have received SDP answer */
-  unsigned :0;
-
-  char const *sr_sdp;		/**< SDP received from client */
-  size_t sr_sdp_len;		/**< ... and its length  */
 };
 
+#define SR_INIT(sr)			     \
+  ((void)memset((sr), 0, sizeof (sr)[0]),    \
+   (void)(SR_STATUS1((sr), SIP_100_TRYING)), \
+   sr)
+
 #define SR_STATUS(sr, status, phrase) \
   ((sr)->sr_phrase = (phrase), (sr)->sr_status = (status))
 
@@ -141,180 +104,37 @@
   return (void)(sr->sr_phrase = phrase), (sr->sr_status = status);
 }
 
-/** Methods for client request */
-typedef struct {
-  sip_method_t crm_method;
-  char const *crm_method_name;
-  size_t crm_extra;		/**< Size of private data */
-
-  struct {
-    unsigned create_dialog:1, in_dialog:1, target_refresh:1;
-    unsigned:0;
-  } crm_flags;
-
-  /** Generate a request message.
-   *
-   * @retval 1 when request message has been created
-   * @retval 0 when request message should be created in normal fashion
-   * @retval -1 upon an error
-   */
-  int (*crm_template)(nua_client_request_t *cr,
-		      msg_t **return_msg,
-		      tagi_t const *tags);
-
-  /**@a crm_init is called when a client request is sent first time. 
-   *
-   * @retval 1 when request has been responded
-   * @retval 0 when request should be sent in normal fashion
-   * @retval -1 upon an error
-   */
-  int (*crm_init)(nua_client_request_t *, msg_t *msg, sip_t *sip,
-		  tagi_t const *tags);
-
-  /** @a crm_send is called each time when a client request is sent.
-   *
-   * @retval 1 when request has been responded
-   * @retval 0 when request has been sent
-   * @retval -1 upon an error (request message has not been destroyed)
-   * @retval -2 upon an error (request message has been destroyed)
-   */
-  int (*crm_send)(nua_client_request_t *,
-		  msg_t *msg, sip_t *sip,
-		  tagi_t const *tags);
-
-  /** @a crm_check_restart is called each time when a response is received.
-   *
-   * It is used to restart reqquest after responses with method-specific
-   * status code or method-specific way of restarting the request.
-   *
-   * @retval 1 when request has been restarted
-   * @retval 0 when response should be processed normally
-   */
-  int (*crm_check_restart)(nua_client_request_t *,
-			   int status, char const *phrase,
-			   sip_t const *sip);
-
-  /** @a crm_recv is called each time a final response is received.
-   *
-   * A final response is in range 200 .. 699 (or internal response) and it
-   * cannot be restarted.
-   *
-   * crm_recv() should call nua_base_client_response() or
-   * nua_base_client_tresponse(). The return values below are documented with
-   * nua_base_client_response(), too.
-   *
-   * @retval 0 if response was preliminary
-   * @retval 1 if response was final
-   * @retval 2 if response destroyed the handle, too.
-   */
-  int (*crm_recv)(nua_client_request_t *,
-		  int status, char const *phrase,
-		  sip_t const *sip);
-
-  /** @a crm_preliminary is called each time a preliminary response is received.
-   *
-   * A preliminary response is in range 101 .. 199.
-   *
-   * crm_preliminary() should call nua_base_client_response() or
-   * nua_base_client_tresponse().
-   *
-   * @retval 0 if response was preliminary
-   * @retval 1 if response was final
-   * @retval 2 if response destroyed the handle, too.
-   */
-  int (*crm_preliminary)(nua_client_request_t *,
-			 int status, char const *phrase,
-			 sip_t const *sip);
-
-  /** @a crm_report is called each time a response is received and it is
-   * reported to the application.
-   *
-   * The status and phrase may be different from the status and phrase
-   * received from the network, e.g., when the request is restarted.
-   *
-   * @return The return value should be 0. It is currently ignored.
-   */
-  int (*crm_report)(nua_client_request_t *,
-		    int status, char const *phrase,
-		    sip_t const *sip,
-		    nta_outgoing_t *orq,
-		    tagi_t const *tags);
-
-  /** @a crm_deinit is called when a client-side request is destroyed.
-   *
-   * @return The return value should be 0. It is currently ignored.
-   */
-  int (*crm_deinit)(nua_client_request_t *);
-
-} nua_client_methods_t;
-
-/* Client-side request. Documented by nua_client_create() */
 struct nua_client_request
 {
-  nua_client_request_t *cr_next, **cr_prev; /**< Linked list of requests */
-  nua_owner_t        *cr_owner;
-  nua_dialog_usage_t *cr_usage;
-
-  nua_saved_signal_t cr_signal;
-  tagi_t const      *cr_tags;
-
-  nua_client_methods_t const *cr_methods;
-
-  msg_t              *cr_msg;
-  sip_t              *cr_sip;
-
-  nta_outgoing_t     *cr_orq;
-
+  nua_client_request_t *cr_next;        /**< Linked list of requests */
   /*nua_event_t*/ int cr_event;		/**< Request event */
-  sip_method_t        cr_method;
-  char const         *cr_method_name;
-
-  url_t              *cr_target;
-
-  uint32_t            cr_seq;
-
-  unsigned short      cr_status;        /**< Latest status */
-
+  nua_creq_restart_f *cr_restart;
+  nta_outgoing_t     *cr_orq;
+  msg_t              *cr_msg;
+  nua_dialog_usage_t *cr_usage;
   unsigned short      cr_retry_count;   /**< Retry count for this request */
 
   /* Flags used with offer-answer */
   unsigned short      cr_answer_recv;   /**< Recv answer in response 
 					 *  with this status.
 					 */
-  unsigned cr_offer_sent:1;	/**< Sent offer in this request */
-
-  unsigned cr_offer_recv:1;	/**< Recv offer in a response */
-  unsigned cr_answer_sent:1;	/**< Sent answer in (PR)ACK */
+  unsigned            cr_offer_sent:1;  /**< Sent offer in this request */
 
-  /* Flags with usage */
-  unsigned cr_neutral:1;	/**< No effect on session or other usage */
+  unsigned            cr_offer_recv:1;  /**< Recv offer in a response */
+  unsigned            cr_answer_sent:1; /**< Sent answer in (PR)ACK */
 
-  /* Lifelong flags? */
-  unsigned cr_auto:1;		/**< Request was generated by stack */
-  unsigned cr_has_contact:1;	/**< Request has user Contact */
-  unsigned cr_contactize:1;	/**< Request needs Contact */
-
-  /* Current state */
-  unsigned cr_challenged:1;	/**< Request was challenged, pending auth */
-  unsigned cr_restarting:1;	/**< Request is being restarted */
-  unsigned cr_reporting:1;	/**< Reporting in progress */
-  unsigned cr_terminating:1;	/**< Request terminates the usage */
-  signed int cr_terminated:2;	/**< Response terminated usage (1) or 
-				    whole dialog (-1) */
-  unsigned cr_graceful:1;	/**< Graceful termination required */
+  unsigned            cr_has_contact:1; /**< Request has application contact */
 };
 
 
 struct nua_dialog_state
 {
+  nua_client_request_t ds_cr[1];
+  nua_server_request_t *ds_sr;
+
   /** Dialog usages. */
   nua_dialog_usage_t     *ds_usage;
 
-  /** Client requests */
-  nua_client_request_t   *ds_cr;
-  /** Server requests */
-  nua_server_request_t *ds_sr;
-
   /* Dialog and subscription state */
   unsigned ds_route:1;		/**< We have route */
   unsigned ds_terminated:1;	/**< Being terminated */
@@ -323,8 +143,7 @@
   unsigned ds_has_register:1;	/**< We have registration */
   unsigned ds_has_publish:1;	/**< We have publish */
 
-  unsigned ds_got_session:1;	/**< We have (or have had) session */
-  unsigned ds_got_referrals:1;	/**< We have (or have had) referrals */
+  unsigned ds_has_referrals:1;	/**< We have (or have had) referrals */
 
   unsigned :0;
 
@@ -377,8 +196,8 @@
 struct nua_dialog_usage {
   nua_dialog_usage_t *du_next;
   nua_usage_class const *du_class;
-  nua_client_request_t *du_cr;	        /**< Client request bound with usage */
 
+  unsigned     du_terminating:1;	/**< Now trying to terminate usage */
   unsigned     du_ready:1;	        /**< Established usage */
   unsigned     du_shutdown:1;	        /**< Shutdown in progress */
   unsigned:0;
@@ -393,6 +212,7 @@
 
   sip_event_t const *du_event;		/**< Event of usage */
 
+  msg_t *du_msg;			/**< Template message */
 };
 
 void nua_dialog_uac_route(nua_owner_t *, nua_dialog_state_t *ds,
@@ -423,12 +243,10 @@
 void nua_dialog_deinit(nua_owner_t *own,
 		       nua_dialog_state_t *ds);
 
-int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds);
-
-void nua_dialog_remove_usages(nua_owner_t *,
-			      struct nua_dialog_state *ds,
-			      int status,
-			      char const *phrase);
+void nua_dialog_terminated(nua_owner_t *,
+			   struct nua_dialog_state *ds,
+			   int status,
+			   char const *phrase);
 
 void nua_dialog_usage_set_expires(nua_dialog_usage_t *du, unsigned delta);
 
@@ -444,10 +262,6 @@
 			      nua_dialog_usage_t *du, 
 			      sip_time_t now);
 
-void nua_dialog_usage_shutdown(nua_owner_t *owner,
-				nua_dialog_state_t *ds,
-				nua_dialog_usage_t *du);
-
 static inline
 int nua_dialog_is_established(nua_dialog_state_t const *ds)
 {
@@ -473,171 +287,18 @@
 
 /* ---------------------------------------------------------------------- */
 
-int nua_client_create(nua_owner_t *owner,
-		      int event,
-		      nua_client_methods_t const *methods,
-		      tagi_t const *tags);
-
-int nua_client_tcreate(nua_owner_t *nh, 
-		       int event,
-		       nua_client_methods_t const *methods,
-		       tag_type_t tag, tag_value_t value, ...);
-
-static inline 
-void *nua_private_client_request(nua_client_request_t const *cr)
-{
-  return (void *)(cr + 1);
-}
-
-void nua_client_request_destroy(nua_client_request_t *);
-
-int nua_client_request_queue(nua_client_request_t *cr);
-
-static inline int nua_client_is_queued(nua_client_request_t const *cr)
-{
-  return cr && cr->cr_prev;
-}
-
-nua_client_request_t *nua_client_request_remove(nua_client_request_t *cr);
-
-int nua_client_bind(nua_client_request_t *cr, nua_dialog_usage_t *du);
-
-static inline int nua_client_is_bound(nua_client_request_t const *cr)
-{
-  return cr && cr->cr_usage && cr->cr_usage->du_cr == cr;
-}
-
-static inline int nua_client_is_reporting(nua_client_request_t const *cr)
-{
-  return cr && cr->cr_reporting;
-}
-
-/** Mark client request as a terminating one */
-static inline void nua_client_terminating(nua_client_request_t *cr)
-{
-  cr->cr_terminating = 1;
-}
-
-int nua_client_init_request(nua_client_request_t *cr);
-
-int nua_client_resend_request(nua_client_request_t *cr,
-			      int terminating,
-			      tagi_t const *tags);
-
-int nua_base_client_request(nua_client_request_t *cr,
-			    msg_t *msg,
-			    sip_t *sip,
-			    tagi_t const *tags);
-
-int nua_base_client_trequest(nua_client_request_t *cr,
-			     msg_t *msg,
-			     sip_t *sip,
-			     tag_type_t tag, tag_value_t value, ...);
-
-extern nta_response_f nua_client_orq_response;
-
-int nua_client_return(nua_client_request_t *cr,
-		      int status,
-		      char const *phrase,
-		      msg_t *to_be_destroyed);
-
-int nua_client_response(nua_client_request_t *cr,
-			int status,
-			char const *phrase,
-			sip_t const *sip);
-
-int nua_client_check_restart(nua_client_request_t *cr,
-			     int status,
-			     char const *phrase,
-			     sip_t const *sip);
-
-int nua_base_client_check_restart(nua_client_request_t *cr,
-				  int status,
-				  char const *phrase,
-				  sip_t const *sip);
-
-int nua_client_restart(nua_client_request_t *cr,
-		       int status, char const *phrase);
-
-int nua_base_client_response(nua_client_request_t *cr,
-			     int status, char const *phrase,
-			     sip_t const *sip,
-			     tagi_t const *tags);
-
-int nua_base_client_tresponse(nua_client_request_t *cr,
-			      int status, char const *phrase,
-			      sip_t const *sip,
-			      tag_type_t tag, tag_value_t value, ...);
-
-int nua_client_set_target(nua_client_request_t *cr, url_t const *target);
-
-int nua_client_report(nua_client_request_t *cr,
-		      int status, char const *phrase,
-		      sip_t const *sip,
-		      nta_outgoing_t *orq,
-		      tagi_t const *tags);
-
-nua_client_request_t *nua_client_request_pending(nua_client_request_t const *);
-
-int nua_client_init_requests(nua_client_request_t *cr,
-			     void const *cr0,
-			     int invite);
-
-/* ---------------------------------------------------------------------- */
-
-extern nua_server_methods_t const
-  nua_extension_server_methods,
-  nua_invite_server_methods,	/**< INVITE */
-  nua_bye_server_methods,	/**< BYE */
-  nua_options_server_methods,	/**< OPTIONS */
-  nua_register_server_methods,	/**< REGISTER */
-  nua_info_server_methods,	/**< INFO */
-  nua_prack_server_methods,	/**< PRACK */
-  nua_update_server_methods,	/**< UPDATE */
-  nua_message_server_methods,	/**< MESSAGE */
-  nua_subscribe_server_methods, /**< SUBSCRIBE */
-  nua_notify_server_methods,	/**< NOTIFY */
-  nua_refer_server_methods,	/**< REFER */
-  nua_publish_server_methods;	/**< PUBLISH */
-
-/** Return true if we have not sent final response to request */ 
-static inline 
-int nua_server_request_is_pending(nua_server_request_t const *sr)
-{
-  return sr && sr->sr_response.msg;
-}
-
 void nua_server_request_destroy(nua_server_request_t *sr);
 
-int nua_base_server_init(nua_server_request_t *sr);
-
-#define nua_base_server_init NULL
-
-int nua_base_server_preprocess(nua_server_request_t *sr);
-
-#define nua_base_server_preprocess NULL
-
-int nua_server_params(nua_server_request_t *sr, tagi_t const *tags);
-
-int nua_base_server_params(nua_server_request_t *sr, tagi_t const *tags);
-
-#define nua_base_server_params NULL
-
-int nua_server_trespond(nua_server_request_t *sr,
-			tag_type_t tag, tag_value_t value, ...);
-int nua_server_respond(nua_server_request_t *sr, tagi_t const *tags);
-
-int nua_base_server_trespond(nua_server_request_t *sr,
-			     tag_type_t tag, tag_value_t value, ...);
-int nua_base_server_respond(nua_server_request_t *sr,
-			    tagi_t const *tags);
+int nua_server_respond(nua_server_request_t *sr,
+		       int status, char const *phrase,
+		       tag_type_t tag, tag_value_t value, ...);
 
-int nua_server_report(nua_server_request_t *sr);
+msg_t *nua_server_response(nua_server_request_t *sr,
+			   int status, char const *phrase,
+			   tag_type_t tag, tag_value_t value, ...);
 
-int nua_base_server_treport(nua_server_request_t *sr, 
-			    tag_type_t tag, tag_value_t value, ...);
-int nua_base_server_report(nua_server_request_t *sr, tagi_t const *tags);
+int nua_default_respond(nua_server_request_t *sr,
+			tagi_t const *tags);
 
-/* ---------------------------------------------------------------------- */
 
 #endif /* NUA_DIALOG_H */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c	Sat Feb 17 01:25:21 2007
@@ -45,6 +45,9 @@
 #include <sofia-sip/sip_status.h>
 #include <sofia-sip/su_tagarg.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+
 #define NEA_SMAGIC_T         struct nua_handle_s
 #define NEA_EMAGIC_T         struct nua_handle_s
 
@@ -118,13 +121,13 @@
     status = 900, phrase = "Error when notifying watchers";
 
   else 
-    nua_stack_tevent(nua, nh, NULL, e, status = SIP_200_OK, 
-		     SIPTAG_EVENT(event),
-		     SIPTAG_CONTENT_TYPE(ct),
-		     TAG_END());
+    nua_stack_event(nua, nh, NULL, e, status = SIP_200_OK, 
+		    SIPTAG_EVENT(event),
+		    SIPTAG_CONTENT_TYPE(ct),
+		    TAG_END());
 	     
   if (status != 200)
-    nua_stack_event(nua, nh, NULL, e, status, phrase, NULL);
+    nua_stack_event(nua, nh, NULL, e, status, phrase, TAG_END());
 
   su_home_deinit(home);
 }
@@ -220,7 +223,7 @@
       what = "active";
     }
 
-    SU_DEBUG_7(("nua(%p): authorize_watcher: %s\n", (void *)nh, what)); 
+    SU_DEBUG_7(("nua(%p): authorize_watcher: %s\n", nh, what)); 
     nea_sub_auth(sn->sn_subscriber, substate,
 		 TAG_IF(substate == nua_substate_pending,
 			NEATAG_FAKE(1)),
@@ -232,13 +235,13 @@
     substate = nua_substate_terminated;
     nea_server_flush(nes, NULL);
     SU_DEBUG_7(("nua(%p): authorize_watcher: %s\n", 
-		(void *)nh, "watcher is removed")); 
+		nh, "watcher is removed")); 
   }
 
-  nua_stack_tevent(nua, nh, msg, nua_i_subscription, status, phrase,
-		   NUTAG_SUBSTATE(substate),
-		   NEATAG_SUB(sn->sn_subscriber),
-		   TAG_END());
+  nua_stack_event(nua, nh, msg, nua_i_subscription, status, phrase,
+	   NUTAG_SUBSTATE(substate),
+	   NEATAG_SUB(sn->sn_subscriber),
+	   TAG_END());
 }
 
 /* ---------------------------------------------------------------------- */
@@ -259,11 +262,12 @@
 
   if (sub && state > 0) {
     nea_sub_auth(sub, state, TAG_NEXT(tags));
-    nua_stack_event(nua, nh, NULL, e, SIP_200_OK, NULL);
+    nua_stack_event(nua, nh, NULL, e, SIP_200_OK, TAG_END());
   }
   else {
-    nua_stack_event(nua, nh, NULL, e, NUA_INTERNAL_ERROR, NULL);
+    nua_stack_event(nua, nh, NULL, e, NUA_INTERNAL_ERROR, TAG_END());
   }
+  return;
 }
 
 /** @internal Shutdown notifier object */
@@ -343,5 +347,5 @@
 		       NEATAG_REASON("noresource"), 
 		       TAG_NEXT(tags));
 
-  nua_stack_event(nua, nh, NULL, e, SIP_200_OK, NULL);
+  nua_stack_event(nua, nh, NULL, e, SIP_200_OK, TAG_END());
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c	Sat Feb 17 01:25:21 2007
@@ -43,8 +43,17 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+
 #include "nua_stack.h"
 
+static int process_response_to_method(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip);
+static void restart_method(nua_handle_t *nh, tagi_t *tags);
+static int respond_to_method(nua_server_request_t *sr, tagi_t const *tags);
+
 /** Send an extension request. 
  *
  * Send an entension request message.
@@ -69,25 +78,32 @@
  * @since New in @VERSION_1_12_4.
  */
 
-static nua_client_methods_t const nua_method_client_methods = {
-  SIP_METHOD_UNKNOWN,
-  0,
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 0,
-    /* target_refresh */ 0
-  },
-  /* nua_method_client_template */ NULL,
-  /* nua_method_client_init */ NULL,
-  /* nua_method_client_request */ NULL,
-  /* nua_method_client_check_restart */ NULL,
-  /* nua_method_client_response */ NULL
-};
-
 int 
 nua_stack_method(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
 { 
-  return nua_client_create(nh, e, &nua_method_client_methods, tags);
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg;
+
+  if (cr->cr_orq)
+    return UA_EVENT2(e, 900, "Request already in progress");
+
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
+		     SIP_METHOD_UNKNOWN,
+		     TAG_NEXT(tags));
+  if (msg)
+    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				      process_response_to_method, nh, NULL,
+				      msg,
+				      SIPTAG_END(),
+				      TAG_NEXT(tags));
+  if (!cr->cr_orq) {
+    msg_destroy(msg);
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  }
+
+  return cr->cr_event = e;
 }
 
 /** @NUA_EVENT nua_r_method
@@ -111,6 +127,20 @@
  * @END_NUA_EVENT
  */
 
+static int process_response_to_method(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip)
+{
+  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_method))
+    return 0;
+  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
+}
+
+void restart_method(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_method, tags);
+}
+
 /** @NUA_EVENT nua_i_method
  *
  * @brief Incoming extension request.
@@ -135,19 +165,40 @@
  * @END_NUA_EVENT
  */
 
-nua_server_methods_t const nua_extension_server_methods = 
-  {
-    SIP_METHOD_UNKNOWN,
-    nua_i_method,		/* Event */
-    { 
-      0,			/* Do not create dialog */
-      0,			/* Can be an initial request */
-      1,			/* Perhaps a target refresh request? */
-      1,			/* Add a contact? */
-    },
-    nua_base_server_init,
-    nua_base_server_preprocess,
-    nua_base_server_params,
-    nua_base_server_respond,
-    nua_base_server_report,
-  };
+int nua_stack_process_method(nua_t *nua,
+			      nua_handle_t *nh,
+			      nta_incoming_t *irq,
+			      sip_t const *sip)
+{
+  nua_server_request_t *sr, sr0[1];
+  
+  sr = SR_INIT(sr0);
+  
+  sr = nua_server_request(nua, nh, irq, sip, sr, sizeof *sr,
+			  respond_to_method, 0);
+
+  return nua_stack_server_event(nua, sr, nua_i_method, TAG_END());
+}
+
+static
+int respond_to_method(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_t *nua = nh->nh_nua;
+  msg_t *msg;
+
+  msg = nua_server_response(sr, sr->sr_status, sr->sr_phrase, TAG_NEXT(tags));
+
+  if (msg) {
+    nta_incoming_mreply(sr->sr_irq, msg);
+  }
+  else {
+    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
+    nua_stack_event(nua, nh, NULL,
+		    nua_i_error, 900, "Response to Extension Method Fails",
+		    TAG_END());
+  }
+  
+  return sr->sr_status >= 200 ? sr->sr_status : 0;
+}

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c	Sat Feb 17 01:25:21 2007
@@ -43,6 +43,9 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+
 #include "nua_stack.h"
 
 /* ======================================================================== */
@@ -69,41 +72,48 @@
  * @sa #nua_i_message, @RFC3428
  */
 
-static int nua_message_client_init(nua_client_request_t *cr, 
-				   msg_t *, sip_t *,
-				   tagi_t const *tags);
-
-static nua_client_methods_t const nua_message_client_methods = {
-  SIP_METHOD_MESSAGE,
-  0,
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 0,
-    /* target refresh */ 0
-  },
-  /* nua_message_client_template */ NULL,
-  nua_message_client_init,
-  /*nua_message_client_request*/ NULL,
-  /* nua_message_client_check_restart */ NULL,
-  /*nua_message_client_response*/ NULL
-};
+static int process_response_to_message(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip);
 
 int 
-nua_stack_message(nua_t *nua,
-		  nua_handle_t *nh,
-		  nua_event_t e,
-		  tagi_t const *tags)
+nua_stack_message(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
 { 
-  return nua_client_create(nh, e, &nua_message_client_methods, tags);
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg;
+  sip_t *sip;
+
+  if (nh_is_special(nh)) {
+    return UA_EVENT2(e, 900, "Invalid handle for MESSAGE");
+  }
+  else if (cr->cr_orq) {
+    return UA_EVENT2(e, 900, "Request already in progress");
+  }
+
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
+			 SIP_METHOD_MESSAGE,
+			 NUTAG_ADD_CONTACT(NH_PGET(nh, win_messenger_enable)),
+			 TAG_NEXT(tags));
+  sip = sip_object(msg);
+
+  if (sip)
+    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				      process_response_to_message, nh, NULL,
+				      msg,
+				      SIPTAG_END(), TAG_NEXT(tags));
+  if (!cr->cr_orq) {
+    msg_destroy(msg);
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  }
+
+  return cr->cr_event = e;
 }
 
-static int nua_message_client_init(nua_client_request_t *cr, 
-				   msg_t *msg, sip_t *sip,
-				   tagi_t const *tags)
+void restart_message(nua_handle_t *nh, tagi_t *tags)
 {
-  if (NH_PGET(cr->cr_owner, win_messenger_enable))
-    cr->cr_contactize = 1;
-  return 0;
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_message, tags);
 }
 
 /** @NUA_EVENT nua_r_message
@@ -127,6 +137,15 @@
  * @END_NUA_EVENT
  */
 
+static int process_response_to_message(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip)
+{
+  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_message))
+    return 0;
+  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
+}
+
 /** @NUA_EVENT nua_i_message
  *
  * @brief Incoming @b MESSAGE request.
@@ -149,39 +168,32 @@
  * @END_NUA_EVENT
  */
 
-int nua_message_server_init(nua_server_request_t *sr);
-int nua_message_server_params(nua_server_request_t *, tagi_t const *);
+int nua_stack_process_message(nua_t *nua,
+			      nua_handle_t *nh,
+			      nta_incoming_t *irq,
+			      sip_t const *sip)
+{
+  msg_t *msg;
 
-nua_server_methods_t const nua_message_server_methods = 
-  {
-    SIP_METHOD_MESSAGE,
-    nua_i_message,		/* Event */
-    { 
-      0,			/* Do not create dialog */
-      0,			/* Can be initial request */
-      0,			/* Perhaps a target refresh request? */
-      0,			/* Do not add contact by default */
-    },
-    nua_message_server_init,
-    nua_base_server_preprocess,
-    nua_message_server_params,
-    nua_base_server_respond,
-    nua_base_server_report,
-  };
+  if (nh
+      ? !NH_PGET(nh, message_enable)
+      : !DNH_PGET(nua->nua_dhandle, message_enable))
+    return 403;
 
-int nua_message_server_init(nua_server_request_t *sr)
-{
-  if (!NH_PGET(sr->sr_owner, message_enable))
-    return SR_STATUS1(sr, SIP_403_FORBIDDEN);
+  if (nh == NULL)
+    if (!(nh = nua_stack_incoming_handle(nua, irq, sip, 0)))
+      return 500;		/* respond with 500 Internal Server Error */
 
-  return 0;
-}
+  msg = nta_incoming_getrequest(irq);
 
-int nua_message_server_params(nua_server_request_t *sr,
-			      tagi_t const *tags)
-{
-  if (NH_PGET(sr->sr_owner, win_messenger_enable))
-    sr->sr_add_contact = 1;
+  nua_stack_event(nh->nh_nua, nh, msg, nua_i_message, SIP_200_OK, TAG_END());
+
+#if 0 /* XXX */
+  if (nh->nh_nua->nua_messageRespond) {	
+    nh->nh_irq = irq;
+    return 0;
+  }
+#endif
 
-  return 0;
+  return 200;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c	Sat Feb 17 01:25:21 2007
@@ -44,12 +44,12 @@
 
 #include <sofia-sip/string0.h>
 #include <sofia-sip/sip_protos.h>
-#include <sofia-sip/sip_extra.h>
 #include <sofia-sip/sip_status.h>
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/su_uniqueid.h>
-#include <sofia-sip/su_md5.h>
-#include <sofia-sip/token64.h>
+
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
 
 #include "nua_stack.h"
 
@@ -59,14 +59,7 @@
 struct notifier_usage
 {
   enum nua_substate  nu_substate;	/**< Subscription state */
-  sip_time_t         nu_expires; 	/**< Expiration time */
-  sip_time_t         nu_requested;      /**< Requested expiration time */
-#if SU_HAVE_EXPERIMENTAL
-  char              *nu_tag;	        /**< @ETag in last NOTIFY */
-  unsigned           nu_etags:1;	/**< Subscriber supports etags */
-  unsigned           nu_appl_etags:1;   /**< Application generates etags */
-  unsigned           nu_no_body:1;      /**< Suppress body */
-#endif
+  sip_time_t         nu_expires;
 };
 
 static char const *nua_notify_usage_name(nua_dialog_usage_t const *du);
@@ -122,6 +115,8 @@
 /* ====================================================================== */
 /* SUBSCRIBE server */
 
+static int respond_to_subscribe(nua_server_request_t *sr, tagi_t const *tags);
+
 /** @NUA_EVENT nua_i_subscribe
  *
  * Incoming @b SUBSCRIBE request.
@@ -165,185 +160,152 @@
  * @END_NUA_EVENT
  */
 
-static int nua_subscribe_server_init(nua_server_request_t *sr);
-static int nua_subscribe_server_preprocess(nua_server_request_t *sr);
-static int nua_subscribe_server_respond(nua_server_request_t*, tagi_t const *);
-static int nua_subscribe_server_report(nua_server_request_t*, tagi_t const *);
-
-nua_server_methods_t const nua_subscribe_server_methods = 
-  {
-    SIP_METHOD_SUBSCRIBE,
-    nua_i_subscribe,		/* Event */
-    { 
-      1,			/* Create dialog */
-      0,			/* Initial request */
-      1,			/* Target refresh request  */
-      1,			/* Add Contact */
-    },
-    nua_subscribe_server_init,
-    nua_subscribe_server_preprocess,
-    nua_base_server_params,
-    nua_subscribe_server_respond,
-    nua_subscribe_server_report,
-  };
 
-int nua_subscribe_server_init(nua_server_request_t *sr)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  sip_allow_events_t const *allow_events = NH_PGET(nh, allow_events);
-  sip_t const *sip = sr->sr_request.sip;
+/** @internal Process incoming SUBSCRIBE. */
+int nua_stack_process_subscribe(nua_t *nua,
+				nua_handle_t *nh,
+				nta_incoming_t *irq,
+				sip_t const *sip)
+{
+  nua_server_request_t *sr, sr0[1];
+  nua_dialog_state_t *ds;
+  nua_dialog_usage_t *du = NULL;
   sip_event_t *o = sip->sip_event;
   char const *event = o ? o->o_type : NULL;
   
-  if (sr->sr_initial || !nua_dialog_usage_get(ds, nua_notify_usage, o)) {
-    if (event && str0cmp(event, "refer") == 0)
-      /* refer event subscription should be initiated with REFER */
-      return SR_STATUS1(sr, SIP_403_FORBIDDEN);
+  enum nua_substate substate = nua_substate_terminated;
 
-    /* XXX - event is case-sensitive, should use msg_header_find_item() */
-    if (!event || !msg_header_find_param(allow_events->k_common, event))
-      return SR_STATUS1(sr, SIP_489_BAD_EVENT);
-  }
+  enter;
 
-  return 0;
-}
+  if (nh)
+    du = nua_dialog_usage_get(ds = nh->nh_ds, nua_notify_usage, o);
 
-int nua_subscribe_server_preprocess(nua_server_request_t *sr)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_dialog_usage_t *du;
-  struct notifier_usage *nu;
-  sip_t const *sip = sr->sr_request.sip;
-  sip_event_t *o = sip->sip_event;
-  char const *event = o ? o->o_type : NULL;
-  /* Maximum expiration time */
-  unsigned long expires = 3600;
-
-  assert(nh && nh->nh_nua->nua_dhandle != nh);
+  sr = SR_INIT(sr0);
   
-  du = nua_dialog_usage_get(ds, nua_notify_usage, o);
+  if (nh == NULL || du == NULL) {
+    sip_allow_events_t *allow_events = NUA_PGET(nua, nh, allow_events);
 
-  if (du == NULL) {
-    /* Create a new subscription */
-    du = nua_dialog_usage_add(nh, ds, nua_notify_usage, o);
-    if (du == NULL)
-      return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    if (event && str0cmp(event, "refer") == 0)
+      /* refer event subscription should be initiated with REFER */
+      SR_STATUS1(sr, SIP_403_FORBIDDEN);
+    else if (!event || !msg_header_find_param(allow_events->k_common, event))
+      SR_STATUS1(sr, SIP_489_BAD_EVENT);
+    else
+      substate = nua_substate_embryonic;
   }
   else {
     /* Refresh existing subscription */
-    if (str0cmp(event, "refer") == 0)
-      expires = NH_PGET(nh, refer_expires);
+    struct notifier_usage *nu = nua_dialog_usage_private(du);
+    unsigned long expires;
 
-    SR_STATUS1(sr, SIP_200_OK);
-  }
+    assert(nh && du && nu);
 
-  nu = nua_dialog_usage_private(du);
+    expires = str0cmp(event, "refer") ? 3600 : NH_PGET(nh, refer_expires);
 
-  if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
-    expires = sip->sip_expires->ex_delta;
-  nu->nu_requested = sip_now() + expires;
-
-#if SU_HAVE_EXPERIMENTAL
-  nu->nu_etags = 
-    sip_suppress_body_if_match(sip) ||
-    sip_suppress_notify_if_match(sip) ||
-    sip_has_feature(sr->sr_request.sip->sip_supported, "etags");
-#endif
-
-  sr->sr_usage = du;
+    if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
+      expires = sip->sip_expires->ex_delta;
 
-  return sr->sr_status <= 100 ? 0 : sr->sr_status;
-}
-
-/** @internal Respond to a SUBSCRIBE request.
- *
- */
-static
-int nua_subscribe_server_respond(nua_server_request_t *sr, tagi_t const *tags)
-{
-  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
+    if (expires == 0)
+      nu->nu_substate = nua_substate_terminated;
 
-  msg_t *msg = sr->sr_response.msg;
-  sip_t *sip = sr->sr_response.sip;
+    nu->nu_expires = sip_now() + expires;
+    substate = nu->nu_substate;
 
-  if (200 <= sr->sr_status && sr->sr_status < 300) {
-    sip_expires_t ex[1]; 
+    /* XXX - send notify */
 
-    sip_expires_init(ex);
+    SR_STATUS1(sr, SIP_200_OK);
+  }
 
-    if (nu) {
-      sip_time_t now = sip_now();
+  sr = nua_server_request(nua, nh, irq, sip, sr, sizeof *sr,
+			  respond_to_subscribe, 1);
 
-      if (nu->nu_requested) {
-	if (nu->nu_requested > nu->nu_expires)
-	  nu->nu_expires = nu->nu_requested;
-	else if (nu->nu_expires <= now || nu->nu_requested <= now)
-	  nu->nu_substate = nua_substate_terminated;
-      }
+  if (!du && substate == nua_substate_embryonic && sr->sr_status < 300) {
+    nh = sr->sr_owner; assert(nh && nh != nua->nua_dhandle);
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, sip->sip_event);
+    if (du) {
+      struct notifier_usage *nu = nua_dialog_usage_private(du);
+      unsigned long expires = 3600; /* XXX */
+      
+      if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
+	expires = sip->sip_expires->ex_delta;
 
-      if (nu->nu_expires > now)
-	ex->ex_delta = nu->nu_expires - now;
-    }
-    else {
-      /* Add header Expires: 0 */
+      nu->nu_expires = sip_now() + expires;
+      nu->nu_substate = substate;
     }
-
-    if (!sip->sip_expires || sip->sip_expires->ex_delta > ex->ex_delta)
-      sip_add_dup(msg, sip, (sip_header_t *)ex);
+    else 
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
   }
 
-  return nua_base_server_respond(sr, tags);
+  if (substate == nua_substate_embryonic && sr->sr_status >= 300)
+    substate = nua_substate_terminated;
+
+  sr->sr_usage = du;
+
+  return nua_stack_server_event(nua, sr, nua_i_subscribe,
+				NUTAG_SUBSTATE(substate), TAG_END());
 }
 
+/** @internal Respond to an SUBSCRIBE request.
+ *
+ */
 static
-int nua_subscribe_server_report(nua_server_request_t *sr, tagi_t const *tags)
+int respond_to_subscribe(nua_server_request_t *sr, tagi_t const *tags)
 {
   nua_handle_t *nh = sr->sr_owner;
   nua_dialog_state_t *ds = nh->nh_ds;
-  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
-  enum nua_substate substate = nua_substate_terminated;
-  int notify = 0;
-  int retval;
-
-  if (nu && !sr->sr_terminating) {
-    substate = nu->nu_substate;
-  }
+  nua_t *nua = nh->nh_nua;
+  struct notifier_usage *nu;
+  sip_allow_events_t *allow_events = NUA_PGET(nua, nh, allow_events);
+  sip_expires_t ex[1]; 
+  sip_time_t now = sip_now();
+  msg_t *msg;
 
-  /* nu_requested is set by SUBSCRIBE and cleared when NOTIFY is sent */
-  if (nu && nu->nu_requested && substate != nua_substate_embryonic) {
-#if SU_HAVE_EXPERIMENTAL
-    sip_t const *sip = sr->sr_request.sip;
-    sip_suppress_notify_if_match_t *snim = sip_suppress_notify_if_match(sip);
-    sip_suppress_body_if_match_t *sbim = sip_suppress_body_if_match(sip);
-    
-    if (!nu->nu_tag)
-      notify = 1;
-    else if (snim && !strcasecmp(snim->snim_tag, nu->nu_tag))
-      notify = 0;
-    else if (sbim && !strcasecmp(snim->snim_tag, nu->nu_tag))
-      notify = 1, nu->nu_no_body = 1;
-    else 
-#endif
-      notify = 1;
-  }
+  sip_expires_init(ex);
 
-  retval = nua_base_server_treport(sr, NUTAG_SUBSTATE(substate), TAG_END());
+  nu = nua_dialog_usage_private(sr->sr_usage);
+  if (nu && nu->nu_expires > now)
+    ex->ex_delta = nu->nu_expires - now;
 
-  if (retval >= 2 || nu == NULL)
-    return retval;
-  
-  if (notify) {
-    /* Send NOTIFY (and terminate subscription, when needed) */
-    nua_dialog_usage_refresh(nh, ds, sr->sr_usage, sip_now());
+  msg = nua_server_response(sr,
+			    sr->sr_status, sr->sr_phrase,
+			    NUTAG_ADD_CONTACT(sr->sr_status < 300),
+			    TAG_IF(nu, SIPTAG_EXPIRES(ex)),
+			    SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
+			    SIPTAG_ALLOW_EVENTS(allow_events),
+			    TAG_NEXT(tags));
+
+  if (msg) {
+    sip_t *sip = sip_object(msg);
+
+    if (nu && sip->sip_expires && sr->sr_status < 300)
+      nu->nu_expires = now + sip->sip_expires->ex_delta;
+
+    nta_incoming_mreply(sr->sr_irq, msg);
+
+    if (nu && nu->nu_substate != nua_substate_embryonic)
+      /* Send NOTIFY (and terminate subscription, when needed) */
+      nua_dialog_usage_refresh(nh, ds, sr->sr_usage, sip_now());
+  }
+  else {
+    /* XXX - send nua_i_error */
+    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
   }
   
-  return retval;
+  return sr->sr_status >= 200 ? sr->sr_status : 0;
 }
 
 /* ======================================================================== */
-/* NOTIFY client */
+/* NOTIFY */
+
+static int process_response_to_notify(nua_handle_t *nh,
+				      nta_outgoing_t *orq,
+				      sip_t const *sip);
+
+static int nua_stack_notify2(nua_t *, nua_handle_t *, nua_event_t, 
+			     nua_dialog_usage_t *du,
+			     tagi_t const *tags);
+
 
 /**@fn void nua_notify(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
@@ -374,271 +336,175 @@
  * @sa @RFC3265, #nua_i_subscribe, #nua_i_refer, NUTAG_ALLOW_EVENTS()
  */
 
-static int nua_notify_client_init(nua_client_request_t *cr, 
-				  msg_t *, sip_t *,
-				  tagi_t const *tags);
-static int nua_notify_client_init_etag(nua_client_request_t *cr,
-				       msg_t *msg, sip_t *sip,
-				       tagi_t const *tags);
-static int nua_notify_client_request(nua_client_request_t *cr,
-				     msg_t *, sip_t *,
-				     tagi_t const *tags);
-static int nua_notify_client_report(nua_client_request_t *cr,
-				    int status, char const *phrase,
-				    sip_t const *sip,
-				    nta_outgoing_t *orq,
-				    tagi_t const *tags);
-
-static nua_client_methods_t const nua_notify_client_methods = {
-  SIP_METHOD_NOTIFY,
-  0,
-  { 
-    /* create_dialog */ 1,
-    /* in_dialog */ 1,
-    /* target refresh */ 1
-  },
-  /* nua_notify_client_template */ NULL,
-  nua_notify_client_init,
-  nua_notify_client_request,
-  /* nua_notify_client_check_restart */ NULL,
-  /* nua_notify_client_response */ NULL,
-  /* nua_notify_client_preliminary */ NULL,
-  nua_notify_client_report
-};
-
 /**@internal Send NOTIFY. */
 int nua_stack_notify(nua_t *nua,
 		     nua_handle_t *nh,
 		     nua_event_t e,
 		     tagi_t const *tags)
 {
-  return nua_client_create(nh, e, &nua_notify_client_methods, tags);
+  return nua_stack_notify2(nua, nh, e, NULL, tags);
 }
 
-static int nua_notify_client_init(nua_client_request_t *cr,
-				  msg_t *msg, sip_t *sip,
-				  tagi_t const *tags)
+
+int nua_stack_notify2(nua_t *nua,
+		      nua_handle_t *nh,
+		      nua_event_t e,
+		      nua_dialog_usage_t *du,
+		      tagi_t const *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
   struct notifier_usage *nu;
-  sip_event_t const *o = sip->sip_event;
-  sip_subscription_state_t *ss = sip->sip_subscription_state;
-  sip_time_t now = sip_now();
-    
-  if (o == NULL && nh->nh_ds->ds_has_notifys == 1)
+  msg_t *msg;
+  sip_t *sip;
+  sip_event_t const *o;
+  sip_time_t now;
+  int refresh = du != NULL;
+
+  if (cr->cr_orq) {
+    return UA_EVENT2(e, 900, "Request already in progress");
+  }
+
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  if (refresh) {
+    assert(!cr->cr_msg);
+    if (cr->cr_msg)
+      msg_destroy(cr->cr_msg);
+    cr->cr_msg = msg_copy(du->du_msg);
+  }
+
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count || refresh,
+		     SIP_METHOD_NOTIFY,
+		     NUTAG_ADD_CONTACT(1),
+		     TAG_NEXT(tags));
+  sip = sip_object(msg);
+  if (!sip)
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+
+  if (nh->nh_ds->ds_has_notifys == 1 && !sip->sip_event)
     o = NONE;
+  else
+    o = sip->sip_event;
 
   du = nua_dialog_usage_get(nh->nh_ds, nua_notify_usage, o);
+  nu = nua_dialog_usage_private(du);
 
-  if (!du) {
-    tagi_t const *newsub = tl_find_last(tags, nutag_newsub);
-
-    if (!newsub || !newsub->t_value)
-      return 0; /* Rejected eventually by nua_notify_client_request() */
+  if (du && du->du_event && !sip->sip_event)
+    sip_add_dup(msg, sip, (sip_header_t *)du->du_event);
 
-    /* Create new notifier */
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, o);
-    if (du == NULL)
-      return -1;
+  now = sip_now();
 
-    nu = nua_dialog_usage_private(du);
-    nu->nu_expires = now;
-  }
-  else
-    nu = nua_dialog_usage_private(du);
+  if (!du)
+    ;
+  else if (sip->sip_subscription_state) {
+    /* SIPTAG_SUBSCRIPTION_STATE() overrides NUTAG_SUBSTATE() */
+    char const *ss_substate = sip->sip_subscription_state->ss_substate;
 
+    if (strcasecmp(ss_substate, "terminated") == 0)
+      nu->nu_substate = nua_substate_terminated;
+    else if (strcasecmp(ss_substate, "pending") == 0)
+      nu->nu_substate = nua_substate_pending;
+    else /* if (strcasecmp(subs->ss_substate, "active") == 0) */ 
+      nu->nu_substate = nua_substate_active;
 
-  if (nu->nu_substate == nua_substate_terminated) {
-    /*Xyzzy*/;
-  }
-  else if (ss != NULL) {
-    /* SIPTAG_SUBSCRIPTION_STATE() overrides NUTAG_SUBSTATE() */
-    nu->nu_substate = nua_substate_make(ss->ss_substate);
+    if (sip->sip_subscription_state->ss_expires) {
+      unsigned long expires;
+      expires = strtoul(sip->sip_subscription_state->ss_expires, NULL, 10);
+      if (expires > 3600)
+        expires = 3600;
+      nu->nu_expires = now + expires;
+    }
+    else if (nu->nu_substate != nua_substate_terminated) {
+      sip_subscription_state_t *ss = sip->sip_subscription_state;
+      char *param;
+
+      if (now < nu->nu_expires)
+        param = su_sprintf(msg_home(msg), "expires=%lu", nu->nu_expires - now);
+      else
+        param = "expires=0";
 
-    if (ss->ss_expires) {
-      unsigned long expires = strtoul(ss->ss_expires, NULL, 10);
-      if (now + expires < now)
-	expires = SIP_TIME_MAX - now - 1;
-
-      /* Notifier can only shorten the subscription time */ 
-      if (nu->nu_requested == 0 || nu->nu_requested >= now + expires)
-	nu->nu_expires = nu->nu_requested = now + expires;
+      msg_header_add_param(msg_home(msg), ss->ss_common, param);
     }
   }
   else {
-    enum nua_substate substate = nu->nu_substate;
+    sip_subscription_state_t *ss;
+    enum nua_substate substate;
+    char const *name;
+
+    substate = nu->nu_substate;
 
-    if (nu->nu_expires > now) {
+    if (nu->nu_expires <= now)
+      substate = nua_substate_terminated;
+
+    if (substate != nua_substate_terminated) {
       tagi_t const *t = tl_find_last(tags, nutag_substate);
       if (t)
-        substate = (enum nua_substate)t->t_value;
+	substate = (enum nua_substate)t->t_value;
     }
-    else
-      substate = nua_substate_terminated;
 
     switch (substate) {
     case nua_substate_embryonic:
       /*FALLTHROUGH*/
     case nua_substate_pending:
+      name = "pending";
       nu->nu_substate = nua_substate_pending;
       break;
     case nua_substate_active:
     default:
+      name = "active";
       nu->nu_substate = nua_substate_active;
       break;
     case nua_substate_terminated:
+      name = "terminated";
       nu->nu_substate = nua_substate_terminated;
       break;
     }
-  }
-
-  if (nu->nu_substate == nua_substate_terminated)
-    cr->cr_terminating = 1;
-
-  cr->cr_usage = du;
-
-  return nua_notify_client_init_etag(cr, msg, sip, tags);
-}
-
-static int nua_notify_client_init_etag(nua_client_request_t *cr,
-				       msg_t *msg, sip_t *sip,
-				       tagi_t const *tags)
-{
-#if SU_HAVE_EXPERIMENTAL
-  nua_handle_t *nh = cr->cr_owner;
-  struct notifier_usage *nu = nua_dialog_usage_private(cr->cr_usage);
-  nua_server_request_t *sr;
-
-  if (nu->nu_tag)
-    su_free(nh->nh_home, nu->nu_tag), nu->nu_tag = NULL;
-    nu->nu_no_body = 0;
-
-  if (sip->sip_etag) {
-    nu->nu_appl_etags = 1;
-    nu->nu_tag = su_strdup(nh->nh_home, sip->sip_etag->g_string);
-  }
-  else if (!nu->nu_appl_etags && nu->nu_etags) {
-    su_md5_t md5[1];
-    unsigned char digest[SU_MD5_DIGEST_SIZE];
-    sip_payload_t pl[1] = { SIP_PAYLOAD_INIT() };
-    char token[2 * 16];
-
-    su_md5_init(md5);
 
-    if (sip->sip_payload) *pl = *sip->sip_payload;
-
-    if (pl->pl_len)
-      su_md5_update(md5, pl->pl_data, pl->pl_len);
-    su_md5_update(md5, &pl->pl_len, sizeof(pl->pl_len));
-
-    if (sip->sip_content_type)
-      su_md5_striupdate(md5, sip->sip_content_type->c_type);
-
-    su_md5_digest(md5, digest);
-    token64_e(token, sizeof token, digest, sizeof digest);
-    token[(sizeof token) - 1] = '\0';
-    nu->nu_tag = su_strdup(nh->nh_home, token);
-  }
-
-  if (!nu->nu_requested || !nu->nu_tag)
-    return 0;
-
-  /* Check if SUBSCRIBE had matching suppression */
-  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
-    if (sr->sr_usage == cr->cr_usage && sr->sr_method == sip_method_subscribe)
-      break;
-
-  if (sr) {
-    sip_t const *sip = sr->sr_request.sip;
-
-    sip_suppress_body_if_match_t *sbim;
-    sip_suppress_notify_if_match_t *snim;
-    
-    if (cr->cr_usage->du_ready) {
-      snim = sip_suppress_notify_if_match(sip);
-
-      if (snim && !strcasecmp(snim->snim_tag, nu->nu_tag)) {
-	if (nu->nu_requested > nu->nu_expires)
-	  nu->nu_expires = nu->nu_requested;
-	nu->nu_requested = 0;
-	return nua_client_return(cr, 202, "NOTIFY Suppressed", msg);
-      }
+    if (nu->nu_substate != nua_substate_terminated) {
+      unsigned long expires = nu->nu_expires - now;
+      ss = sip_subscription_state_format(msg_home(msg), "%s;expires=%lu",
+					 name, expires);
+    }
+    else {
+      ss = sip_subscription_state_make(msg_home(msg), "terminated; "
+				       "reason=noresource");
     }
 
-    sbim = sip_suppress_body_if_match(sip);
-    if (sbim && !strcasecmp(sbim->sbim_tag, nu->nu_tag))
-      nu->nu_no_body = 1;
-  }
-#endif
-
-  return 0;
-}
-
-static
-int nua_notify_client_request(nua_client_request_t *cr,
-			      msg_t *msg, sip_t *sip,
-			      tagi_t const *tags)
-{
-  nua_dialog_usage_t *du = cr->cr_usage; 
-  struct notifier_usage *nu = nua_dialog_usage_private(du);
-  su_home_t *home = msg_home(msg);
-  sip_time_t now = sip_now();
-  sip_subscription_state_t *ss = sip->sip_subscription_state;
-  char const *expires;
-
-  if (du == NULL)		/* Subscription has been terminated */
-    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
-
-  assert(du && nu);
-
-  if (du && nua_client_bind(cr, du) < 0)
-    return -1;
-
-  if (nu->nu_requested)
-    nu->nu_expires = nu->nu_requested;
-  nu->nu_requested = 0;
-
-  if (nu->nu_expires <= now || du->du_shutdown) {
-    nu->nu_substate = nua_substate_terminated;
-    expires = "expires=0";
-  }
-  else {
-    expires = su_sprintf(home, "expires=%lu", nu->nu_expires - now);
+    msg_header_insert(msg, (void *)sip, (void *)ss);
   }
 
-  if (ss == NULL || nua_substate_make(ss->ss_substate) != nu->nu_substate) {
+  if (du) {
     if (nu->nu_substate == nua_substate_terminated)
-      expires = nu->nu_expires > now ? "noresource" : "timeout";
+      du->du_terminating = 1;
 
-    ss = sip_subscription_state_format(home, "%s;%s", 
-				       nua_substate_name(nu->nu_substate),
-				       expires);
-
-    msg_header_insert(msg, (void *)sip, (void *)ss);
-  }
-  else if (nu->nu_substate != nua_substate_terminated) {
-    msg_header_replace_param(home, ss->ss_common, expires);
+    if (!du->du_terminating && !refresh) {
+      /* Save template */
+      if (du->du_msg)
+        msg_destroy(du->du_msg);
+      du->du_msg = msg_ref_create(cr->cr_msg);
+    }
   }
 
-#if SU_HAVE_EXPERIMENTAL
-  if (nu->nu_tag && !sip->sip_etag)
-    msg_header_add_make(msg, (void *)sip, sip_etag_class, nu->nu_tag);
-
-  if (nu->nu_no_body) {
-    nu->nu_no_body = 0;
-    msg_header_remove(msg, (void *)sip, (void *)sip->sip_payload);
-    msg_header_remove(msg, (void *)sip, (void *)sip->sip_content_length);
+  /* NOTIFY outside a dialog */
+  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				    process_response_to_notify, nh, NULL,
+				    msg,
+				    SIPTAG_END(), TAG_NEXT(tags));
+
+  if (!cr->cr_orq) {
+    msg_destroy(msg);
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
   }
-#endif
 
-  if (nu->nu_substate == nua_substate_terminated)
-    cr->cr_terminating = 1;
+  cr->cr_usage = du;
 
-  if (du->du_event && !sip->sip_event)
-    sip_add_dup(cr->cr_msg, sip, (sip_header_t *)du->du_event);
+  return cr->cr_event = e;
+}
 
-  return nua_base_client_request(cr, msg, sip, tags);
+static
+void restart_notify(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_notify, tags);
 }
 
 /** @NUA_EVENT nua_r_notify
@@ -661,36 +527,30 @@
  *               (status code is in @a status and 
  *               descriptive message in @a phrase parameters)
  * @param tags   NUTAG_SUBSTATE() indicating subscription state
- *               SIPTAG_EVENT() indicating subscription event
  *
  * @sa nua_notify(), @RFC3265, #nua_i_subscribe, #nua_i_refer
  *
  * @END_NUA_EVENT
  */
 
-static int nua_notify_client_report(nua_client_request_t *cr,
-				    int status, char const *phrase,
-				    sip_t const *sip,
-				    nta_outgoing_t *orq,
-				    tagi_t const *tags)
+static int process_response_to_notify(nua_handle_t *nh,
+				      nta_outgoing_t *orq,
+				      sip_t const *sip)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  struct notifier_usage *nu = nua_dialog_usage_private(du);
   enum nua_substate substate = nua_substate_terminated;
 
-  if (nu && !cr->cr_terminated)
-    substate = nu->nu_substate;
+  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_notify))
+    return 0;
 
-  nua_stack_tevent(nh->nh_nua, nh, 
-		   nta_outgoing_getresponse(orq),
-		   cr->cr_event,
-		   status, phrase,
-		   NUTAG_SUBSTATE(substate),
-		   SIPTAG_EVENT(du ? du->du_event : NULL),
-		   TAG_NEXT(tags));
+  if (nh->nh_ds->ds_cr->cr_usage) {
+    struct notifier_usage *nu = nua_dialog_usage_private(nh->nh_ds->ds_cr->cr_usage);
+    substate = nu->nu_substate;
+    assert(substate != nua_substate_embryonic);
+  }
 
-  return 0;
+  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, 
+				    NUTAG_SUBSTATE(substate),
+				    TAG_END());
 }
 
 
@@ -699,30 +559,30 @@
 				     nua_dialog_usage_t *du,
 				     sip_time_t now)
 {
-  nua_client_request_t *cr = du->du_cr;
-  nua_event_t e = nua_r_notify;
-
-  if (cr) {
-    int terminating;
+  struct notifier_usage *nu = nua_dialog_usage_private(du);
 
-    if (nua_client_is_queued(cr)) /* Already notifying. */
-      return;
+  if (nh->nh_ds->ds_cr->cr_usage == du) /* Already notifying. */
+    return;
 
-    terminating = du->du_expires && du->du_expires <= now;
+  if (now >= nu->nu_expires) {
+    sip_subscription_state_t ss[1];
+    char const *params[] = { NULL, NULL };
+    tagi_t tags[2] = {
+      { SIPTAG_SUBSCRIPTION_STATE(ss) }, { TAG_END() }
+    };
+
+    sip_subscription_state_init(ss);
+
+    ss->ss_substate = "terminated";
+    ss->ss_params = params;
+    params[0] = "reason=timeout";
+    ss->ss_reason = "timeout";
 
-    if (nua_client_resend_request(cr, terminating, NULL) >= 0)
-      return;
+    nua_stack_notify2(nh->nh_nua, nh, nua_r_notify, du, tags);
   }
   else {
-    if (nua_client_create(nh, e, &nua_notify_client_methods, NULL) >= 0)
-      return;
+    nua_stack_notify2(nh->nh_nua, nh, nua_r_notify, du, NULL);
   }
-
-  nua_stack_tevent(nh->nh_nua, nh, NULL, e, NUA_INTERNAL_ERROR,
-		   NUTAG_SUBSTATE(nua_substate_terminated),
-		   TAG_END());
-
-  nua_dialog_usage_remove(nh, ds, du);
 }
 
 /** @interal Shut down NOTIFY usage. 
@@ -735,113 +595,26 @@
 				     nua_dialog_state_t *ds,
 				     nua_dialog_usage_t *du)
 {
-  struct notifier_usage *nu = nua_dialog_usage_private(du);
-  nua_client_request_t *cr = du->du_cr;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
 
-  if (nua_client_is_queued(cr)) /* Already notifying. */
-    return -1;  /* Request in progress */
-
-  nu->nu_substate = nua_substate_terminated;
-
-  if (cr) {
-    if (nua_client_resend_request(cr, 1, NULL) >= 0)
-      return 0;
-  }
-  else {
-    if (nua_client_create(nh, nua_r_notify, 
-			  &nua_notify_client_methods, NULL) >= 0)
-      return 0;
+  if (!cr->cr_usage) {
+    /* Unnotify */
+	/* Commenting this line out to supress an attended transfer bug (awaiting fix from pessi) */
+    //nua_stack_notify2(nh->nh_nua, nh, nua_r_destroy, du, NULL);
+    return cr->cr_usage != du;
   }
 
-  nua_dialog_usage_remove(nh, ds, du);
-  return 200;
+  if (!du->du_ready && !cr->cr_orq)
+    return 1;			/* Unauthenticated NOTIFY? */
+
+  return -1;  /* Request in progress */
 }
 
+
 /* ======================================================================== */
 /* REFER */
 /* RFC 3515 */
 
-static int nua_refer_server_init(nua_server_request_t *sr);
-static int nua_refer_server_preprocess(nua_server_request_t *sr);
-static int nua_refer_server_respond(nua_server_request_t*, tagi_t const *);
-static int nua_refer_server_report(nua_server_request_t*, tagi_t const *);
-
-nua_server_methods_t const nua_refer_server_methods = 
-  {
-    SIP_METHOD_REFER,
-    nua_i_refer,		/* Event */
-    { 
-      1,			/* Create dialog */
-      0,			/* Initial request */
-      1,			/* Target refresh request  */
-      1,			/* Add Contact */
-    },
-    nua_refer_server_init,
-    nua_refer_server_preprocess,
-    nua_base_server_params,
-    nua_refer_server_respond,
-    nua_refer_server_report,
-  };
-
-static int nua_refer_server_init(nua_server_request_t *sr)
-{
-  return 0;
-}
-
-static int nua_refer_server_preprocess(nua_server_request_t *sr)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  sip_t const *sip = sr->sr_request.sip;
-  struct notifier_usage *nu;
-  sip_event_t *o;
-
-  if (nh->nh_ds->ds_got_referrals || NH_PGET(nh, refer_with_id))
-    o = sip_event_format(nh->nh_home, "refer;id=%u", sip->sip_cseq->cs_seq);
-  else
-    o = sip_event_make(nh->nh_home, "refer");
-
-  if (o) {
-    sr->sr_usage = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, o);
-    msg_header_free(nh->nh_home, (msg_header_t *)o);
-  }
-
-  if (!sr->sr_usage)
-    return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-
-  nu = nua_dialog_usage_private(sr->sr_usage);
-  nu->nu_requested = sip_now() + NH_PGET(nh, refer_expires);
-
-  return 0;
-}
-
-static
-int nua_refer_server_respond(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
-  sip_refer_sub_t const *rs = sip_refer_sub(sr->sr_response.sip);
-
-  if (sr->sr_status < 200 || nu == NULL) {
-  }
-  else if (sr->sr_status < 300 && 
-	   /* Application included Refer-Sub: false in response */
-	   (rs == NULL || str0casecmp("false", rs->rs_value))) {
-    sr->sr_usage->du_ready = 1;
-
-    nu->nu_expires = sip_now() + NH_PGET(nh, refer_expires);
-
-    if (sr->sr_application)	/* Application responded to REFER */
-      nu->nu_substate = nua_substate_active;
-  }
-  else {
-    /* Destroy the implicit subscription usage */
-    sr->sr_terminating = 1;
-  }
-
-  return nua_base_server_respond(sr, tags);
-}
-
-
 /** @NUA_EVENT nua_i_refer
  *
  * Incoming @b REFER request used to transfer calls.
@@ -862,45 +635,89 @@
  * @END_NUA_EVENT
  */
 
-static
-int nua_refer_server_report(nua_server_request_t *sr, tagi_t const *tags)
+/** @internal Process incoming REFER. */
+int nua_stack_process_refer(nua_t *nua,
+			    nua_handle_t *nh,
+			    nta_incoming_t *irq,
+			    sip_t const *sip)
 {
-  nua_handle_t *nh = sr->sr_owner;
-  struct notifier_usage *nu = nua_dialog_usage_private(sr->sr_usage);
-  sip_t const *sip = sr->sr_request.sip;
-  sip_referred_by_t *by = sip->sip_referred_by, default_by[1];
-  sip_event_t const *o = sr->sr_usage->du_event;
-  enum nua_substate substate = nua_substate_terminated;
-  int initial = sr->sr_initial, retval;
+  nua_dialog_usage_t *du = NULL;
+  struct notifier_usage *nu;
+  sip_event_t *event;
+  sip_referred_by_t *by = NULL, default_by[1];
+  msg_t *response;
+  sip_time_t expires;
+  int created = 0;
+
+  if (nh == NULL) {
+    if (!(nh = nua_stack_incoming_handle(nua, irq, sip, 1)))
+      return 500;
+    created = 1;
+  }
+
+  if (nh->nh_ds->ds_has_referrals || NH_PGET(nh, refer_with_id))
+    event = sip_event_format(nh->nh_home, "refer;id=%u", sip->sip_cseq->cs_seq);
+  else
+    event = sip_event_make(nh->nh_home, "refer");
+
+  if (event)
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_notify_usage, event);
 
-  if (nu) {
-    if (!sr->sr_terminating)
-      substate = nu->nu_substate;
+  if (!du || du->du_ready) {
+    if (du->du_ready) {
+      SU_DEBUG_1(("nua(%p): REFER with existing refer;id=%u\n", nh,
+		  sip->sip_cseq->cs_seq));
+    }
+    if (created) 
+      nh_destroy(nua, nh);
+    return 500;
   }
 
-  if (by == NULL) {
-     by = sip_referred_by_init(default_by);
+  nu = nua_dialog_usage_private(du);
+  du->du_ready = 1;
+  nh->nh_ds->ds_has_referrals = 1;
+
+  nua_dialog_uas_route(nh, nh->nh_ds, sip, 1);	/* Set route and tags */
+
+  if (!sip->sip_referred_by) {
+    sip_from_t *a = sip->sip_from;
+
+    sip_referred_by_init(by = default_by);
 
-    by->b_display = sip->sip_from->a_display;
-    *by->b_url = *sip->sip_from->a_url;
+    *by->b_url = *a->a_url;
+    by->b_display = a->a_display;
   }
 
-  retval = nua_base_server_treport(sr,
-				   NUTAG_SUBSTATE(substate),
-				   NUTAG_REFER_EVENT(o),
-				   TAG_IF(by, SIPTAG_REFERRED_BY(by)),
-				   TAG_END());
+  response = nh_make_response(nua, nh, irq, 
+			      SIP_202_ACCEPTED, 
+			      NUTAG_ADD_CONTACT(1),
+			      TAG_END());
 
-  if (retval >= 2 || nu == NULL)
-    return retval;
+  nta_incoming_mreply(irq, response);
 
-  if (initial)
+  expires = NH_PGET(nh, refer_expires);
+
+  if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
+    expires = sip->sip_expires->ex_delta;
+  nu->nu_substate = nua_substate_pending;
+  nu->nu_expires = sip_now() + expires;
+
+  /* Immediate notify in order to establish the dialog */
+  if (!sip->sip_to->a_tag)
     nua_stack_post_signal(nh,
 			  nua_r_notify,
-			  SIPTAG_EVENT(o),
+			  SIPTAG_EVENT(event),
 			  SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 			  SIPTAG_PAYLOAD_STR("SIP/2.0 100 Trying\r\n"),
 			  TAG_END());
+  
+  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
+		  nua_i_refer, SIP_202_ACCEPTED, 
+		  NUTAG_REFER_EVENT(event),
+		  TAG_IF(by, SIPTAG_REFERRED_BY(by)),
+		  TAG_END());
+  
+  su_free(nh->nh_home, event);
 
-  return retval;
+  return 500;   
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c	Sat Feb 17 01:25:21 2007
@@ -45,6 +45,9 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+
 #include "nua_stack.h"
 
 /**@fn void nua_options(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
@@ -66,6 +69,46 @@
  * @sa #nua_i_options, @RFC3261 section 10
  */
 
+static int process_response_to_options(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip);
+
+int
+nua_stack_options(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
+{
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg;
+
+  if (nh_is_special(nh)) {
+    return UA_EVENT2(e, 900, "Invalid handle for OPTIONS");
+  }
+  else if (cr->cr_orq) {
+    return UA_EVENT2(e, 900, "Request already in progress");
+  }
+
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
+			 SIP_METHOD_OPTIONS, 
+			 TAG_NEXT(tags));
+
+  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				    process_response_to_options, nh, NULL,
+				    msg,
+				    SIPTAG_END(), TAG_NEXT(tags));
+  if (!cr->cr_orq) {
+    msg_destroy(msg);
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  }
+
+  return cr->cr_event = e;
+}
+
+void restart_options(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_options, tags);
+}
+
 /** @NUA_EVENT nua_r_options
  *
  * Answer to outgoing OPTIONS.
@@ -87,25 +130,11 @@
  * @END_NUA_EVENT
  */
 
-static nua_client_methods_t const nua_options_client_methods = {
-  SIP_METHOD_OPTIONS,
-  0,
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 0,
-    /* target refresh */ 0
-  },
-  /*nua_options_client_template*/ NULL,
-  /*nua_options_client_init*/ NULL,
-  /*nua_options_client_request*/ NULL,
-  /* nua_options_client_check_restart */ NULL,
-  /*nua_options_client_response*/ NULL
-};
-
-int nua_stack_options(nua_t *nua,
-		      nua_handle_t *nh,
-		      nua_event_t e,
-		      tagi_t const *tags)
-{ 
-  return nua_client_create(nh, e, &nua_options_client_methods, tags);
+static int process_response_to_options(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip)
+{
+  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_options))
+    return 0;
+  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c	Sat Feb 17 01:25:21 2007
@@ -762,6 +762,12 @@
     else if (tag == nutag_enablemessenger) {
       NHP_SET(nhp, win_messenger_enable, value != 0);
     }
+#if 0
+    /* NUTAG_AUTORESPOND(autorespond) */
+    else if (tag == nutag_autorespond) {
+      NHP_SET(nhp, autorespond, value);
+    }
+#endif
     /* NUTAG_CALLEE_CAPS(callee_caps) */
     else if (tag == nutag_callee_caps) {
       NHP_SET(nhp, callee_caps, value != 0);
@@ -876,8 +882,7 @@
 			     sip_allow_class,
 			     &appl_method,
 			     (msg_list_t const *)nhp->nhp_appl_method,
-			     /* already set by tags? */
-			     NHP_ISSET(nhp, appl_method), 
+			     NHP_ISSET(nhp, allow), /* already set by tags */
 			     0, /* dup it, don't make */
 			     1, /* merge with old value */
 			     t->t_value);
@@ -1166,10 +1171,10 @@
 
   nh->nh_tags = 
     tl_filtered_tlist(nh->nh_home, tagfilter,
-		      TAG_IF(p_from != SIP_NONE, SIPTAG_FROM(p_from)),
-		      TAG_IF(p_from != SIP_NONE, TAG_FILTER(nua_handle_tags_filter)),
-		      TAG_IF(p_to != SIP_NONE, SIPTAG_TO(p_to)),
-		      TAG_IF(p_to != SIP_NONE, TAG_FILTER(nua_handle_tags_filter)),
+		      SIPTAG_FROM(p_from),
+		      TAG_FILTER(nua_handle_tags_filter),
+		      SIPTAG_TO(p_to),
+		      TAG_FILTER(nua_handle_tags_filter),
 		      TAG_NEXT(tags));
 
   nh->nh_ptags = 
@@ -1361,8 +1366,7 @@
  *               application contact associated with the operation handle 
  *               when responding to nua_get_hparams()
  * @param sip    NULL
- * @param tags
- *   NUTAG_APPL_METHOD() \n
+ * @param tags   
  *   NUTAG_AUTOACK() \n
  *   NUTAG_AUTOALERT() \n
  *   NUTAG_AUTOANSWER() \n
@@ -1555,7 +1559,6 @@
      TIF_STR(SIPTAG_SUPPORTED_STR, supported),
      TIF(SIPTAG_ALLOW, allow),
      TIF_STR(SIPTAG_ALLOW_STR, allow),
-     TIF_STR(NUTAG_APPL_METHOD, appl_method),
      TIF(SIPTAG_ALLOW_EVENTS, allow_events),
      TIF_STR(SIPTAG_ALLOW_EVENTS_STR, allow_events),
      TIF_SIP(SIPTAG_USER_AGENT, user_agent),
@@ -1604,7 +1607,7 @@
 
      TAG_NEXT(media_params));
 
-  nua_stack_event(nua, nh, NULL, nua_r_get_params, SIP_200_OK, lst);
+  nua_stack_event(nua, nh, NULL, nua_r_get_params, SIP_200_OK, TAG_NEXT(lst));
 
   su_home_deinit(tmphome);
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c	Sat Feb 17 01:25:21 2007
@@ -45,6 +45,9 @@
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+
 #include "nua_stack.h"
 
 /* ====================================================================== */
@@ -52,7 +55,6 @@
 
 struct publish_usage {
   sip_etag_t *pu_etag;
-  int pu_published;
 };
 
 static char const *nua_publish_usage_name(nua_dialog_usage_t const *du);
@@ -114,6 +116,14 @@
 /* ======================================================================== */
 /* PUBLISH */
 
+static int nua_stack_publish2(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+			      int refresh, tagi_t const *tags);
+
+static int process_response_to_publish(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip);
+
+
 /**@fn \
  * void nua_publish(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
@@ -227,217 +237,213 @@
  * @END_NUA_EVENT
  */
 
-static int nua_publish_client_template(nua_client_request_t *cr,
-				       msg_t **return_msg,
-				       tagi_t const *tags);
-static int nua_publish_client_init(nua_client_request_t *cr,
-				   msg_t *, sip_t *,
-				   tagi_t const *tags);
-static int nua_publish_client_request(nua_client_request_t *cr,
-				      msg_t *, sip_t *,
-				      tagi_t const *tags);
-static int nua_publish_client_response(nua_client_request_t *cr,
-				       int status, char const *phrase,
-				       sip_t const *sip);
-
-static nua_client_methods_t const nua_publish_client_methods = {
-  SIP_METHOD_PUBLISH,
-  0,
-  {
-    /* create_dialog */ 0,
-    /* in_dialog */ 0,
-    /* target refresh */ 0
-  },
-  nua_publish_client_template,
-  nua_publish_client_init,
-  nua_publish_client_request,
-  /* nua_publish_client_check_restart */ NULL,
-  nua_publish_client_response,
-  /* nua_publish_client_preliminary */ NULL
-};
-
-/**@internal Send PUBLISH. */
-int nua_stack_publish(nua_t *nua,
-		     nua_handle_t *nh,
-		     nua_event_t e,
-		     tagi_t const *tags)
-{
-  return nua_client_create(nh, e, &nua_publish_client_methods, tags);
+int nua_stack_publish(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		      tagi_t const *tags)
+{
+  return nua_stack_publish2(nua, nh, e, 0, tags);
 }
 
-static int nua_publish_client_template(nua_client_request_t *cr,
-				       msg_t **return_msg,
-				       tagi_t const *tags)
+static
+int nua_stack_publish2(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		       int refresh,
+		       tagi_t const *tags)
 {
   nua_dialog_usage_t *du;
+  struct publish_usage *pu;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg = NULL;
+  sip_t *sip;
+  int remove_body = 0;
 
-  if (cr->cr_event == nua_r_publish)
-    return 0;
+  if (nua_stack_set_handle_special(nh, nh_has_nothing, nua_r_publish) < 0)
+    return UA_EVENT2(e, 900, "Invalid handle for PUBLISH");
 
-  du = nua_dialog_usage_get(cr->cr_owner->nh_ds, nua_publish_usage, NULL);
-  if (du && du->du_cr) {
-    if (nua_client_set_target(cr, du->du_cr->cr_target) < 0)
-      return -1;
-    *return_msg = msg_copy(du->du_cr->cr_msg);
-    return 1;
+  if (cr->cr_orq) {
+    return UA_EVENT2(e, 900, "Request already in progress");
   }
 
-  return 0;
-}
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
 
-static int nua_publish_client_init(nua_client_request_t *cr,
-				   msg_t *msg, sip_t *sip,
-				   tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du;
-  struct publish_usage *pu;
-
-  if (cr->cr_event == nua_r_publish) {
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_publish_usage, NULL);
-    if (!du)
-      return -1;
-    pu = nua_dialog_usage_private(du);
-    pu->pu_published = 0;
-    if (sip->sip_if_match) {
-      pu->pu_etag = sip_etag_dup(nh->nh_home, sip->sip_if_match);
-      if (!pu->pu_etag)
-	return -1;
-      sip_header_remove(msg, sip, (sip_header_t *)sip->sip_if_match);
-    }
+  if (e == nua_r_unpublish) {
+    du = nua_dialog_usage_get(nh->nh_ds, nua_publish_usage, NULL);
+    if (du)
+      refresh = 1;
+    else
+      du = nua_dialog_usage_add(nh, nh->nh_ds, nua_publish_usage, NULL);
   }
+  else if (!refresh)
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_publish_usage, NULL);
   else
     du = nua_dialog_usage_get(nh->nh_ds, nua_publish_usage, NULL);
 
-  cr->cr_usage = du;
+  if (!du)
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
 
-  return 0;
-}
+  nua_dialog_usage_reset_refresh(du);
+  pu = nua_dialog_usage_private(du); assert(pu);
 
-static
-int nua_publish_client_request(nua_client_request_t *cr,
-			       msg_t *msg, sip_t *sip,
-			       tagi_t const *tags)
-{
-  nua_dialog_usage_t *du = cr->cr_usage;
-  int un, done;
-  sip_etag_t const *etag = NULL;
+  if (refresh) {
+    if (cr->cr_msg)
+      msg_destroy(cr->cr_msg);
+    cr->cr_msg = msg_copy(du->du_msg);
+    remove_body = pu->pu_etag != NULL;
+  }
 
-  un = cr->cr_terminating ||
-    cr->cr_event != nua_r_publish ||
-    (du && du->du_shutdown) ||
-    (sip->sip_expires && sip->sip_expires->ex_delta == 0);
-  cr->cr_terminating = un;
-  done = un;
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count || refresh,
+		     SIP_METHOD_PUBLISH,
+		     NUTAG_ADD_CONTACT(0),
+		     TAG_NEXT(tags));
+  sip = sip_object(msg);
 
-  if (du) {
-    struct publish_usage *pu = nua_dialog_usage_private(du);
+  if (!msg || !sip) 
+    goto error;
 
-    if (nua_client_bind(cr, du) < 0)
-      return -1;
-    if (pu->pu_published)
-      done = 1;
-    etag = pu->pu_etag;
+  du->du_terminating =
+    e != nua_r_publish ||
+    (sip->sip_expires && sip->sip_expires->ex_delta == 0);
+
+  if (!du->du_terminating && !refresh) {
+    /* Save template */
+    if (du->du_msg)
+      msg_destroy(du->du_msg);
+    du->du_msg = msg_ref_create(cr->cr_msg);
   }
 
-  return nua_base_client_trequest(cr, msg, sip,
-				  SIPTAG_IF_MATCH(etag),
-				  TAG_IF(done, SIPTAG_PAYLOAD(NONE)),
-				  TAG_IF(done, SIPTAG_CONTENT_TYPE(NONE)),
-				  TAG_IF(un, SIPTAG_EXPIRES_STR("0")),
-				  TAG_NEXT(tags));
+  cr->cr_orq =
+    nta_outgoing_mcreate(nua->nua_nta,
+			 process_response_to_publish, nh, NULL,
+			 msg,
+			 SIPTAG_IF_MATCH(pu->pu_etag),
+			 TAG_IF(remove_body, SIPTAG_PAYLOAD(NONE)),
+			 TAG_IF(remove_body, SIPTAG_CONTENT_TYPE(NONE)),
+			 TAG_IF(e != nua_r_publish,
+				SIPTAG_EXPIRES_STR("0")),
+			 SIPTAG_END(), TAG_NEXT(tags));
+  if (!cr->cr_orq)
+    goto error;
+
+  cr->cr_usage = du;
+
+  return cr->cr_event = e;
+
+ error:
+  msg_destroy(msg);
+  if (!du->du_ready == 0)
+    nua_dialog_usage_remove(nh, nh->nh_ds, du);
+  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
 }
 
-static int nua_publish_client_response(nua_client_request_t *cr,
-				       int status, char const *phrase,
-				       sip_t const *sip)
+
+static void
+restart_publish(nua_handle_t *nh, tagi_t *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_publish, tags);
+}
+
+
+static
+int process_response_to_publish(nua_handle_t *nh,
+				nta_outgoing_t *orq,
+				sip_t const *sip)
+{
+  int status = sip->sip_status->st_status;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
   nua_dialog_usage_t *du = cr->cr_usage;
+  struct publish_usage *pu = nua_dialog_usage_private(du);
+  unsigned saved_retry_count = cr->cr_retry_count + 1;
 
-  if (!cr->cr_terminated && du && sip) {
-    struct publish_usage *pu = nua_dialog_usage_private(du);
-    sip_expires_t const *ex = sip->sip_expires;
-
-    /* Reset state */
-    pu->pu_published = 0;
-    if (pu->pu_etag)
-      su_free(nh->nh_home, pu->pu_etag), pu->pu_etag = NULL;
-
-    if (status == 412) {
-      if (nua_client_restart(cr, 100, phrase))
-	return 0;
-    }
-    else if (status < 300) {
-      if (ex && ex->ex_delta == 0 &&
-	  nua_client_restart(cr, 100, "Trying re-PUBLISH"))
-	return 0;
+  if (nua_creq_check_restart(nh, cr, orq, sip, restart_publish))
+    return 0;
 
-      pu->pu_published = 1;
-      pu->pu_etag = sip_etag_dup(nh->nh_home, sip->sip_etag);
+  if (status < 200 || pu == NULL)
+    return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+
+  if (pu->pu_etag)
+    su_free(nh->nh_home, pu->pu_etag), pu->pu_etag = NULL;
 
-      if (!ex || ex->ex_delta == 0 || !pu->pu_etag) {
-	cr->cr_terminated = 1;
+  if (!du->du_terminating) {
+    int retry = 0, invalid_expiration = 0;
 
-	if (!ex || ex->ex_delta == 0)
-	  SET_STATUS(900, "Received Invalid Expiration Time");
-	else
-	  SET_STATUS1(NUA_INTERNAL_ERROR);
-      }
+    if (status < 300) {
+      if (!sip->sip_expires)
+	invalid_expiration = 1;
+      else if (sip->sip_expires->ex_delta == 0)
+	retry = 1, invalid_expiration = 1;
+    }
+    else if (status == 412)
+      retry = 1;
+
+    if (status < 300 && !invalid_expiration && !retry) {
+      pu->pu_etag = sip_etag_dup(nh->nh_home, sip->sip_etag);
+      du->du_ready = 1;
+      nua_dialog_usage_set_expires(du, sip->sip_expires->ex_delta);
+    }
+    else if (retry && saved_retry_count < NH_PGET(nh, retry_count)) {
+      msg_t *response = nta_outgoing_getresponse(orq);
+      nua_stack_event(nh->nh_nua, nh, response, cr->cr_event,
+      		100, "Trying re-PUBLISH",
+      		TAG_END());
+      nua_creq_deinit(cr, orq);
+      nua_stack_publish2(nh->nh_nua, nh, cr->cr_event, 1, NULL);
+      cr->cr_retry_count = saved_retry_count;
+      return 0;
+    }
+    else if (invalid_expiration) {
+      msg_t *response = nta_outgoing_getresponse(orq);
+      nua_stack_event(nh->nh_nua, nh, response, cr->cr_event,
+      		900, "Received Invalid Expiration Time",
+      		TAG_END());
+      nua_dialog_usage_remove(nh, nh->nh_ds, cr->cr_usage);
+      nua_creq_deinit(cr, orq);
+      cr->cr_usage = NULL;
+      return 0;
     }
   }
 
-  return nua_base_client_response(cr, status, phrase, sip, NULL);
+  return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
 }
 
-static void nua_publish_usage_refresh(nua_handle_t *nh,
-				     nua_dialog_state_t *ds,
-				     nua_dialog_usage_t *du,
-				     sip_time_t now)
-{
-  nua_client_request_t *cr = du->du_cr;
-
-  if (cr) {
-    if (nua_client_is_queued(cr) /* Already publishing. */
-	|| nua_client_resend_request(cr, 0, NULL) >= 0)
-      return;
-  }
-
-  nua_stack_event(nh->nh_nua, nh, NULL,
-		  nua_r_publish, NUA_INTERNAL_ERROR,
-		  NULL);
 
-  nua_dialog_usage_remove(nh, ds, du);
+static void nua_publish_usage_refresh(nua_handle_t *nh,
+				      nua_dialog_state_t *ds,
+				      nua_dialog_usage_t *du,
+				      sip_time_t now)
+{
+  if (ds->ds_cr->cr_usage == du) /* Already publishing. */
+    return;
+  nua_stack_publish2(nh->nh_nua, nh, nua_r_publish, 1, NULL);
 }
 
-/** @interal Shut down PUBLISH usage.
+/** @interal Shut down PUBLISH usage. 
  *
  * @retval >0  shutdown done
  * @retval 0   shutdown in progress
  * @retval <0  try again later
  */
 static int nua_publish_usage_shutdown(nua_handle_t *nh,
-				     nua_dialog_state_t *ds,
-				     nua_dialog_usage_t *du)
+				      nua_dialog_state_t *ds,
+				      nua_dialog_usage_t *du)
 {
-  nua_client_request_t *cr = du->du_cr;
+  nua_client_request_t *cr = ds->ds_cr;
 
-  if (cr) {
-    if (nua_client_is_queued(cr)) /* Already publishing. */
-      return -1;
-
-    if (nua_client_resend_request(cr, 1, NULL) >= 0)
-      return 0;
+  if (!cr->cr_usage) {
+    /* Unpublish */
+    nua_stack_publish2(nh->nh_nua, nh, nua_r_destroy, 1, NULL);
+    return cr->cr_usage != du;
   }
 
-  /* XXX - report to user */
-  nua_dialog_usage_remove(nh, ds, du);
-  return 200;
+  if (!du->du_ready && !cr->cr_orq)
+    return 1;			/* had unauthenticated initial request */
+
+  return -1;  /* Request in progress */
 }
 
 /* ---------------------------------------------------------------------- */
 /* Server side */
 
+static
+int respond_to_publish(nua_server_request_t *sr, tagi_t const *tags);
+
 /** @NUA_EVENT nua_i_publish
  *
  * Incoming PUBLISH request.
@@ -475,35 +481,48 @@
  * @END_NUA_EVENT
  */
 
-int nua_publish_server_init(nua_server_request_t *sr);
-
-nua_server_methods_t const nua_publish_server_methods = 
-  {
-    SIP_METHOD_PUBLISH,
-    nua_i_publish,		/* Event */
-    { 
-      0,			/* Do not create dialog */
-      0,			/* Initial request */
-      0,			/* Not a target refresh request  */
-      1,			/* Add Contact */
-    },
-    nua_publish_server_init,
-    nua_base_server_preprocess,
-    nua_base_server_params,
-    nua_base_server_respond,
-    nua_base_server_report,
-  };
-
-int nua_publish_server_init(nua_server_request_t *sr)
-{
-  sip_allow_events_t *allow_events = NH_PGET(sr->sr_owner, allow_events);
-  sip_event_t *o = sr->sr_request.sip->sip_event;
+int nua_stack_process_publish(nua_t *nua,
+			      nua_handle_t *nh,
+			      nta_incoming_t *irq,
+			      sip_t const *sip)
+{
+  nua_server_request_t *sr, sr0[1];
+  sip_allow_events_t *allow_events = NUA_PGET(nua, nh, allow_events);
+  sip_event_t *o = sip->sip_event;
   char const *event = o ? o->o_type : NULL;
   
+  sr = SR_INIT(sr0);
+  
   if (!allow_events)
-    return SR_STATUS1(sr, SIP_501_NOT_IMPLEMENTED);
+    SR_STATUS1(sr, SIP_501_NOT_IMPLEMENTED);
   else if (!event || !msg_header_find_param(allow_events->k_common, event))
-    return SR_STATUS1(sr, SIP_489_BAD_EVENT);
+    SR_STATUS1(sr, SIP_489_BAD_EVENT);
 
-  return 0;
+  sr = nua_server_request(nua, nh, irq, sip, sr, sizeof *sr,
+			  respond_to_publish, 0);
+
+  return nua_stack_server_event(nua, sr, nua_i_publish, TAG_END());
+}
+
+static
+int respond_to_publish(nua_server_request_t *sr, tagi_t const *tags)
+{
+  nua_handle_t *nh = sr->sr_owner;
+  nua_t *nua = nh->nh_nua;
+  msg_t *msg;
+
+  msg = nua_server_response(sr, sr->sr_status, sr->sr_phrase, TAG_NEXT(tags));
+
+  if (msg) {
+    nta_incoming_mreply(sr->sr_irq, msg);
+  }
+  else {
+    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
+    nua_stack_event(nua, nh, NULL,
+		    nua_i_error, 900, "PUBLISH Response Fails",
+		    TAG_END());
+  }
+  
+  return sr->sr_status >= 200 ? sr->sr_status : 0;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c	Sat Feb 17 01:25:21 2007
@@ -27,7 +27,6 @@
  *
  * @author Pekka Pessi <Pekka.Pessi at nokia.com>
  * @author Martti Mela <Martti.Mela at nokia.com>
- * @author Kai Vehmanen <Kai.Vehmanen at nokia.com>
  *
  * @date Created: Wed Mar  8 11:48:49 EET 2006 ppessi
  */
@@ -46,6 +45,8 @@
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/sip_status.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
 #define NTA_UPDATE_MAGIC_T   struct nua_s
 
 #include "nua_stack.h"
@@ -119,11 +120,8 @@
   nua_registration_t *nr_next, **nr_prev, **nr_list; /* Doubly linked list and its head */
   sip_from_t *nr_aor;		/**< AoR for this registration, NULL if none */
   sip_contact_t *nr_contact;	/**< Our Contact */
-  sip_contact_t nr_dcontact[1];	/**< Contact in dialog */
   sip_via_t *nr_via;		/**< Corresponding Via headers */
 
-  unsigned long nr_min_expires;	/**< Value from 423 negotiation */
-
   /** Status of registration */
   unsigned nr_ready:1;
   /** Kind of registration.
@@ -222,16 +220,25 @@
 /* ======================================================================== */
 /* REGISTER */
 
+static void restart_register(nua_handle_t *nh, tagi_t *tags);
+
+static int process_response_to_register(nua_handle_t *nh,
+					nta_outgoing_t *orq,
+					sip_t const *sip);
+
+static void unregister_expires_contacts(msg_t *msg, sip_t *sip);
+
 /* Interface towards outbound_t */
 sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
 					 su_home_t *home,
-					 int in_dialog,
 					 char const *extra_username,
 					 sip_via_t const *v,
 					 char const *transport,
 					 char const *m_param,
 					 ...);
 
+static int nua_stack_outbound_features(nua_handle_t *nh, outbound_t *ob);
+
 static int nua_stack_outbound_refresh(nua_handle_t *,
 				      outbound_t *ob);
 
@@ -433,11 +440,6 @@
  * the desired transport-layer keepalive interval for stream-based
  * transports like TLS and TCP.
  *
- * As alternative to OPTIONS/STUN keepalives, the client can propose
- * a more frequent registration refresh interval with
- * NUTAG_M_FEATURES() (e.g. NUTAG_M_FEATURES("expires=120") given as 
- * parameter to nua_register()).
- * 
  * @sa #nua_r_register, nua_unregister(), #nua_r_unregister, 
  * #nua_i_register,
  * @RFC3261 section 10,
@@ -535,351 +537,384 @@
  * @END_NUA_EVENT
  */
 
-static int nua_register_client_template(nua_client_request_t *cr,
-					msg_t **return_msg,
-					tagi_t const *tags);
-static int nua_register_client_init(nua_client_request_t *cr,
-				    msg_t *, sip_t *,
-				    tagi_t const *tags);
-static int nua_register_client_request(nua_client_request_t *cr,
-				       msg_t *, sip_t *,
-				       tagi_t const *tags);
-static int nua_register_client_check_restart(nua_client_request_t *cr,
-					     int status, char const *phrase,
-					     sip_t const *sip);
-static int nua_register_client_response(nua_client_request_t *cr,
-					int status, char const *phrase,
-					sip_t const *sip);
-
-static nua_client_methods_t const nua_register_client_methods = {
-  SIP_METHOD_REGISTER,
-  0,
-  {
-    /* create_dialog */ 1,
-    /* in_dialog */ 0,
-    /* target refresh */ 0
-  },
-  nua_register_client_template,
-  nua_register_client_init,
-  nua_register_client_request,
-  nua_register_client_check_restart,
-  nua_register_client_response
-};
-
-/**@internal Send REGISTER. */
-int nua_stack_register(nua_t *nua,
-		       nua_handle_t *nh,
-		       nua_event_t e,
-		       tagi_t const *tags)
-{
-  return nua_client_create(nh, e, &nua_register_client_methods, tags);
-}
-
-static int nua_register_client_template(nua_client_request_t *cr,
-					msg_t **return_msg,
-					tagi_t const *tags)
-{
-  nua_dialog_usage_t *du;
-
-  if (cr->cr_event == nua_r_register)
-    return 0;
-
-  /* Use a copy of REGISTER message as the template for un-REGISTER */
-  du = nua_dialog_usage_get(cr->cr_owner->nh_ds, nua_register_usage, NULL);
-  if (du && du->du_cr) {
-    if (nua_client_set_target(cr, du->du_cr->cr_target) < 0)
-      return -1;
-    *return_msg = msg_copy(du->du_cr->cr_msg);
-    return 1;
-  }
-
-  return 0;
-}
-
-static int nua_register_client_init(nua_client_request_t *cr,
-				    msg_t *msg, sip_t *sip,
-				    tagi_t const *tags)
+int
+nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		   tagi_t const *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
   nua_dialog_usage_t *du;
-  nua_registration_t *nr;
-  sip_to_t const *aor = sip->sip_to;
-
-  int unreg;
-
-  /* Explicit empty (NULL) contact - used for CPL store/remove? */
-  if (!sip->sip_contact && cr->cr_has_contact)
-    /* Do not create any usage */
-    return 0;
+  nua_registration_t *nr = NULL;
+  outbound_t *ob = NULL;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg = NULL;
+  sip_t *sip;
+  int terminating = e != nua_r_register;
+
+  if (nua_stack_set_handle_special(nh, nh_has_register, nua_r_register) < 0)
+    return UA_EVENT2(e, 900, "Invalid handle for REGISTER");
+  if (cr->cr_orq)
+    return UA_EVENT2(e, 900, "Request already in progress");
 
-  unreg = cr->cr_event != nua_r_register ||
-    (sip->sip_expires && sip->sip_expires->ex_delta == 0);
-  if (unreg)
-    nua_client_terminating(cr);
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
 
   du = nua_dialog_usage_add(nh, nh->nh_ds, nua_register_usage, NULL);
-  if (du == NULL)
-    return -1;
-  nr = nua_dialog_usage_private(du);
-
+  if (!du)
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  nr = nua_dialog_usage_private(du); assert(nr);
   nua_registration_add(&nh->nh_nua->nua_registrations, nr);
+  if (!terminating && du->du_terminating)
+    return UA_EVENT2(e, 900, "Unregister in progress");
 
-  if (nua_client_bind(cr, du) < 0)
-    return -1;
+  if (cr->cr_msg)
+    msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
+  /* Use original message as template when unregistering */
+  if (terminating)		
+    cr->cr_msg = msg_ref_create(du->du_msg);
 
-  if (aor == NULL)
-    aor = sip->sip_from;
-  if (aor == NULL)
-    aor = nh->nh_nua->nua_from;
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_msg != NULL,
+		     SIP_METHOD_REGISTER,
+		     TAG_IF(!terminating, NUTAG_USE_DIALOG(1)),
+		     TAG_NEXT(tags));
+  sip = sip_object(msg);
+  if (!msg || !sip)
+    goto error;
 
-  if (nua_registration_set_aor(nh->nh_home, nr, aor) < 0)
-    return -1;
+  if (!nr->nr_aor) {
+    if (nua_registration_set_aor(nh->nh_home, nr, sip->sip_to) < 0)
+      goto error;
+  }
 
-  if (nua_registration_set_contact(nh, nr, sip->sip_contact, unreg) < 0)
-    return -1;
+  if (terminating)
+    /* Add Expires: 0 and remove the expire parameters from contacts */
+    unregister_expires_contacts(msg, sip);
 
-  if (!nr->nr_ob && (NH_PGET(nh, outbound) || NH_PGET(nh, instance))) {
-    nr->nr_ob = outbound_new(nh, &nua_stack_outbound_callbacks,
-			     nh->nh_nua->nua_root,
-			     nh->nh_nua->nua_nta,
-			     NH_PGET(nh, instance));
-    if (!nr->nr_ob)
-      return nua_client_return(cr, 900, "Cannot create outbound", msg);
+  if (!sip->sip_contact && cr->cr_has_contact) {
+    terminating = 1;
   }
+  else if (nua_registration_set_contact(nh, nr, sip->sip_contact, terminating)
+	   < 0)
+    goto error;
 
-  if (nr->nr_ob) {
-    outbound_t *ob = nr->nr_ob;
-    sip_contact_t *m;
+  du->du_terminating = terminating;
 
-    if (!unreg && sip->sip_contact) {
-      for (m = sip->sip_contact; m; m = m->m_next)
-	if (!m->m_expires || strtoul(m->m_expires, NULL, 10) != 0)
-	  break;
-      
-      if (m == NULL)
-	unreg = 1;	/* All contacts have expires=0 */
-    }
+  if (du->du_msg == NULL && !terminating)
+    du->du_msg = msg_ref_create(cr->cr_msg); /* Save original message */
+
+  ob = nr->nr_ob;
+  
+  if (!ob && (NH_PGET(nh, outbound) || NH_PGET(nh, instance))) {
+    nr->nr_ob = ob = outbound_new(nh, &nua_stack_outbound_callbacks,
+				  nh->nh_nua->nua_root,
+				  nh->nh_nua->nua_nta,
+				  NH_PGET(nh, instance));
+    if (!ob)
+      goto error;
+  }
 
+  if (ob) {
     outbound_set_options(ob,
 			 NH_PGET(nh, outbound),
 			 NH_PGET(nh, keepalive),
 			 NH_PISSET(nh, keepalive_stream)
 			 ? NH_PGET(nh, keepalive_stream)
 			 : NH_PGET(nh, keepalive));
+    nua_stack_outbound_features(nh, ob);
+    outbound_stop_keepalive(ob);
 
-    if (outbound_set_contact(ob, sip->sip_contact, nr->nr_via, unreg) < 0)
-      return nua_client_return(cr, 900, "Cannot set outbound contact", msg);
+    if (outbound_set_contact(ob, sip->sip_contact, nr->nr_via, terminating) < 0)
+      goto error;
   }
 
-  return 0;
+  /* This calls nta_outgoing_mcreate() but adds a few tags */
+  cr->cr_orq =
+    outbound_register_request(ob, terminating,
+			      nr->nr_by_stack ? nr->nr_contact : NULL,
+			      nua->nua_nta,
+			      process_response_to_register, nh, NULL,
+			      msg,
+			      SIPTAG_END(), 
+			      TAG_IF(terminating, NTATAG_SIGCOMP_CLOSE(1)),
+			      TAG_IF(!terminating, NTATAG_COMP("sigcomp")),
+			      TAG_NEXT(tags));
+
+  if (!cr->cr_orq)
+    goto error;
+
+  cr->cr_usage = du;
+  return cr->cr_event = e;
+
+ error:
+  msg_destroy(msg);
+  msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
+  nua_dialog_usage_remove(nh, nh->nh_ds, du);    
+  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
 }
 
-static
-int nua_register_client_request(nua_client_request_t *cr,
-				msg_t *msg, sip_t *sip,
-				tagi_t const *tags)
+static void
+restart_register(nua_handle_t *nh, tagi_t *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg;
   nua_dialog_usage_t *du = cr->cr_usage;
-  nua_registration_t *nr;
-  sip_contact_t *m, *contacts = sip->sip_contact;
-  char const *min_expires = NULL;
-  int unreg;
-
-  (void)nh;
-
-  /* Explicit empty (NULL) contact - used for CPL store/remove? */
-  if (!contacts && cr->cr_has_contact)
-    return nua_base_client_request(cr, msg, sip, tags);
-
-  if ((du && du->du_shutdown) ||
-      (sip->sip_expires && sip->sip_expires->ex_delta == 0))
-    nua_client_terminating(cr);
-
-  if (contacts) {
-    if (!cr->cr_terminating) {
-      for (m = contacts; m; m = m->m_next)
-	if (!m->m_expires || strtoul(m->m_expires, NULL, 10) != 0)
-	  break;
-      /* All contacts have expires=0 */
-      if (m == NULL)
-	nua_client_terminating(cr);
-    }
-  }
-
-  unreg = cr->cr_terminating;
+  nua_registration_t *nr = nua_dialog_usage_private(du);
+  int terminating = du && du->du_terminating;
 
-  nr = nua_dialog_usage_private(du);
+  cr->cr_restart = NULL;
 
-  if (nr) {
-    if (nr->nr_ob) {
-      outbound_stop_keepalive(nr->nr_ob);
-      outbound_start_registering(nr->nr_ob);
-    }
+  if (!cr->cr_msg)
+    return;
 
-    if (nr->nr_by_stack) {
-      sip_contact_t *m = nr->nr_contact, *previous = NULL;
+  msg = nua_creq_msg(nh->nh_nua, nh, cr, 1,
+		     SIP_METHOD_UNKNOWN,
+		     TAG_NEXT(tags));
 
-      outbound_get_contacts(nr->nr_ob, &m, &previous);
+  if (!msg)
+    return;			/* XXX - Uh-oh */
 
-      sip_add_dup(msg, sip, (sip_header_t *)m);
-      /* previous is an outdated contact generated by stack 
-       * and it is now unregistered */
-      if (previous)
-	sip_add_dup(msg, sip, (sip_header_t *)previous);
-    }
-  }
-
-  for (m = sip->sip_contact; m; m = m->m_next) {
-    if (m->m_url->url_type == url_any) {
-      /* If there is a '*' in contact list, remove everything else */
-      while (m != sip->sip_contact)
-	sip_header_remove(msg, sip, (sip_header_t *)sip->sip_contact);
-      while (m->m_next)
-	sip_header_remove(msg, sip, (sip_header_t *)m->m_next);
-      contacts = m;
-      break;
-    }
+  if (terminating)
+    unregister_expires_contacts(msg, sip_object(msg));
 
-    if (!m->m_expires)
-      continue;
-    if (unreg) {
-      /* Remove the expire parameters from contacts */
-      msg_header_remove_param(m->m_common, "expires");
-    }
-    else if (nr && nr->nr_min_expires && 
-	     strtoul(m->m_expires, 0, 10) < nr->nr_min_expires) {
-      if (min_expires == NULL) 
-	min_expires = su_sprintf(msg_home(msg), "expires=%lu", 
-				 nr->nr_min_expires);
-      msg_header_replace_param(msg_home(msg), m->m_common, min_expires);
-    }
-  }
+  /* This calls nta_outgoing_mcreate() but adds a few tags */
+  cr->cr_orq =
+    outbound_register_request(nr->nr_ob, terminating,
+			      nr->nr_by_stack ? nr->nr_contact : NULL,
+			      nh->nh_nua->nua_nta,
+			      process_response_to_register, nh, NULL,
+			      msg,
+			      SIPTAG_END(), 
+			      TAG_IF(terminating, NTATAG_SIGCOMP_CLOSE(1)),
+			      TAG_IF(!terminating, NTATAG_COMP("sigcomp")),
+			      TAG_NEXT(tags));
 
-  return nua_base_client_trequest(cr, msg, sip,
-				  TAG_IF(unreg, SIPTAG_EXPIRES_STR("0")),
-#if 0
-				  TAG_IF(unreg, NTATAG_SIGCOMP_CLOSE(1)),
-				  TAG_IF(!unreg, NTATAG_COMP("sigcomp")),
-#endif
-				  TAG_NEXT(tags));
+  if (!cr->cr_orq)
+    msg_destroy(msg);
 }
 
-static int nua_register_client_check_restart(nua_client_request_t *cr,
-					     int status, char const *phrase,
-					     sip_t const *sip)
+/** Refresh registration */
+static
+void nua_register_usage_refresh(nua_handle_t *nh,
+				nua_dialog_state_t *ds,
+				nua_dialog_usage_t *du,
+				sip_time_t now)
 {
-  nua_registration_t *nr = nua_dialog_usage_private(cr->cr_usage);
-  unsigned short retry_count = cr->cr_retry_count;
-  int restart = 0, retry;
-
-  if (nr && nr->nr_ob) {
-    msg_t *_reqmsg = nta_outgoing_getrequest(cr->cr_orq);
-    sip_t *req = sip_object(_reqmsg); msg_destroy(_reqmsg);
-
-    retry = outbound_register_response(nr->nr_ob, cr->cr_terminating,
-				       req, sip);
-
-    restart = retry >= ob_reregister_now;
-    
-    if (retry == ob_reregister)
-      /* outbound restarts REGISTER later */;
+  nua_t *nua = nh->nh_nua;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_registration_t *nr = nua_dialog_usage_private(du);
+  msg_t *msg;
+  sip_t *sip;
 
-    if (retry < 0)
-      /* XXX - report an error? */;
-  }
+  if (du->du_terminating || du->du_shutdown)
+    return;
 
-  if (nr && status == 423) {
-    if (sip->sip_min_expires)
-      nr->nr_min_expires = sip->sip_min_expires->me_delta;
-  }
+  if (cr->cr_msg) {
+    /* Dialog is busy, delay of 5 .. 15 seconds */
+    nua_dialog_usage_refresh_range(du, 5, 15);
+    return;
+  }
+
+  outbound_stop_keepalive(nr->nr_ob);
+
+  cr->cr_msg = msg_copy(du->du_msg);
+  msg = nua_creq_msg(nua, nh, cr, 1,
+		     SIP_METHOD_REGISTER,
+		     NUTAG_USE_DIALOG(1),
+		     TAG_END());
+  sip = sip_object(msg);
+  if (!msg || !sip)
+    goto error;
+
+  cr->cr_orq =
+    outbound_register_request(nr->nr_ob, 0,
+			      nr->nr_by_stack ? nr->nr_contact : NULL,
+			      nh->nh_nua->nua_nta,
+			      process_response_to_register, nh, NULL,
+			      msg,
+			      SIPTAG_END(), 
+			      NTATAG_COMP("sigcomp"),
+			      TAG_END());
+  if (!cr->cr_orq)
+    goto error;
 
-  /* Check for status-specific reasons to retry */
-  if (nua_base_client_check_restart(cr, status, phrase, sip))
-    return 1;
+  cr->cr_usage = du;
+  cr->cr_event = nua_r_register;
+  return;
 
-  /* Restart only if nua_base_client_check_restart() did not try to restart */
-  if (restart && retry_count == cr->cr_retry_count)
-    return nua_client_restart(cr, status, phrase);
-  
-  return 0;
+ error:
+  msg_destroy(msg);
+  msg_destroy(cr->cr_msg);
+  UA_EVENT2(nua_r_register, NUA_INTERNAL_ERROR, TAG_END());
+  return;
 }
 
-static int nua_register_client_response(nua_client_request_t *cr,
-					int status, char const *phrase,
-					sip_t const *sip)
+/** Shutdown register usage. 
+ *
+ * Called when stack is shut down or handle is destroyed. Unregister.
+ */
+static
+int nua_register_usage_shutdown(nua_handle_t *nh, 
+				nua_dialog_state_t *ds,
+				nua_dialog_usage_t *du)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_t *nua = nh->nh_nua;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
   nua_registration_t *nr = nua_dialog_usage_private(du);
-  int ready;
+  msg_t *msg;
+  sip_t *sip;
 
-  ready = du && !cr->cr_terminated && status < 300;
+  if (du->du_terminating)	/* Already terminating? */
+    return 100;
 
-  if (ready) {
-    sip_time_t mindelta = 0;
-    sip_time_t now = sip_now(), delta, reqdelta, mdelta;
+  du->du_terminating = 1;
+
+  if (cr->cr_msg)    /* Busy */
+    return 100;
+
+  outbound_stop_keepalive(nr->nr_ob);
+
+  cr->cr_msg = msg_copy(du->du_msg);
+  msg = nua_creq_msg(nua, nh, cr, 1,
+		     SIP_METHOD_REGISTER,
+		     NUTAG_USE_DIALOG(1),
+		     TAG_END());
+  sip = sip_object(msg);
+  if (!msg || !sip)
+    goto error;
+
+  unregister_expires_contacts(msg, sip);
+
+  cr->cr_orq =
+    outbound_register_request(nr->nr_ob, 1,
+			      nr->nr_by_stack ? nr->nr_contact : NULL,
+			      nh->nh_nua->nua_nta,
+			      process_response_to_register, nh, NULL,
+			      msg,
+			      SIPTAG_END(), 
+			      NTATAG_SIGCOMP_CLOSE(1),
+			      TAG_END());
+  if (!cr->cr_orq)
+    goto error;
 
-    sip_contact_t const *m, *sent;
+  cr->cr_usage = du;
+  cr->cr_event = nua_r_destroy;
+  return 200;
 
-    msg_t *_reqmsg = nta_outgoing_getrequest(cr->cr_orq);
-    sip_t *req = sip_object(_reqmsg);
+ error:
+  nua_dialog_usage_remove(nh, nh->nh_ds, du);
+  msg_destroy(msg);
+  msg_destroy(cr->cr_msg);
+  return 500;
+}
 
-    msg_destroy(_reqmsg);
 
-    assert(nr); assert(sip); assert(req);
+static
+int process_response_to_register(nua_handle_t *nh,
+				 nta_outgoing_t *orq,
+				 sip_t const *sip)
+{
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_registration_t *nr = nua_dialog_usage_private(du);
+  int status, ready, reregister, terminating;
+  char const *phrase;
+  msg_t *_reqmsg = nta_outgoing_getrequest(orq);
+  sip_t *req = sip_object(_reqmsg); msg_destroy(_reqmsg);
+
+  assert(sip);
+  assert(du && du->du_class == nua_register_usage);
+  status = sip->sip_status->st_status;
+  phrase = sip->sip_status->st_phrase;
+
+  if (status < 200 || !du)
+    return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+
+  terminating = du->du_terminating;
+  if (!terminating)
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+
+  reregister = outbound_register_response(nr->nr_ob, terminating, req, sip);
+  if (reregister < 0)
+    SET_STATUS1(NUA_INTERNAL_ERROR);
+  else if (reregister >= ob_reregister) {
+    /* Save msg otherwise nua_creq_check_restart() will zap it */
+    msg_t *msg = msg_ref_create(cr->cr_msg);
 
-#if HAVE_SIGCOMP
-    {
-      struct sigcomp_compartment *cc;
-      cc = nta_outgoing_compartment(cr->cr_orq);
-      sigcomp_compartment_unref(nr->nr_compartment);
-      nr->nr_compartment = cc;
+    if (nua_creq_check_restart(nh, cr, orq, sip, restart_register)) {
+      msg_destroy(msg);
+      return 0;
     }
-#endif
 
-    /* XXX - if store/remove, remove 
-       Content-Disposition
-       Content-Type
-       body
-    */
-
-    /** Search for lowest delta of SIP contacts we tried to register */
-    mindelta = SIP_TIME_MAX;
-
-    reqdelta = req->sip_expires ? req->sip_expires->ex_delta : 0;
-
-    for (m = sip->sip_contact; m; m = m->m_next) {
-      if (m->m_url->url_type != url_sip && 
-	  m->m_url->url_type != url_sips)
-	continue;
+    assert(cr->cr_msg == NULL);
+    cr->cr_msg = msg;
+
+    if (reregister >= ob_reregister_now) {
+      /* We can try to reregister immediately */
+      nua_creq_restart_with(nh, cr, orq, 100, "Updated Contact",
+			    restart_register,
+			    TAG_END());
+    }
+    else {
+      /* Outbound will invoke refresh_register() later */
+      nua_creq_save_restart(nh, cr, orq, 100, "Updated Contact",
+			    restart_register);
+    }
+    return 0;
+  }
+
+  if (status >= 300)
+    if (nua_creq_check_restart(nh, cr, orq, sip, restart_register))
+      return 0;
 
-      for (sent = req->sip_contact; sent; sent = sent->m_next) {
-	if (url_cmp(m->m_url, sent->m_url))
-	  continue;
-
-	if (sent->m_expires)
-	  mdelta = strtoul(sent->m_expires, NULL, 10);
-	else
-	  mdelta = reqdelta;
-
-	if (mdelta == 0)
-	  mdelta = 3600;
-	  
-	delta = sip_contact_expires(m, sip->sip_expires, sip->sip_date,
-				    mdelta, now);
-	if (delta > 0 && delta < mindelta)
-	  mindelta = delta;
+  ready = !terminating && status < 300;
+  du->du_ready = ready;
 
-	if (url_cmp_all(m->m_url, sent->m_url) == 0)
-	  break;
+  if (status < 300) {
+    if (!du->du_terminating) {
+      sip_time_t mindelta = 0;
+      sip_time_t now = sip_now(), delta, reqdelta;
+      sip_contact_t const *m, *sent;
+
+      /** Search for lowest delta of SIP contacts we tried to register */
+      mindelta = SIP_TIME_MAX;
+
+      reqdelta = req->sip_expires ? req->sip_expires->ex_delta : 0;
+
+      for (m = sip->sip_contact; m; m = m->m_next) {
+        if (m->m_url->url_type != url_sip && 
+            m->m_url->url_type != url_sips)
+          continue;
+        for (sent = req->sip_contact; sent; sent = sent->m_next)
+          if (url_cmp(m->m_url, sent->m_url) == 0) {
+            sip_time_t mdelta = reqdelta;
+
+            if (sent->m_expires)
+              mdelta = strtoul(sent->m_expires, NULL, 10);
+            if (mdelta == 0)
+              mdelta = 3600;
+
+            delta = sip_contact_expires(m, sip->sip_expires, sip->sip_date,
+       				 mdelta, now);
+            if (delta > 0 && delta < mindelta)
+              mindelta = delta;
+            if (url_cmp_all(m->m_url, sent->m_url) == 0)
+              break;
+          }
       }
-    }
 
-    if (mindelta == SIP_TIME_MAX)
-      mindelta = 3600;
+      if (mindelta == SIP_TIME_MAX)
+        mindelta = 3600;
+      nua_dialog_usage_set_expires(du, mindelta);
+    }
+    else
+      nua_dialog_usage_set_expires(du, 0);
+  }
 
-    nua_dialog_usage_set_expires(du, mindelta);
+#if HAVE_SIGCOMP
+  if (ready) {
+    struct sigcomp_compartment *cc;
+    cc = nta_outgoing_compartment(orq);
+    sigcomp_compartment_unref(nr->nr_compartment);
+    nr->nr_compartment = cc;
+  }
+#endif
 
   /*  RFC 3608 Section 6.1 Procedures at the UA
 
@@ -899,104 +934,46 @@
    route for that address-of-record.
 
   */
+  if (ready) {
     su_free(nh->nh_home, nr->nr_route);
     nr->nr_route = sip_route_dup(nh->nh_home, sip->sip_service_route);
-
-    {
-      /* RFC 3327 */
-      /* Store last URI in Path header */
-      sip_path_t *path = sip->sip_path;
-
-      while (path && path->r_next)
-	path = path->r_next;
-
-      if (!nr->nr_path || !path ||
-	  url_cmp_all(nr->nr_path->r_url, path->r_url)) {
-	su_free(nh->nh_home, nr->nr_path);
-	nr->nr_path = sip_path_dup(nh->nh_home, path);
-      }
-    }
-
-    if (sip->sip_to->a_url->url_type == url_sips)
-      nr->nr_secure = 1;
-
-    if (nr->nr_ob) {
-      outbound_gruuize(nr->nr_ob, sip);
-      outbound_start_keepalive(nr->nr_ob, cr->cr_orq);
-    }
-
-    /* persistant connection for registration */
-    if (!nr->nr_tport)
-      /* note: nta_outgoing_transport() takes a ref */
-      nr->nr_tport = nta_outgoing_transport (cr->cr_orq); 
-
-    nua_registration_set_ready(nr, 1);
   }
-  else if (du) {
-    nua_dialog_usage_set_expires(du, 0);
-
+  else {
     su_free(nh->nh_home, nr->nr_route);
     nr->nr_route = NULL;
-
-    outbound_stop_keepalive(nr->nr_ob);
-
-    /* release the persistant transport for registration */
-    if (nr->nr_tport)
-      tport_decref(&nr->nr_tport), nr->nr_tport = NULL;
-
-    nua_registration_set_ready(nr, 0);
   }
 
+  if (ready) {
+    /* RFC 3327 */
+    /* Store last URI in Path header */
+    sip_path_t *path = sip->sip_path;
 
-  return nua_base_client_response(cr, status, phrase, sip, NULL);
-}
-
-static void nua_register_usage_refresh(nua_handle_t *nh,
-				       nua_dialog_state_t *ds,
-				       nua_dialog_usage_t *du,
-				       sip_time_t now)
-{
-  nua_t *nua = nh->nh_nua;
-  nua_client_request_t *cr = du->du_cr;
+    while (path && path->r_next)
+      path = path->r_next;
 
-  if (cr) {
-    if (nua_client_is_queued(cr) /* Already registering. */
-	|| nua_client_resend_request(cr, 0, NULL) >= 0)
-      return;
+    if (!nr->nr_path || !path ||
+        url_cmp_all(nr->nr_path->r_url, path->r_url)) {
+      su_free(nh->nh_home, nr->nr_path);
+      nr->nr_path = sip_path_dup(nh->nh_home, path);
+    }
   }
 
-  /* Report that we have de-registered */
-  nua_stack_event(nua, nh, NULL, nua_r_register, NUA_INTERNAL_ERROR, NULL);
-  nua_dialog_usage_remove(nh, ds, du);
-}
-
-/** @interal Shut down REGISTER usage.
- *
- * @retval >0  shutdown done
- * @retval 0   shutdown in progress
- * @retval <0  try again later
- */
-static int nua_register_usage_shutdown(nua_handle_t *nh,
-				     nua_dialog_state_t *ds,
-				     nua_dialog_usage_t *du)
-{
-  nua_client_request_t *cr = du->du_cr;
-  nua_registration_t *nr = nua_dialog_usage_private(du);
+  if (ready)
+    if (sip->sip_to->a_url->url_type == url_sips)
+      nr->nr_secure = 1;
 
-  if (cr) {
-    if (nua_client_is_queued(cr)) /* Already registering. */
-      return -1;
-    cr->cr_event = nua_r_unregister;
-    if (nua_client_resend_request(cr, 1, NULL) >= 0)
-      return 0;
+  if (nr->nr_ob) {
+    if (ready) {
+      outbound_gruuize(nr->nr_ob, sip);
+      outbound_start_keepalive(nr->nr_ob, orq);
+    }
+    else
+      outbound_stop_keepalive(nr->nr_ob);
   }
 
-  /* release the persistant transport for registration */
-  if (nr->nr_tport)
-    tport_decref(&nr->nr_tport), nr->nr_tport = NULL;
+  nua_registration_set_ready(nr, ready);
 
-  nua_dialog_usage_remove(nh, ds, du);
-  return 200;
+  return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
 }
 
 /* ---------------------------------------------------------------------- */
@@ -1007,8 +984,7 @@
 #endif
 
 static void nua_stack_tport_update(nua_t *nua, nta_agent_t *nta);
-static int nua_registration_add_contact_and_route(nua_handle_t *nh,
-						  nua_registration_t *nr,
+static int nua_registration_add_contact_and_route(nua_registration_t *nr,
 						  msg_t *msg,
 						  sip_t *sip,
 						  int add_contact,
@@ -1105,7 +1081,9 @@
 
   switch (nw_updates) {
   case NUA_NW_DETECT_ONLY_INFO:
-    nua_stack_event(nua, NULL, NULL, nua_i_network_changed, SIP_200_OK, NULL);
+    nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
+		    SIP_200_OK, TAG_END());
+
     break;
     
   case NUA_NW_DETECT_TRY_FULL:
@@ -1117,10 +1095,10 @@
     if (nua_stack_init_transport(nua, nua->nua_args) < 0)
       /* We are hosed */
       nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
-		      900, "Internal Error", NULL);
+		      900, "Internal Error", TAG_END());
     else
       nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
-		      SIP_200_OK, NULL);
+		      SIP_200_OK, TAG_END());
 
     break;
     
@@ -1284,8 +1262,11 @@
 
     v2[1].v_next = NULL;
 
-    contact = nua_handle_contact_by_via(nh, home, 0, NULL, v2, protocol, NULL);
-
+#if 1
+    contact = nua_handle_contact_by_via(nh, home, NULL, v2, protocol, NULL);
+#else
+    contact = sip_contact_create_from_via_with_transport(home, v2, NULL, protocol);
+#endif
     v = sip_via_dup(home, v2);
 
     if (!contact || !v) {
@@ -1296,7 +1277,6 @@
     nr->nr_ready = 1, nr->nr_default = 1, nr->nr_public = public;
     nr->nr_secure = contact->m_url->url_type == url_sips;
     nr->nr_contact = contact;
-    *nr->nr_dcontact = *contact, nr->nr_dcontact->m_params = NULL;
     nr->nr_via = v;
     nr->nr_ip4 = host_is_ip4_address(contact->m_url->url_host);
     nr->nr_ip6 = !nr->nr_ip4 && host_is_ip6_reference(contact->m_url->url_host);
@@ -1466,10 +1446,7 @@
       return m;
   }
 
-  if (nr->nr_contact)
-    return nr->nr_dcontact;
-  else
-    return NULL;
+  return nr->nr_contact;
 }
 
 /** Return initial route. */
@@ -1481,7 +1458,7 @@
 sip_contact_t const *nua_stack_get_contact(nua_registration_t const *nr)
 {
   nr = nua_registration_by_aor(nr, NULL, NULL, 1);
-  return nr && nr->nr_contact ? nr->nr_dcontact : NULL;
+  return nr ? nr->nr_contact : NULL;
 }
 
 /** Add a Contact (and Route) header to request */
@@ -1505,7 +1482,7 @@
   if (nr == NULL)
     nr = nua_registration_for_request(nh->nh_nua->nua_registrations, sip);
 
-  return nua_registration_add_contact_and_route(nh, nr, msg, sip, 
+  return nua_registration_add_contact_and_route(nr, msg, sip, 
 						add_contact, 
 						add_service_route);
 }
@@ -1536,15 +1513,12 @@
     nr = nua_registration_for_response(nh->nh_nua->nua_registrations, sip,
 				       record_route, remote_contact);
 
-  return nua_registration_add_contact_and_route(nh, nr, msg, sip, 
-						1,
-						0);
+  return nua_registration_add_contact_and_route(nr, msg, sip, 1, 0);
 }
 
 /** Add a Contact (and Route) header to request */
 static 
-int nua_registration_add_contact_and_route(nua_handle_t *nh,
-					   nua_registration_t *nr,
+int nua_registration_add_contact_and_route(nua_registration_t *nr,
 					   msg_t *msg,
 					   sip_t *sip,
 					   int add_contact,
@@ -1554,63 +1528,8 @@
     return -1;
 
   if (add_contact) {
-    sip_contact_t const *m = NULL;
-    char const *m_display;
-    char const *m_username;
-    char const *m_params;
-    url_t const *u;
-
-    if (nr->nr_by_stack && nr->nr_ob) {
-      m = outbound_dialog_gruu(nr->nr_ob);
-
-      if (m)
-	return msg_header_add_dup(msg, (msg_pub_t *)sip, (void const *)m);
-
-      m = outbound_dialog_contact(nr->nr_ob);
-    }
-
-    if (m == NULL)
-      m = nr->nr_contact;
-
-    if (!m)
-      return -1;
-
-    u = m->m_url;
-
-    if (NH_PISSET(nh, m_display))
-      m_display = NH_PGET(nh, m_display);
-    else
-      m_display = m->m_display;
-
-    if (NH_PISSET(nh, m_username))
-      m_username = NH_PGET(nh, m_username);
-    else
-      m_username = m->m_url->url_user;
-
-    if (NH_PISSET(nh, m_params)) {
-      m_params = NH_PGET(nh, m_params);
-
-      if (u->url_params && m_params && strstr(u->url_params, m_params) == 0)
-	m_params = NULL;
-    }
-    else
-      m_params = NULL;
-
-    m = sip_contact_format(msg_home(msg),
-			   "%s<%s:%s%s%s%s%s%s%s%s%s>",
-			   m_display ? m_display : "",
-			   u->url_scheme,
-			   m_username ? m_username : "",
-			   m_username ? "@" : "",
-			   u->url_host,
-			   u->url_port ? ":" : "",
-			   u->url_port ? u->url_port : "",
-			   u->url_params ? ";" : "",
-			   u->url_params ? u->url_params : "",
-			   m_params ? ";" : "",
-			   m_params ? m_params : "");
-
-    if (msg_header_insert(msg, (msg_pub_t *)sip, (void *)m) < 0)
+    sip_contact_t const *m = nua_registration_contact(nr);
+    if (!m || msg_header_add_dup(msg, (msg_pub_t *)sip, (void const *)m) < 0)
       return -1;
   }
 
@@ -1699,7 +1618,7 @@
 
     if (nr0 && nr0->nr_via) {
       char const *tport = nr0->nr_via->v_next ? NULL : nr0->nr_via->v_protocol;
-      m = nua_handle_contact_by_via(nh, nh->nh_home, 0,
+      m = nua_handle_contact_by_via(nh, nh->nh_home,
 				    NULL, nr0->nr_via, tport, NULL);
     }
   }
@@ -1708,7 +1627,6 @@
     return -1;
 
   nr->nr_contact = m;
-  *nr->nr_dcontact = *m, nr->nr_dcontact->m_params = NULL;
   nr->nr_ip4 = host_is_ip4_address(m->m_url->url_host);
   nr->nr_ip6 = !nr->nr_ip4 && host_is_ip6_reference(m->m_url->url_host);
   nr->nr_by_stack = !application_contact;
@@ -1721,10 +1639,8 @@
 /** Mark registration as ready */
 void nua_registration_set_ready(nua_registration_t *nr, int ready)
 {
-  if (nr) {
-    assert(!ready || nr->nr_contact);
-    nr->nr_ready = ready;
-  }
+  assert(!ready || nr->nr_contact);
+  nr->nr_ready = ready;
 }
 
 /** @internal Hook for processing incoming request by registration.
@@ -1754,6 +1670,48 @@
   return 481;			/* Call/Transaction does not exist */
 }
 
+/**@internal
+ * Fix contacts for un-REGISTER.
+ *
+ * Remove (possible non-zero) "expires" parameters from contacts and extra
+ * contacts, add Expire: 0.
+ */
+static
+void unregister_expires_contacts(msg_t *msg, sip_t *sip)
+{
+  sip_contact_t *m;
+  int unregister_all;
+
+  if (msg == NULL || sip == NULL)
+    return;
+
+  /* Remove payload */
+  while (sip->sip_payload)
+    sip_header_remove(msg, sip, (sip_header_t *)sip->sip_payload);
+  while (sip->sip_content_type)
+    sip_header_remove(msg, sip, (sip_header_t *)sip->sip_content_type);
+
+  for (m = sip->sip_contact; m; m = m->m_next) {
+    if (m->m_url->url_type == url_any)
+      break;
+    msg_header_remove_param(m->m_common, "expires");
+#if 0
+    msg_header_add_param(msg_home(msg), m->m_common, "expires=0");
+#endif
+  }
+
+  unregister_all = m && (m != sip->sip_contact || m->m_next);
+
+  sip_add_tl(msg, sip,
+             /* Remove existing contacts */
+             TAG_IF(unregister_all, SIPTAG_CONTACT(NONE)),
+             /* Add '*' contact: 0 */
+             TAG_IF(unregister_all, SIPTAG_CONTACT_STR("*")),
+             SIPTAG_EXPIRES_STR("0"),
+             TAG_END());
+}
+
+
 /** Outbound requests us to refresh registration */
 static int nua_stack_outbound_refresh(nua_handle_t *nh,
 				      outbound_t *ob)
@@ -1800,7 +1758,7 @@
 
   nua_stack_event(nh->nh_nua, nh, NULL,
 		  nua_i_outbound, status, phrase,
-		  ta_args(ta));
+		  ta_tags(ta));
 
   ta_end(ta);
 
@@ -1817,7 +1775,7 @@
 
   nua_stack_event(nh->nh_nua, nh, NULL,
 		  nua_i_outbound, status, phrase,
-		  ta_args(ta));
+		  ta_tags(ta));
 
   ta_end(ta);
 
@@ -1837,7 +1795,6 @@
 /** @internal Generate a @Contact header. */
 sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
 					 su_home_t *home,
-					 int in_dialog,
 					 char const *extra_username,
 					 sip_via_t const *v,
 					 char const *transport,
@@ -1921,7 +1878,7 @@
     su_strlst_append(l, ";comp="), su_strlst_append(l, comp);
   s = NH_PGET(nh, m_params);
   if (s) 
-    s[0] == ';' ? "" : su_strlst_append(l, ";"), su_strlst_append(l, s);
+    su_strlst_append(l, s[0] == ';' ? "" : ";"), su_strlst_append(l, s);
   su_strlst_append(l, ">");
 
   va_start(va, m_param);
@@ -1935,42 +1892,81 @@
   
   va_end(va);
 
-  if (!in_dialog) {
-    s = NH_PGET(nh, m_features);
-    if (s) 
-      s[0] == ';' ? "" : su_strlst_append(l, ";"), su_strlst_append(l, s);
-
-    if (NH_PGET(nh, callee_caps)) {
-      sip_allow_t const *allow = NH_PGET(nh, allow);
-
-      if (allow) {
-	su_strlst_append(l, ";methods=\"");
-	if (allow->k_items) {
-	  size_t i;
-	  for (i = 0; allow->k_items[i]; i++) {
-	    su_strlst_append(l, allow->k_items[i]);
-	    if (allow->k_items[i + 1])
-	      su_strlst_append(l, ",");
-	  }
-	}
-	su_strlst_append(l, "\"");
+  m = sip_contact_make(home, su_strlst_join(l, su_strlst_home(l), ""));
+  
+  su_strlst_destroy(l);
+  
+  return m;
+}
+
+/** @internal Return a string describing our features. */
+static char *nua_handle_features(nua_handle_t *nh)
+{
+  char *retval = NULL;
+  su_strlst_t *l = su_strlst_create(NULL);
+  su_home_t *home = su_strlst_home(l);
+
+  if (!l)
+    return NULL;
+
+  if (NH_PGET(nh, m_features)) {
+    char const *m_features = NH_PGET(nh, m_features);
+
+    if (m_features[0] != ';')
+      su_strlst_append(l, ";");
+
+    su_strlst_append(l, m_features);
+  }
+
+  if (NH_PGET(nh, callee_caps)) {
+    sip_allow_t const *allow = NH_PGET(nh, allow);
+
+    if (allow) {
+      /* Skip ";" if this is first one */
+      su_strlst_append(l, ";methods=\"" + (su_strlst_len(l) == 0));
+      if (allow->k_items) {
+        size_t i;
+        for (i = 0; allow->k_items[i]; i++) {
+          su_strlst_append(l, allow->k_items[i]);
+          if (allow->k_items[i + 1])
+            su_strlst_append(l, ",");
+        }
       }
+      su_strlst_append(l, "\"");
+    }
+
+    if (nh->nh_soa) {
+      char **media = soa_media_features(nh->nh_soa, 0, home);
 
-      if (nh->nh_soa) {
-	char **media = soa_media_features(nh->nh_soa, 0, home);
-	
-	while (*media) {
-	  if (su_strlst_len(l))
-	    su_strlst_append(l, ";");
-	  su_strlst_append(l, *media++);
-	}
+      while (*media) {
+        if (su_strlst_len(l))
+          su_strlst_append(l, ";");
+        su_strlst_append(l, *media++);
       }
     }
   }
 
-  m = sip_contact_make(home, su_strlst_join(l, su_strlst_home(l), ""));
-  
+  if (su_strlst_len(l))
+    retval = su_strlst_join(l, nh->nh_home, "");
+
   su_strlst_destroy(l);
-  
-  return m;
+
+  return retval;
+}
+
+static int nua_stack_outbound_features(nua_handle_t *nh, outbound_t *ob)
+{
+  char *features;
+  int retval;
+
+  if (!nh)
+    return -1;
+  if (!ob)
+    return 0;
+
+  features = nua_handle_features(nh);
+  retval = outbound_set_features(ob, features);
+  su_free(nh->nh_home, features);
+
+  return retval;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c	Sat Feb 17 01:25:21 2007
@@ -44,6 +44,8 @@
 #include <sofia-sip/sip_status.h>
 #include <sofia-sip/sip_util.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
 #define NTA_INCOMING_MAGIC_T struct nua_handle_s
 #define NTA_RELIABLE_MAGIC_T struct nua_handle_s
 
@@ -87,19 +89,15 @@
  * @END_NUA_EVENT
  */
 
-nua_server_methods_t const nua_register_server_methods = 
-  {
-    SIP_METHOD_REGISTER,
-    nua_i_register,		/* Event */
-    { 
-      0,			/* Do not create dialog */
-      0,			/* Initial request */
-      0,			/* Not a target refresh request  */
-      0,			/* Do not add Contact */
-    },
-    nua_base_server_init,
-    nua_base_server_preprocess,
-    nua_base_server_params,
-    nua_base_server_respond,
-    nua_base_server_report,
-  };
+int nua_stack_process_register(nua_t *nua,
+			       nua_handle_t *nh,
+			       nta_incoming_t *irq,
+			       sip_t const *sip)
+{
+  nua_server_request_t *sr, sr0[1];
+
+  sr = nua_server_request(nua, nh, irq, sip, SR_INIT(sr0), sizeof *sr,
+			  nua_default_respond, 0);
+
+  return nua_stack_server_event(nua, sr, nua_i_register, TAG_END());
+}

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c	Sat Feb 17 01:25:21 2007
@@ -45,8 +45,9 @@
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/su_uniqueid.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
 #define NTA_INCOMING_MAGIC_T struct nua_server_request
-#define NTA_OUTGOING_MAGIC_T struct nua_client_request
 #define NTA_RELIABLE_MAGIC_T struct nua_handle_s
 
 #include "nua_stack.h"
@@ -140,7 +141,8 @@
 /** Session-related state */
 typedef struct nua_session_usage
 {
-  enum nua_callstate ss_state;		/**< Session status (enum nua_callstate) */
+  /* enum nua_callstate */
+  unsigned        ss_state:4;		/**< Session status (enum nua_callstate) */
   
   unsigned        ss_100rel:1;	        /**< Use 100rel, send 183 */
   unsigned        ss_alerting:1;	/**< 180 is sent/received */
@@ -150,16 +152,17 @@
   unsigned        ss_precondition:1;	/**< Precondition required */
 
   unsigned        ss_timer_set:1;       /**< We have active session timer. */
-
-  unsigned        ss_reporting:1;       /**< True if reporting state */
   unsigned        : 0;
   
   unsigned        ss_session_timer;	/**< Value of Session-Expires (delta) */
   unsigned        ss_min_se;		/**< Minimum session expires */
   enum nua_session_refresher ss_refresher; /**< none, local or remote */
 
-  char const     *ss_oa_recv, *ss_oa_sent;
-  char const     *ss_reason;	        /**< Reason for termination. */
+  char const     *ss_ack_needed;	/**< If non-null, need to send an ACK
+					 * (do O/A, if "offer" or "answer")
+					 */
+
+  nua_client_request_t ss_crequest[1];  /* Outgoing invite */
 } nua_session_usage_t;
 
 static char const *nua_session_usage_name(nua_dialog_usage_t const *du);
@@ -177,9 +180,6 @@
 				      nua_dialog_state_t *,
 				      nua_dialog_usage_t *);
 
-static int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags);
-static int nua_invite_client_deinit(nua_client_request_t *cr);
-
 static nua_usage_class const nua_session_usage[1] = {
   {
     sizeof (nua_session_usage_t),
@@ -202,11 +202,14 @@
 			   nua_dialog_state_t *ds,
 			   nua_dialog_usage_t *du)
 {
+  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+
   if (ds->ds_has_session)
     return -1;
   ds->ds_has_session = 1;
-  ds->ds_got_session = 1;
 
+  nh->nh_ds->ds_cr->cr_next = ss->ss_crequest;
+ 
   return 0;
 }
 
@@ -216,57 +219,17 @@
 			       nua_dialog_usage_t *du)
 {
   nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  nua_client_request_t *cr, *cr_next;
-
-  cr = du->du_cr;
-
-  if (cr && cr->cr_orq && cr->cr_status >= 200) {
-    ss->ss_reporting = 1;
-    nua_invite_client_ack(cr, NULL);
-    ss->ss_reporting = 0;
-  }
 
-  /* Destroy queued INVITE transactions */
-  for (cr = ds->ds_cr; cr; cr = cr_next) {
-    cr_next = cr->cr_next;
-
-    if (cr->cr_method != sip_method_invite)
-      continue;
-    if (cr == du->du_cr)
-      continue;
-
-    nua_stack_event(nh->nh_nua, nh, 
-		    NULL,
-		    cr->cr_event,
-		    SIP_481_NO_TRANSACTION,
-		    NULL);
-
-    nua_client_request_destroy(cr);
-
-    cr_next = ds->ds_cr;
-  }
-
-  
   ds->ds_has_session = 0;
-  nh->nh_has_invite = 0;
-  nh->nh_active_call = 0;
-  nh->nh_hold_remote = 0;
-
-  if (nh->nh_soa)
-    soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
-}
 
-static
-nua_dialog_usage_t *nua_dialog_usage_for_session(nua_dialog_state_t const *ds)
-{
-  if (ds == ((nua_handle_t *)NULL)->nh_ds)
-    return NULL;
+  if (ss->ss_crequest)
+    nua_creq_deinit(ss->ss_crequest, NULL);
 
-  return nua_dialog_usage_get(ds, nua_session_usage, NULL);
+  ds->ds_cr->cr_next = NULL;
 }
 
 static
-nua_session_usage_t *nua_session_usage_for_dialog(nua_dialog_state_t const *ds)
+nua_session_usage_t *nua_session_usage_get(nua_dialog_state_t const *ds)
 {
   nua_dialog_usage_t *du;
 
@@ -278,30 +241,38 @@
   return (nua_session_usage_t *)nua_dialog_usage_private(du);
 }
 
-/** Zap the session associated with the handle */
-static
-void nua_session_usage_destroy(nua_handle_t *nh,
-			       nua_session_usage_t *ss)
-{
-  /* Remove usage */
-  nua_dialog_usage_remove(nh, nh->nh_ds, nua_dialog_usage_public(ss));
-
-  SU_DEBUG_5(("nua: terminated session %p\n", (void *)nh));
-}
-
 /* ======================================================================== */
 /* INVITE and call (session) processing */
 
+static int nua_stack_invite2(nua_t *, nua_handle_t *, nua_event_t e,
+			     int restarted, tagi_t const *tags);
+static int process_response_to_invite(nua_handle_t *nh,
+				      nta_outgoing_t *orq,
+				      sip_t const *sip);
+static void
+  session_timeout(nua_handle_t *nh, nua_dialog_usage_t *du, sip_time_t now);
+
+static void restart_invite(nua_handle_t *nh, tagi_t *tags);
+
+static int process_100rel(nua_handle_t *nh,
+			  nua_session_usage_t *ss,
+			  nta_outgoing_t *orq,
+			  sip_t const *sip);
+
 int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
 		    tagi_t const *tags);
 
+static int process_response_to_prack(nua_handle_t *nh,
+				     nta_outgoing_t *orq,
+				     sip_t const *sip);
+
+static void nua_session_usage_destroy(nua_handle_t *, nua_session_usage_t *);
+
 static void session_timer_preferences(nua_session_usage_t *ss,
 				      unsigned expires,
 				      unsigned min_se,
 				      enum nua_session_refresher refresher);
-
 static int session_timer_is_supported(nua_handle_t const *nh);
-
 static int prefer_session_timer(nua_handle_t const *nh);
 
 static int use_session_timer(nua_session_usage_t *ss, int uas, int always,
@@ -309,18 +280,24 @@
 static int init_session_timer(nua_session_usage_t *ss, sip_t const *, int refresher);
 static void set_session_timer(nua_session_usage_t *ss);
 
-static int session_timer_check_restart(nua_client_request_t *cr,
-				       int status, char const *phrase,
-				       sip_t const *sip);
+static int
+check_session_timer_restart(nua_handle_t *nh,
+			    nua_session_usage_t *ss,
+			    nua_client_request_t *cr,
+			    nta_outgoing_t *orq,
+			    sip_t const *sip,
+			    nua_creq_restart_f *restart_function);
 
 static int nh_referral_check(nua_handle_t *nh, tagi_t const *tags);
 static void nh_referral_respond(nua_handle_t *,
 				int status, char const *phrase);
 
 static void signal_call_state_change(nua_handle_t *nh,
-				      nua_session_usage_t *ss,
-				      int status, char const *phrase,
-				      enum nua_callstate next_state);
+				     nua_session_usage_t *ss,
+				     int status, char const *phrase,
+				     enum nua_callstate next_state,
+				     char const *oa_recv,
+				     char const *oa_sent);
 
 static
 int session_get_description(sip_t const *sip,
@@ -342,9 +319,16 @@
 			     sip_payload_t **return_pl);
 
 static
-int nua_server_retry_after(nua_server_request_t *sr,
-			   int status, char const *phrase,
-			   int min, int max);
+int session_process_response(nua_handle_t *nh,
+			     nua_client_request_t *cr,
+			     nta_outgoing_t *orq,
+			     sip_t const *sip,
+			     char const **return_received);
+
+static
+int respond_with_retry_after(nua_handle_t *nh, nta_incoming_t *irq,
+			     int status, char const *phrase,
+			     int min, int max);
 
 /**@fn void nua_invite(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
@@ -491,456 +475,322 @@
 /* Tags not implemented
  *    NUTAG_REFER_PAUSE() \n
  */
-
-static int nua_invite_client_init(nua_client_request_t *cr, 
-				  msg_t *msg, sip_t *sip,
-				  tagi_t const *tags);
-static int nua_invite_client_request(nua_client_request_t *cr,
-				     msg_t *msg, sip_t *sip,
-				     tagi_t const *tags);
-static int nua_invite_client_preliminary(nua_client_request_t *cr,
-					 int status, char const *phrase,
-					 sip_t const *sip);
-static int nua_invite_client_response(nua_client_request_t *cr,
-				      int status, char const *phrase,
-				      sip_t const *sip);
-static int nua_session_client_response(nua_client_request_t *cr,
-				       int status, char const *phrase,
-				       sip_t const *sip);
-static int nua_invite_client_report(nua_client_request_t *cr,
-				    int status, char const *phrase,
-				    sip_t const *sip,
-				    nta_outgoing_t *orq,
-				    tagi_t const *tags);
-
-nua_client_methods_t const nua_invite_client_methods = {
-  SIP_METHOD_INVITE,
-  0,
-  { 
-    /* create_dialog */ 1,
-    /* in_dialog */ 1,
-    /* target refresh */ 1
-  },
-  NULL,
-  nua_invite_client_init,
-  nua_invite_client_request,
-  session_timer_check_restart,
-  nua_invite_client_response,
-  nua_invite_client_preliminary,
-  nua_invite_client_report,
-  nua_invite_client_deinit
-};
-
-extern nua_client_methods_t const nua_bye_client_methods;
-extern nua_client_methods_t const nua_cancel_client_methods;
-extern nua_client_methods_t const nua_info_client_methods;
-extern nua_client_methods_t const nua_update_client_methods;
-extern nua_client_methods_t const nua_prack_client_methods;
-
-int nua_stack_invite(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-		     tagi_t const *tags)
-{
-  return nua_client_create(nh, e, &nua_invite_client_methods, tags);
-}
-
-static int nua_invite_client_init(nua_client_request_t *cr, 
-				  msg_t *msg, sip_t *sip,
-				  tagi_t const *tags)
+int
+nua_stack_invite(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		 tagi_t const *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du;
+  char const *what;
 
-  cr->cr_usage = du = nua_dialog_usage_for_session(nh->nh_ds);
-  /* Errors returned by nua_invite_client_init() 
-     are neutral to session state */
-  cr->cr_neutral = 1;	
-  
   if (nh_is_special(nh) || 
       nua_stack_set_handle_special(nh, nh_has_invite, nua_i_error))
-    return nua_client_return(cr, 900, "Invalid handle for INVITE", msg);
-  else if (nh_referral_check(nh, tags) < 0)
-    return nua_client_return(cr, 900, "Invalid referral", msg);
-
-  if (du) {
-    nua_server_request_t *sr;
-    for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
-      /* INVITE in progress? */
-      if (sr->sr_usage == du && sr->sr_method == sip_method_invite &&
-	  nua_server_request_is_pending(sr))
-	return nua_client_return(cr, SIP_491_REQUEST_PENDING, msg);
+    what = "Invalid handle for INVITE";
+  else if (nh_referral_check(nh, tags) < 0) {
+    what = "Invalid referral";
+  }
+  else if (nua_stack_init_handle(nua, nh, TAG_NEXT(tags)) < 0) {
+    what = "Handle initialization failed";
   }
   else
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_session_usage, NULL);
-  if (!du)
-    return -1;
-
-  if (nua_client_bind(cr, du) < 0)
-    return nua_client_return(cr, 900, "INVITE already in progress", msg);
+    return nua_stack_invite2(nua, nh, e, 0, tags);
 
-  session_timer_preferences(nua_dialog_usage_private(du), 
-			    NH_PGET(nh, session_timer),
-			    NH_PGET(nh, min_se),
-			    NH_PGET(nh, refresher));
+  UA_EVENT2(e, 900, what);
 
-  cr->cr_neutral = 0;
+  signal_call_state_change(nh, NULL, 900, what, nua_callstate_init, 0, 0);
 
-  return 0;
+  return e;
 }
 
-static int nua_invite_client_request(nua_client_request_t *cr,
-				     msg_t *msg, sip_t *sip,
-				     tagi_t const *tags)
+static int
+nua_stack_invite2(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		  int restarted,
+		  tagi_t const *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  int offer_sent = 0, retval;
-  sip_time_t invite_timeout;
-
-  if (du == NULL)		/* Call terminated */ 
-    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
+  nua_dialog_usage_t *du;
+  nua_session_usage_t *ss;
+  nua_client_request_t *cr;
+  int offer_sent = 0;
 
-  assert(ss);
+  msg_t *msg = NULL;
+  sip_t *sip = NULL;
 
-  invite_timeout = NH_PGET(nh, invite_timeout);
-  if (invite_timeout == 0)
-    invite_timeout = UINT_MAX;
-  /* Send CANCEL if we don't get response within timeout*/
-  nua_dialog_usage_set_expires(du, invite_timeout);
-  nua_dialog_usage_set_refresh(du, 0);
-
-  /* Add session timer headers */
-  if (session_timer_is_supported(nh))
-    use_session_timer(ss, 0, prefer_session_timer(nh), msg, sip);
+  char const *what;
 
-  ss->ss_100rel = NH_PGET(nh, early_media);
-  ss->ss_precondition = sip_has_feature(sip->sip_require, "precondition");
-  if (ss->ss_precondition)
-    ss->ss_update_needed = ss->ss_100rel = 1;
+  du = nua_dialog_usage_add(nh, nh->nh_ds, nua_session_usage, NULL);
+  ss = nua_dialog_usage_private(du);
+  cr = ss->ss_crequest;
+  what = nua_internal_error;		/* Internal error */
 
-  if (nh->nh_soa) {
-    soa_init_offer_answer(nh->nh_soa);
+  if (du == NULL)
+    goto failure;
 
-    if (sip->sip_payload)
-      offer_sent = 0;		/* XXX - kludge */
-    else if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0)
-      return -1;
-    else
-      offer_sent = 1;
+  if (cr->cr_orq) {
+    what = "INVITE request already in progress";
+    goto failure;
   }
 
-  if (offer_sent > 0 &&
-      session_include_description(nh->nh_soa, 1, msg, sip) < 0)
-    return nua_client_return(cr, 900, "Internal media error", msg);
-
-  if (nh->nh_soa &&
-      NH_PGET(nh, media_features) &&
-      !nua_dialog_is_established(nh->nh_ds) &&
-      !sip->sip_accept_contact && !sip->sip_reject_contact) {
-    sip_accept_contact_t ac[1];
-    sip_accept_contact_init(ac);
-
-    ac->cp_params = (msg_param_t *)
-      soa_media_features(nh->nh_soa, 1, msg_home(msg));
-
-    if (ac->cp_params) {
-      msg_header_replace_param(msg_home(msg), ac->cp_common, "explicit");
-      sip_add_dup(msg, sip, (sip_header_t *)ac);
-    }
-  }
+  if (ss->ss_state == nua_callstate_terminated)
+    ss->ss_state = nua_callstate_init;
 
-  retval = nua_base_client_trequest(cr, msg, sip,
-				    NTATAG_REL100(ss->ss_100rel),
-				    TAG_NEXT(tags));
-  if (retval == 0) {
-    cr->cr_offer_sent = offer_sent;
-    ss->ss_oa_sent = offer_sent ? "offer" : NULL;
-
-    if (!cr->cr_restarting)
-      signal_call_state_change(nh, ss, 0, "INVITE sent", 
-			       nua_callstate_calling);
+  if (!restarted) {
+    session_timer_preferences(ss, 
+			      NH_PGET(nh, session_timer),
+			      NH_PGET(nh, min_se),
+			      NH_PGET(nh, refresher));
   }
 
-  return retval;
-}
+  if (restarted && !cr->cr_msg) {
+    if (du->du_msg)
+      cr->cr_msg = msg_dup(du->du_msg);
+    else
+      restarted = 0;
+  }
 
-static int nua_invite_client_response(nua_client_request_t *cr,
-				      int status, char const *phrase,
-				      sip_t const *sip)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  msg = nua_creq_msg(nua, nh, cr, restarted,
+		     SIP_METHOD_INVITE,
+		     NUTAG_USE_DIALOG(1),
+		     NUTAG_ADD_CONTACT(1),
+		     TAG_NEXT(tags));
+  sip = sip_object(msg);
 
-  if (ss == NULL || sip == NULL) {
-    /* Xyzzy */
+  if (!sip) {
+    what = "Cannot Initialize Request";
+    goto failure;
   }
-  else if (status < 300) {
-    du->du_ready = 1;
 
-    init_session_timer(ss, sip, NH_PGET(nh, refresher));
-    set_session_timer(ss);
+  if (!restarted) {
+    msg_destroy(du->du_msg), du->du_msg = msg_dup(msg);
   }
-  
-  return nua_session_client_response(cr, status, phrase, sip);
-}
 
-static int nua_invite_client_preliminary(nua_client_request_t *cr,
-					 int status, char const *phrase,
-					 sip_t const *sip)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-
-  assert(sip); assert(ss);
+  if (nh->nh_soa) {
+    soa_init_offer_answer(nh->nh_soa);
 
-  if (ss && sip && sip->sip_rseq) {
-    /* Handle 100rel responses */
-    sip_rseq_t *rseq = sip->sip_rseq;
-
-    /* Establish early dialog - we should fork here */
-    if (!nua_dialog_is_established(nh->nh_ds)) {
-      nta_outgoing_t *tagged;
-
-      nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
-      nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-      
-      /* Tag the INVITE request */
-      tagged = nta_outgoing_tagged(cr->cr_orq,
-				   nua_client_orq_response, cr,
-				   sip->sip_to->a_tag, sip->sip_rseq);
-      if (tagged) {
-	nta_outgoing_destroy(cr->cr_orq), cr->cr_orq = tagged;
-      }
-      else {
-	cr->cr_graceful = 1;
-	ss->ss_reason = "SIP;cause=500;text=\"Cannot Create Early Dialog\"";
-      }
-    }
-  
-    if (!rseq) {
-      SU_DEBUG_5(("nua(%p): 100rel missing RSeq\n", (void *)nh));
-    }
-    else if (nta_outgoing_rseq(cr->cr_orq) > rseq->rs_response) {
-      SU_DEBUG_5(("nua(%p): 100rel bad RSeq %u (got %u)\n", (void *)nh, 
-		  (unsigned)rseq->rs_response,
-		  nta_outgoing_rseq(cr->cr_orq)));
-      return 1;    /* Do not send event */
-    }
-    else if (nta_outgoing_setrseq(cr->cr_orq, rseq->rs_response) < 0) {
-      SU_DEBUG_1(("nua(%p): cannot set RSeq %u\n", (void *)nh, 
-		  (unsigned)rseq->rs_response));
-      cr->cr_graceful = 1;
-      ss->ss_reason = "SIP;cause=400;text=\"Bad RSeq\"";
-    }
+    if (sip->sip_payload)
+      offer_sent = 0;
+    else if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0)
+      offer_sent = -1;
+    else
+      offer_sent = 1;
   }
 
-  return nua_session_client_response(cr, status, phrase, sip);
-}
+  if (offer_sent >= 0) {
+    sip_time_t invite_timeout = NH_PGET(nh, invite_timeout);
+    if (invite_timeout == 0)
+      invite_timeout = UINT_MAX;
+    /* Cancel if we don't get response within timeout*/
+    nua_dialog_usage_set_expires(du, invite_timeout);
+    nua_dialog_usage_set_refresh(du, 0);
 
-/** Process response to a session request (INVITE, PRACK, UPDATE) */
-static int nua_session_client_response(nua_client_request_t *cr,
-				       int status, char const *phrase,
-				       sip_t const *sip)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+    /* Add session timer headers */
+    if (session_timer_is_supported(nh))
+      use_session_timer(ss, 0, prefer_session_timer(nh), msg, sip);
 
-  char const *sdp = NULL;
-  size_t len;
-  char const *received = NULL;
+    ss->ss_100rel = NH_PGET(nh, early_media);
+    ss->ss_precondition = sip_has_feature(sip->sip_require, "precondition");
 
-#define LOG3(m) \
-  SU_DEBUG_3(("nua(%p): %s: %s %s in %u %s\n", \
-	      (void *)nh, cr->cr_method_name, (m),		\
-	      received ? received : "SDP", status, phrase))
-#define LOG5(m) \
-  SU_DEBUG_5(("nua(%p): %s: %s %s in %u %s\n", \
-	      (void *)nh, cr->cr_method_name, (m), received, status, phrase))
+    if (ss->ss_precondition)
+      ss->ss_update_needed = ss->ss_100rel = 1;
 
-  if (nh->nh_soa == NULL || !ss || !sip || 300 <= status)
-    /* Xyzzy */;
-  else if (!session_get_description(sip, &sdp, &len))
-    /* No SDP */;
-  else if (cr->cr_answer_recv) {
-    /* Ignore spurious answers after completing O/A */
-    LOG3("ignoring duplicate");
-    sdp = NULL;
-  }
-  else if (cr->cr_offer_sent) {
-    /* case 1: incoming answer */
-    cr->cr_answer_recv = status;
-    received = "answer";
+    if (offer_sent > 0 &&
+	session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+      what = "Internal media error"; goto failure;
+    }
 
-    if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
-      LOG3("error parsing SDP");
-      sdp = NULL;
-      cr->cr_graceful = 1;
-      ss->ss_reason = "SIP;cause=400;text=\"Malformed Session Description\"";
+    if (nh->nh_soa &&
+	NH_PGET(nh, media_features) && !nua_dialog_is_established(nh->nh_ds) &&
+	!sip->sip_accept_contact && !sip->sip_reject_contact) {
+      sip_accept_contact_t ac[1];
+      sip_accept_contact_init(ac);
+
+      ac->cp_params = (msg_param_t *)
+	soa_media_features(nh->nh_soa, 1, msg_home(msg));
+
+      if (ac->cp_params) {
+	msg_header_replace_param(msg_home(msg), ac->cp_common, "explicit");
+	sip_add_dup(msg, sip, (sip_header_t *)ac);
+      }
     }
-    else if (soa_process_answer(nh->nh_soa, NULL) < 0) {
-      LOG5("error processing SDP");
-      /* XXX */
-      sdp = NULL;
+
+    if (nh->nh_auth) {
+      if (auc_authorize(&nh->nh_auth, msg, sip) < 0) {
+	what = "Internal authentication error"; goto failure;
+      }
     }
-    else if (soa_activate(nh->nh_soa, NULL) < 0)
-      /* XXX - what about errors? */
-      LOG3("error activating media after");
-    else
-      LOG5("processed SDP");
-  }
-  else if (cr->cr_method != sip_method_invite) {
-    /* If non-invite request did not have offer, ignore SDP in response */
-    LOG3("ignoring extra");
-    sdp = NULL;
-  }
-  else {
-    /* case 2: answer to our offer */
-    cr->cr_offer_recv = 1, cr->cr_answer_sent = 0;
-    received = "offer";
 
-    if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
-      LOG3("error parsing SDP");
-      sdp = NULL;
-      cr->cr_graceful = 1;
-      ss->ss_reason = "SIP;cause=400;text=\"Malformed Session Description\"";
+      cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+					process_response_to_invite, nh, NULL,
+					msg,
+					NTATAG_REL100(ss->ss_100rel),
+					SIPTAG_END(), TAG_NEXT(tags));
+
+    if (cr->cr_orq) {
+      cr->cr_offer_sent = offer_sent;
+      cr->cr_usage = du;
+      du->du_refresh = 0;
+      signal_call_state_change(nh, ss, 0, "INVITE sent",
+			       nua_callstate_calling, 0,
+			       offer_sent ? "offer" : 0);
+      return cr->cr_event = e;
     }
-    else 
-      LOG5("got SDP");
   }
 
-  if (ss && received)
-    ss->ss_oa_recv = received;
+ failure:
 
-  if (sdp)
-    return nua_base_client_tresponse(cr, status, phrase, sip,
-				     NH_REMOTE_MEDIA_TAGS(1, nh->nh_soa),
-				     TAG_END());
-  else
-    return nua_base_client_response(cr, status, phrase, sip, NULL);
-}
+  msg_destroy(msg);
+  if (du && !du->du_ready)
+    nua_dialog_usage_remove(nh, nh->nh_ds, du), ss = NULL;
 
-static int nua_invite_client_report(nua_client_request_t *cr,
-				    int status, char const *phrase,
-				    sip_t const *sip,
-				    nta_outgoing_t *orq,
-				    tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  unsigned next_state;
-  int error;
+  UA_EVENT2(e, 900, what);
+  signal_call_state_change(nh, ss, 900, what, nua_callstate_init, 0, 0);
 
-  nh_referral_respond(nh, status, phrase);
+  return e;
+}
 
-  nua_stack_event(nh->nh_nua, nh, 
-		  nta_outgoing_getresponse(orq),
-		  cr->cr_event,
-		  status, phrase,
-		  tags);
+/** @NUA_EVENT nua_r_invite
+ *
+ * Answer to outgoing INVITE.
+ *
+ * The INVITE may be sent explicitly by nua_invite() or
+ * implicitly by NUA state machine.
+ *
+ * @param status response status code
+ *               (if the request is retried, @a status is 100, the @a
+ *               sip->sip_status->st_status contain the real status code
+ *               from the response message, e.g., 302, 401, or 407)
+ * @param phrase a short textual description of @a status code
+ * @param nh     operation handle associated with the call
+ * @param hmagic application context associated with the call
+ * @param sip    response message to INVITE or NULL upon an error
+ *               (status code is in @a status and 
+ *                descriptive message in @a phrase parameters)
+ * @param tags   empty
+ *
+ * @sa nua_invite(), @ref nua_call_model, #nua_i_state, #nua_i_invite, 
+ * nua_ack(), NUTAG_AUTOACK()
+ * 
+ * @END_NUA_EVENT
+ */
+
+static int process_response_to_invite(nua_handle_t *nh,
+				      nta_outgoing_t *orq,
+				      sip_t const *sip)
+{
+  nua_t *nua = nh->nh_nua;
+  nua_client_request_t *cr;
+  nua_dialog_usage_t *du;
+  nua_session_usage_t *ss;
+  int status = sip->sip_status->st_status;
+  char const *phrase = sip->sip_status->st_phrase;
+  int terminated = 0;
+  int gracefully = 1;
+  char const *received = NULL;
 
-  if (orq != cr->cr_orq && status != 100)
-    return 1;
+  cr = nua_client_request_by_orq(nh->nh_ds->ds_cr, orq);
+  du = cr ? cr->cr_usage : NULL;
+  ss = nua_dialog_usage_private(du);
+  
+  assert(cr && du && ss);
 
-  if (ss == NULL) {
-    signal_call_state_change(nh, ss, status, phrase, nua_callstate_terminated);
-    return 1;
+  if (ss->ss_state == nua_callstate_terminating && 200 <= status) {
+    /*
+     * If the call is being terminated but re-INVITE was responded with 2XX
+     * re-send the BYE, otherwise terminate the call.
+     */
+    gracefully = status < 300, terminated = !gracefully;
   }
+  else if (status >= 300) {
+    if (sip->sip_retry_after)
+      gracefully = 0;
 
-  ss->ss_reporting = 1;
+    terminated = sip_response_terminates_dialog(status, sip_method_invite,
+						&gracefully);
 
-  if (cr->cr_neutral) {
-    signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
-    ss->ss_reporting = 0;
-    return 1;
-  }
+    if (!terminated) {
+      if (check_session_timer_restart(nh, ss, cr, orq, sip, restart_invite))
+	return 0;
 
-  if (status == 100) {
-    next_state = nua_callstate_calling;
-  }
-  else if (status < 300 && cr->cr_graceful) {
-    next_state = nua_callstate_terminating;
-    if (200 <= status) {
-      nua_invite_client_ack(cr, NULL);
+      if (ss->ss_state < nua_callstate_ready)
+	terminated = 1;
     }
   }
-  else if (status < 200) {
-    next_state = nua_callstate_proceeding;
-    if (sip && sip->sip_rseq) {
-      sip_rack_t rack[1];
+  else if (status >= 200) {
+    du->du_ready = 1;
+    cr->cr_usage = NULL;
 
-      sip_rack_init(rack);
-      rack->ra_response    = sip->sip_rseq->rs_response;
-      rack->ra_cseq        = sip->sip_cseq->cs_seq;
-      rack->ra_method      = sip->sip_cseq->cs_method;
-      rack->ra_method_name = sip->sip_cseq->cs_method_name;
+    /* XXX - check remote tag, handle forks */
+    /* Set route, contact, nh_ds->ds_remote_tag */
+    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
 
-      error = nua_client_tcreate(nh, nua_r_prack, &nua_prack_client_methods, 
-				 SIPTAG_RACK(rack),
-				 TAG_END());
-      if (error < 0) {
-	cr->cr_graceful = 1;
-	next_state = nua_callstate_terminating;
-      }
+    init_session_timer(ss, sip, NH_PGET(nh, refresher));
+    set_session_timer(ss);
+
+    /* signal_call_state_change */
+    if (session_process_response(nh, cr, orq, sip, &received) >= 0) {
+      ss->ss_ack_needed = received ? received : "";
+
+      if (NH_PGET(nh, auto_ack) ||
+	  /* Auto-ACK response to re-INVITE unless auto_ack is set to 0 */
+	  (ss->ss_state == nua_callstate_ready &&
+	   !NH_PISSET(nh, auto_ack)))
+	nua_stack_ack(nua, nh, nua_r_ack, NULL);
+      else
+	signal_call_state_change(nh, ss, status, phrase,
+				 nua_callstate_completing, received, 0);
+      nh_referral_respond(nh, SIP_200_OK);
+      return 0;
     }
+
+    status = 500, phrase = "Malformed Session in Response";
+
+    nua_stack_ack(nua, nh, nua_r_ack, NULL);
+    gracefully = 1;
   }
-  else if (status < 300) {
-    next_state = nua_callstate_completing;
-  }
-  else if (cr->cr_terminated) {
-    next_state = nua_callstate_terminated;
-  }
-  else if (cr->cr_graceful && ss->ss_state >= nua_callstate_completing) {
-    next_state = nua_callstate_terminating;
+  else if (sip->sip_rseq) {
+    /* Reliable provisional response */
+    nh_referral_respond(nh, status, phrase);
+
+    return process_100rel(nh, ss, orq, sip); /* signal_call_state_change */
   }
   else {
-    next_state = nua_callstate_init;
-  }
-
-  if (next_state == nua_callstate_calling) {
-    if (sip && sip->sip_status && sip->sip_status->st_status == 100) {
-      ss->ss_reporting = 0;
-      return 1;
-    }
+    /* Provisional response */
+    nh_referral_respond(nh, status, phrase);
+    session_process_response(nh, cr, orq, sip, &received);
+    signal_call_state_change(nh, ss, status, phrase,
+			     nua_callstate_proceeding, received, 0);
+    return 0;
   }
 
-  if (next_state == nua_callstate_completing) {
-    if (NH_PGET(nh, auto_ack) ||
-	/* Auto-ACK response to re-INVITE unless auto_ack is set to 0 */
-	(ss->ss_state == nua_callstate_ready &&
-	 !NH_PISSET(nh, auto_ack))) {
+  cr->cr_usage = NULL;
 
-      if (nua_invite_client_ack(cr, NULL) > 0)
-	next_state = nua_callstate_ready;
-      else
-	next_state = nua_callstate_terminating;
-    }
-  }
+  nh_referral_respond(nh, status, phrase);
+  nua_stack_process_response(nh, cr, orq, sip, TAG_END());
 
-  if (next_state == nua_callstate_terminating) {
-    /* Send BYE or CANCEL */
-    /* XXX - Forking - send BYE to early dialog?? */
-    if (ss->ss_state > nua_callstate_proceeding || status >= 200)
-      error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
-    else
-      error = nua_client_create(nh, nua_r_cancel, 
-				&nua_cancel_client_methods, tags);
+  if (terminated)
+    signal_call_state_change(nh, ss, status, phrase,
+			     nua_callstate_terminated, 0, 0);
 
-    if (error) {
-      next_state = nua_callstate_terminated;
-      cr->cr_terminated = 1;
-    }
-    cr->cr_graceful = 0;
+  if (terminated < 0) {
+    nua_dialog_terminated(nh, nh->nh_ds, status, phrase);
   }
+  else if (terminated > 0) {
+    nua_dialog_usage_remove(nh, nh->nh_ds, du);
+  }
+  else if (gracefully) {
+    char *reason =
+      su_sprintf(NULL, "SIP;cause=%u;text=\"%s\"", 
+		 status > 699 ? 500 : status, phrase);
 
-  ss->ss_reporting = 0;
+    signal_call_state_change(nh, ss, status, phrase,
+			     nua_callstate_terminating, 0, 0);
 
-  signal_call_state_change(nh, ss, status, phrase, next_state);
+    nua_stack_post_signal(nh, nua_r_bye,
+			  SIPTAG_REASON_STR(reason),
+			  TAG_END());
 
-  return 1;
+    su_free(NULL, reason);
+  }
+
+  return 0;
 }
 
 /**@fn void nua_ack(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
@@ -948,7 +798,7 @@
  * Acknowledge a succesful response to INVITE request.
  *
  * Acknowledge a successful response (200..299) to INVITE request with the
- * SIP ACK request message. This function is needed only if NUTAG_AUTOACK()
+ * SIP ACK request message. This function is need only if NUTAG_AUTOACK()
  * parameter has been cleared.
  *
  * @param nh              Pointer to operation handle
@@ -962,7 +812,7 @@
  *
  * @par Events:
  *    #nua_i_media_error \n
- *    #nua_i_state  (#nua_i_active, #nua_i_terminating, #nua_i_terminated) 
+ *    #nua_i_state  (#nua_i_active, #nua_i_terminated) 
  *
  * @sa NUTAG_AUTOACK(), @ref nua_call_model, #nua_i_state
  */
@@ -970,187 +820,201 @@
 int nua_stack_ack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
 		  tagi_t const *tags)
 {
-  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  nua_client_request_t *cr = du ? du->du_cr : NULL;
-  int error;
+  nua_session_usage_t *ss;
+  nua_client_request_t *cr;
+  nta_outgoing_t *ack = NULL;
+  msg_t *msg;
+  sip_t *sip;
+  int status = 200;
+  char const *phrase = "OK", *reason = NULL, *sent = NULL;
+  char const *received;
 
-  if (!cr || cr->cr_orq == NULL || cr->cr_status < 200) {
-    UA_EVENT2(nua_i_error, 900, "No response to ACK");
-    return 1;
-  }
+  ss = nua_session_usage_get(nh->nh_ds);
+  cr = ss->ss_crequest;
 
-  if (tags) {
-    nua_stack_set_params(nua, nh, nua_i_error, tags);
-    if (nh->nh_soa)
-      soa_set_params(nh->nh_soa, TAG_NEXT(tags));
-  }
+  received = ss ? ss->ss_ack_needed : NULL;
 
-  error = nua_invite_client_ack(cr, tags);
+  if (!received)
+    return UA_EVENT2(nua_i_error, 900, "No response to ACK");
 
-  if (error < 0) {
-    ss->ss_reason = "SIP;cause=500;text=\"Internal Error\"";
-    ss->ss_reporting = 1;	/* We report state here if BYE fails */
-    error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
-    ss->ss_reporting = 0;
-    signal_call_state_change(nh, ss, 500, "Internal Error", 
-			     error 
-			     ? nua_callstate_terminated
-			     : nua_callstate_terminating);
-  }
-  else {
-    if (!nua_client_is_queued(cr) && !nua_client_is_bound(cr))
-      nua_client_request_destroy(cr);
+  ss->ss_ack_needed = 0;
 
-    nua_client_init_requests(nh->nh_ds->ds_cr, cr, 1);
-  }
+  if (!received[0])
+    received = NULL;
 
-  return 0;
-}
+  if (tags)
+    nua_stack_set_params(nua, nh, nua_i_error, tags);
 
-/** Send ACK, destroy INVITE transaction.
- *
- *  @retval 1 if successful
- *  @retval < 0 if an error occurred
- */
-static
-int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
+  msg = nua_creq_msg(nua, nh, cr, 0,
+		     SIP_METHOD_ACK,
+		     /* NUTAG_COPY(0), */
+		     TAG_NEXT(tags));
+  sip = sip_object(msg);
 
-  msg_t *msg;
-  sip_t *sip;
-  int error = -1;
-  sip_authorization_t *wa;
-  sip_proxy_authorization_t *pa;
-  sip_cseq_t *cseq;
-  nta_outgoing_t *ack;
-  int status = 200;
-  char const *phrase = "OK", *reason = NULL;
-
-  assert(ds->ds_leg);
-  assert(cr->cr_orq);
-
-  msg = nta_outgoing_getrequest(cr->cr_orq);
-  sip = sip_object(msg);  
-  if (!msg)
-    return -1;
-  
-  wa = sip_authorization(sip);
-  pa = sip_proxy_authorization(sip);
-  
-  msg_destroy(msg);
-
-  msg = nta_msg_create(nh->nh_nua->nua_nta, 0);
-  sip = sip_object(msg);  
-  if (!msg)
-    return -1;
-
-  cseq = sip_cseq_create(msg_home(msg), cr->cr_seq, SIP_METHOD_ACK);
+  if (sip && nh->nh_soa) {
+    if (tags)
+      soa_set_params(nh->nh_soa, TAG_NEXT(tags));
 
-  if (!cseq)
-    ;
-  else if (nh->nh_tags && sip_add_tl(msg, sip, TAG_NEXT(nh->nh_tags)) < 0)
-    ;
-  else if (tags && sip_add_tl(msg, sip, TAG_NEXT(tags)) < 0)
-    ;
-  else if (wa && sip_add_dup(msg, sip, (sip_header_t *)wa) < 0)
-    ;
-  else if (pa && sip_add_dup(msg, sip, (sip_header_t *)pa) < 0)
-    ;
-  else if (sip_header_insert(msg, sip, (sip_header_t *)cseq) < 0)
-    ;
-  else if (nta_msg_request_complete(msg, ds->ds_leg, SIP_METHOD_ACK, NULL) < 0)
-    ;
-  else {
-    /* Remove extra headers */
-    while (sip->sip_allow)
-      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_allow);
-    while (sip->sip_priority)
-      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_priority);
-    while (sip->sip_proxy_require)
-      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_proxy_require);
-    while (sip->sip_require)
-      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_require);
-    while (sip->sip_subject)
-      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_subject);
-    while (sip->sip_supported)
-      sip_header_remove(msg, sip, (sip_header_t*)sip->sip_supported);
-
-    if (!nh->nh_soa || ss == NULL)
-      ;
-    else if (cr->cr_offer_recv && !cr->cr_answer_sent) {
+    if (cr->cr_offer_recv && !cr->cr_answer_sent) {
       if (soa_generate_answer(nh->nh_soa, NULL) < 0 ||
 	  session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+	reason = soa_error_as_sip_reason(nh->nh_soa);
 	status = 900, phrase = "Internal media error";
 	reason = "SIP;cause=500;text=\"Internal media error\"";
-	/* reason = soa_error_as_sip_reason(nh->nh_soa); */
       }
       else {
 	cr->cr_answer_sent = 1;
 	soa_activate(nh->nh_soa, NULL);
+
 	/* signal that O/A round is complete */
-	ss->ss_oa_sent = "answer";
-      }
-      
-      if (!reason &&
-	  /* ss->ss_offer_sent && !ss->ss_answer_recv */
-	  !soa_is_complete(nh->nh_soa)) {
-	/* No SDP answer in 2XX response -> terminate call */
-	status = 988, phrase = "Incomplete offer/answer";
-	reason = "SIP;cause=488;text=\"Incomplete offer/answer\"";
+	sent = "answer";
       }
     }
-    
-    if ((ack = nta_outgoing_mcreate(nh->nh_nua->nua_nta, NULL, NULL, NULL,
-				    msg,
-				    SIPTAG_END(),
-				    TAG_NEXT(tags)))) {
-      nta_outgoing_destroy(ack);	/* TR engine keeps this around for T2 */
+
+    if (!reason &&
+	/* ss->ss_offer_sent && !ss->ss_answer_recv */
+	!soa_is_complete(nh->nh_soa)) {
+      /* No SDP answer in 2XX response -> terminate call */
+      status = 988, phrase = "Incomplete offer/answer";
+      reason = "SIP;cause=488;text=\"Incomplete offer/answer\"";
     }
-    else if (!reason) {
+  }
+
+  if (sip) {
+    msg_t *imsg = nta_outgoing_getrequest(cr->cr_orq);
+    sip_t const *isip = sip_object(imsg);
+    if (isip->sip_proxy_authorization)
+      sip_add_dup(msg, sip, (void *)isip->sip_proxy_authorization);
+    if (isip->sip_authorization)
+      sip_add_dup(msg, sip, (void *)isip->sip_authorization);
+    msg_destroy(imsg);
+  }
+
+  if (sip)
+    ack = nta_outgoing_mcreate(nua->nua_nta, NULL, NULL, NULL, msg,
+			       SIPTAG_END(), TAG_NEXT(tags));
+
+  if (!ack) {
+    if (!reason) {
       status = 900, phrase = "Cannot send ACK";
       reason = "SIP;cause=500;text=\"Internal Error\"";
     }
+    msg_destroy(msg);
+  }
 
-    if (ss && reason)
-      ss->ss_reason = reason;
+  nua_creq_deinit(cr, NULL);	/* Destroy INVITE transaction */
+  nta_outgoing_destroy(ack);	/* TR engine keeps this around for T2 */
 
-    if (status < 300)
-      error = 1;
-    else
-      error = -2;
+  if (status < 300) {
+    signal_call_state_change(nh, ss, status, phrase, nua_callstate_ready,
+			     received, sent);
   }
+  else {
+    signal_call_state_change(nh, ss, status, phrase, nua_callstate_terminating,
+			     0, 0);
+    nua_stack_post_signal(nh, nua_r_bye,
+			  SIPTAG_REASON_STR(reason),
+			  TAG_END());
+  }
+
+  return 0;
+}
 
-  nta_outgoing_destroy(cr->cr_orq), cr->cr_orq = NULL;
-  nua_client_request_remove(cr);
 
-  if (ss) {
-    if (!ss->ss_reporting && error >= 0)
-      signal_call_state_change(nh, ss, status, phrase, nua_callstate_ready);
+/* Process reliable provisional response */
+static int
+process_100rel(nua_handle_t *nh,
+	       nua_session_usage_t *ss,
+	       nta_outgoing_t *orq,
+	       sip_t const *sip)
+{
+  nua_client_request_t *cr_invite = ss->ss_crequest;
+  nua_client_request_t *cr_prack = nh->nh_ds->ds_cr;
+  
+  sip_rseq_t *rseq;
+  char const *recv = NULL;
+  int status; char const *phrase;
+
+  if (cr_prack->cr_orq) {
+    /* XXX - better luck next time */
+    SU_DEBUG_3(("nua(%p): cannot send PRACK because %s is pending\n", nh,
+		nta_outgoing_method_name(cr_prack->cr_orq)));
+    return 0; /* Wait until this response is re-transmitted */
+  }
+
+  if (!nua_dialog_is_established(nh->nh_ds)) {
+    /* Establish early dialog */
+    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+    
+    /* Tag the INVITE request */
+    cr_invite->cr_orq =
+      nta_outgoing_tagged(orq, process_response_to_invite, nh,
+			  sip->sip_to->a_tag, sip->sip_rseq);
+    nta_outgoing_destroy(orq);
+    orq = cr_invite->cr_orq;
   }
   
-  return error;
-}
+  assert(sip);
 
-/** Deinitialize client request */
-static int nua_invite_client_deinit(nua_client_request_t *cr)
-{
-  if (cr->cr_orq == NULL)
-    /* Xyzzy */;
-  else if (cr->cr_status < 200)
-    nta_outgoing_cancel(cr->cr_orq);
-  else
-    nua_invite_client_ack(cr, NULL);
+  status = sip->sip_status->st_status, phrase = sip->sip_status->st_phrase;
+  rseq = sip->sip_rseq;
+
+  if (!rseq) {
+    SU_DEBUG_5(("nua(%p): 100rel missing RSeq\n", nh));
+  }
+  else if (rseq->rs_response <= nta_outgoing_rseq(orq)) {
+    SU_DEBUG_5(("nua(%p): 100rel bad RSeq %u (got %u)\n", nh, 
+		(unsigned)rseq->rs_response,
+		nta_outgoing_rseq(orq)));
+    /* XXX - send nua_r_invite event or not? */
+    return 0;
+  }
+  else if (nta_outgoing_setrseq(orq, rseq->rs_response) < 0) {
+    SU_DEBUG_1(("nua(%p): cannot set RSeq %u\n", nh, 
+		(unsigned)rseq->rs_response));
+  }
+  else if (session_process_response(nh, cr_invite, orq, sip, &recv) < 0) {
+    assert(nh->nh_soa);
+    status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+    nua_stack_event(nh->nh_nua, nh, NULL,
+		    nua_i_media_error, status, phrase, TAG_END());
+  }
+  /* Here we could let application PRACK and just send state event */
+  else {
+    sip_rack_t rack[1];
+    tagi_t tags[] = {
+      { TAG_SKIP(nua_stack_prack) }, /* this is autoprack */
+      { NUTAG_STATUS(status), },
+      { NUTAG_PHRASE(phrase), },
+      { NUTAG_PHRASE(recv), },
+      { SIPTAG_RACK(rack) }, 
+      { TAG_END() }
+    };
+
+    sip_rack_init(rack);
+
+    rack->ra_response    = sip->sip_rseq->rs_response;
+    rack->ra_cseq        = sip->sip_cseq->cs_seq;
+    rack->ra_method      = sip->sip_cseq->cs_method;
+    rack->ra_method_name = sip->sip_cseq->cs_method_name;
+
+    nua_stack_prack(nh->nh_nua, nh, nua_r_prack, tags);
+
+    return 0;
+  }
+
+  /* XXX - CANCEL INVITE or BYE this session? */
+  /* Because we don't do forking very well we just cancel INVITE */
+  nua_stack_cancel(nh->nh_nua, nh, nua_r_cancel, NULL);
 
   return 0;
 }
 
-/**@fn void nua_cancel(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
+/**@fn void nua_prack(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
+ * Send a PRACK request. 
  *
- * Cancel an INVITE operation 
+ * PRACK is used to acknowledge receipt of 100rel responses. See @RFC3262.
  *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
@@ -1159,142 +1023,300 @@
  *    nothing
  *
  * @par Related Tags:
- *    Tags in <sip_tag.h>
+ *    Tags in <sofia-sip/soa_tag.h>, <sofia-sip/sip_tag.h>.
  *
  * @par Events:
- *    #nua_r_cancel, #nua_i_state  (#nua_i_active, #nua_i_terminated)
- *
- * @sa @ref nua_call_model, nua_invite(), #nua_i_cancel
+ *    #nua_r_prack
  */
 
-static int nua_cancel_client_request(nua_client_request_t *cr,
-				     msg_t *msg, sip_t *sip,
-				     tagi_t const *tags);
-
-nua_client_methods_t const nua_cancel_client_methods = {
-  SIP_METHOD_CANCEL,
-  0,
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 1,
-    /* target refresh */ 0
-  },
-  NULL,
-  NULL,
-  nua_cancel_client_request,
-  /* nua_cancel_client_check_restart */ NULL,
-  /* nua_cancel_client_response */ NULL
-};
-
-int nua_stack_cancel(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-		     tagi_t const *tags)
-{
-  return nua_client_create(nh, e, &nua_cancel_client_methods, tags);
-}
-
-static int nua_cancel_client_request(nua_client_request_t *cr,
-				     msg_t *msg, sip_t *sip,
-				     tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
-
-  if (!du || !du->du_cr || !du->du_cr->cr_orq || 
-      nta_outgoing_status(du->du_cr->cr_orq) >= 200) {
-    return nua_client_return(cr, 481, "No transaction to CANCEL", msg);
-  }
-
-  cr->cr_orq = nta_outgoing_tcancel(du->du_cr->cr_orq,
-				    nua_client_orq_response, cr,
-				    TAG_NEXT(tags));
-
-  return cr->cr_orq ? 0 : -1;
-}
-
-/** @NUA_EVENT nua_r_cancel
- *
- * Answer to outgoing CANCEL.
+/** @NUA_EVENT nua_r_prack
  *
- * The CANCEL may be sent explicitly by nua_cancel() or implicitly by NUA
- * state machine.
+ * Response to an outgoing @b PRACK request. PRACK request is used to
+ * acknowledge reliable preliminary responses and it is usually sent
+ * automatically by the nua stack.
  *
- * @param status response status code 
+ * @param status response status code
+ *               (if the request is retried, @a status is 100, the @a
+ *               sip->sip_status->st_status contain the real status code
+ *               from the response message, e.g., 302, 401, or 407)
  * @param phrase a short textual description of @a status code
  * @param nh     operation handle associated with the call
  * @param hmagic application context associated with the call
- * @param sip    response to CANCEL request or NULL upon an error
+ * @param sip    response to @b PRACK or NULL upon an error
  *               (status code is in @a status and 
  *                descriptive message in @a phrase parameters)
  * @param tags   empty
  *
- * @sa nua_cancel(), @ref nua_uac_call_model, #nua_r_invite, nua_invite(),
- * #nua_i_state
+ * @sa nua_prack(), #nua_i_prack, @RFC3262
  *
  * @END_NUA_EVENT
  */
 
+
+int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		    tagi_t const *tags)
+{
+  nua_session_usage_t *ss;
+  nua_client_request_t *cr;
+  msg_t *msg;
+  sip_t *sip;
+  int offer_sent_in_prack = 0, answer_sent_in_prack = 0;
+
+  int status = 0; char const *phrase = "PRACK sent";
+  char const *recv = NULL, *sent = NULL;
+
+  int autoprack =		/* XXX - should have common indication */
+    tags && tags->t_tag == tag_skip && 
+    tags->t_value == (tag_value_t)nua_stack_prack;
+
+  if (autoprack) {
+    status = (int)tags[1].t_value; 
+    phrase = (char const *)tags[2].t_value;
+    recv = (char const *)tags[3].t_value;
+    tags += 4;
+  }
+
+  ss = nua_session_usage_get(nh->nh_ds);
+
+  if (!ss || !ss->ss_crequest || !nta_outgoing_rseq(ss->ss_crequest->cr_orq))
+    return UA_EVENT2(e, 900, "Nothing to PRACK");
+  else if (nh->nh_ds->ds_cr->cr_orq)
+    return UA_EVENT2(e, 900, "Request already in progress");
+
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  cr = nh->nh_ds->ds_cr;
+
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
+		     SIP_METHOD_PRACK,
+		     NUTAG_USE_DIALOG(1),
+		     NUTAG_ADD_CONTACT(1),
+		     TAG_NEXT(tags));
+
+  sip = sip_object(msg);
+
+  if (sip) {
+    nua_client_request_t *cri = ss->ss_crequest;
+    if (nh->nh_soa == NULL)
+      /* It is up to application to handle SDP */;
+    else if (sip->sip_payload)
+      /* XXX - we should just do MIME in session_include_description() */;
+    else if (cri->cr_offer_recv && !cri->cr_answer_sent) {
+
+      if (soa_generate_answer(nh->nh_soa, NULL) < 0 ||
+	  session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+
+	status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+	SU_DEBUG_3(("nua(%p): PRACK answer: %d %s\n", nh, status, phrase));
+	nua_stack_event(nh->nh_nua, nh, NULL,
+			nua_i_media_error, status, phrase, TAG_END());
+
+	goto error;
+      }
+      else {
+	answer_sent_in_prack = 1, sent = "answer";
+	soa_activate(nh->nh_soa, NULL);
+      }
+    }
+    /* When 100rel response status was 183 fake support for preconditions */
+    else if (autoprack && status == 183 && ss->ss_precondition) {
+
+      if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
+	  session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+
+	status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+	SU_DEBUG_3(("nua(%p): PRACK offer: %d %s\n", nh, status, phrase));
+	nua_stack_event(nh->nh_nua, nh, NULL,
+			nua_i_media_error, status, phrase, TAG_END());
+	goto error;
+      }
+      else {
+	offer_sent_in_prack = 1, sent = "offer";
+      }
+    }
+
+    if (nh->nh_auth) {
+      if (auc_authorize(&nh->nh_auth, msg, sip) < 0)
+	/* xyzzy */;
+    }
+
+    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				      process_response_to_prack, nh, NULL,
+				      msg,
+				      SIPTAG_END(), TAG_NEXT(tags));
+    if (cr->cr_orq) {
+      cr->cr_usage = nua_dialog_usage_public(ss);
+      cr->cr_event = nua_r_prack;
+
+      if (answer_sent_in_prack)
+	cri->cr_answer_sent = 1;
+      else if (offer_sent_in_prack)
+	cr->cr_offer_sent = 1;
+
+      if (autoprack) 
+	signal_call_state_change(nh, ss, status, phrase,
+				 nua_callstate_proceeding, recv, sent);
+      else
+	signal_call_state_change(nh, ss, 0, "PRACK sent",
+				 nua_callstate_proceeding, NULL, sent);
+	
+
+      return cr->cr_event = e;
+    }
+  }
+
+ error:
+  msg_destroy(msg);
+  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+}
+
+void restart_prack(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_prack, tags);
+}
+
+
+static int
+process_response_to_prack(nua_handle_t *nh,
+			  nta_outgoing_t *orq,
+			  sip_t const *sip)
+{
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
+  int status;
+  char const *phrase = "OK", *reason = NULL, *recv = NULL;
+
+  assert(cr->cr_usage && cr->cr_usage->du_class == nua_session_usage);
+
+  if (sip)
+    status = sip->sip_status->st_status, phrase = sip->sip_status->st_phrase;
+  else
+    status = 408, phrase = sip_408_Request_timeout;
+
+  SU_DEBUG_5(("nua: process_response_to_prack: %u %s\n", status, phrase));
+
+  if (nua_creq_check_restart(nh, cr, orq, sip, restart_prack))
+    return 0;
+
+  if (status < 200)
+    return 0;
+
+  cr->cr_usage = NULL;
+
+  if (status < 300) {
+    if (session_process_response(nh, cr, orq, sip, &recv) < 0) {
+      status = 900, phrase = "Malformed Session in Response";
+      reason = "SIP;status=400;phrase=\"Malformed Session in Response\"";
+    }
+  }
+  else
+    nua_stack_process_response(nh, cr, orq, sip, TAG_END());
+
+  if (recv)
+    signal_call_state_change(nh, ss, status, phrase,
+			     nua_callstate_proceeding, recv, NULL);
+
+  if (status < 300 && ss->ss_update_needed)
+    nua_stack_update(nh->nh_nua, nh, nua_r_update, NULL);
+
+  return 0;
+}
+
+/** Refresh session usage */
 static void nua_session_usage_refresh(nua_handle_t *nh,
 				      nua_dialog_state_t *ds,
 				      nua_dialog_usage_t *du,
 				      sip_time_t now)
 {
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  nua_client_request_t const *cr = du->du_cr;
-  nua_server_request_t const *sr;
-
-  assert(cr);
-
-  if (ss->ss_state >= nua_callstate_terminating || 
-      /* No INVITE template */
-      cr == NULL || 
-      /* INVITE is in progress or being authenticated */
-      cr->cr_orq || cr->cr_challenged)
-    return;
+  tagi_t const timer_tags[2] = {
+    { SIPTAG_SUBJECT_STR("Session refresh") }, 
+    { TAG_END() }
+  };
+  tagi_t const refresh_tags[2] = {
+    { SIPTAG_SUBJECT_STR("Dialog refresh") }, 
+    { TAG_END() }
+  };
 
-  /* UPDATE in progress or being authenticated */
-  for (cr = ds->ds_cr; cr; cr = cr->cr_next) 
-    if (cr->cr_method == sip_method_update)
-      return;
+  nua_session_usage_t const *ss = nua_dialog_usage_private(du);
+  nua_client_request_t const *cri = ss->ss_crequest, *cro = ds->ds_cr;
+  nua_server_request_t const *sr;
 
-  /* INVITE or UPDATE in progress */
   for (sr = ds->ds_sr; sr; sr = sr->sr_next)
     if (sr->sr_usage == du && 
 	(sr->sr_method == sip_method_invite || 
 	 sr->sr_method == sip_method_update))
-      return;
+      break;
+
+  /* INVITE or UPDATE in progress or being authenticated */
+  if ((cri && cri->cr_orq) || sr)	
+    return;
+  if (ss->ss_state >= nua_callstate_terminating)
+    return;
 
   if (!ss->ss_refresher) {
-    if (du->du_expires == 0 || now < du->du_expires)
-      /* Refresh contact & route set using re-INVITE */
-      nua_client_resend_request(du->du_cr, 0, NULL);
-    else {
-      ss->ss_reason = "SIP;cause=408;text=\"Session timeout\""; 
-      nua_stack_bye(nh->nh_nua, nh, nua_r_bye, NULL);
-    }
+    if (now >= du->du_expires)
+      session_timeout(nh, du, now);
+    else
+      /* Refreshing contact & route set */
+      nua_stack_invite2(nh->nh_nua, nh, nua_r_invite, 1, refresh_tags);
   }
   else if (NH_PGET(nh, update_refresh)) {
-    nua_stack_update(nh->nh_nua, nh, nua_r_update, NULL);
+    if (!cro->cr_orq)
+      nua_stack_update(nh->nh_nua, nh, nua_r_update, timer_tags);
+    else
+      nua_dialog_usage_refresh_range(du, 5, 15);
   }
   else {
-    nua_client_resend_request(du->du_cr, 0, NULL);
+    nua_stack_invite2(nh->nh_nua, nh, nua_r_invite, 1, timer_tags);
   }
 }
 
-/** @interal Shut down session usage. 
- *
- * @retval >0  shutdown done
- * @retval 0   shutdown in progress
- * @retval <0  try again later
- */
+static
+char const reason_timeout[] = "SIP;cause=408;text=\"Session timeout\"";
+
+static void
+session_timeout(nua_handle_t *nh, nua_dialog_usage_t *du, sip_time_t now)
+{
+  if (now > 1) {
+    nua_session_usage_t *ss = nua_dialog_usage_private(du);
+
+    signal_call_state_change(nh, ss, 408, "Session Timeout",
+			     nua_callstate_terminating, NULL, NULL);
+
+    nua_stack_post_signal(nh, nua_r_bye,
+			  SIPTAG_REASON_STR(reason_timeout),
+			  TAG_END());
+  }
+}
+
+/** Terminate usage/dialog/handle/agent gracefully */
 static int nua_session_usage_shutdown(nua_handle_t *nh,
 				      nua_dialog_state_t *ds,
 				      nua_dialog_usage_t *du)
 {
   nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_client_request_t *cr;
   nua_server_request_t *sr, *sr_next;
-  nua_client_request_t *cri;
+  int status;
 
-  assert(ss == nua_session_usage_for_dialog(nh->nh_ds));
+  /* Zap client-side invite transaction */
+  if (ss->ss_crequest->cr_orq) {
+    cr = ss->ss_crequest;
+    status = nta_outgoing_status(cr->cr_orq);
+
+    if (status < 200) 
+      nta_outgoing_tcancel(cr->cr_orq, NULL, NULL, TAG_END());
+
+    if (ss->ss_ack_needed) {
+      msg_t *ack = nua_creq_msg(nh->nh_nua, nh, cr, 0,
+				SIP_METHOD_ACK,
+				TAG_END());
+      nta_outgoing_mcreate(nh->nh_nua->nua_nta, NULL, NULL, NULL, 
+			   ack, TAG_END());
+    }
+
+    nua_creq_deinit(cr, NULL);
+  }
 
   /* Zap server-side transactions */
   for (sr = ds->ds_sr; sr; sr = sr_next) {
@@ -1302,55 +1324,54 @@
     if (sr->sr_usage == du) {
       assert(sr->sr_usage == du);
       sr->sr_usage = NULL;
-
-      if (nua_server_request_is_pending(sr)) {
-	SR_STATUS1(sr, SIP_480_TEMPORARILY_UNAVAILABLE);
-	nua_server_respond(sr, NULL);
-	if (nua_server_report(sr) >= 2)
-	  return 480;
-      }
+      if (sr->sr_respond) 
+	nua_server_respond(sr, SIP_480_TEMPORARILY_UNAVAILABLE, TAG_END());
       else
 	nua_server_request_destroy(sr);
     }
   }
 
-  cri = du->du_cr;
+  assert(ss == nua_session_usage_get(nh->nh_ds));
 
   switch (ss->ss_state) {
-  case nua_callstate_calling:
-  case nua_callstate_proceeding:
-    return nua_client_create(nh, nua_r_cancel, &nua_cancel_client_methods, NULL);
-
   case nua_callstate_completing:
   case nua_callstate_ready:
   case nua_callstate_completed:
-    if (cri && cri->cr_orq) {
-      if (cri->cr_status < 200)
-	nua_client_create(nh, nua_r_cancel, &nua_cancel_client_methods, NULL);
-      else if (cri->cr_status < 300)
-	nua_invite_client_ack(cri, NULL);
-    }
-    if (nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL) != 0)
-      break;
-    return 0;
-
-  case nua_callstate_terminating:
-  case nua_callstate_terminated: /* XXX */
-    return 0;
+    {
+      msg_t *bye;
 
-  default:
-    break;
+      cr = ds->ds_cr;
+      nua_creq_deinit(cr, NULL);
+      bye = nua_creq_msg(nh->nh_nua, nh, ds->ds_cr, 0, 
+			 SIP_METHOD_BYE,
+			 TAG_END());
+      cr->cr_orq = nta_outgoing_mcreate(nh->nh_nua->nua_nta,
+					NULL, NULL, NULL,
+					bye,
+					TAG_END());
+      nua_creq_deinit(cr, NULL);
+    }
   }
-  
+
   nua_dialog_usage_remove(nh, ds, du);
 
-  return 200;
+  return 0;
 }
 
-/**@fn void nua_prack(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
- * Send a PRACK request. 
+/** Restart invite (e.g., after 302 or 407) */
+void
+restart_invite(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_stack_invite2(nh->nh_nua, nh, nua_r_invite, 1, tags);
+}
+
+static int process_response_to_cancel(nua_handle_t *nh,
+				      nta_outgoing_t *orq,
+				      sip_t const *sip);
+
+/**@fn void nua_cancel(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
- * PRACK is used to acknowledge receipt of 100rel responses. See @RFC3262.
+ * Cancel an INVITE operation 
  *
  * @param nh              Pointer to operation handle
  * @param tag, value, ... List of tagged parameters
@@ -1359,201 +1380,109 @@
  *    nothing
  *
  * @par Related Tags:
- *    Tags in <sofia-sip/soa_tag.h>, <sofia-sip/sip_tag.h>.
+ *    Tags in <sip_tag.h>
  *
  * @par Events:
- *    #nua_r_prack
- */
-
-/** @NUA_EVENT nua_r_prack
- *
- * Response to an outgoing @b PRACK request. PRACK request is used to
- * acknowledge reliable preliminary responses and it is usually sent
- * automatically by the nua stack.
- *
- * @param status response status code
- *               (if the request is retried, @a status is 100, the @a
- *               sip->sip_status->st_status contain the real status code
- *               from the response message, e.g., 302, 401, or 407)
- * @param phrase a short textual description of @a status code
- * @param nh     operation handle associated with the call
- * @param hmagic application context associated with the call
- * @param sip    response to @b PRACK or NULL upon an error
- *               (status code is in @a status and 
- *                descriptive message in @a phrase parameters)
- * @param tags   empty
- *
- * @sa nua_prack(), #nua_i_prack, @RFC3262
+ *    #nua_r_cancel, #nua_i_state  (#nua_i_active, #nua_i_terminated)
  *
- * @END_NUA_EVENT
+ * @sa @ref nua_call_model, nua_invite(), #nua_i_cancel
  */
 
-static int nua_prack_client_init(nua_client_request_t *cr, 
-				 msg_t *msg, sip_t *sip,
-				 tagi_t const *tags);
-static int nua_prack_client_request(nua_client_request_t *cr,
-				    msg_t *msg, sip_t *sip,
-				    tagi_t const *tags);
-static int nua_prack_client_response(nua_client_request_t *cr,
-				     int status, char const *phrase,
-				     sip_t const *sip);
-static int nua_prack_client_report(nua_client_request_t *cr,
-				   int status, char const *phrase,
-				   sip_t const *sip,
-				   nta_outgoing_t *orq,
-				   tagi_t const *tags);
-
-nua_client_methods_t const nua_prack_client_methods = {
-  SIP_METHOD_PRACK,
-  0,
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 1,
-    /* target refresh */ 0
-  },
-  NULL,
-  nua_prack_client_init,
-  nua_prack_client_request,
-  /* nua_prack_client_check_restart */ NULL,
-  nua_prack_client_response,
-  NULL,
-  nua_prack_client_report
-};
-
-int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-		     tagi_t const *tags)
-{
-  return nua_client_create(nh, e, &nua_prack_client_methods, tags);
-}
-
-static int nua_prack_client_init(nua_client_request_t *cr, 
-				 msg_t *msg, sip_t *sip,
-				 tagi_t const *tags)
+int
+nua_stack_cancel(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		 tagi_t const *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+  nua_session_usage_t *ss;
+  nua_client_request_t *cri, *crc;
 
-  cr->cr_usage = du;
+  ss = nua_session_usage_get(nh->nh_ds);
 
-  return 0;
-}
+  if (!nh || !ss || !ss->ss_crequest->cr_usage ||
+      nta_outgoing_status(ss->ss_crequest->cr_orq) >= 200) {
+    return UA_EVENT2(e, 481, "No transaction to CANCEL");
+  }
 
-static int nua_prack_client_request(nua_client_request_t *cr,
-				    msg_t *msg, sip_t *sip,
-				    tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  nua_client_request_t *cri;
-  int offer_sent = 0, answer_sent = 0, retval;
-  int status = 0; char const *phrase = "PRACK Sent";
-  uint32_t rseq = 0;
-
-  if (du == NULL)		/* Call terminated */
-    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
-  assert(ss);
+  cri = ss->ss_crequest;
+  crc = nh->nh_ds->ds_cr;
 
-  cri = du->du_cr;
+  if (tags)
+    nua_stack_set_params(nua, nh, nua_i_error, tags);
 
-  if (sip->sip_rack)
-    rseq = sip->sip_rack->ra_response;
+  if (nh && cri->cr_orq && cri->cr_usage) {
+    nta_outgoing_t *orq;
 
-  if (nh->nh_soa == NULL)
-    /* It is up to application to handle SDP */;
-  else if (sip->sip_payload)
-    /* XXX - we should just do MIME in session_include_description() */;
-  else if (cri->cr_offer_recv && !cri->cr_answer_sent) {
-    if (soa_generate_answer(nh->nh_soa, NULL) < 0 ||
-	session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-      SU_DEBUG_3(("nua(%p): local response to PRACK: %d %s\n",
-		  (void *)nh, status, phrase));
-      nua_stack_event(nh->nh_nua, nh, NULL,
-		      nua_i_media_error, status, phrase,
-		      NULL);
-      return nua_client_return(cr, status, phrase, msg);
-    }
-    else {
-      answer_sent = 1;
-      soa_activate(nh->nh_soa, NULL);
-    }
-  }
-  /* When 100rel response status was 183 fake support for preconditions */
-  else if (cr->cr_auto && cri->cr_status == 183 && ss->ss_precondition) {
-    if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
-	session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
-      SU_DEBUG_3(("nua(%p): PRACK offer: %d %s\n", (void *)nh,
-		  status, phrase));
-      nua_stack_event(nh->nh_nua, nh, NULL,
-		      nua_i_media_error, status, phrase, NULL);
-      return nua_client_return(cr, status, phrase, msg);
-    }
-    else {
-      offer_sent = 1;
-    }
-  }
+    /* nh_referral_respond(nh, SIP_487_REQUEST_TERMINATED); */
 
-  retval = nua_base_client_request(cr, msg, sip, NULL);
+    if (e)
+      orq = nta_outgoing_tcancel(cri->cr_orq, process_response_to_cancel, nh,
+				 TAG_NEXT(tags));
+    else
+      orq = nta_outgoing_tcancel(cri->cr_orq, NULL, NULL, TAG_NEXT(tags));
 
-  if (retval == 0) {
-    cr->cr_offer_sent = offer_sent;
-    cr->cr_answer_sent = answer_sent;
-
-    if (!cr->cr_restarting) {
-      if (offer_sent) 
-	ss->ss_oa_sent = "offer";
-      else if (answer_sent)
-	ss->ss_oa_sent = "answer";
+    if (orq == NULL)
+      return nua_stack_event(nua, nh, NULL, e, 400, "Internal error",
+			     TAG_END());
 
-      if (!ss->ss_reporting)
-	signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
-    }
+    if (e && crc->cr_orq == NULL)
+      crc->cr_orq = orq, crc->cr_event = e;
   }
 
-  return retval;
-}
-
-static int nua_prack_client_response(nua_client_request_t *cr,
-				     int status, char const *phrase,
-				     sip_t const *sip)
-{
-  /* XXX - fatal error cases? */
-
-  return nua_session_client_response(cr, status, phrase, sip);
+  return 0;
 }
 
-static int nua_prack_client_report(nua_client_request_t *cr,
-				   int status, char const *phrase,
-				   sip_t const *sip,
-				   nta_outgoing_t *orq,
-				   tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
-
-  nua_stack_event(nh->nh_nua, nh, 
-		  nta_outgoing_getresponse(orq),
-		  cr->cr_event,
-		  status, phrase,
-		  tags);
+/** @NUA_EVENT nua_r_cancel
+ *
+ * Answer to outgoing CANCEL.
+ *
+ * The CANCEL may be sent explicitly by nua_cancel() or implicitly by NUA
+ * state machine.
+ *
+ * @param status response status code 
+ * @param phrase a short textual description of @a status code
+ * @param nh     operation handle associated with the call
+ * @param hmagic application context associated with the call
+ * @param sip    response to CANCEL request or NULL upon an error
+ *               (status code is in @a status and 
+ *                descriptive message in @a phrase parameters)
+ * @param tags   empty
+ *
+ * @sa nua_cancel(), @ref nua_uac_call_model, #nua_r_invite, nua_invite(),
+ * #nua_i_state
+ *
+ * @END_NUA_EVENT
+ */
 
-  if (!ss || orq != cr->cr_orq || cr->cr_terminated || cr->cr_graceful)
-    return 1;
 
-  if (cr->cr_offer_sent)
-    signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
 
-  if (ss->ss_update_needed && 200 <= status && status < 300)
-    nua_client_create(nh, nua_r_update, &nua_update_client_methods, NULL);
-  
-  return 1;
+static int process_response_to_cancel(nua_handle_t *nh,
+				      nta_outgoing_t *orq,
+				      sip_t const *sip)
+{
+  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
 }
 
 /* ---------------------------------------------------------------------- */
 /* UAS side of INVITE */
 
+static int respond_to_invite(nua_server_request_t *sr, tagi_t const *tags);
+
+static int
+  preprocess_invite(nua_t *, nua_handle_t *, nua_server_request_t **, sip_t *),
+  session_check_request(nua_t *nua,
+			nua_handle_t *nh,
+			nta_incoming_t *irq,
+			sip_t const *sip),
+  process_invite(nua_t *, nua_handle_t *, nua_server_request_t *, sip_t *),
+  process_prack(nua_handle_t *, nta_reliable_t *, nta_incoming_t *,
+		sip_t const *);
+
+static int
+  process_ack_or_cancel(nua_server_request_t *, nta_incoming_t *, 
+			sip_t const *),
+  process_ack(nua_server_request_t *, nta_incoming_t *, sip_t const *),
+  process_cancel(nua_server_request_t *, nta_incoming_t *, sip_t const *),
+  process_timeout(nua_server_request_t *, nta_incoming_t *);
+
 /** @NUA_EVENT nua_i_invite
  *
  * Indication of incoming call or re-INVITE request. 
@@ -1599,18 +1528,16 @@
  * the 2XX response. If @soa is not disabled with NUTAG_MEDIA_ENABLE(0), the
  * SDP should be included in the SOATAG_USER_SDP() or SOATAG_USER_SDP_STR()
  * parameter given to nua_respond(). If it is disabled, the SDP should be
- * included in the response message using SIPTAG_PAYLOAD() or
- * SIPTAG_PAYLOAD_STR(). Also, the @ContentType should be set using
- * SIPTAG_CONTENT_TYPE() or SIPTAG_CONTENT_TYPE_STR().
+ * included in message
  *
  * @par Preliminary Responses and 100rel
  *
  * Call progress can be signaled with preliminary responses (with status
  * code in the range 101..199). It is possible to conclude the SDP
  * Offer-Answer negotiation using preliminary responses, too. If
- * NUTAG_EARLY_ANSWER(1), SOATAG_USER_SDP() or SOATAG_USER_SDP_STR()
- * parameter is included with in a preliminary nua_response(), the SDP
- * answer is generated and sent with the preliminary responses, too.
+ * SOATAG_USER_SDP() or SOATAG_USER_SDP_STR() parameter is included with in
+ * a preliminary nua_response(), the SDP answer is generated and sent with
+ * the preliminary responses, too.
  *
  * The preliminary responses are sent reliably if feature tag "100rel" is
  * included in the @Require header of the response or if
@@ -1633,8 +1560,7 @@
  *
  * @sa nua_respond(), @ref nua_uas_call_model, #nua_i_state,
  * NUTAG_MEDIA_ENABLE(), SOATAG_USER_SDP(), SOATAG_USER_SDP_STR(),
- * @RFC3262, NUTAG_EARLY_ANSWER(), NUTAG_EARLY_MEDIA(), 
- * NUTAG_ONLY183_100REL(), 
+ * @RFC3262, NUTAG_EARLY_MEDIA(), NUTAG_ONLY183_100REL(), 
  * NUTAG_INCLUDE_EXTRA_SDP(),
  * #nua_i_prack, #nua_i_update, nua_update(),
  * nua_invite(), #nua_r_invite
@@ -1653,207 +1579,193 @@
  * @END_NUA_EVENT
  */
 
-static int nua_invite_server_init(nua_server_request_t *sr);
-static int nua_session_server_init(nua_server_request_t *sr);
-static int nua_invite_server_preprocess(nua_server_request_t *sr);
-static int nua_invite_server_respond(nua_server_request_t *sr, tagi_t const *);
-static int nua_invite_server_is_100rel(nua_server_request_t *, tagi_t const *);
-static int nua_invite_server_report(nua_server_request_t *sr, tagi_t const *);
+/** @internal Process incoming INVITE. */
+int nua_stack_process_invite(nua_t *nua,
+			     nua_handle_t *nh,
+			     nta_incoming_t *irq,
+			     sip_t const *sip)
+{
+  nua_server_request_t *sr, sr0[1];
+  int status;
+  
+  sr = SR_INIT(sr0);
+  sr->sr_irq = irq;
+
+  status = preprocess_invite(nua, nh, &sr, (sip_t *)sip);
 
-static int
-  process_ack_or_cancel(nua_server_request_t *, nta_incoming_t *, 
-			sip_t const *),
-  process_ack(nua_server_request_t *, nta_incoming_t *, sip_t const *),
-  process_cancel(nua_server_request_t *, nta_incoming_t *, sip_t const *),
-  process_timeout(nua_server_request_t *, nta_incoming_t *),
-  process_prack(nua_handle_t *nh,
-		nta_reliable_t *rel,
-		nta_incoming_t *irq,
-		sip_t const *sip);
+  if (status) {
+    if (sr->sr_status > 100) 
+      nta_incoming_treply(irq, sr->sr_status, sr->sr_phrase,
+			  SIPTAG_USER_AGENT_STR(NUA_PGET(nua, nh, user_agent)),
+			  TAG_END());
+    nua_server_request_destroy(sr);
+    /* if something has failed, respond with 500 Internal Server Error */
+    return 500; 
+  }
 
-nua_server_methods_t const nua_invite_server_methods = 
-  {
-    SIP_METHOD_INVITE,
-    nua_i_invite,		/* Event */
-    { 
-      1,			/* Create dialog */
-      0,			/* Initial request */
-      1,			/* Target refresh request  */
-      1,			/* Add Contact */
-    },
-    nua_invite_server_init,
-    nua_invite_server_preprocess,
-    nua_base_server_params,
-    nua_invite_server_respond,
-    nua_invite_server_report,
-  };
+  assert(sr != sr0);
 
+  return process_invite(nua, sr->sr_owner, sr, (sip_t *)sip);
+}
 
 /** @internal Preprocess incoming invite - sure we have a valid request. 
  * 
- * @return 0 if request is valid, or error statuscode otherwise
+ * @return 0 if request is valid, or error statuscode when request has been 
+ * responded.
  */
-static int
-nua_invite_server_init(nua_server_request_t *sr)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_t *nua = nh->nh_nua;
+static
+int preprocess_invite(nua_t *nua,
+		      nua_handle_t *nh,
+		      nua_server_request_t **inout_sr,
+		      sip_t *sip)
+{
+  nua_dialog_state_t *ds;
+  nua_server_request_t *sr = *inout_sr;
+  nua_server_request_t const *sr0;
+  nua_dialog_usage_t *du;
+  nua_session_usage_t *ss;
+  int have_sdp;
+  char const *sdp;
+  size_t len;
+
+  if (nh) {
+    ds = nh->nh_ds;
+    du = nua_dialog_usage_get(ds, nua_session_usage, NULL);
+    ss = nua_dialog_usage_private(du);
+  }
+  else {
+    nh = nua->nua_dhandle, ds = NULL, du = NULL, ss = NULL;
+  }
 
-  sr->sr_neutral = 1;
+  sr->sr_usage = du;
 
   if (!NUA_PGET(nua, nh, invite_enable))
     return SR_STATUS1(sr, SIP_403_FORBIDDEN);
 
-  if (nua_session_server_init(sr))
-    return sr->sr_status;
-    
-  if (sr->sr_usage) {
-    /* Existing session - check for overlap and glare */ 
+  if (session_check_request(nua, nh, sr->sr_irq, sip))
+    return 500;
 
-    nua_server_request_t const *sr0;
-    nua_client_request_t const *cr;
+  have_sdp = session_get_description(sip, &sdp, &len);
+
+  if (ss) {
+    /* Existing session */ 
 
-    for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) {
+    for (sr0 = ds->ds_sr; sr0; sr0 = sr0->sr_next) {
       /* Final response have not been sent to previous INVITE */
-      if (sr0->sr_method == sip_method_invite && 
-	  nua_server_request_is_pending(sr0))
+      if (sr0->sr_method == sip_method_invite && sr0->sr_respond)
 	break;
       /* Or we have sent offer but have not received answer */
-      if (sr->sr_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
+      if (have_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
 	break;
       /* Or we have received request with offer but not sent answer */
-      if (sr->sr_sdp && sr0->sr_offer_recv && !sr0->sr_answer_sent)
+      if (have_sdp && sr0->sr_offer_recv && !sr0->sr_answer_sent)
 	break;
     }
     
-    if (sr0) {
+    if (sr0)
       /* Overlapping invites - RFC 3261 14.2 */
-      return nua_server_retry_after(sr, 500, "Overlapping Requests", 0, 10);
-    }
+      return respond_with_retry_after(nh, sr->sr_irq, 
+				      500, "Overlapping Requests",
+				      0, 10);
 
-    for (cr = nh->nh_ds->ds_cr; cr; cr = cr->cr_next) {
-      if (cr->cr_usage == sr->sr_usage && cr->cr_orq && cr->cr_offer_sent)
-	/* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */
-	return SR_STATUS1(sr, SIP_491_REQUEST_PENDING);
+    if ((ss->ss_crequest && ss->ss_crequest->cr_orq) ||
+	(have_sdp && ds && ds->ds_cr->cr_orq && ds->ds_cr->cr_offer_sent)) {
+      /* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */
+      return SR_STATUS1(sr, SIP_491_REQUEST_PENDING);
     }
   }
 
-  sr->sr_neutral = 0;
-
-  return 0;
-}
-
-/** Initialize session server request.
- *
- * Ensure that the request is valid.
- */
-static int
-nua_session_server_init(nua_server_request_t *sr)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_t *nua = nh->nh_nua;
-
-  msg_t *msg = sr->sr_response.msg;
-  sip_t *sip = sr->sr_response.sip;
+  /* Create handle and server request structure when needed */
+  sr = nua_server_request(nua, nh, sr->sr_irq, sip, sr, sizeof *sr,
+			  respond_to_invite, create_dialog);
+  *inout_sr = sr;
 
-  sip_t const *request = sr->sr_request.sip;
-
-  unsigned min = NH_PGET(nh, min_se);
-
-  if (!sr->sr_initial)
-    sr->sr_usage = nua_dialog_usage_get(nh->nh_ds, nua_session_usage, NULL);
+  if (sr->sr_status > 100)
+    return sr->sr_status;
 
-  if (sr->sr_method != sip_method_invite && sr->sr_usage == NULL) {
-    /* UPDATE/PRACK sent within an existing dialog? */
-    return SR_STATUS(sr, 481, "Call Does Not Exist");
-  }
+  nh = sr->sr_owner; assert(nh != nua->nua_dhandle);
+  ds = nh->nh_ds;
 
   if (nh->nh_soa) {
-    sip_accept_t *a = nua->nua_invite_accept;
-
-    /* XXX - soa should know what it supports */
-    sip_add_dup(msg, sip, (sip_header_t *)a);
-
-    /* Make sure caller uses application/sdp without compression */
-    if (nta_check_session_content(NULL, request, a, TAG_END())) {
-      sip_add_make(msg, sip, sip_accept_encoding_class, "");
-      return SR_STATUS1(sr, SIP_415_UNSUPPORTED_MEDIA);
-    }
+    soa_init_offer_answer(nh->nh_soa);
 
-    /* Make sure caller accepts application/sdp */
-    if (nta_check_accept(NULL, request, a, NULL, TAG_END())) {
-      sip_add_make(msg, sip, sip_accept_encoding_class, "");
-      return SR_STATUS1(sr, SIP_406_NOT_ACCEPTABLE);
+    if (have_sdp) {
+      if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
+	SU_DEBUG_5(("nua(%p): error parsing SDP in INVITE\n", nh));
+	return SR_STATUS(sr, 400, "Bad Session Description");
+      }
+      else
+	sr->sr_offer_recv = 1;
     }
   }
 
-  if (request->sip_session_expires &&
-      nta_check_session_expires(NULL, request, min, TAG_END())) {
-    sip_min_se_t *min_se, min_se0[1];
-
-    min_se = sip_min_se_init(min_se0);
-    min_se->min_delta = min;
-    
-    if (request->sip_min_se && request->sip_min_se->min_delta > min)
-      min_se = request->sip_min_se;
+  /* Add the session usage */
+  if (du == NULL)
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_session_usage, NULL);
 
-    sip_add_dup(msg, sip, (sip_header_t *)min_se);
-    
-    return SR_STATUS1(sr, SIP_422_SESSION_TIMER_TOO_SMALL);
-  }
+  if (!du)
+    return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
 
-  session_get_description(sr->sr_request.sip, &sr->sr_sdp, &sr->sr_sdp_len);
+  sr->sr_usage = du;
 
   return 0;
 }
 
-/** Preprocess INVITE.
- *
- * This is called after a handle has been created for an incoming INVITE.
- */
-int nua_invite_server_preprocess(nua_server_request_t *sr)
+static int
+session_check_request(nua_t *nua,
+		      nua_handle_t *nh,
+		      nta_incoming_t *irq,
+		      sip_t const *sip)
 {
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_session_usage_t *ss;
-
-  sip_t const *request = sr->sr_request.sip;
-
-  assert(sr->sr_status == 100);
-  assert(nh != nh->nh_nua->nua_dhandle);
-
-  if (sr->sr_status > 100)
-    return sr->sr_status;
+  char const *user_agent = NUA_PGET(nua, nh, user_agent);
 
   if (nh->nh_soa) {
-    soa_init_offer_answer(nh->nh_soa);
+    /* Make sure caller uses application/sdp without compression */
+    if (nta_check_session_content(irq, sip,
+				  nua->nua_invite_accept,
+				  SIPTAG_USER_AGENT_STR(user_agent),
+				  SIPTAG_ACCEPT_ENCODING_STR(""),
+				  TAG_END()))
+      return 415;
 
-    if (sr->sr_sdp) {
-      if (soa_set_remote_sdp(nh->nh_soa, NULL,
-			     sr->sr_sdp, sr->sr_sdp_len) < 0) {
-	SU_DEBUG_5(("nua(%p): %s server: error parsing SDP\n", (void *)nh,
-		    "INVITE"));
-	return SR_STATUS(sr, 400, "Bad Session Description");
-      }
-      else
-	sr->sr_offer_recv = 1;
-    }
+    /* Make sure caller accepts application/sdp */
+    if (nta_check_accept(irq, sip,
+			 nua->nua_invite_accept,
+			 NULL,
+			 SIPTAG_USER_AGENT_STR(user_agent),
+			 SIPTAG_ACCEPT_ENCODING_STR(""),
+			 TAG_END()))
+      return 406;
+  }
+
+  if (sip->sip_session_expires) {
+    unsigned min_se = NH_PGET(nh, min_se);
+    if (sip->sip_min_se && min_se < sip->sip_min_se->min_delta)
+      min_se = sip->sip_min_se->min_delta;
+    if (nta_check_session_expires(irq, sip,
+				  min_se,
+				  SIPTAG_USER_AGENT_STR(user_agent),
+				  TAG_END()))
+      return 422;
   }
 
-  /* Add the session usage */
-  if (sr->sr_usage == NULL) {
-    sr->sr_usage = nua_dialog_usage_add(nh, ds, nua_session_usage, NULL);
-    if (sr->sr_usage == NULL)
-      return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-  }
+  return 0;
+}
 
-  ss = nua_dialog_usage_private(sr->sr_usage);
+/** @internal Process incoming invite - initiate media, etc. */
+static
+int process_invite(nua_t *nua,
+		   nua_handle_t *nh,
+		   nua_server_request_t *sr,
+		   sip_t *sip)
+{
+  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
 
-  if (sr->sr_offer_recv)
-    ss->ss_oa_recv = "offer";
+  assert(ss); assert(status == 100);
 
   ss->ss_100rel = NH_PGET(nh, early_media);
-  ss->ss_precondition = sip_has_feature(request->sip_require, "precondition");
+  ss->ss_precondition = sip_has_feature(sip->sip_require, "precondition");
   if (ss->ss_precondition)
     ss->ss_100rel = 1;
 
@@ -1864,7 +1776,11 @@
 
   /* Session Timer negotiation */
   if (sip_has_supported(NH_PGET(nh, supported), "timer"))
-    init_session_timer(ss, request, ss->ss_refresher);
+    init_session_timer(ss, sip, ss->ss_refresher);
+
+  nua_dialog_uas_route(nh, nh->nh_ds, sip, 1);	/* Set route and tags */
+
+  nta_incoming_bind(sr->sr_irq, process_ack_or_cancel, sr);
 
   assert(ss->ss_state >= nua_callstate_ready ||
 	 ss->ss_state == nua_callstate_init);
@@ -1877,238 +1793,269 @@
 	*/
        nh->nh_soa &&
        !NH_PISSET(nh, auto_answer))) {
-    SR_STATUS1(sr, SIP_200_OK);
+    SET_STATUS1(SIP_200_OK);
   }
   else if (NH_PGET(nh, auto_alert)) {
     if (ss->ss_100rel &&
-	(sip_has_feature(request->sip_supported, "100rel") ||
-	 sip_has_feature(request->sip_require, "100rel"))) {
-      SR_STATUS1(sr, SIP_183_SESSION_PROGRESS);
+	(sip_has_feature(nh->nh_ds->ds_remote_ua->nr_supported, "100rel") ||
+	 sip_has_feature(nh->nh_ds->ds_remote_ua->nr_require, "100rel"))) {
+      SET_STATUS1(SIP_183_SESSION_PROGRESS);
     }
     else {
-      SR_STATUS1(sr, SIP_180_RINGING);
+      SET_STATUS1(SIP_180_RINGING);
     }
   }
 
+  /* Magical value indicating autoanswer within respond_to_invite() */
+#define AUTOANSWER ((void*)-1)
+
+  if (status > 100) {
+    sr->sr_auto = 1;
+    nua_server_respond(sr, status, phrase, TAG_END());
+    sr->sr_auto = 0;
+    return 0;
+  }
+
+  nta_incoming_treply(sr->sr_irq, SIP_100_TRYING, 
+		      SIPTAG_USER_AGENT_STR(NUA_PGET(nua, nh, user_agent)),
+		      TAG_END());
+
+  nua_stack_event(nh->nh_nua, nh, 
+		  sr->sr_msg = nta_incoming_getrequest(sr->sr_irq),
+		  nua_i_invite, SIP_100_TRYING,
+		  NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
+		  TAG_END());
+
+  signal_call_state_change(nh, ss, SIP_100_TRYING,
+			   nua_callstate_received,
+			   sr->sr_offer_recv ? "offer" : 0, 0);
+
   return 0;
 }
 
-
 /** @internal Respond to an INVITE request.
  *
+ * XXX - use tags to indicate when to use reliable responses.
+ * XXX - change prototype.
  */
 static
-int nua_invite_server_respond(nua_server_request_t *sr, tagi_t const *tags)
+int respond_to_invite(nua_server_request_t *sr, tagi_t const *tags)
 {
   nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_usage_t *du = sr->sr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  msg_t *msg = sr->sr_response.msg; 
-  sip_t *sip = sr->sr_response.sip; 
+  nua_t *nua = nh->nh_nua;
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_dialog_usage_t *du;
+  nua_session_usage_t *ss;
+  msg_t *msg;
+  sip_t *sip;
+  int reliable;
+  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
+  sip_warning_t *warning = NULL;
 
-  int reliable = 0, offer = 0, answer = 0, early_answer = 0, extra = 0;
+  int offer = 0, answer = 0, early_answer = 0;
 
   enter;
 
-  if (du == NULL) {
-    if (sr->sr_status < 300)
-      sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
-    return nua_base_server_respond(sr, tags);
-  }
+  du = sr->sr_usage, ss = nua_dialog_usage_private(du);
 
-  if (nua_invite_server_is_100rel(sr, tags)) {
-    reliable = 1, early_answer = 1;
-  }
-  else if (!nh->nh_soa || sr->sr_status >= 300) {
-    
-  }
-  else if (tags && 100 < sr->sr_status && sr->sr_status < 200 && 
-      !NHP_ISSET(nh->nh_prefs, early_answer)) {
-    sdp_session_t const *user_sdp = NULL;
-    char const *user_sdp_str = NULL;
-
-    tl_gets(tags,
-	    SOATAG_USER_SDP_REF(user_sdp),
-	    SOATAG_USER_SDP_STR_REF(user_sdp_str),
-	    TAG_END());
+  if (du == NULL)
+    return nua_default_respond(sr, tags);
 
-    early_answer = user_sdp || user_sdp_str;
-  }
-  else {
-    early_answer = NH_PGET(nh, early_answer);
-  }
+  assert(ss == nua_session_usage_get(nh->nh_ds));
+
+  if (tags) {
+    nua_stack_set_params(nua, nh, nua_i_error, tags);
 
-  if (!nh->nh_soa) {
-    /* Xyzzy */
+    if (!NHP_ISSET(nh->nh_prefs, early_answer)
+	&& 100 < status && status < 200) {
+      sdp_session_t const *user_sdp = NULL;
+      char const *user_sdp_str = NULL;
+
+      tl_gets(tags,
+	      SOATAG_USER_SDP_REF(user_sdp),
+	      SOATAG_USER_SDP_STR_REF(user_sdp_str),
+	      TAG_END());
+
+      early_answer = user_sdp || user_sdp_str;
+    }
+    else
+      early_answer = NH_PGET(nh, early_answer);
   }
-  else if (sr->sr_status >= 300) {
+
+  msg = nua_server_response(sr,
+			    status, phrase,
+			    TAG_IF(status < 300, NUTAG_ADD_CONTACT(1)),
+			    SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
+			    TAG_NEXT(tags));
+  sip = sip_object(msg);
+
+  if (!sip) {
+    SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR), reliable = 0;
+    goto send_response;
+  }
+
+  reliable =
+    (status >= 200)
+    || (status > 100 && sip->sip_require &&
+	sip_has_feature(sip->sip_require, "100rel"))
+    || (status > 100 &&
+	ds->ds_remote_ua->nr_require &&
+	sip_has_feature(ds->ds_remote_ua->nr_require, "100rel"))
+    || (status > 100 && !NH_PGET(nh, only183_100rel) &&
+	(NH_PGET(nh, early_media) ||
+	 (ds->ds_remote_ua->nr_require &&
+	  sip_has_feature(ds->ds_remote_ua->nr_require, "precondition"))) &&
+	ds->ds_remote_ua->nr_supported &&
+	sip_has_feature(ds->ds_remote_ua->nr_supported, "100rel"))
+    || (status == 183 &&
+	ds->ds_remote_ua->nr_supported &&
+	sip_has_feature(ds->ds_remote_ua->nr_supported, "100rel"))
+    || (status == 183 &&
+	ds->ds_remote_ua->nr_require &&
+	sip_has_feature(ds->ds_remote_ua->nr_require, "precondition"))
+    || (status > 100 &&
+	ds->ds_remote_ua->nr_require &&
+	sip_has_feature(ds->ds_remote_ua->nr_require, "precondition") &&
+	sr->sr_offer_recv && !sr->sr_answer_sent);
+
+  if (!nh->nh_soa)
+    /* Xyzzy */;
+  else if (status >= 300) {
     soa_clear_remote_sdp(nh->nh_soa);
   }
-  else if (sr->sr_offer_sent && !sr->sr_answer_recv)
-    /* Wait for answer */;
-  else if (sr->sr_offer_recv && sr->sr_answer_sent > 1) {
-    /* We have sent answer */
-    /* ...  but we may want to send it again */
-    tagi_t const *t = tl_find_last(tags, nutag_include_extra_sdp);
-    extra = t && t->t_value;
-  }
-  else if (sr->sr_offer_recv && !sr->sr_answer_sent && early_answer) {
-    /* Generate answer */ 
-    if (soa_generate_answer(nh->nh_soa, NULL) >= 0) {
-      answer = 1;
-      soa_activate(nh->nh_soa, NULL);
-      /* signal that O/A answer sent (answer to invite) */
-    }
-    else if (sr->sr_status >= 200) {
-      sip_warning_t *warning = NULL;
-      int wcode;
-      char const *text;
-      char const *host = "invalid.";
-      
-      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
-      
-      wcode = soa_get_warning(nh->nh_soa, &text);
-      
-      if (wcode) {
-	if (sip->sip_contact)
-	  host = sip->sip_contact->m_url->url_host;
-	warning = sip_warning_format(msg_home(msg), "%u %s \"%s\"",
-				     wcode, host, text);
-	sip_header_insert(msg, sip, (sip_header_t *)warning);
+  else {
+    int extra = 0;
+
+    if (sr->sr_offer_sent && !sr->sr_answer_recv)
+      /* Wait for answer */;
+    else if (sr->sr_offer_recv && sr->sr_answer_sent > 1) {
+      /* We have sent answer */
+      /* ...  but we may want to send it again */
+      tagi_t const *t = tl_find_last(tags, nutag_include_extra_sdp);
+      extra = t && t->t_value;
+    }
+    else if (sr->sr_offer_recv && !sr->sr_answer_sent && 
+	     (reliable || early_answer)) {
+      /* Generate answer */ 
+      if (soa_generate_answer(nh->nh_soa, NULL) >= 0) {
+	answer = 1;
+	soa_activate(nh->nh_soa, NULL);
+	/* signal that O/A answer sent (answer to invite) */
+      }
+      else if (status >= 200) {
+	int wcode;
+	char const *text;
+	char const *host = "invalid.";
+	status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+
+	wcode = soa_get_warning(nh->nh_soa, &text);
+	if (wcode) {
+	  if (sip->sip_contact)
+	    host = sip->sip_contact->m_url->url_host;
+	  warning = sip_warning_format(msg_home(msg), "%u %s \"%s\"",
+				       wcode, host, text);
+	}
+      }
+      else {
+	/* 1xx - we don't have to send answer */
       }
     }
-    else {
-      /* 1xx - we don't have to send answer */
+    else if (sr->sr_offer_recv && sr->sr_answer_sent == 1 && 
+	     (reliable || early_answer)) {
+      /* The answer was sent unreliably, keep sending it */
+      answer = 1;
+    }
+    else if (!sr->sr_offer_recv && !sr->sr_offer_sent && reliable) {
+      /* Generate offer */
+      if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0)
+	status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+      else
+	offer = 1;
     }
-  }
-  else if (sr->sr_offer_recv && sr->sr_answer_sent == 1 && early_answer) {
-    /* The answer was sent unreliably, keep sending it */
-    answer = 1;
-  }
-  else if (!sr->sr_offer_recv && !sr->sr_offer_sent && reliable) {
-    /* Generate offer */
-    if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0)
-      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
-    else
-      offer = 1;
-  }
-
-  if (sr->sr_status < 300 && (offer || answer || extra)) {
-    if (session_include_description(nh->nh_soa, 1, msg, sip) < 0)
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-    else if (offer)
-      sr->sr_offer_sent = 1, ss->ss_oa_sent = "offer";
-    else if (answer)
-      sr->sr_answer_sent = 1 + reliable, ss->ss_oa_sent = "answer";
-  }
 
-  if (reliable && sr->sr_status < 200) {
-    sr->sr_response.msg = NULL, sr->sr_response.sip = NULL;
-    if (nta_reliable_mreply(sr->sr_irq, process_prack, nh, msg) == NULL)
-      return -1;
-    return 0;
+    if (offer || answer || extra) {
+      if (session_include_description(nh->nh_soa, 1, msg, sip) < 0)
+	SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
+    }
   }
 
-  if (ss->ss_refresher && 200 <= sr->sr_status && sr->sr_status < 300)
+  if (ss->ss_refresher && 200 <= status && status < 300)
     if (session_timer_is_supported(nh))
       use_session_timer(ss, 1, 1, msg, sip);
 
-  return nua_base_server_respond(sr, tags);  
-}
-
-/** Check if the response should be sent reliably.
- * XXX - use tags to indicate when to use reliable responses ???
- */
-static
-int nua_invite_server_is_100rel(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  sip_t const *sip = sr->sr_response.sip;
-  sip_require_t *require = sr->sr_request.sip->sip_require;
-  sip_supported_t *supported = sr->sr_request.sip->sip_supported;
-
-  if (sr->sr_status >= 200)
-    return 1;
-  else if (sr->sr_status == 100)
-    return 0;
-
-  if (sip_has_feature(sip->sip_require, "100rel"))
-    return 1;
-
-  if (require == NULL && supported == NULL)
-    return 0;
-
-  if (sip_has_feature(require, "100rel"))
-    return 1;
-  if (!sip_has_feature(supported, "100rel"))
-    return 0;
-  if (sr->sr_status == 183)
-    return 1;
-
-  if (NH_PGET(nh, early_media) && !NH_PGET(nh, only183_100rel))
-    return 1;
-
-  if (sip_has_feature(require, "precondition")) {
-    if (!NH_PGET(nh, only183_100rel))
-      return 1;
-    if (sr->sr_offer_recv && !sr->sr_answer_sent)
-      return 1;
+  if (reliable && status < 200) {
+    nta_reliable_t *rel;
+    rel = nta_reliable_mreply(sr->sr_irq,
+			      process_prack, nh, msg);
+    if (!rel)
+      SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
+  }
+
+ send_response:
+
+  if (reliable && status < 200)
+    /* we are done */;
+  else if (status != sr->sr_status) {    /* Error responding */
+    assert(status >= 200);
+    sr->sr_respond = NULL;
+    nta_incoming_treply(sr->sr_irq,
+			status, phrase,
+			SIPTAG_WARNING(warning),
+			SIPTAG_USER_AGENT_STR(NH_PGET(nh, user_agent)),
+			TAG_END());
+    msg_destroy(msg), msg = NULL;
   }
-
-  return 0;
-}
-
-
-int nua_invite_server_report(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_usage_t *du = sr->sr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-  int initial = sr->sr_initial && !sr->sr_event;
-  int neutral = sr->sr_neutral;
-  int application = sr->sr_application;
-  int status = sr->sr_status; char const *phrase = sr->sr_phrase;
-  int retval;
-
-  if (!sr->sr_event && status < 300) {	/* Not reported yet */
-    nta_incoming_bind(sr->sr_irq, process_ack_or_cancel, sr);
+  else {
+    if (status >= 200)
+      sr->sr_respond = NULL;
+    nta_incoming_mreply(sr->sr_irq, msg);
+  }
+
+  if (sr->sr_auto) {
+    msg_t *request = nta_incoming_getrequest(sr->sr_irq);
+    if (status < 200)
+      sr->sr_msg = request;
+    nua_stack_event(nh->nh_nua, nh, request,
+		    nua_i_invite, status, phrase,
+		    NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
+		    TAG_END());
   }
+  else if (status != sr->sr_status)
+    nua_stack_event(nua, nh, NULL, nua_i_error, status, phrase, TAG_END());
 
-  retval = nua_base_server_report(sr, tags), sr = NULL; /* destroys sr */
-  
-  if (retval >= 2 || ss == NULL) {
-    /* Session has been terminated. */ 
-    if (!initial && !neutral)
-      signal_call_state_change(nh, NULL, status, phrase,
-			       nua_callstate_terminated);
-    return retval;
-  }
+  sr->sr_status = status, sr->sr_phrase = phrase;
+
+  if (status >= 300)
+    offer = 0, answer = 0;
 
-  assert(ss);
+  if (offer)
+    sr->sr_offer_sent = 1;
+  else if (answer)
+    sr->sr_answer_sent = 1 + reliable;
 
   /* Update session state */
-  if (status < 300 || application != 0) {
-    assert(ss->ss_state != nua_callstate_calling);
-    assert(ss->ss_state != nua_callstate_proceeding);
-    signal_call_state_change(nh, ss, status, phrase,
-			     status >= 300
-			     ? nua_callstate_init
-			     : status >= 200
-			     ? nua_callstate_completed
-			     : status > 100
-			     ? nua_callstate_early
-			     : nua_callstate_received);
-  }
+  assert(ss->ss_state != nua_callstate_calling);
+  assert(ss->ss_state != nua_callstate_proceeding);
+
+  signal_call_state_change(nh, ss, status, phrase,
+			   status >= 300
+			   ? nua_callstate_init
+			   : status >= 200
+			   ? nua_callstate_completed
+			   : nua_callstate_early,
+			   sr->sr_auto && sr->sr_offer_recv ? "offer" : 0,
+			   offer ? "offer" : answer ? "answer" : 0);
 
   if (status == 180)
     ss->ss_alerting = 1;
   else if (status >= 200)
     ss->ss_alerting = 0;
 
-  if (200 <= status && status < 300) {
-     du->du_ready = 1;
+  if (status >= 200 && status < 300) {
+    du->du_ready = 1;
   }
-  else if (300 <= status && !neutral) {
+  else if (status >= 300) {
+    sr->sr_usage = NULL;
     if (nh->nh_soa)
       soa_init_offer_answer(nh->nh_soa);
   }
@@ -2118,9 +2065,10 @@
     nua_session_usage_destroy(nh, ss);
   }
 
-  return retval;
+  return status >= 300 ? status : 0;
 }
 
+
 /** @internal Process ACK or CANCEL or timeout (no ACK) for incoming INVITE */
 static
 int process_ack_or_cancel(nua_server_request_t *sr,
@@ -2129,15 +2077,148 @@
 {
   enter;
 
-  assert(sr->sr_usage);
-  assert(sr->sr_usage->du_class == nua_session_usage);
+  assert(sr->sr_usage);
+  assert(sr->sr_usage->du_class == nua_session_usage);
+
+  if (sip && sip->sip_request->rq_method == sip_method_ack)
+    return process_ack(sr, irq, sip);
+  else if (sip && sip->sip_request->rq_method == sip_method_cancel)
+    return process_cancel(sr, irq, sip);
+  else
+    return process_timeout(sr, irq);
+}
+
+/** @NUA_EVENT nua_i_prack
+ *
+ * Incoming PRACK request. PRACK request is used to acknowledge reliable
+ * preliminary responses and it is usually sent automatically by the nua
+ * stack.
+ *
+ * @param status status code of response sent automatically by stack
+ * @param phrase a short textual description of @a status code
+ * @param nh     operation handle associated with the call
+ * @param hmagic application context associated with the call
+ * @param sip    incoming INFO request
+ * @param tags   empty
+ *
+ * @sa nua_prack(), #nua_r_prack, @RFC3262, NUTAG_EARLY_MEDIA()
+ * 
+ * @END_NUA_EVENT
+ */
+
+/** @internal Process PRACK or (timeout from 100rel) */
+static
+int process_prack(nua_handle_t *nh,
+		  nta_reliable_t *rel,
+		  nta_incoming_t *irq,
+		  sip_t const *sip)
+{
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_dialog_usage_t *du;
+  nua_session_usage_t *ss;
+  nua_server_request_t *sri;
+  int status = 200; char const *phrase = sip_200_OK;
+  char const *recv = NULL, *sent = NULL;
+
+  nta_reliable_destroy(rel);
+
+  ss = nua_session_usage_get(ds); du = nua_dialog_usage_public(ss);
+
+  for (sri = ds->ds_sr; sri; sri = sri->sr_next) {
+    if (sri->sr_method == sip_method_invite && sri->sr_usage == du)
+      break;
+  }
+                     
+  if (!sri || !sri->sr_respond) /* XXX */
+    return 481;
+
+  if (sip)
+    /* received PRACK */;
+  else if (!sri || irq == NULL) { /* Final response interrupted 100rel */
+    /* Ignore */
+    return 200;
+  }
+  else if (sip == NULL) {
+    SET_STATUS(504, "Reliable Response Timeout");
+
+    nua_stack_event(nh->nh_nua, nh, NULL,
+		    nua_i_error, status, phrase,
+		    TAG_END());
+
+    nua_server_respond(sri, status, phrase, TAG_END());
+
+    return status;
+  }
+
+  if (nh->nh_soa) {
+    msg_t *msg = nta_incoming_getrequest(irq);
+    char const *sdp;
+    size_t len;
+
+    if (session_get_description(sip, &sdp, &len)) {
+      su_home_t home[1] = { SU_HOME_INIT(home) };
+
+      sip_content_disposition_t *cd = NULL;
+      sip_content_type_t *ct = NULL;
+      sip_payload_t *pl = NULL;
+
+      if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
+	SU_DEBUG_5(("nua(%p): error parsing SDP in INVITE\n", nh));
+	msg_destroy(msg);
+	status = 400, phrase = "Bad Session Description";
+      }
+
+      /* Respond to PRACK */
+
+      if (status >= 300)
+	;
+      else if (sri->sr_offer_sent) {
+	recv = "answer";
+	sri->sr_answer_recv = 1;
+	if (soa_process_answer(nh->nh_soa, NULL) < 0)
+	  status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+      }
+      else {
+	recv = "offer";
+	if (soa_generate_answer(nh->nh_soa, NULL) < 0) {
+	  status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+	}
+	else {
+	  if (session_make_description(home, nh->nh_soa, 1, &cd, &ct, &pl) > 0)
+	    sent = "answer";
+	}
+      }
+
+      if (nta_incoming_treply(irq, status, phrase,
+			      SIPTAG_CONTENT_DISPOSITION(cd),
+			      SIPTAG_CONTENT_TYPE(ct),
+			      SIPTAG_PAYLOAD(pl),
+			      TAG_END()) < 0)
+	/* Respond with 500 if nta_incoming_treply() failed */
+	SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
+
+      su_home_deinit(home);
+    }
+
+    msg_destroy(msg);
+  }
+
+  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
+		  nua_i_prack, status, phrase, TAG_END());
 
-  if (sip && sip->sip_request->rq_method == sip_method_ack)
-    return process_ack(sr, irq, sip);
-  else if (sip && sip->sip_request->rq_method == sip_method_cancel)
-    return process_cancel(sr, irq, sip);
-  else
-    return process_timeout(sr, irq);
+  if (status >= 300)
+    return status;
+
+  if (recv || sent) {
+    soa_activate(nh->nh_soa, NULL);
+    signal_call_state_change(nh, ss, status, phrase,
+			     nua_callstate_early, recv, sent);
+  }
+
+  if (NH_PGET(nh, auto_alert) && !ss->ss_alerting && !ss->ss_precondition)
+    nua_server_respond(sri, SIP_180_RINGING, TAG_END());
+
+  return status;
 }
 
 /** @NUA_EVENT nua_i_ack
@@ -2171,7 +2252,6 @@
   if (nh->nh_soa && sr->sr_offer_sent && !sr->sr_answer_recv) {
     char const *sdp;
     size_t len;
-    int error;
 
     if (!session_get_description(sip, &sdp, &len) ||
 	!(recv = "answer") ||
@@ -2184,30 +2264,23 @@
       reason = soa_error_as_sip_reason(nh->nh_soa);
 
       nua_stack_event(nh->nh_nua, nh, msg,
-		      nua_i_ack, status, phrase, NULL);
+	       nua_i_ack, status, phrase, TAG_END());
       nua_stack_event(nh->nh_nua, nh, NULL,
-		      nua_i_media_error, status, phrase, NULL);
-
-      assert(ss->ss_oa_recv == NULL);
-
-      ss->ss_oa_recv = recv;
-
-      ss->ss_reporting = 1;	/* We report state here if BYE fails */
-      error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
-      ss->ss_reporting = 0;
+	       nua_i_media_error, status, phrase, TAG_END());
 
       signal_call_state_change(nh, ss, 488, "Offer-Answer Error",
-			       error
-			       ? nua_callstate_terminated
-			       : nua_callstate_terminating);
+			       nua_callstate_terminating, recv, 0);
+      nua_stack_post_signal(nh, nua_r_bye,
+			    SIPTAG_REASON_STR(reason),
+			    TAG_END());
 
       return 0;
     }
   }
 
   soa_clear_remote_sdp(nh->nh_soa);
-  nua_stack_event(nh->nh_nua, nh, msg, nua_i_ack, SIP_200_OK, NULL);
-  signal_call_state_change(nh, ss, 200, "OK", nua_callstate_ready);
+  nua_stack_event(nh->nh_nua, nh, msg, nua_i_ack, SIP_200_OK, TAG_END());
+  signal_call_state_change(nh, ss, 200, "OK", nua_callstate_ready, recv, 0);
   set_session_timer(ss);
 
   nua_server_request_destroy(sr);
@@ -2239,21 +2312,14 @@
 {
   nua_handle_t *nh = sr->sr_owner;
   nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
+  msg_t *cancel = nta_incoming_getrequest_ackcancel(irq);
 
-  assert(ss); assert(ss == nua_session_usage_for_dialog(nh->nh_ds)); (void)ss;
-
-  if (nua_server_request_is_pending(sr)) {
-    msg_t *cancel = nta_incoming_getrequest_ackcancel(irq);
-
-    assert(nta_incoming_status(irq) < 200);
+  assert(nta_incoming_status(irq) < 200);  assert(sr->sr_respond);
+  assert(ss); assert(ss == nua_session_usage_get(nh->nh_ds)); (void)ss;
 
-    nua_stack_event(nh->nh_nua, nh, cancel, nua_i_cancel, SIP_200_OK, NULL);
+  nua_stack_event(nh->nh_nua, nh, cancel, nua_i_cancel, SIP_200_OK, TAG_END());
 
-    SR_STATUS1(sr, SIP_487_REQUEST_TERMINATED);
-
-    nua_server_respond(sr, NULL);
-    nua_server_report(sr);
-  }
+  nua_server_respond(sr, SIP_487_REQUEST_TERMINATED, TAG_END());
 
   return 0;
 }
@@ -2265,41 +2331,31 @@
 {
   nua_handle_t *nh = sr->sr_owner;
   nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-  char const *phrase = "ACK Timeout";
-  char const *reason = "SIP;cause=408;text=\"ACK Timeout\"";
-  int error;
 
-  assert(ss); assert(ss == nua_session_usage_for_dialog(nh->nh_ds));
-
-  if (nua_server_request_is_pending(sr)) {
-    phrase = "PRACK Timeout";
-    reason = "SIP;cause=504;text=\"PRACK Timeout\"";
-  }
+  assert(ss); assert(ss == nua_session_usage_get(nh->nh_ds));
 
-  nua_stack_event(nh->nh_nua, nh, 0, nua_i_error, 408, phrase, NULL);
+  nua_stack_event(nh->nh_nua, nh, 0, nua_i_error,
+		  408, "Response timeout",
+		  TAG_END());
 
-  if (nua_server_request_is_pending(sr)) {
+  if (sr->sr_respond) {
     /* PRACK timeout */
-    SR_STATUS1(sr, SIP_504_GATEWAY_TIME_OUT);
-    nua_server_trespond(sr, 
-			SIPTAG_REASON_STR(reason),
-			TAG_END());
-    if (nua_server_report(sr) >= 2)
-      return 0;			/* Done */
+    nua_server_respond(sr, SIP_504_GATEWAY_TIME_OUT,
+		       SIPTAG_REASON_STR("SIP;cause=504;"
+					 "text=\"PRACK Timeout\""),
+		       TAG_END());
+    ss = nua_session_usage_get(nh->nh_ds);
     sr = NULL;
   }
 
-  /* send BYE, too, if 200 OK (or 183 to re-INVITE) timeouts  */
-  ss->ss_reason = reason;
-
-  ss->ss_reporting = 1;		/* We report state here if BYE fails */
-  error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
-  ss->ss_reporting = 0;
-
-  signal_call_state_change(nh, ss, 0, phrase,
-			   error
-			   ? nua_callstate_terminated
-			   : nua_callstate_terminating);
+  if (ss) {
+    /* send BYE, too if 200 OK (or 183 to re-INVITE) timeouts  */
+    signal_call_state_change(nh, ss, 0, "Timeout",
+			     nua_callstate_terminating, 0, 0);
+    nua_stack_post_signal(nh, nua_r_bye,
+			  SIPTAG_REASON_STR("SIP;cause=408;text=\"ACK Timeout\""),
+			  TAG_END());
+  }
 
   if (sr)
     nua_server_request_destroy(sr);
@@ -2308,206 +2364,6 @@
 }
 
 
-/** @NUA_EVENT nua_i_prack
- *
- * Incoming PRACK request. PRACK request is used to acknowledge reliable
- * preliminary responses and it is usually sent automatically by the nua
- * stack.
- *
- * @param status status code of response sent automatically by stack
- * @param phrase a short textual description of @a status code
- * @param nh     operation handle associated with the call
- * @param hmagic application context associated with the call
- * @param sip    incoming PRACK request
- * @param tags   empty
- *
- * @sa nua_prack(), #nua_r_prack, @RFC3262, NUTAG_EARLY_MEDIA()
- * 
- * @END_NUA_EVENT
- */
-
-int nua_prack_server_init(nua_server_request_t *sr);
-int nua_prack_server_preprocess(nua_server_request_t *sr);
-int nua_prack_server_respond(nua_server_request_t *sr, tagi_t const *tags);
-int nua_prack_server_report(nua_server_request_t *sr, tagi_t const *tags);
-
-nua_server_methods_t const nua_prack_server_methods = 
-  {
-    SIP_METHOD_PRACK,
-    nua_i_prack,		/* Event */
-    { 
-      0,			/* Do not create dialog */
-      1,			/* In-dialog request */
-      1,			/* Target refresh request  */
-      1,			/* Add Contact */
-    },
-    nua_prack_server_init,
-    nua_prack_server_preprocess,
-    nua_base_server_params,
-    nua_prack_server_respond,
-    nua_prack_server_report,
-  };
-
-/** @internal Process reliable response PRACK or (timeout from 100rel) */
-static int process_prack(nua_handle_t *nh,
-			 nta_reliable_t *rel,
-			 nta_incoming_t *irq,
-			 sip_t const *sip)
-{
-  nua_dialog_state_t *ds = nh->nh_ds;
-  nua_dialog_usage_t *du;
-  nua_server_request_t *sr;
-
-  nta_reliable_destroy(rel);
-  if (irq == NULL)  
-    /* Final response interrupted 100rel, we did not actually receive PRACK */
-    return 200;
-
-  if (!nh->nh_ds->ds_leg)
-    return 481;
-
-  du = nua_dialog_usage_for_session(ds);
-
-  for (sr = ds->ds_sr; sr; sr = sr->sr_next) {
-    if (sr->sr_method == sip_method_invite && sr->sr_usage == du)
-      break;
-  }
-
-  if (!nua_server_request_is_pending(sr)) /* There is no INVITE */
-    return 481;
-
-  if (sip == NULL) {
-    /* 100rel timeout */
-    SR_STATUS(sr, 504, "Reliable Response Timeout");
-    nua_stack_event(nh->nh_nua, nh, NULL, nua_i_error,
-		    sr->sr_status, sr->sr_phrase,
-		    NULL);
-    nua_server_trespond(sr,
-			SIPTAG_REASON_STR("SIP;cause=504;"
-					  "text=\"PRACK Timeout\""),
-			TAG_END());
-    nua_server_report(sr);
-    return 504;
-  }
-
-  nta_incoming_bind(irq, NULL, (void *)sr);
-
-  return nua_stack_process_request(nh, nh->nh_ds->ds_leg, irq, sip);
-}
-
-
-int nua_prack_server_init(nua_server_request_t *sr)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_server_request_t *sri = nta_incoming_magic(sr->sr_irq, NULL);
-
-  if (sri == NULL)
-    return SR_STATUS(sr, 481, "No Such Preliminary Response");
-  
-  if (nua_session_server_init(sr))
-    return sr->sr_status;
-
-  if (sr->sr_sdp) {
-    nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-
-    /* XXX - check for overlap? */
-    
-    if (sri->sr_offer_sent)
-      sr->sr_answer_recv = 1, ss->ss_oa_recv = "answer";
-    else 
-      sr->sr_offer_recv = 1, ss->ss_oa_recv = "offer";
-
-    if (nh->nh_soa &&
-	soa_set_remote_sdp(nh->nh_soa, NULL, sr->sr_sdp, sr->sr_sdp_len) < 0) {
-      SU_DEBUG_5(("nua(%p): %s server: error parsing %s\n", (void *)nh,
-		  "PRACK", "offer"));
-      return 
-	sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
-    }
-  }
-
-  return 0;
-}
-
-int nua_prack_server_preprocess(nua_server_request_t *sr)
-{
-  return sr_status(sr, SIP_200_OK); /* For now */
-}
-
-int nua_prack_server_respond(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-
-  if (sr->sr_status < 200 || 300 <= sr->sr_status) 
-    return nua_base_server_respond(sr, tags);
-
-  if (nh->nh_soa && sr->sr_sdp) {
-    nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-    msg_t *msg = sr->sr_response.msg;
-    sip_t *sip = sr->sr_response.sip;
-
-    if ((sr->sr_offer_recv && soa_generate_answer(nh->nh_soa, NULL) < 0) ||
-	(sr->sr_answer_recv && soa_process_answer(nh->nh_soa, NULL) < 0)) {
-      SU_DEBUG_5(("nua(%p): %s server: %s %s\n", 
-		  (void *)nh, "PRACK", 
-		  "error processing",
-		  sr->sr_offer_recv ? "offer" : "answer"));
-      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
-    }
-    else if (sr->sr_offer_recv) {
-      if (session_include_description(nh->nh_soa, 1, msg, sip) < 0)
-	sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
-      else
-      sr->sr_answer_sent = 1, ss->ss_oa_sent = "answer";
-    }
-  }
-
-  return nua_base_server_respond(sr, tags);
-}
-
-int nua_prack_server_report(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-  int retval = nua_base_server_report(sr, tags); /* destroys sr */
-
-  if (retval >= 2 || ss == NULL) {
-    signal_call_state_change(nh, NULL,
-			     sr->sr_status, sr->sr_phrase, 
-			     nua_callstate_terminated);
-    return retval;
-  }
-
-  if (sr->sr_offer_recv || sr->sr_answer_sent) {
-    /* signal offer received, answer sent */
-    signal_call_state_change(nh, ss,
-			     sr->sr_status, sr->sr_phrase, 
-			     ss->ss_state);
-    soa_activate(nh->nh_soa, NULL);
-  }
-
-  if (200 <= sr->sr_status && sr->sr_status < 300
-      && ss->ss_state < nua_callstate_ready
-      && !ss->ss_alerting
-      && !ss->ss_precondition
-      && NH_PGET(nh, auto_alert))  {
-    nua_server_request_t *sri;
-    
-    for (sri = nh->nh_ds->ds_sr; sri; sri = sri->sr_next)
-      if (sri->sr_method == sip_method_invite && 
-	  nua_server_request_is_pending(sri))
-	break;
-
-    if (sri) {
-      SR_STATUS1(sri, SIP_180_RINGING);
-      nua_server_respond(sri, NULL);
-      nua_server_report(sri);
-    }
-  }
-
-  return retval;
-}
-
 /* ---------------------------------------------------------------------- */
 /* Session timer - RFC 4028 */
 
@@ -2625,24 +2481,6 @@
   return 1;
 }
 
-static int session_timer_check_restart(nua_client_request_t *cr,
-				       int status, char const *phrase,
-				       sip_t const *sip)
-{
-  if (cr->cr_usage && status == 422) {
-    nua_session_usage_t *ss = nua_dialog_usage_private(cr->cr_usage);
-
-    if (sip->sip_min_se && ss->ss_min_se < sip->sip_min_se->min_delta)
-      ss->ss_min_se = sip->sip_min_se->min_delta;
-    if (ss->ss_min_se > ss->ss_session_timer)
-      ss->ss_session_timer = ss->ss_min_se;
-  
-    return nua_client_restart(cr, 100, "Re-Negotiating Session Timer");
-  }
-
-  return nua_base_client_check_restart(cr, status, phrase, sip);
-}
-
 static void
 set_session_timer(nua_session_usage_t *ss)
 {
@@ -2667,6 +2505,31 @@
   }
 }
 
+static int
+check_session_timer_restart(nua_handle_t *nh,
+			    nua_session_usage_t *ss,
+			    nua_client_request_t *cr,
+			    nta_outgoing_t *orq,
+			    sip_t const *sip,
+			    nua_creq_restart_f *restart_function)
+{
+  if (ss && sip && sip->sip_status->st_status == 422) {
+    if (sip->sip_min_se && ss->ss_min_se < sip->sip_min_se->min_delta)
+      ss->ss_min_se = sip->sip_min_se->min_delta;
+    if (ss->ss_min_se > ss->ss_session_timer)
+      ss->ss_session_timer = ss->ss_min_se;
+  
+    if (orq == cr->cr_orq)
+      cr->cr_orq = NULL;
+
+    return nua_creq_restart_with(nh, cr, orq,
+				 100, "Re-Negotiating Session Timer",
+				 restart_function, TAG_END());
+  }
+
+  return nua_creq_check_restart(nh, cr, orq, sip, restart_function);
+}
+
 static inline int
 is_session_timer_set(nua_session_usage_t *ss)
 {
@@ -2748,7 +2611,7 @@
     if (ref) {
       if (ref->ref_handle)
 	SU_DEBUG_1(("nh_handle_referral: stale referral handle %p\n",
-		    (void *)ref->ref_handle));
+		    ref->ref_handle));
       ref->ref_handle = NULL;
     }
     return;
@@ -2784,9 +2647,33 @@
   nua_handle_unref(ref->ref_handle), ref->ref_handle = NULL;
 }
 
+
+/** Zap the session associated with the handle */
+static
+void nua_session_usage_destroy(nua_handle_t *nh,
+			       nua_session_usage_t *ss)
+{
+  nh->nh_has_invite = 0;
+  nh->nh_active_call = 0;
+  nh->nh_hold_remote = 0;
+
+  if (nh->nh_soa)
+    soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
+
+  /* Remove usage */
+  nua_dialog_usage_remove(nh, nh->nh_ds, nua_dialog_usage_public(ss));
+
+  SU_DEBUG_5(("nua: terminated session %p\n", nh));
+}
+
+
 /* ======================================================================== */
 /* INFO */
 
+static int process_response_to_info(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip);
+
 /**@fn void nua_info(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
  * Send an INFO request. 
@@ -2809,59 +2696,41 @@
  * @sa #nua_i_info
  */
 
-static int nua_info_client_init(nua_client_request_t *cr, 
-				msg_t *msg, sip_t *sip,
-				tagi_t const *tags);
-
-static int nua_info_client_request(nua_client_request_t *cr,
-				   msg_t *msg, sip_t *sip,
-				   tagi_t const *tags);
-
-nua_client_methods_t const nua_info_client_methods = {
-  SIP_METHOD_INFO,
-  0,
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 1,
-    /* target refresh */ 0
-  },
-  /*nua_info_client_template*/ NULL,
-  nua_info_client_init,
-  nua_info_client_request,
-  /*nua_info_client_check_restart*/ NULL,
-  /*nua_info_client_response*/ NULL
-};
-
 int
 nua_stack_info(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
 {
-  return nua_client_create(nh, e, &nua_info_client_methods, tags);
-}
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg;
 
-static int nua_info_client_init(nua_client_request_t *cr, 
-				msg_t *msg, sip_t *sip,
-				tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  if (nh_is_special(nh)) {
+    return UA_EVENT2(e, 900, "Invalid handle for INFO");
+  }
+  else if (cr->cr_orq) {
+    return UA_EVENT2(e, 900, "Request already in progress");
+  }
 
-  if (!ss || ss->ss_state >= nua_callstate_terminating)
-    return nua_client_return(cr, 900, "Invalid handle for INFO", msg);
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
 
-  cr->cr_usage = du;
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
+			 SIP_METHOD_INFO ,
+			 NUTAG_ADD_CONTACT(1),
+			 TAG_NEXT(tags));
 
-  return 0;
+  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				    process_response_to_info, nh, NULL,
+				    msg,
+				    SIPTAG_END(), TAG_NEXT(tags));
+  if (!cr->cr_orq) {
+    msg_destroy(msg);
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  }
+
+  return cr->cr_event = e;
 }
 
-static int nua_info_client_request(nua_client_request_t *cr,
-				   msg_t *msg, sip_t *sip,
-				   tagi_t const *tags)
+void restart_info(nua_handle_t *nh, tagi_t *tags)
 {
-  if (cr->cr_usage == NULL)
-    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
-  else
-    return nua_base_client_request(cr, msg, sip, tags);
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_info, tags);
 }
 
 /** @NUA_EVENT nua_r_info
@@ -2885,6 +2754,15 @@
  * @END_NUA_EVENT
  */
 
+static int process_response_to_info(nua_handle_t *nh,
+				    nta_outgoing_t *orq,
+				    sip_t const *sip)
+{
+  if (nua_creq_check_restart(nh, nh->nh_ds->ds_cr, orq, sip, restart_info))
+    return 0;
+  return nua_stack_process_response(nh, nh->nh_ds->ds_cr, orq, sip, TAG_END());
+}
+
 /** @NUA_EVENT nua_i_info
  *
  * Incoming session INFO request.
@@ -2901,26 +2779,25 @@
  * @END_NUA_EVENT
  */
 
-nua_server_methods_t const nua_info_server_methods = 
-  {
-    SIP_METHOD_INFO,
-    nua_i_info,			/* Event */
-    { 
-      0,			/* Do not create dialog */
-      1,			/* In-dialog request */
-      0,			/* Not a target refresh request  */
-      0,			/* Do not add Contact */
-    },
-    nua_base_server_init,
-    nua_base_server_preprocess,
-    nua_base_server_params,
-    nua_base_server_respond,
-    nua_base_server_report,
-  };
+int nua_stack_process_info(nua_t *nua,
+			   nua_handle_t *nh,
+			   nta_incoming_t *irq,
+			   sip_t const *sip)
+{
+  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
+		  nua_i_info, SIP_200_OK, TAG_END());
+
+  return 200;		/* Respond automatically with 200 Ok */
+}
+
 
 /* ======================================================================== */
 /* UPDATE */
 
+static int process_response_to_update(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip);
+
 /**@fn void nua_update(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
  * Update a session. 
@@ -2949,134 +2826,91 @@
  * @sa @ref nua_call_model, @RFC3311, nua_update(), #nua_i_update
  */
 
-static int nua_update_client_init(nua_client_request_t *cr, 
-				  msg_t *msg, sip_t *sip,
-				  tagi_t const *tags);
-static int nua_update_client_request(nua_client_request_t *cr,
-				     msg_t *msg, sip_t *sip,
-				     tagi_t const *tags);
-static int nua_update_client_response(nua_client_request_t *cr,
-				      int status, char const *phrase,
-				      sip_t const *sip);
-static int nua_update_client_report(nua_client_request_t *cr,
-				    int status, char const *phrase,
-				    sip_t const *sip,
-				    nta_outgoing_t *orq,
-				    tagi_t const *tags);
-
-nua_client_methods_t const nua_update_client_methods = {
-  SIP_METHOD_UPDATE,
-  0,				/* size of private data */
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 1,
-    /* target refresh */ 1
-  },
-  NULL,
-  nua_update_client_init,
-  nua_update_client_request,
-  session_timer_check_restart,
-  nua_update_client_response,
-  NULL,
-  nua_update_client_report
-};
-
 int nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e,
 		     tagi_t const *tags)
 {
-  return nua_client_create(nh, e, &nua_update_client_methods, tags);
-}
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_session_usage_t *ss;
+  nua_client_request_t *cr;
+  msg_t *msg;
+  sip_t *sip;
+  char const *offer_sent = 0;
 
-static int nua_update_client_init(nua_client_request_t *cr, 
-				  msg_t *msg, sip_t *sip,
-				  tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
+  ss = nua_session_usage_get(ds);
+  cr = ds->ds_cr;
 
-  cr->cr_usage = du;
+  if (!ss)
+    return UA_EVENT2(e, 900, "Invalid handle for UPDATE");
+  else if (cr->cr_orq)
+    return UA_EVENT2(e, 900, "Request already in progress");
 
-  return 0;
-}
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
 
-static int nua_update_client_request(nua_client_request_t *cr,
-				     msg_t *msg, sip_t *sip,
-				     tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  nua_server_request_t *sr;
-  nua_client_request_t *cri;
-  int offer_sent = 0, retval;
-  
-  if (du == NULL)		/* Call terminated */
-    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
-  assert(ss);
-
-  cri = du->du_cr;
-
-  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
-    if ((sr->sr_offer_sent && !sr->sr_answer_recv) ||
-	(sr->sr_offer_recv && !sr->sr_answer_sent))
-      break;
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
+		     SIP_METHOD_UPDATE,
+		     NUTAG_USE_DIALOG(1),
+		     NUTAG_ADD_CONTACT(1),
+		     TAG_NEXT(tags));
+
+  sip = sip_object(msg);
+
+  if (sip) {
+    nua_client_request_t *cri = ss->ss_crequest;
+    nua_server_request_t *sr;
+
+    for (sr = ds->ds_sr; sr; sr = sr->sr_next)
+      if ((sr->sr_offer_sent && !sr->sr_answer_recv) ||
+	  (sr->sr_offer_recv && !sr->sr_answer_sent))
+	break;
     
-  if (nh->nh_soa && !sip->sip_payload && 
-      !sr &&
-      !(cri && cri->cr_offer_sent && !cri->cr_answer_recv) &&
-      !(cri && cri->cr_offer_recv && !cri->cr_answer_sent)) {
-    soa_init_offer_answer(nh->nh_soa);
+    if (nh->nh_soa && !sip->sip_payload && 
+	!sr &&
+	!(cri && cri->cr_offer_sent && !cri->cr_answer_recv) &&
+	!(cri && cri->cr_offer_recv && !cri->cr_answer_sent)) {
+      soa_init_offer_answer(nh->nh_soa);
 
-    if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
-	session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-      if (ss->ss_state < nua_callstate_ready) {
-	/* XXX - use soa_error_as_sip_reason(nh->nh_soa) */
-	cr->cr_graceful = 1;
-	ss->ss_reason = "SIP;cause=400;text=\"Local media failure\"";
+      if (soa_generate_offer(nh->nh_soa, 0, NULL) < 0 ||
+	  session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
+	if (ss->ss_state < nua_callstate_ready) {
+	  /* XXX */
+	}
+	msg_destroy(msg);
+	return UA_EVENT2(e, 900, "Local media failed");
       }
-      return nua_client_return(cr, 900, "Local media failed", msg);
-    }
-    offer_sent = 1;
-  }
 
-  /* Add session timer headers */
-  if (session_timer_is_supported(nh))
-    use_session_timer(ss, 0, prefer_session_timer(nh), msg, sip);
+      offer_sent = "offer";
+    }
 
-  retval = nua_base_client_request(cr, msg, sip, NULL);
+    /* Add session timer headers */
+    if (session_timer_is_supported(nh))
+      use_session_timer(ss, 0, prefer_session_timer(nh), msg, sip);
 
-  if (retval == 0) {
-    cr->cr_offer_sent = offer_sent;
-    ss->ss_update_needed = 0;
+    if (nh->nh_auth) {
+      if (auc_authorize(&nh->nh_auth, msg, sip) < 0)
+	/* xyzzy */;
+    }
 
-    if (!cr->cr_restarting) {
+    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				      process_response_to_update, nh, NULL,
+				      msg,
+				      SIPTAG_END(), TAG_NEXT(tags));
+    if (cr->cr_orq) {
       if (offer_sent)
-	ss->ss_oa_sent = "offer";
-      signal_call_state_change(nh, ss, 0, "UPDATE sent", ss->ss_state);
+	cr->cr_offer_sent = 1;
+      ss->ss_update_needed = 0;
+      signal_call_state_change(nh, ss, 0, "UPDATE sent",
+			       ss->ss_state, 0, offer_sent);
+      return cr->cr_event = e;
     }
   }
 
-  return retval;
+  msg_destroy(msg);
+  return UA_EVENT1(e, NUA_INTERNAL_ERROR);
 }
 
-static int nua_update_client_response(nua_client_request_t *cr,
-				      int status, char const *phrase,
-				      sip_t const *sip)
+void restart_update(nua_handle_t *nh, tagi_t *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-
-  assert(200 <= status);
-
-  if (ss && sip && status < 300) {
-    if (is_session_timer_set(ss)) {
-      init_session_timer(ss, sip, NH_PGET(nh, refresher));
-      set_session_timer(ss);
-    }
-  }
-
-  return nua_session_client_response(cr, status, phrase, sip);
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_update, tags);
 }
 
 /** @NUA_EVENT nua_r_update
@@ -3103,75 +2937,134 @@
  * @END_NUA_EVENT
  */
 
-static int nua_update_client_report(nua_client_request_t *cr,
-				    int status, char const *phrase,
-				    sip_t const *sip,
-				    nta_outgoing_t *orq,
-				    tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+static int process_response_to_update(nua_handle_t *nh,
+				       nta_outgoing_t *orq,
+				       sip_t const *sip)
+{
+  nua_t *nua = nh->nh_nua;
+  nua_session_usage_t *ss;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+
+  int status = sip->sip_status->st_status;
+  char const *phrase = sip->sip_status->st_phrase;
+  char const *recv = NULL;
+  int terminate = 0, gracefully = 1;
+
+  ss = nua_session_usage_get(nh->nh_ds); assert(ss);
+
+  if (status >= 300) {
+    if (sip->sip_retry_after)
+      gracefully = 0;
+
+    terminate = sip_response_terminates_dialog(status, sip_method_update,
+					       &gracefully);
+
+    if (!terminate &&
+	check_session_timer_restart(nh, ss, cr, orq, sip, restart_update)) {
+      return 0;
+    }
+    /* XXX - if we have a concurrent INVITE, what we do with it? */
+  }
+  else if (status >= 200) {
+    /* XXX - check remote tag, handle forks */
+    /* Set (route), contact, (remote tag) */
+    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+
+    if (is_session_timer_set(ss)) {
+      init_session_timer(ss, sip, NH_PGET(nh, refresher));
+      set_session_timer(ss);
+    }
+
+    if (session_process_response(nh, cr, orq, sip, &recv) < 0) {
+      nua_stack_event(nua, nh, NULL, nua_i_error,
+	       400, "Bad Session Description", TAG_END());
+    }
 
-  nua_stack_event(nh->nh_nua, nh, 
-		  nta_outgoing_getresponse(orq),
-		  cr->cr_event,
-		  status, phrase,
-		  tags);
+    signal_call_state_change(nh, ss, status, phrase, ss->ss_state, recv, 0);
 
-  if (!ss || orq != cr->cr_orq || 
-      cr->cr_terminated || cr->cr_graceful || !cr->cr_offer_sent)
-    return 1;
+    return 0;
+  }
+  else
+    gracefully = 0;
 
-  signal_call_state_change(nh, ss, status, phrase, ss->ss_state);
+  nua_stack_process_response(nh, cr, orq, sip, TAG_END());
 
-  return 1;
-}
+  if (!terminate && !gracefully)
+    return 0;
 
-/* ---------------------------------------------------------------------- */
-/* UPDATE server */
+  nh_referral_respond(nh, status, phrase);
+  
+  if (ss == NULL) {
 
-int nua_update_server_init(nua_server_request_t *sr);
-int nua_update_server_preprocess(nua_server_request_t *sr);
-int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags);
-int nua_update_server_report(nua_server_request_t *, tagi_t const *);
+  } 
+  else if (terminate || 
+      (ss->ss_state < nua_callstate_completed &&
+       ss->ss_state != nua_callstate_completing)) {
+    signal_call_state_change(nh, ss, status, phrase,
+			     nua_callstate_terminated, recv, 0);
+    nua_session_usage_destroy(nh, ss);
+  }
+  else /* if (gracefully) */ {
+    signal_call_state_change(nh, ss, status, phrase,
+			     nua_callstate_terminating, recv, 0);
+#if 0
+    if (nh->nh_ss->ss_crequest->cr_orq)
+      nua_stack_post_signal(nh, nua_r_cancel, TAG_END());
+    else
+#endif
+      nua_stack_post_signal(nh, nua_r_bye, TAG_END());
+  }
 
-nua_server_methods_t const nua_update_server_methods = 
-  {
-    SIP_METHOD_UPDATE,
-    nua_i_update,		/* Event */
-    { 
-      0,			/* Do not create dialog */
-      1,			/* In-dialog request */
-      1,			/* Target refresh request  */
-      1,			/* Add Contact */
-    },
-    nua_update_server_init,
-    nua_update_server_preprocess,
-    nua_base_server_params,
-    nua_update_server_respond,
-    nua_update_server_report,
-  };
+  return 0;
+}
 
-int nua_update_server_init(nua_server_request_t *sr)
+int nua_stack_process_update(nua_t *nua,
+			     nua_handle_t *nh,
+			     nta_incoming_t *irq,
+			     sip_t const *sip)
 {
-  nua_handle_t *nh = sr->sr_owner;
+  nua_dialog_state_t *ds = nh->nh_ds;
   nua_session_usage_t *ss;
+  nua_dialog_usage_t *du;
+  msg_t *msg = nta_incoming_getrequest(irq);
+
+  char const *sdp;
+  size_t len;
 
-  sip_t const *request = sr->sr_request.sip;
+  int original_status = 200, status = 200;
+  char const *phrase = sip_200_OK;
 
-  if (nua_session_server_init(sr))
-    return sr->sr_status;
+  char const *offer_recv = NULL, *answer_sent = NULL;
+  int use_timer = 0;
+
+  msg_t *rmsg;
+  sip_t *rsip;
+
+  ss = nua_session_usage_get(ds); du = nua_dialog_usage_public(ss);
+  if (!ss) {
+    /* RFC 3261 section 12.2.2:
+       If the UAS wishes to reject the request because it does not wish to
+       recreate the dialog, it MUST respond to the request with a 481
+       (Call/Transaction Does Not Exist) status code and pass that to the
+       server transaction.
+    */
+    return 481;
+  }
 
-  ss = nua_dialog_usage_private(sr->sr_usage);
+  if (session_check_request(nua, nh, irq, sip))
+    return 501;
 
   /* Do session timer negotiation */
-  if (request->sip_session_expires)
-    init_session_timer(ss, request, NH_PGET(nh, refresher));
+  if (sip->sip_session_expires) {
+    use_timer = 1;
+    init_session_timer(ss, sip, NH_PGET(nh, refresher));
+  }
 
-  if (sr->sr_sdp) {		/* Check for overlap */
+  if (status < 300 && nh->nh_soa &&
+      session_get_description(sip, &sdp, &len)) {
     nua_client_request_t *cr;
-    nua_server_request_t *sr0;
+    nua_server_request_t *sr;
     int overlap = 0;
 
     /*
@@ -3189,76 +3082,70 @@
       reject the UPDATE with a 500 response, and MUST include a Retry-After
       header field with a randomly chosen value between 0 and 10 seconds.
     */
-    for (cr = nh->nh_ds->ds_cr; cr; cr = cr->cr_next)
-      if ((overlap = cr->cr_offer_sent && !cr->cr_answer_recv))
-	break;
-
-    if (!overlap)
-      for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next)
-	if ((overlap = sr0->sr_offer_recv && !sr0->sr_answer_sent))
-	  break;
+    for (cr = ds->ds_cr; cr && !overlap; cr = cr->cr_next)
+      overlap = cr->cr_offer_sent && !cr->cr_answer_recv;
+    for (sr = ds->ds_sr; sr && !overlap; sr = sr->sr_next)
+      overlap = (sr->sr_offer_recv && !sr->sr_answer_sent) ||
+	(sr->sr_method == sip_method_update && sr->sr_respond);
 
     if (overlap)
-      return nua_server_retry_after(sr, 500, "Overlapping Offer/Answer", 1, 9);
-
-    if (nh->nh_soa &&
-	soa_set_remote_sdp(nh->nh_soa, NULL, sr->sr_sdp, sr->sr_sdp_len) < 0) {
-      SU_DEBUG_5(("nua(%p): %s server: error parsing %s\n", (void *)nh,
-		  "UPDATE", "offer"));
-      return 
-	sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
-    }
+      return respond_with_retry_after(nh, irq, 
+				      500, "Overlapping Offer/Answer",
+				      0, 10);
 
-    sr->sr_offer_recv = 1;
-    ss->ss_oa_recv = "offer";
-  }
-
-  return 0;
-}
-
-int nua_update_server_preprocess(nua_server_request_t *sr)
-{
-  return sr_status(sr, SIP_200_OK); /* For now */
-}
-
-/** @internal Respond to an UPDATE request.
- *
- */
-int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-  soa_session_t *soa = nh->nh_soa;
-
-  msg_t *msg = sr->sr_response.msg;
-  sip_t *sip = sr->sr_response.sip;
+    offer_recv = "offer";
 
-  if (200 <= sr->sr_status && sr->sr_status < 300 && soa && sr->sr_sdp) {
-    if (soa_generate_answer(nh->nh_soa, NULL) < 0) {
-      SU_DEBUG_5(("nua(%p): %s server: %s %s\n", 
-		  (void *)nh, "UPDATE", "error processing", "offer"));
-      sr->sr_status = soa_error_as_sip_response(nh->nh_soa, &sr->sr_phrase);
+    if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
+      SU_DEBUG_5(("nua(%p): error parsing SDP in UPDATE\n", nh));
+      msg_destroy(msg);
+      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
+      offer_recv = NULL;
+    }
+    /* Respond to UPDATE */
+    else if (soa_generate_answer(nh->nh_soa, NULL) < 0) {
+      SU_DEBUG_5(("nua(%p): error processing SDP in UPDATE\n", nh));
+      msg_destroy(msg);
+      status = soa_error_as_sip_response(nh->nh_soa, &phrase);
     }
     else if (soa_activate(nh->nh_soa, NULL) < 0) {
-      SU_DEBUG_5(("nua(%p): %s server: error activating media\n",
-		  (void *)nh, "UPDATE"));
+      SU_DEBUG_5(("nua(%p): error activating media after %s\n",
+		  nh, "UPDATE"));
       /* XXX */
     }
-    else if (session_include_description(nh->nh_soa, 1, msg, sip) < 0) {
-      sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    else {
+      answer_sent = "answer";
     }
-    else
-      sr->sr_answer_sent = 1, ss->ss_oa_sent = "answer";
   }
 
-  if (ss->ss_refresher && 200 <= sr->sr_status && sr->sr_status < 300)
-    if (session_timer_is_supported(nh)) {
-      use_session_timer(ss, 1, 1, msg, sip);
-      set_session_timer(ss);	/* XXX */
-    }
+  rmsg = nh_make_response(nua, nh, irq,
+			  status, phrase,
+			  TAG_IF(status < 300, NUTAG_ADD_CONTACT(1)),
+			  SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
+			  TAG_NEXT(NULL));
+  rsip = sip_object(rmsg);
+  assert(sip);			/* XXX */
 
-  return nua_base_server_respond(sr, tags);
-}
+  if (answer_sent && 
+      session_include_description(nh->nh_soa, 1, rmsg, rsip) < 0) {
+    status = 500, phrase = sip_500_Internal_server_error;
+    answer_sent = NULL;
+  }
+
+  if (200 <= status && status < 300 && session_timer_is_supported(nh)) {
+    use_session_timer(ss, 1, use_timer, rmsg, rsip);
+    set_session_timer(ss);
+  }
+
+  if (status == original_status) {
+    if (nta_incoming_mreply(irq, rmsg) < 0)
+      status = 500, phrase = sip_500_Internal_server_error;
+  }
+
+  if (status != original_status) {
+    nua_stack_event(nua, nh, NULL, nua_i_error, status, phrase, TAG_END());
+    nta_incoming_treply(irq, status, phrase, TAG_END());
+    msg_destroy(rmsg), rmsg = NULL;
+  }
 
 /** @NUA_EVENT nua_i_update
  *
@@ -3276,52 +3163,39 @@
  * @END_NUA_EVENT
  */
 
-int nua_update_server_report(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_usage_t *du = sr->sr_usage;
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
-  int retval = nua_base_server_report(sr, tags); /* destroys sr */
-
-  if (retval >= 2 || ss == NULL) {
-    signal_call_state_change(nh, NULL,
-			     sr->sr_status, sr->sr_phrase, 
-			     nua_callstate_terminated);
-    return retval;
-  }
+  nua_stack_event(nh->nh_nua, nh, msg, nua_i_update, status, phrase, TAG_END());
 
-  if (sr->sr_offer_recv || sr->sr_answer_sent)
+  if (offer_recv || answer_sent)
     /* signal offer received, answer sent */
-    signal_call_state_change(nh, ss,
-			     sr->sr_status, sr->sr_phrase, 
-			     ss->ss_state);
+    signal_call_state_change(nh, ss, 200, "OK", ss->ss_state,
+			     offer_recv, answer_sent);
 
-  if (200 <= sr->sr_status && sr->sr_status < 300
+  if (NH_PGET(nh, auto_alert)
       && ss->ss_state < nua_callstate_ready
-      && ss->ss_precondition 
       && !ss->ss_alerting
-      && NH_PGET(nh, auto_alert))  {
+      && ss->ss_precondition) {
     nua_server_request_t *sr;
     
-    for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next)
+    for (sr = ds->ds_sr; sr; sr = sr->sr_next)
       if (sr->sr_method == sip_method_invite && 
-	  nua_server_request_is_pending(sr))
+	  sr->sr_usage == du && sr->sr_respond)
 	break;
 
-    if (sr) {
-      SR_STATUS1(sr, SIP_180_RINGING);
-      nua_server_respond(sr, NULL);
-      nua_server_report(sr);
-      return retval;
-    }
+    if (sr)
+      nua_server_respond(sr, SIP_180_RINGING, TAG_END());
   }
 
-  return retval;
+  return status;
 }
 
+
 /* ======================================================================== */
 /* BYE */
 
+static int process_response_to_bye(nua_handle_t *nh,
+				   nta_outgoing_t *orq,
+				   sip_t const *sip);
+
 /**@fn void nua_bye(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
  *
  * Hangdown a call.
@@ -3343,95 +3217,87 @@
  *    #nua_i_media_error
  */
 
-static int nua_bye_client_init(nua_client_request_t *cr, 
-			       msg_t *msg, sip_t *sip,
-			       tagi_t const *tags);
-static int nua_bye_client_request(nua_client_request_t *cr,
-				  msg_t *msg, sip_t *sip,
-				  tagi_t const *tags);
-static int nua_bye_client_report(nua_client_request_t *cr,
-				 int status, char const *phrase,
-				 sip_t const *sip,
-				 nta_outgoing_t *orq,
-				 tagi_t const *tags);
-
-nua_client_methods_t const nua_bye_client_methods = {
-  SIP_METHOD_BYE,
-  0,
-  { 
-    /* create_dialog */ 0,
-    /* in_dialog */ 1,
-    /* target refresh */ 0
-  },
-  NULL,
-  nua_bye_client_init,
-  nua_bye_client_request,
-  /*nua_bye_client_check_restart*/ NULL,
-  /*nua_bye_client_response*/ NULL,
-  /*nua_bye_client_preliminary*/ NULL,
-  nua_bye_client_report
-};
-
 int
 nua_stack_bye(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
 {
-  nua_session_usage_t *ss = nua_session_usage_for_dialog(nh->nh_ds);
+  nua_session_usage_t *ss;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg;
+  nta_outgoing_t *orq;
 
-  if (ss && 
-      nua_callstate_calling <= ss->ss_state &&
-      ss->ss_state <= nua_callstate_proceeding)
-    return nua_client_create(nh, e, &nua_cancel_client_methods, tags);
-  else
-    return nua_client_create(nh, e, &nua_bye_client_methods, tags);
-}
+  ss = nua_session_usage_get(nh->nh_ds);
+  
+  if (!ss || ss->ss_state >= nua_callstate_terminating)
+    return UA_EVENT2(e, 900, "Invalid handle for BYE");
 
-static int nua_bye_client_init(nua_client_request_t *cr, 
-			       msg_t *msg, sip_t *sip,
-			       tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
-  nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  if (!nua_dialog_is_established(nh->nh_ds)) {
+    nua_client_request_t *cri = ss->ss_crequest;
+
+    if (cri->cr_orq == NULL)
+      return UA_EVENT2(e, 900, "No session to BYE");
+
+    /* No (early) dialog. BYE is invalid action, do CANCEL instead */
+    orq = nta_outgoing_tcancel(cri->cr_orq,
+			       process_response_to_cancel, nh,
+			       TAG_NEXT(tags));
+    if (!cr->cr_orq)
+      cr->cr_orq = orq, cr->cr_event = e;
+
+    return 0;
+  }
 
-  if (!ss || (ss->ss_state >= nua_callstate_terminating && !cr->cr_auto))
-    return nua_client_return(cr, 900, "Invalid handle for BYE", msg);
+  if (cr->cr_orq) {
+    if (cr->cr_usage == nua_dialog_usage_public(ss)) {
+      nua_creq_deinit(cr, cr->cr_orq);
+    }
+    else {
+      cr = ss->ss_crequest;
+      if (cr->cr_orq)
+	nua_creq_deinit(cr, cr->cr_orq);
+    }
+  }
 
-  if (!cr->cr_auto)
-    /* Implicit state transition by nua_bye() */
-    ss->ss_state = nua_callstate_terminating;
+  assert(!cr->cr_orq);
 
+  msg = nua_creq_msg(nua, nh, cr, 0, SIP_METHOD_BYE, TAG_NEXT(tags));
+
+  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				    process_response_to_bye, nh, NULL,
+				    msg,
+				    SIPTAG_END(), TAG_NEXT(tags));
+
+  ss->ss_state = nua_callstate_terminating;
   if (nh->nh_soa)
     soa_terminate(nh->nh_soa, 0);
-  cr->cr_usage = du;
+
+  if (cr->cr_orq) {
+    cr->cr_event = e;
+  }
+  else {
+    msg_destroy(msg);
+    UA_EVENT2(e, 400, "Internal error");
+    signal_call_state_change(nh, ss, 400, "Failure sending BYE",
+			     nua_callstate_terminated, 0, 0);
+    nua_session_usage_destroy(nh, ss);
+  }
 
   return 0;
 }
 
-static int nua_bye_client_request(nua_client_request_t *cr,
-				  msg_t *msg, sip_t *sip,
-				  tagi_t const *tags)
-{
-  nua_dialog_usage_t *du = cr->cr_usage;
-  nua_session_usage_t *ss;
-  char const *reason = NULL;
-
-  if (du == NULL)
-    return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
-
-  ss = nua_dialog_usage_private(du);
-  reason = ss->ss_reason;
 
-  return nua_base_client_trequest(cr, msg, sip,
-				  SIPTAG_REASON_STR(reason),
-				  TAG_NEXT(tags));
+void restart_bye(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_bye, tags);
 }
 
 /** @NUA_EVENT nua_r_bye
  *
  * Answer to outgoing BYE.
  *
- * The BYE may be sent explicitly by nua_bye() or implicitly by NUA state
- * machine.
+ * The BYE may be sent explicitly by nua_bye() or
+ * implicitly by NUA state machine.
  *
  * @param status response status code
  *               (if the request is retried, @a status is 100, the @a
@@ -3450,44 +3316,45 @@
  * @END_NUA_EVENT
  */
 
-static int nua_bye_client_report(nua_client_request_t *cr,
-				 int status, char const *phrase,
-				 sip_t const *sip,
-				 nta_outgoing_t *orq,
-				 tagi_t const *tags)
+static int process_response_to_bye(nua_handle_t *nh,
+				   nta_outgoing_t *orq,
+				   sip_t const *sip)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
+  nua_client_request_t *cr = NULL;
+  nua_session_usage_t *ss;
+  int status = sip ? sip->sip_status->st_status : 400;
+  char const *phrase = sip ? sip->sip_status->st_phrase : "";
 
-  nua_stack_event(nh->nh_nua, nh, 
-		  nta_outgoing_getresponse(orq),
-		  cr->cr_event,
-		  status, phrase,
-		  tags);
+  cr = nua_client_request_by_orq(nh->nh_ds->ds_cr, orq); assert(cr);
 
-  if (du == NULL) {
-    /* No more session */
+  if (cr) {
+    if (nua_creq_check_restart(nh, cr, orq, sip, restart_bye))
+      return 0;
+    nua_stack_process_response(nh, cr, orq, sip, TAG_END());
   }
-  else if (status < 200) {
-    /* Preliminary */
+  else {			/* No cr for BYE */
+    msg_t *msg = nta_outgoing_getresponse(orq);
+    nua_stack_event(nh->nh_nua, nh, msg, nua_r_bye, status, phrase, TAG_END());
+    nta_outgoing_destroy(orq);
   }
-  else {
-    nua_session_usage_t *ss = nua_dialog_usage_private(du);
 
-    signal_call_state_change(nh, ss, status, "to BYE", 
-			     nua_callstate_terminated);
+  ss = nua_session_usage_get(nh->nh_ds);
 
-    if (ss && !ss->ss_reporting) {
-      if (nua_client_is_queued(du->du_cr) && du->du_cr->cr_status < 200)
-	/* No final response to INVITE received yet */;
-      else
-	nua_session_usage_destroy(nh, ss);
+  if (status >= 200 && ss) {
+    if (ss->ss_crequest->cr_orq) {
+      /* Do not destroy usage while INVITE is alive */
+    }
+    else {
+      signal_call_state_change(nh, ss, status, "to BYE",
+			       nua_callstate_terminated, 0, 0);
+      nua_session_usage_destroy(nh, ss);
     }
   }
 
-  return 1;
+  return 0;
 }
 
+
 /** @NUA_EVENT nua_i_bye
  *
  * Incoming BYE request, call hangup.
@@ -3504,82 +3371,48 @@
  * @END_NUA_EVENT
  */
 
-int nua_bye_server_init(nua_server_request_t *sr);
-int nua_bye_server_report(nua_server_request_t *sr, tagi_t const *tags);
-
-nua_server_methods_t const nua_bye_server_methods = 
-  {
-    SIP_METHOD_BYE,
-    nua_i_bye,			/* Event */
-    { 
-      0,			/* Do not create dialog */
-      1,			/* In-dialog request */
-      0,			/* Not a target refresh request  */
-      0,			/* Do not add Contact */
-    },
-    nua_bye_server_init,
-    nua_base_server_preprocess,
-    nua_base_server_params,
-    nua_base_server_respond,
-    nua_bye_server_report,
-  };
-
-
-int nua_bye_server_init(nua_server_request_t *sr)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_usage_t *du = nua_dialog_usage_for_session(nh->nh_ds);
-
-  sr->sr_terminating = 1;
-
-  if (du)
-    sr->sr_usage = du;
-  else
-    return SR_STATUS(sr, 481, "No Such Call");
-
-  return 0;
-}
-
-int nua_bye_server_report(nua_server_request_t *sr, tagi_t const *tags)
+int nua_stack_process_bye(nua_t *nua,
+			  nua_handle_t *nh,
+			  nta_incoming_t *irq,
+			  sip_t const *sip)
 {
-  nua_handle_t *nh = sr->sr_owner;
-  nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
-  int early = 0, retval;
-
-  if (sr->sr_status < 200)
-    return nua_base_server_report(sr, tags);
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_session_usage_t *ss;
+  nua_server_request_t *sr, *sr_next;
+  int early = 0;
 
-  if (ss) {
-    nua_server_request_t *sr0 = NULL, *sr_next;
-    char const *phrase;
+  ss = nua_session_usage_get(ds);
+  if (!ss)
+    return 481;
 
-    early = ss->ss_state < nua_callstate_ready;
-    phrase = early ? "Early Session Terminated" : "Session Terminated";
-    
-    for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr_next) {
-      sr_next = sr0->sr_next;
+  assert(nh && ss);
 
-      if (sr == sr0 || sr0->sr_usage != sr->sr_usage)
-	continue;
+  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
+		  nua_i_bye, SIP_200_OK, TAG_END());
+  nta_incoming_treply(irq, SIP_200_OK, TAG_END());
+  nta_incoming_destroy(irq), irq = NULL;
 
-      if (nua_server_request_is_pending(sr0)) {
-	SR_STATUS(sr0, 487, phrase);
-	nua_server_respond(sr0, NULL);
-      }
-      nua_server_request_destroy(sr0);
+  for (sr = ds->ds_sr; sr; sr = sr_next) {
+    sr_next = sr->sr_next;
+    if (sr->sr_respond && sr->sr_usage == nua_dialog_usage_public(ss)) {
+      char const *phrase;
+      early = ss->ss_state < nua_callstate_ready;
+      phrase = early ? "Early Session Terminated" : "Session Terminated";
+      sr->sr_usage = NULL;
+      if (sr->sr_respond)
+	nua_server_respond(sr, 487, phrase, TAG_END());
+      else
+	nua_server_request_destroy(sr);
     }
   }
 
-  retval = nua_base_server_report(sr, tags);
+  signal_call_state_change(nh, ss, 200,
+			   early ? "Received early BYE" : "Received BYE",
+			   nua_callstate_terminated, 0, 0);
 
-  assert(2 <= retval && retval < 4);
+  nua_session_usage_destroy(nh, ss);
 
-  if (ss)
-    signal_call_state_change(nh, NULL, 200,
-			     early ? "Received early BYE" : "Received BYE",
-			     nua_callstate_terminated);
-
-  return retval;
+  return 0;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -3597,46 +3430,35 @@
 static void signal_call_state_change(nua_handle_t *nh,
 				     nua_session_usage_t *ss,
 				     int status, char const *phrase,
-				     enum nua_callstate next_state)
+				     enum nua_callstate next_state,
+				     char const *oa_recv,
+				     char const *oa_sent)
 {
-  enum nua_callstate ss_state = nua_callstate_init;
+  enum nua_callstate ss_state;
 
   sdp_session_t const *remote_sdp = NULL;
   char const *remote_sdp_str = NULL;
   sdp_session_t const *local_sdp = NULL;
   char const *local_sdp_str = NULL;
-  char const *oa_recv = NULL;
-  char const *oa_sent = NULL;
 
   int offer_recv = 0, answer_recv = 0, offer_sent = 0, answer_sent = 0;
 
-  if (ss && ss->ss_reporting)
-    return;
-
-  if (ss) {
-    ss_state = ss->ss_state;
-    oa_recv = ss->ss_oa_recv, ss->ss_oa_recv = NULL;
-    oa_sent = ss->ss_oa_sent, ss->ss_oa_sent = NULL;
-  }
+  ss_state = ss ? ss->ss_state : nua_callstate_init;
 
   if (ss_state < nua_callstate_ready || next_state > nua_callstate_ready)
     SU_DEBUG_5(("nua(%p): call state changed: %s -> %s%s%s%s%s\n",
-		(void *)nh, nua_callstate_name(ss_state),
+		nh, nua_callstate_name(ss_state),
 		nua_callstate_name(next_state),
 		oa_recv ? ", received " : "", oa_recv ? oa_recv : "",
 		oa_sent && oa_recv ? ", and sent " :
 		oa_sent ? ", sent " : "", oa_sent ? oa_sent : ""));
   else
     SU_DEBUG_5(("nua(%p): ready call updated: %s%s%s%s%s\n",
-		(void *)nh, nua_callstate_name(next_state),
+		nh, nua_callstate_name(next_state),
 		oa_recv ? " received " : "", oa_recv ? oa_recv : "",
 		oa_sent && oa_recv ? ", sent " :
 		oa_sent ? " sent " : "", oa_sent ? oa_sent : ""));
 
-  if (next_state == nua_callstate_terminating &&
-      ss_state >= nua_callstate_terminating)
-    return;
-
   if (oa_recv) {
     soa_get_remote_sdp(nh->nh_soa, &remote_sdp, &remote_sdp_str, 0);
     offer_recv = strcasecmp(oa_recv, "offer") == 0;
@@ -3661,20 +3483,12 @@
 
   if (ss) {
     /* Update state variables */
-    if (next_state == nua_callstate_init) {
-      if (ss_state < nua_callstate_ready)
-	ss->ss_state = next_state;
-      else
-	/* Do not change state - we are ready, terminating, or terminated */
-	next_state = ss_state;
-    }
-    else if (next_state > ss_state)
+    if (next_state > ss_state)
       ss->ss_state = next_state;
+    else if (next_state == nua_callstate_init && ss_state < nua_callstate_ready)
+      ss->ss_state = nua_callstate_init, next_state = nua_callstate_terminated;
   }
 
-  if (next_state == nua_callstate_init) 
-    next_state = nua_callstate_terminated;
-
   if (ss && ss->ss_state == nua_callstate_ready)
     nh->nh_active_call = 1;
   else if (next_state == nua_callstate_terminated)
@@ -3733,20 +3547,20 @@
  * @END_NUA_EVENT
  */
 
-  nua_stack_tevent(nh->nh_nua, nh, NULL, nua_i_state,
-		   status, phrase,
-		   NUTAG_CALLSTATE(next_state),
-		   NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
-		   /* NUTAG_SOA_SESSION(nh->nh_soa), */
-		   TAG_IF(offer_recv, NUTAG_OFFER_RECV(offer_recv)),
-		   TAG_IF(answer_recv, NUTAG_ANSWER_RECV(answer_recv)),
-		   TAG_IF(offer_sent, NUTAG_OFFER_SENT(offer_sent)),
-		   TAG_IF(answer_sent, NUTAG_ANSWER_SENT(answer_sent)),
-		   TAG_IF(oa_recv, SOATAG_REMOTE_SDP(remote_sdp)),
-		   TAG_IF(oa_recv, SOATAG_REMOTE_SDP_STR(remote_sdp_str)),
-		   TAG_IF(oa_sent, SOATAG_LOCAL_SDP(local_sdp)),
-		   TAG_IF(oa_sent, SOATAG_LOCAL_SDP_STR(local_sdp_str)),
-		   TAG_END());
+  nua_stack_event(nh->nh_nua, nh, NULL, nua_i_state,
+		  status, phrase,
+		  NUTAG_CALLSTATE(next_state),
+		  NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
+		  /* NUTAG_SOA_SESSION(nh->nh_soa), */
+		  TAG_IF(offer_recv, NUTAG_OFFER_RECV(offer_recv)),
+		  TAG_IF(answer_recv, NUTAG_ANSWER_RECV(answer_recv)),
+		  TAG_IF(offer_sent, NUTAG_OFFER_SENT(offer_sent)),
+		  TAG_IF(answer_sent, NUTAG_ANSWER_SENT(answer_sent)),
+		  TAG_IF(oa_recv, SOATAG_REMOTE_SDP(remote_sdp)),
+		  TAG_IF(oa_recv, SOATAG_REMOTE_SDP_STR(remote_sdp_str)),
+		  TAG_IF(oa_sent, SOATAG_LOCAL_SDP(local_sdp)),
+		  TAG_IF(oa_sent, SOATAG_LOCAL_SDP_STR(local_sdp_str)),
+		  TAG_END());
 
 /** @NUA_EVENT nua_i_active
  *
@@ -3770,10 +3584,10 @@
  */
 
   if (next_state == nua_callstate_ready && ss_state <= nua_callstate_ready) {
-    nua_stack_tevent(nh->nh_nua, nh, NULL, nua_i_active, status, "Call active",
-		     NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
-		     /* NUTAG_SOA_SESSION(nh->nh_soa), */
-		     TAG_END());
+    nua_stack_event(nh->nh_nua, nh, NULL, nua_i_active, status, "Call active",
+	     NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
+	     /* NUTAG_SOA_SESSION(nh->nh_soa), */
+	     TAG_END());
   }
 
 /** @NUA_EVENT nua_i_terminated
@@ -3801,18 +3615,17 @@
  */
 
   else if (next_state == nua_callstate_terminated) {
-    nua_stack_event(nh->nh_nua, nh, NULL,
-		    nua_i_terminated, status, phrase,
-		    NULL);
+    nua_stack_event(nh->nh_nua, nh, NULL, nua_i_terminated, status, phrase,
+	     TAG_END());
   }
 }
 
 /* ======================================================================== */
 
 static
-int nua_server_retry_after(nua_server_request_t *sr,
-			   int status, char const *phrase,
-			   int min, int max)
+int respond_with_retry_after(nua_handle_t *nh, nta_incoming_t *irq,
+			     int status, char const *phrase,
+			     int min, int max)
 {
   sip_retry_after_t af[1];
 
@@ -3820,9 +3633,12 @@
   af->af_delta = (unsigned)su_randint(min, max);
   af->af_comment = phrase;
 
-  sip_add_dup(sr->sr_response.msg, sr->sr_response.sip, (sip_header_t *)af);
+  nta_incoming_treply(irq, status, phrase,
+		      SIPTAG_RETRY_AFTER(af),
+		      SIPTAG_USER_AGENT_STR(NH_PGET(nh, user_agent)),
+		      TAG_END());
 
-  return sr_status(sr, status, phrase);
+  return 500;
 }
 
 /* ======================================================================== */
@@ -3940,6 +3756,146 @@
   return retval;
 }
 
+/**
+ * Stores and processes SDP from incoming response, then calls
+ * nua_stack_process_response().
+ *
+ * @retval 1 if there was SDP to process.
+ */
+static
+int session_process_response(nua_handle_t *nh,
+			     nua_client_request_t *cr,
+			     nta_outgoing_t *orq,
+			     sip_t const *sip,
+			     char const **return_received)
+{
+  char const *method = nta_outgoing_method_name(orq);
+  msg_t *msg = nta_outgoing_getresponse(orq);
+  int retval = 0;
+  char const *sdp = NULL;
+  size_t len;
+
+  if (nh->nh_soa == NULL)
+    /* Xyzzy */;
+  else if (!session_get_description(sip, &sdp, &len))
+    /* No SDP */;
+  else if (cr->cr_answer_recv) {
+    /* Ignore spurious answers after completing O/A */
+    SU_DEBUG_3(("nua(%p): %s: ignoring duplicate SDP in %u %s\n",
+		nh, method,
+		sip->sip_status->st_status, sip->sip_status->st_phrase));
+    sdp = NULL;
+  }
+  else if (!cr->cr_offer_sent &&
+	   nta_outgoing_method(orq) != sip_method_invite) {
+    /* If non-invite request did not have offer, ignore SDP in response */
+    SU_DEBUG_3(("nua(%p): %s: ignoring extra SDP in %u %s\n",
+		nh, method,
+		sip->sip_status->st_status, sip->sip_status->st_phrase));
+    sdp = NULL;
+  }
+  else {
+    if (cr->cr_offer_sent) {
+      cr->cr_answer_recv = sip->sip_status->st_status;
+      *return_received = "answer";
+    }
+    else {
+      cr->cr_offer_recv = 1, cr->cr_answer_sent = 0;
+      *return_received = "offer";
+    }
+
+    if (soa_set_remote_sdp(nh->nh_soa, NULL, sdp, len) < 0) {
+      SU_DEBUG_5(("nua(%p): %s: error parsing SDP in %u %s\n",
+		  nh, method,
+		  sip->sip_status->st_status,
+		  sip->sip_status->st_phrase));
+      retval = -1;
+      sdp = NULL;
+    }
+    else if (cr->cr_offer_recv) {
+      /* note: case 1: incoming offer */
+      SU_DEBUG_5(("nua(%p): %s: get SDP %s in %u %s\n",
+		  nh, method, "offer",
+		  sip->sip_status->st_status,
+		  sip->sip_status->st_phrase));
+      retval = 1;
+    }
+    else if (soa_process_answer(nh->nh_soa, NULL) < 0) {
+      SU_DEBUG_5(("nua(%p): %s: error processing SDP answer in %u %s\n",
+		  nh, method,
+		  sip->sip_status->st_status,
+		  sip->sip_status->st_phrase));
+      sdp = NULL;
+    }
+    else {
+      /* note: case 2: answer to our offer */
+      if (soa_activate(nh->nh_soa, NULL) < 0) {
+	SU_DEBUG_3(("nua(%p): %s: error activating media after %u %s\n",
+		    nh, method,
+		    sip->sip_status->st_status,
+		    sip->sip_status->st_phrase));
+	/* XXX */
+      }
+      else {
+	SU_DEBUG_5(("nua(%p): %s: processed SDP answer in %u %s\n",
+		    nh, method,
+		    sip->sip_status->st_status,
+		    sip->sip_status->st_phrase));
+      }
+
+      assert(!cr->cr_offer_recv);
+    }
+  }
+
+  msg_destroy(msg);		/* unref */
+
+  nua_stack_process_response(nh, cr, orq, sip,
+			     NH_REMOTE_MEDIA_TAGS(sdp != NULL, nh->nh_soa),
+			     TAG_END());
+
+  return retval;
+}
+
+#if 0
+/** Parse and store SDP from incoming request */
+static
+int session_process_request(nua_handle_t *nh,
+			    nta_incoming_t *irq,
+			    sip_t const *sip)
+{
+  char const *sdp = NULL;
+  isize_t len;
+
+  if (nh->nh_soa) {
+    msg_t *msg = nta_outgoing_getresponse(irq);
+
+    if (session_get_description(msg, sip, &sdp, &len)) {
+      if (soa_is_complete(nh->nh_soa)) {
+	/* Ignore spurious answers after completing O/A */
+	SU_DEBUG_5(("nua: ignoring duplicate SDP in %u %s\n",
+		    sip->sip_status->st_status, sip->sip_status->st_phrase));
+	sdp = NULL;
+      }
+      else if (soa_parse_sdp(nh->nh_soa, sdp, len) < 0) {
+	SU_DEBUG_5(("nua: error parsing SDP in %u %s\n",
+		    sip->sip_status->st_status,
+		    sip->sip_status->st_phrase));
+	sdp = NULL;
+      }
+    }
+
+    msg_destroy(msg);
+  }
+
+  return
+    nua_stack_process_response(nh, cr, orq, sip,
+			       NH_REMOTE_MEDIA_TAGS(sdp != NULL, nh->nh_soa),
+			       TAG_END());
+}
+#endif
+
+static int respond_to_options(nua_server_request_t *sr, tagi_t const *tags);
+
 /** @NUA_EVENT nua_i_options
  *
  * Incoming OPTIONS request. The user-agent should respond to an OPTIONS
@@ -3968,38 +3924,50 @@
  * @END_NUA_EVENT
  */
 
-int nua_options_server_respond(nua_server_request_t *sr, tagi_t const *tags);
+int nua_stack_process_options(nua_t *nua,
+			      nua_handle_t *nh,
+			      nta_incoming_t *irq,
+			      sip_t const *sip)
+{
+  nua_server_request_t *sr, sr0[1];
+  int done;
 
-nua_server_methods_t const nua_options_server_methods = 
-  {
-    SIP_METHOD_OPTIONS,
-    nua_i_options,		/* Event */
-    { 
-      0,			/* Do not create dialog */
-      0,			/* Initial request */
-      0,			/* Not a target refresh request  */
-      1,			/* Add Contact */
-    },
-    nua_base_server_init,
-    nua_base_server_preprocess,
-    nua_base_server_params,
-    nua_options_server_respond,
-    nua_base_server_report,
-  };
+  /* Hook to outbound */
+  done = nua_registration_process_request(nua->nua_registrations, irq, sip);
+  if (done)
+    return done;
+
+  sr = nua_server_request(nua, nh, irq, sip, SR_INIT(sr0), sizeof *sr,
+			  respond_to_options, 0);
+
+  SR_STATUS1(sr, SIP_200_OK);
+
+  return nua_stack_server_event(nua, sr, nua_i_options, TAG_END());
+}
 
 /** @internal Respond to an OPTIONS request.
  *
  */
-int nua_options_server_respond(nua_server_request_t *sr, tagi_t const *tags)
+static int respond_to_options(nua_server_request_t *sr, tagi_t const *tags)
 {
   nua_handle_t *nh = sr->sr_owner;
   nua_t *nua = nh->nh_nua;
+  msg_t *msg;
+  int final;
+
+  msg = nua_server_response(sr,
+			    sr->sr_status, sr->sr_phrase,
+			    SIPTAG_ALLOW(NH_PGET(nh, allow)),
+			    SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
+			    TAG_IF(NH_PGET(nh, path_enable),
+				   SIPTAG_SUPPORTED_STR("path")),
+			    SIPTAG_ACCEPT_STR(SDP_MIME_TYPE),
+			    TAG_NEXT(tags));
 
-  if (200 <= sr->sr_status && sr->sr_status < 300) {
-    msg_t *msg = sr->sr_response.msg;
-    sip_t *sip = sr->sr_response.sip;
+  final = sr->sr_status >= 200;
 
-    sip_add_tl(msg, sip, SIPTAG_ACCEPT_STR(SDP_MIME_TYPE), TAG_END());
+  if (msg) {
+    sip_t *sip = sip_object(msg);
 
     if (!sip->sip_payload) {	/* XXX - do MIME multipart? */
       soa_session_t *soa = nh->nh_soa;
@@ -4009,8 +3977,10 @@
 
       session_include_description(soa, 0, msg, sip);
     }
+
+    if (nta_incoming_mreply(sr->sr_irq, msg) < 0)
+      final = 1;
   }
 
-  return nua_base_server_respond(sr, tags);
+  return final;
 }
-

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c	Sat Feb 17 01:25:21 2007
@@ -37,7 +37,7 @@
 #include "config.h"
 
 #include <sofia-sip/su_tag_class.h>
-#include <sofia-sip/su_tag_inline.h>
+#include <sofia-sip/su_tag_class.h>
 #include <sofia-sip/su_tagarg.h>
 #include <sofia-sip/su_strlst.h>
 #include <sofia-sip/su_uniqueid.h>
@@ -51,7 +51,8 @@
 
 #define NTA_AGENT_MAGIC_T    struct nua_s
 #define NTA_LEG_MAGIC_T      struct nua_handle_s
-#define NTA_OUTGOING_MAGIC_T struct nua_client_request
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+#define NTA_INCOMING_MAGIC_T struct nua_handle_s
 
 #include <sofia-sip/sip.h>
 #include <sofia-sip/sip_header.h>
@@ -94,9 +95,6 @@
 
 static void nua_stack_timer(nua_t *nua, su_timer_t *t, su_timer_arg_t *a);
 
-inline int nua_client_request_queue(nua_client_request_t *cr);
-inline nua_client_request_t *nua_client_request_remove(nua_client_request_t *cr);
-
 /* ---------------------------------------------------------------------- */
 /* Constant data */
 
@@ -149,7 +147,7 @@
     return -1;
 
   dnh->nh_prefs = (void *)(dnh + 1);
-  dnh->nh_valid = nua_valid_handle_cookie;
+  dnh->nh_valid = nua_handle;
   dnh->nh_nua = nua;
   nua_handle_ref(dnh); dnh->nh_ref_by_stack = 1; 
   nua_handle_ref(dnh); dnh->nh_ref_by_user = 1;
@@ -228,40 +226,29 @@
 int nh_notifier_shutdown(nua_handle_t *nh, nea_event_t *ev,
 			 tag_type_t t, tag_value_t v, ...);
 
-int nua_stack_tevent(nua_t *nua, nua_handle_t *nh, msg_t *msg,
-		     nua_event_t event, int status, char const *phrase,
-		     tag_type_t tag, tag_value_t value, ...)
-{
-  ta_list ta;
-  int retval;
-  ta_start(ta, tag, value);
-  retval = nua_stack_event(nua, nh, msg, event, status, phrase, ta_args(ta));
-  ta_end(ta);
-  return retval;
-}
-
 /** @internal Send an event to the application. */
 int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg,
 		    nua_event_t event, int status, char const *phrase,
-		    tagi_t const *tags)
+		    tag_type_t tag, tag_value_t value, ...)
 {
   su_msg_r sumsg = SU_MSG_R_INIT;
+
+  ta_list ta;
   size_t e_len, len, xtra, p_len;
 
   if (event == nua_r_ack || event == nua_i_none)
     return event;
 
-  if (nh == nua->nua_dhandle)
-    nh = NULL;
+  enter;
 
   if (nua_log->log_level >= 5) {
     char const *name = nua_event_name(event) + 4;
     char const *p = phrase ? phrase : "";
 
     if (status == 0)
-      SU_DEBUG_5(("nua(%p): event %s %s\n", (void *)nh, name, p));
+      SU_DEBUG_5(("nua(%p): %s %s\n", nh, name, p));
     else
-      SU_DEBUG_5(("nua(%p): event %s %u %s\n", (void *)nh, name, status, p));
+      SU_DEBUG_5(("nua(%p): %s %u %s\n", nh, name, status, p));
   }
 
   if (event == nua_r_destroy) {
@@ -282,42 +269,36 @@
     return event;
   }
 
-  if (tags) {
-    e_len = offsetof(event_t, e_tags);
-    len = tl_len(tags);
-    xtra = tl_xtra(tags, len);
-  }
-  else {
-    e_len = sizeof(event_t), len = 0, xtra = 0;
-  }
+  ta_start(ta, tag, value);
+
+  e_len = offsetof(event_t, e_tags);
+  len = tl_len(ta_args(ta));
+  xtra = tl_xtra(ta_args(ta), len);
   p_len = phrase ? strlen(phrase) + 1 : 1;
 
   if (su_msg_create(sumsg, nua->nua_client, su_task_null,
 		    nua_event, e_len + len + xtra + p_len) == 0) {
     event_t *e = su_msg_data(sumsg);
-    void *p;
 
-    if (tags) {
-      tagi_t *t = e->e_tags, *t_end = (tagi_t *)((char *)t + len);
-      void *b = t_end, *end = (char *)b + xtra;
+    tagi_t *t = e->e_tags, *t_end = (tagi_t *)((char *)t + len);
+    void *b = t_end, *end = (char *)b + xtra;
 
-      t = tl_dup(t, tags, &b); p = b;
-      assert(t == t_end); assert(b == end); (void)end;
-    }
-    else
-      p = e + 1;
+    t = tl_dup(t, ta_args(ta), &b);
+    assert(t == t_end); assert(b == end);
 
     e->e_event = event;
     e->e_nh = nh ? nua_handle_ref(nh) : nua->nua_dhandle;
     e->e_status = status;
-    e->e_phrase = strcpy(p, phrase ? phrase : "");
+    e->e_phrase = strcpy(end, phrase ? phrase : "");
     if (msg)
       e->e_msg = msg, su_home_threadsafe(msg_home(msg));
 
-    if (su_msg_send(sumsg) != 0 && nh)
+    if (su_msg_send(sumsg) != 0)
       nua_handle_unref(nh);
   }
 
+  ta_end(ta);
+
   return event;
 }
 
@@ -341,16 +322,9 @@
 {
   nua_handle_t *nh = e->e_nh;
   tagi_t *tags = e->e_tags;
-  nua_event_t event;
-  int error = 0;
 
   assert(tags);
 
-  if (nua_log->log_level >= 7) {
-    char const *name = nua_event_name(e->e_event) + 4;
-    SU_DEBUG_7(("nua(%p): recv %s\n", (void *)nh, name));
-  }
-
   if (nh) {
     if (!nh->nh_prev)
       nh_append(nua, nh);
@@ -364,105 +338,98 @@
   if (nua_log->log_level >= 5) {
     char const *name = nua_event_name(e->e_event);
     if (e->e_status == 0)
-      SU_DEBUG_5(("nua(%p): signal %s\n", (void *)nh, name + 4));
+      SU_DEBUG_5(("nua(%p): signal %s\n", nh, name + 4));
     else
       SU_DEBUG_5(("nua(%p): signal %s %u %s\n",
-		  (void *)nh, name + 4,
-		  e->e_status, e->e_phrase ? e->e_phrase : ""));
+		  nh, name + 4, e->e_status, e->e_phrase ? e->e_phrase : ""));
   }
 
   su_msg_save(nua->nua_signal, msg);
 
-  event = e->e_event;
-
   if (nua->nua_shutdown && !e->e_always) {
     /* Shutting down */
-    nua_stack_event(nua, nh, NULL, event,
+    nua_stack_event(nua, nh, NULL, e->e_event,
 		    901, "Stack is going down",
-		    NULL);
+		    TAG_END());
   }
-  else switch (event) {
+
+  else switch (e->e_event) {
   case nua_r_get_params:
-    nua_stack_get_params(nua, nh ? nh : nua->nua_dhandle, event, tags);
+    nua_stack_get_params(nua, nh ? nh : nua->nua_dhandle, e->e_event, tags);
     break;
   case nua_r_set_params:
-    nua_stack_set_params(nua, nh ? nh : nua->nua_dhandle, event, tags);
+    nua_stack_set_params(nua, nh ? nh : nua->nua_dhandle, e->e_event, tags);
     break;
   case nua_r_shutdown:
     nua_stack_shutdown(nua);
     break;
   case nua_r_register:
   case nua_r_unregister:
-    nua_stack_register(nua, nh, event, tags);
+    nua_stack_register(nua, nh, e->e_event, tags);
     break;
   case nua_r_invite:
-    error = nua_stack_invite(nua, nh, event, tags);
+    nua_stack_invite(nua, nh, e->e_event, tags);
     break;
   case nua_r_cancel:
-    error = nua_stack_cancel(nua, nh, event, tags);
+    nua_stack_cancel(nua, nh, e->e_event, tags);
     break;
   case nua_r_bye:
-    error = nua_stack_bye(nua, nh, event, tags);
+    nua_stack_bye(nua, nh, e->e_event, tags);
     break;
   case nua_r_options:
-    error = nua_stack_options(nua, nh, event, tags);
+    nua_stack_options(nua, nh, e->e_event, tags);
     break;
   case nua_r_refer:
-    error = nua_stack_refer(nua, nh, event, tags);
+    nua_stack_refer(nua, nh, e->e_event, tags);
     break;
   case nua_r_publish:
   case nua_r_unpublish:
-    error = nua_stack_publish(nua, nh, event, tags);
+    nua_stack_publish(nua, nh, e->e_event, tags);
     break;
   case nua_r_info:
-    error = nua_stack_info(nua, nh, event, tags);
+    nua_stack_info(nua, nh, e->e_event, tags);
     break;
   case nua_r_update:
-    error = nua_stack_update(nua, nh, event, tags);
+    nua_stack_update(nua, nh, e->e_event, tags);
     break;
   case nua_r_message:
-    error = nua_stack_message(nua, nh, event, tags);
+    nua_stack_message(nua, nh, e->e_event, tags);
     break;
   case nua_r_subscribe:
   case nua_r_unsubscribe:
-    error = nua_stack_subscribe(nua, nh, event, tags);
+    nua_stack_subscribe(nua, nh, e->e_event, tags);
     break;
   case nua_r_notify:
-    error = nua_stack_notify(nua, nh, event, tags);
+    nua_stack_notify(nua, nh, e->e_event, tags);
     break;
   case nua_r_notifier:
-    nua_stack_notifier(nua, nh, event, tags);
+    nua_stack_notifier(nua, nh, e->e_event, tags);
     break;
   case nua_r_terminate:
-    nua_stack_terminate(nua, nh, event, tags);
+    nua_stack_terminate(nua, nh, e->e_event, tags);
     break;
   case nua_r_method:
-    error = nua_stack_method(nua, nh, event, tags);
+    nua_stack_method(nua, nh, e->e_event, tags);
     break;
   case nua_r_authenticate:
-    nua_stack_authenticate(nua, nh, event, tags);
+    nua_stack_authenticate(nua, nh, e->e_event, tags);
     break;
   case nua_r_authorize:
-    nua_stack_authorize(nua, nh, event, tags);
+    nua_stack_authorize(nua, nh, e->e_event, tags);
     break;
   case nua_r_ack:
-    error = nua_stack_ack(nua, nh, event, tags);
+    nua_stack_ack(nua, nh, e->e_event, tags);
     break;
   case nua_r_respond:
     nua_stack_respond(nua, nh, e->e_status, e->e_phrase, tags);
     break;
-  case nua_r_destroy: 
+  case nua_r_destroy:
     nua_stack_destroy_handle(nua, nh, tags);
-    su_msg_destroy(nua->nua_signal);
-    return;
+    break;
   default:
     break;
   }
 
-  if (error < 0) {
-    nua_stack_event(nh->nh_nua, nh, NULL, event, NUA_INTERNAL_ERROR, NULL);
-  }
-
   if (su_msg_is_non_null(nua->nua_signal))
     su_msg_destroy(nua->nua_signal);
 
@@ -545,7 +512,6 @@
 }
 
 
-
 /* ====================================================================== */
 
 /**Shutdown a @nua stack.
@@ -615,11 +581,15 @@
     for (sr = ds->ds_sr; sr; sr = sr_next) {
       sr_next = sr->sr_next;
 
-      if (nua_server_request_is_pending(sr)) {
-	SR_STATUS1(sr, SIP_410_GONE); /* 410 terminates dialog */
-	nua_server_respond(sr, NULL);
-	nua_server_report(sr);
+      if (sr->sr_respond) {
+	SR_STATUS1(sr, SIP_410_GONE);
+	sr->sr_usage = NULL;
+	sr->sr_respond(sr, NULL);
+	sr->sr_respond = NULL;
+	busy++;
       }
+	
+      nua_server_request_destroy(sr);
     }
 
     busy += nh_call_pending(nh, 0);
@@ -655,7 +625,7 @@
     nta_agent_destroy(nua->nua_nta), nua->nua_nta = NULL;
   }
 
-  nua_stack_event(nua, NULL, NULL, nua_r_shutdown, status, phrase, NULL);
+  nua_stack_event(nua, NULL, NULL, nua_r_shutdown, status, phrase, TAG_END());
 }
 
 /* ---------------------------------------------------------------------- */
@@ -680,7 +650,7 @@
   return nh;
 }
 
-/** @internal Append a handle to the list of handles */
+/** @internal Append an handle to the list of handles */
 void nh_append(nua_t *nua, nua_handle_t *nh)
 {
   nh->nh_next = NULL;
@@ -703,15 +673,17 @@
 
 void nua_stack_destroy_handle(nua_t *nua, nua_handle_t *nh, tagi_t const *tags)
 {
+  nh_call_pending(nh, 0);	/* Call pending operations with 0 */
+
   if (nh->nh_notifier)
     nua_stack_terminate(nua, nh, 0, NULL);
 
-  nua_dialog_shutdown(nh, nh->nh_ds);
-
+#if 0
   if (nh->nh_ref_by_user) {
     nh->nh_ref_by_user = 0;
     nua_handle_unref(nh);
   }
+#endif
 
   nh_destroy(nua, nh);
 }
@@ -740,14 +712,12 @@
 {
   assert(nh); assert(nh != nua->nua_dhandle);
 
+  nh_enter;
+
   if (nh->nh_notifier)
     nea_server_destroy(nh->nh_notifier), nh->nh_notifier = NULL;
 
-  while (nh->nh_ds->ds_cr)
-    nua_client_request_destroy(nh->nh_ds->ds_cr);
-
-  while (nh->nh_ds->ds_sr)
-    nua_server_request_destroy(nh->nh_ds->ds_sr);
+  nua_creq_deinit(nh->nh_ds->ds_cr, NULL);
 
   nua_dialog_deinit(nh, nh->nh_ds);
 
@@ -763,7 +733,7 @@
 /* ======================================================================== */
 
 /**@internal
- * Save handle parameters and initial authentication info.
+ * Initialize handle Allow and authentication info, save parameters.
  *
  * @retval -1 upon an error
  * @retval 0 when successful
@@ -969,1709 +939,1175 @@
   return server + proxy;
 }
 
-static inline
-int can_redirect(sip_contact_t const *m, sip_method_t method)
+#include <sofia-sip/su_tag_inline.h>
+
+/** Check if tag list has contact */
+int nua_tagis_have_contact_tag(tagi_t const *t)
 {
-  if (m && m->m_url->url_host) {
-    enum url_type_e type = m->m_url->url_type;
-    return
-      type == url_sip ||
-      type == url_sips ||
-      (type == url_tel &&
-       (method == sip_method_invite || method == sip_method_message)) ||
-      (type == url_im && method == sip_method_message) ||
-      (type == url_pres && method == sip_method_subscribe);
-  }
+  for (; t && t->t_tag; t = t_next(t))
+    if (t->t_tag == siptag_contact ||
+	t->t_tag == siptag_contact_str)
+      return 1;
   return 0;
 }
 
-/* ======================================================================== */
-/* Authentication */
-
-/** @NUA_EVENT nua_r_authenticate
- *
- * Response to nua_authenticate(). Under normal operation, this event is
- * never sent but rather the unauthenticated operation is completed. 
- * However, if there is no operation to authentication or if there is an
- * authentication error the #nua_r_authenticate event is sent to the
- * application with the status code as follows:
- * - <i>202 No operation to restart</i>:\n
- *   The authenticator associated with the handle was updated, but there was
- *   no operation to retry with the new credentials.
- * - <i>900 Cannot add credentials</i>:\n
- *   There was internal problem updating authenticator.
- * - <i>904 No matching challenge</i>:\n
- *   There was no challenge matching with the credentials provided by
- *   nua_authenticate(), e.g., their realm did not match with the one 
- *   received with the challenge.
- * 
- * @param status status code from authentication 
- * @param phrase a short textual description of @a status code
- * @param nh     operation handle authenticated
- * @param hmagic application context associated with the handle
- * @param sip    NULL
- * @param tags   empty
- * 
- * @sa nua_terminate(), nua_handle_destroy()
+/**@internal
+ * Create a request message.
  *
- * @END_NUA_EVENT
- */
-
-void
-nua_stack_authenticate(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-		       tagi_t const *tags)
+ * @param nua
+ * @param nh
+ * @param cr
+ * @param restart
+ * @param method
+ * @param name
+ * @param tag, value, ... list of tag-value pairs
+ */
+msg_t *nua_creq_msg(nua_t *nua,
+		    nua_handle_t *nh,
+		    nua_client_request_t *cr,
+		    int restart,
+		    sip_method_t method, char const *name,
+		    tag_type_t tag, tag_value_t value, ...)
 {
-  int status = nh_authorize(nh, TAG_NEXT(tags));
-
-  if (status > 0) {
-    nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  struct nua_dialog_state *ds = nh->nh_ds;
+  msg_t *msg = NULL;
+  sip_t *sip;
+  ta_list ta;
+  url_string_t const *url = NULL;
+  long seq = -1;
+  int copy = 1;
 
-    if (cr && cr->cr_challenged) {
-      nua_client_resend_request(cr, cr->cr_terminating, tags);
-    }
-    else {
-      nua_stack_event(nua, nh, NULL, e, 
-		      202, "No operation to restart",
-		      NULL);
+  /* If restarting, use existing message */
+  if (restart) {
+    msg = cr->cr_msg; sip = sip_object(msg);
+
+    /* Trying to restart different method? */
+    if (sip && method && sip->sip_request->rq_method != method) {
+      SU_DEBUG_3(("nua(%p): trying to %s "
+		  "but there is already %s waiting to restart\n",
+		  nh, name, sip->sip_request->rq_method_name));
+      restart = 0, msg = NULL; sip = NULL;
+    }
+
+    /* Remove CSeq */
+    if (sip && sip->sip_cseq)
+      sip_header_remove(msg, sip, (sip_header_t *)sip->sip_cseq);
+    if (sip && sip->sip_request)
+      method = sip->sip_request->rq_method,
+	name = sip->sip_request->rq_method_name;
+  }
+
+  if (!restart) {
+    if (cr->cr_msg) {
+      /* If method is ACK or CANCEL, use existing CSeq */
+      if (method == sip_method_ack || method == sip_method_cancel) {
+	sip_t *nh_sip = sip_object(cr->cr_msg);
+	if (nh_sip && nh_sip->sip_cseq)
+	  seq = nh_sip->sip_cseq->cs_seq;
+	/* ACK/CANCEL cannot be restarted so we do not copy message */
+	copy = 0;
+      }
+      else
+	msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
     }
-  }
-  else if (status < 0) {
-    nua_stack_event(nua, nh, NULL, e, 900, "Cannot add credentials", NULL);
-  }
-  else {
-    nua_stack_event(nua, nh, NULL, e, 904, "No matching challenge", NULL);
-  }
-}
-
-
-/* ======================================================================== */
-/*
- * Process incoming requests
- */
+    msg = nta_msg_create(nua->nua_nta, 0);
 
-nua_server_methods_t const *nua_server_methods[] = {
-  /* These must be in same order as in sip_method_t */
-  &nua_extension_server_methods,
-  &nua_invite_server_methods,	/**< INVITE */
-  NULL,				/**< ACK */
-  NULL,				/**< CANCEL */
-  &nua_bye_server_methods,	/**< BYE */
-  &nua_options_server_methods,	/**< OPTIONS */
-  &nua_register_server_methods,	/**< REGISTER */
-  &nua_info_server_methods,	/**< INFO */
-  &nua_prack_server_methods,	/**< PRACK */
-  &nua_update_server_methods,	/**< UPDATE */
-  &nua_message_server_methods,	/**< MESSAGE */
-  &nua_subscribe_server_methods,/**< SUBSCRIBE */
-  &nua_notify_server_methods,	/**< NOTIFY */
-  &nua_refer_server_methods,	/**< REFER */
-  &nua_publish_server_methods,	/**< PUBLISH */
-  NULL
-};
+    /**@par Populating SIP Request Message with Tagged Arguments
+     *
+     * The tagged arguments can be used to pass values for any SIP headers
+     * to the stack. When the INVITE message (or any other SIP message) is
+     * created, the tagged values saved with nua_handle() are used first,
+     * next the tagged values given with the operation (nua_invite()) are
+     * added.
+     *
+     * When multiple tags for the same header are specified, the behaviour
+     * depends on the header type. If only a single header field can be
+     * included in a SIP message, the latest non-NULL value is used, e.g.,
+     * @Subject. However, if the SIP header can consist of multiple lines or
+     * header fields separated by comma, e.g., @Accept, all the tagged
+     * values are concatenated.
+     *
+     * However, if a tag value is #SIP_NONE (-1 casted as a void pointer),
+     * the values from previous tags are ignored.
+     */
+    tl_gets(nh->nh_tags, NUTAG_URL_REF(url), TAG_END());
+    sip_add_tl(msg, sip_object(msg), TAG_NEXT(nh->nh_tags));
+  }
 
+  ta_start(ta, tag, value);
 
-int nua_stack_process_request(nua_handle_t *nh,
-			      nta_leg_t *leg,
-			      nta_incoming_t *irq,
-			      sip_t const *sip)
-{
-  nua_t *nua = nh->nh_nua;
-  sip_method_t method = sip->sip_request->rq_method;
-  char const *name = sip->sip_request->rq_method_name;
-  nua_server_methods_t const *sm;
-  nua_server_request_t *sr, sr0[1];
-  int status, initial = 1;
+  sip = sip_object(msg);
+  if (!sip)
+    goto error;
+  if (sip_add_tl(msg, sip, ta_tags(ta)) < 0)
+    goto error;
 
-  char const *user_agent = NH_PGET(nh, user_agent);
-  sip_supported_t const *supported = NH_PGET(nh, supported);
-  sip_allow_t const *allow = NH_PGET(nh, allow);
+  if (method != sip_method_ack) {
+    /**
+     * Next, values previously set with nua_set_params() or nua_set_hparams()
+     * are used: @Allow, @Supported, @Organization, and @UserAgent headers are
+     * added to the request if they are not already set. 
+     */
+    if (!sip->sip_allow && !ds->ds_remote_tag)
+      sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow));
 
-  enter;
+    if (!sip->sip_supported && NH_PGET(nh, supported))
+      sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, supported));
+    
+    if (method == sip_method_register && NH_PGET(nh, path_enable) &&
+	!sip_has_feature(sip->sip_supported, "path") &&
+	!sip_has_feature(sip->sip_require, "path"))
+      sip_add_make(msg, sip, sip_supported_class, "path");
+
+    if (!sip->sip_organization && NH_PGET(nh, organization))
+      sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, organization));
+
+    if (!sip->sip_user_agent && NH_PGET(nh, user_agent))
+      sip_add_make(msg, sip, sip_user_agent_class, NH_PGET(nh, user_agent));
+  }
+	  
+  {
+    int add_contact = 0, use_dialog = 0, add_service_route, has_contact = 0;
+    tagi_t const *t;
 
-  nta_incoming_tag(irq, NULL);
+    for (t = ta_args(ta); t; t = t_next(t)) {
+      if (t->t_tag == siptag_contact ||
+	  t->t_tag == siptag_contact_str)
+	has_contact = 1;
+      else if (t->t_tag == nutag_url)
+	url = (url_string_t const *)t->t_value;
+      else if (t->t_tag == nutag_method && method == sip_method_unknown)
+	name = (char const *)t->t_value;
+      else if (t->t_tag == nutag_use_dialog)
+	use_dialog = t->t_value != 0;
+      else if (t->t_tag == _nutag_add_contact)
+	add_contact = t->t_value != 0;
+    }
+
+    if (!restart)
+      cr->cr_has_contact = has_contact;
+
+    if (has_contact) add_contact = 0;
+
+    if (method == sip_method_register && url == NULL)
+      url = (url_string_t const *)NH_PGET(nh, registrar);
+
+    if (seq != -1) {
+      sip_cseq_t *cseq;
+     
+      assert(method != sip_method_unknown || name || sip->sip_request);
+      
+      if (method || name)
+	cseq = sip_cseq_create(msg_home(msg), seq, method, name);
+      else 
+	cseq = sip_cseq_create(msg_home(msg), seq, 
+			       sip->sip_request->rq_method, 
+			       sip->sip_request->rq_method_name);
+
+      sip_header_insert(msg, sip, (sip_header_t *)cseq);
+    }
+
+    /**
+     * Now, the target URI for the request needs to be determined.
+     *
+     * For initial requests, values from tags are used. If NUTAG_URL() is
+     * given, it is used as target URI. Otherwise, if SIPTAG_TO() is given,
+     * it is used as target URI. If neither is given, the complete request
+     * line already specified using SIPTAG_REQUEST() or SIPTAG_REQUEST_STR()
+     * is used. At this point, the target URI is stored in the request line,
+     * together with method name and protocol version ("SIP/2.0"). The
+     * initial dialog information is also created: @CallID, @CSeq headers
+     * are generated, if they do not exist, and a tag is added to the @From
+     * header.
+     */
+    if (!ds->ds_leg) {
+      nta_leg_t *leg = nua->nua_dhandle->nh_ds->ds_leg;
+
+      if ((ds->ds_remote_tag && ds->ds_remote_tag[0] && 
+	   sip_to_tag(nh->nh_home, sip->sip_to, ds->ds_remote_tag) < 0)
+	  || 
+	  (sip->sip_from == NULL &&
+	   sip_add_dup(msg, sip, (sip_header_t *)nua->nua_from) < 0))
+	goto error;
 
-  if (method == sip_method_cancel)
-    return 481;
+      if (use_dialog) {
+	ds->ds_leg = nta_leg_tcreate(nua->nua_nta,
+				     nua_stack_process_request, nh,
+				     SIPTAG_CALL_ID(sip->sip_call_id),
+				     SIPTAG_FROM(sip->sip_from),
+				     SIPTAG_TO(sip->sip_to),
+				     SIPTAG_CSEQ(sip->sip_cseq),
+				     TAG_END());
+	if (!ds->ds_leg)
+	  goto error;
+
+	leg = ds->ds_leg;
+
+	if (!sip->sip_from->a_tag &&
+	    sip_from_tag(msg_home(msg), sip->sip_from,
+			 nta_leg_tag(ds->ds_leg, NULL)) < 0)
+	  goto error;
+      }
 
-  /* Hook to outbound */
-  if (method == sip_method_options) {
-    status = nua_registration_process_request(nua->nua_registrations,
-					      irq, sip);
-    if (status)
-      return status;
-  }
+      if (nta_msg_request_complete(msg, leg, method, name, url) < 0)
+	goto error;
 
-  if (nta_check_method(irq, sip, allow,
-		       SIPTAG_SUPPORTED(supported),
-		       SIPTAG_USER_AGENT_STR(user_agent),
-		       TAG_END()))
-    return 405;
+      add_service_route = !restart;
+    }
+    else {
+      /**
+       * For in-dialog requests, the request URI is taken from the @Contact
+       * header received from the remote party during dialog establishment, 
+       * and the NUTAG_URL() is ignored.
+       */
+      if (ds->ds_route)
+	url = NULL;
+
+      /**Also, the @CallID and @CSeq headers and @From and @To tags are
+       * generated based on the dialog information and added to the request. 
+       * If the dialog has a route, it is added to the request, too.
+       */
+      if (nta_msg_request_complete(msg, ds->ds_leg, method, name, url) < 0)
+	goto error;
+      add_service_route = 0;
+    }
+    /***
+     * @MaxForwards header (with default value set by NTATAG_MAX_FORWARDS()) is
+     * also added now, if it does not exist.
+     */
+
+    /**
+     * Next, the stack generates a @Contact header for the request (unless
+     * the application already gave a @Contact header or it does not want to
+     * use @Contact and indicates that by including SIPTAG_CONTACT(NULL) or
+     * SIPTAG_CONTACT(SIP_NONE) in the tagged parameters.) If the
+     * application has registered the URI in @From header, the @Contact
+     * header used with registration is used. Otherwise, the @Contact header
+     * is generated from the local IP address and port number.
+     */
+    if (!add_contact ||
+	sip->sip_contact ||
+	nua_tagis_have_contact_tag(nh->nh_tags) ||
+	nua_tagis_have_contact_tag(ta_args(ta)))
+      add_contact = 0;
+
+    /**For the initial requests, @ServiceRoute set received from the registrar
+     * is also added to the request message.
+     */
+    if (add_contact || add_service_route) {
+      if (nua_registration_add_contact_to_request(nh, msg, sip, 
+						  add_contact, 
+						  add_service_route) < 0)
+	goto error;
+    }
 
-  switch (sip->sip_request->rq_url->url_type) {
-  case url_sip:
-  case url_sips:
-  case url_im:
-  case url_pres:
-  case url_tel:
-    break;
-  default:
-    nta_incoming_treply(irq, status = SIP_416_UNSUPPORTED_URI,
-			SIPTAG_ALLOW(allow),
-			SIPTAG_SUPPORTED(supported),
-			SIPTAG_USER_AGENT_STR(user_agent),
-			TAG_END());
-    return status;
+    if (method != sip_method_ack) {
+      if (nh->nh_auth) {
+	nh_authorize(nh, ta_tags(ta));
+
+	if (method != sip_method_invite &&
+	    method != sip_method_update &&
+	    method != sip_method_prack &&
+	    /* auc_authorize() removes existing authentication headers */
+	    auc_authorize(&nh->nh_auth, msg, sip) < 0)
+	  goto error;
+      }
+    }
+    else /* ACK */ {
+      while (sip->sip_allow)
+	sip_header_remove(msg, sip, (sip_header_t*)sip->sip_allow);
+      while (sip->sip_priority)
+	sip_header_remove(msg, sip, (sip_header_t*)sip->sip_priority);
+      while (sip->sip_proxy_require)
+	sip_header_remove(msg, sip, (sip_header_t*)sip->sip_proxy_require);
+      while (sip->sip_require)
+	sip_header_remove(msg, sip, (sip_header_t*)sip->sip_require);
+      while (sip->sip_subject)
+	sip_header_remove(msg, sip, (sip_header_t*)sip->sip_subject);
+      while (sip->sip_supported)
+	sip_header_remove(msg, sip, (sip_header_t*)sip->sip_supported);
+    }
+
+    ta_end(ta);
+
+    if (!ds->ds_remote)
+      ds->ds_remote = sip_to_dup(nh->nh_home, sip->sip_to);
+    if (!ds->ds_local)
+      ds->ds_local = sip_from_dup(nh->nh_home, sip->sip_from);
+
+    if (copy) {
+      cr->cr_msg = msg;
+      msg = msg_copy(msg);
+    }
   }
 
-  if (nta_check_required(irq, sip, supported,
-			 SIPTAG_ALLOW(allow),
-			 SIPTAG_USER_AGENT_STR(user_agent),
-			 TAG_END()))
-    return 420;
-
-  if (method > sip_method_unknown && method <= sip_method_publish)
-    sm = nua_server_methods[method];
-  else
-    sm = nua_server_methods[0];
-
-  initial = nh == nua->nua_dhandle;
+  return msg;
 
-  if (sm == NULL) {
-    SU_DEBUG_1(("nua(%p): strange %s from <" URL_PRINT_FORMAT ">\n",
-		(void *)nh, sip->sip_request->rq_method_name,
-		URL_PRINT_ARGS(sip->sip_from->a_url)));
-  }
-  else if (initial && sm->sm_flags.in_dialog) {
-    /* These must be in-dialog */
-    sm = NULL;
-  }
-  else if (initial && sip->sip_to->a_tag) {
-    /* RFC 3261 section 12.2.2:
-       
-       If the UAS wishes to reject the request because it does not wish to
-       recreate the dialog, it MUST respond to the request with a 481
-       (Call/Transaction Does Not Exist) status code and pass that to the
-       server transaction.
-    */
-    if (method != sip_method_message || !NH_PGET(nh, win_messenger_enable))
-      sm = NULL;
-  }
+ error:
+  ta_end(ta);
+  msg_destroy(msg);
+  return NULL;
+}
 
-  if (!sm) {
-    nta_incoming_treply(irq,
-			status = 481, "Call Does Not Exist",
-			SIPTAG_ALLOW(allow),
-			SIPTAG_SUPPORTED(supported),
-			SIPTAG_USER_AGENT_STR(user_agent),
-			TAG_END());
-    return 481;
-  }
+/* ---------------------------------------------------------------------- */
+nua_client_request_t *
+nua_client_request_pending(nua_client_request_t const *cr)
+{
+  for (;cr;cr = cr->cr_next)
+    if (cr->cr_orq)
+      return (nua_client_request_t *)cr;
 
-  sr = memset(sr0, 0, (sizeof sr0));
+  return NULL;
+}
 
-  sr->sr_methods = sm;
-  sr->sr_method = method = sip->sip_request->rq_method;
-  sr->sr_add_contact = sm->sm_flags.add_contact;
+nua_client_request_t *
+nua_client_request_restarting(nua_client_request_t const *cr)
+{
+  for (;cr;cr = cr->cr_next)
+    if (cr->cr_restart)
+      return (nua_client_request_t *)cr;
 
-  sr->sr_owner = nh;
-  sr->sr_initial = initial;
+  return NULL;
+}
 
-  sr->sr_irq = irq;
+nua_client_request_t *
+nua_client_request_by_orq(nua_client_request_t const *cr,
+			  nta_outgoing_t const *orq)
+{
+  for (;cr;cr = cr->cr_next)
+    if (cr->cr_orq == orq)
+      return (nua_client_request_t *)cr;
 
-  SR_STATUS1(sr, SIP_100_TRYING);
+  return NULL;
+}
 
-  sr->sr_request.msg = nta_incoming_getrequest(irq);
-  sr->sr_request.sip = sip;
-  assert(sr->sr_request.msg);
+void nua_creq_deinit(nua_client_request_t *cr, nta_outgoing_t *orq)
+{
+  if (orq == NULL || orq == cr->cr_orq) {
+    cr->cr_retry_count = 0;
+    cr->cr_offer_sent = cr->cr_answer_recv = 0;
 
-  sr->sr_response.msg = nta_incoming_create_response(irq, 0, NULL);
-  sr->sr_response.sip = sip_object(sr->sr_response.msg);
+    if (cr->cr_msg)
+      msg_destroy(cr->cr_msg);
+    cr->cr_msg = NULL;
 
-  if (sr->sr_response.msg == NULL) {
-    SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-  }
-  else if (sm->sm_init && sm->sm_init(sr)) {
-    if (sr->sr_status < 200)    /* Init may have set response status */
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+    if (cr->cr_orq)
+      nta_outgoing_destroy(cr->cr_orq);
+    cr->cr_orq = NULL;
   }
-  /* Create handle if request does not fail */
-  else if (initial && sr->sr_status < 300) {
-    if ((nh = nua_stack_incoming_handle(nua, irq, sip, create_dialog)))
-      sr->sr_owner = nh;
-    else
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  else {
+    nta_outgoing_destroy(orq);
   }
+}
 
-  if (sr->sr_status < 300 && sm->sm_preprocess && sm->sm_preprocess(sr)) {
-    if (sr->sr_status < 200)    /* Preprocess may have set response status */
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-  }
 
-  if (sr->sr_status < 300) {
-    if (sm->sm_flags.target_refresh)
-      nua_dialog_uas_route(nh, nh->nh_ds, sip, 1); /* Set route and tags */
-    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-  }
+/**@internal
+ * Get remote contact header for @a irq */
+static inline
+sip_contact_t const *incoming_contact(nta_incoming_t *irq)
+{
+  sip_contact_t const *retval = NULL;
+  msg_t *request;
+  sip_t *sip;
 
-  if (sr->sr_status == 100 && method != sip_method_unknown &&
-      !sip_is_allowed(NH_PGET(sr->sr_owner, appl_method), method, name)) {
-    if (method == sip_method_refer || method == sip_method_subscribe)
-      SR_STATUS1(sr, SIP_202_ACCEPTED);
-    else
-      SR_STATUS1(sr, SIP_200_OK);
-  }
+  request = nta_incoming_getrequest(irq);
+  sip = sip_object(request);
+  if (sip)
+    retval = sip->sip_contact;
+  msg_destroy(request);
 
-  /* INVITE server request is not finalized after 2XX response */
-  if (sr->sr_status < (method == sip_method_invite ? 300 : 200)) {
-    sr = su_alloc(nh->nh_home, (sizeof *sr));
+  return retval;
+}
 
-    if (sr) {
-      *sr = *sr0;
+/**@internal
+ * Create a response message.
+ */
+msg_t *nh_make_response(nua_t *nua,
+			nua_handle_t *nh,
+			nta_incoming_t *irq,
+			int status, char const *phrase,
+			tag_type_t tag, tag_value_t value, ...)
+{
+  ta_list ta;
+  msg_t *msg = nta_msg_create(nua->nua_nta, 0);
+  sip_t *sip = sip_object(msg);
+  msg_t *retval = NULL;
+  tagi_t const *t;
 
-      if ((sr->sr_next = nh->nh_ds->ds_sr))
-	*(sr->sr_prev = sr->sr_next->sr_prev) = sr,
-	  sr->sr_next->sr_prev = &sr->sr_next;
-      else
-	*(sr->sr_prev = &nh->nh_ds->ds_sr) = sr;
-    }
-    else {
-      sr = sr0;
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-    }
-  }
-
-  if (sr->sr_status <= 100) {
-    SR_STATUS1(sr, SIP_100_TRYING);
-    if (method == sip_method_invite || sip->sip_timestamp) {
-      nta_incoming_treply(irq, SIP_100_TRYING,
-			  SIPTAG_USER_AGENT_STR(user_agent),
-			  TAG_END());
-    }
-  }
-  else {
-    /* Note that this may change the sr->sr_status */
-    nua_server_respond(sr, NULL);
-  }
-
-  if (nua_server_report(sr) == 0)
-    return 0;
-
-  return 501;
-}		 
-
-#undef nua_base_server_init
-#undef nua_base_server_preprocess
-
-int nua_base_server_init(nua_server_request_t *sr)
-{
-  return 0;
-}
-
-int nua_base_server_preprocess(nua_server_request_t *sr)
-{
-  return 0;
-}
-
-void nua_server_request_destroy(nua_server_request_t *sr)
-{
-  if (sr == NULL)
-    return;
-
-  if (sr->sr_irq)
-    nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL;
-
-  if (sr->sr_request.msg)
-    msg_destroy(sr->sr_request.msg), sr->sr_request.msg = NULL;
-
-  if (sr->sr_response.msg)
-    msg_destroy(sr->sr_response.msg), sr->sr_response.msg = NULL;
-
-  if (sr->sr_prev) {
-    /* Allocated from heap */
-    if ((*sr->sr_prev = sr->sr_next))
-      sr->sr_next->sr_prev = sr->sr_prev;
-    su_free(sr->sr_owner->nh_home, sr);
-  }
-}
-
-/** Respond to a request with given status. 
- *
- * When nua protocol engine receives an incoming SIP request, it can either
- * respond to the request automatically or let it up to application to
- * respond to the request. The automatic answer is sent if the request fails
- * because of method, SIP extension or, in some times, MIME content
- * negotiation fails.
- *
- * When responding to an incoming INVITE request, the nua_respond() can be
- * called without NUTAG_WITH() (or NUTAG_WITH_CURRENT() or
- * NUTAG_WITH_SAVED()). Otherwise, NUTAG_WITH() will contain an indication
- * of the request being responded.
- *
- * In order to simplify the simple applications, most requests are responded
- * automatically. The set of requests always responded by the stack include
- * BYE, CANCEL and NOTIFY. The application can add methods that it likes to
- * handle by itself with NUTAG_APPL_METHOD(). The default set of
- * NUTAG_APPL_METHOD() includes INVITE, PUBLISH, REGISTER and SUBSCRIBE. 
- * Note that unless the method is also included in the set of allowed
- * methods with NUTAG_ALLOW(), the stack will respond to the incoming
- * methods with <i>405 Not Allowed</i>.
- *
- * Note that certain methods are rejected outside a SIP session (created
- * with INVITE transaction). They include BYE, UPDATE, PRACK and INFO. Also
- * the auxiliary methods ACK and CANCEL are rejected by stack if there is no
- * ongoing INVITE transaction corresponding to them.
- *
- * @param nh              Pointer to operation handle
- * @param status          SIP response status (see RFCs of SIP)
- * @param phrase          free text (default response phrase used if NULL)
- * @param tag, value, ... List of tagged parameters
- *
- * @return 
- *    nothing
- *
- * @par Related Tags:
- *    NUTAG_WITH(), NUTAG_WITH_CURRENT(), NUTAG_WITH_SAVED() \n
- *    NUTAG_EARLY_ANSWER() \n
- *    SOATAG_ADDRESS() \n
- *    SOATAG_AF() \n
- *    SOATAG_HOLD() \n
- *    Tags in <sip_tag.h>.
- *
- * @par Events:
- *    #nua_i_state \n
- *    #nua_i_media_error \n
- *    #nua_i_error \n
- *    #nua_i_active \n
- *    #nua_i_terminated \n
- *
- * @sa #nua_i_invite, #nua_i_register, #nua_i_subscribe, #nua_i_publish
- */
-void
-nua_stack_respond(nua_t *nua, nua_handle_t *nh,
-		  int status, char const *phrase, tagi_t const *tags)
-{
-  nua_server_request_t *sr;
-  tagi_t const *t;
-  msg_t const *request = NULL;
-
-  t = tl_find_last(tags, nutag_with);
-
-  if (t)
-    request = (msg_t const *)t->t_value;
-
-  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next) {
-    if (request && sr->sr_request.msg == request)
-      break;
-    /* nua_respond() to INVITE can be used without NUTAG_WITH() */
-    if (!t && sr->sr_method == sip_method_invite)
-      break;
-  }
-
-  if (sr == NULL) {
-    nua_stack_event(nua, nh, NULL, nua_i_error,
-		    500, "Responding to a Non-Existing Request", NULL);
-  }
-  else if (!nua_server_request_is_pending(sr)) {
-    nua_stack_event(nua, nh, NULL, nua_i_error,
-		    500, "Already Sent Final Response", NULL);
-  }
-  else {
-    sr->sr_application = status;
-
-    if (tags && nua_stack_set_params(nua, nh, nua_i_none, tags) < 0)
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-    else
-      sr->sr_status = status, sr->sr_phrase = phrase;
-
-    nua_server_params(sr, tags);
-    nua_server_respond(sr, tags);
-    nua_server_report(sr);
-  }
-}
-
-int nua_server_params(nua_server_request_t *sr, tagi_t const *tags)
-{
-  if (sr->sr_methods->sm_params)
-    return sr->sr_methods->sm_params(sr, tags);
-  return 0;
-}
-
-#undef nua_base_server_params
-
-int nua_base_server_params(nua_server_request_t *sr, tagi_t const *tags) 
-{
-  return 0;
-}
-
-/** Return the response to the client.
- *
- * @retval 0 when successfully sent
- * @retval -1 upon an error
- */
-int nua_server_trespond(nua_server_request_t *sr,
-			tag_type_t tag, tag_value_t value, ...)
-{
-  int retval;
-  ta_list ta;
   ta_start(ta, tag, value);
-  retval = nua_server_respond(sr, ta_args(ta));
-  ta_end(ta);
-  return retval;
-}
-
-/** Return the response to the client.
- *
- * @retval 0 when successfully sent
- * @retval -1 upon an error
- */
-int nua_server_respond(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  sip_method_t method = sr->sr_method;
-  struct { msg_t *msg; sip_t *sip; } next = { NULL, NULL };
-  tagi_t next_tags[2] = {{ SIPTAG_END() }, { TAG_NEXT(tags) }};
-  int retval;
-
-  msg_t *msg = sr->sr_response.msg;
-  sip_t *sip = sr->sr_response.sip;
-  sip_contact_t *m = sr->sr_request.sip->sip_contact;
-
-  if (sr->sr_response.msg == NULL) {
-    assert(sr->sr_status == 500);
-    goto internal_error;
-  }
-
-  if (sr->sr_status < 200) {
-    next.msg = nta_incoming_create_response(sr->sr_irq, 0, NULL);
-    next.sip = sip_object(next.msg);
-    if (next.sip == NULL)
-      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-  }
 
-  if (nta_incoming_complete_response(sr->sr_irq, msg,
-				     sr->sr_status,
-				     sr->sr_phrase,
-				     TAG_NEXT(tags)) < 0)
-    ;
+  if (!msg)
+    /* retval is NULL */;
+  else if (nta_msg_response_complete(msg, irq, status, phrase) < 0)
+    msg_destroy(msg);
+  else if (sip_add_tl(msg, sip, ta_tags(ta)) < 0)
+    msg_destroy(msg);
+  else if (sip_complete_message(msg) < 0)
+    msg_destroy(msg);
   else if (!sip->sip_supported && NH_PGET(nh, supported) &&
 	   sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, supported)) < 0)
-    ;
+    msg_destroy(msg);
   else if (!sip->sip_user_agent && NH_PGET(nh, user_agent) &&
 	   sip_add_make(msg, sip, sip_user_agent_class, 
 			NH_PGET(nh, user_agent)) < 0)
-    ;
+    msg_destroy(msg);
   else if (!sip->sip_organization && NH_PGET(nh, organization) &&
-	   sip_add_dup(msg, sip, (void *)NH_PGET(nh, organization)) < 0)
-    ;
+	   sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, organization)) < 0)
+    msg_destroy(msg);
   else if (!sip->sip_allow && NH_PGET(nh, allow) &&
-	   sip_add_dup(msg, sip, (void *)NH_PGET(nh, allow)) < 0)
-    ;
+	   sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow)) < 0)
+    msg_destroy(msg);
   else if (!sip->sip_allow_events && 
-	   (method == sip_method_publish || method == sip_method_subscribe) &&
+	   (sip->sip_cseq && 
+	    (sip->sip_cseq->cs_method == sip_method_publish ||
+	     sip->sip_cseq->cs_method == sip_method_subscribe)) &&
 	   NH_PGET(nh, allow_events) &&
-	   sip_add_dup(msg, sip, (void *)NH_PGET(nh, allow_events)) < 0)
-    ;
-  else if (!sip->sip_contact && sr->sr_status < 300 && sr->sr_add_contact &&
-	   nua_registration_add_contact_to_response(nh, msg, sip, NULL, m) < 0)
-    ;
-  else {
-    int term;
-    
-    term = sip_response_terminates_dialog(sr->sr_status, sr->sr_method, NULL);
-
-    sr->sr_terminating = (term < 0) ? -1 : (term > 0 || sr->sr_terminating);
-
-    retval = sr->sr_methods->sm_respond(sr, next_tags);
-
-    if (sr->sr_status < 200) 
-      sr->sr_response.msg = next.msg, sr->sr_response.sip = next.sip;
-    else if (next.msg)
-      msg_destroy(next.msg);
-
-    assert(sr->sr_status >= 200 || sr->sr_response.msg);
-
-    return retval;
-  }
-
-  if (next.msg)
-    msg_destroy(next.msg);
-
-  SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
-
-  msg_destroy(msg);
+	   sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow_events)) < 0)
+    msg_destroy(msg);
+  else if (!sip->sip_contact &&
+	   (t = tl_find(ta_args(ta), _nutag_add_contact)) &&
+	   t->t_value && 
+	   nua_registration_add_contact_to_response(nh, msg, sip, NULL, 
+						    incoming_contact(irq)) < 0)
+    msg_destroy(msg);
+  else
+    retval = msg;
 
- internal_error:
-  sr->sr_response.msg = NULL, sr->sr_response.sip = NULL;
-  nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
+  ta_end(ta);
 
-  return 0;
+  return retval;
 }
 
-/** Return the response to the client.
- *
- * @retval 0 when successfully sent
- * @retval -1 upon an error
- */
-int nua_base_server_respond(nua_server_request_t *sr, tagi_t const *tags)
-{
-  msg_t *response = sr->sr_response.msg;
-
-  sr->sr_response.msg = NULL, sr->sr_response.sip = NULL;
 
-  return nta_incoming_mreply(sr->sr_irq, response);
-}
-
-int nua_server_report(nua_server_request_t *sr)
-{
-  if (sr)
-    return sr->sr_methods->sm_report(sr, NULL);
-  else
-    return 1;
-}
+/* ======================================================================== */
+/* Generic processing */
 
-int nua_base_server_treport(nua_server_request_t *sr,
-			    tag_type_t tag, tag_value_t value,
-			    ...)
+int nua_stack_process_unknown(nua_t *nua,
+			      nua_handle_t *nh,
+			      nta_incoming_t *irq,
+			      sip_t const *sip)
 {
-  int retval;
-  ta_list ta;
-  ta_start(ta, tag, value);
-  retval = nua_base_server_report(sr, ta_args(ta));
-  ta_end(ta);
-  return retval;
+  return 501;
 }
 
-/**Report request event to the application.
+/**@internal
+ * Relay response message to the application.
  *
- * @retval 0 request lives
- * @retval 1 request was destroyed
- * @retval 2 request and its usage was destroyed
- * @retval 3 request, all usages and dialog was destroyed
- * @retval 4 request, all usages, dialog, and handle was destroyed
+ * If handle has already been marked as destroyed by nua_handle_destroy(),
+ * release the handle with nh_destroy().
  */
-int nua_base_server_report(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_t *nua = nh->nh_nua;
-  nua_dialog_usage_t *usage = sr->sr_usage;
-  int initial = sr->sr_initial;
-  int status = sr->sr_status;
-  char const *phrase = sr->sr_phrase;
-
-  int terminated;
-  int handle_can_be_terminated = initial && !sr->sr_event;
-
-  assert(nh);
-
-  if (sr->sr_application) {
-    /* There was an error sending response */
-    if (sr->sr_application != sr->sr_status)
-      nua_stack_event(nua, nh, NULL, nua_i_error, status, phrase, tags);
-    sr->sr_application = 0;
-  }
-  else if (status < 300 && !sr->sr_event) {
-    msg_t *msg = msg_ref_create(sr->sr_request.msg);
-    nua_event_t e = sr->sr_methods->sm_event;
-    sr->sr_event = 1;
-    nua_stack_event(nua, nh, msg, e, status, phrase, tags);
-  }
-
-  if (status < 200)
-    return 0;			/* sr lives on until final response is sent */
-
-  if (sr->sr_method == sip_method_invite && status < 300)
-    return 0;			/* INVITE lives on until ACK is received */
-
-  if (initial && 300 <= status)
-    terminated = 1;
-  else if (sr->sr_terminating && status < 300)
-    terminated = 1;
-  else
-    terminated = sip_response_terminates_dialog(status, sr->sr_method, NULL);
-
-  nua_server_request_destroy(sr);
-
-  if (!terminated)
-    return 1;
+int nua_stack_process_response(nua_handle_t *nh,
+			       nua_client_request_t *cr,
+			       nta_outgoing_t *orq,
+			       sip_t const *sip,
+			       tag_type_t tag, tag_value_t value, ...)
+{
+  msg_t *msg = nta_outgoing_getresponse(orq);
+  int status = sip->sip_status->st_status;
+  char const *phrase = sip->sip_status->st_phrase;
+  ta_list ta;
+  int final;
 
-  if (usage)
-    nua_dialog_usage_remove(nh, nh->nh_ds, usage);
+  if (status >= 200 && status < 300)
+    nh_challenge(nh, sip);  /* Collect nextnonce */
 
-  if (!initial) {
-    if (terminated > 0)
-      return 2;
+  if (nta_outgoing_method(orq) == sip_method_invite)
+    final = status >= 300;
+  else
+    final = status >= 200;
 
-    /* Remove all usages of the dialog */
-    nua_dialog_remove_usages(nh, nh->nh_ds, status, phrase);
+  if (final && cr) {
+    nua_creq_deinit(cr, orq);
 
-    return 3;
-  }
-  else if (!handle_can_be_terminated) {
-    return 3;
-  }
-  else {
-    if (nh != nh->nh_nua->nua_dhandle)
-      nh_destroy(nh->nh_nua, nh);
+    if (cr->cr_usage && nh->nh_ds->ds_cr == cr) {
+      if ((status >= 300 && !cr->cr_usage->du_ready) ||
+	  cr->cr_usage->du_terminating)
+	nua_dialog_usage_remove(nh, nh->nh_ds, cr->cr_usage);
+    }
 
-    return 4;
+    cr->cr_usage = NULL;
   }
-}
 
-/* ---------------------------------------------------------------------- */
+  ta_start(ta, tag, value);
 
-/** @class nua_client_request
- *
- * Each handle has a queue of client-side requests; if a request is pending,
- * a new request from API is added to the queue. After the request is
- * complete, it is removed from the queue and destroyed by the default. The
- * exception is the client requests bound to a dialog usage: they are saved
- * and re-used when the dialog usage is refreshed (and sometimes when the
- * usage is terminated).
- * 
- * The client request is subclassed and its behaviour modified using virtual
- * function table in #nua_client_methods_t.
- * 
- * The first three methods (crm_template(), crm_init(), crm_send()) are
- * called when the request is sent first time.
- * 
- * The crm_template() is called if a template request message is needed (for
- * example, in case of unregister, unsubscribe and unpublish, the template
- * message is taken from the request establishing the usage).
- * 
- * The crm_init() is called when the template message and dialog leg has
- * been created and populated by the tags procided by the application. Its
- * parameters msg and sip are pointer to the template request message that
- * is saved in the @ref "cr_msg" nua_client_request::cr_msg field.
- *
- * The crm_send() is called with a copy of the template message that has
- * been populated with all the fields included in the request, including
- * @CSeq and @MaxForwards. The crm_send() function, such as
- * nua_publish_client_request(), usually calls nua_base_client_trequest() that
- * then creates the nta-level transaction.
- *
- * The response to the request is processed by crm_check_restart(), which
- * modifies and restarts the request when needed (e.g., when negotiating
- * expiration time). After the request has been suitably modified, e.g., the
- * expiration time has been increased, the restart function calls
- * nua_client_restart(), which restarts the request and relays the
- * intermediate response to the application with nua_client_restart() and
- * crm_report().
- *
- * The final responses are processed by crm_recv() and and preliminary ones
- * by crm_preliminary(). Both functions call nua_base_client_response() after
- * method-specific processing.
- *
- * The nua_base_client_response() relays the response to the application with
- * nua_client_restart() and crm_report().
- *
- * @par Terminating Dialog Usages and Dialogs
- *
- * The response can be marked as terminating with nua_client_terminating(). 
- * When a terminating request completes the dialog usage is removed and the
- * dialog is destroyed (unless there is an another active usage).
- */
-static int nua_client_request_try(nua_client_request_t *cr);
-static int nua_client_request_sendmsg(nua_client_request_t *cr,
-  				      msg_t *msg, sip_t *sip);
-
-/**Create a client request.
- *
- * @retval 0 if request is pending
- * @retval > 0 if error event has been sent
- * @retval < 0 upon an error
- */
-int nua_client_create(nua_handle_t *nh, 
-		      int event,
-		      nua_client_methods_t const *methods,
-		      tagi_t const * const tags)
-{
-  su_home_t *home = nh->nh_home;
-  nua_client_request_t *cr;
-  sip_method_t method;
-  char const *name;
-
-  method = methods->crm_method, name = methods->crm_method_name;
-  if (!name) {
-    tagi_t const *t = tl_find_last(tags, nutag_method);
-    if (t)
-      name = (char const *)t->t_value;
-  }
-
-  cr = su_zalloc(home, sizeof *cr + methods->crm_extra);
-  if (!cr) {
-    return nua_stack_event(nh->nh_nua, nh, 
-			   NULL,
-			   event,
-			   NUA_INTERNAL_ERROR,
-			   NULL);
-  }
-
-  cr->cr_owner = nh;
-  cr->cr_methods = methods;
-  cr->cr_event = event;
-  cr->cr_method = method;
-  cr->cr_method_name = name;
-  cr->cr_contactize = methods->crm_flags.target_refresh;
-  cr->cr_auto = 1;
-
-  if (su_msg_is_non_null(nh->nh_nua->nua_signal)) {
-    nua_event_data_t const *e = su_msg_data(cr->cr_signal);
-
-    if (tags == e->e_tags && event == e->e_event) {
-      cr->cr_auto = 0;
-      if (tags) {
-	su_msg_save(cr->cr_signal, nh->nh_nua->nua_signal);
-	cr->cr_tags = tags;
-      }
-    }
-  }
+  nua_stack_event(nh->nh_nua, nh, msg, cr->cr_event, status, phrase,
+		  ta_tags(ta));
 
-  if (tags && cr->cr_tags == NULL)
-    cr->cr_tags = tl_tlist(nh->nh_home, TAG_NEXT(tags));
+  if (final)
+    cr->cr_event = nua_i_error;
 
-  if (nua_client_request_queue(cr))
-    return 0;
+  ta_end(ta);
 
-  return nua_client_init_request(cr);
+  return 0;
 }
 
-int nua_client_tcreate(nua_handle_t *nh, 
-		       int event,
-		       nua_client_methods_t const *methods,
-		       tag_type_t tag, tag_value_t value, ...)
+static inline
+int can_redirect(sip_contact_t const *m, sip_method_t method)
 {
-  int retval;
-  ta_list ta;
-  ta_start(ta, tag, value);
-  retval = nua_client_create(nh, event, methods, ta_args(ta));
-  ta_end(ta);
-  return retval;
+  if (m && m->m_url->url_host) {
+    enum url_type_e type = m->m_url->url_type;
+    return
+      type == url_sip ||
+      type == url_sips ||
+      (type == url_tel &&
+       (method == sip_method_invite || method == sip_method_message)) ||
+      (type == url_im && method == sip_method_message) ||
+      (type == url_pres && method == sip_method_subscribe);
+  }
+  return 0;
 }
 
-inline int nua_client_request_queue(nua_client_request_t *cr)
+int nua_creq_restart_with(nua_handle_t *nh,
+			  nua_client_request_t *cr,
+			  nta_outgoing_t *orq,
+			  int status, char const *phrase,
+			  nua_creq_restart_f *f,
+			  TAG_LIST)
 {
-  int queued = 0;
-  nua_client_request_t **queue = &cr->cr_owner->nh_ds->ds_cr;
+  ta_list ta;
+  msg_t *msg = nta_outgoing_getresponse(orq);
 
-  assert(cr->cr_prev == NULL && cr->cr_next == NULL);
+  nua_stack_event(nh->nh_nua, nh, msg, cr->cr_event, status, phrase,
+		  TAG_END());
 
-  cr->cr_status = 0;
+  nta_outgoing_destroy(orq);
 
-  if (cr->cr_method != sip_method_invite &&
-      cr->cr_method != sip_method_cancel) {
-    while (*queue) {
-      if ((*queue)->cr_method == sip_method_invite ||
-	  (*queue)->cr_method == sip_method_cancel)
-	break;
-      queue = &(*queue)->cr_next;
-      queued = 1;
-    }
+  if (f) {
+    ta_start(ta, tag, value);
+    f(nh, ta_args(ta));
+    ta_end(ta);
   }
-  else {
-    while (*queue) {
-      queue = &(*queue)->cr_next;
-      if (cr->cr_method == sip_method_invite)
-	queued = 1;
-    }
-  }
-
-  if ((cr->cr_next = *queue))
-    cr->cr_next->cr_prev = &cr->cr_next;
 
-  cr->cr_prev = queue, *queue = cr;
-
-  return queued;
+  return 1;
 }
 
-inline nua_client_request_t *nua_client_request_remove(nua_client_request_t *cr)
-{
-  if (cr->cr_prev)
-    if ((*cr->cr_prev = cr->cr_next))
-      cr->cr_next->cr_prev = cr->cr_prev;
-  cr->cr_prev = NULL, cr->cr_next = NULL;
-  return cr;
-}
 
-void nua_client_request_destroy(nua_client_request_t *cr)
+/** @internal Save operation until it can be restarted */
+int nua_creq_save_restart(nua_handle_t *nh,
+			  nua_client_request_t *cr,
+			  nta_outgoing_t *orq,
+			  int status, char const *phrase,
+			  nua_creq_restart_f *restart_function)
 {
-  nua_handle_t *nh;
-  
-  if (cr == NULL)
-    return;
-
-  if (cr->cr_methods->crm_deinit)
-    cr->cr_methods->crm_deinit(cr);
-
-  nh = cr->cr_owner;
-
-  su_msg_destroy(cr->cr_signal);
-
-  nua_client_request_remove(cr);
-  nua_client_bind(cr, NULL);
-  
-  if (cr->cr_msg)
-    msg_destroy(cr->cr_msg);
-  cr->cr_msg = NULL, cr->cr_sip = NULL;
-
-  if (cr->cr_orq)
-    nta_outgoing_destroy(cr->cr_orq);
+  nua_dialog_usage_t *du = cr->cr_usage;
+  msg_t *msg = nta_outgoing_getresponse(orq);
 
-  cr->cr_orq = NULL;
+  nua_stack_event(nh->nh_nua, nh, msg, cr->cr_event,
+		  status, phrase, 
+		  TAG_END());
+  nta_outgoing_destroy(orq);
 
-  if (cr->cr_target)
-    su_free(nh->nh_home, cr->cr_target);
+  if (du)
+    du->du_refresh = 0;
 
-  su_free(nh->nh_home, cr);
+  cr->cr_restart = restart_function;
+  return 1;
 }
 
-/** Bind client request to a dialog usage */ 
-int nua_client_bind(nua_client_request_t *cr, nua_dialog_usage_t *du)
-{
-  assert(cr);
-  if (cr == NULL)
-    return -1;
 
-  if (du == NULL) {
-    if (cr->cr_usage && cr->cr_usage->du_cr == cr)
-      cr->cr_usage->du_cr = NULL;
-    cr->cr_usage = NULL;
-    return 0;
-  }
-
-  if (du->du_cr && cr != du->du_cr) {
-    if (nua_client_is_queued(du->du_cr))
-      return -1;
-    if (nua_client_is_reporting(du->du_cr)) {
-      du->du_cr->cr_usage = NULL;
-      du->du_cr = NULL;
-    }
-    else
-      nua_client_request_destroy(du->du_cr);
-  }
-
-  du->du_cr = cr, cr->cr_usage = du;
-
-  return 0;
-}
-
-/**Initialize client request for sending.
- *
- * This function is called only first time the request is sent.
+/**@internal
+ * Check response, return true if we can restart the request.
  *
- * @retval 0 if request is pending
- * @retval >=1 if error event has been sent
  */
-int nua_client_init_request(nua_client_request_t *cr)
+int nua_creq_check_restart(nua_handle_t *nh,
+			   nua_client_request_t *cr,
+			   nta_outgoing_t *orq,
+			   sip_t const *sip,
+			   nua_creq_restart_f *restart_function)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_t *nua = nh->nh_nua;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  msg_t *msg = NULL;
-  sip_t *sip;
-  url_string_t const *url = NULL;
-  tagi_t const *t;
-  int has_contact = 0;
-  int error = 0;
-  
-  if (!cr->cr_method_name)
-    return nua_client_return(cr, NUA_INTERNAL_ERROR, NULL);
-
-  if (cr->cr_msg)
-    return nua_client_request_try(cr);
+  int status = sip->sip_status->st_status;
+  sip_method_t method = nta_outgoing_method(orq);
 
-  cr->cr_answer_recv = 0, cr->cr_offer_sent = 0;
-  cr->cr_offer_recv = 0, cr->cr_answer_sent = 0;
-  cr->cr_terminated = 0, cr->cr_graceful = 0;
-
-  nua_stack_init_handle(nua, nh, TAG_NEXT(cr->cr_tags));
+  nua_dialog_usage_t *du = cr->cr_usage;
 
-  if (cr->cr_method == sip_method_cancel) {
-    if (cr->cr_methods->crm_init) {
-      error = cr->cr_methods->crm_init(cr, NULL, NULL, cr->cr_tags);
-      if (error)
-	return error;
-    }
+  assert(restart_function);
 
-    if (cr->cr_methods->crm_send)
-      return cr->cr_methods->crm_send(cr, NULL, NULL, cr->cr_tags);
-    else
-      return nua_base_client_request(cr, NULL, NULL, cr->cr_tags);
-  }
-
-  if (!cr->cr_methods->crm_template ||
-      !cr->cr_methods->crm_template(cr, &msg, cr->cr_tags))
-    msg = nta_msg_create(nua->nua_nta, 0);
+  if (orq != cr->cr_orq)
+    return 0;
 
-  sip = sip_object(msg);
-  if (!sip)
-    return nua_client_return(cr, NUA_INTERNAL_ERROR, msg);
+  cr->cr_orq = NULL;
+  cr->cr_restart = NULL;
 
-  /**@par Populating SIP Request Message with Tagged Arguments
-   *
-   * The tagged arguments can be used to pass values for any SIP headers
-   * to the stack. When the INVITE message (or any other SIP message) is
-   * created, the tagged values saved with nua_handle() are used first,
-   * next the tagged values given with the operation (nua_invite()) are
-   * added.
-   *
-   * When multiple tags for the same header are specified, the behaviour
-   * depends on the header type. If only a single header field can be
-   * included in a SIP message, the latest non-NULL value is used, e.g.,
-   * @Subject. However, if the SIP header can consist of multiple lines or
-   * header fields separated by comma, e.g., @Accept, all the tagged
-   * values are concatenated.
-   *
-   * However, if a tag value is #SIP_NONE (-1 casted as a void pointer),
-   * the values from previous tags are ignored.
-   */
-  if (nh->nh_tags) {
-    for (t = nh->nh_tags; t; t = t_next(t)) {
-      if (t->t_tag == siptag_contact ||
-	  t->t_tag == siptag_contact_str)
-	has_contact = 1;
-      else if (t->t_tag == nutag_url)
-	url = (url_string_t const *)t->t_value;
+  if (cr->cr_msg == NULL || status < 200)
+    ;
+  else if (++cr->cr_retry_count > NH_PGET(nh, retry_count))
+    ;
+  else if (status == 302) {
+    if (can_redirect(sip->sip_contact, method)) {
+      return
+	nua_creq_restart_with(nh, cr, orq, 100, "Redirected",
+			      restart_function,
+			      NUTAG_URL(sip->sip_contact->m_url),
+			      TAG_END());
     }
-
-    t = nh->nh_tags, sip_add_tagis(msg, sip, &t);
   }
+  else if (status == 423) {
+    sip_t *req = sip_object(cr->cr_msg);
+    unsigned my_expires = 0;
 
-  for (t = cr->cr_tags; t; t = t_next(t)) {
-    if (t->t_tag == siptag_contact ||
-	t->t_tag == siptag_contact_str)
-      has_contact = 1;
-    else if (t->t_tag == nutag_url)
-      url = (url_string_t const *)t->t_value;
-    else if (t->t_tag == nutag_auth && t->t_value) {
-      /* XXX ignoring errors */
-      if (nh->nh_auth)
-	auc_credentials(&nh->nh_auth, nh->nh_home, (char *)t->t_value);
-    }
-  }
+    if (req->sip_expires)
+      my_expires = req->sip_expires->ex_delta;
 
-  if (cr->cr_method == sip_method_register && url == NULL)
-    url = (url_string_t const *)NH_PGET(nh, registrar);
-  
-  if ((t = cr->cr_tags)) {
-    if (sip_add_tagis(msg, sip, &t) < 0)
-      goto error;
-  }
-
-  /**
-   * Now, the target URI for the request needs to be determined.
-   *
-   * For initial requests, values from tags are used. If NUTAG_URL() is
-   * given, it is used as target URI. Otherwise, if SIPTAG_TO() is given,
-   * it is used as target URI. If neither is given, the complete request
-   * line already specified using SIPTAG_REQUEST() or SIPTAG_REQUEST_STR()
-   * is used. At this point, the target URI is stored in the request line,
-   * together with method name and protocol version ("SIP/2.0"). The
-   * initial dialog information is also created: @CallID, @CSeq headers
-   * are generated, if they do not exist, and a tag is added to the @From
-   * header.
-   */
-
-  if (!ds->ds_leg) {
-    if (ds->ds_remote_tag && ds->ds_remote_tag[0] && 
-	sip_to_tag(nh->nh_home, sip->sip_to, ds->ds_remote_tag) < 0)
-      goto error;
-
-    if (sip->sip_from == NULL && 
-	sip_add_dup(msg, sip, (sip_header_t *)nua->nua_from) < 0)
-      goto error;
-
-    if (cr->cr_methods->crm_flags.create_dialog) {
-      ds->ds_leg = nta_leg_tcreate(nua->nua_nta,
-				   nua_stack_process_request, nh,
-				   SIPTAG_CALL_ID(sip->sip_call_id),
-				   SIPTAG_FROM(sip->sip_from),
-				   SIPTAG_TO(sip->sip_to),
-				   SIPTAG_CSEQ(sip->sip_cseq),
-				   TAG_END());
-      if (!ds->ds_leg)
-	goto error;
+    if (sip->sip_min_expires &&
+	sip->sip_min_expires->me_delta > my_expires) {
+      sip_expires_t ex[1];
+      sip_expires_init(ex);
+      ex->ex_delta = sip->sip_min_expires->me_delta;
 
-      if (!sip->sip_from->a_tag &&
-	  sip_from_tag(msg_home(msg), sip->sip_from,
-		       nta_leg_tag(ds->ds_leg, NULL)) < 0)
-	goto error;
+      return
+	nua_creq_restart_with(nh, cr, orq,
+			      100, "Re-Negotiating Expiration",
+			      restart_function, 
+			      SIPTAG_EXPIRES(ex),
+			      TAG_END());
+    }
+  }
+  else if (method != sip_method_ack && method != sip_method_cancel &&
+	   ((status == 401 && sip->sip_www_authenticate) ||
+	    (status == 407 && sip->sip_proxy_authenticate)) &&
+	   nh_challenge(nh, sip) > 0) {
+    msg_t *request = nta_outgoing_getrequest(orq);
+    sip_t *rsip = sip_object(request);
+    int done;
+
+    /* XXX - check for instant restart */
+    done = auc_authorization(&nh->nh_auth, cr->cr_msg, (msg_pub_t*)NULL,
+			     rsip->sip_request->rq_method_name,
+			     rsip->sip_request->rq_url,
+			     rsip->sip_payload);
+
+    msg_destroy(request);
+
+    if (done > 0) {
+      return
+	nua_creq_restart_with(nh, cr, orq,
+			      100, "Request Authorized by Cache",
+			      restart_function, TAG_END());
+    }
+    else if (done == 0) {
+      /* Operation waits for application to call nua_authenticate() */
+      return nua_creq_save_restart(nh, cr, orq, 
+				   status, sip->sip_status->st_phrase, 
+				   restart_function);
+    }
+    else {
+      SU_DEBUG_5(("nua(%p): auc_authorization failed\n", nh));
     }
   }
-  else {
-    if (ds->ds_route)
-      url = NULL;
-  }
-
-  if (url && nua_client_set_target(cr, (url_t *)url) < 0)
-    goto error;
-
-  cr->cr_has_contact = has_contact;
 
-  if (cr->cr_methods->crm_init) {
-    error = cr->cr_methods->crm_init(cr, msg, sip, cr->cr_tags);
-    if (error < -1)
-      msg = NULL;
-    if (error < 0)
-      goto error;
-    if (error != 0)
-      return error;
-  }
+  /* This was final response that cannot be restarted. */
+  cr->cr_orq = orq;
 
-  cr->cr_msg = msg;
-  cr->cr_sip = sip;
+  if (du)
+    du->du_refresh = 0;
+  cr->cr_retry_count = 0;
 
-  return nua_client_request_try(cr);
+  if (cr->cr_msg)
+    msg_destroy(cr->cr_msg), cr->cr_msg = NULL;
 
- error:
-  return nua_client_return(cr, NUA_INTERNAL_ERROR, msg);
+  return 0;
 }
 
+/** @internal Restart a request */
+int nua_creq_restart(nua_handle_t *nh,
+		     nua_client_request_t *cr,
+		     nta_response_f *cb,
+		     tagi_t *tags)
+{
+  msg_t *msg;
 
-/** Resend the request message.
- *
- * @retval 0 if request is pending
- * @retval >=1 if error event has been sent
- */
-int nua_client_resend_request(nua_client_request_t *cr,
-			      int terminating,
-			      tagi_t const *tags)
-{
-  if (cr) {
-    if (tags && cr->cr_msg)
-      if (sip_add_tagis(cr->cr_msg, NULL, &tags) < 0)
-	/* XXX */;
+  cr->cr_restart = NULL;
 
-    cr->cr_retry_count = 0;
-    cr->cr_terminating = terminating;
+  if (!cr->cr_msg)
+    return 0;
 
-    if (!nua_client_is_queued(cr)) {
-      if (nua_client_request_queue(cr))
-	return 0;
-      if (nua_client_is_reporting(cr))
-	return 0;
-    }
+  msg = nua_creq_msg(nh->nh_nua, nh, cr, 1, SIP_METHOD_UNKNOWN,
+		     TAG_NEXT(tags));
 
-    return nua_client_request_try(cr);
+  cr->cr_orq = nta_outgoing_mcreate(nh->nh_nua->nua_nta, cb, nh, NULL, msg,
+				    SIPTAG_END(), TAG_NEXT(tags));
+
+  if (!cr->cr_orq) {
+    msg_destroy(msg);
+    return 0;
   }
-  return 0;
+
+  return 1;
 }
 
+/* ======================================================================== */
+/* Authentication */
 
-/** Create a request message and send it.
+/** @NUA_EVENT nua_r_authenticate
  *
- * If an error occurs, send error event to the application.
+ * Response to nua_authenticate(). Under normal operation, this event is
+ * never sent but rather the unauthenticated operation is completed. 
+ * However, if there is no operation to authentication or if there is an
+ * authentication error the #nua_r_authenticate event is sent to the
+ * application with the status code as follows:
+ * - <i>202 No operation to restart</i>:\n
+ *   The authenticator associated with the handle was updated, but there was
+ *   no operation to retry with the new credentials.
+ * - <i>900 Cannot add credentials</i>:\n
+ *   There was internal problem updating authenticator.
+ * - <i>904 No matching challenge</i>:\n
+ *   There was no challenge matching with the credentials provided by
+ *   nua_authenticate(), e.g., their realm did not match with the one 
+ *   received with the challenge.
+ * 
+ * @param status status code from authentication 
+ * @param phrase a short textual description of @a status code
+ * @param nh     operation handle authenticated
+ * @param hmagic application context associated with the handle
+ * @param sip    NULL
+ * @param tags   empty
+ * 
+ * @sa nua_terminate(), nua_handle_destroy()
  *
- * @retval 0 if request is pending
- * @retval >=1 if error event has been sent
+ * @END_NUA_EVENT
  */
-static
-int nua_client_request_try(nua_client_request_t *cr)
-{
-  int error = -1;
-  msg_t *msg = msg_copy(cr->cr_msg);
-  sip_t *sip = sip_object(msg);
-
-  cr->cr_answer_recv = 0, cr->cr_offer_sent = 0;
-  cr->cr_offer_recv = 0, cr->cr_answer_sent = 0;
-  cr->cr_terminated = 0, cr->cr_graceful = 0;
-
-  if (msg && sip) {
-    error = nua_client_request_sendmsg(cr, msg, sip);
-    if (!error)
-      return 0;
-
-    if (error == -1)
-      msg_destroy(msg);
-  }
 
-  if (error < 0)
-    error = nua_client_response(cr, NUA_INTERNAL_ERROR, NULL);
-
-  assert(error > 0);
-  return error;
-}
-
-/**Send a request message.
- *
- * @retval 0 if request is pending
- * @retval >=1 if error event has been sent
- * @retval -1 if error occurred but event has not been sent,
-               and @a msg has not been destroyed
- * @retval -2 if error occurred, event has not been sent,
- *            but @a msg has been destroyed
- */
-static
-int nua_client_request_sendmsg(nua_client_request_t *cr, msg_t *msg, sip_t *sip)
+void
+nua_stack_authenticate(nua_t *nua, nua_handle_t *nh, nua_event_t e,
+		       tagi_t const *tags)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_state_t *ds = nh->nh_ds;
-  sip_method_t method = cr->cr_method;
-  char const *name = cr->cr_method_name;
-  url_string_t const *url = (url_string_t *)cr->cr_target;
-  nta_leg_t *leg;
-
-  assert(cr->cr_orq == NULL);
-
-  if (ds->ds_leg)
-    leg = ds->ds_leg;
-  else
-    leg = nh->nh_nua->nua_dhandle->nh_ds->ds_leg; /* Default leg */
+  int status = nh_authorize(nh, TAG_NEXT(tags));
 
-  if (nua_dialog_is_established(ds)) {
-    while (sip->sip_route)
-      sip_route_remove(msg, sip);
-  }
-  
-  /**
-   * For in-dialog requests, the request URI is taken from the @Contact
-   * header received from the remote party during dialog establishment, 
-   * and the NUTAG_URL() is ignored.
-   *
-   * Also, the @CallID and @CSeq headers and @From and @To tags are
-   * generated based on the dialog information and added to the request. 
-   * If the dialog has a route, it is added to the request, too.
-   */
-  if (nta_msg_request_complete(msg, leg, method, name, url) < 0)
-    return -1;
+  if (status > 0) {
+    nua_client_request_t *cr;
+    nua_creq_restart_f *restart = NULL;
 
-  /**@MaxForwards header (with default value set by NTATAG_MAX_FORWARDS()) is
-   * also added now, if it does not exist.
-   */
-
-  if (!ds->ds_remote)
-    ds->ds_remote = sip_to_dup(nh->nh_home, sip->sip_to);
-  if (!ds->ds_local)
-    ds->ds_local = sip_from_dup(nh->nh_home, sip->sip_from);
-
-  /**
-   * Next, values previously set with nua_set_params() or nua_set_hparams()
-   * are used: @Allow, @Supported, @Organization, and @UserAgent headers are
-   * added to the request if they are not already set. 
-   */
-  if (!sip->sip_allow && !ds->ds_route)
-    sip_add_dup(msg, sip, (sip_header_t*)NH_PGET(nh, allow));
-  
-  if (!sip->sip_supported && NH_PGET(nh, supported))
-    sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, supported));
-  
-  if (method == sip_method_register && NH_PGET(nh, path_enable) &&
-      !sip_has_feature(sip->sip_supported, "path") &&
-      !sip_has_feature(sip->sip_require, "path"))
-    sip_add_make(msg, sip, sip_supported_class, "path");
-  
-  if (!sip->sip_organization && NH_PGET(nh, organization))
-    sip_add_dup(msg, sip, (sip_header_t *)NH_PGET(nh, organization));
+    cr = nua_client_request_restarting(nh->nh_ds->ds_cr);
 
-  if (!sip->sip_user_agent && NH_PGET(nh, user_agent))
-    sip_add_make(msg, sip, sip_user_agent_class, NH_PGET(nh, user_agent));
+    if (cr) 
+      restart = cr->cr_restart, cr->cr_restart = NULL;
 
-  /**
-   * Next, the stack generates a @Contact header for the request (unless
-   * the application already gave a @Contact header or it does not want to
-   * use @Contact and indicates that by including SIPTAG_CONTACT(NULL) or
-   * SIPTAG_CONTACT(SIP_NONE) in the tagged parameters.) If the
-   * application has registered the URI in @From header, the @Contact
-   * header used with registration is used. Otherwise, the @Contact header
-   * is generated from the local IP address and port number.
-   */
-
-  /**For the initial requests, @ServiceRoute set that was received from the
-   * registrar is also added to the request message.
-   */
-  if (cr->cr_method != sip_method_register) {
-    if (nua_registration_add_contact_to_request(nh, msg, sip,
-						cr->cr_contactize &&
-						!cr->cr_has_contact,
-						!ds->ds_route) < 0)
-      return -1;
-  }
-
-  cr->cr_challenged = 0;
-
-  if (cr->cr_methods->crm_send)
-    return cr->cr_methods->crm_send(cr, msg, sip, NULL);
-
-  return nua_base_client_request(cr, msg, sip, NULL);
-}
-
-/**Add tags to request message and send it, 
- *
- * @retval 0 success
- * @retval -1 if error occurred, but event has not been sent
- * @retval -2 if error occurred, event has not been sent,
- *            and @a msg has been destroyed
- * @retval >=1 if error event has been sent
- */
-int nua_base_client_trequest(nua_client_request_t *cr,
-			     msg_t *msg, sip_t *sip,
-			     tag_type_t tag, tag_value_t value, ...)
-{
-  int retval;
-  ta_list ta;
-  ta_start(ta, tag, value);
-  retval = nua_base_client_request(cr, msg, sip, ta_args(ta));
-  ta_end(ta);
-  return retval;
+    if (restart) {
+      /* nua_stack_event(nua, nh, NULL, e, SIP_200_OK, TAG_END()); */
+      restart(nh, (tagi_t *)tags);	/* Restart operation */
+    }
+    else {
+      nua_stack_event(nua, nh, NULL, e, 
+		      202, "No operation to restart",
+		      TAG_END());
+    }
+  }
+  else if (status < 0) {
+    nua_stack_event(nua, nh, NULL, e, 900, "Cannot add credentials", TAG_END());
+  }
+  else {
+    nua_stack_event(nua, nh, NULL, e, 904, "No matching challenge", TAG_END());
+  }
 }
 
-/** Send request.
- *
- * @retval 0 success
- * @retval -1 if error occurred, but event has not been sent
- * @retval -2 if error occurred, event has not been sent,
- *            and @a msg has been destroyed
- * @retval >=1 if error event has been sent
+/* ======================================================================== */
+/*
+ * Process incoming requests
  */
-int nua_base_client_request(nua_client_request_t *cr, msg_t *msg, sip_t *sip,
-			    tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
 
-  if (nh->nh_auth && auc_authorize(&nh->nh_auth, msg, sip) < 0)
-    return nua_client_return(cr, 900, "Cannot add credentials", msg);
+int nua_stack_process_request(nua_handle_t *nh,
+			      nta_leg_t *leg,
+			      nta_incoming_t *irq,
+			      sip_t const *sip)
+{
+  nua_t *nua = nh->nh_nua;
+  sip_method_t method = sip->sip_request->rq_method;
+  char const *user_agent = NH_PGET(nh, user_agent);
+  sip_supported_t const *supported = NH_PGET(nh, supported);
+  sip_allow_t const *allow = NH_PGET(nh, allow);
+  enter;
 
-  cr->cr_seq = sip->sip_cseq->cs_seq; /* Save last sequence number */
+  nta_incoming_tag(irq, NULL);
 
-  cr->cr_orq = nta_outgoing_mcreate(nh->nh_nua->nua_nta,
-				    nua_client_orq_response, cr,
-				    NULL, 
-				    msg,
-				    TAG_NEXT(tags));
+  if (nta_check_method(irq, sip, allow,
+		       SIPTAG_SUPPORTED(supported),
+		       SIPTAG_USER_AGENT_STR(user_agent),
+		       TAG_END()))
+    return 405;
 
-  return cr->cr_orq ? 0 : -1;
-}
+  switch (sip->sip_request->rq_url->url_type) {
+  case url_sip:
+  case url_sips:
+  case url_im:
+  case url_pres:
+  case url_tel:
+    break;
+  default:
+    nta_incoming_treply(irq, SIP_416_UNSUPPORTED_URI,
+			SIPTAG_ALLOW(allow),
+			SIPTAG_SUPPORTED(supported),
+			SIPTAG_USER_AGENT_STR(user_agent),
+			TAG_END());
+  }
 
-/** Callback for nta client transaction */
-int nua_client_orq_response(nua_client_request_t *cr,
-			    nta_outgoing_t *orq,
-			    sip_t const *sip)
-{
-  int status;
-  char const *phrase;
+  if (nta_check_required(irq, sip, supported,
+			 SIPTAG_ALLOW(allow),
+			 SIPTAG_USER_AGENT_STR(user_agent),
+			 TAG_END()))
+    return 420;
 
-  if (sip && sip->sip_status) {
-    status = sip->sip_status->st_status;
-    phrase = sip->sip_status->st_phrase;
-  }
-  else {
-    status = nta_outgoing_status(orq);
-    phrase = "";
+  if (nh == nua->nua_dhandle) {
+    if (!sip->sip_to->a_tag)
+      ;
+    else if (method == sip_method_message && NH_PGET(nh, win_messenger_enable))
+      ;
+    else {
+      nta_incoming_treply(irq, 481, "Initial transaction with a To tag",
+			  TAG_END());
+      return 481;
+    }
+    nh = NULL;
   }
 
-  nua_client_response(cr, status, phrase, sip);
-
-  return 0;
-}
+  if (sip->sip_timestamp)
+    nta_incoming_treply(irq, SIP_100_TRYING, TAG_END());
 
-/**Return response to the client request.
- *
- * Return a response generated by the stack. This function is used to return
- * a error response within @a nua_client_methods_t#crm_init or @a
- * nua_client_methods_t#crm_send functions. It takes care of disposing the @a
- * to_be_destroyed that cannot be sent.
- *
- * @retval 0 if response event was preliminary
- * @retval 1 if response event was final
- * @retval 2 if response event destroyed the handle, too.
- */
-int nua_client_return(nua_client_request_t *cr,
-		      int status,
-		      char const *phrase,
-		      msg_t *to_be_destroyed)
-{
-  if (to_be_destroyed)
-    msg_destroy(to_be_destroyed);
-  nua_client_response(cr, status, phrase, NULL);
-  return 1;
-}
+  switch (method) {
+  case sip_method_invite:
+    return nua_stack_process_invite(nua, nh, irq, sip);
+
+  case sip_method_info:
+    if (nh) return nua_stack_process_info(nua, nh, irq, sip);
+    /*FALLTHROUGH*/
+
+  case sip_method_update:
+    if (nh) return nua_stack_process_update(nua, nh, irq, sip);
+    /*FALLTHROUGH*/
 
-/** Process response to the client request.
- *
- * The response can be generated by the stack (@a sip is NULL) or
- * returned by the remote server.
- *
- * @retval 0 if response event was preliminary
- * @retval 1 if response event was final
- * @retval 2 if response event destroyed the handle, too.
- */
-int nua_client_response(nua_client_request_t *cr,
-			int status,
-			char const *phrase,
-			sip_t const *sip)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
+  case sip_method_bye:
+    if (nh) return nua_stack_process_bye(nua, nh, irq, sip);
 
-  if (cr->cr_restarting)
-    return 0;
+    nta_incoming_treply(irq,
+			481, "Call Does Not Exist",
+			SIPTAG_ALLOW(allow),
+			SIPTAG_SUPPORTED(supported),
+			SIPTAG_USER_AGENT_STR(user_agent),
+			TAG_END());
+    return 481;
 
-  cr->cr_status = status;
+  case sip_method_message:
+    return nua_stack_process_message(nua, nh, irq, sip);
 
-  if (status < 200) {
-    /* Xyzzy */
-  }
-  else if (sip && nua_client_check_restart(cr, status, phrase, sip)) {
-    return 0;
-  }
-  else if (status < 300) {
-    if (cr->cr_terminating) {
-      cr->cr_terminated = 1;
-    }
-    else {
-      if (sip) {
-	if (cr->cr_methods->crm_flags.target_refresh)
-	  nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
-	nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
-      }
+  case sip_method_notify:
+    return nua_stack_process_notify(nua, nh, irq, sip);
 
-      if (du && du->du_cr == cr)
-	du->du_ready = 1;
-    }
-  }
-  else {
-    sip_method_t method = cr->cr_method;
-    int terminated, graceful = 1;
+  case sip_method_subscribe:
+    return nua_stack_process_subscribe(nua, nh, irq, sip);
 
-    if (status < 700)
-      terminated = sip_response_terminates_dialog(status, method, &graceful);
-    else
-      /* XXX - terminate usage by all internal error responses */
-      terminated = 0, graceful = 1;
+  case sip_method_register:
+    return nua_stack_process_register(nua, nh, irq, sip);
 
-    if (terminated < 0)
-      cr->cr_terminated = terminated;      
-    else if (cr->cr_terminating)
-      cr->cr_terminated = 1;
-    else if (terminated && graceful)
-      cr->cr_graceful = graceful;
-    else if (terminated)
-      cr->cr_terminated = 1;
-  }
-  
-  if (status < 200) {
-    if (cr->cr_methods->crm_preliminary)
-      cr->cr_methods->crm_preliminary(cr, status, phrase, sip);
-    else
-      nua_base_client_response(cr, status, phrase, sip, NULL);
-    return 0;
-  }  
+  case sip_method_options:
+    return nua_stack_process_options(nua, nh, irq, sip);
 
-  if (cr->cr_methods->crm_recv)
-    return cr->cr_methods->crm_recv(cr, status, phrase, sip);
-  else
-    return nua_base_client_response(cr, status, phrase, sip, NULL);
-}
+  case sip_method_refer:
+    return nua_stack_process_refer(nua, nh, irq, sip);
 
-/** Check if request should be restarted.
- *
- * @retval 1 if restarted or waring for restart
- * @retval 0 otherwise
- */
-int nua_client_check_restart(nua_client_request_t *cr,
-			     int status,
-			     char const *phrase,
-			     sip_t const *sip)
-{
-  nua_handle_t *nh = cr->cr_owner;
+  case sip_method_publish:
+    return nua_stack_process_publish(nua, nh, irq, sip);
 
-  assert(cr && status >= 200 && phrase && sip);
+  case sip_method_ack:
+  case sip_method_cancel:
+    SU_DEBUG_1(("nua(%p): strange %s from <" URL_PRINT_FORMAT ">\n", nh,
+		sip->sip_request->rq_method_name,
+		URL_PRINT_ARGS(sip->sip_from->a_url)));
+    /* Send nua_i_error ? */
+    return 481;
 
-  if (cr->cr_retry_count >= NH_PGET(nh, retry_count))
-    return 0;
+  case sip_method_unknown:
+    return nua_stack_process_method(nua, nh, irq, sip);
 
-  if (cr->cr_methods->crm_check_restart)
-    return cr->cr_methods->crm_check_restart(cr, status, phrase, sip);
-  else
-    return nua_base_client_check_restart(cr, status, phrase, sip);
+  default:
+    return nua_stack_process_unknown(nua, nh, irq, sip);
+  }
 }
 
-int nua_base_client_check_restart(nua_client_request_t *cr,
-				  int status,
-				  char const *phrase,
-				  sip_t const *sip)
+nua_server_request_t *nua_server_request(nua_t *nua,
+					 nua_handle_t *nh,
+					 nta_incoming_t *irq,
+					 sip_t const *sip,
+					 nua_server_request_t *sr,
+					 size_t size,
+					 nua_server_respond_f *respond,
+					 int create_dialog)
 {
-  nua_handle_t *nh = cr->cr_owner; 
+  int initial = 1, final = 200;
+
+  assert(nua && irq && sip && sr);
 
-  /* XXX - handle Retry-After */
+  initial = nh == NULL || nh == nua->nua_dhandle;
 
-  if (status == 302) {
-    if (!can_redirect(sip->sip_contact, cr->cr_method))
-      return 0;
+  /* INVITE server request is not finalized after 2XX response */
+  if (sip->sip_request->rq_method == sip_method_invite)
+    final = 300;
 
-    if (nua_client_set_target(cr, sip->sip_contact->m_url) >= 0)
-      return nua_client_restart(cr, 100, "Redirected");
+  /* Create handle if request does not fail */
+  if (sr->sr_status >= 300)
+    ;
+  else if (initial) {
+    if (!(nh = nua_stack_incoming_handle(nua, irq, sip, create_dialog)))
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
+  }
+  else if (create_dialog) {
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+    nua_dialog_uas_route(nh, nh->nh_ds, sip, 1);
   }
 
-  if (status == 423) {
-    unsigned my_expires = 0;
-    
-    if (cr->cr_sip->sip_expires)
-      my_expires = cr->cr_sip->sip_expires->ex_delta;
+  if (nh == NULL)
+    nh = nua->nua_dhandle;
 
-    if (sip->sip_min_expires &&
-	sip->sip_min_expires->me_delta > my_expires) {
-      sip_expires_t ex[1];
-      sip_expires_init(ex);
-      ex->ex_delta = sip->sip_min_expires->me_delta;
+  if (sr->sr_status < final) {
+    nua_server_request_t *sr0 = sr;
+
+    if (size < (sizeof *sr))
+      size = sizeof *sr;
 
-      if (sip_add_dup(cr->cr_msg, NULL, (sip_header_t *)ex) < 0)
-	return 0;
+    sr = su_zalloc(nh->nh_home, size);
 
-      return nua_client_restart(cr, 100, "Re-Negotiating Expiration");
+    if (sr) {
+      if ((sr->sr_next = nh->nh_ds->ds_sr))
+	*(sr->sr_prev = sr->sr_next->sr_prev) = sr,
+	  sr->sr_next->sr_prev = &sr->sr_next;
+      else
+	*(sr->sr_prev = &nh->nh_ds->ds_sr) = sr;
+      SR_STATUS(sr, sr0->sr_status, sr0->sr_phrase);
+    }
+    else {
+      sr = sr0;
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
     }
   }
 
-  if (((status == 401 && sip->sip_www_authenticate) ||
-       (status == 407 && sip->sip_proxy_authenticate)) &&
-      nh_challenge(nh, sip) > 0) {
-    nta_outgoing_t *orq;
-    if (auc_has_authorization(&nh->nh_auth)) 
-      return nua_client_restart(cr, 100, "Request Authorized by Cache");
-
-    orq = cr->cr_orq, cr->cr_orq = NULL;
-    cr->cr_challenged = 1;
-    cr->cr_retry_count++;
-    nua_client_report(cr, status, phrase, NULL, orq, NULL);
-    nta_outgoing_destroy(orq);
-
-    return 1;
-  }
+  sr->sr_owner = nh;
+  sr->sr_method = sip->sip_request->rq_method;
+  sr->sr_respond = respond;
+  sr->sr_irq = irq;
+  sr->sr_initial = initial;
 
-  return 0;  /* This was a final response that cannot be restarted. */
-}
+  return sr;
+}		 
 
-/** Restart request.
- *
- * @retval 1 if restarted
- * @retval 0 otherwise
- */
-int nua_client_restart(nua_client_request_t *cr,
-		       int status, char const *phrase)
+void nua_server_request_destroy(nua_server_request_t *sr)
 {
-  nua_handle_t *nh = cr->cr_owner;
-  nta_outgoing_t *orq;
-  int error = -1, terminated, graceful;
-  msg_t *msg;
-  sip_t *sip;
-
-  if (++cr->cr_retry_count > NH_PGET(nh, retry_count))
-    return 0;
+  if (sr->sr_irq)
+    nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL;
 
-  orq = cr->cr_orq, cr->cr_orq = NULL;  assert(orq);
-  terminated = cr->cr_terminated, cr->cr_terminated = 0;
-  graceful = cr->cr_graceful, cr->cr_graceful = 0;
+  sr->sr_msg = NULL;
 
-  msg = msg_copy(cr->cr_msg);
-  sip = sip_object(msg);
+  if (sr->sr_prev) {
+    if ((*sr->sr_prev = sr->sr_next))
+      sr->sr_next->sr_prev = sr->sr_prev;
 
-  if (msg && sip) {
-    cr->cr_restarting = 1;
-    error = nua_client_request_sendmsg(cr, msg, sip);
-    cr->cr_restarting = 0;
-    if (error !=0 && error != -2)
-      msg_destroy(msg);
+    if (sr->sr_owner)
+      su_free(sr->sr_owner->nh_home, sr);
   }
+}
 
+/** Send server event (nua_i_*) to the application. */
+int nua_stack_server_event(nua_t *nua,
+			   nua_server_request_t *sr,
+			   nua_event_t event,
+			   tag_type_t tag, tag_value_t value, ...)
+{
+  nua_handle_t *nh = sr->sr_owner; 
+  int status, final = 0;
 
-  if (error) {
-    cr->cr_graceful = graceful;
-    cr->cr_terminated = terminated;
-    assert(cr->cr_orq == NULL);
-    cr->cr_orq = orq;
-    return 0;
-  }
-
-  nua_client_report(cr, status, phrase, NULL, orq, NULL);
+  if (nh == NULL) nh = nua->nua_dhandle;
 
-  nta_outgoing_destroy(orq);
+  if (sr->sr_status > 100)
+    /* Note that this may change the sr->sr_status */
+    final = sr->sr_respond(sr, NULL);
 
-  return 1;
-}
+  status = sr->sr_status;
 
-int nua_client_set_target(nua_client_request_t *cr, url_t const *target)
-{
-  url_t *new_target, *old_target = cr->cr_target;
+  if (status >= 200)
+    sr->sr_respond = NULL;
+  
+  if (status < 300 || !sr->sr_initial) {
+    ta_list ta;
+    msg_t *request;
+
+    ta_start(ta, tag, value);
+
+    assert(sr->sr_owner);
+    request = nta_incoming_getrequest(sr->sr_irq);
+    nua_stack_event(nua, sr->sr_owner, request, event, 
+		    sr->sr_status, sr->sr_phrase, 
+		    ta_tags(ta));
+    ta_end(ta);
+
+    if (final)
+      nua_server_request_destroy(sr);
+    else if (sr->sr_status < 200)
+      sr->sr_msg = request;
+  }
+  else {
+    nh = sr->sr_owner;
 
-  if (!target || target == old_target)
-    return 0;
+    nua_server_request_destroy(sr);
 
-  new_target = url_hdup(cr->cr_owner->nh_home, (url_t *)target);
-  if (!new_target)
-    return -1;
-  cr->cr_target = new_target;
-  if (old_target)
-    su_free(cr->cr_owner->nh_home, old_target);
+    if (nh && nh != nua->nua_dhandle)
+      nh_destroy(nua, nh);
+  }
 
   return 0;
 }
 
-/**@internal
- * Relay response event to the application.
- *
- * @todo 
- * If handle has already been marked as destroyed by nua_handle_destroy(),
- * release the handle with nh_destroy().
- *
- * @retval 0 if event was preliminary
- * @retval 1 if event was final
- * @retval 2 if event destroyed the handle, too.
- */
-int nua_base_client_tresponse(nua_client_request_t *cr,
-			      int status, char const *phrase,
-			      sip_t const *sip,
-			      tag_type_t tag, tag_value_t value, ...)
+/** Respond to a request. */
+int nua_server_respond(nua_server_request_t *sr,
+		       int status, char const *phrase,
+		       tag_type_t tag, tag_value_t value, ...)
 {
   ta_list ta;
-  int retval;
+  int final;
 
-  if (cr->cr_event == nua_r_destroy)
-    return nua_base_client_response(cr, status, phrase, sip, NULL);
+  assert(sr && sr->sr_respond);
+  SR_STATUS(sr, status, phrase);
 
   ta_start(ta, tag, value);
-  retval = nua_base_client_response(cr, status, phrase, sip, ta_args(ta));
+  final = sr->sr_respond(sr, ta_args(ta));
   ta_end(ta);
 
-  return retval;
-}
-
-/**@internal
- * Relay response event to the application.
- *
- * @todo 
- * If handle has already been marked as destroyed by nua_handle_destroy(),
- * release the handle with nh_destroy().
- *
- * @retval 0 if event was preliminary
- * @retval 1 if event was final
- * @retval 2 if event destroyed the handle, too.
- */
-int nua_base_client_response(nua_client_request_t *cr,
-			     int status, char const *phrase,
-			     sip_t const *sip,
-			     tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  sip_method_t method = cr->cr_method;
-
-  cr->cr_reporting = 1;
-
-  if (status >= 200 && status < 300)
-    nh_challenge(nh, sip);  /* Collect nextnonce */
-
-  nua_client_report(cr, status, phrase, sip, cr->cr_orq, tags);
-
-  if (status < 200 ||
-      /* Un-ACKed 2XX response to INVITE */
-      (cr->cr_method == sip_method_invite && status < 300 && cr->cr_orq)) {
-    cr->cr_reporting = 0;
-    return 1;
+  if (final) {
+    nua_server_request_destroy(sr);    
+    return final;
   }
 
-  nua_client_request_remove(cr);
-
-  if (cr->cr_orq)
-    nta_outgoing_destroy(cr->cr_orq), cr->cr_orq = NULL;
-
-  if (cr->cr_usage) {
-    nua_dialog_usage_t *du = cr->cr_usage;
-
-    if (cr->cr_terminated < 0)
-      /* XXX - dialog has been terminated */;
+  if (sr->sr_status >= 200)
+    sr->sr_respond = NULL;
 
-    if (cr->cr_terminated ||
-	(!du->du_ready && status >= 300 && nua_client_is_bound(cr))) {
-      /* Usage has been destroyed */
-      nua_dialog_usage_remove(nh, nh->nh_ds, du);
-    }
-    else if (cr->cr_graceful) {
-      /* Terminate usage gracefully */
-      nua_dialog_usage_shutdown(nh, nh->nh_ds, du); 
-    }
-  }
+  return 0;
+}
 
-  cr->cr_reporting = 0;
+msg_t *nua_server_response(nua_server_request_t *sr,
+			   int status, char const *phrase,
+			   tag_type_t tag, tag_value_t value, ...)
+{
+  msg_t *msg;
+  ta_list(ta);
 
-  if (nua_client_is_queued(cr))
-    return 1;
+  assert(sr && sr->sr_owner && sr->sr_owner->nh_nua);
 
-  if (!nua_client_is_bound(cr))
-    nua_client_request_destroy(cr);
+  ta_start(ta, tag, value);
 
-  if (method != sip_method_cancel)
-    return nua_client_init_requests(nh->nh_ds->ds_cr, cr,
-				    method == sip_method_invite);
+  msg = nh_make_response(sr->sr_owner->nh_nua, sr->sr_owner, sr->sr_irq,
+			 sr->sr_status, sr->sr_phrase,
+			 ta_tags(ta));
+  
+  ta_end(ta);
 
-  return 1;
+  return msg;
 }
 
-/** Send event, zap transaction but leave cr in list */
-int nua_client_report(nua_client_request_t *cr,
-		      int status, char const *phrase,
-		      sip_t const *sip,
-		      nta_outgoing_t *orq,
-		      tagi_t const *tags)
+int nua_default_respond(nua_server_request_t *sr,
+			tagi_t const *tags)
 {
-  nua_handle_t *nh;
+  msg_t *m;
 
-  if (cr->cr_event == nua_r_destroy)
-    return 1;
+  assert(sr && sr->sr_owner && sr->sr_owner->nh_nua);
 
-  if (cr->cr_methods->crm_report)
-    return cr->cr_methods->crm_report(cr, status, phrase, sip, orq, tags);
+  m = nh_make_response(sr->sr_owner->nh_nua, sr->sr_owner, 
+		       sr->sr_irq,
+		       sr->sr_status, sr->sr_phrase,
+		       TAG_NEXT(tags));
 
-  nh = cr->cr_owner;
+  if (m) {
+    if (nta_incoming_mreply(sr->sr_irq, m) < 0)
+      SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);      
+  }
   
-  nua_stack_event(nh->nh_nua, nh, 
-		  nta_outgoing_getresponse(orq),
-		  cr->cr_event,
-		  status, phrase,
-		  tags);
-  return 1;
-}
-
-int nua_client_treport(nua_client_request_t *cr,
-		       int status, char const *phrase,
-		       sip_t const *sip,
-		       nta_outgoing_t *orq,
-		       tag_type_t tag, tag_value_t value, ...)
-{
-  int retval;
-  ta_list ta;
-  ta_start(ta, tag, value);
-  retval = nua_client_report(cr, status, phrase, sip, orq, ta_args(ta));
-  ta_end(ta);
-  return retval;
+  return sr->sr_status >= 200 ? sr->sr_status : 0;
 }
 
-int nua_client_init_requests(nua_client_request_t *cr,
-			     void const *cr0,
-			     int invite)
+/** Respond to an request with given status. 
+ *
+ * When nua protocol engine receives an incoming SIP request, it can either
+ * respond to the request automatically or let it up to application to
+ * respond to the request. The automatic answer is sent if the request fails
+ * because of method, SIP extension or, in some times, MIME content
+ * negotiation fails.
+ *
+ * When responding to an incoming INVITE request, the nua_respond() can be
+ * called without NUTAG_WITH() (or NUTAG_WITH_CURRENT() or
+ * NUTAG_WITH_SAVED()). Otherwise, NUTAG_WITH() will contain an indication
+ * of the request being responded.
+ *
+ * In order to simplify the simple applications, most requests are responded
+ * automatically. The set of requests always responded by the stack include
+ * BYE, CANCEL and NOTIFY. The application can add methods that it likes to
+ * handle by itself with NUTAG_APPL_METHOD(). The default set of
+ * NUTAG_APPL_METHOD() includes INVITE, PUBLISH, REGISTER and SUBSCRIBE. 
+ * Note that unless the method is also included in the set of allowed
+ * methods with NUTAG_ALLOW(), the stack will respond to the incoming
+ * methods with <i>405 Not Allowed</i>.
+ *
+ * Note that certain methods are rejected outside a SIP session (created
+ * with INVITE transaction). They include BYE, UPDATE, PRACK and INFO. Also
+ * the auxiliary methods ACK and CANCEL are rejected by stack if there is no
+ * ongoing INVITE transaction corresponding to them.
+ *
+ * @param nh              Pointer to operation handle
+ * @param status          SIP response status (see RFCs of SIP)
+ * @param phrase          free text (default response phrase used if NULL)
+ * @param tag, value, ... List of tagged parameters
+ *
+ * @return 
+ *    nothing
+ *
+ * @par Related Tags:
+ *    NUTAG_WITH(), NUTAG_WITH_CURRENT(), NUTAG_WITH_SAVED() \n
+ *    NUTAG_EARLY_ANSWER() \n
+ *    SOATAG_ADDRESS() \n
+ *    SOATAG_AF() \n
+ *    SOATAG_HOLD() \n
+ *    Tags in <sip_tag.h>.
+ *
+ * @par Events:
+ *    #nua_i_state \n
+ *    #nua_i_media_error \n
+ *    #nua_i_error \n
+ *    #nua_i_active \n
+ *    #nua_i_terminated \n
+ *
+ * @sa #nua_i_invite, #nua_i_register, #nua_i_subscribe, #nua_i_publish
+ */
+void
+nua_stack_respond(nua_t *nua, nua_handle_t *nh,
+		  int status, char const *phrase, tagi_t const *tags)
 {
-  if (cr0 == cr)		/* already initialized! */
-    return 1;
-  
-  for (; cr; cr = cr->cr_next) {
-    if (cr->cr_method == sip_method_cancel)
-      continue;
-    
-    if (invite 
-	? cr->cr_method == sip_method_invite
-	: cr->cr_method != sip_method_invite)
-      break;
-  }
+  nua_server_request_t *sr;
+  tagi_t const *t;
+  msg_t const *request = NULL;
 
-  if (cr) 
-    nua_client_init_request(cr);
+  t = tl_find_last(tags, nutag_with);
 
-  return 1;
-}
+  if (t)
+    request = (msg_t const *)t->t_value;
 
-nua_client_request_t *
-nua_client_request_pending(nua_client_request_t const *cr)
-{
-  for (;cr;cr = cr->cr_next)
-    if (cr->cr_orq)
-      return (nua_client_request_t *)cr;
+  for (sr = nh->nh_ds->ds_sr; sr; sr = sr->sr_next) {
+    if (request && sr->sr_msg == request)
+      break;
+    /* nua_respond() to INVITE can be used without NUTAG_WITH() */
+    if (!t && sr->sr_method == sip_method_invite && sr->sr_respond)
+      break;
+  }
+  
+  if (sr && sr->sr_respond) {
+    int final;
+    SR_STATUS(sr, status, phrase);
+    final = sr->sr_respond(sr, tags);
+    if (final)
+      nua_server_request_destroy(sr);    
+    else if (sr->sr_status >= 200)
+      sr->sr_respond = NULL;
+    return;
+  }
+  else if (sr) {
+    nua_stack_event(nua, nh, NULL, nua_i_error,
+		    500, "Already Sent Final Response", TAG_END());
+    return;
+  }
 
-  return NULL;
+  nua_stack_event(nua, nh, NULL, nua_i_error,
+		  500, "Responding to a Non-Existing Request", TAG_END());
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h	Sat Feb 17 01:25:21 2007
@@ -103,32 +103,6 @@
   TAG_IF((include) && (soa) && soa_is_remote_chat_active(soa) >= 0,	\
 	 SOATAG_ACTIVE_CHAT(soa_is_remote_chat_active(soa)))
 
-#if HAVE_NUA_HANDLE_DEBUG
-
-#define nua_handle_ref(nh) nua_handle_ref_by((nh), __func__)
-#define nua_handle_unref(nh) nua_handle_unref_by((nh), __func__)
-
-static inline nua_handle_t *nua_handle_ref_by(nua_handle_t *nh,
-					      char const *by)
-{
-  if (nh)
-    SU_DEBUG_0(("nua_handle_ref(%p) => "MOD_ZU" by %s\n", nh, 
-		su_home_refcount((su_home_t *)nh) + 1,
-		by));
-  return (nua_handle_t *)su_home_ref((su_home_t *)nh);
-}
-
-static inline int nua_handle_unref_by(nua_handle_t *nh, char const *by)
-{
-  if (nh)
-    SU_DEBUG_0(("nua_handle_unref(%p) => "MOD_ZU" by %s\n", nh, 
-		su_home_refcount((su_home_t *)nh) - 1,
-		by));
-  return su_home_unref((su_home_t *)nh);
-}
-
-#endif
-
 /** NUA handle. 
  *
  */
@@ -139,8 +113,7 @@
   nua_handle_t  **nh_prev;
 
   nua_t        	 *nh_nua;	/**< Pointer to NUA object  */
-  void           *nh_valid;	/**< Cookie */
-#define nua_valid_handle_cookie ((void *)(intptr_t)nua_handle)
+  void           *nh_valid;
   nua_hmagic_t 	 *nh_magic;	/**< Application context */
 
   tagi_t         *nh_tags;	/**< Initial tags */
@@ -181,8 +154,7 @@
   nea_server_t   *nh_notifier;	/**< SIP notifier */
 };
 
-#define NH_IS_VALID(nh) \
-  ((nh) && (nh)->nh_valid == nua_valid_handle_cookie)
+#define NH_IS_VALID(nh) ((nh) && (nh)->nh_valid)
 
 #define NH_STATUS(nh) \
   (nh)->nh_status, \
@@ -313,23 +285,20 @@
   nua_stack_method;
 
 #define UA_EVENT1(e, statusphrase) \
-  nua_stack_event(nua, nh, NULL, e, statusphrase, NULL)
+  nua_stack_event(nua, nh, NULL, e, statusphrase, TAG_END())
 
 #define UA_EVENT2(e, status, phrase)			\
-  nua_stack_event(nua, nh, NULL, e, status, phrase, NULL)
+  nua_stack_event(nua, nh, NULL, e, status, phrase, TAG_END())
 
 #define UA_EVENT3(e, status, phrase, tag)			\
-  nua_stack_event(nua, nh, NULL, e, status, phrase, tag, NULL)
-
-int nua_stack_tevent(nua_t *nua, nua_handle_t *nh, msg_t *msg,
-		     nua_event_t event, int status, char const *phrase,
-		     tag_type_t tag, tag_value_t value, ...);
+  nua_stack_event(nua, nh, NULL, e, status, phrase, tag, TAG_END())
 
 int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg,
 		    nua_event_t event, int status, char const *phrase,
-		    tagi_t const *tags);
+		    tag_type_t tag, tag_value_t value, ...);
 
-nua_handle_t *nh_create_handle(nua_t *nua, nua_hmagic_t *hmagic, tagi_t *tags);
+nua_handle_t *nh_create_handle(nua_t *nua, nua_hmagic_t *hmagic,
+			       tagi_t *tags);
 
 nua_handle_t *nua_stack_incoming_handle(nua_t *nua,
 					nta_incoming_t *irq,
@@ -380,8 +349,48 @@
 			      nta_incoming_t *irq,
 			      sip_t const *sip);
 
+int nua_stack_process_response(nua_handle_t *nh,
+			       nua_client_request_t *cr,
+			       nta_outgoing_t *orq,
+			       sip_t const *sip,
+			       tag_type_t tag, tag_value_t value, ...);
+
 int nua_stack_launch_network_change_detector(nua_t *nua);
 
+msg_t *nua_creq_msg(nua_t *nua, nua_handle_t *nh,
+		    nua_client_request_t *cr,
+		    int restart, 
+		    sip_method_t method, char const *name,
+		    tag_type_t tag, tag_value_t value, ...);
+
+int nua_tagis_have_contact_tag(tagi_t const *t);
+
+int nua_creq_check_restart(nua_handle_t *nh,
+			   nua_client_request_t *cr,
+			   nta_outgoing_t *orq,
+			   sip_t const *sip,
+			   nua_creq_restart_f *f);
+
+int nua_creq_restart_with(nua_handle_t *nh,
+			  nua_client_request_t *cr,
+			  nta_outgoing_t *orq,
+			  int status, char const *phrase,
+			  nua_creq_restart_f *f, 
+			  tag_type_t tag, tag_value_t value, ...);
+
+int nua_creq_save_restart(nua_handle_t *nh,
+			  nua_client_request_t *cr,
+			  nta_outgoing_t *orq,
+			  int status, char const *phrase,
+			  nua_creq_restart_f *f);
+
+int nua_creq_restart(nua_handle_t *nh,
+		     nua_client_request_t *cr,
+		     nta_response_f *cb,
+		     tagi_t *tags);
+
+void nua_creq_deinit(nua_client_request_t *cr, nta_outgoing_t *orq);
+
 sip_contact_t const *nua_stack_get_contact(nua_registration_t const *nr);
 
 int nua_registration_add_contact_to_request(nua_handle_t *nh,
@@ -396,6 +405,51 @@
 					     sip_record_route_t const *,
 					     sip_contact_t const *remote);
 
+msg_t *nh_make_response(nua_t *nua, nua_handle_t *nh, 
+			nta_incoming_t *irq,
+			int status, char const *phrase,
+			tag_type_t tag, tag_value_t value, ...);
+
+
+typedef int nua_stack_process_request_t(nua_t *nua,
+					nua_handle_t *nh,
+					nta_incoming_t *irq,
+					sip_t const *sip);
+
+nua_stack_process_request_t nua_stack_process_invite;
+nua_stack_process_request_t nua_stack_process_info;
+nua_stack_process_request_t nua_stack_process_update;
+nua_stack_process_request_t nua_stack_process_bye;
+nua_stack_process_request_t nua_stack_process_message;
+nua_stack_process_request_t nua_stack_process_options;
+nua_stack_process_request_t nua_stack_process_publish;
+nua_stack_process_request_t nua_stack_process_subscribe;
+nua_stack_process_request_t nua_stack_process_notify;
+nua_stack_process_request_t nua_stack_process_refer;
+nua_stack_process_request_t nua_stack_process_unknown;
+nua_stack_process_request_t nua_stack_process_register;
+nua_stack_process_request_t nua_stack_process_method;
+
+nua_client_request_t
+  *nua_client_request_pending(nua_client_request_t const *),
+  *nua_client_request_restarting(nua_client_request_t const *),
+  *nua_client_request_by_orq(nua_client_request_t const *cr,
+			     nta_outgoing_t const *orq);
+
+nua_server_request_t *nua_server_request(nua_t *nua,
+					 nua_handle_t *nh,
+					 nta_incoming_t *irq,
+					 sip_t const *sip,
+					 nua_server_request_t *sr,
+					 size_t size,
+					 nua_server_respond_f *respond,
+					 int create_dialog);
+
+int nua_stack_server_event(nua_t *nua,
+			   nua_server_request_t *sr,
+			   nua_event_t event,
+			   tag_type_t tag, tag_value_t value, ...);
+
 /* ---------------------------------------------------------------------- */
 
 #ifndef SDP_MIME_TYPE
@@ -412,6 +466,15 @@
 #define NUTAG_ADD_CONTACT(v) _nutag_add_contact, tag_bool_v(v)
 extern tag_typedef_t _nutag_add_contact;
 
+#define NUTAG_ADD_CONTACT_REF(v) _nutag_add_contact_ref, tag_bool_vr(&v)
+extern tag_typedef_t _nutag_add_contact_ref;
+
+#define NUTAG_COPY(v) _nutag_copy, tag_bool_v(v)
+extern tag_typedef_t _nutag_copy;
+
+#define NUTAG_COPY_REF(v) _nutag_copy_ref, tag_bool_vr(&v)
+extern tag_typedef_t _nutag_copy_ref;
+
 /* ---------------------------------------------------------------------- */
 
 typedef unsigned longlong ull;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c	Sat Feb 17 01:25:21 2007
@@ -47,10 +47,12 @@
 #include <sofia-sip/string0.h>
 #include <sofia-sip/sip_protos.h>
 #include <sofia-sip/sip_status.h>
-#include <sofia-sip/sip_extra.h>
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/su_uniqueid.h>
 
+#define NTA_LEG_MAGIC_T      struct nua_handle_s
+#define NTA_OUTGOING_MAGIC_T struct nua_handle_s
+
 #include "nua_stack.h"
 
 /* ---------------------------------------------------------------------- */
@@ -58,10 +60,9 @@
 
 struct event_usage
 {
-  enum nua_substate eu_substate;	/**< Subscription state */
+  enum nua_substate  eu_substate;	/**< Subscription state */
   sip_time_t eu_expires;	        /**< Proposed expiration time */
   unsigned eu_notified;		        /**< Number of NOTIFYs received */
-  unsigned eu_refer:1;		        /**< Implied subscription by refer */
   unsigned eu_final_wait:1;	        /**< Waiting for final NOTIFY */
   unsigned eu_no_id:1;		        /**< Do not use "id" (even if we have one) */
 };
@@ -104,7 +105,6 @@
 {
   ds->ds_has_events++;
   ds->ds_has_subscribes++;
-
   return 0;
 }
 
@@ -167,128 +167,134 @@
  * @sa NUTAG_SUBSTATE(), @RFC3265
  */
 
-static int nua_subscribe_client_init(nua_client_request_t *cr, 
-				     msg_t *, sip_t *,
-				     tagi_t const *tags);
-static int nua_subscribe_client_request(nua_client_request_t *cr,
-					msg_t *, sip_t *,
-					tagi_t const *tags);
-static int nua_subscribe_client_response(nua_client_request_t *cr,
-					 int status, char const *phrase,
+static int process_response_to_subscribe(nua_handle_t *nh,
+					 nta_outgoing_t *orq,
 					 sip_t const *sip);
 
-static nua_client_methods_t const nua_subscribe_client_methods = {
-  SIP_METHOD_SUBSCRIBE,
-  0,
-  { 
-    /* create_dialog */ 1,
-    /* in_dialog */ 1,
-    /* target refresh */ 1
-  },
-  NULL,
-  nua_subscribe_client_init,
-  nua_subscribe_client_request,
-  /* nua_subscribe_client_check_restart */ NULL,
-  nua_subscribe_client_response
-};
 
 int
 nua_stack_subscribe(nua_t *nua, nua_handle_t *nh, nua_event_t e,
 		    tagi_t const *tags)
 {
-  return nua_client_create(nh, e, &nua_subscribe_client_methods, tags);
-}
-
-static int nua_subscribe_client_init(nua_client_request_t *cr,
-				     msg_t *msg, sip_t *sip,
-				     tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du;
-  sip_event_t *o = sip->sip_event;
-
-  du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, o);
-
-  if (du == NULL && o == NULL)
-    du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, NONE);
-
-  if (du) {
-    if (du->du_event && o == NULL)
-      /* Add Event header */
-      sip_add_dup(msg, sip, (sip_header_t *)du->du_event);
-  }
-  else if (cr->cr_event == nua_r_subscribe) {	
-    /* Create dialog usage */
-    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, o);
-    /* Note that we allow SUBSCRIBE without event */
-  }
-
-  cr->cr_usage = du;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  nua_dialog_usage_t *du = NULL;
+  struct event_usage *eu;
+  msg_t *msg;
+  sip_t *sip;
 
-  return 0;
-}
+  if (nua_stack_set_handle_special(nh, nh_has_subscribe, nua_r_subscribe) < 0)
+    return UA_EVENT3(e, 500, "Invalid handle for SUBSCRIBE", 
+		     NUTAG_SUBSTATE(nua_substate_terminated));
+  else if (cr->cr_orq)
+    return UA_EVENT2(e, 900, "Request already in progress");
+
+  /* Initialize allow and auth */
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  msg = nua_creq_msg(nua, nh, cr, 0,
+		     SIP_METHOD_SUBSCRIBE,
+		     NUTAG_USE_DIALOG(1),
+		     NUTAG_ADD_CONTACT(1),
+		     TAG_NEXT(tags));
+  sip = sip_object(msg);
 
-static int nua_subscribe_client_request(nua_client_request_t *cr,
-					msg_t *msg, sip_t *sip,
-					tagi_t const *tags)
-{
-  nua_dialog_usage_t *du = cr->cr_usage; 
-  sip_time_t expires = 0;
+  if (sip) {
+    sip_event_t *o = sip->sip_event;
 
-  if (cr->cr_event != nua_r_subscribe ||
-      (du && du->du_shutdown) ||
-      (sip->sip_expires && sip->sip_expires->ex_delta == 0))
-    cr->cr_terminating = 1;
+    du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, o);
 
-  if (du) {
-    struct event_usage *eu = nua_dialog_usage_private(du);
-    sip_event_t *o = sip->sip_event;
+    if (du == NULL && o == NULL)
+      du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, NONE);
 
-    if (nua_client_bind(cr, du) < 0)
-      return -1;
+    eu = nua_dialog_usage_private(du);
 
-    if (eu->eu_no_id && o && o->o_id) {
-      /* Notifier does not handle id properly, remove it */
-      msg_header_remove_param(o->o_common, "id");
+    if (du && du->du_event && (o == NULL || (o->o_id && eu->eu_no_id))) {
+      if (eu->eu_no_id)		/* No id (XXX - nor other parameters) */
+	sip_add_make(msg, sip, sip_event_class, du->du_event->o_type);
+      else
+	sip_add_dup(msg, sip, (sip_header_t *)du->du_event);
     }
 
-#if 0
-    if (cr->cr_terminating) {
-      /* Already terminated subscription? */
+    if (e == nua_r_subscribe) {	
+      if (du == NULL)		/* Create dialog usage */
+	/* We allow here SUBSCRIBE without event */
+	du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, o);
+    }
+    else if (du) { /* Unsubscribe */
+      /* Embryonic subscription is just a placeholder */
       if (eu->eu_substate == nua_substate_terminated ||
 	  eu->eu_substate == nua_substate_embryonic) {
-	return nua_client_return(cr, SIP_200_OK, msg);
+	nua_dialog_usage_remove(nh, nh->nh_ds, du);
+	msg_destroy(msg);
+	return UA_EVENT3(e, SIP_200_OK, 
+			 NUTAG_SUBSTATE(nua_substate_terminated),
+			 TAG_END());
       }
     }
-#endif
+  }
 
-    nua_dialog_usage_reset_refresh(du); /* during SUBSCRIBE transaction */
-    
-    if (cr->cr_terminating)
-      expires = eu->eu_expires = 0;
-    else if (sip->sip_expires)
-      /* Use value specified by application or negotiated with Min-Expires */
-      expires = eu->eu_expires = sip->sip_expires->ex_delta;
+  /* Store message template with supported features (eventlist) */
+  if (du && sip) {
+    if (du->du_msg)
+      msg_destroy(du->du_msg);
+    du->du_msg = msg_ref_create(cr->cr_msg);
+  }
+
+  if (du)
+    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				      process_response_to_subscribe, nh, NULL,
+				      msg,
+				      TAG_IF(e != nua_r_subscribe,
+					     SIPTAG_EXPIRES_STR("0")),
+				      SIPTAG_END(), TAG_NEXT(tags));
+
+  eu = nua_dialog_usage_private(du);
+
+  if (!cr->cr_orq) {
+    int substate = nua_substate_terminated;
+
+    if (du == NULL)
+      ;
+    else if (du->du_ready)
+      substate = eu->eu_substate; /* No change in subscription state  */
     else
+      nua_dialog_usage_remove(nh, nh->nh_ds, du);
+
+    msg_destroy(msg);
+
+    return UA_EVENT3(e, NUA_INTERNAL_ERROR, 
+		     NUTAG_SUBSTATE(substate), TAG_END());
+  }
+
+  nua_dialog_usage_reset_refresh(du); /* during SUBSCRIBE transaction */
+  du->du_terminating = e != nua_r_subscribe; /* Unsubscribe or destroy */
+
+  if (du->du_terminating)
+    eu->eu_expires = 0;
+  else if (sip->sip_expires)
+    eu->eu_expires = sip->sip_expires->ex_delta;
+  else
     /* We just use common default value, but the default is actually
        package-specific according to the RFC 3265 section 4.4.4:
        [Event] packages MUST also define a
        default "Expires" value to be used if none is specified. */
-      expires = eu->eu_expires = 3600;
+    eu->eu_expires = 3600;
 
-    eu->eu_final_wait = 0;
+  eu->eu_final_wait = 0;
+    
+  if (sip->sip_expires && sip->sip_expires->ex_delta == 0)
+    du->du_terminating = 1;
 
-    if (eu->eu_substate == nua_substate_terminated)
-      eu->eu_substate = nua_substate_embryonic;
-  }
+  if (eu->eu_substate == nua_substate_terminated)
+    eu->eu_substate = nua_substate_embryonic;
 
-  if (!sip->sip_expires || sip->sip_expires->ex_delta != expires) {
-    sip_expires_t ex[1];
-    sip_expires_init(ex)->ex_delta = expires;
-    sip_add_dup(msg, sip, (sip_header_t *)ex);
-  }
+  cr->cr_usage = du;
+  return cr->cr_event = e;
+}
 
-  return nua_base_client_request(cr, msg, sip, tags);
+static void restart_subscribe(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_creq_restart(nh, nh->nh_ds->ds_cr, process_response_to_subscribe, tags);
 }
 
 /** @NUA_EVENT nua_r_subscribe
@@ -336,41 +342,51 @@
  * @END_NUA_EVENT
  */
 
-static int nua_subscribe_client_response(nua_client_request_t *cr,
-					 int status, char const *phrase,
+static int process_response_to_subscribe(nua_handle_t *nh,
+					 nta_outgoing_t *orq,
 					 sip_t const *sip)
 {
-  nua_handle_t *nh = cr->cr_owner;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
   nua_dialog_usage_t *du = cr->cr_usage; 
   struct event_usage *eu = nua_dialog_usage_private(du);
-  enum nua_substate substate;
-
-  if (eu == NULL || cr->cr_terminated)
-    substate = nua_substate_terminated;
-  else if (status >= 300)
-    substate = eu->eu_substate;
-  else {
+  int status = sip ? sip->sip_status->st_status : 408;
+  int gracefully = 0;
+  int substate = nua_substate_embryonic;
+
+  assert(du); assert(du->du_class == nua_subscribe_usage);
+
+  if (status < 200)
+    ;
+  else if (du == NULL) {
+    /* NOTIFY already removed du */
+  }
+  /* We have not received NOTIFY. */
+  else if (status < 300) {
     int win_messenger_enable = NH_PGET(nh, win_messenger_enable);
     sip_time_t delta, now = sip_now();
 
     du->du_ready = 1;
-
-    if (eu->eu_substate != nua_substate_terminated)
-      /* If there is no @Expires header, 
+    substate = eu->eu_substate;
+    
+    if (du->du_terminating)
+      delta = 0;
+    else
+      /* If there is no expires header,
 	 use default value stored in eu_expires */
       delta = sip_contact_expires(NULL, sip->sip_expires, sip->sip_date, 
 				  eu->eu_expires, now);
-    else
-      delta = 0;
 
     if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) {
       /* Notify from messanger does not match with dialog tag */ 
       nh->nh_ds->ds_remote_tag = su_strdup(nh->nh_home, "");
     }
 
+    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+
     if (delta > 0) {
       nua_dialog_usage_set_refresh(du, delta);
-    } 
+    }
     else if (!eu->eu_notified) {
       /* This is a fetch: subscription was really terminated
 	 but we wait 32 seconds for NOTIFY. */
@@ -380,26 +396,51 @@
 	delta = 4 * 60; 	/* Wait 4 minutes for NOTIFY from Messenger */
 
       eu->eu_final_wait = 1;
-	
-      if (eu->eu_substate == nua_substate_terminated)
-	eu->eu_substate = nua_substate_embryonic;
+
+      /* Do not remove usage in nua_stack_process_response  */
+      cr->cr_usage = NULL;	
 
       nua_dialog_usage_refresh_range(du, delta, delta);
     }
     else {
-      eu->eu_substate = nua_substate_terminated;
+      eu->eu_substate = substate = nua_substate_terminated;
     }
+  }
+  else /* if (status >= 300) */ {
+    int terminated;
+
+    if (nua_creq_check_restart(nh, cr, orq, sip, restart_subscribe))
+      return 0;
+
+    cr->cr_usage = NULL; /* We take care of removing/not removing usage */
 
     substate = eu->eu_substate;
 
-    if (substate == nua_substate_terminated)
-      /* let nua_base_client_tresponse to remove usage */
-      cr->cr_terminated = 1;	
+    if (!sip || !sip->sip_retry_after)
+      gracefully = 1;
+
+    terminated = 
+      sip_response_terminates_dialog(status, sip_method_subscribe, 
+				     &gracefully);
+
+    /* XXX - zap dialog if terminated < 0 ? */
+
+    if (terminated || !du->du_ready || du->du_terminating) {
+      substate = nua_substate_terminated;
+      nua_dialog_usage_remove(nh, nh->nh_ds, du);
+    }
+    else if (gracefully && substate != nua_substate_terminated) 
+      /* Post un-subscribe event */
+      nua_stack_post_signal(nh, nua_r_unsubscribe, 
+			    SIPTAG_EVENT(du->du_event), 
+			    SIPTAG_EXPIRES_STR("0"),
+			    TAG_END());
   }
-  
-  return nua_base_client_tresponse(cr, status, phrase, sip, 
-				   NUTAG_SUBSTATE(substate),
-				   TAG_END());
+
+  nua_stack_process_response(nh, cr, orq, sip, 
+			     TAG_IF(substate >= 0, NUTAG_SUBSTATE(substate)),
+			     TAG_END());
+  return 0;
 }
 
 /** Refresh subscription */
@@ -408,75 +449,120 @@
 					nua_dialog_usage_t *du,
 					sip_time_t now)
 {
-  nua_client_request_t *cr = du->du_cr;
+  nua_t *nua = nh->nh_nua;
+  nua_client_request_t *cr = ds->ds_cr;
   struct event_usage *eu = nua_dialog_usage_private(du);
-  
+  msg_t *msg;
+
   assert(eu);
   
   if (eu->eu_final_wait) {
-    /* Did not receive NOTIFY for fetch */
+    /* Did not receive NOTIFY for fetch... */
     sip_event_t const *o = du->du_event;
     char const *id = o ? o->o_id : NULL;
 
-    SU_DEBUG_3(("nua(%p): event %s%s%s fetch timeouts\n",
-		(void *)nh, o ? o->o_type : "(empty)",
+    SU_DEBUG_3(("nua(%p): fetch event %s%s%s timeouts\n",
+		nh, o ? o->o_type : "(empty)",
 		id ? "; id=" : "", id ? id : ""));
 
-    nua_stack_tevent(nh->nh_nua, nh,  NULL,
-		     nua_i_notify, 408, "Fetch Timeouts without NOTIFY", 
-		     NUTAG_SUBSTATE(nua_substate_terminated),
-		     SIPTAG_EVENT(du->du_event),
-		     TAG_END());
+    nua_stack_event(nh->nh_nua, nh,  NULL,
+		    nua_i_notify, 408, "Fetch Timeouts without NOTIFY", 
+		    NUTAG_SUBSTATE(nua_substate_terminated),
+		    SIPTAG_EVENT(o),
+		    TAG_END());
+
     nua_dialog_usage_remove(nh, ds, du);
 
     return;
   }
 
-  if (cr) {
-    if (nua_client_is_queued(cr) || /* Already refreshing */
-	nua_client_resend_request(cr, 0, NULL) >= 0)
-      return;
-  }
-  else if (eu->eu_refer) {
-    /*
-     * XXX - If we have received a NOTIFY, we should try to terminate
-     * subscription
-     */
-  }
-
-  nua_stack_tevent(nh->nh_nua, nh, NULL,
-		   nua_i_notify, NUA_INTERNAL_ERROR,
-		   NUTAG_SUBSTATE(nua_substate_terminated),
-		   SIPTAG_EVENT(du->du_event),
-		   TAG_END());
+  if (du->du_terminating)	/* No need to refresh. */
+    return;
 
-  nua_dialog_usage_remove(nh, ds, du);
+  if (cr->cr_msg) {
+    /* Already doing something, delay 5..15 seconds? */
+    if (cr->cr_usage != du)
+      nua_dialog_usage_refresh_range(du, 5, 15);
+    return;
+  }
+
+  cr->cr_msg = msg_copy(du->du_msg);
+
+  msg = nua_creq_msg(nua, nh, cr, 1,
+		     SIP_METHOD_SUBSCRIBE,
+		     NUTAG_USE_DIALOG(1),
+		     NUTAG_ADD_CONTACT(1),
+		     /* If dialog is established, remove initial route */
+		     TAG_IF(nua_dialog_is_established(nh->nh_ds),
+			    SIPTAG_ROUTE(NONE)),
+		     TAG_END());
+
+  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				    process_response_to_subscribe, nh, NULL,
+				    msg,
+				    SIPTAG_END(), TAG_NEXT(NULL));
+  if (cr->cr_orq) {
+    cr->cr_usage = du;
+    cr->cr_event = nua_r_subscribe;
+    return;
+  }
+
+  if (du->du_terminating)
+    nua_dialog_usage_remove(nh, nh->nh_ds, du);
+  else   /* Try again later? */
+    nua_dialog_usage_refresh_range(du, 5, 15);
+
+  msg_destroy(msg);
+  UA_EVENT3(nua_r_subscribe, NUA_INTERNAL_ERROR, 
+	    NUTAG_SUBSTATE(eu->eu_substate),
+	    TAG_END());
 }
 
-/** Terminate subscription.
- *
- * @retval >0  shutdown done
- * @retval 0   shutdown in progress
- * @retval <0  try again later
- */
+
+/** Terminate subscription */
 static int nua_subscribe_usage_shutdown(nua_handle_t *nh,
 					nua_dialog_state_t *ds,
 					nua_dialog_usage_t *du)
 {
+  nua_t *nua = nh->nh_nua;
+  nua_client_request_t *cr = ds->ds_cr;
   struct event_usage *eu = nua_dialog_usage_private(du);
-  nua_client_request_t *cr = du->du_cr;
+  msg_t *msg;
 
   assert(eu); (void)eu;
 
-  if (cr) {
-    if (nua_client_is_queued(cr)) /* Subscribing. */
-      return -1;  /* Request in progress */
+  if (du->du_terminating)
+    return 100;			/* ...in progress */
+  
+  if (cr->cr_msg)
+    /* XXX - already doing something else? */
+    return 100;
+
+  cr->cr_msg = msg_copy(du->du_msg);
+
+  msg = nua_creq_msg(nua, nh, cr, 1,
+		     SIP_METHOD_SUBSCRIBE,
+		     NUTAG_USE_DIALOG(1),
+		     NUTAG_ADD_CONTACT(1),
+		     SIPTAG_EXPIRES_STR("0"),
+		     /* If dialog is established, remove initial route */
+		     TAG_IF(nua_dialog_is_established(nh->nh_ds),
+			    SIPTAG_ROUTE(NONE)),
+		     TAG_END());
 
-    if (nua_client_resend_request(cr, 1, NULL) >= 0)
-      return 0;
+  cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				    process_response_to_subscribe, nh, NULL,
+				    msg,
+				    SIPTAG_END(), TAG_NEXT(NULL));
+  if (cr->cr_orq) {
+    cr->cr_usage = du;
+    cr->cr_event = nua_r_destroy;
+    return 100;
   }
-  
+
+  /* Too bad. */
   nua_dialog_usage_remove(nh, ds, du);
+  msg_destroy(msg);
   return 200;
 }
 
@@ -499,183 +585,178 @@
  * @END_NUA_EVENT
  */
 
-int nua_notify_server_init(nua_server_request_t *sr);
-int nua_notify_server_preprocess(nua_server_request_t *sr);
-int nua_notify_server_report(nua_server_request_t *, tagi_t const *);
-
-nua_server_methods_t const nua_notify_server_methods = 
-  {
-    SIP_METHOD_NOTIFY,
-    nua_i_notify,		/* Event */
-    { 
-      1,			/* Do create dialog */
-      0,			/* Not always in-dialog request */
-      1,			/* Target refresh request  */
-      1,			/* Add Contact to response */
-    },
-    nua_notify_server_init,
-    nua_notify_server_preprocess,
-    nua_base_server_params,
-    nua_base_server_respond,
-    nua_notify_server_report,
-  };
-
-
-int nua_notify_server_init(nua_server_request_t *sr)
-{
-  if (!sr->sr_initial) {
-    nua_dialog_state_t *ds = sr->sr_owner->nh_ds;
-
-    /* Check for forked subscription. */
-    if (ds->ds_remote_tag && ds->ds_remote_tag[0] && 
-	str0cmp(ds->ds_remote_tag, sr->sr_request.sip->sip_from->a_tag)) {
-      sip_contact_t const *m = NULL;
-
-      m = nua_stack_get_contact(sr->sr_owner->nh_nua->nua_registrations);
-      
-      if (m) {
-	sip_warning_t w[1];
-	
-	sip_warning_init(w)->w_code = 399;
-	w->w_host = m->m_url->url_host;
-	w->w_port = m->m_url->url_port;
-	w->w_text = "Forking SUBSCRIBEs are not supported";
+/** @internal Process incoming NOTIFY. */
+int nua_stack_process_notify(nua_t *nua,
+			     nua_handle_t *nh,
+			     nta_incoming_t *irq,
+			     sip_t const *sip)
+{
+  nua_dialog_state_t *ds = nh->nh_ds;
+  nua_dialog_usage_t *du;
+  struct event_usage *eu;
+  sip_subscription_state_t *subs = sip ? sip->sip_subscription_state : NULL;
+  sip_subscription_state_t ss0[1];
+  msg_t *response;
+  char expires[32];
+  int retry = -1;
+  char const *what = NULL, *why = NULL;
 
-	sip_add_dup(sr->sr_response.msg, NULL, (sip_header_t*)w);
-      }
+  enter;
 
-      return SR_STATUS(sr, 481, "Subscription Does Not Exist");
+  if (nh == NULL) {
+    nta_incoming_treply(irq, 481, "Subscription Does Not Exist", 
+			TAG_END());
+    return 481;
+  }
+  assert(nh);
+
+  if (/* XXX - support forking of subscriptions?... */
+      ds->ds_remote_tag && ds->ds_remote_tag[0] && 
+      sip && sip->sip_from->a_tag &&
+      strcmp(ds->ds_remote_tag, sip->sip_from->a_tag)) {
+    sip_contact_t const *m = NULL;
+    sip_warning_t *w = NULL, w0[1];
+
+    m = nua_stack_get_contact(nua->nua_registrations);
+    if (m) {
+      w = sip_warning_init(w0);
+      w->w_code = 399;
+      w->w_host = m->m_url->url_host;
+      w->w_port = m->m_url->url_port;
+      w->w_text = "Forking SUBSCRIBEs are not supported";
     }
-  }
-
-  return 0;
-}
 
-int nua_notify_server_preprocess(nua_server_request_t *sr)
-{
-  nua_dialog_state_t *ds = sr->sr_owner->nh_ds;
-  nua_dialog_usage_t *du;
-  struct event_usage *eu;
-  sip_t const *sip = sr->sr_request.sip;
-  sip_event_t *o = sip->sip_event;
-  enum nua_substate substate = nua_substate_terminated;
-  sip_subscription_state_t *subs = sip->sip_subscription_state;
-  char const *what = "", *reason = NULL;
+    nta_incoming_treply(irq, 481, "Subscription Does Not Exist", 
+			SIPTAG_WARNING(w),
+			TAG_END());
+    return 481;
+  }
 
-  du = nua_dialog_usage_get(ds, nua_subscribe_usage, o);
-  sr->sr_usage = du;
+  du = nua_dialog_usage_get(nh->nh_ds, nua_subscribe_usage, sip->sip_event);
 
   if (du == NULL) {
-    if (!sip_is_allowed(NH_PGET(sr->sr_owner, appl_method), SIP_METHOD_NOTIFY))
-      return SR_STATUS(sr, 481, "Subscription Does Not Exist");
-    /* Let application to handle unsolicited NOTIFY */
-    return 0;
+    nta_incoming_treply(irq, 481, "Subscription Does Not Exist", TAG_END());
+    return 481;
   }
-  
+
   eu = nua_dialog_usage_private(du); assert(eu);
   eu->eu_notified++;
-  if (!o->o_id) 
+
+  if (!sip->sip_event->o_id) {
     eu->eu_no_id = 1;
+  }
 
   if (subs == NULL) {
-    /* Compatibility */
-    unsigned long delta = eu->eu_expires;
-    if (sip->sip_expires) 
-      delta = sip->sip_expires->ex_delta;
+    /* Do some compatibility stuff here */
+    unsigned long delta;
+
+    sip_subscription_state_init(subs = ss0);
+
+    delta = sip->sip_expires ? sip->sip_expires->ex_delta : eu->eu_expires;
 
     if (delta == 0)
-      substate = nua_substate_terminated, what = "terminated";
+      subs->ss_substate = "terminated";
     else
-      substate = nua_substate_active, what = "active";
-  }
-  else if (strcasecmp(subs->ss_substate, what = "terminated") == 0) {
-    substate = nua_substate_terminated;
-    reason = subs->ss_reason;
+      subs->ss_substate = "active";
 
-    if (str0casecmp(reason, "deactivated") == 0 ||
-	str0casecmp(reason, "probation") == 0) 
-      substate = nua_substate_embryonic;
-  }
-  else if (strcasecmp(subs->ss_substate, what = "pending") == 0) {
-    substate = nua_substate_pending;
-  }
-  else /* if (strcasecmp(subs->ss_substate, what = "active") == 0) */ {
-    /* Any extended state is considered as active */
-    what = subs->ss_substate;
-    substate = nua_substate_active;
+    if (delta > 0 && sip->sip_expires) {
+      snprintf(expires, sizeof expires, "%lu", delta);
+      subs->ss_expires = expires;
+    }
   }
 
-  eu->eu_substate = substate;
-
-  SU_DEBUG_5(("nua(%p): %s: %s (%s)\n", 
-	      (void *)sr->sr_owner, "nua_notify_server_preprocess",
-	      what, reason ? reason : ""));
-
-  return SR_STATUS1(sr, SIP_200_OK);
-}
+  nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+  nua_dialog_uas_route(nh, nh->nh_ds, sip, 1);
 
+  if (strcasecmp(subs->ss_substate, what = "terminated") == 0) {
+    eu->eu_substate = nua_substate_terminated;
 
-int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
-{
-  nua_handle_t *nh = sr->sr_owner;
-  nua_dialog_usage_t *du = sr->sr_usage;
-  struct event_usage *eu = nua_dialog_usage_private(du);
-  sip_t const *sip = sr->sr_request.sip;
-  enum nua_substate substate = nua_substate_terminated;
-  sip_time_t delta = SIP_TIME_MAX;
-  int retry = -1;
-  int retval;
-
-  if (eu) {
-    sip_subscription_state_t *subs = sip->sip_subscription_state;
-
-    substate = eu->eu_substate;
-
-    if (substate == nua_substate_active || substate == nua_substate_pending) {
-      if (subs && subs->ss_expires)
-	delta = strtoul(subs->ss_expires, NULL, 10);
-      else
-	delta = eu->eu_expires;
-    }
-    else if (substate == nua_substate_embryonic) {
-      if (subs && subs->ss_reason) {
-	if (str0casecmp(subs->ss_reason, "deactivated") == 0) {
-	  retry = 0;		/* retry immediately */
-	} 
-	else if (str0casecmp(subs->ss_reason, "probation") == 0) {
-	  retry = 30;
-	  if (subs->ss_retry_after)
-	    retry = strtoul(subs->ss_retry_after, NULL, 10);
-	  if (retry > 3600)
-	    retry = 3600;
-	}
-      }
-    }
-    else if (substate == nua_substate_terminated) {
-      sr->sr_terminating = 1;
+    if (str0casecmp(subs->ss_reason, why = "deactivated") == 0) {
+      eu->eu_substate = nua_substate_embryonic;
+      retry = 0;		/* retry immediately */
+    } 
+    else if (str0casecmp(subs->ss_reason, why = "probation") == 0) {
+      eu->eu_substate = nua_substate_embryonic;
+      retry = 30;
+      if (subs->ss_retry_after)
+	retry = strtoul(subs->ss_retry_after, NULL, 10);
+      if (retry > 3600)
+	retry = 3600;
     }
+    else
+      why = subs->ss_reason;
   }
+  else if (strcasecmp(subs->ss_substate, what = "pending") == 0)
+    eu->eu_substate = nua_substate_pending;
+  else /* if (strcasecmp(subs->ss_substate, "active") == 0) */ {
+    /* Any extended state is considered as active */
+    what = subs->ss_substate ? subs->ss_substate : "active";
+    eu->eu_substate = nua_substate_active;
+  }
+
+  if (du->du_terminating)
+    retry = -1;
   
-  retval = nua_base_server_treport(sr, /* can destroy sr */
-				   NUTAG_SUBSTATE(substate),
-				   TAG_NEXT(tags)); 
-
-  if (retval >= 2 || du == NULL)
-    return retval;
-
-  if (retry >= 0) {		/* Try to subscribe again */
-    /* XXX - this needs through testing */
-    nua_dialog_remove(nh, nh->nh_ds, du); /* tear down */
-    nua_dialog_usage_refresh_range(du, retry, retry + 5);
+  response = nh_make_response(nua, nh, irq, SIP_200_OK,
+			      SIPTAG_ALLOW(NH_PGET(nh, allow)),
+			      SIPTAG_SUPPORTED(NH_PGET(nh, supported)),
+			      TAG_END());
+
+  if (response && 
+      nua_registration_add_contact_to_response(nh, response, NULL, 
+					       sip->sip_record_route,
+					       sip->sip_contact) >= 0)
+    nta_incoming_mreply(irq, response);
+  else
+    nta_incoming_treply(irq, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
+
+  if (eu->eu_substate == nua_substate_terminated && retry > 0)
+    eu->eu_substate = nua_substate_embryonic;
+
+  nua_stack_event(nh->nh_nua, nh, nta_incoming_getrequest(irq),
+		  nua_i_notify, SIP_200_OK, 
+		  NUTAG_SUBSTATE(eu->eu_substate),
+		  TAG_END());
+
+  nta_incoming_destroy(irq), irq = NULL;
+
+  SU_DEBUG_5(("nua(%p): nua_stack_process_notify: %s (%s)\n", 
+	      nh, what, why ? why : ""));
+
+  if (eu->eu_substate == nua_substate_terminated) {
+    if (du != nh->nh_ds->ds_cr->cr_usage)
+      nua_dialog_usage_remove(nh, nh->nh_ds, du);
+    else
+      nua_dialog_usage_reset_refresh(du);
+  }
+  else if (eu->eu_substate == nua_substate_embryonic) {
+    if (retry >= 0) {
+      /* Try to subscribe again */
+      nua_dialog_remove(nh, nh->nh_ds, du); /* tear down */
+      nua_dialog_usage_refresh_range(du, retry, retry + 5);
+    }
+    else if (du != nh->nh_ds->ds_cr->cr_usage)
+      nua_dialog_usage_remove(nh, nh->nh_ds, du);
+    else
+      nua_dialog_usage_reset_refresh(du);
+  }
+  else if (du->du_terminating) {
+    nua_dialog_usage_reset_refresh(du);
   }
   else {
+    sip_time_t delta;
+
+    if (subs->ss_expires)
+      delta = strtoul(subs->ss_expires, NULL, 10);
+    else
+      delta = eu->eu_expires;
+    
     nua_dialog_usage_set_refresh(du, delta);
   }
 
-  return retval;
+  return 0;
 }
 
-
 /* ======================================================================== */
 /* REFER */
 
@@ -721,6 +802,81 @@
  * @RFC3515, @ReferTo, @RFC3892, @ReferredBy
  */
 
+static int process_response_to_refer(nua_handle_t *nh,
+				     nta_outgoing_t *orq,
+				     sip_t const *sip);
+
+int
+nua_stack_refer(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
+{
+  nua_dialog_usage_t *du = NULL;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  msg_t *msg;
+  sip_t *sip;
+  sip_referred_by_t by[1];
+  sip_event_t *event = NULL;
+
+  if (nua_stack_set_handle_special(nh, nh_has_subscribe, nua_r_subscribe) < 0)
+    return UA_EVENT2(e, 900, "Invalid handle for REFER");
+  else if (cr->cr_orq)
+    return UA_EVENT2(e, 900, "Request already in progress");
+
+  nua_stack_init_handle(nua, nh, TAG_NEXT(tags));
+
+  sip_referred_by_init(by);
+  by->b_display = nua->nua_from->a_display;
+  *by->b_url = *nua->nua_from->a_url;
+
+  /* Now we create a REFER request message */
+  msg = nua_creq_msg(nua, nh, cr, cr->cr_retry_count,
+			 SIP_METHOD_REFER,
+			 NUTAG_USE_DIALOG(1),
+			 SIPTAG_EVENT(SIP_NONE), /* remove event */
+			 SIPTAG_REFERRED_BY(by), /* Overriden by user tags */
+			 NUTAG_ADD_CONTACT(1),
+			 TAG_NEXT(tags));
+  sip = sip_object(msg);
+
+  if (sip && sip->sip_cseq)
+    event = sip_event_format(nh->nh_home, "refer;id=%u", 
+			     sip->sip_cseq->cs_seq);
+
+  if (event)
+    du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, event);
+  
+  if (du)
+    cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
+				      process_response_to_refer, nh, NULL,
+				      msg,
+				      SIPTAG_END(), TAG_NEXT(tags));
+  
+  if (!cr->cr_orq) {
+    if (du)
+      nua_dialog_usage_remove(nh, nh->nh_ds, du);
+    su_free(nh->nh_home, event);
+    msg_destroy(msg);
+    return UA_EVENT1(e, NUA_INTERNAL_ERROR);
+  }
+
+  /*
+   * We send a 100 trying event so that application gets a event 
+   * it can use to match NOTIFYs with its REFER
+   */
+  nua_stack_event(nua, nh, NULL, e, SIP_100_TRYING, 
+	   NUTAG_REFER_EVENT(event),
+	   TAG_END());
+  su_free(nh->nh_home, event);
+
+  cr->cr_usage = du;
+
+  return cr->cr_event = e;
+}
+
+void restart_refer(nua_handle_t *nh, tagi_t *tags)
+{
+  nua_stack_refer(nh->nh_nua, nh, nh->nh_ds->ds_cr->cr_event, tags);
+}
+
 /**@NUA_EVENT nua_r_refer
  *
  * @brief Response to outgoing REFER.
@@ -744,130 +900,27 @@
  * @END_NUA_EVENT
  */
 
-static int nua_refer_client_init(nua_client_request_t *cr, 
-				 msg_t *, sip_t *,
-				 tagi_t const *tags);
-static int nua_refer_client_request(nua_client_request_t *cr,
-				    msg_t *, sip_t *,
-				    tagi_t const *tags);
-static int nua_refer_client_response(nua_client_request_t *cr,
-				     int status, char const *phrase,
-				     sip_t const *sip);
-
-static nua_client_methods_t const nua_refer_client_methods = {
-  SIP_METHOD_REFER,
-  0,
-  { 
-    /* create_dialog */ 1,
-    /* in_dialog */ 1,
-    /* target refresh */ 1
-  },
-  /*nua_refer_client_template*/ NULL,
-  nua_refer_client_init,
-  nua_refer_client_request,
-  /* nua_refer_client_check_restart */ NULL,
-  nua_refer_client_response,
-  nua_refer_client_response,	/* Preliminary */
-  NULL
-};
-
-int
-nua_stack_refer(nua_t *nua, nua_handle_t *nh, nua_event_t e,
-		    tagi_t const *tags)
-{
-  return nua_client_create(nh, e, &nua_refer_client_methods, tags);
-}
-
-static int nua_refer_client_init(nua_client_request_t *cr,
-				 msg_t *msg, sip_t *sip,
-				 tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-
-  if (sip->sip_referred_by == NULL) {
-    sip_from_t *a = sip->sip_from;
-    sip_referred_by_t by[1];
-
-    sip_referred_by_init(by);
-
-    if (a == NULL)
-      a = nh->nh_nua->nua_from;
-    by->b_display = a->a_display;
-    *by->b_url = *a->a_url;
-
-    sip_add_dup(msg, sip, (sip_header_t *)by);
-  }
-
-  if (sip->sip_event)
-    sip_header_remove(msg, sip, (sip_header_t *)sip->sip_event);
-
-  return 0;
-}
-
-static int nua_refer_client_request(nua_client_request_t *cr,
-				    msg_t *msg, sip_t *sip,
-				    tagi_t const *tags)
-{
-  nua_handle_t *nh = cr->cr_owner;
-  nua_dialog_usage_t *du = cr->cr_usage;
-  struct event_usage *eu;
-  sip_event_t *event;
-  int error;
-
-  cr->cr_usage = NULL;
-
-  if (du)
-    nua_dialog_usage_remove(nh, nh->nh_ds, du);
-
-  event = sip_event_format(nh->nh_home, "refer;id=%u", sip->sip_cseq->cs_seq);
-  if (!event)
-    return -1;
-  du = nua_dialog_usage_add(nh, nh->nh_ds, nua_subscribe_usage, event);
-  if (!du)
-    return -1;
-
-  eu = nua_dialog_usage_private(cr->cr_usage = du);
-  eu ->eu_refer = 1;
-
-  error = nua_base_client_request(cr, msg, sip, tags);
-
-  if (!error) {
-    /* Give application an Event header for matching NOTIFYs with REFER */
-    nua_stack_tevent(nh->nh_nua, nh, NULL,
-		     cr->cr_event, SIP_100_TRYING,
-		     NUTAG_REFER_EVENT(event),
-		     TAG_END());
-    su_free(nh->nh_home, event);
-  }
-
-  return error;
-}
-
-static int nua_refer_client_response(nua_client_request_t *cr,
-				     int status, char const *phrase,
+static int process_response_to_refer(nua_handle_t *nh,
+				     nta_outgoing_t *orq,
 				     sip_t const *sip)
 {
-  nua_dialog_usage_t *du = cr->cr_usage; 
-  enum nua_substate substate = nua_substate_terminated;
-
-  if (du) {
-    struct event_usage *eu = nua_dialog_usage_private(du);
-
-    if (status < 200) {
-      substate = eu->eu_substate;      
-    } 
-    else if (status < 300) {
-      sip_refer_sub_t const *rs = sip_refer_sub(sip);
-
-      if (rs && strcasecmp("false", rs->rs_value) == 0)
-	cr->cr_terminated = 1;
+  nua_client_request_t *cr = nh->nh_ds->ds_cr;
+  int status = sip ? sip->sip_status->st_status : 408;
 
-      if (!cr->cr_terminated)
-	substate = eu->eu_substate;
-    }
+  if (status < 200)
+    ;
+  else if (status < 300) {
+    if (cr->cr_usage)
+      cr->cr_usage->du_ready = 1;
+    nua_dialog_uac_route(nh, nh->nh_ds, sip, 1);
+    nua_dialog_store_peer_info(nh, nh->nh_ds, sip);
+  }
+  else /* if (status >= 300) */ {
+    if (cr->cr_usage)
+      nua_dialog_usage_remove(nh, nh->nh_ds, cr->cr_usage), cr->cr_usage = NULL;
+    if (nua_creq_check_restart(nh, cr, orq, sip, restart_refer))
+      return 0;
   }
-  
-  return nua_base_client_tresponse(cr, status, phrase, sip, 
-				   NUTAG_SUBSTATE(substate),
-				   TAG_END());
+
+  return nua_stack_process_response(nh, cr, orq, sip, TAG_END());
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c	Sat Feb 17 01:25:21 2007
@@ -68,7 +68,6 @@
 tag_typedef_t nutag_offer_sent = BOOLTAG_TYPEDEF(offer_sent);
 tag_typedef_t nutag_answer_sent = BOOLTAG_TYPEDEF(answer_sent);
 tag_typedef_t nutag_substate = INTTAG_TYPEDEF(substate);
-tag_typedef_t nutag_newsub = BOOLTAG_TYPEDEF(newsub);
 tag_typedef_t nutag_invite_timer = UINTTAG_TYPEDEF(invite_timer);
 tag_typedef_t nutag_session_timer = UINTTAG_TYPEDEF(session_timer);
 tag_typedef_t nutag_min_se = UINTTAG_TYPEDEF(min_se);
@@ -148,3 +147,6 @@
 tag_typedef_t nutag_detect_network_updates = UINTTAG_TYPEDEF(detect_network_updates);
 
 tag_typedef_t nutag_with = PTRTAG_TYPEDEF(with);
+
+tag_typedef_t _nutag_add_contact = BOOLTAG_TYPEDEF(add_contact);
+tag_typedef_t _nutag_copy = BOOLTAG_TYPEDEF(copy);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c	Sat Feb 17 01:25:21 2007
@@ -117,6 +117,7 @@
 
   char const *ob_instance;	/**< Our instance ID */
   int32_t ob_reg_id;		/**< Flow-id */
+  char const *ob_features;	/**< Feature parameters for rcontact */
   sip_contact_t *ob_rcontact;	/**< Our contact */
   sip_contact_t *ob_dcontact;	/**< Contact for dialogs */
   sip_contact_t *ob_previous;	/**< Stale contact */
@@ -293,8 +294,7 @@
     else if (MATCH(use-upnp) || MATCH(use_upnp)) prefs->use_upnp = value;
     else if (MATCH(use-stun) || MATCH(use_stun)) prefs->use_stun = value;
     else
-      SU_DEBUG_1(("outbound(%p): unknown option \"%.*s\"\n",
-		  (void *)ob->ob_owner, (int)len, s));
+      SU_DEBUG_1(("outbound_t: unknown option \"%.*s\"\n", (int)len, s));
 
     s += len;
     len = strspn(s, " \t\n\r,;");
@@ -304,8 +304,7 @@
   }
 
   if (s && s[0]) {
-    SU_DEBUG_1(("outbound(%p): invalid options \"%s\"\n", 
-		(void *)ob->ob_owner, options));
+    SU_DEBUG_1(("outbound_t: invalid options \"%s\"\n", options));
     return -1;
   }
 
@@ -316,8 +315,7 @@
 	prefs->use_socks ||
 	prefs->use_upnp ||
 	prefs->use_stun)) {
-    SU_DEBUG_1(("outbound(%p): no nat traversal method given\n",
-		(void *)ob->ob_owner));
+    SU_DEBUG_1(("outbound(%p): no nat traversal method given\n", ob->ob_owner));
   }
 
   ob->ob_prefs = *prefs;
@@ -326,27 +324,60 @@
   return 0;
 }
 
-/* ---------------------------------------------------------------------- */
-
-/** Obtain contacts for REGISTER */
-int outbound_get_contacts(outbound_t *ob, 
-			  sip_contact_t **return_current_contact, 
-			  sip_contact_t **return_previous_contact)
+/** Set the feature string (added to the Contact header when registering). */
+int outbound_set_features(outbound_t *ob, char *features)
 {
-  if (ob) {
-    if (ob->ob_contacts)
-      *return_current_contact = ob->ob_rcontact;
-    *return_previous_contact = ob->ob_previous;
-  }
+  char *old_features = (char *)ob->ob_features;
+  char *new_features = su_strdup(ob->ob_home, features);
+
+  if (features && !new_features)
+    return -1;
+
+  ob->ob_features = new_features;
+  su_free(ob->ob_home, old_features);
   return 0;
 }
 
-/** REGISTER request has been sent */
-int outbound_start_registering(outbound_t *ob)
-{
-  if (ob)
+/* ---------------------------------------------------------------------- */
+
+/** Hook for sending register request with extra outbound-ish headers. */
+nta_outgoing_t *outbound_register_request(outbound_t *ob, int terminating, 
+					  sip_contact_t *stack_contact,
+					  nta_agent_t *nta,
+					  nta_response_f *callback,
+					  nta_outgoing_magic_t *magic,
+					  url_string_t *next_hop,
+					  msg_t *msg,
+					  tag_type_t tag, tag_value_t value,
+					  ...)
+{
+  sip_contact_t *previous_contact = NULL;
+  ta_list ta;
+  nta_outgoing_t *orq;
+
+  if (stack_contact) {
+    if (ob) {
+      if (ob->ob_contacts)
+	stack_contact = ob->ob_rcontact;
+      previous_contact = ob->ob_previous;
+    }
+  }
+
+  ta_start(ta, tag, value);
+
+  orq = nta_outgoing_mcreate(nta, callback, magic, next_hop, msg,
+			     TAG_IF(previous_contact,
+				    SIPTAG_CONTACT(previous_contact)),
+			     TAG_IF(stack_contact,
+				    SIPTAG_CONTACT(stack_contact)),
+			     ta_tags(ta));
+
+  ta_end(ta);
+
+  if (orq && ob)
     ob->ob_registering = 1;
-  return 0;
+
+  return orq;
 }
 
 /** Process response to REGISTER request */
@@ -360,16 +391,17 @@
   if (!ob)
     return 0;
 
+  assert(!request || request->sip_request);
+  assert(!response || response->sip_status);
+  
+  if (!response || !request)
+    return 0;
+
   if (terminating) {
-    ob->ob_registering = ob->ob_registered = 0;
+    ob->ob_registered = ob->ob_registering = 0;
     return 0;			/* Cleanup is done separately */
   }  
 
-  if (!response || !request)
-    return 0;
-
-  assert(request->sip_request); assert(response->sip_status);
-  
   reregister = outbound_check_for_nat(ob, request, response);
   if (reregister)
     return reregister;
@@ -391,13 +423,7 @@
 }
 
 
-/** @internal Check if there is a NAT between us and registrar.
- *
- * @retval -1 upon an error
- * @retval #ob_register_ok (0) if the registration was OK
- * @retval #ob_reregister (1) if client needs to re-register
- * @retval #ob_reregister_now (2) if client needs to re-register immediately
- */
+/** @internal Check if there is a NAT between us and registrar */
 static
 int outbound_check_for_nat(outbound_t *ob,
 			   sip_t const *request,
@@ -431,11 +457,11 @@
   if (!m || binding_changed >= ob_nat_changed) {
     if (ob->ob_stun) {
       /* Use STUN? */
-      return ob_reregister;
+      return 1;
     }
     else if (ob->ob_upnp) {
       /* Use UPnP */
-      return ob_reregister;
+      return 1;
     }
     else {
       if (outbound_contacts_from_via(ob, response->sip_via) < 0)
@@ -486,7 +512,7 @@
   if (!host_is_ip_address(received)) {
     if (received[0])
       SU_DEBUG_3(("outbound(%p): Via with invalid received=%s\n",
-		  (void *)ob->ob_owner, received));
+		  ob->ob_owner, received));
     return 0;
   }
 
@@ -504,14 +530,14 @@
 
   if (!nat_detected) {
     SU_DEBUG_1(("outbound(%p): detected NAT: %s != %s\n",
-		(void *)ob->ob_owner, v->v_host, received));
+		ob->ob_owner, v->v_host, received));
     if (ob->ob_oo && ob->ob_oo->oo_status)
       ob->ob_oo->oo_status(ob->ob_owner, ob, 101, "NAT detected", TAG_END());
   }
   else {
     SU_DEBUG_1(("outbound(%p): NAT binding changed: "
 		"[%s]:%s != [%s]:%s\n",
-		(void *)ob->ob_owner, nat_detected, nat_port, received, rport));
+		ob->ob_owner, nat_detected, nat_port, received, rport));
     if (ob->ob_oo && ob->ob_oo->oo_status)
       ob->ob_oo->oo_status(ob->ob_owner, ob, 102, "NAT binding changed", TAG_END());
   }
@@ -683,32 +709,21 @@
 {
   msg_t *msg = nta_msg_create(ob->ob_nta, MSG_FLG_COMPACT), *previous;
   sip_t *osip = sip_object(msg);
-  sip_contact_t *m = ob->ob_rcontact;
+  sip_accept_contact_t *ac;
+
+  char const *p1 = ob->ob_instance;
+  char const *p2 = ob->ob_features;
 
   unsigned d = ob->ob_keepalive.interval;
 
   assert(regsip); assert(regsip->sip_request);
 
-  if (m && m->m_params) {
-    sip_accept_contact_t *ac;
-    size_t i;
-    int features = 0;
-
-    ac = sip_accept_contact_make(msg_home(msg), "*;require;explicit");
-
-    for (i = 0; m->m_params[i]; i++) {
-      char const *s = m->m_params[i];
-      if (!sip_is_callerpref(s))
-	continue;
-      features++;
-      s = su_strdup(msg_home(msg), s);
-      msg_header_add_param(msg_home(msg), ac->cp_common, s);
-    }
-    
-    if (features)
-      msg_header_insert(msg, NULL, (void *)ac);
-    else
-      msg_header_free(msg_home(msg), (void *)ac);
+  if (p1 || p2) {
+    ac = sip_accept_contact_format(msg_home(msg), "*;require;explicit;%s%s%s",
+				   p1 ? p1 : "",
+				   p2 && p2 ? ";" : "",
+				   p2 ? p2 : "");
+    msg_header_insert(msg, NULL, (void *)ac);
   }
 
   if (0 >
@@ -862,19 +877,18 @@
     if (loglevel >= SU_LOG->log_level) {
       su_llog(SU_LOG, loglevel,       
 	      "outbound(%p): %s <" URL_PRINT_FORMAT ">\n",
-	      (void *)ob->ob_owner,
-	      failed ? "FAILED to validate" : "validated",
+	      ob->ob_owner, failed ? "FAILED to validate" : "validated", 
 	      URL_PRINT_ARGS(ob->ob_rcontact->m_url));
       if (failed)
 	su_llog(SU_LOG, loglevel, "outbound(%p): FAILED with %u %s\n", 
-		(void *)ob->ob_owner, status, phrase);
+		ob->ob_owner, status, phrase);
     }
 
     if (failed) 
       ob->ob_oo->oo_probe_error(ob->ob_owner, ob, status, phrase, TAG_END());
   }
   else if (status == 408) {
-    SU_DEBUG_1(("outbound(%p): keepalive timeout\n", (void *)ob->ob_owner));
+    SU_DEBUG_1(("outbound(%p): keepalive timeout\n", ob->ob_owner));
     ob->ob_oo->oo_keepalive_error(ob->ob_owner, ob, status, phrase, TAG_END());
     return 0;
   }
@@ -968,7 +982,7 @@
 
   if (ob->ob_keepalive.validating) {
     SU_DEBUG_1(("outbound(%p): registration check OPTIONS received\n", 
-		(void *)ob->ob_owner));
+		ob->ob_owner));
     ob->ob_keepalive.validated = 1;
   }
 
@@ -1004,16 +1018,48 @@
 
   v = v0; *v0 = *via; v0->v_next = NULL;
 
-  dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 1,
+  dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
 				   NULL, v, v->v_protocol, NULL);
 
   if (ob->ob_instance && ob->ob_reg_id != 0)
     snprintf(reg_id_param, sizeof reg_id_param, ";reg-id=%u", ob->ob_reg_id);
 
-  rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 0,
+  rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
 				   NULL, v, v->v_protocol, 
+				   ob->ob_features ? ob->ob_features : "",
 				   ob->ob_instance, reg_id_param, NULL);
     
+#if 0
+  char *uri;
+
+  /* uri contains < > */
+  uri = sip_contact_string_from_via(NULL, via, NULL, v->v_protocol);
+
+  dcontact = sip_contact_make(home, uri);
+
+
+
+  if (ob->ob_instance) {
+    char reg_id[20];
+
+    if (ob->ob_instance && ob->ob_reg_id)
+      snprintf(reg_id, sizeof reg_id, ";reg-id=%u", ob->ob_reg_id);
+    else
+      strcpy(reg_id, "");
+
+    rcontact = sip_contact_format(home, "%s;%s%s%s%s",
+				  uri, ob->ob_instance, reg_id,
+				  ob->ob_features ? ";" : "",
+				  ob->ob_features ? ob->ob_features : "");
+  }
+  else if (ob->ob_features)
+    rcontact = sip_contact_format(home, "%s;%s", uri, ob->ob_features);
+  else
+    rcontact = dcontact;
+
+  free(uri);
+#endif
+
   v = sip_via_dup(home, v);
 
   if (!rcontact || !dcontact || !v) {
@@ -1105,7 +1151,7 @@
     char const *tport = !v->v_next ? v->v_protocol : NULL; 
     char reg_id_param[20];
 
-    dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 1, 
+    dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
 				     NULL, v, tport, NULL);
     if (!dcontact)
       return -1;
@@ -1113,8 +1159,9 @@
     if (ob->ob_instance && ob->ob_reg_id != 0)
       snprintf(reg_id_param, sizeof reg_id_param, ";reg-id=%u", ob->ob_reg_id);
 
-    rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 0,
+    rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
 				     NULL, v, v->v_protocol, 
+				     ob->ob_features ? ob->ob_features : "",
 				     ob->ob_instance, reg_id_param, NULL);
     if (!rcontact)
       return -1;
@@ -1125,10 +1172,8 @@
       previous = ob->ob_contacts ? ob->ob_rcontact : NULL;
     }
   }
-    
-  ob->ob_by_stack = application_contact == NULL;
 
-  ob->ob_contacts = rcontact != NULL;
+  ob->ob_by_stack = application_contact == NULL;
 
   ob->ob_rcontact = rcontact;
   ob->ob_dcontact = dcontact;
@@ -1160,11 +1205,6 @@
     return ob->ob_dcontact;
 }
 
-sip_contact_t const *outbound_dialog_gruu(outbound_t const *ob)
-{
-  return ob ? ob->ob_gruu : NULL;
-}
-
 /* ---------------------------------------------------------------------- */
 
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.h	Sat Feb 17 01:25:21 2007
@@ -70,11 +70,17 @@
 			 unsigned dgram_interval,
 			 unsigned stream_interval);
 
-int outbound_get_contacts(outbound_t *ob, 
-			  sip_contact_t **return_current_contact, 
-			  sip_contact_t **return_previous_contact);
+int outbound_set_features(outbound_t *ob, char *features);
 
-int outbound_start_registering(outbound_t *ob);
+nta_outgoing_t *outbound_register_request(outbound_t *ob, int terminating, 
+					  sip_contact_t *stack_contact,
+					  nta_agent_t *nta,
+					  nta_response_f *callback,
+					  nta_outgoing_magic_t *magic,
+					  url_string_t *next_hop,
+					  msg_t *msg,
+					  tag_type_t tag, tag_value_t value,
+					  ...);
 
 int outbound_register_response(outbound_t *ob,
 			       int terminating,
@@ -96,8 +102,6 @@
 
 sip_contact_t const *outbound_dialog_contact(outbound_t const *ob);
 
-sip_contact_t const *outbound_dialog_gruu(outbound_t const *ob);
-
 int outbound_gruuize(outbound_t *ob, sip_t const *sip);
 
 void outbound_start_keepalive(outbound_t *ob,
@@ -118,7 +122,6 @@
   int oo_size;
   sip_contact_t *(*oo_contact)(outbound_owner_t *,
 			       su_home_t *home,
-			       int used_in_dialog,
 			       char const *extra_username,
 			       sip_via_t const *v,
 			       char const *transport,

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h	Sat Feb 17 01:25:21 2007
@@ -262,12 +262,6 @@
 /** Get name for NUA callstate. */
 SOFIAPUBFUN char const *nua_callstate_name(enum nua_callstate state);
 
-/** Return name of subscription state. @NEW_1_12_5. */
-SOFIAPUBFUN char const *nua_substate_name(enum nua_substate substate);
-
-/** Convert string to enum nua_substate. @NEW_1_12_5. */
-SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate);
-
 /** Send SIP REGISTER request to the registrar. */ 
 SOFIAPUBFUN void nua_register(nua_handle_t *nh, tag_type_t, tag_value_t, ...);
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h	Sat Feb 17 01:25:21 2007
@@ -1074,7 +1074,7 @@
  *
  * The outbound option string can specify how the NAT traversal is handled.
  * The option tokens are as follows:
- * - "gruuize": try to generate a GRUU contact from REGISTER response
+ * - "gruuize": try to generate a GRUU
  * - "outbound": use SIP outbound extension (off by default)
  * - "validate": validate registration behind a NAT by sending OPTIONS to self
  * - "natify": try to traverse NAT
@@ -1084,10 +1084,6 @@
  * An option token with "no-" or "not-" prefix turns the option off. For
  * example, if you want to try to traverse NATs but not to use OPTIONS
  * keepalive, use NUTAG_OUTBOUND("natify no-options-keepalive").
- * 
- * An empty string can be passed to let the stack choose the
- * default values for outbound usage (in the 1.12.5 release, the
- * defaults are: "gruuize no-outbound validate use-port options-keepalive").
  *
  * @note
  * Options string is used so that no new tags need to be added when the
@@ -1211,7 +1207,7 @@
  *    nua_create()
  *
  * @par Parameter type
- *    msg_mclass_t const *
+ *    msg_mclass_t *
  *
  * @par Values
  *    Pointer to an extended SIP parser.
@@ -1248,9 +1244,6 @@
 
 /** Keepalive interval in milliseconds.
  *
- * This setting applies to OPTIONS/STUN keepalives. See documentation 
- * for nua_register() for more detailed information.
- *
  * @par Used with
  *    nua_register()   \n
  *    nua_set_params() \n
@@ -1276,8 +1269,6 @@
 
 /** Transport-level keepalive interval for streams.
  *
- * See documentation for nua_register() for more detailed information.
- *
  * @par Used with
  *    nua_register()   \n
  *    nua_set_params() \n
@@ -1336,7 +1327,6 @@
  *
  * @par Used with
  *    nua_register(), nua_set_hparams(), nua_set_params().
- *    nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
  *
  * @par Parameter type
  *    string (char *)
@@ -1368,7 +1358,6 @@
  *
  * @par Used with
  *    nua_register(), nua_set_hparams(), nua_set_params().
- *    nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
  *
  * @par Parameter type
  *    string (char *)
@@ -1399,8 +1388,7 @@
  * user-agent.
  *
  * @par Used with
- *    nua_register(), nua_set_hparams(), nua_set_params(), 
- *    nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
+ *    nua_register(), nua_set_hparams(), nua_set_params().
  *
  * @par Parameter type
  *    string (char *)
@@ -1871,39 +1859,26 @@
 /** Get name for NUA call state */
 SOFIAPUBFUN char const *nua_callstate_name(enum nua_callstate state);
 
-/**Subscription state.
+/** Subscription state
  *
  * @par Used with
- *    #nua_notify() \n
  *    #nua_r_subscribe \n
- *    #nua_i_notify \n
- *    #nua_i_subscribe \n
- *    #nua_r_notify \n
- *    nua_notify() \n
- *    nua_respond() to SUBSCRIBE
+ *    #nua_i_notify
  *
  * @par Parameter type
  *    int
  *
  * @par Values
- *   - #nua_substate_embryonic (0)
- *   - #nua_substate_pending (1)
- *   - #nua_substate_active (2)
- *   - #nua_substate_terminated (3)
- *
- * Note that the @SubscriptionState or @Expires headers specified by
- * application overrides the subscription state specified by
- * NUTAG_SUBSTATE(). Application can terminate subscription by including
- * NUTAG_SUBSTATE(nua_substate_terminated), @SubscriptionState with value
- * "terminated" or @Expires header with value 0 in the NOTIFY request sent
- * by nua_notify().
- *
- * @sa @RFC3265, @SubscriptionState, SIPTAG_SUBSCRIPTION_STATE(),
- * SIPTAG_SUBSCRIPTION_STATE_STR(), #nua_r_subscribe, #nua_i_subscribe,
- * #nua_i_refer, #nua_r_notify, #nua_i_notify.
+ *   @c nua_substate_embryonic (0) \n
+ *   @c nua_substate_pending (1) \n
+ *   @c nua_substate_active (2) \n
+ *   @c nua_substate_terminated	(3) \n
+ *
+ * see
+ * <a href="http://www.ietf.org/rfc/rfc3265.txt">RFC 3265</a>
  *
  * Corresponding tag taking reference parameter is NUTAG_SUBSTATE_REF()
- */
+*/
 #define NUTAG_SUBSTATE(x) nutag_substate, tag_int_v(x)
 SOFIAPUBVAR tag_typedef_t nutag_substate;
 
@@ -1921,46 +1896,6 @@
   nua_substate_terminated = nea_terminated /**< Terminated subscription */
 };
 
-/** Return name of subscription state. @NEW_1_12_5. */
-SOFIAPUBFUN char const *nua_substate_name(enum nua_substate substate);
-
-/** Convert string to enum nua_substate. @NEW_1_12_5. */
-SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate);
-
-/**Send unsolicited NOTIFY request.
- *
- * Some applications may require sending unsolicited NOTIFY requests, that
- * is, NOTIFY without SUBSCRIBE or REFER request sent by event watcher. 
- * However, sending NOTIFY request requires an existing dialog usage by
- * default. If NUTAG_NEWSUB(1) is included in the nua_notify() the usage
- * is create the usage by itself.
- *
- * If you want to create a subscription that does not terminate immediately
- * include SIPTAG_SUBSCRIPTION_STATE_STR() with an "expires" parameter in
- * the argument list, too.
- *
- * @par Used with
- *    nua_notify()
- *
- * @par Parameter type
- *    int (boolean)
- *
- * @par Values
- *   - 0 - false (default) - do not create new subscription 
- *         but reject NOTIFY with 481 locally \n
- *   - 1 - true - create a subscription if it does not exist \n
- *
- * Corresponding tag taking reference parameter is NUTAG_NEWSUB().
- *
- * @since @NEW_1_12_5.
- */
-#define NUTAG_NEWSUB(x)   nutag_newsub, tag_bool_v(x)
-SOFIAPUBVAR tag_typedef_t nutag_newsub;
-
-#define NUTAG_NEWSUB_REF(x) nutag_newsub_ref, tag_bool_vr(&(x))
-SOFIAPUBVAR tag_typedef_t nutag_newsub_ref;
-
-
 /**Default lifetime for implicit subscriptions created by REFER.
  *
  * Default expiration time in seconds for implicit subscriptions created by

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c	Sat Feb 17 01:25:21 2007
@@ -1578,310 +1578,6 @@
   END();
 }
  
-int cancel_when_pracked(CONDITION_PARAMS);
-int alert_call(CONDITION_PARAMS);
-
-int test_180rel_cancel1(struct context *ctx)
-{
-  BEGIN();
-
-  struct endpoint *a = &ctx->a,  *b = &ctx->b;
-  struct call *a_call = a->call, *b_call = b->call;
-  struct event *e;
-
-  if (print_headings)
-    printf("TEST NUA-10.6: CANCEL after PRACK\n");
-
-/* Test for 100rel:
-
-   A			B
-   |-------INVITE------>|
-   |<----100 Trying-----|
-   |			|
-   |<-------180---------|
-   |-------PRACK------->|
-   |<-------200---------|
-   |			|
-   |------CANCEL------->|
-   |<------200 OK-------|
-   |			|
-   |<-------487---------|
-   |--------ACK-------->|
-   |			|
-
-*/
-
-  a_call->sdp = "m=audio 5008 RTP/AVP 8";
-  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
-
-  nua_set_params(ctx->a.nua,
-		 NUTAG_EARLY_MEDIA(1),
-		 NUTAG_ONLY183_100REL(0),
-		 TAG_END());
-  run_a_until(ctx, nua_r_set_params, until_final_response);
-
-  nua_set_params(ctx->b.nua,
-		 NUTAG_EARLY_MEDIA(1),
-		 NUTAG_ONLY183_100REL(0),
-		 TAG_END());
-  run_b_until(ctx, nua_r_set_params, until_final_response);
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 TAG_END());
-
-  run_ab_until(ctx, -1, cancel_when_pracked, -1, alert_call);
-
-  /* Client transitions:
-     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
-     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state, nua_r_prack
-     PROCEEDING -(C3+C4)-> TERMINATED: nua_r_invite, nua_i_state
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(is_offer_sent(e->data->e_tags));
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
-  TEST_1(is_answer_recv(e->data->e_tags));
-  TEST_1(!is_offer_sent(e->data->e_tags));
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_cancel);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 487);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated);
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-
-  /*
-   Server transitions:
-   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
-   Option A:
-   EARLY -(S10)-> TERMINATED: nua_i_cancel, nua_i_state
-   Option B:
-   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
-   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
-   READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state   
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-
-  /* Responded with 180 Ringing */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(is_answer_sent(e->data->e_tags));
-
-  /* 180 is PRACKed */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_prack);
-  /* Does not have effect on call state */
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_cancel);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-
-  free_events_in_list(ctx, b->events);
-
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-10.6: PASSED\n");
-  
-  END();
-}
-
-int cancel_when_pracked(CONDITION_PARAMS)
-{
-  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 0;
-
-  save_event_in_list(ctx, event, ep, call);
-
-  if (event == nua_r_prack)
-    CANCEL(ep, call, nh, TAG_END());
-
-  switch (callstate(tags)) {
-  case nua_callstate_proceeding:
-    return 0;
-  case nua_callstate_ready:
-    return 1;
-  case nua_callstate_terminated:
-    return 1;
-  default:
-    return 0;
-  }
-}
-
-int test_180rel_cancel2(struct context *ctx)
-{
-  BEGIN();
-
-  struct endpoint *a = &ctx->a,  *b = &ctx->b;
-  struct call *a_call = a->call, *b_call = b->call;
-  struct event *e;
-
-  if (print_headings)
-    printf("TEST NUA-10.7: CANCEL after 100rel 180\n");
-
-/* Test for 100rel:
-
-   A			B
-   |-------INVITE------>|
-   |<----100 Trying-----|
-   |			|
-   |<-------180---------|
-   |-------PRACK------->|
-   |<-------200---------|
-   |			|
-   |------CANCEL------->|
-   |<------200 OK-------|
-   |			|
-   |<-------487---------|
-   |--------ACK-------->|
-   |			|
-
-*/
-
-  a_call->sdp = "m=audio 5008 RTP/AVP 8";
-  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
-
-  nua_set_params(ctx->a.nua,
-		 NUTAG_EARLY_MEDIA(1),
-		 NUTAG_ONLY183_100REL(0),
-		 TAG_END());
-  run_a_until(ctx, nua_r_set_params, until_final_response);
-
-  nua_set_params(ctx->b.nua,
-		 NUTAG_EARLY_MEDIA(1),
-		 NUTAG_ONLY183_100REL(0),
-		 TAG_END());
-  run_b_until(ctx, nua_r_set_params, until_final_response);
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 TAG_END());
-
-  run_ab_until(ctx, -1, cancel_when_ringing, -1, accept_pracked2);
-
-  /* Client transitions:
-     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
-     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state, nua_r_prack
-     PROCEEDING -(C3+C4)-> TERMINATED: nua_r_invite, nua_i_state
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(is_offer_sent(e->data->e_tags));
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
-  TEST_1(is_answer_recv(e->data->e_tags));
-  TEST_1(!is_offer_sent(e->data->e_tags));
-
-#define NEXT_SKIP_PRACK_CANCEL() \
-  do { TEST_1(e = e->next); } \
-  while (e->data->e_event == nua_r_prack || e->data->e_event == nua_r_cancel)
-
-  NEXT_SKIP_PRACK_CANCEL();
-
-  TEST_E(e->data->e_event, nua_r_invite);
-  if (e->data->e_status == 487) {
-    TEST(e->data->e_status, 487);
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-    TEST(callstate(e->data->e_tags), nua_callstate_terminated);
-    TEST_1(!e->next);
-  }
-  else {
-    TEST(e->data->e_status, 200);
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-    TEST(callstate(e->data->e_tags), nua_callstate_ready);
-
-    BYE(a, a_call, a_call->nh, TAG_END());
-    run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
-
-    NEXT_SKIP_PRACK_CANCEL(); TEST_E(e->data->e_event, nua_r_bye);
-    TEST(e->data->e_status, 200);
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-    TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-    TEST_1(!e->next);
-  }
-
-  free_events_in_list(ctx, a->events);
-
-  /*
-   Server transitions:
-   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
-   Option A:
-   EARLY -(S10)-> TERMINATED: nua_i_cancel, nua_i_state
-   Option B:
-   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
-   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
-   READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state   
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-
-  /* Responded with 180 Ringing */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(is_answer_sent(e->data->e_tags));
-
-  /* 180 is PRACKed */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_prack);
-  /* Does not have effect on call state */
-
-  if (e->next->data->e_event == nua_i_cancel) {
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_cancel);
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-    TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  }
-  else {
-    /* Respond with 200 OK */
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-    TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
-    TEST_1(!is_offer_answer_done(e->data->e_tags));
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-    TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
-    TEST_1(!is_offer_answer_done(e->data->e_tags));
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-    TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  }
-
-  free_events_in_list(ctx, b->events);
-
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-10.7: PASSED\n");
-  
-  END();
-}
-
 
 int test_100rel(struct context *ctx)
 {
@@ -1893,29 +1589,6 @@
   retval = test_preconditions(ctx); RETURN_ON_SINGLE_FAILURE(retval);
   retval = test_preconditions2(ctx); RETURN_ON_SINGLE_FAILURE(retval);
   retval = test_update_by_uas(ctx); RETURN_ON_SINGLE_FAILURE(retval);
-  retval = test_180rel_cancel1(ctx); RETURN_ON_SINGLE_FAILURE(retval);
-  retval = test_180rel_cancel2(ctx); RETURN_ON_SINGLE_FAILURE(retval);
-
-  nua_set_params(ctx->a.nua,
-		 NUTAG_EARLY_MEDIA(0),
-		 SIPTAG_SUPPORTED(ctx->a.supported),
-		 TAG_END());
-  run_a_until(ctx, nua_r_set_params, until_final_response);
-
-  nua_set_params(ctx->b.nua,
-		 NUTAG_EARLY_MEDIA(0),
-		 NUTAG_ONLY183_100REL(0),
-		 SIPTAG_SUPPORTED(ctx->b.supported),
-		 TAG_END());
-  run_b_until(ctx, nua_r_set_params, until_final_response);
-
-  nua_set_params(ctx->c.nua,
-		 NUTAG_EARLY_MEDIA(0),
-		 NUTAG_ONLY183_100REL(0),
-		 SIPTAG_SUPPORTED(ctx->c.supported),
-		 TAG_END());
-  run_c_until(ctx, nua_r_set_params, until_final_response);
 
   return retval;
 }
-

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_basic_call.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_basic_call.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_basic_call.c	Sat Feb 17 01:25:21 2007
@@ -117,8 +117,6 @@
   case nua_callstate_received:
     RESPOND(ep, call, nh, SIP_180_RINGING, 
 	    TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
-	    NUTAG_M_DISPLAY("Bob"),
-	    NUTAG_M_USERNAME("b+b"),
 	    TAG_END());
     return 0;
   case nua_callstate_early:
@@ -219,8 +217,6 @@
   INVITE(a, a_call, a_call->nh,
 	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
 	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 NUTAG_M_USERNAME("a+a"),
-	 NUTAG_M_DISPLAY("Alice"),
 	 TAG_END());
 
   run_ab_until(ctx, -1, until_ready, -1, accept_call_with_early_sdp);
@@ -267,11 +263,8 @@
   TEST_1(is_answer_recv(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
   TEST(e->data->e_status, 200);
-  TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(sip->sip_payload);
-  TEST_1(sip->sip_contact);
-  TEST_S(sip->sip_contact->m_display, "Bob");
-  TEST_S(sip->sip_contact->m_url->url_user, "b+b");
+  TEST_1(sip = sip_object(e->data->e_msg));
   /* Test that B uses application-specific contact */
   if (ctx->proxy_tests)
     TEST_1(sip->sip_contact->m_url->url_user);
@@ -289,10 +282,6 @@
   */
   TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
   TEST(e->data->e_status, 100);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_contact);
-  TEST_S(sip->sip_contact->m_display, "Alice");
-  TEST_S(sip->sip_contact->m_url->url_user, "a+a");
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
@@ -415,7 +404,6 @@
   INVITE(a, a_call, a_call->nh,
 	 NUTAG_URL(b->contact->m_url),
 	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 NUTAG_ALLOW("INFO"),
 	 TAG_END());
 
   run_ab_until(ctx, -1, until_ready, -1, accept_early_answer);
@@ -478,96 +466,32 @@
   TEST_1(nua_handle_has_active_call(b_call->nh));
   TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
 
-  /* Send a NOTIFY from B to A */
-  if (print_headings)
-    printf("TEST NUA-3.2.2: send a NOTIFY within a dialog\n");
-
-  /* Make A to accept NOTIFY */
-  nua_set_params(a->nua, NUTAG_APPL_METHOD("NOTIFY"), TAG_END());
-  run_a_until(ctx, nua_r_set_params, until_final_response);
-
-  NOTIFY(b, b_call, b_call->nh,
-	 NUTAG_NEWSUB(1),
-	 SIPTAG_SUBJECT_STR("NUA-3.2.2"),
-	 SIPTAG_EVENT_STR("message-summary"),
-	 SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
-	 SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
-	 TAG_END());
-
-  run_ab_until(ctx, -1, accept_notify, -1, save_until_final_response);
-
-  /* Notifier events: nua_r_notify */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_notify);
-  TEST(e->data->e_status, 200);
-  TEST_1(tl_find(e->data->e_tags, nutag_substate));
-  TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
-       nua_substate_terminated);
-
-  /* watcher events: nua_i_notify */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_notify);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_subscription_state);
-  TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
-  TEST_1(tl_find(e->data->e_tags, nutag_substate));
-  TEST(tl_find(e->data->e_tags, nutag_substate)->t_value, 
-       nua_substate_terminated);
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  free_events_in_list(ctx, b->events);
-
-  if (print_headings)
-    printf("TEST NUA-3.2.2: PASSED\n");
-
-  INFO(b, b_call, b_call->nh, TAG_END());
   BYE(b, b_call, b_call->nh, TAG_END());
-  INFO(b, b_call, b_call->nh, TAG_END());
-
   run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
 
-  while (!b->events->head || /* r_info */
-	 !b->events->head->next || /* r_bye */
-	 !b->events->head->next->next || /* i_state */
-	 !b->events->head->next->next->next) /* r_info */
-    run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
-
   /* B transitions:
-   nua_info()
    READY --(T2)--> TERMINATING: nua_bye()
-   nua_r_info with 200
    TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
-   nua_r_info with 481/900
   */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_info);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = b->events->head);  TEST_E(e->data->e_event, nua_r_bye);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_info);
-  TEST_1(e->data->e_status >= 900 || e->data->e_status == 481);
   TEST_1(!e->next);
   free_events_in_list(ctx, b->events);
 
   TEST_1(!nua_handle_has_active_call(b_call->nh));
 
   /* A transitions:
-     nua_i_info
      READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
   */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_info);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
   TEST(e->data->e_status, 200);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(!e->next);
   free_events_in_list(ctx, a->events);
 
-  BYE(a, a_call, a_call->nh, TAG_END());
-  run_a_until(ctx, -1, save_until_final_response);
-
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
-  TEST_1(e->data->e_status >= 900);
-  TEST_1(!e->next);
-  free_events_in_list(ctx, a->events);
+  TEST_1(!nua_handle_has_active_call(a_call->nh));
 
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_hold.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_hold.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_hold.c	Sat Feb 17 01:25:21 2007
@@ -467,7 +467,7 @@
   */
 
   if (print_headings)
-    printf("TEST NUA-7.6.1: re-INVITE without auto-ack\n");
+    printf("TEST NUA-7.6: re-INVITE without auto-ack\n");
 
   /* Turn off auto-ack */
   nua_set_hparams(b_call->nh, NUTAG_AUTOACK(0), TAG_END());
@@ -517,7 +517,7 @@
   free_events_in_list(ctx, a->events);
 
   if (print_headings)
-    printf("TEST NUA-7.6.1: PASSED\n");
+    printf("TEST NUA-7.6: PASSED\n");
 
 
   /* ---------------------------------------------------------------------- */
@@ -528,7 +528,7 @@
    */
 
   if (print_headings)
-    printf("TEST NUA-7.6.2: terminate call\n");
+    printf("TEST NUA-7.6: terminate call\n");
 
   BYE(a, a_call, a_call->nh, TAG_END());
   run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
@@ -555,7 +555,7 @@
   free_events_in_list(ctx, b->events);
 
   if (print_headings)
-    printf("TEST NUA-7.6.2: PASSED\n");
+    printf("TEST NUA-7.6: PASSED\n");
 
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
@@ -725,6 +725,9 @@
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
+  if (print_headings)
+    printf("TEST NUA-7.8: PASSED\n");
+
   END();
 }
 
@@ -781,211 +784,6 @@
   }
 }
 
-/* ======================================================================== */
-
-int accept_and_attempt_reinvite(CONDITION_PARAMS);
-int until_ready2(CONDITION_PARAMS);
-
-/* test_reinvite2 message sequence looks like this:
-
- A                    B
- |                    |
- |-------INVITE------>|
- |<----100 Trying-----|
- |                    |
- |<----180 Ringing----|
- |                    |
- |           /-INVITE-|
- |           \---900->|
- |                    |
- |<--------200--------|
- |---------ACK------->|
- :                    :
- :   queue INVITE     :
- :                    :
- |-----re-INVITE----->|
- |<--------200--------|
- |---------ACK------->|
- |-----re-INVITE----->|
- |<--------200--------|
- |---------ACK------->|
- :                    :
- :        glare       :
- :                    :
- |-----re-INVITE----->|
- |<----re-INVITE------|
- |<--------491--------|
- |---------491------->|
- |---------ACK------->|
- |<--------ACK--------|
- :                    :
- |---------BYE------->|
- |<--------200--------|
-*/
-
-int test_reinvite2(struct context *ctx)
-{
-  BEGIN();
-
-  struct endpoint *a = &ctx->a, *b = &ctx->b;
-  struct call *a_call = a->call, *b_call = b->call;
-  struct event *e;
-
-  if (print_headings)
-    printf("TEST NUA-7.8.1: Test re-INVITE glare\n");
-
-  a_call->sdp = "m=audio 5008 RTP/AVP 0 8\n";
-  b_call->sdp = "m=audio 5010 RTP/AVP 8\n";
-
-  TEST_1(a_call->nh = 
-	 nua_handle(a->nua, a_call, 
-		    SIPTAG_FROM_STR("Alice <sip:alice at example.com>"),
-		    SIPTAG_TO(b->to),
-		    TAG_END()));
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 TAG_END());
-
-  run_ab_until(ctx, -1, until_ready, -1, accept_and_attempt_reinvite);
-
-  TEST_1(nua_handle_has_active_call(a_call->nh));
-  TEST_1(nua_handle_has_active_call(b_call->nh));
-
-  free_events_in_list(ctx, a->events);
-  free_events_in_list(ctx, b->events);
-
-  /* Check that we can queue INVITEs */
-  INVITE(a, a_call, a_call->nh, TAG_END());
-  INVITE(a, a_call, a_call->nh, TAG_END());
-
-  run_ab_until(ctx, -1, until_ready2, -1, until_ready2);
-
-  free_events_in_list(ctx, a->events);
-  free_events_in_list(ctx, b->events);
-
-  /* Check that INVITE glare works */
-  INVITE(a, a_call, a_call->nh, TAG_END());
-  INVITE(b, b_call, b_call->nh, TAG_END());
-
-  a->flags.n = 0, b->flags.n = 0;
-  run_ab_until(ctx, -1, until_ready2, -1, until_ready2);
-
-  free_events_in_list(ctx, a->events);
-  free_events_in_list(ctx, b->events);
-
-  if (print_headings)
-    printf("TEST NUA-7.8.1: PASSED\n");
-
-
-
-  /* ---------------------------------------------------------------------- */
-  /*
- A                    B
- |---------BYE------->|
- |<--------200--------|
-   */
-
-  if (print_headings)
-    printf("TEST NUA-7.8.2: terminate call\n");
-
-  BYE(a, a_call, a_call->nh, TAG_END());
-  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
-
-  /*
-   Transitions of A:
-   READY --(T2)--> TERMINATING: nua_bye()
-   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-  free_events_in_list(ctx, a->events);
-
-  /* Transitions of B:
-     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_bye);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-  free_events_in_list(ctx, b->events);
-
-  if (print_headings)
-    printf("TEST NUA-7.8.2: PASSED\n");
-
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  END();
-}
-
-int accept_and_attempt_reinvite(CONDITION_PARAMS)
-{
-  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 0;
-
-  save_event_in_list(ctx, event, ep, call);
-
-  if (event == nua_i_prack) {
-    INVITE(ep, call, nh, TAG_END());
-    RESPOND(ep, call, nh, SIP_200_OK,
-	    TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
-	    TAG_END());
-  }
-  else switch (callstate(tags)) {
-  case nua_callstate_received:
-    RESPOND(ep, call, nh, SIP_180_RINGING, 
-	    SIPTAG_REQUIRE_STR("100rel"),
-	    TAG_END());
-    return 0;
-  case nua_callstate_early:
-    return 0;
-  case nua_callstate_ready:
-    return 1;
-  case nua_callstate_terminated:
-    if (call)
-      nua_handle_destroy(call->nh), call->nh = NULL;
-    return 1;
-  default:
-    return 0;
-  }
-  return 0;
-}
-
-/*
- X      INVITE
- |                    |
- |-------INVITE------>|
- |<--------200--------|
- |---------ACK------->|
-*/
-int until_ready2(CONDITION_PARAMS)
-{
-  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 0;
-
-  save_event_in_list(ctx, event, ep, call);
-
-  if (event == nua_r_invite && status == 491) {
-    if (ep == &ctx->a && ++ctx->b.flags.n >= 2) ctx->b.running = 0;
-    if (ep == &ctx->b && ++ctx->a.flags.n >= 2) ctx->a.running = 0;
-  }
-
-  switch (callstate(tags)) {
-  case nua_callstate_ready:
-    return ++ep->flags.n >= 2;
-  case nua_callstate_terminated:
-    if (call)
-      nua_handle_destroy(call->nh), call->nh = NULL;
-    return 1;
-  default:
-    return 0;
-  }
-}
-
 int test_reinvites(struct context *ctx)
 {
   int retval = 0;
@@ -996,10 +794,7 @@
   retval = test_call_hold(ctx);
   
   if (retval == 0)
-    retval = test_reinvite(ctx);
-
-  if (retval == 0)
-    retval = test_reinvite2(ctx);
+    retval |= test_reinvite(ctx);
 
   if (print_headings && retval == 0)
     printf("TEST NUA-7: PASSED\n");

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c	Sat Feb 17 01:25:21 2007
@@ -638,12 +638,11 @@
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
   TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_proxy_authorization);
-  /* Ensure that nua_authenticate() tags get added to the request */
   TEST_1(sip->sip_subject);
   TEST_S(sip->sip_subject->g_value, "Got 407");
+  TEST_1(sip->sip_proxy_authorization);
+  TEST(e->data->e_status, 100);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
@@ -912,7 +911,7 @@
 
   /*
    Client transitions in reject-3:
-   INIT -(C1)-> CALLING -(C6a)-> TERMINATED
+   INIT -(C1)-> PROCEEDING -(C6a)-> TERMINATED
   */
 
   TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
@@ -928,7 +927,7 @@
   /* No content-encoding is supported */
   TEST_S(sip->sip_accept_encoding->aa_value, "");
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* CALLING */
   TEST_1(!e->next);
 
   free_events_in_list(ctx, a->events);
@@ -945,316 +944,3 @@
 
   END();
 }
-
-/* ---------------------------------------------------------------------- */
-
-size_t filter_200_OK(void *message, size_t len)
-{
-  if (len >= 11 && strncasecmp(message, "SIP/2.0 200", 11) == 0)
-    return 0;
-  return len;
-}
-
-size_t filter_ACK(void *message, size_t len)
-{
-  if (len >= 7 && strncasecmp(message, "ACK sip", 7) == 0) 
-    return 0;
-  return len;
-}
-
-int call_with_bad_ack(CONDITION_PARAMS);
-int accept_call_with_bad_contact(CONDITION_PARAMS);
-
-int test_call_timeouts(struct context *ctx)
-{
-  BEGIN();
-
-  struct endpoint *a = &ctx->a, *b = &ctx->b;
-  struct call *a_call = a->call, *b_call = b->call;
-  struct event *e;
-  struct nat_filter *f;
-
-  if (print_headings)
-    printf("TEST NUA-4.7: check for error and timeout handling\n");
-
-  a_call->sdp = "m=audio 5008 RTP/AVP 8";
-  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
-
-  if (!ctx->nat)
-    goto completed_4_7_1;
-
-  if (print_headings)
-    printf("TEST NUA-4.7.1: ACK timeout (200 OK filtered)\n");
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  TEST_1(f = test_nat_add_filter(ctx->nat, filter_200_OK, nat_inbound));
-  
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 SIPTAG_SUBJECT_STR("NUA-4.7.1"),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 TAG_END());
-  run_ab_until(ctx, -1, until_terminated, -1, accept_call);
-
-  /*
- A     accept_call    B
- |                    |
- |-------INVITE------>|
- |<----100 Trying-----|
- |                    |
- |<----180 Ringing----|
- |                    |
- |   X-----200--------|
- |   X-----200--------|
- |   X-----200--------|
- |                    |
- |<--------BYE--------|
- |--------200 OK----->|
-
-  */
-
-  /*
-    Client transitions:
-  */
-
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-
-  /*
-   Server transitions:
-   -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S5)-> TERMINATING
-   -(S10)-> TERMINATED -X
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
-  TEST_1(is_answer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_error);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-  free_events_in_list(ctx, b->events);
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
-
-  if (print_headings)
-    printf("TEST NUA-4.7.1: PASSED\n");
-
- completed_4_7_1:
-
-  if (!ctx->nat)
-    goto completed_4_7_2;
-
-  if (print_headings)
-    printf("TEST NUA-4.7.2: ACK timeout (ACK filtered)\n");
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  TEST_1(f = test_nat_add_filter(ctx->nat, filter_ACK, nat_outbound));
-  
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 SIPTAG_SUBJECT_STR("NUA-4.7.2"),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 TAG_END());
-  run_ab_until(ctx, -1, until_terminated, -1, accept_call);
-
-  /*
- A     accept_call    B
- |                    |
- |-------INVITE------>|
- |<----100 Trying-----|
- |                    |
- |<----180 Ringing----|
- |                    |
- |<--------200--------|
- |--------ACK-----X   |
- |                    |
- |<--------200--------|
- |--------ACK-----X   |
- |                    |
- |<--------200--------|
- |--------ACK-----X   |
- |                    |
- |<--------BYE--------|
- |--------200 OK----->|
-
-  */
-
-  /*
-  */
-
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); 
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); 
-  TEST_1(!e->next);
-
-  /*
-   Server transitions:
-   -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S5)-> TERMINATING
-   -(S10)-> TERMINATED -X
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
-  TEST_1(is_answer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_error);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-  free_events_in_list(ctx, b->events);
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
-
-  if (print_headings)
-    printf("TEST NUA-4.7.2: PASSED\n");
-
- completed_4_7_2:
-
-  if (print_headings)
-    printf("TEST NUA-4.7.3: sending ACK fails\n");
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 SIPTAG_SUBJECT_STR("NUA-4.7.3"),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 NUTAG_AUTOACK(0),
-	 TAG_END());
-  run_ab_until(ctx, -1, call_with_bad_ack, -1, accept_call);
-
-  /*
- A     accept_call    B
- |                    |
- |-------INVITE------>|
- |<----100 Trying-----|
- |                    |
- |<----180 Ringing----|
- |                    |
- |<--------200--------|
- |--ACK-X             |
- |                    |
- |---------BYE------->|
- |<-------200 OK------|
-
-  */
-
-  /*
-  */
-
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); 
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
-  /* try to send ACK */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminating);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); 
-  TEST_1(!e->next);
-
-  /*
-   Server transitions:
-   -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S5)-> TERMINATING
-   -(S10)-> TERMINATED -X
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
-  TEST_1(is_answer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-  free_events_in_list(ctx, b->events);
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-4.7.3: PASSED\n");
-
-  /* XXX - PRACK timeout, PRACK failing, media failing, re-INVITEs */
-
-  if (print_headings)
-    printf("TEST NUA-4.7: PASSED\n");
-
-  END();
-}
-
-int call_with_bad_ack(CONDITION_PARAMS)
-{
-  if (!check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR))
-    return 0;
-
-  save_event_in_list(ctx, event, ep, call);
-
-  if (event == nua_r_invite && 200 <= status && status < 300) {
-    ACK(ep, call, nh,
-	/* Syntax error - sending ACK fails, we send BYE */
-	SIPTAG_MAX_FORWARDS_STR("blue"),
-	TAG_END());
-  }
-
-  return event == nua_i_state && callstate(tags) == nua_callstate_terminated;
-}

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c	Sat Feb 17 01:25:21 2007
@@ -118,8 +118,6 @@
   case nua_callstate_proceeding:
     CANCEL(ep, call, nh, TAG_END());
     return 0;
-  case nua_callstate_ready:
-    return 1;
   case nua_callstate_terminated:
     return 1;
   default:
@@ -498,13 +496,13 @@
     return 0;
   case nua_callstate_early:
     if (call)
-      DESTROY(ep, call, nh), call->nh = NULL;
+      nua_handle_destroy(call->nh), call->nh = NULL;
     return 1;
   case nua_callstate_completed:
   case nua_callstate_ready:
   case nua_callstate_terminated:
     if (call)
-      DESTROY(ep, call, nh), call->nh = NULL;
+      nua_handle_destroy(call->nh), call->nh = NULL;
     return 1;
   default:
     return 0;
@@ -596,7 +594,7 @@
   case nua_callstate_ready:
   case nua_callstate_terminated:
     if (call)
-      DESTROY(ep, call, nh), call->nh = NULL;
+      nua_handle_destroy(call->nh), call->nh = NULL;
     return 1;
   default:
     return 0;
@@ -675,82 +673,6 @@
   END();
 }
 
-/* Destroy when one INVITE is queued. */
-int test_call_destroy_5(struct context *ctx)
-{
-  BEGIN();
-
-  struct endpoint *a = &ctx->a,  *b = &ctx->b;
-  struct call *a_call = a->call, *b_call = b->call;
-  struct event *e;
-
-  if (print_headings)
-    printf("TEST NUA-5.7: destroy when re-INVITE is queued\n");
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 NUTAG_AUTOACK(0),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 TAG_END());
-
-  INVITE(a, a_call, a_call->nh, TAG_END());
-
-  run_ab_until(ctx, -1, until_terminated, -1, destroy_when_completed);
-
-  /* Client transitions:
-     INIT -(C1)-> CALLING: nua_invite(), ...
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
-  TEST_1(is_offer_sent(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
-  TEST_1(is_answer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 481);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-
-  /*
-   Server transitions:
-   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
-   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state ... DESTROY
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
-  TEST_1(is_answer_sent(e->data->e_tags));
-  TEST_1(!e->next);  
-
-  free_events_in_list(ctx, b->events);
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-5.7: PASSED\n");
-
-  END();
-}
-
 int test_call_destroy(struct context *ctx)
 {
   struct endpoint *a = &ctx->a,  *b = &ctx->b;
@@ -763,12 +685,10 @@
     test_call_destroy_1(ctx) ||
     test_call_destroy_2(ctx) ||
     test_call_destroy_3(ctx) ||
-    test_call_destroy_4(ctx) ||
-    test_call_destroy_5(ctx);
+    test_call_destroy_4(ctx);
 }
 
 /* ======================================================================== */
-
 /* Early BYE
 
    A			B
@@ -811,27 +731,12 @@
   }
 }
 
-int bye_when_completing(CONDITION_PARAMS);
-
-static int ack_sent = 0;
-
-size_t count_acks(void *message, size_t len)
-{
-  if (strncasecmp(message, "ACK sip:", 8) == 0)
-    ack_sent++;
-  return len;
-}
-
 int test_early_bye(struct context *ctx)
 {
   BEGIN();
   struct endpoint *a = &ctx->a,  *b = &ctx->b;
   struct call *a_call = a->call, *b_call = b->call;
   struct event *e;
-  struct nat_filter *f = NULL;
-
-  a_call->sdp = "m=audio 5008 RTP/AVP 8";
-  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
 
   if (print_headings)
     printf("TEST NUA-6.1: BYE call when ringing\n");
@@ -901,119 +806,6 @@
   if (print_headings)
     printf("TEST NUA-6.1: PASSED\n");
 
-/* Early BYE 2
-
-   A			B
-   |-------INVITE------>|
-   |<----100 Trying-----|
-   |			|
-   |<----180 Ringing----|
-   |<-------200---------|
-   |			|
-   |--------BYE-------->|
-   |<------200 OK-------|
-   |--------ACK-------->|
-   |			|
-   |			|
-*/
-  if (print_headings)
-    printf("TEST NUA-6.2: BYE call when completing\n");
-
-  if (ctx->nat)
-    TEST_1(f = test_nat_add_filter(ctx->nat, count_acks, nat_outbound));
-  ack_sent = 0;
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  INVITE(a, a_call, a_call->nh,
-	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	 SOATAG_USER_SDP_STR(a_call->sdp),
-	 NUTAG_AUTOACK(0),
-	 TAG_END());
-
-  run_ab_until(ctx, -1, bye_when_completing, -1, accept_until_terminated);
-
-  /* Client transitions:
-     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
-     CALLING -(C2)-> PROCEEDING: nua_r_invite(180, nua_i_state, nua_cancel()
-     PROCEEDING -(C6b)-> TERMINATED: nua_r_invite(487), nua_i_state
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_calling);
-  TEST_1(is_offer_sent(e->data->e_tags));
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); 
-
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completing); 
-  TEST_1(e = e->next);
-
-  TEST_E(e->data->e_event, nua_r_bye); TEST(e->data->e_status, 200);
-  TEST_1(e->data->e_msg);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-
-  if (ctx->nat) {
-    while (ack_sent == 0)
-      su_root_step(ctx->root, 100);
-    TEST_1(ack_sent > 0);
-    TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
-  }
-
-  /*
-   Server transitions:
-   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S2a)-> EARLY: nua_respond(180), nua_i_state
-   EARLY -(S6b)--> TERMINATED: nua_i_cancel, nua_i_state
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
-  TEST(e->data->e_status, 100);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
-  TEST_1(is_offer_recv(e->data->e_tags));
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
-  TEST(e->data->e_status, 200);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-
-  free_events_in_list(ctx, b->events);
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-6.2: PASSED\n");
-
   END();
 }
 
-int bye_when_completing(CONDITION_PARAMS)
-{
-  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 0;
-
-  save_event_in_list(ctx, event, ep, call);
-
-  switch (callstate(tags)) {
-  case nua_callstate_completing:
-    ack_sent = 0;
-    BYE(ep, call, nh, TAG_END());
-    return 0;
-  case nua_callstate_terminated:
-    return 1;
-  default:
-    return 0;
-  }
-}

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_extension.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_extension.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_extension.c	Sat Feb 17 01:25:21 2007
@@ -167,13 +167,6 @@
   free_events_in_list(ctx, b->events);
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
-  nua_set_params(b->nua,
-		 SIPTAG_ALLOW(b->allow),
-		 NUTAG_APPL_METHOD(NULL),
-		 NUTAG_APPL_METHOD(b->appl_method),
-		 TAG_END());
-  run_b_until(ctx, nua_r_set_params, until_final_response);
-
   if (print_headings)
     printf("TEST NUA-13.1: PASSED\n");
   END();

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c	Sat Feb 17 01:25:21 2007
@@ -35,8 +35,6 @@
 
 #include "test_nua.h"
 
-#include <sofia-sip/tport_tag.h>
-
 #if HAVE_FUNC
 #elif HAVE_FUNCTION
 #define __func__ __FUNCTION__
@@ -67,9 +65,6 @@
   struct event *e;
   sip_contact_t const *m = NULL;
   sip_from_t const *sipaddress = NULL;
-  sip_allow_t const *allow = NULL;
-  sip_supported_t const *supported = NULL;
-  char const *appl_method = NULL;
   url_t const *p_uri, *a_uri;		/* Proxy URI */
   char const *a_bind, *a_bind2;
 
@@ -111,7 +106,6 @@
 			       AUTHTAG_DB(passwd_name),
 			       AUTHTAG_QOP("auth-int"),
 			       AUTHTAG_ALGORITHM("md5-sess"),
-			       TAG_IF(ctx->proxy_logging, TPTAG_LOG(1)),
 			       TAG_END());
 
     ctx->proxy_tests = ctx->p != NULL;
@@ -224,29 +218,22 @@
 			  NUTAG_URL(a_bind),
 			  TAG_IF(a_bind != a_bind2, NUTAG_SIPS_URL(a_bind2)),
 			  SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
-			  NTATAG_SIP_T1X64(2000),
+			  NTATAG_SIP_T1X64(4000),
 			  NUTAG_INSTANCE(ctx->a.instance),
-			  TAG_IF(ctx->a.logging, TPTAG_LOG(1)),
 			  TAG_END());
   TEST_1(ctx->a.nua);
 
   nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
   run_a_until(ctx, nua_r_get_params, save_until_final_response);
-  TEST_1(e = ctx->a.specials->head);
+  TEST_1(e = ctx->a.events->head);
   TEST(tl_gets(e->data->e_tags,
 	       NTATAG_CONTACT_REF(m),
 	       SIPTAG_FROM_REF(sipaddress),
-	       SIPTAG_ALLOW_REF(allow),
-	       NUTAG_APPL_METHOD_REF(appl_method),
-	       SIPTAG_SUPPORTED_REF(supported),
-	       TAG_END()), 5); TEST_1(m);
+	       TAG_END()), 2); TEST_1(m);
   TEST_1(ctx->a.contact = sip_contact_dup(ctx->home, m));
   TEST_1(ctx->a.to = sip_to_dup(ctx->home, sipaddress));
-  TEST_1(ctx->a.allow = sip_allow_dup(ctx->home, allow));
-  TEST_1(ctx->a.appl_method = su_strdup(ctx->home, appl_method));
-  TEST_1(ctx->a.supported = sip_supported_dup(ctx->home, supported));
 
-  free_events_in_list(ctx, ctx->a.specials);
+  free_events_in_list(ctx, ctx->a.events);
 
   if (print_headings)
     printf("TEST NUA-2.2.1: PASSED\n");
@@ -262,30 +249,19 @@
 			  NUTAG_URL("sip:0.0.0.0:*"),
 			  SOATAG_USER_SDP_STR("m=audio 5006 RTP/AVP 8 0"),
 			  NUTAG_INSTANCE(ctx->b.instance),
-			  /* Quicker timeout */
-			  NTATAG_SIP_T1X64(2000),
-			  TAG_IF(ctx->b.logging, TPTAG_LOG(1)),
 			  TAG_END());
   TEST_1(ctx->b.nua);
 
   nua_get_params(ctx->b.nua, TAG_ANY(), TAG_END());
   run_b_until(ctx, nua_r_get_params, save_until_final_response);
-  TEST_1(e = ctx->b.specials->head);
+  TEST_1(e = ctx->b.events->head);
   TEST(tl_gets(e->data->e_tags,
 	       NTATAG_CONTACT_REF(m),
 	       SIPTAG_FROM_REF(sipaddress),
-	       SIPTAG_ALLOW_REF(allow),
-	       NUTAG_APPL_METHOD_REF(appl_method),
-	       SIPTAG_SUPPORTED_REF(supported),
-	       TAG_END()), 5); TEST_1(m);
-
+	       TAG_END()), 2); TEST_1(m);
   TEST_1(ctx->b.contact = sip_contact_dup(ctx->home, m));
   TEST_1(ctx->b.to = sip_to_dup(ctx->home, sipaddress));
-  TEST_1(ctx->b.allow = sip_allow_dup(ctx->home, allow));
-  TEST_1(ctx->b.appl_method = su_strdup(ctx->home, appl_method));
-  TEST_1(ctx->b.supported = sip_supported_dup(ctx->home, supported));
-
-  free_events_in_list(ctx, ctx->b.specials);
+  free_events_in_list(ctx, ctx->b.events);
 
   if (print_headings)
     printf("TEST NUA-2.2.2: PASSED\n");
@@ -301,26 +277,19 @@
 			  NUTAG_URL("sip:0.0.0.0:*"),
 			  SOATAG_USER_SDP_STR("m=audio 5400 RTP/AVP 8 0"),
 			  NUTAG_INSTANCE(ctx->c.instance),
-			  TAG_IF(ctx->c.logging, TPTAG_LOG(1)),
 			  TAG_END());
   TEST_1(ctx->c.nua);
 
   nua_get_params(ctx->c.nua, TAG_ANY(), TAG_END());
   run_c_until(ctx, nua_r_get_params, save_until_final_response);
-  TEST_1(e = ctx->c.specials->head);
+  TEST_1(e = ctx->c.events->head);
   TEST(tl_gets(e->data->e_tags,
 	       NTATAG_CONTACT_REF(m),
 	       SIPTAG_FROM_REF(sipaddress),
-	       SIPTAG_ALLOW_REF(allow),
-	       NUTAG_APPL_METHOD_REF(appl_method),
-	       SIPTAG_SUPPORTED_REF(supported),
-	       TAG_END()), 5); TEST_1(m);
+	       TAG_END()), 2); TEST_1(m);
   TEST_1(ctx->c.contact = sip_contact_dup(ctx->home, m));
   TEST_1(ctx->c.to = sip_to_dup(ctx->home, sipaddress));
-  TEST_1(ctx->c.allow = sip_allow_dup(ctx->home, allow));
-  TEST_1(ctx->c.appl_method = su_strdup(ctx->home, appl_method));
-  TEST_1(ctx->c.supported = sip_supported_dup(ctx->home, supported));
-  free_events_in_list(ctx, ctx->c.specials);
+  free_events_in_list(ctx, ctx->c.events);
 
   if (print_headings)
     printf("TEST NUA-2.2.3: PASSED\n");

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.c	Sat Feb 17 01:25:21 2007
@@ -91,8 +91,6 @@
 
   struct binding *bindings;
 
-  struct nat_filter *in_filters, *out_filters;
-
   /* True if we act in symmetric way */
   int symmetric;
   /* True if we do logging */
@@ -155,14 +153,6 @@
 
 static int invalidate_binding(struct binding *b);
 
-LIST_PROTOS(static, nat_filter, struct nat_filter);
-
-struct nat_filter
-{
-  struct nat_filter *next, **prev;
-  size_t (*condition)(void *message, size_t len);
-};
-
 /* nat entry point */
 static int
 test_nat_init(su_root_t *root, struct nat *nat)
@@ -680,35 +670,19 @@
 {
   int events;
   ssize_t n, m;
-  size_t len, filtered;
-  struct nat_filter *f;
 
   events = su_wait_events(wait, b->in_socket);
 
   n = su_recv(b->in_socket, nat->buffer, sizeof nat->buffer, 0);
-  if (n == -1) {
+  if (n < 0) {
     su_perror("udp_in_to_out: recv");
     return 0;
   }
 
-  len = (size_t)n;
-
-  for (f = nat->out_filters; f; f = f->next) {
-    filtered = f->condition(nat->buffer, len);
-    if (filtered != len) {
-      if (nat->logging)
-	printf("nat: udp filtered "MOD_ZU" from %s => "MOD_ZU" to %s\n",
-	       len, b->in_name, filtered, b->out_name);
-      if (filtered == 0)
-	return 0;
-      len = filtered;
-    }
-  }
-
   if (nat->symmetric)
-    m = su_send(b->out_socket, nat->buffer, len, 0);
+    m = su_send(b->out_socket, nat->buffer, n, 0);
   else
-    m = su_sendto(b->out_socket, nat->buffer, len, 0,
+    m = su_sendto(b->out_socket, nat->buffer, n, 0,
 		  nat->out_address, nat->out_addrlen);
 
   if (nat->logging)
@@ -722,8 +696,6 @@
 {
   int events;
   ssize_t n, m;
-  size_t len, filtered;
-  struct nat_filter *f;
 
   events = su_wait_events(wait, b->out_socket);
 
@@ -733,20 +705,6 @@
     return 0;
   }
 
-  len = (size_t)n;
-
-  for (f = nat->in_filters; f; f = f->next) {
-    filtered = f->condition(nat->buffer, len);
-    if (filtered != len) {
-      if (nat->logging)
-	printf("nat: udp filtered "MOD_ZU" from %s => "MOD_ZU" to %s\n",
-	       len, b->out_name, filtered, b->in_name);
-      if (filtered == 0)
-	return 0;
-      len = filtered;
-    }
-  }
-
   m = su_send(b->in_socket, nat->buffer, n, 0);
 
   if (nat->logging)
@@ -924,72 +882,3 @@
 
   return 0;
 }
-
-LIST_BODIES(static, nat_filter, struct nat_filter, next, prev);
-
-struct args {
-  struct nat *nat;
-  struct nat_filter *f;
-  int outbound;
-};
-
-int execute_nat_filter_insert(void *_args)
-{
-  struct args *a = (struct args *)_args;
-  if (a->outbound)
-    nat_filter_insert(&a->nat->out_filters, a->f);
-  else
-    nat_filter_insert(&a->nat->in_filters, a->f);
-  return 0;
-}
-
-int execute_nat_filter_remove(void *_args)
-{
-  struct args *a = (struct args *)_args;
-  nat_filter_remove(a->f);
-  return 0;
-}
-
-struct nat_filter *test_nat_add_filter(struct nat *nat,
-				       size_t (*condition)(void *message,
-							   size_t len),
-				       int outbound)
-{
-  struct args a[1];
-
-  if (nat == NULL)
-    return su_seterrno(EFAULT), NULL;
-
-  a->nat = nat;
-  a->f = su_zalloc(nat->home, sizeof *a->f);
-  a->outbound = outbound;
-
-  if (a->f) {
-    a->f->condition = condition;
-    if (su_task_execute(su_clone_task(nat->clone),
-			execute_nat_filter_insert, a, NULL) < 0)
-      su_free(nat->home, a->f), a->f = NULL;
-  }
-
-  return a->f;
-}
-
-
-int test_nat_remove_filter(struct nat *nat,
-			   struct nat_filter *filter)
-{
-  struct args a[1];
-
-  if (nat == NULL)
-    return su_seterrno(EFAULT);
-
-  a->nat = nat;
-  a->f = filter;
-  
-  if (su_task_execute(su_clone_task(nat->clone),
-		      execute_nat_filter_remove, a, NULL) < 0)
-    return -1;
-
-  su_free(nat->home, filter);
-  return 0;
-}

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nat.h	Sat Feb 17 01:25:21 2007
@@ -31,7 +31,6 @@
 SOFIA_BEGIN_DECLS
 
 struct nat;
-struct nat_filter;
 
 struct nat *test_nat_create(su_root_t *, int family, 
 			    tag_type_t, tag_value_t, ...);
@@ -43,16 +42,6 @@
 
 int test_nat_flush(struct nat *nat);
 
-struct nat_filter *test_nat_add_filter(struct nat *nat,
-				       size_t (*condition)(void *message,
-							   size_t len),
-				       int outbound);
-
-enum { nat_inbound, nat_outbound };
-
-int test_nat_remove_filter(struct nat *nat,
-			   struct nat_filter *filter);
-
 /* Tags */
 
 /** If true, act as symmetric nat. */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c	Sat Feb 17 01:25:21 2007
@@ -72,29 +72,20 @@
 static char const options_usage[] =
   "   -v | --verbose    be verbose\n"
   "   -q | --quiet      be quiet\n"
-  "   -a | --abort      abort on error\n" 
   "   -s                use only single thread\n"
   "   -l level          set logging level (0 by default)\n"
   "   -e | --events     print nua events\n"
   "   -A                print nua events for A\n"
   "   -B                print nua events for B\n"
   "   -C                print nua events for C\n"
-  "   --log=a           log messages for A\n"
-  "   --log=b           log messages for B\n"
-  "   --log=c           log messages for C\n"
-  "   --log=proxy       log messages for proxy\n"
   "   --attach          print pid, wait for a debugger to be attached\n"
   "   --no-proxy        do not use internal proxy\n"
   "   --no-nat          do not use internal \"nat\"\n"
   "   --symmetric       run internal \"nat\" in symmetric mode\n"
   "   -N                print events from internal \"nat\"\n"
-  "   --loop            loop main tests for ever\n"
   "   --no-alarm        don't ask for guard ALARM\n"
   "   -p uri            specify uri of outbound proxy (implies --no-proxy)\n"
   "   --proxy-tests     run tests involving proxy, too\n"
-#if SU_HAVE_OSX_CF_API /* If compiled with CoreFoundation events */
-  "   --osx-runloop     use OSX CoreFoundation runloop instead of poll() loop\n"
-#endif
   "   -k                do not exit after first error\n"
   ;
 
@@ -108,7 +99,7 @@
 int main(int argc, char *argv[])
 {
   int retval = 0;
-  int i, o_quiet = 0, o_attach = 0, o_alarm = 1, o_loop = 0;
+  int i, o_quiet = 0, o_attach = 0, o_alarm = 1;
   int o_events_init = 0, o_events_a = 0, o_events_b = 0, o_events_c = 0;
   int o_iproxy = 1, o_inat = 1;
   int o_inat_symmetric = 0, o_inat_logging = 0, o_expensive = 0;
@@ -208,21 +199,6 @@
     else if (strcmp(argv[i], "--no-alarm") == 0) {
       o_alarm = 0;
     }
-    else if (strcmp(argv[i], "--loop") == 0) {
-      o_alarm = 0, o_loop = 1;
-    }
-    else if (strcmp(argv[i], "--log=a") == 0) {
-      ctx->a.logging = 1;
-    }
-    else if (strcmp(argv[i], "--log=b") == 0) {
-      ctx->b.logging = 1;
-    }
-    else if (strcmp(argv[i], "--log=c") == 0) {
-      ctx->c.logging = 1;
-    }
-    else if (strcmp(argv[i], "--log=proxy") == 0) {
-      ctx->proxy_logging = 1;
-    }
 #if SU_HAVE_OSX_CF_API /* If compiled with CoreFoundation events */
     else if (strcmp(argv[i], "--osx-runloop") == 0) {
       ctx->osx_runloop = 1;
@@ -234,10 +210,8 @@
     else if (argv[i][0] != '-') {
       break;
     }
-    else {
-      fprintf(stderr, "test_nua: unknown argument \"%s\"\n\n", argv[i]);
+    else
       usage(1);
-    }
   }
 
   if (o_attach) {
@@ -305,14 +279,14 @@
     if (retval == 0 && o_inat)
       retval |= test_nat_timeout(ctx);
 
-    while (retval == 0) {
+    if (retval == 0) {
+      retval |= test_extension(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_basic_call(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_reject_a(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_reject_b(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_reject_302(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_reject_401(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_mime_negotiation(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_call_timeouts(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_reject_401_aka(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_call_cancel(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_call_destroy(ctx); SINGLE_FAILURE_CHECK();
@@ -321,11 +295,8 @@
       retval |= test_session_timer(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_refer(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_100rel(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_events(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_simple(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_extension(ctx); SINGLE_FAILURE_CHECK();
-      if (!o_loop)
-	break;
+      retval |= test_events(ctx); SINGLE_FAILURE_CHECK();
     }
 
     if (ctx->proxy_tests && (retval == 0 || !ctx->p))

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h	Sat Feb 17 01:25:21 2007
@@ -126,14 +126,10 @@
   int threading, proxy_tests, expensive, quit_on_single_failure, osx_runloop;
   char const *external_proxy;
 
-  int proxy_logging;
-
   struct endpoint {
     char name[4];
     struct context *ctx;	/* Backpointer */
 
-    int logging;
-
     int running;
 
     condition_function *next_condition;
@@ -142,10 +138,6 @@
     sip_contact_t *contact;
     sip_from_t *to;
 
-    sip_allow_t *allow;
-    char const *appl_method;
-    sip_supported_t *supported;
-
     printer_function *printer;
 
     char const *instance;
@@ -166,11 +158,12 @@
     struct eventlist specials[1];
 
     /* State flags for complex scenarios */
-    struct {
+    union {
+      struct {
+	unsigned bit0:1, bit1:1, bit2:1, bit3:1;
+	unsigned bit4:1, bit5:1, bit6:1, bit7:1;
+      } b;
       unsigned n;
-      unsigned bit0:1, bit1:1, bit2:1, bit3:1;
-      unsigned bit4:1, bit5:1, bit6:1, bit7:1;
-      unsigned :0;
     } flags;
 
   } a, b, c;
@@ -192,9 +185,6 @@
 		       struct call *);
 void free_events_in_list(struct context *,
 			 struct eventlist *);
-void free_event_in_list(struct context *ctx,
-			struct eventlist *list,
-			struct event *e);
 
 #define CONDITION_PARAMS			\
   nua_event_t event,				\
@@ -214,9 +204,6 @@
 int until_terminated(CONDITION_PARAMS);
 int until_ready(CONDITION_PARAMS);
 int accept_call(CONDITION_PARAMS);
-int cancel_when_ringing(CONDITION_PARAMS);
-
-int accept_notify(CONDITION_PARAMS);
 
 void a_callback(nua_event_t event,
 		int status, char const *phrase,
@@ -334,7 +321,6 @@
 int test_reject_302(struct context *ctx);
 int test_reject_401(struct context *ctx);
 int test_mime_negotiation(struct context *ctx);
-int test_call_timeouts(struct context *ctx);
 int test_reject_401_aka(struct context *ctx);
 int test_call_cancel(struct context *ctx);
 int test_call_destroy(struct context *ctx);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c	Sat Feb 17 01:25:21 2007
@@ -117,12 +117,12 @@
   nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
   run_a_until(ctx, nua_r_get_params, save_until_final_response);
 
-  TEST_1(e = ctx->a.specials->head);
+  TEST_1(e = ctx->a.events->head);
   TEST_E(e->data->e_event, nua_r_get_params);
   for (n = 0, t = e->data->e_tags; t; n++, t = tl_next(t))
     ;
   TEST_1(n > 32);
-  free_events_in_list(ctx, ctx->a.specials);
+  free_events_in_list(ctx, ctx->a.events);
 
   nh = nua_handle(ctx->a.nua, NULL, TAG_END()); TEST_1(nh);
   nua_handle_unref(nh);
@@ -148,12 +148,9 @@
 
 		 SIPTAG_SUPPORTED_STR("test"),
 		 SIPTAG_ALLOW_STR("DWIM, OPTIONS, INFO"),
-		 NUTAG_APPL_METHOD(NULL),
-		 NUTAG_APPL_METHOD("INVITE, REGISTER, PUBLISH, SUBSCRIBE"),
 		 SIPTAG_ALLOW_EVENTS_STR("reg"),
 		 SIPTAG_USER_AGENT_STR("test_nua/1.0"),
 
-
 		 SIPTAG_ORGANIZATION_STR("Open Laboratory"),
 		 
 		 NUTAG_M_DISPLAY("XXX"),
@@ -214,13 +211,10 @@
 		 SIPTAG_ALLOW(sip_allow_make(tmphome, "INFO")),
 		 NUTAG_ALLOW("ACK, INFO"),
 
-		 NUTAG_APPL_METHOD("NOTIFY"),
-
 		 SIPTAG_ALLOW_EVENTS_STR("reg"),
 		 SIPTAG_ALLOW_EVENTS(sip_allow_events_make(tmphome, "presence")),
 		 NUTAG_ALLOW_EVENTS("presence.winfo"),
 
-
 		 SIPTAG_USER_AGENT(sip_user_agent_make(tmphome, "test_nua")),
 
 		 SIPTAG_ORGANIZATION(sip_organization_make(tmphome, "Pussy Galore's Flying Circus")),
@@ -274,7 +268,6 @@
 
     sip_allow_t const *allow = NONE;
     char const *allow_str = "NONE";
-    char const *appl_method = "NONE";
     sip_allow_events_t const *allow_events = NONE;
     char const *allow_events_str = "NONE";
     sip_supported_t const *supported = NONE;
@@ -298,7 +291,7 @@
     nua_get_params(ctx->a.nua, TAG_ANY(), TAG_END());
     run_a_until(ctx, nua_r_get_params, save_until_final_response);
 
-    TEST_1(e = ctx->a.specials->head);
+    TEST_1(e = ctx->a.events->head);
     TEST_E(e->data->e_event, nua_r_get_params);
 
     n = tl_gets(e->data->e_tags,
@@ -339,7 +332,6 @@
 	       	SIPTAG_SUPPORTED_STR_REF(supported_str),
 	       	SIPTAG_ALLOW_REF(allow),
 	       	SIPTAG_ALLOW_STR_REF(allow_str),
-		NUTAG_APPL_METHOD_REF(appl_method),
 		SIPTAG_ALLOW_EVENTS_REF(allow_events),
 		SIPTAG_ALLOW_EVENTS_STR_REF(allow_events_str),
 	       	SIPTAG_USER_AGENT_REF(user_agent),
@@ -361,7 +353,7 @@
 		NUTAG_INSTANCE_REF(instance),
 
 		TAG_END());
-    TEST(n, 47);
+    TEST(n, 46);
 
     TEST_S(sip_header_as_string(tmphome, (void *)from), Alice);
     TEST_S(from_str, Alice);
@@ -397,7 +389,6 @@
 
     TEST_S(sip_header_as_string(tmphome, (void *)allow), "OPTIONS, INFO, ACK");
     TEST_S(allow_str, "OPTIONS, INFO, ACK");
-    TEST_S(appl_method, "INVITE, REGISTER, PUBLISH, SUBSCRIBE, NOTIFY");
     TEST_S(sip_header_as_string(tmphome, (void *)allow_events), 
 	   "reg, presence, presence.winfo");
     TEST_S(allow_events_str, "reg, presence, presence.winfo");
@@ -423,7 +414,7 @@
     TEST_S(m_features, expect_m_features); }
     TEST_S(outbound, "foo");
 
-    free_events_in_list(ctx, ctx->a.specials);
+    free_events_in_list(ctx, ctx->a.events);
   }
 
   /* Test that only those tags that have been set per handle are returned by nua_get_hparams() */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c	Sat Feb 17 01:25:21 2007
@@ -44,7 +44,7 @@
 
 int save_events(CONDITION_PARAMS)
 {
-  return save_event_in_list(ctx, event, ep, call) == event_is_normal;
+  return save_event_in_list(ctx, event, ep, ep->call) == event_is_normal;
 }
 
 int until_final_response(CONDITION_PARAMS)
@@ -54,7 +54,7 @@
 
 int save_until_final_response(CONDITION_PARAMS)
 {
-  save_event_in_list(ctx, event, ep, call);
+  save_event_in_list(ctx, event, ep, ep->call);
   return event >= nua_r_set_params && status >= 200;
 }
 
@@ -64,13 +64,13 @@
  */
 int save_until_received(CONDITION_PARAMS)
 {
-  return save_event_in_list(ctx, event, ep, call) == event_is_normal;
+  return save_event_in_list(ctx, event, ep, ep->call) == event_is_normal;
 }
 
 /** Save events until nua_i_outbound is received.  */
 int save_until_special(CONDITION_PARAMS)
 {
-  return save_event_in_list(ctx, event, ep, call) == event_is_special;
+  return save_event_in_list(ctx, event, ep, ep->call) == event_is_special;
 }
 
 /* Return call state from event tag list */
@@ -143,49 +143,34 @@
 		 sip_t const *sip,
 		 tagi_t tags[])
 {
-  tagi_t const *t;
-
   if (event == nua_i_state) {
     fprintf(stderr, "%s.nua(%p): event %s %s\n",
-	    ep->name, (void *)nh, nua_event_name(event),
+	    ep->name, nh, nua_event_name(event),
 	    nua_callstate_name(callstate(tags)));
   }
   else if ((int)event >= nua_r_set_params) {
-    t = tl_find(tags, nutag_substate);
-    if (t) {
-      fprintf(stderr, "%s.nua(%p): event %s status %u %s (%s)\n",
-	      ep->name, (void*)nh, nua_event_name(event), status, phrase,
-	      nua_substate_name(t->t_value));
-    }
-    else {
-      fprintf(stderr, "%s.nua(%p): event %s status %u %s\n",
-	      ep->name, (void *)nh, nua_event_name(event), status, phrase);
-    }
-  }
-  else if (event == nua_i_notify) {
-    t = tl_find(tags, nutag_substate);
-    fprintf(stderr, "%s.nua(%p): event %s %s (%s)\n",
-	    ep->name, (void *)nh, nua_event_name(event), phrase,
-	    nua_substate_name(t ? t->t_value : 0));
+    fprintf(stderr, "%s.nua(%p): event %s status %u %s\n",
+	    ep->name, nh, nua_event_name(event), status, phrase);
   }
   else if ((int)event >= 0) {
     fprintf(stderr, "%s.nua(%p): event %s %s\n",
-	    ep->name, (void *)nh, nua_event_name(event), phrase);
+	    ep->name, nh, nua_event_name(event), phrase);
   }
   else if (status > 0) {
     fprintf(stderr, "%s.nua(%p): call %s() with status %u %s\n",
-	    ep->name, (void *)nh, operation, status, phrase);
+	    ep->name, nh, operation, status, phrase);
   }
   else {
+    tagi_t const *t;
     t = tl_find(tags, siptag_subject_str);
     if (t && t->t_value) {
       char const *subject = (char const *)t->t_value;
       fprintf(stderr, "%s.nua(%p): call %s() \"%s\"\n",
-	      ep->name, (void *)nh, operation, subject);
+	      ep->name, nh, operation, subject);
     }
     else
       fprintf(stderr, "%s.nua(%p): call %s()\n",
-	      ep->name, (void *)nh, operation);
+	      ep->name, nh, operation);
   }
 
   if ((tstflags & tst_verbatim) && tags)
@@ -217,11 +202,10 @@
     }
   }
 
-  if ((ep->next_condition == NULL ||
+  if ((ep->next_event == -1 || ep->next_event == event) &&
+      (ep->next_condition == NULL ||
        ep->next_condition(event, status, phrase,
-			  nua, ctx, ep, nh, call, sip, tags))
-      &&
-      (ep->next_event == -1 || ep->next_event == event))
+			  nua, ctx, ep, nh, call, sip, tags)))
     ep->running = 0;
 
   ep->last_event = event;
@@ -272,21 +256,21 @@
   a->last_event = -1;
   a->running = a_condition != NULL && a_condition != save_events;
   a->running |= a_event != -1;
-  memset(&a->flags, 0, sizeof a->flags);
+  a->flags.n = 0;
 
   b->next_event = b_event;
   b->next_condition = b_condition;
   b->last_event = -1;
   b->running = b_condition != NULL && b_condition != save_events;
   b->running |= b_event != -1;
-  memset(&b->flags, 0, sizeof b->flags);
+  b->flags.n = 0;
 
   c->next_event = c_event;
   c->next_condition = c_condition;
   c->last_event = -1;
   c->running = c_condition != NULL && c_condition != save_events;
   c->running |= c_event != -1;
-  memset(&c->flags, 0, sizeof c->flags);
+  c->flags.n = 0;
 
   for (; a->running || b->running || c->running;) {
     su_root_step(ctx->root, 1000);
@@ -395,7 +379,7 @@
   return 0;
 }
 
-/* Destroy a handle */
+/* Destroy an handle */
 int DESTROY(struct endpoint *ep,
 	    struct call *call,
 	    nua_handle_t *nh)
@@ -466,7 +450,7 @@
   return action;
 }
 
-/* Free nua events from endpoint list */
+/* Save nua event in endpoint list */
 void free_events_in_list(struct context *ctx,
 			 struct eventlist *list)
 {
@@ -482,21 +466,6 @@
   list->tail = &list->head;
 }
 
-void free_event_in_list(struct context *ctx,
-			struct eventlist *list,
-			struct event *e)
-{
-  if (e) {
-    if ((*e->prev = e->next))
-      e->next->prev = e->prev;
-    nua_destroy_event(e->saved_event);
-    su_free(ctx->home, e);
-
-    if (list->head == NULL)
-      list->tail = &list->head;
-  }
-}			      
-
 int is_special(nua_event_t e)
 {
   if (e == nua_i_active || e == nua_i_terminated)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_proxy.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_proxy.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_proxy.c	Sat Feb 17 01:25:21 2007
@@ -228,10 +228,9 @@
 				  URL_STRING_MAKE("sip:0.0.0.0:*"),
 				  NULL, NULL,
 				  NTATAG_UA(0),
-				  NTATAG_CANCEL_487(0),
 				  NTATAG_SERVER_RPORT(1),
 				  NTATAG_CLIENT_RPORT(1),
-				  TAG_NEXT(proxy->tags));
+				  TAG_END());
 
   proxy->transport_contacts = create_transport_contacts(proxy);
 
@@ -309,7 +308,7 @@
   free(proxy->tags);
 }
 
-/* Create test proxy object */
+/* Create tst proxy object */
 struct proxy *test_proxy_create(su_root_t *root,
 				tag_type_t tag, tag_value_t value, ...)
 {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_refer.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_refer.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_refer.c	Sat Feb 17 01:25:21 2007
@@ -43,22 +43,21 @@
 #define __func__ "test_call_hold"
 #endif
 
+int accept_call_immediately(CONDITION_PARAMS);
+
 /* ======================================================================== */
 /* NUA-9 tests: REFER */
 
-int test_refer0(struct context *ctx, char const *tests,
-		int refer_with_id, int notify_by_appl);
-
-int notify_until_terminated(CONDITION_PARAMS);
+int test_refer0(struct context *ctx, int refer_with_id, char const *tests);
+int test_refer1(struct context *ctx, int refer_with_id, char const *tests);
 
 int test_refer(struct context *ctx)
 {
   /* test twice, once without id and once with id */
   return
-    test_refer0(ctx, "NUA-9.1", 0, 0) ||
-    test_refer0(ctx, "NUA-9.2", 1, 0) ||
-    test_refer0(ctx, "NUA-9.3", 0, 1) ||
-    test_refer0(ctx, "NUA-9.4", 1, 1);
+    test_refer0(ctx, 0, "NUA-9.1") ||
+    test_refer0(ctx, 1, "NUA-9.2") ||
+    test_refer1(ctx, 0, "NUA-9.3");
 }
 
 /* Referred call:
@@ -104,15 +103,13 @@
 
 */
 
-int test_refer0(struct context *ctx, char const *tests,
-		int refer_with_id, int notify_by_appl)
+int test_refer0(struct context *ctx, int refer_with_id, char const *tests)
 {
   BEGIN();
 
   struct endpoint *a = &ctx->a,  *b = &ctx->b, *c = &ctx->c;
   struct call *a_call = a->call, *b_call = b->call, *c_call = c->call;
-  struct call *a_refer, *a_c2, *b_refer;
-  struct eventlist *a_revents, *b_revents;
+  struct call *a_c2;
   struct event *e;
   sip_t const *sip;
   sip_event_t const *a_event, *b_event;
@@ -127,10 +124,7 @@
   su_home_auto(tmphome, sizeof(tmphome));
 
   if (print_headings)
-    printf("TEST %s: REFER: refer A to C%s%s%s\n", tests,
-	   refer_with_id ? " with Event id" : "",
-	   refer_with_id && !notify_by_appl ? " and" : "",
-	   !notify_by_appl ? " nua generating the NOTIFYs" : "");
+    printf("TEST %s: REFER: refer A to C\n", tests);
 
   if (print_headings)
     printf("TEST %s.1: REFER: make a call between A and B\n", tests);
@@ -139,28 +133,6 @@
   nua_set_params(ctx->a.nua, NUTAG_REFER_WITH_ID(refer_with_id), TAG_END());
   run_a_until(ctx, nua_r_set_params, until_final_response);
 
-  if (refer_with_id) {
-    TEST_1(a_refer = calloc(1, (sizeof *a_refer) + (sizeof *a_refer->events)));
-    call_init(a_refer);
-    a_refer->events = (void *)(a_refer + 1);
-    eventlist_init(a_refer->events);
-
-    a_call->next = a_refer;
-    a_revents = a_refer->events;
-
-    TEST_1(b_refer = calloc(1, (sizeof *b_refer) + (sizeof *b_refer->events)));
-    call_init(b_refer);
-    b_refer->events = (void *)(b_refer + 1);
-    eventlist_init(b_refer->events);
-
-    b_call->next = b_refer;
-    b_revents = b_refer->events;
-  }
-  else {
-    a_refer = a_call, b_refer = b_call;
-    a_revents = a->events, b_revents = b->events;
-  }
-
   TEST_1(a_c2 = calloc(1, (sizeof *a_c2) + (sizeof *a_c2->events)));
   call_init(a_c2);
   a_c2->events = (void *)(a_c2 + 1);
@@ -226,7 +198,7 @@
     printf("TEST %s.1: PASSED\n", tests);
 
   /* ---------------------------------------------------------------------- */
-  /* REFER (initial NOTIFY is no more sent unless REFER creates a new dialog)
+  /* REFER (initial NOTIFY is no more sent)
    A                    B
    |<------REFER--------|
    |-------200 OK------>|
@@ -235,20 +207,13 @@
    */
 
   if (print_headings)
-    printf("TEST %s.2: B refers A to C\n", tests);
-
-  if (b_refer != b_call)
-    TEST_1(b_refer->nh = 
-	   nua_handle(b->nua, b_refer, SIPTAG_TO(a->to), TAG_END()));
+    printf("TEST %s.2: refer A to C\n", tests);
 
   *sip_refer_to_init(r0)->r_url = *c->contact->m_url;
   r0->r_url->url_headers = "subject=referred";
   r0->r_display = "C";
 
-  REFER(b, b_refer, b_refer->nh, SIPTAG_REFER_TO(r0),
-	TAG_IF(!ctx->proxy_tests && b_refer != b_call,
-	       NUTAG_URL(a->contact->m_url)),
-	TAG_END());
+  REFER(b, b_call, b_call->nh, SIPTAG_REFER_TO(r0), TAG_END());
   run_ab_until(ctx, -1, save_until_received,
 	       -1, save_until_final_response);
 
@@ -256,7 +221,7 @@
     Events in A:
     nua_i_refer
   */
-  TEST_1(e = a_revents->head); TEST_E(e->data->e_event, nua_i_refer);
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_refer);
   TEST(e->data->e_status, 202);
   a_event = NULL;
   TEST(tl_gets(e->data->e_tags,
@@ -268,12 +233,17 @@
   TEST_1(refer_to = sip_refer_to_dup(tmphome, sip->sip_refer_to));
   TEST_1(sip->sip_referred_by);
   TEST_1(referred_by = sip_referred_by_dup(tmphome, sip->sip_referred_by));
+  if (e->next) {
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+  TEST_1(!e->next);
+  }
+  free_events_in_list(ctx, a->events);
 
   /*
      Events in B after nua_refer():
      nua_r_refer
   */
-  TEST_1(e = b_revents->head); TEST_E(e->data->e_event, nua_r_refer);
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_refer);
   TEST(e->data->e_status, 100);
   TEST(tl_gets(e->data->e_tags,
 	       NUTAG_REFER_EVENT_REF(b_event),
@@ -284,32 +254,22 @@
   TEST(e->data->e_status, 202);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_SIZE(strtoul(b_event->o_id, NULL, 10), sip->sip_cseq->cs_seq);
-
-  if (a_refer != a_call) {
-    if (b_revents->head->next->next == NULL)
-      run_ab_until(ctx, -1, save_until_received, nua_i_notify, save_events);
-    else if (a_revents->head->next == NULL)
-      run_a_until(ctx, -1, save_until_received);
-
-    TEST_1(e = a_revents->head->next); TEST_E(e->data->e_event, nua_r_notify);
-    TEST_1(!e->next);
-
-    TEST_1(e = b_revents->head->next->next);
-    TEST_E(e->data->e_event, nua_i_notify);
-    TEST(e->data->e_status, 200);
-    TEST_1(sip = sip_object(e->data->e_msg));
-    TEST_1(sip->sip_event);
-    if (refer_with_id)
-      TEST_S(sip->sip_event->o_id, b_event->o_id);
-    TEST_1(sip->sip_subscription_state);
-    TEST_S(sip->sip_subscription_state->ss_substate, "pending");
-    TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
-    TEST_S(sip->sip_payload->pl_data, "SIP/2.0 100 Trying\r\n");
-    TEST_1(!e->next);
-  }
-
-  free_events_in_list(ctx, a_revents);
-  free_events_in_list(ctx, b_revents);
+#if 0
+  if (!e->next)
+    run_b_until(ctx, -1, save_until_received);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_event);
+  if (refer_with_id)
+    TEST_S(sip->sip_event->o_id, b_event->o_id);
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "pending");
+  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
+  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 100 Trying\r\n");
+  TEST_1(!e->next);
+#endif
+  free_events_in_list(ctx, b->events);
 
   if (print_headings)
     printf("TEST %s.2: PASSED\n", tests);
@@ -411,43 +371,42 @@
   *sip_to_init(to)->a_url = *refer_to->r_url;
   to->a_display = refer_to->r_display;
 
-  a_refer->next = a_c2;
+  a->call->next = a_c2;
 
   TEST_1(a_c2->nh = nua_handle(a->nua, a_c2, SIPTAG_TO(to), TAG_END()));
 
   INVITE(a, a_c2, a_c2->nh, /* NUTAG_URL(refer_to->r_url), */
-	 TAG_IF(!notify_by_appl, NUTAG_REFER_EVENT(a_event)),
-	 TAG_IF(!notify_by_appl, NUTAG_NOTIFY_REFER(a_refer->nh)),
+	 NUTAG_REFER_EVENT(a_event),
+	 NUTAG_NOTIFY_REFER(a_call->nh),
 	 SOATAG_USER_SDP_STR(a_c2->sdp),
 	 SIPTAG_REFERRED_BY(referred_by),
 	 TAG_END());
 
   run_abc_until(ctx,
-		-1, notify_by_appl ? notify_until_terminated : until_ready,
+		-1, until_ready,
 		-1, save_until_received,
-		-1, accept_call);
-
-  /* Wait until both NOTIFY has been responded */
-  while (a_revents->head == NULL || a_revents->head->next == NULL)
-    run_ab_until(ctx, -1, save_until_received, -1, save_events);
-  while (b_revents->head == NULL || b_revents->head->next == NULL)
-    run_ab_until(ctx, -1, save_events, -1, save_until_received);
+		-1, accept_call_immediately);
+  /* XXX - we should use accept_call instead of accept_call_immediately but
+     nua has a problem with automatically generated NOTIFYs:
+     3rd NOTIFY is not sent because 2nd is still in progress
+  */
 
   /* Client A transitions:
      INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2a+C4)-> READY: nua_r_invite, nua_i_state
+     nua_i_notify
+
+     XXX should be:
      CALLING -(C2+C4)-> PROCEEDING: nua_r_invite, nua_i_state
-     nua_r_notify
+     optional: nua_i_notify
      PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
-     nua_r_notify
+     nua_i_notify
+     optional: nua_i_notify
   */
   TEST_1(e = a_c2->events->head); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
   TEST_1(is_offer_sent(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
-  TEST(e->data->e_status, 180);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
   TEST(e->data->e_status, 200);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
@@ -455,32 +414,19 @@
   TEST_1(!e->next);
   free_events_in_list(ctx, a_c2->events);
 
-  TEST_1(e = a_revents->head); TEST_E(e->data->e_event, nua_r_notify);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
-  if (a_refer == a_call && notify_by_appl) {
-    free_event_in_list(ctx, a_revents, a_revents->head);
-    free_event_in_list(ctx, a_revents, a_revents->head);
-  }
-  else {
-    TEST_1(!e->next);
-    free_events_in_list(ctx, a_revents);
-  }
+  if (a->events->head == NULL)
+    run_a_until(ctx, -1, save_until_received);
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
 
   /*
      Events in B after nua_refer():
      nua_i_notify
   */
-  TEST_1(e = b_revents->head); TEST_E(e->data->e_event, nua_i_notify);
-  TEST(e->data->e_status, 200);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_subscription_state);
-  TEST_S(sip->sip_subscription_state->ss_substate, "active");
-  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
-  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 180 Ringing\r\n");
-  TEST_1(sip->sip_event);
-  if (refer_with_id)
-    TEST_S(sip->sip_event->o_id, b_event->o_id);
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+  if (b->events->head == NULL)
+    run_b_until(ctx, -1, save_until_received);
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
   TEST(e->data->e_status, 200);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(sip->sip_subscription_state);
@@ -490,20 +436,13 @@
   TEST_1(sip->sip_event);
   if (refer_with_id)
     TEST_S(sip->sip_event->o_id, b_event->o_id);
-  if (b_refer == b_call && notify_by_appl) {
-    free_event_in_list(ctx, b_revents, b_revents->head);
-    free_event_in_list(ctx, b_revents, b_revents->head);
-  }
-  else {
-    TEST_1(!e->next);
-    free_events_in_list(ctx, b_revents);
-  }
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
 
   /*
    C transitions:
    INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
-   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
-   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   RECEIVED -(S3b)-> COMPLETED: nua_respond(), nua_i_state
    COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
   */
   TEST_1(e = c->events->head); TEST_E(e->data->e_event, nua_i_invite);
@@ -512,8 +451,6 @@
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
-  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
   TEST_1(is_answer_sent(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
@@ -535,28 +472,20 @@
   if (print_headings)
     printf("TEST %s.5.1: terminate call between A and B\n", tests);
 
-  if (notify_by_appl) {
-    if (!a->events->head || !a->events->head->next)
-      run_ab_until(ctx, -1, until_terminated, -1, save_events);
-    if (!b->events->head || !b->events->head->next)
-      run_ab_until(ctx, -1, save_events, -1, until_terminated);
-  }
-  else {
-    BYE(a, a_call, a_call->nh, TAG_END());
-    run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
-  }
+  BYE(a, a_call, a_call->nh, TAG_END());
+  run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
 
   /*
-    Transitions of A:
-    READY --(T2)--> TERMINATING: nua_bye()
-    TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+   Transitions of A:
+   READY --(T2)--> TERMINATING: nua_bye()
+   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
   */
   TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(!e->next);
   free_events_in_list(ctx, a->events);
-  
+
   /* Transitions of B:
      READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
   */
@@ -611,20 +540,10 @@
   if (print_headings)
     printf("TEST %s.5.2: PASSED\n", tests);
 
-  nua_handle_destroy(c_call->nh), c_call->nh = NULL;
-
   nua_handle_destroy(a_c2->nh), a_c2->nh = NULL;
-  a_refer->next = NULL; free(a_c2);
+  a->call->next = NULL; free(a_c2);
 
-  if (a_refer != a_call) {
-    nua_handle_destroy(a_refer->nh), a_refer->nh = NULL;
-    a_call->next = NULL; free(a_refer);
-  }
-
-  if (b_refer != b_call) {
-    nua_handle_destroy(b_refer->nh), b_refer->nh = NULL;
-    b_call->next = NULL; free(b_refer);
-  }
+  nua_handle_destroy(c_call->nh), c_call->nh = NULL;
 
   if (print_headings)
     printf("TEST %s: PASSED\n", tests);
@@ -636,6 +555,40 @@
 
 
 /*
+ accept_call_immediately
+                      X
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |                    |
+ |<--------200--------|
+ |---------ACK------->|
+*/
+int accept_call_immediately(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_200_OK,
+	    TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
+	    TAG_END());
+    return 0;
+  case nua_callstate_ready:
+    return 1;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+/*
  X      INVITE
  |                    |
  |-----------------INVITE-------------------->|
@@ -657,31 +610,18 @@
   if (event == nua_r_invite) {
     sip_status_t *st = sip->sip_status;
     sip_payload_t *pl;
-    struct call *r_call;
-
-    if (!nua_handle_has_events(ep->call->nh))
-      r_call = ep->call->next;
-    else
-      r_call = ep->call;
-
-    assert(nua_handle_has_events(r_call->nh));
 
     pl = sip_payload_format(NULL, "SIP/2.0 %u %s\r\n", 
 			    st->st_status, st->st_phrase);
 
-    NOTIFY(ep, r_call, r_call->nh,
+    NOTIFY(ep, ep->call, ep->call->nh,
 	   SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 	   SIPTAG_PAYLOAD(pl),
-	   NUTAG_SUBSTATE(st->st_status >= 200
-			  ? nua_substate_terminated
-			  : nua_substate_active),
+	   TAG_IF(st->st_status >= 200,
+		  NUTAG_SUBSTATE(nua_substate_terminated)),
 	   TAG_END());
 
-    su_free(NULL, pl);
-
-    if (st->st_status >= 200)
-      BYE(ep, ep->call, ep->call->nh, TAG_END());
-
+    BYE(ep, ep->call, ep->call->nh, TAG_END());
     return 0;
   }
 
@@ -695,3 +635,392 @@
     return 0;
   }
 }
+
+/* Referred call - NOTIFY and BYE are overlapped
+
+   A			B
+   |			|
+   |-------INVITE------>|
+   |<----100 Trying-----|
+   |			|
+   |<----180 Ringing----|
+   |			|
+   |<------200 OK-------|
+   |--------ACK-------->|
+   |			|
+   |<------REFER--------|
+   |-------200 OK------>|			C
+  [|-------NOTIFY------>|]			|
+  [|<------200 OK-------|]			|
+   |			|			|
+   |			|			|
+   |<-----SUBSCRIBE-----|                       |
+   |-------200 OK------>|			|
+   |			|			|
+   |			|			|
+   |-----------------INVITE-------------------->|
+   |			|			|
+   |			|			|
+   |<------------------200----------------------|
+   |-------NOTIFY------>|			|
+   |--------BYE-------->|			|
+   |-------------------ACK--------------------->|
+   |<------200 OK-------|			|
+   |<------200 OK-------|			|
+   |			X			|
+   |			 			|
+   |-------------------BYE--------------------->|
+   |<------------------200----------------------|
+   |						|
+
+*/
+
+int test_refer1(struct context *ctx, int refer_with_id, char const *tests)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a,  *b = &ctx->b, *c = &ctx->c;
+  struct call *a_call = a->call, *b_call = b->call, *c_call = c->call;
+  struct call *a_c2;
+  struct event *e;
+  sip_t const *sip;
+  sip_event_t const *a_event, *b_event;
+  sip_refer_to_t const *refer_to;
+  sip_referred_by_t const *referred_by;
+
+  sip_refer_to_t r0[1];
+  sip_to_t to[1];
+
+  su_home_t tmphome[SU_HOME_AUTO_SIZE(16384)];
+
+  su_home_auto(tmphome, sizeof(tmphome));
+
+  if (print_headings)
+    printf("TEST %s: REFER: refer A to C\n", tests);
+
+  if (print_headings)
+    printf("TEST %s.1: REFER: make a call between A and B\n", tests);
+
+  /* Do (not) include id with first implicit Event: refer */
+  nua_set_params(ctx->a.nua, NUTAG_REFER_WITH_ID(refer_with_id), TAG_END());
+  run_a_until(ctx, nua_r_set_params, until_final_response);
+
+  TEST_1(a_c2 = calloc(1, (sizeof *a_c2) + (sizeof *a_c2->events)));
+  call_init(a_c2);
+  a_c2->events = (void *)(a_c2 + 1);
+  eventlist_init(a_c2->events);
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+  b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+  a_c2->sdp   = "m=audio 5012 RTP/AVP 8";
+  c_call->sdp = "m=audio 5014 RTP/AVP 0 8";
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+  INVITE(a, a_call, a_call->nh,
+	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+	 SOATAG_USER_SDP_STR(a_call->sdp),
+	 TAG_END());
+
+  run_ab_until(ctx, -1, until_ready, -1, accept_call);
+
+  /* Client transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
+     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 180);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
+   EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  if (print_headings)
+    printf("TEST %s.1: PASSED\n", tests);
+
+  /* ---------------------------------------------------------------------- */
+  /* REFER (initial NOTIFY is no more sent)
+   A                    B
+   |<------REFER--------|
+   |-------200 OK------>|
+  [|-------NOTIFY------>|]			|
+  [|<------200 OK-------|]			|
+   */
+
+  if (print_headings)
+    printf("TEST %s.2: refer A to C\n", tests);
+
+  *sip_refer_to_init(r0)->r_url = *c->contact->m_url;
+  r0->r_url->url_headers = "subject=referred";
+  r0->r_display = "C";
+
+  REFER(b, b_call, b_call->nh, SIPTAG_REFER_TO(r0), TAG_END());
+  run_ab_until(ctx, -1, save_until_received,
+	       -1, save_until_final_response);
+
+  /*
+    Events in A:
+    nua_i_refer
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_refer);
+  TEST(e->data->e_status, 202);
+  a_event = NULL;
+  TEST(tl_gets(e->data->e_tags,
+	       NUTAG_REFER_EVENT_REF(a_event),
+	       TAG_END()), 1);
+  TEST_1(a_event); TEST_1(a_event = sip_event_dup(tmphome, a_event));
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_refer_to);
+  TEST_1(refer_to = sip_refer_to_dup(tmphome, sip->sip_refer_to));
+  TEST_1(sip->sip_referred_by);
+  TEST_1(referred_by = sip_referred_by_dup(tmphome, sip->sip_referred_by));
+  if (e->next) {
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+  TEST_1(!e->next);
+  }
+  free_events_in_list(ctx, a->events);
+
+  /*
+     Events in B after nua_refer():
+     nua_r_refer
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_refer);
+  TEST(e->data->e_status, 100);
+  TEST(tl_gets(e->data->e_tags,
+	       NUTAG_REFER_EVENT_REF(b_event),
+	       TAG_END()), 1);
+  TEST_1(b_event); TEST_1(b_event->o_id);
+  TEST_1(b_event = sip_event_dup(tmphome, b_event));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_refer);
+  TEST(e->data->e_status, 202);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_SIZE(strtoul(b_event->o_id, NULL, 10), sip->sip_cseq->cs_seq);
+#if 0
+  if (!e->next)
+    run_b_until(ctx, -1, save_until_received);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_event);
+  if (refer_with_id)
+    TEST_S(sip->sip_event->o_id, b_event->o_id);
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "pending");
+  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
+  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 100 Trying\r\n");
+  TEST_1(!e->next);
+#endif
+  free_events_in_list(ctx, b->events);
+
+  if (print_headings)
+    printf("TEST %s.2: PASSED\n", tests);
+
+
+  /* ---------------------------------------------------------------------- */
+  /*
+   A                    B                       C
+   |			|			|
+   |-----------------INVITE-------------------->|
+   |			|			|
+  XXX			|			|
+   |			|			|
+   |<------------------200----------------------|
+   |-------NOTIFY------>|			|
+   |---------BYE------->|			|
+   |-------------------ACK--------------------->|
+   |<--------200--------|			|
+   |<------200 OK-------|			|
+   |                    X
+     */
+
+  if (print_headings)
+    printf("TEST %s.4: A invites C\n", tests);
+
+  *sip_to_init(to)->a_url = *refer_to->r_url;
+  to->a_display = refer_to->r_display;
+
+  a->call->next = a_c2;
+
+  TEST_1(a_c2->nh = nua_handle(a->nua, a_c2, SIPTAG_TO(to), TAG_END()));
+
+  INVITE(a, a_c2, a_c2->nh, /* NUTAG_URL(refer_to->r_url), */
+	 NUTAG_REFER_EVENT(a_event),
+	 /* NUTAG_NOTIFY_REFER(a_call->nh), */
+	 SOATAG_USER_SDP_STR(a_c2->sdp),
+	 SIPTAG_REFERRED_BY(referred_by),
+	 TAG_END());
+
+  run_abc_until(ctx,
+		-1, notify_until_terminated,
+		-1, until_terminated,
+		-1, accept_call_immediately);
+
+  /* XXX - we should use accept_call instead of accept_call_immediately but
+     nua has a problem with automatically generated NOTIFYs:
+     3rd NOTIFY is not sent because 2nd is still in progress
+  */
+
+  /* Client A transitions:
+     INIT -(C1)-> CALLING: nua_invite(), nua_i_state
+     CALLING -(C2a+C4)-> READY: nua_r_invite, nua_i_state
+     nua_r_notify
+
+     Transitions of first call:
+     READY --(T2)--> TERMINATING: nua_bye()
+     TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+
+     XXX should be:
+     CALLING -(C2+C4)-> PROCEEDING: nua_r_invite, nua_i_state
+     optional: nua_i_notify
+     PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
+     nua_i_notify
+     optional: nua_i_notify
+  */
+  TEST_1(e = a_c2->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(is_answer_recv(e->data->e_tags));
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a_c2->events);
+
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  free_events_in_list(ctx, a->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+  /*
+     Events in B after nua_refer():
+     nua_i_notify
+     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
+  */
+  if (b->events->head == NULL)
+    run_b_until(ctx, -1, save_until_received);
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
+  TEST(e->data->e_status, 200);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_subscription_state);
+  TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+  TEST_1(sip->sip_payload && sip->sip_payload->pl_data);
+  TEST_S(sip->sip_payload->pl_data, "SIP/2.0 200 OK\r\n");
+  TEST_1(sip->sip_event);
+  if (refer_with_id)
+    TEST_S(sip->sip_event->o_id, b_event->o_id);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  /*
+   C transitions:
+   INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
+   RECEIVED -(S3b)-> COMPLETED: nua_respond(), nua_i_state
+   COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
+  */
+  TEST_1(e = c->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
+  TEST_1(is_answer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, c->events);
+
+  if (print_headings)
+    printf("TEST %s.4: PASSED\n", tests);
+
+  /* ---------------------------------------------------------------------- */
+  /*
+   A                                            C
+   |-------------------BYE--------------------->|
+   |<------------------200----------------------|
+   */
+
+  if (print_headings)
+    printf("TEST %s.5.2: terminate call between A and C\n", tests);
+
+  BYE(a, a_c2, a_c2->nh, TAG_END());
+  run_abc_until(ctx, -1, until_terminated, -1, NULL, -1, until_terminated);
+
+  /*
+   Transitions of A:
+   READY --(T2)--> TERMINATING: nua_bye()
+   TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
+  */
+  TEST_1(e = a_c2->events->head); TEST_E(e->data->e_event, nua_r_bye);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, a_c2->events);
+
+  /* Transitions of B:
+     READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
+  */
+  TEST_1(e = c->events->head); TEST_E(e->data->e_event, nua_i_bye);
+  TEST(e->data->e_status, 200);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+  free_events_in_list(ctx, c->events);
+
+  if (print_headings)
+    printf("TEST %s.5.2: PASSED\n", tests);
+
+  nua_handle_destroy(a_c2->nh), a_c2->nh = NULL;
+  a->call->next = NULL; free(a_c2);
+
+  nua_handle_destroy(c_call->nh), c_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST %s: PASSED\n", tests);
+
+  su_home_deinit(tmphome);
+
+  END();
+}

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c	Sat Feb 17 01:25:21 2007
@@ -133,8 +133,6 @@
 	   NUTAG_KEEPALIVE(1000),
 	   NUTAG_M_DISPLAY("A&A"),
 	   NUTAG_M_USERNAME("a"),
-	   NUTAG_M_PARAMS("foo=bar"),
-	   NUTAG_M_FEATURES("q=0.9"),
 	   SIPTAG_CSEQ(cseq),
 	   TAG_END());
   run_a_until(ctx, -1, save_until_final_response);
@@ -144,7 +142,6 @@
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST(e->data->e_status, 401);
   TEST(sip->sip_status->st_status, 401);
-  /* Check that CSeq included in tags is actually used in the request */
   TEST(sip->sip_cseq->cs_seq, 13);
   TEST_1(!sip->sip_contact);
   TEST_1(!e->next);
@@ -163,8 +160,6 @@
     /* VC does not dig \" with TEST_S() */
   TEST_S(sip->sip_contact->m_display, expect_m_display); }
   TEST_S(sip->sip_contact->m_url->url_user, "a");
-  TEST_1(strstr(sip->sip_contact->m_url->url_params, "foo=bar"));
-  TEST_S(sip->sip_contact->m_q, "0.9");
   TEST(sip->sip_cseq->cs_seq, 14);
 
   if (ctx->nat) {
@@ -226,12 +221,8 @@
   TEST_1(c_reg->nh = nua_handle(c->nua, c_reg, TAG_END()));
 
   REGISTER(c, c_reg, c_reg->nh, SIPTAG_TO(c->to), 
-	   NUTAG_OUTBOUND(NULL),
 	   NUTAG_M_DISPLAY("C"),
 	   NUTAG_M_USERNAME("c"),
-	   NUTAG_M_PARAMS("c=1"),
-	   NUTAG_M_FEATURES("q=0.987;expires=5"),
-	   NUTAG_CALLEE_CAPS(1),
 	   SIPTAG_EXPIRES_STR("5"), /* Test 423 negotiation */
 	   TAG_END());
   run_abc_until(ctx, -1, save_events, -1, save_events, 
@@ -262,9 +253,6 @@
   TEST_1(sip->sip_contact);
   TEST_S(sip->sip_contact->m_display, "C");
   TEST_S(sip->sip_contact->m_url->url_user, "c");
-  TEST_1(strstr(sip->sip_contact->m_url->url_params, "c=1"));
-  TEST_S(sip->sip_contact->m_q, "0.987");
-  TEST_1(msg_header_find_param(sip->sip_contact->m_common, "methods="));
   TEST_1(!e->next);
   free_events_in_list(ctx, c->events);
 
@@ -361,7 +349,7 @@
   sip_t const *sip;
 
   if (print_headings)
-    printf("TEST NUA-2.6.1: REGISTER b to c\n");
+    printf("TEST NUA-2.3.2: REGISTER b to c\n");
 
   nua_set_params(ctx->c.nua,
 		 NUTAG_ALLOW("REGISTER"),
@@ -384,6 +372,9 @@
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(!sip->sip_contact);
 
+  if (print_headings)
+    printf("TEST NUA-2.6.1: PASSED\n");
+
   free_events_in_list(ctx, b->events);
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
@@ -397,7 +388,7 @@
   nua_handle_destroy(c_call->nh), c_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-2.6.1: PASSED\n");
+    printf("TEST NUA-2.3.4: PASSED\n");
 
   END();
 }
@@ -561,8 +552,7 @@
 
   BEGIN();
 
-  struct endpoint *a = &ctx->a,  *b = &ctx->b;
-  struct call *a_call = a->call, *b_call = b->call;
+  struct endpoint *a = &ctx->a,  *b = &ctx->b, *c = &ctx->c;
   struct event *e;
   sip_t const *sip;
 
@@ -596,38 +586,7 @@
   if (print_headings)
     printf("TEST NUA-2.5.1: PASSED\n");
   
-  if (print_headings)
-    printf("TEST NUA-2.5.2: OPTIONS from B to A\n");
-
-  TEST_1(b_call->nh = nua_handle(b->nua, b_call, SIPTAG_TO(a->to), TAG_END()));
-
-  OPTIONS(b, b_call, b_call->nh, TAG_END());
-
-  run_ab_until(ctx, -1, save_until_received,
-	       -1, save_until_final_response);
-
-  /* Client events: nua_options(), nua_r_options */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_options);
-  TEST(e->data->e_status, 200);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_allow); TEST_1(sip->sip_accept); TEST_1(sip->sip_supported);
-  /* TEST_1(sip->sip_content_type); */
-  /* TEST_1(sip->sip_payload); */
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, b->events);
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  /* Server events: nua_i_options */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_options);
-  TEST(e->data->e_status, 200);
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-2.5.2: PASSED\n");
+  (void)b; (void)c; (void)sip;
 
   END();
 }
@@ -699,7 +658,6 @@
   UNREGISTER(c, c->call, c->call->nh, SIPTAG_TO(c->to), 
 	     NUTAG_M_DISPLAY("C"),
 	     NUTAG_M_USERNAME("c"),
-	     NUTAG_M_PARAMS("c=1"),
 	     TAG_END());
   run_c_until(ctx, -1, save_until_final_response);
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c	Sat Feb 17 01:25:21 2007
@@ -43,8 +43,6 @@
 #define __func__ "test_simple"
 #endif
 
-extern int accept_request(CONDITION_PARAMS);
-
 int test_message(struct context *ctx)
 {
   BEGIN();
@@ -64,7 +62,7 @@
 
 */
   if (print_headings)
-    printf("TEST NUA-11.1.1: MESSAGE\n");
+    printf("TEST NUA-11.1: MESSAGE\n");
 
   if (ctx->proxy_tests)
     *url = *b->to->a_url;
@@ -78,7 +76,7 @@
 
   MESSAGE(a, a_call, a_call->nh,
 	  NUTAG_URL(url),
-	  SIPTAG_SUBJECT_STR("NUA-11.1.1"),
+	  SIPTAG_SUBJECT_STR("NUA-11.1"),
 	  SIPTAG_CONTENT_TYPE_STR("text/plain"),
 	  SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
 	  TAG_END());
@@ -100,64 +98,7 @@
   TEST(e->data->e_status, 200);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(sip->sip_subject && sip->sip_subject->g_string);
-  TEST_S(sip->sip_subject->g_string, "NUA-11.1.1");
-  TEST_1(sip->sip_organization);
-  TEST_S(sip->sip_organization->g_string, "United Testers");
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-
-  free_events_in_list(ctx, b->events);
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-11.1.1: PASSED\n");
-
-/* MESSAGE as application method
-
-   A			B
-   |-------MESSAGE----->|
-   |<-------202---------|
-   |			|
-*/
-
-  if (print_headings)
-    printf("TEST NUA-11.1.2: MESSAGE\n");
-
-  nua_set_params(b->nua, NUTAG_APPL_METHOD("MESSAGE"), TAG_END());
-  run_b_until(ctx, nua_r_set_params, until_final_response);
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, TAG_END()));
-
-  MESSAGE(a, a_call, a_call->nh,
-	  NUTAG_URL(url),
-	  SIPTAG_SUBJECT_STR("NUA-11.1.2"),
-	  SIPTAG_CONTENT_TYPE_STR("text/plain"),
-	  SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
-	  TAG_END());
-
-  run_ab_until(ctx, -1, save_until_final_response, -1, accept_request);
-
-  /* Client events:
-     nua_message(), nua_r_message
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_message);
-  TEST(e->data->e_status, 202);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip_user_agent(sip)); 
-  TEST_S(sip_user_agent(sip)->g_value, "007");
-  TEST_1(!e->next);
-
-  /*
-   Server events:
-   nua_i_message
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_message);
-  TEST(e->data->e_status, 100);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_subject && sip->sip_subject->g_string);
-  TEST_S(sip->sip_subject->g_string, "NUA-11.1.2");
+  TEST_S(sip->sip_subject->g_string, "NUA-11.1");
   TEST_1(sip->sip_organization);
   TEST_S(sip->sip_organization->g_string, "United Testers");
   TEST_1(!e->next);
@@ -169,7 +110,7 @@
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-11.1.2: PASSED\n");
+    printf("TEST NUA-11.1: PASSED\n");
 
 
 /* Message test
@@ -190,7 +131,7 @@
   MESSAGE(a, a_call, a_call->nh,
 	  /* We cannot reach us by using our contact! */
 	  NUTAG_URL(!ctx->p && !ctx->proxy_tests ? a->contact->m_url : NULL),
-	  SIPTAG_SUBJECT_STR("NUA-11.2"),
+	  SIPTAG_SUBJECT_STR("NUA-11.1b"),
 	  SIPTAG_CONTENT_TYPE_STR("text/plain"),
 	  SIPTAG_PAYLOAD_STR("Hello hellO!\n"),
 	  TAG_END());
@@ -200,18 +141,16 @@
   /* Events:
      nua_message(), nua_i_message, nua_r_message
   */
-  TEST_1(e = a->specials->head); TEST_E(e->data->e_event, nua_i_message);
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_message);
   TEST(e->data->e_status, 200);
   TEST_1(sip = sip_object(e->data->e_msg));
   TEST_1(sip->sip_subject && sip->sip_subject->g_string);
-  TEST_S(sip->sip_subject->g_string, "NUA-11.2");
-  TEST_1(!e->next);
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_message);
+  TEST_S(sip->sip_subject->g_string, "NUA-11.1b");
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_message);
   TEST(e->data->e_status, 200);
   TEST_1(!e->next);
 
   free_events_in_list(ctx, a->events);
-  free_events_in_list(ctx, a->specials);
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
 
   if (print_headings)
@@ -220,32 +159,12 @@
   END();
 }
 
-int accept_request(CONDITION_PARAMS)
-{
-  msg_t *with = nua_current_request(nua);
-  
-  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 0;
-
-  save_event_in_list(ctx, event, ep, call);
-
-  if (status < 200) {
-    RESPOND(ep, call, nh, SIP_202_ACCEPTED,
-	    NUTAG_WITH(with),
-	    SIPTAG_USER_AGENT_STR("007"),
-	    TAG_END());
-    return 1;
-  }
-
-  return 0;
-}
-
 int respond_with_etag(CONDITION_PARAMS)
 {
   msg_t *with = nua_current_request(nua);
 
   if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
-    return 1;
+    return 0;
 
   save_event_in_list(ctx, event, ep, call);
 
@@ -272,14 +191,6 @@
   }
 }
 
-static int close_handle(CONDITION_PARAMS)
-{
-  if (call->nh == nh)
-    call->nh = NULL;
-  nua_handle_destroy(nh);
-  return 1;
-}
-
 int test_publish(struct context *ctx)
 {
   BEGIN();
@@ -446,60 +357,8 @@
   nua_handle_destroy(a_call->nh), a_call->nh = NULL;
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  /* Let server close handle without responding to PUBLISH */ 
-  PUBLISH(a, a_call, a_call->nh,
-	  TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	  SIPTAG_EVENT_STR("presence"),
-	  SIPTAG_CONTENT_TYPE_STR("text/urllist"),
-	  SIPTAG_PAYLOAD_STR("sip:example.com\n"),
-	  TAG_END());
-
-  run_ab_until(ctx, -1, save_until_final_response, -1, close_handle);
-
-  /* Client events:
-     nua_publish(), nua_r_publish
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_publish);
-  TEST(e->data->e_status, 500);
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-
-  /* No Event header */
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  PUBLISH(a, a_call, a_call->nh,
-	  TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
-	  SIPTAG_CONTENT_TYPE_STR("text/urllist"),
-	  SIPTAG_PAYLOAD_STR("sip:example.com\n"),
-	  TAG_END());
-
-  run_ab_until(ctx, -1, save_until_final_response, -1, save_events);
-
-  /* Client events:
-     nua_publish(), nua_r_publish
-  */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_publish);
-  TEST(e->data->e_status, 489);
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-
-  /*
-   Server events: nothing
-  */
-  TEST_1(!b->events->head);
-
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-
   if (print_headings)
     printf("TEST NUA-11.3: PASSED\n");
-
   END();
 }
 
@@ -760,155 +619,14 @@
   END();
 }
 
-/* ---------------------------------------------------------------------- */
-/* Unsolicited NOTIFY */
-
-int accept_notify(CONDITION_PARAMS);
-
-int test_newsub_notify(struct context *ctx)
-{
-  BEGIN();
-
-  struct endpoint *a = &ctx->a,  *b = &ctx->b;
-  struct call *a_call = a->call, *b_call = b->call;
-  struct event *e;
-  sip_t const *sip;
-  tagi_t const *n_tags, *r_tags;
-
-  if (print_headings)
-    printf("TEST NUA-11.7.1: rejecting NOTIFY without subscription locally\n");
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  NOTIFY(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
-	 SIPTAG_SUBJECT_STR("NUA-11.7.1"),
-	 SIPTAG_EVENT_STR("message-summary"),
-	 SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
-	 SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
-	 TAG_END());
-
-  run_a_until(ctx, -1, save_until_final_response);
-
-  /* Client events:
-     nua_notify(), nua_r_notify
-  */
-  TEST_1(e = a->events->head);
-  TEST_E(e->data->e_event, nua_r_notify);
-  TEST(e->data->e_status, 481);
-  TEST_1(!e->data->e_msg);
-  TEST_1(!e->next);
-  free_events_in_list(ctx, a->events);
-
-  if (print_headings)
-    printf("TEST NUA-11.7.1: PASSED\n");
-
-  if (print_headings)
-    printf("TEST NUA-11.7.2: rejecting NOTIFY without subscription\n");
-
-  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
-
-  NOTIFY(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
-	 NUTAG_NEWSUB(1),
-	 SIPTAG_SUBJECT_STR("NUA-11.7.2"),
-	 SIPTAG_EVENT_STR("message-summary"),
-	 SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
-	 SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
-	 TAG_END());
-
-  run_a_until(ctx, -1, save_until_final_response);
-
-  /* Client events:
-     nua_notify(), nua_r_notify
-  */
-  TEST_1(e = a->events->head);
-  TEST_E(e->data->e_event, nua_r_notify);
-  TEST(e->data->e_status, 481);
-  TEST_1(e->data->e_msg);
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-
-  if (print_headings)
-    printf("TEST NUA-11.7.2: PASSED\n");
-
-  /* ---------------------------------------------------------------------- */
-
-  if (print_headings)
-    printf("TEST NUA-11.7.3: accept NOTIFY\n");
-
-  nua_set_params(b->nua, NUTAG_APPL_METHOD("NOTIFY"), TAG_END());
-  run_b_until(ctx, nua_r_set_params, until_final_response);
-
-  NOTIFY(a, a_call, a_call->nh,
-	 NUTAG_URL(b->contact->m_url),
-	 NUTAG_NEWSUB(1),
-	 SIPTAG_SUBJECT_STR("NUA-11.7.3"),
-	 SIPTAG_EVENT_STR("message-summary"),
-	 SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
-	 SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
-	 TAG_END());
-
-  run_ab_until(ctx, -1, save_until_final_response, -1, accept_notify);
-
-  /* Notifier events: nua_r_notify */
-  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
-  TEST(e->data->e_status, 200);
-  r_tags = e->data->e_tags;
-  TEST_1(tl_find(r_tags, nutag_substate));
-  TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
-
-  /* subscriber events:
-     nua_i_notify
-  */
-  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
-  TEST_1(sip = sip_object(e->data->e_msg));
-  TEST_1(sip->sip_subscription_state);
-  TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
-  n_tags = e->data->e_tags;
-  TEST_1(tl_find(n_tags, nutag_substate));
-  TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
-  TEST_1(!e->next);
-
-  free_events_in_list(ctx, a->events);
-  free_events_in_list(ctx, b->events);
-
-  if (print_headings)
-    printf("TEST NUA-11.7.3: PASSED\n");
-
-  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
-  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
-
-  if (print_headings)
-    printf("TEST NUA-11.6: PASSED\n");
-
-  END();
-}
-
-/**Terminate when received notify. 
- * Respond to NOTIFY with 200 OK if it has not been responded.
- * Save events (except nua_i_active or terminated).
- */
-int accept_notify(CONDITION_PARAMS)
-{
-  if (event == nua_i_notify && status < 200)
-    RESPOND(ep, call, nh, SIP_200_OK, 
-	    NUTAG_WITH_THIS(ep->nua),
-	    TAG_END());
-
-  save_event_in_list(ctx, event, ep, call);
-
-  return event == nua_i_notify;
-}
-
 /* ======================================================================== */
 /* Test simple methods: MESSAGE, PUBLISH, SUBSCRIBE/NOTIFY */
 
 int test_simple(struct context *ctx)
 {
   return
-    /* test_message(ctx)
-       || */ test_publish(ctx)
+    test_message(ctx)
+    || test_publish(ctx)
     || test_subscribe_notify(ctx)
-    || test_newsub_notify(ctx)
     ;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_sip_events.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_sip_events.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_sip_events.c	Sat Feb 17 01:25:21 2007
@@ -64,15 +64,15 @@
 int save_until_notified_and_responded(CONDITION_PARAMS)
 {
   save_event_in_list(ctx, event, ep, call);
-  if (event == nua_i_notify) ep->flags.bit0 = 1;
+  if (event == nua_i_notify) ep->flags.b.bit0 = 1;
   if (event == nua_r_subscribe || event == nua_r_unsubscribe) {
     if (status >= 300)
       return 1;
     else if (status >= 200)
-      ep->flags.bit1 = 1;
+      ep->flags.b.bit1 = 1;
   }
 
-  return ep->flags.bit0 && ep->flags.bit1;
+  return ep->flags.b.bit0 && ep->flags.b.bit1;
 }
 
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -58,5 +58,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 
@@ -81,12 +56,8 @@
 target_triplet = @target@
 check_PROGRAMS = torture_sdp$(EXEEXT) test_sdp$(EXEEXT)
 DIST_COMMON = README $(dist_noinst_SCRIPTS) \
-	$(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+	$(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/sdp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -139,7 +110,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -186,12 +156,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -235,7 +201,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -328,8 +293,7 @@
 			tests/message-9.sdp \
 			tests/message-10.sdp
 
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -355,14 +319,12 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -602,7 +564,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip $(distdir)/tests
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip $(distdir)/tests
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -753,92 +715,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -100,7 +100,7 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 MSG_PARSER_AWK = $(srcdir)/../msg/msg_parser.awk
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -21,36 +21,11 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SOURCES = $(libsip_la_SOURCES) test_date.c test_sip_msg.c torture_sip.c validator.c
+SOURCES = $(libsip_la_SOURCES) date_test.c test_sip_msg.c torture_sip.c validator.c
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
@@ -76,13 +51,9 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = torture_sip$(EXEEXT) test_sip_msg$(EXEEXT) \
-	validator$(EXEEXT) test_date$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+	validator$(EXEEXT) date_test$(EXEEXT)
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/sip
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -104,10 +75,10 @@
 	sip_refer.lo sip_session.lo sip_caller_prefs.lo sip_reason.lo \
 	sip_status.lo sip_time.lo sip_tag_class.lo $(am__objects_1)
 libsip_la_OBJECTS = $(am_libsip_la_OBJECTS)
-test_date_SOURCES = test_date.c
-test_date_OBJECTS = test_date.$(OBJEXT)
-test_date_LDADD = $(LDADD)
-test_date_DEPENDENCIES = libsip.la ../msg/libmsg.la ../bnf/libbnf.la \
+date_test_SOURCES = date_test.c
+date_test_OBJECTS = date_test.$(OBJEXT)
+date_test_LDADD = $(LDADD)
+date_test_DEPENDENCIES = libsip.la ../msg/libmsg.la ../bnf/libbnf.la \
 	../url/liburl.la ../su/libsu.la
 test_sip_msg_SOURCES = test_sip_msg.c
 test_sip_msg_OBJECTS = test_sip_msg.$(OBJEXT)
@@ -135,9 +106,9 @@
 CCLD = $(CC)
 LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(libsip_la_SOURCES) test_date.c test_sip_msg.c \
+SOURCES = $(libsip_la_SOURCES) date_test.c test_sip_msg.c \
 	torture_sip.c validator.c
-DIST_SOURCES = $(libsip_la_SOURCES) test_date.c test_sip_msg.c \
+DIST_SOURCES = $(libsip_la_SOURCES) date_test.c test_sip_msg.c \
 	torture_sip.c validator.c
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
@@ -152,7 +123,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -199,12 +169,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -248,7 +214,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -350,7 +315,7 @@
 
 torture_sip_LDFLAGS = -static
 test_sip_msg_LDFLAGS = -static
-test_date_LDFLAGS = -static
+date_test_LDFLAGS = -static
 
 # ----------------------------------------------------------------------
 # Install and distribution rules
@@ -380,8 +345,7 @@
 	tests/test35.txt tests/test36.txt tests/test37.txt tests/test38.txt  \
 	tests/test39.txt tests/test40.txt tests/test41.txt tests/test42.txt
 
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -407,15 +371,13 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Tests
 
-#TESTS = torture_sip run_test_sip_msg run_test_date
+#TESTS = torture_sip run_test_sip_msg run_date_test
 
-#dist_noinst_SCRIPTS = 	run_test_sip_msg run_test_date
+#dist_noinst_SCRIPTS = 	run_test_sip_msg run_date_test
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -427,7 +389,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -474,9 +436,9 @@
 	  echo " rm -f $$p $$f"; \
 	  rm -f $$p $$f ; \
 	done
-test_date$(EXEEXT): $(test_date_OBJECTS) $(test_date_DEPENDENCIES) 
-	@rm -f test_date$(EXEEXT)
-	$(LINK) $(test_date_LDFLAGS) $(test_date_OBJECTS) $(test_date_LDADD) $(LIBS)
+date_test$(EXEEXT): $(date_test_OBJECTS) $(date_test_DEPENDENCIES) 
+	@rm -f date_test$(EXEEXT)
+	$(LINK) $(date_test_LDFLAGS) $(date_test_OBJECTS) $(date_test_LDADD) $(LIBS)
 test_sip_msg$(EXEEXT): $(test_sip_msg_OBJECTS) $(test_sip_msg_DEPENDENCIES) 
 	@rm -f test_sip_msg$(EXEEXT)
 	$(LINK) $(test_sip_msg_LDFLAGS) $(test_sip_msg_OBJECTS) $(test_sip_msg_LDADD) $(LIBS)
@@ -493,6 +455,7 @@
 distclean-compile:
 	-rm -f *.tab.c
 
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/date_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sip_basic.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sip_caller_prefs.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sip_event.Plo at am__quote@
@@ -514,7 +477,6 @@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sip_tag_ref.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sip_time.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sip_util.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_date.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_sip_msg.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/torture_sip.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/validator.Po at am__quote@
@@ -618,7 +580,7 @@
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/images $(distdir)/sofia-sip $(distdir)/tests
+	$(mkdir_p) $(distdir)/.. $(distdir)/images $(distdir)/sofia-sip $(distdir)/tests
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -768,92 +730,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 #
 # Note: sip_bad_mask is used by nta to weed out bad messages
 #

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_basic.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_basic.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_basic.c	Sat Feb 17 01:25:21 2007
@@ -899,7 +899,7 @@
   sip_header_t *h;
 
   n = url_xtra(us->us_url);
-  h = sip_header_alloc(home, hc, n);    
+  h = sip_header_alloc(home, sip_to_class, n);    
 
   if (h) {
     sip_addr_t *a = h->sh_to;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra.c	Sat Feb 17 01:25:21 2007
@@ -757,8 +757,6 @@
 
 /* ====================================================================== */
 
-#if SU_HAVE_EXPERIMENTAL
-
 /**@SIP_HEADER sip_suppress_body_if_match Suppress-Body-If-Match Header
  *
  * The @b Suppress-Body-If-Match header field identifies a SIP event content
@@ -775,7 +773,7 @@
  *
  * @sa @RFC3265, draft-niemi-sip-subnot-etags-01.txt
  *
- * @EXP_1_12_5. Note that #sip_t does not contain @a
+ * @NEW_1_12_5. Note that #sip_t does not contain @a
  * sip_suppress_body_if_match field, but sip_suppress_body_if_match()
  * function should be used for accessing the @b Suppress-Body-If-Match
  * header structure.
@@ -841,7 +839,7 @@
  *
  * @sa @RFC3265, draft-niemi-sip-subnot-etag-01
  *
- * @EXP_1_12_5. Note that #sip_t does not contain @a
+ * @NEW_1_12_5. Note that #sip_t does not contain @a
  * sip_suppress_notify_if_match field, but sip_suppress_notify_if_match()
  * function should be used for accessing the @b Suppress-Notify-If-Match
  * header structure.
@@ -889,4 +887,4 @@
   return msg_generic_e(b, bsiz, h, f);
 }
 
-#endif
+

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra_headers.txt
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra_headers.txt	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_extra_headers.txt	Sat Feb 17 01:25:21 2007
@@ -4,15 +4,10 @@
 # The line format is: 
 # C-name @SINCE sip_t-like-comment
 #
-# Put all experimental things after EXPERIMENTAL HEADER LIST STARTS HERE...
-#
 #### EXTRA HEADER LIST STARTS HERE ####
 
-refer_sub @NEW_1_12_5 /**< Refer-Sub header */
-
-#### EXPERIMENTAL HEADER LIST STARTS HERE ####
-
-suppress_body_if_match @EXP_1_12_5 /**< Suppress-Body-If-Match header */
-suppress_notify_if_match @EXP_1_12_5 /**< Suppress-Notify-If-Match header */
+refer_sub @VERSION_1_12_5 /**< Refer-Sub header */
+suppress_body_if_match @VERSION_1_12_5 /**< Suppress-Body-If-Match header */
+suppress_notify_if_match @VERSION_1_12_5 /**< Suppress-Notify-If-Match header*/
 
 #### EXTRA HEADER LIST ENDS HERE ####

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_parser.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_parser.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_parser.c	Sat Feb 17 01:25:21 2007
@@ -60,9 +60,9 @@
 char const sip_version_2_0[] = "SIP/2.0";
 
 /** Default message class */
-extern msg_mclass_t const sip_mclass[];
+extern msg_mclass_t sip_mclass[];
 
-msg_mclass_t const *sip_default_mclass(void)
+msg_mclass_t *sip_default_mclass(void)
 {
   return sip_mclass;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_header.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_header.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_header.h	Sat Feb 17 01:25:21 2007
@@ -58,7 +58,7 @@
 SOFIA_BEGIN_DECLS
 
 /** Return built-in SIP parser object. */
-SOFIAPUBFUN msg_mclass_t const *sip_default_mclass(void);
+SOFIAPUBFUN msg_mclass_t *sip_default_mclass(void);
 
 /** Check that sip_t is a SIP structure (not RTSP or HTTP). @HIDE */
 #define sip_is_sip(sip) ((sip) && (sip)->sip_ident == SIP_PROTOCOL_TAG)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_date.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_date.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_date.c	Sat Feb 17 01:25:21 2007
@@ -33,8 +33,6 @@
  * @date Wed Mar 21 19:12:13 2001 ppessi
  */
 
-#include "config.h"
-
 #include <stdio.h>
 #include <sofia-sip/string0.h>
 #include <stddef.h>

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_sip_msg.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_sip_msg.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/test_sip_msg.c	Sat Feb 17 01:25:21 2007
@@ -65,7 +65,7 @@
   return *o != *n;
 }
 
-int test_msg_class(msg_mclass_t const *mc)
+int test_msg_class(msg_mclass_t *mc)
 {
   int i, j, N;
 
@@ -159,7 +159,7 @@
   int m, tcp;
   sip_t *sip;
   int exitcode = 0; 
-  msg_mclass_t const *sip_mclass = sip_default_mclass();
+  msg_mclass_t *sip_mclass = sip_default_mclass();
   msg_t *msg = msg_create(sip_mclass, MSG_FLG_EXTRACT_COPY);
   msg_iovec_t iovec[1];
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c	Sat Feb 17 01:25:21 2007
@@ -412,12 +412,7 @@
     TEST_1(sip_from_tag(home, f, "tag=jxahudsf") == 0);
     su_free(home, f);
 
-    TEST_1(f = sip_from_create(home, (void *)"<sip:joe at bar;tag=bar> (joe)"));
-    TEST_1(sip_is_from((sip_header_t*)f));
-    su_free(home, f);
-
     TEST_1(t = sip_to_create(home, (void *)"<sip:joe at bar;tag=bar> (joe)"));
-    TEST_1(sip_is_to((sip_header_t*)f));
     TEST_1(sip_to_tag(home, t, "tag=jxahudsf") == 0);
     TEST_S(t->a_tag, "jxahudsf");
     TEST(msg_header_replace_param(home, t->a_common, "tag=bar"), 1);
@@ -1658,11 +1653,7 @@
   TEST(count(sip->sip_content_type->c_common), 1);
   TEST(count(sip->sip_route->r_common), 0);
   TEST(count(sip->sip_record_route->r_common), 4);
-#if SU_HAVE_EXPERIMENTAL
   TEST(count(sip->sip_unknown->un_common), 2);
-#else
-  TEST(count(sip->sip_unknown->un_common), 4);
-#endif
   TEST(count(sip->sip_error->er_common), 1);
   TEST(count(sip->sip_max_forwards->mf_common), 1);
   TEST(count(sip->sip_min_expires->me_common), 1);
@@ -1676,7 +1667,6 @@
   TEST(sip->sip_max_forwards->mf_count, 12);
   TEST(sip->sip_min_expires->me_delta, 150);
 
-#if SU_HAVE_EXPERIMENTAL
   {
     sip_suppress_body_if_match_t *sbim;
     sip_suppress_notify_if_match_t *snim;
@@ -1693,7 +1683,6 @@
     TEST_SIZE(offsetof(msg_generic_t, g_value),
 	      offsetof(sip_suppress_notify_if_match_t, snim_tag));
   }
-#endif
 
   TEST_1(sip->sip_from->a_display);
   TEST_S(sip->sip_from->a_display, "h");

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/validator.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/validator.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/validator.c	Sat Feb 17 01:25:21 2007
@@ -180,7 +180,7 @@
     return path;
 }
 
-msg_mclass_t const *mclass = NULL;
+msg_mclass_t *mclass = NULL;
 
 int validate_file(int fd, char const *name, context_t *ctx);
 int validate_dump(char *, off_t, context_t *ctx);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -58,6 +58,6 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 TAG_DLL_FLAGS =		LIST=soa_tag_list
\ No newline at end of file

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(libsoa_la_SOURCES) test_soa.c
@@ -79,12 +54,8 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = test_soa$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/soa
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -133,7 +104,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -180,12 +150,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -229,7 +195,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -323,8 +288,7 @@
 # ----------------------------------------------------------------------
 # Install and distribution rules
 EXTRA_DIST = Doxyfile soa.docs $(BUILT_SOURCES)
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -350,8 +314,6 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -361,7 +323,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -596,7 +558,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -746,92 +708,6 @@
  ../sresolv/libsresolv.la ../stun/libstun.la ../su/libsu.la \
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
-
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c	Sat Feb 17 01:25:21 2007
@@ -167,7 +167,7 @@
   struct soa_namenode const *n;
   struct soa_namenode *e;
 
-  SU_DEBUG_9(("soa_add(%s%s%s, %p) called\n", NICE(name), (void *)actions));
+  SU_DEBUG_9(("soa_add(%s%s%s, %p) called\n", NICE(name), actions));
 
   if (name == NULL || actions == NULL)
     return su_seterrno(EFAULT);
@@ -227,7 +227,7 @@
   size_t namelen;
 
   SU_DEBUG_9(("soa_create(\"%s\", %p, %p) called\n",
-	      name ? name : "default", (void *)root, (void *)magic));
+	      name ? name : "default", root, magic));
 
   if (name && name[0]) {
     struct soa_namenode const *n;
@@ -276,7 +276,7 @@
 
   SU_DEBUG_9(("soa_clone(%s::%p, %p, %p) called\n",
 	      parent_ss ? parent_ss->ss_actions->soa_name : "",
-	      (void *)parent_ss, (void *)root, (void *)magic));
+	      parent_ss, root, magic));
 
   if (parent_ss == NULL || root == NULL)
     return (void)su_seterrno(EFAULT), NULL;
@@ -302,7 +302,7 @@
 soa_session_t *soa_session_ref(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_session_ref(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
   return su_home_ref(ss->ss_home);
 }
 
@@ -310,7 +310,7 @@
 void soa_session_unref(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_session_unref(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
   su_home_unref(ss->ss_home);
 }
 
@@ -350,7 +350,7 @@
 void soa_destroy(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_destroy(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss) {
     ss->ss_active = 0;
@@ -396,7 +396,7 @@
   int n;
 
   SU_DEBUG_9(("soa_set_params(%s::%p, ...) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss == NULL)
     return su_seterrno(EFAULT), -1;
@@ -606,7 +606,7 @@
   int n;
 
   SU_DEBUG_9(("soa_get_params(%s::%p, ...) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss == NULL)
     return su_seterrno(EFAULT), -1;
@@ -688,7 +688,7 @@
   tagi_t *params = NULL;
 
   SU_DEBUG_9(("soa_get_paramlist(%s::%p, ...) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss) {
     ta_start(ta, tag, value);
@@ -756,7 +756,7 @@
 			      char const **return_phrase)
 {
   SU_DEBUG_9(("soa_error_as_sip_response(%s::%p, ...) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss == NULL || ss->ss_status < 400 || ss->ss_status >= 700) {
     if (return_phrase)
@@ -777,7 +777,7 @@
   char *reason;
 
   SU_DEBUG_9(("soa_error_as_sip_reason(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss == NULL)
     return "SIP;cause=500;text=\"Internal Server Error\"";
@@ -832,8 +832,8 @@
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_capability_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss,
-	      (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
+	      ss ? ss->ss_actions->soa_name : "", ss,
+	      return_sdp, return_sdp_str, return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -878,7 +878,7 @@
 			   char const *str, issize_t len)
 {
   SU_DEBUG_9(("soa_set_capability_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)sdp, (void *)str, (ssize_t)len));
+	      ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
 
   return soa_set_sdp(ss, soa_capability_sdp_kind, sdp, str, len);
 }
@@ -964,8 +964,8 @@
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_user_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss,
-			  (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
+	      ss ? ss->ss_actions->soa_name : "", ss,
+	      return_sdp, return_sdp_str, return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -1036,7 +1036,7 @@
 		     char const *str, issize_t len)
 {
   SU_DEBUG_9(("soa_set_user_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)sdp, (void *)str, (ssize_t)len));
+	      ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
 
   return soa_set_sdp(ss, soa_user_sdp_kind, sdp, str, len);
 }
@@ -1081,8 +1081,8 @@
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_remote_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss,
-			  (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
+	      ss ? ss->ss_actions->soa_name : "", ss,
+	      return_sdp, return_sdp_str, return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -1155,7 +1155,7 @@
 		       char const *str, issize_t len)
 {
   SU_DEBUG_9(("soa_set_remote_sdp(%s::%p, %p, %p, "MOD_ZD") called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)sdp, (void *)str, (ssize_t)len));
+	      ss ? ss->ss_actions->soa_name : "", ss, sdp, str, (ssize_t)len));
 
   return soa_set_sdp(ss, soa_remote_sdp_kind, sdp, str, len);
 }
@@ -1198,7 +1198,7 @@
 int soa_clear_remote_sdp(soa_session_t *ss)
 {
   SU_DEBUG_9(("soa_clear_remote_sdp(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (!ss)
     return (void)su_seterrno(EFAULT), -1;
@@ -1253,8 +1253,8 @@
   char const *sdp_str;
 
   SU_DEBUG_9(("soa_get_local_sdp(%s::%p, [%p], [%p], [%p]) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss,
-			  (void *)return_sdp, (void *)return_sdp_str, (void *)return_len));
+	      ss ? ss->ss_actions->soa_name : "", ss,
+	      return_sdp, return_sdp_str, return_len));
 
   if (ss == NULL)
     return (void)su_seterrno(EFAULT), -1;
@@ -1286,7 +1286,7 @@
   int complete;
 
   SU_DEBUG_9(("soa_init_offer_answer(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (!ss)
     return 0;
@@ -1308,7 +1308,7 @@
 char **soa_media_features(soa_session_t *ss, int live, su_home_t *home)
 {
   SU_DEBUG_9(("soa_media_features(%s::%p, %u, %p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, live, (void *)home));
+	      ss ? ss->ss_actions->soa_name : "", ss, live, home));
 
   if (ss)
     return ss->ss_actions->soa_media_features(ss, live, home);
@@ -1324,7 +1324,7 @@
 char const * const * soa_sip_require(soa_session_t const *ss)
 {
   SU_DEBUG_9(("soa_sip_require(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss)
     return ss->ss_actions->soa_sip_require(ss);
@@ -1341,7 +1341,7 @@
 char const * const * soa_sip_supported(soa_session_t const *ss)
 {
   SU_DEBUG_9(("soa_sip_supported(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   if (ss)
     return ss->ss_actions->soa_sip_supported(ss);
@@ -1360,7 +1360,7 @@
 			    char const * const * require)
 {
   SU_DEBUG_9(("soa_remote_sip_features(%s::%p, %p, %p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, (void *)supported, (void *)require));
+	      ss ? ss->ss_actions->soa_name : "", ss, supported, require));
 
   if (ss)
     return ss->ss_actions->soa_remote_sip_features(ss, supported, require);
@@ -1405,8 +1405,8 @@
 		       int always,
 		       soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_generate_offer(%s::%p, %u) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, always));
+  SU_DEBUG_9(("soa_generate_offer(%s::%p, %u, %p) called\n",
+	      ss ? ss->ss_actions->soa_name : "", ss, always, completed));
 
   /** @ERROR EFAULT Bad address. */
   if (ss == NULL)
@@ -1493,8 +1493,8 @@
 int soa_generate_answer(soa_session_t *ss,
 			soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_generate_answer(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+  SU_DEBUG_9(("soa_generate_answer(%s::%p, %p) called\n",
+	      ss ? ss->ss_actions->soa_name : "", ss, completed));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1573,8 +1573,8 @@
 int soa_process_answer(soa_session_t *ss,
 		       soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_process_answer(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+  SU_DEBUG_9(("soa_process_answer(%s::%p, %p) called\n",
+	      ss ? ss->ss_actions->soa_name : "", ss, completed));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1654,8 +1654,8 @@
 int soa_process_reject(soa_session_t *ss,
 		       soa_callback_f *completed)
 {
-  SU_DEBUG_9(("soa_process_reject(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+  SU_DEBUG_9(("soa_process_reject(%s::%p, %p) called\n",
+	      ss ? ss->ss_actions->soa_name : "", ss, completed));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1711,7 +1711,7 @@
 int soa_activate(soa_session_t *ss, char const *option)
 {
   SU_DEBUG_9(("soa_activate(%s::%p, %s%s%s) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, NICE(option)));
+	      ss ? ss->ss_actions->soa_name : "", ss, NICE(option)));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1741,7 +1741,7 @@
 int soa_deactivate(soa_session_t *ss, char const *option)
 {
   SU_DEBUG_9(("soa_deactivate(%s::%p, %s%s%s) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss, NICE(option)));
+	      ss ? ss->ss_actions->soa_name : "", ss, NICE(option)));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)
@@ -1763,7 +1763,7 @@
 void soa_terminate(soa_session_t *ss, char const *option)
 {
   SU_DEBUG_9(("soa_terminate(%s::%p) called\n",
-	      ss ? ss->ss_actions->soa_name : "", (void *)ss));
+	      ss ? ss->ss_actions->soa_name : "", ss));
 
   /** @ERROR EFAULT Bad address as @a ss. */
   if (ss == NULL)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c	Sat Feb 17 01:25:21 2007
@@ -822,7 +822,7 @@
   sdp_mode_t recv_mode;
 
   SU_DEBUG_7(("soa_sdp_mode_set_is_needed(%p, %p, \"%s\"): called\n",
-	      (void *)session, (void *)remote, hold ? hold : ""));
+	      session, remote, hold ? hold : ""));
 
   if (!session )
     return 0;
@@ -865,7 +865,7 @@
   sdp_mode_t send_mode, recv_mode;
 
   SU_DEBUG_7(("soa_sdp_mode_set(%p, %p, \"%s\"): called\n",
-	      (void *)session, (void *)remote, hold ? hold : ""));
+	      session, remote, hold ? hold : ""));
 
   if (!session || !session->sdp_media)
     return 0;
@@ -928,8 +928,7 @@
 
   su_home_auto(tmphome, sizeof tmphome);
 
-  SU_DEBUG_7(("soa_static_offer_answer_action(%p, %s): called\n",
-	      (void *)ss, by));
+  SU_DEBUG_7(("soa_static_offer_answer_action(%p, %s): called\n", ss, by));
 
   if (user == NULL)
     return soa_set_status(ss, 500, "No session set by user");
@@ -955,8 +954,7 @@
   if (local == NULL) switch (action) {
   case generate_offer:
   case generate_answer:
-    SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
-		"generating local description"));
+    SU_DEBUG_7(("soa_static(%p, %s): generating local description\n", ss, by));
 
     local = local0;
     *local = *user, local->sdp_media = NULL;
@@ -989,7 +987,7 @@
       break;
     if (local != local0)
       *local0 = *local, local = local0;
-    SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by, 
+    SU_DEBUG_7(("soa_static(%p, %s): %s\n", ss, by, 
 		"upgrade with local description"));
     soa_sdp_upgrade(ss, tmphome, local, user, user);
     break;
@@ -1001,7 +999,7 @@
     if (1) {
       if (local != local0)
 	*local0 = *local, local = local0;
-      SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
+      SU_DEBUG_7(("soa_static(%p, %s): %s\n", ss, by,
 		  "upgrade with remote description"));
       soa_sdp_upgrade(ss, tmphome, local, user, remote);
     }
@@ -1034,8 +1032,7 @@
 	} while (0)
 	DUP_LOCAL(local);
       }
-      SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by, 
-		  "marking rejected media"));
+      SU_DEBUG_7(("soa_static(%p, %s): marking rejected media\n", ss, by));
       soa_sdp_reject(tmphome, local, remote);
     }
     break;
@@ -1068,7 +1065,7 @@
     if (ss->ss_local_remote_version == remote_version)
       break;
     if (1 /* We don't have good test for codecs */) {
-      SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
+      SU_DEBUG_7(("soa_static(%p, %s): %s\n", ss, by,
 		  "upgrade codecs with remote description"));
       if (local != local0) {
 	*local0 = *local, local = local0; 
@@ -1146,8 +1143,7 @@
       ss->ss_previous_remote_version = ss->ss_local_remote_version;
     }
 
-    SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
-		"storing local description"));
+    SU_DEBUG_7(("soa_static(%p, %s): storing local description\n", ss, by));
 
     /* Update the unparsed and pretty-printed descriptions  */
     if (soa_description_set(ss, ss->ss_local, local, NULL, 0) < 0) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -61,5 +61,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 
@@ -81,12 +56,8 @@
 target_triplet = @target@
 check_PROGRAMS = test_sresolv$(EXEEXT)
 DIST_COMMON = $(dist_noinst_DATA) $(nobase_include_sofia_HEADERS) \
-	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am \
-	ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+	$(srcdir)/../sofia.am $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/sresolv
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -136,7 +107,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -183,12 +153,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -232,7 +198,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = $(SHELL)
@@ -327,8 +292,7 @@
 	127.zone 194.2.188 3.f.f.e.1.2.0.0.3.0.1.2.c.0.0.0 example.com \
 	3.f.f.e.1.2.0.0.3.0.1.2.c.0.0.0.arpa
 
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -354,13 +318,11 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -595,7 +557,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-resolv $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-resolv $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -744,92 +706,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv	Sat Feb 17 01:25:21 2007
@@ -55,13 +55,8 @@
     done
 fi
 
-# No BIND 9, no fun
-{ type -p named >/dev/null &&
-  named -v | grep -q BIND.*9 
-} || {
-echo test_sresolv: there is no BIND 9 named in you path, skipping
-exit 77
-} 
+# No named, no fun
+type -p named >/dev/null || exit 77
 
 if eval $ipv6
 then

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	Sat Feb 17 01:25:21 2007
@@ -70,10 +70,6 @@
 #endif
 #endif
 
-#if HAVE_IPHLPAPI_H
-#include <iphlpapi.h>
-#endif
-
 #include <time.h>
 
 #include "sofia-resolv/sres.h"
@@ -927,8 +923,8 @@
   size_t dlen;
   
   char b[8];
-  SU_DEBUG_9(("sres_query(%p, %p, %s, \"%s\") called\n",
-			  (void *)res, (void *)context, sres_record_type(type, b), domain));
+  SU_DEBUG_9(("sres_query(%p, %p, %p, %s, \"%s\") called\n",
+	      res, callback, context, sres_record_type(type, b), domain));
 
   if (res == NULL || domain == NULL)
     return su_seterrno(EFAULT), (void *)NULL;
@@ -994,8 +990,8 @@
   unsigned dots; char const *dot;
   char b[8];
 
-  SU_DEBUG_9(("sres_search(%p, %p, %s, \"%s\") called\n",
-			  (void *)res, (void *)context, sres_record_type(type, b), domain));
+  SU_DEBUG_9(("sres_search(%p, %p, %p, %s, \"%s\") called\n",
+	      res, callback, context, sres_record_type(type, b), domain));
 
   if (res == NULL || domain == NULL)
     return su_seterrno(EFAULT), (void *)NULL;
@@ -1239,7 +1235,7 @@
   int i;
 
   SU_DEBUG_9(("sres_search_cached_answers(%p, %s, \"%s\") called\n",
-	      (void *)res, sres_record_type(type, rooted_domain), domain));
+	      res, sres_record_type(type, rooted_domain), domain));
 
   if (!res || !name)
     return su_seterrno(EFAULT), (void *)NULL;
@@ -1899,36 +1895,6 @@
 #define MAX_DATALEN           65535
 
 /**
- * Uses IP Helper IP to get DNS servers list.
- */
-static int sres_parse_win32_ip(sres_config_t *c)
-{
-  int ret = -1;
-
-#if HAVE_IPHLPAPI_H
-  DWORD dw;
-  su_home_t *home = c->c_home;
-  ULONG size = sizeof(FIXED_INFO);
-
-  do {
-    FIXED_INFO *info = (FIXED_INFO *)su_alloc(home, size);
-    dw = GetNetworkParams(info, &size);
-    if (dw == ERROR_SUCCESS) {
-      IP_ADDR_STRING* addr = &info->DnsServerList;
-      for (; addr; addr = addr->Next) {
-       SU_DEBUG_3(("Adding nameserver: %s\n", addr->IpAddress.String));
-       sres_parse_nameserver(c, addr->IpAddress.String);
-      }
-      ret = 0;
-    }
-    su_free(home, info);
-  } while (dw == ERROR_BUFFER_OVERFLOW);
-#endif
-
-  return ret;
-}
-
-/**
  * Parses name servers listed in registry key 'key+lpValueName'. The
  * key is expected to contain a whitespace separate list of
  * name server IP addresses.
@@ -2106,7 +2072,7 @@
 #if _WIN32    
     /* note: no 127.0.0.1 on win32 systems */
     /* on win32, query the registry for nameservers */
-    if (sres_parse_win32_ip(c) == 0 || sres_parse_win32_reg(c) == 0)
+    if (sres_parse_win32_reg(c) == 0) 
       /* success */;
     else
       /* now what? */;
@@ -2592,7 +2558,7 @@
 
   if (now == 0) time(&now);
 
-  SU_DEBUG_9(("sres_send_dns_query(%p, %p) called\n", (void *)res, (void *)q));
+  SU_DEBUG_9(("sres_send_dns_query(%p, %p) called\n", res, q));
 
   if (domain == NULL)
     return -1;
@@ -2679,7 +2645,7 @@
 
   SU_DEBUG_5(("%s(%p, %p) id=%u %s %s (to [%s]:%u)\n", 
 	      "sres_send_dns_query",
-	      (void *)res, (void *)q, id, sres_record_type(type, b), domain, 
+	      res, q, id, sres_record_type(type, b), domain, 
 	      dns->dns_name, 
 	      htons(((struct sockaddr_in *)dns->dns_addr)->sin_port)));
 
@@ -2797,7 +2763,7 @@
     }
 
     SU_DEBUG_5(("sres(q=%p): reporting errors for %u %s\n",
-		(void *)q, q->q_type, q->q_name));
+		q, q->q_type, q->q_name));
  
     sres_remove_query(q->q_res, q, 1);
     (q->q_callback)(q->q_context, q, answers);
@@ -2864,7 +2830,7 @@
   sres_server_t *dns;
 
   SU_DEBUG_9(("sres_resend_dns_query(%p, %p, %u) called\n",
-	      (void *)res, (void *)q, timeout));
+	      res, q, timeout));
   
   N = res->res_n_servers;
 
@@ -3032,8 +2998,7 @@
   int n;
   char info[128] = "";
 
-  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error",
-	      (void *)res, socket));
+  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error", res, socket));
 
   msg->msg_name = name, msg->msg_namelen = sizeof(name);
   msg->msg_iov = iov, msg->msg_iovlen = 1;
@@ -3146,8 +3111,7 @@
   int errcode = 0;
   socklen_t errorlen = sizeof(errcode);
 
-  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error",
-	      (void *)res, socket));
+  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_error", res, socket));
 
   getsockopt(socket, SOL_SOCKET, SO_ERROR, (void *)&errcode, &errorlen);
 
@@ -3239,8 +3203,7 @@
   struct sockaddr_storage from[1];
   socklen_t fromlen = sizeof from;
 
-  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_receive",
-	      (void *)res, socket));
+  SU_DEBUG_9(("%s(%p, %u) called\n", "sres_resolver_receive", res, socket));
 
   memset(m, 0, offsetof(sres_message_t, m_data)); 
   
@@ -3319,7 +3282,7 @@
 #endif
 
     SU_DEBUG_5(("sres_resolver_receive(%p, %p) id=%u (from [%s]:%u)\n", 
-		(void *)res, (void *)query, m->m_id, 
+		res, query, m->m_id, 
 		host, ntohs(((struct sockaddr_in *)from)->sin_port)));
   }
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c	Sat Feb 17 01:25:21 2007
@@ -86,13 +86,7 @@
 #elif HAVE_SELECT
   struct { sres_socket_t fd; } fds[SRES_MAX_NAMESERVERS];
 #else
-#warning No guaranteed wait mechanism!
-/* typedef struct os_specific su_wait_t; */
-struct _pollfd {
-  sres_socket_t fd;   /* file descriptor */
-  short events;     /* requested events */
-  short revents;    /* returned events */
-} fds[SRES_MAX_NAMESERVERS];
+#error No wait mechanism!
 #endif
   sres_record_t ***return_records;  
 };

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c	Sat Feb 17 01:25:21 2007
@@ -178,7 +178,7 @@
   *return_cached = NULL;
 
   SU_DEBUG_9(("%s(%p, %s, \"%s\") called\n", "sres_cache_get",
-	      (void *)cache, sres_record_type(type, b), domain));
+	      cache, sres_record_type(type, b), domain));
 
   hash = sres_hash_key(domain);
 
@@ -241,7 +241,7 @@
   UNLOCK(cache);
 
   SU_DEBUG_9(("%s(%p, %s, \"%s\") returned %d entries\n", "sres_cache_get", 
-	      (void *)cache, sres_record_type(type, b), domain, rr_count));
+	      cache, sres_record_type(type, b), domain, rr_count));
 
   *return_cached = result;
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sresolv.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sresolv.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sresolv.c	Sat Feb 17 01:25:21 2007
@@ -186,8 +186,8 @@
   int i, index = -1, error = 0;
   int N = SRES_MAX_NAMESERVERS;
 
-  SU_DEBUG_9(("sres_sofia_update(%p, %d, %d)\n",
-	      (void *)srs, (int)new_socket, (int)old_socket));
+  SU_DEBUG_9(("sres_sofia_update(%p, %d, %d)\n", srs, 
+	      (int)new_socket, (int)old_socket));
 
   if (srs == NULL)
     return 0;
@@ -297,7 +297,7 @@
   if (!srs)
     return su_seterrno(EINVAL);
 
-  if (sres_resolver_set_async(res, sres_sofia_update, srs, 1) == NULL)
+  if (sres_resolver_set_async(res, sres_sofia_update, srs, 1) < 0)
     return INVALID_SOCKET;
 
   if (srs->srs_socket != INVALID_SOCKET)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/test_sresolv.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/test_sresolv.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/test_sresolv.c	Sat Feb 17 01:25:21 2007
@@ -64,6 +64,7 @@
 #include <sofia-resolv/sres_async.h>
 #include <sofia-resolv/sres_record.h>
 
+#include <sofia-sip/su.h>
 #include <sofia-sip/su_alloc.h>
 
 #include <assert.h>
@@ -100,7 +101,7 @@
   sres_record_t  **result;
 
   int              timeout;
-  sres_socket_t    sink;
+  int              sink;
   int              sinkidx;
   char const      *sinkconf;
   
@@ -119,84 +120,6 @@
 
 static int tstflags = 0;
 
-#if HAVE_WINSOCK2_H
-
-/* Posix send() */
-static inline 
-ssize_t sres_send(sres_socket_t s, void *b, size_t length, int flags)
-{
-  if (length > INT_MAX)
-    length = INT_MAX;
-  return (ssize_t)send(s, b, (int)length, flags);
-}
-
-static inline 
-ssize_t sres_sendto(sres_socket_t s, void *b, size_t length, int flags,
-		    struct sockaddr const *sa, socklen_t salen)
-{
-  if (length > INT_MAX)
-    length = INT_MAX;
-  return (ssize_t)sendto(s, b, (int)length, flags, (void *)sa, (int)salen);
-}
-
-/* Posix recvfrom() */
-static inline 
-ssize_t sres_recvfrom(sres_socket_t s, void *buffer, size_t length, int flags,
-		      struct sockaddr *from, socklen_t *fromlen)
-{
-  int retval, ilen;
-
-  if (fromlen)
-    ilen = *fromlen;
-
-  if (length > INT_MAX)
-    length = INT_MAX;
-
-  retval = recvfrom(s, buffer, (int)length, flags, 
-		    (void *)from, fromlen ? &ilen : NULL);
-
-  if (fromlen)
-    *fromlen = ilen;
-
-  return (ssize_t)retval;
-}
-
-static sres_socket_t sres_socket(int af, int socktype, int protocol)
-{
-  return socket(af, socktype, protocol);
-}
-
-static inline
-int sres_close(sres_socket_t s)
-{
-  return closesocket(s);
-}
-
-#if !defined(IPPROTO_IPV6)
-#if HAVE_SIN6
-#include <tpipv6.h>
-#else
-#if !defined(__MINGW32__)
-struct sockaddr_storage {
-    short ss_family;
-    char ss_pad[126];
-};
-#endif
-#endif
-#endif
-#else
-
-#define sres_send(s,b,len,flags) send((s),(b),(len),(flags))
-#define sres_sendto(s,b,len,flags,a,alen) \
-  sendto((s),(b),(len),(flags),(a),(alen))
-#define sres_recvfrom(s,b,len,flags,a,alen) \
-  recvfrom((s),(b),(len),(flags),(a),(alen))
-#define sres_close(s) close((s))
-#define SOCKET_ERROR   (-1)
-#define INVALID_SOCKET ((sres_socket_t)-1)
-#define sres_socket(x,y,z) socket((x),(y),(z))
-#endif
-
 #if 1
 
 #if HAVE_POLL && 0
@@ -222,7 +145,7 @@
 int test_socket(sres_context_t *ctx)
 {
   int af;
-  sres_socket_t s1, s2, s3, s4;
+  su_sockeet_t s1, s2, s3, s4;
   struct sockaddr_storage a[1];
   struct sockaddr_storage a1[1], a2[1], a3[1], a4[1];
   struct sockaddr_in *sin = (void *)a;
@@ -237,10 +160,10 @@
   af = AF_INET;
 
   for (;;) {
-    TEST_1((s1 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
-    TEST_1((s2 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
-    TEST_1((s3 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
-    TEST_1((s4 = sres_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s1 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s2 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s3 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
+    TEST_1((s4 = su_socket(af, SOCK_DGRAM, 0)) != INVALID_SOCKET);
 
     TEST_1(setblocking(s1, 0) == 0);
     TEST_1(setblocking(s2, 0) == 0);
@@ -289,13 +212,13 @@
     TEST(connect(s2, sa4, a4len), 0);
     TEST(getsockname(s2, (struct sockaddr *)a2, &a2len), 0);
 
-    TEST(sres_sendto(s1, "foo", 3, 0, sa4, a4len), 3);
-    TEST(sres_recvfrom(s4, buf, sizeof buf, 0, sa, &alen), 3);
-    TEST(sres_sendto(s4, "bar", 3, 0, sa, alen), 3);
-    TEST(sres_recvfrom(s2, buf, sizeof buf, 0, sa, &alen), -1);
-    TEST(sres_recvfrom(s1, buf, sizeof buf, 0, sa, &alen), 3);
+    TEST(sendto(s1, "foo", 3, 0, sa4, a4len), 3);
+    TEST(recvfrom(s4, buf, sizeof buf, 0, sa, &alen), 3);
+    TEST(sendto(s4, "bar", 3, 0, sa, alen), 3);
+    TEST(recvfrom(s2, buf, sizeof buf, 0, sa, &alen), -1);
+    TEST(recvfrom(s1, buf, sizeof buf, 0, sa, &alen), 3);
 
-    sres_close(s1), sres_close(s2), sres_close(s3), sres_close(s4);
+    su_close(s1), su_close(s2), su_close(s3), su_close(s4);
 
     break;
   }
@@ -1433,15 +1356,14 @@
 {
   char *tmpdir = getenv("TMPDIR");
   char *template;
-  int fd;
-  sres_socket_t sink;
+  int fd, sink;
   struct sockaddr_in sin[1];
   socklen_t sinsize = sizeof sin;
   FILE *f;
   
   BEGIN();
 
-  sink = socket(AF_INET, SOCK_DGRAM, 0); TEST_1(sink != INVALID_SOCKET);
+  sink = socket(AF_INET, SOCK_DGRAM, 0); TEST_1(sink != -1);
   TEST(getsockname(sink, (struct sockaddr *)sin, &sinsize), 0);
   sin->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   TEST(bind(sink, (struct sockaddr *)sin, sinsize), 0);
@@ -1505,7 +1427,7 @@
   if (ctx->sinkidx)
     su_root_deregister(ctx->root, ctx->sinkidx);
   ctx->sinkidx = 0;
-  sres_close(ctx->sink), ctx->sink = INVALID_SOCKET;
+  su_close(ctx->sink), ctx->sink = -1;
 
   END();
 }
@@ -1530,7 +1452,7 @@
 
   result = sres_cached_answers(res, sres_type_a, domain);
 
-#if 0  /* Currently, we do not create error records */
+#if 0
   TEST_1(result); TEST_1(result[0] != NULL);
 
   rr_soa = result[0]->sr_soa;
@@ -1541,6 +1463,7 @@
 
   sres_free_answers(res, result);
 #else
+  /* Currently, we do not create error records */
   TEST_1(result == NULL);
 #endif
 
@@ -1618,12 +1541,12 @@
 /* Convert lowercase hex to binary */
 static
 void *hex2bin(char const *test_name,
-	      char const *hex1, char const *hex2, size_t *binsize)
+	      char const *hex1, char const *hex2, unsigned *binsize)
 {
   char output[2048];
   char *bin;
   char const *b;
-  size_t j;
+  int j;
 
   if (hex1 == NULL || binsize == NULL)
     return NULL;
@@ -1696,19 +1619,18 @@
 {
   sres_resolver_t *res = ctx->resolver;
   sres_query_t *q = NULL;
-  sres_socket_t c = ctx->sink;
+  int c = ctx->sink;
   struct sockaddr_storage ss[1];
   struct sockaddr *sa = (void *)ss;
-  socklen_t salen = sizeof ss;
+  socklen_t salen = sizeof ss, binlen;
   char *bin;
-  size_t i, binlen;
-  ssize_t n;
+  int i, n;
   char const *domain = "example.com";
   char query[512];
 
   BEGIN();
 
-  TEST_1(ctx->sink != INVALID_SOCKET && ctx->sink != (sres_socket_t)0);
+  TEST_1(ctx->sink != -1 && ctx->sink != 0);
 
   /* Prepare for test_answer() callback */
   sres_free_answers(ctx->resolver, ctx->result); 
@@ -1719,19 +1641,19 @@
   TEST_1(bin = hex2bin(__func__, hextest, NULL, &binlen));
 
   /* Send responses with one erroneus byte */
-  for (i = 1; i < binlen; i++) {
+  for (i = 1; i < (int)binlen; i++) {
     if (!q) {
       /* We got an error => make new query */
       TEST_1(q = sres_query(res, test_answer, ctx, /* Send query */
 				 sres_type_naptr, domain));
-      TEST_1((n = sres_recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
+      TEST_1((n = recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
       memcpy(bin, query, 2); /* Copy ID */
     }
     if (i != 1)
       bin[i] ^= 0xff;
     else
       bin[3] ^= SRES_FORMAT_ERR; /* format error -> EDNS0 failure */
-    n = sres_sendto(c, bin, binlen, 0, sa, salen);
+    n = sendto(c, bin, binlen, 0, sa, salen);
     if (i != 1)
       bin[i] ^= 0xff;
     else
@@ -1747,15 +1669,15 @@
   }
 
   /* Send runt responses */
-  for (i = 1; i <= binlen; i++) {
+  for (i = 1; i <= (int)binlen; i++) {
     if (!q) {
       /* We got an error => make new query */
       TEST_1(q = sres_query(res, test_answer, ctx, /* Send query */
 				 sres_type_naptr, domain));
-      TEST_1((n = sres_recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
+      TEST_1((n = recvfrom(c, query, sizeof query, 0, sa, &salen)) != -1);
       memcpy(bin, query, 2); /* Copy ID */
     }
-    n = sres_sendto(c, bin, i, 0, sa, salen);
+    n = sendto(c, bin, i, 0, sa, salen);
     if (n == -1)
       perror("sendto");
     while (!poll_sockets(ctx))
@@ -2016,12 +1938,12 @@
   }
 
   if (o_attach) {
-    char buf[8], *line;
+    char buf[8];
 
     fprintf(stderr, "test_sresolv: started with pid %u"
 	    " (press enter to continue)\n", getpid());
 
-    line = fgets(buf, sizeof buf, stdin); (void) line;
+    fgets(buf, sizeof buf, stdin);
   }
 #if HAVE_ALARM
   else if (o_alarm) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -58,6 +58,6 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 TAG_DLL_FLAGS =		LIST=stun_tag_list

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # General options
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 
@@ -81,12 +56,8 @@
 target_triplet = @target@
 bin_PROGRAMS = stunc$(EXEEXT)
 check_PROGRAMS = lookup_stun_server$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/stun
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -141,7 +112,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -188,12 +158,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -237,7 +203,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -326,8 +291,7 @@
 # ----------------------------------------------------------------------
 # Install and distribution rules
 EXTRA_DIST = Doxyfile stun.docs cert.pem key.pem
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -353,8 +317,6 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -364,7 +326,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -560,7 +522,7 @@
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -712,92 +674,6 @@
  ../sresolv/libsresolv.la ../stun/libstun.la ../su/libsu.la \
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
-
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c	Sat Feb 17 01:25:21 2007
@@ -57,7 +57,7 @@
 #include <ws2tcpip.h>
 #endif
 
-#if HAVE_OPENSSL
+#if defined(HAVE_OPENSSL)
 #include <openssl/opensslv.h>
 #endif
 
@@ -218,7 +218,7 @@
   stun_discovery_magic_t *sh_dns_pend_ctx;
   tagi_t             *sh_dns_pend_tags;
 
-#if HAVE_OPENSSL
+#if defined(HAVE_OPENSSL)
   SSL_CTX        *sh_ctx;           /**< SSL context for TLS */
   SSL            *sh_ssl;           /**< SSL handle for TLS */
 #else
@@ -316,7 +316,7 @@
 }
 
 
-#if HAVE_OPENSSL
+#if defined(HAVE_OPENSSL)
 char const stun_version[] = 
  "sofia-sip-stun using " OPENSSL_VERSION_TEXT;
 #else
@@ -325,9 +325,7 @@
 #endif
 
 static int do_action(stun_handle_t *sh, stun_msg_t *binding_response);
-#if HAVE_OPENSSL
 static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg);
-#endif
 static int process_binding_request(stun_request_t *req, stun_msg_t *binding_response);
 static stun_discovery_t *stun_discovery_create(stun_handle_t *sh,
 					       stun_action_t action,
@@ -351,11 +349,9 @@
 static void stun_sendto_timer_cb(su_root_magic_t *magic, 
 				 su_timer_t *t,
 				 su_timer_arg_t *arg);
-#if HAVE_OPENSSL
 static void stun_tls_connect_timer_cb(su_root_magic_t *magic, 
 				      su_timer_t *t,
 				      su_timer_arg_t *arg);
-#endif
 static void stun_test_lifetime_timer_cb(su_root_magic_t *magic, 
 					su_timer_t *t,
 					su_timer_arg_t *arg);
@@ -530,7 +526,7 @@
 			      stun_discovery_magic_t *magic,
 			      tag_type_t tag, tag_value_t value, ...)
 {
-#if HAVE_OPENSSL
+#if defined(HAVE_OPENSSL)
   int events = -1;
   int one, err = -1;
   su_wait_t wait[1] = { SU_WAIT_INIT };
@@ -1284,9 +1280,8 @@
  * Internal functions
  *******************************************************************/
 
-#if HAVE_OPENSSL
-static 
-int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
+#if defined(HAVE_OPENSSL)
+static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
 {
   stun_discovery_t *sd = arg;
   stun_handle_t *self = sd->sd_handle;
@@ -1303,7 +1298,7 @@
 
   enter;
 
-  SU_DEBUG_7(("%s(%p): events%s%s%s%s\n", __func__, (void *)self,
+  SU_DEBUG_7(("%s(%p): events%s%s%s%s\n", __func__, self,
 	      events & SU_WAIT_CONNECT ? " CONNECTED" : "",
 	      events & SU_WAIT_ERR     ? " ERR"       : "",
 	      events & SU_WAIT_IN      ? " IN"        : "",
@@ -1533,11 +1528,15 @@
 
   return 0;
 }
-
+#else
+static int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
+{
+  return 0;
+}
 #endif /* HAVE_OPENSSL */
 
 
-#if HAVE_OPENSSL
+#if defined(HAVE_OPENSSL)
 static void stun_tls_connect_timer_cb(su_root_magic_t *magic, 
 				      su_timer_t *t,
 				      su_timer_arg_t *arg)
@@ -1567,7 +1566,12 @@
 
   return;
 }
-
+#else
+static void stun_tls_connect_timer_cb(su_root_magic_t *magic, 
+				      su_timer_t *t,
+				      su_timer_arg_t *arg)
+{
+}
 #endif /* HAVE_OPENSSL */
 
 /** Compose a STUN message of the format defined by stun_msg_t
@@ -1660,7 +1664,7 @@
 
   enter;
 
-  SU_DEBUG_7(("%s(%p): events%s%s%s\n", __func__, (void *)self,
+  SU_DEBUG_7(("%s(%p): events%s%s%s\n", __func__, self,
 	      events & SU_WAIT_IN ? " IN" : "",
 	      events & SU_WAIT_OUT ? " OUT" : "",
 	      events & SU_WAIT_ERR ? " ERR" : ""));

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -77,10 +77,7 @@
 	su_alloc.c su_alloc_lock.c su_strdup.c su_sprintf.c \
 	su_strlst.c su_vector.c \
 	su_time.c su_time0.c \
-	su_wait.c su_root.c su_timer.c \
-	su_port.c  su_port.h \
-	su_base_port.c su_pthread_port.c su_socket_port.c \
-	su_poll_port.c su_epoll_port.c su_select_port.c \
+	su_wait.c su_root.c su_timer.c su_port.c su_port.h \
 	su_localinfo.c \
 	su_os_nw.c \
 	su_taglist.c su_tag.c su_tag_io.c \
@@ -91,10 +88,9 @@
 EXTRA_libsu_la_SOURCES = \
 			memmem.c strtoull.c strcasestr.c \
 			memspn.c memcspn.c memccpy.c \
-			inet_ntop.c inet_pton.c poll.c getopt.c \
-			su_tag_ref.c su_win32_port.c
+			inet_ntop.c inet_pton.c getopt.c \
+			su_tag_ref.c
 
-libsu_la_CFLAGS = 	$(AM_CFLAGS) $(SOFIA_CFLAGS)
 libsu_la_LIBADD = 	$(REPLACE_LIBADD)
 libsu_la_DEPENDENCIES = $(REPLACE_LIBADD)
 
@@ -120,4 +116,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -28,33 +28,8 @@
 # ----------------------------------------------------------------------
 # Build targets
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 
@@ -93,12 +68,8 @@
 	torture_su_timer$(EXEEXT) test_su$(EXEEXT) su_proxy$(EXEEXT) \
 	test_poll$(EXEEXT) $(am__EXEEXT_1)
 DIST_COMMON = $(am__nobase_include_sofia_HEADERS_DIST) \
-	$(dist_pkgdata_SCRIPTS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+	$(dist_pkgdata_SCRIPTS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/su
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -116,28 +87,18 @@
 am__libsu_la_SOURCES_DIST = su.c su_errno.c su_addrinfo.c su_alloc.c \
 	su_alloc_lock.c su_strdup.c su_sprintf.c su_strlst.c \
 	su_vector.c su_time.c su_time0.c su_wait.c su_root.c \
-	su_timer.c su_port.c su_port.h su_base_port.c \
-	su_pthread_port.c su_socket_port.c su_poll_port.c \
-	su_epoll_port.c su_select_port.c su_localinfo.c su_os_nw.c \
+	su_timer.c su_port.c su_port.h su_localinfo.c su_os_nw.c \
 	su_taglist.c su_tag.c su_tag_io.c su_log.c su_global_log.c \
 	su_default_log.c su_module_debug.h su_md5.c su_uniqueid.c \
 	su_bm.c su_osx_runloop.c
- at COREFOUNDATION_TRUE@am__objects_1 = libsu_la-su_osx_runloop.lo
-am_libsu_la_OBJECTS = libsu_la-su.lo libsu_la-su_errno.lo \
-	libsu_la-su_addrinfo.lo libsu_la-su_alloc.lo \
-	libsu_la-su_alloc_lock.lo libsu_la-su_strdup.lo \
-	libsu_la-su_sprintf.lo libsu_la-su_strlst.lo \
-	libsu_la-su_vector.lo libsu_la-su_time.lo libsu_la-su_time0.lo \
-	libsu_la-su_wait.lo libsu_la-su_root.lo libsu_la-su_timer.lo \
-	libsu_la-su_port.lo libsu_la-su_base_port.lo \
-	libsu_la-su_pthread_port.lo libsu_la-su_socket_port.lo \
-	libsu_la-su_poll_port.lo libsu_la-su_epoll_port.lo \
-	libsu_la-su_select_port.lo libsu_la-su_localinfo.lo \
-	libsu_la-su_os_nw.lo libsu_la-su_taglist.lo libsu_la-su_tag.lo \
-	libsu_la-su_tag_io.lo libsu_la-su_log.lo \
-	libsu_la-su_global_log.lo libsu_la-su_default_log.lo \
-	libsu_la-su_md5.lo libsu_la-su_uniqueid.lo libsu_la-su_bm.lo \
-	$(am__objects_1)
+ at COREFOUNDATION_TRUE@am__objects_1 = su_osx_runloop.lo
+am_libsu_la_OBJECTS = su.lo su_errno.lo su_addrinfo.lo su_alloc.lo \
+	su_alloc_lock.lo su_strdup.lo su_sprintf.lo su_strlst.lo \
+	su_vector.lo su_time.lo su_time0.lo su_wait.lo su_root.lo \
+	su_timer.lo su_port.lo su_localinfo.lo su_os_nw.lo \
+	su_taglist.lo su_tag.lo su_tag_io.lo su_log.lo \
+	su_global_log.lo su_default_log.lo su_md5.lo su_uniqueid.lo \
+	su_bm.lo $(am__objects_1)
 libsu_la_OBJECTS = $(am_libsu_la_OBJECTS)
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgdatadir)" \
 	"$(DESTDIR)$(include_sofiadir)" \
@@ -270,7 +231,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -317,12 +277,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -366,7 +322,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -474,10 +429,7 @@
 	su_alloc.c su_alloc_lock.c su_strdup.c su_sprintf.c \
 	su_strlst.c su_vector.c \
 	su_time.c su_time0.c \
-	su_wait.c su_root.c su_timer.c \
-	su_port.c  su_port.h \
-	su_base_port.c su_pthread_port.c su_socket_port.c \
-	su_poll_port.c su_epoll_port.c su_select_port.c \
+	su_wait.c su_root.c su_timer.c su_port.c su_port.h \
 	su_localinfo.c \
 	su_os_nw.c \
 	su_taglist.c su_tag.c su_tag_io.c \
@@ -487,10 +439,9 @@
 EXTRA_libsu_la_SOURCES = \
 			memmem.c strtoull.c strcasestr.c \
 			memspn.c memcspn.c memccpy.c \
-			inet_ntop.c inet_pton.c poll.c getopt.c \
-			su_tag_ref.c su_win32_port.c
+			inet_ntop.c inet_pton.c getopt.c \
+			su_tag_ref.c
 
-libsu_la_CFLAGS = $(AM_CFLAGS) $(SOFIA_CFLAGS)
 libsu_la_LIBADD = $(REPLACE_LIBADD)
 libsu_la_DEPENDENCIES = $(REPLACE_LIBADD)
 COVERAGE_INPUT = $(libsu_la_SOURCES) $(include_sofia_HEADERS)
@@ -506,8 +457,7 @@
 # ----------------------------------------------------------------------
 # Automake options
 AUTOMAKE_OPTIONS = foreign
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -533,14 +483,12 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -696,53 +644,45 @@
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/addrinfo.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-getopt.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-inet_ntop.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-inet_pton.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-memccpy.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-memcspn.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-memmem.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-memspn.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-poll.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-strcasestr.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-strtoull.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_addrinfo.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_alloc.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_alloc_lock.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_base_port.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_bm.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_default_log.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_epoll_port.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_errno.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_global_log.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_localinfo.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_log.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_md5.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_os_nw.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_osx_runloop.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_poll_port.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_port.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_pthread_port.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_root.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_select_port.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_socket_port.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_sprintf.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_strdup.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_strlst.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_tag.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_tag_io.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_tag_ref.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_taglist.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_time.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_time0.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_timer.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_uniqueid.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_vector.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_wait.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libsu_la-su_win32_port.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/getopt.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/inet_ntop.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/inet_pton.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/localinfo.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/memccpy.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/memcspn.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/memmem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/memspn.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/strcasestr.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/strtoull.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_addrinfo.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_alloc.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_alloc_lock.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_bm.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_default_log.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_errno.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_global_log.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_localinfo.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_log.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_md5.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_os_nw.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_osx_runloop.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_port.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_proxy.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_root.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_sprintf.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_strdup.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_strlst.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_tag.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_tag_io.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_tag_ref.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_taglist.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_time.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_time0.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_timer.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_uniqueid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_vector.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/su_wait.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_htable.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_memmem.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_poll.Po at am__quote@
@@ -780,321 +720,6 @@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
-libsu_la-su.lo: su.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su.Tpo" -c -o libsu_la-su.lo `test -f 'su.c' || echo '$(srcdir)/'`su.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su.Tpo" "$(DEPDIR)/libsu_la-su.Plo"; else rm -f "$(DEPDIR)/libsu_la-su.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su.c' object='libsu_la-su.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su.lo `test -f 'su.c' || echo '$(srcdir)/'`su.c
-
-libsu_la-su_errno.lo: su_errno.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_errno.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_errno.Tpo" -c -o libsu_la-su_errno.lo `test -f 'su_errno.c' || echo '$(srcdir)/'`su_errno.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_errno.Tpo" "$(DEPDIR)/libsu_la-su_errno.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_errno.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_errno.c' object='libsu_la-su_errno.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_errno.lo `test -f 'su_errno.c' || echo '$(srcdir)/'`su_errno.c
-
-libsu_la-su_addrinfo.lo: su_addrinfo.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_addrinfo.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_addrinfo.Tpo" -c -o libsu_la-su_addrinfo.lo `test -f 'su_addrinfo.c' || echo '$(srcdir)/'`su_addrinfo.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_addrinfo.Tpo" "$(DEPDIR)/libsu_la-su_addrinfo.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_addrinfo.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_addrinfo.c' object='libsu_la-su_addrinfo.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_addrinfo.lo `test -f 'su_addrinfo.c' || echo '$(srcdir)/'`su_addrinfo.c
-
-libsu_la-su_alloc.lo: su_alloc.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_alloc.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_alloc.Tpo" -c -o libsu_la-su_alloc.lo `test -f 'su_alloc.c' || echo '$(srcdir)/'`su_alloc.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_alloc.Tpo" "$(DEPDIR)/libsu_la-su_alloc.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_alloc.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_alloc.c' object='libsu_la-su_alloc.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_alloc.lo `test -f 'su_alloc.c' || echo '$(srcdir)/'`su_alloc.c
-
-libsu_la-su_alloc_lock.lo: su_alloc_lock.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_alloc_lock.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_alloc_lock.Tpo" -c -o libsu_la-su_alloc_lock.lo `test -f 'su_alloc_lock.c' || echo '$(srcdir)/'`su_alloc_lock.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_alloc_lock.Tpo" "$(DEPDIR)/libsu_la-su_alloc_lock.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_alloc_lock.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_alloc_lock.c' object='libsu_la-su_alloc_lock.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_alloc_lock.lo `test -f 'su_alloc_lock.c' || echo '$(srcdir)/'`su_alloc_lock.c
-
-libsu_la-su_strdup.lo: su_strdup.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_strdup.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_strdup.Tpo" -c -o libsu_la-su_strdup.lo `test -f 'su_strdup.c' || echo '$(srcdir)/'`su_strdup.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_strdup.Tpo" "$(DEPDIR)/libsu_la-su_strdup.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_strdup.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_strdup.c' object='libsu_la-su_strdup.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_strdup.lo `test -f 'su_strdup.c' || echo '$(srcdir)/'`su_strdup.c
-
-libsu_la-su_sprintf.lo: su_sprintf.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_sprintf.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_sprintf.Tpo" -c -o libsu_la-su_sprintf.lo `test -f 'su_sprintf.c' || echo '$(srcdir)/'`su_sprintf.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_sprintf.Tpo" "$(DEPDIR)/libsu_la-su_sprintf.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_sprintf.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_sprintf.c' object='libsu_la-su_sprintf.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_sprintf.lo `test -f 'su_sprintf.c' || echo '$(srcdir)/'`su_sprintf.c
-
-libsu_la-su_strlst.lo: su_strlst.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_strlst.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_strlst.Tpo" -c -o libsu_la-su_strlst.lo `test -f 'su_strlst.c' || echo '$(srcdir)/'`su_strlst.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_strlst.Tpo" "$(DEPDIR)/libsu_la-su_strlst.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_strlst.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_strlst.c' object='libsu_la-su_strlst.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_strlst.lo `test -f 'su_strlst.c' || echo '$(srcdir)/'`su_strlst.c
-
-libsu_la-su_vector.lo: su_vector.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_vector.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_vector.Tpo" -c -o libsu_la-su_vector.lo `test -f 'su_vector.c' || echo '$(srcdir)/'`su_vector.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_vector.Tpo" "$(DEPDIR)/libsu_la-su_vector.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_vector.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_vector.c' object='libsu_la-su_vector.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_vector.lo `test -f 'su_vector.c' || echo '$(srcdir)/'`su_vector.c
-
-libsu_la-su_time.lo: su_time.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_time.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_time.Tpo" -c -o libsu_la-su_time.lo `test -f 'su_time.c' || echo '$(srcdir)/'`su_time.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_time.Tpo" "$(DEPDIR)/libsu_la-su_time.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_time.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_time.c' object='libsu_la-su_time.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_time.lo `test -f 'su_time.c' || echo '$(srcdir)/'`su_time.c
-
-libsu_la-su_time0.lo: su_time0.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_time0.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_time0.Tpo" -c -o libsu_la-su_time0.lo `test -f 'su_time0.c' || echo '$(srcdir)/'`su_time0.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_time0.Tpo" "$(DEPDIR)/libsu_la-su_time0.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_time0.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_time0.c' object='libsu_la-su_time0.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_time0.lo `test -f 'su_time0.c' || echo '$(srcdir)/'`su_time0.c
-
-libsu_la-su_wait.lo: su_wait.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_wait.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_wait.Tpo" -c -o libsu_la-su_wait.lo `test -f 'su_wait.c' || echo '$(srcdir)/'`su_wait.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_wait.Tpo" "$(DEPDIR)/libsu_la-su_wait.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_wait.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_wait.c' object='libsu_la-su_wait.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_wait.lo `test -f 'su_wait.c' || echo '$(srcdir)/'`su_wait.c
-
-libsu_la-su_root.lo: su_root.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_root.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_root.Tpo" -c -o libsu_la-su_root.lo `test -f 'su_root.c' || echo '$(srcdir)/'`su_root.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_root.Tpo" "$(DEPDIR)/libsu_la-su_root.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_root.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_root.c' object='libsu_la-su_root.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_root.lo `test -f 'su_root.c' || echo '$(srcdir)/'`su_root.c
-
-libsu_la-su_timer.lo: su_timer.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_timer.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_timer.Tpo" -c -o libsu_la-su_timer.lo `test -f 'su_timer.c' || echo '$(srcdir)/'`su_timer.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_timer.Tpo" "$(DEPDIR)/libsu_la-su_timer.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_timer.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_timer.c' object='libsu_la-su_timer.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_timer.lo `test -f 'su_timer.c' || echo '$(srcdir)/'`su_timer.c
-
-libsu_la-su_port.lo: su_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_port.Tpo" -c -o libsu_la-su_port.lo `test -f 'su_port.c' || echo '$(srcdir)/'`su_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_port.Tpo" "$(DEPDIR)/libsu_la-su_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_port.c' object='libsu_la-su_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_port.lo `test -f 'su_port.c' || echo '$(srcdir)/'`su_port.c
-
-libsu_la-su_base_port.lo: su_base_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_base_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_base_port.Tpo" -c -o libsu_la-su_base_port.lo `test -f 'su_base_port.c' || echo '$(srcdir)/'`su_base_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_base_port.Tpo" "$(DEPDIR)/libsu_la-su_base_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_base_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_base_port.c' object='libsu_la-su_base_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_base_port.lo `test -f 'su_base_port.c' || echo '$(srcdir)/'`su_base_port.c
-
-libsu_la-su_pthread_port.lo: su_pthread_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_pthread_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_pthread_port.Tpo" -c -o libsu_la-su_pthread_port.lo `test -f 'su_pthread_port.c' || echo '$(srcdir)/'`su_pthread_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_pthread_port.Tpo" "$(DEPDIR)/libsu_la-su_pthread_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_pthread_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_pthread_port.c' object='libsu_la-su_pthread_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_pthread_port.lo `test -f 'su_pthread_port.c' || echo '$(srcdir)/'`su_pthread_port.c
-
-libsu_la-su_socket_port.lo: su_socket_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_socket_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_socket_port.Tpo" -c -o libsu_la-su_socket_port.lo `test -f 'su_socket_port.c' || echo '$(srcdir)/'`su_socket_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_socket_port.Tpo" "$(DEPDIR)/libsu_la-su_socket_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_socket_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_socket_port.c' object='libsu_la-su_socket_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_socket_port.lo `test -f 'su_socket_port.c' || echo '$(srcdir)/'`su_socket_port.c
-
-libsu_la-su_poll_port.lo: su_poll_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_poll_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_poll_port.Tpo" -c -o libsu_la-su_poll_port.lo `test -f 'su_poll_port.c' || echo '$(srcdir)/'`su_poll_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_poll_port.Tpo" "$(DEPDIR)/libsu_la-su_poll_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_poll_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_poll_port.c' object='libsu_la-su_poll_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_poll_port.lo `test -f 'su_poll_port.c' || echo '$(srcdir)/'`su_poll_port.c
-
-libsu_la-su_epoll_port.lo: su_epoll_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_epoll_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_epoll_port.Tpo" -c -o libsu_la-su_epoll_port.lo `test -f 'su_epoll_port.c' || echo '$(srcdir)/'`su_epoll_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_epoll_port.Tpo" "$(DEPDIR)/libsu_la-su_epoll_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_epoll_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_epoll_port.c' object='libsu_la-su_epoll_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_epoll_port.lo `test -f 'su_epoll_port.c' || echo '$(srcdir)/'`su_epoll_port.c
-
-libsu_la-su_select_port.lo: su_select_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_select_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_select_port.Tpo" -c -o libsu_la-su_select_port.lo `test -f 'su_select_port.c' || echo '$(srcdir)/'`su_select_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_select_port.Tpo" "$(DEPDIR)/libsu_la-su_select_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_select_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_select_port.c' object='libsu_la-su_select_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_select_port.lo `test -f 'su_select_port.c' || echo '$(srcdir)/'`su_select_port.c
-
-libsu_la-su_localinfo.lo: su_localinfo.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_localinfo.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_localinfo.Tpo" -c -o libsu_la-su_localinfo.lo `test -f 'su_localinfo.c' || echo '$(srcdir)/'`su_localinfo.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_localinfo.Tpo" "$(DEPDIR)/libsu_la-su_localinfo.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_localinfo.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_localinfo.c' object='libsu_la-su_localinfo.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_localinfo.lo `test -f 'su_localinfo.c' || echo '$(srcdir)/'`su_localinfo.c
-
-libsu_la-su_os_nw.lo: su_os_nw.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_os_nw.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_os_nw.Tpo" -c -o libsu_la-su_os_nw.lo `test -f 'su_os_nw.c' || echo '$(srcdir)/'`su_os_nw.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_os_nw.Tpo" "$(DEPDIR)/libsu_la-su_os_nw.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_os_nw.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_os_nw.c' object='libsu_la-su_os_nw.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_os_nw.lo `test -f 'su_os_nw.c' || echo '$(srcdir)/'`su_os_nw.c
-
-libsu_la-su_taglist.lo: su_taglist.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_taglist.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_taglist.Tpo" -c -o libsu_la-su_taglist.lo `test -f 'su_taglist.c' || echo '$(srcdir)/'`su_taglist.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_taglist.Tpo" "$(DEPDIR)/libsu_la-su_taglist.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_taglist.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_taglist.c' object='libsu_la-su_taglist.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_taglist.lo `test -f 'su_taglist.c' || echo '$(srcdir)/'`su_taglist.c
-
-libsu_la-su_tag.lo: su_tag.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_tag.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_tag.Tpo" -c -o libsu_la-su_tag.lo `test -f 'su_tag.c' || echo '$(srcdir)/'`su_tag.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_tag.Tpo" "$(DEPDIR)/libsu_la-su_tag.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_tag.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_tag.c' object='libsu_la-su_tag.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_tag.lo `test -f 'su_tag.c' || echo '$(srcdir)/'`su_tag.c
-
-libsu_la-su_tag_io.lo: su_tag_io.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_tag_io.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_tag_io.Tpo" -c -o libsu_la-su_tag_io.lo `test -f 'su_tag_io.c' || echo '$(srcdir)/'`su_tag_io.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_tag_io.Tpo" "$(DEPDIR)/libsu_la-su_tag_io.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_tag_io.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_tag_io.c' object='libsu_la-su_tag_io.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_tag_io.lo `test -f 'su_tag_io.c' || echo '$(srcdir)/'`su_tag_io.c
-
-libsu_la-su_log.lo: su_log.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_log.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_log.Tpo" -c -o libsu_la-su_log.lo `test -f 'su_log.c' || echo '$(srcdir)/'`su_log.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_log.Tpo" "$(DEPDIR)/libsu_la-su_log.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_log.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_log.c' object='libsu_la-su_log.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_log.lo `test -f 'su_log.c' || echo '$(srcdir)/'`su_log.c
-
-libsu_la-su_global_log.lo: su_global_log.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_global_log.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_global_log.Tpo" -c -o libsu_la-su_global_log.lo `test -f 'su_global_log.c' || echo '$(srcdir)/'`su_global_log.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_global_log.Tpo" "$(DEPDIR)/libsu_la-su_global_log.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_global_log.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_global_log.c' object='libsu_la-su_global_log.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_global_log.lo `test -f 'su_global_log.c' || echo '$(srcdir)/'`su_global_log.c
-
-libsu_la-su_default_log.lo: su_default_log.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_default_log.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_default_log.Tpo" -c -o libsu_la-su_default_log.lo `test -f 'su_default_log.c' || echo '$(srcdir)/'`su_default_log.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_default_log.Tpo" "$(DEPDIR)/libsu_la-su_default_log.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_default_log.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_default_log.c' object='libsu_la-su_default_log.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_default_log.lo `test -f 'su_default_log.c' || echo '$(srcdir)/'`su_default_log.c
-
-libsu_la-su_md5.lo: su_md5.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_md5.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_md5.Tpo" -c -o libsu_la-su_md5.lo `test -f 'su_md5.c' || echo '$(srcdir)/'`su_md5.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_md5.Tpo" "$(DEPDIR)/libsu_la-su_md5.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_md5.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_md5.c' object='libsu_la-su_md5.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_md5.lo `test -f 'su_md5.c' || echo '$(srcdir)/'`su_md5.c
-
-libsu_la-su_uniqueid.lo: su_uniqueid.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_uniqueid.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_uniqueid.Tpo" -c -o libsu_la-su_uniqueid.lo `test -f 'su_uniqueid.c' || echo '$(srcdir)/'`su_uniqueid.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_uniqueid.Tpo" "$(DEPDIR)/libsu_la-su_uniqueid.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_uniqueid.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_uniqueid.c' object='libsu_la-su_uniqueid.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_uniqueid.lo `test -f 'su_uniqueid.c' || echo '$(srcdir)/'`su_uniqueid.c
-
-libsu_la-su_bm.lo: su_bm.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_bm.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_bm.Tpo" -c -o libsu_la-su_bm.lo `test -f 'su_bm.c' || echo '$(srcdir)/'`su_bm.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_bm.Tpo" "$(DEPDIR)/libsu_la-su_bm.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_bm.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_bm.c' object='libsu_la-su_bm.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_bm.lo `test -f 'su_bm.c' || echo '$(srcdir)/'`su_bm.c
-
-libsu_la-su_osx_runloop.lo: su_osx_runloop.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_osx_runloop.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_osx_runloop.Tpo" -c -o libsu_la-su_osx_runloop.lo `test -f 'su_osx_runloop.c' || echo '$(srcdir)/'`su_osx_runloop.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_osx_runloop.Tpo" "$(DEPDIR)/libsu_la-su_osx_runloop.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_osx_runloop.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_osx_runloop.c' object='libsu_la-su_osx_runloop.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_osx_runloop.lo `test -f 'su_osx_runloop.c' || echo '$(srcdir)/'`su_osx_runloop.c
-
-libsu_la-memmem.lo: memmem.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-memmem.lo -MD -MP -MF "$(DEPDIR)/libsu_la-memmem.Tpo" -c -o libsu_la-memmem.lo `test -f 'memmem.c' || echo '$(srcdir)/'`memmem.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-memmem.Tpo" "$(DEPDIR)/libsu_la-memmem.Plo"; else rm -f "$(DEPDIR)/libsu_la-memmem.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='memmem.c' object='libsu_la-memmem.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-memmem.lo `test -f 'memmem.c' || echo '$(srcdir)/'`memmem.c
-
-libsu_la-strtoull.lo: strtoull.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-strtoull.lo -MD -MP -MF "$(DEPDIR)/libsu_la-strtoull.Tpo" -c -o libsu_la-strtoull.lo `test -f 'strtoull.c' || echo '$(srcdir)/'`strtoull.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-strtoull.Tpo" "$(DEPDIR)/libsu_la-strtoull.Plo"; else rm -f "$(DEPDIR)/libsu_la-strtoull.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='strtoull.c' object='libsu_la-strtoull.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-strtoull.lo `test -f 'strtoull.c' || echo '$(srcdir)/'`strtoull.c
-
-libsu_la-strcasestr.lo: strcasestr.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-strcasestr.lo -MD -MP -MF "$(DEPDIR)/libsu_la-strcasestr.Tpo" -c -o libsu_la-strcasestr.lo `test -f 'strcasestr.c' || echo '$(srcdir)/'`strcasestr.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-strcasestr.Tpo" "$(DEPDIR)/libsu_la-strcasestr.Plo"; else rm -f "$(DEPDIR)/libsu_la-strcasestr.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='strcasestr.c' object='libsu_la-strcasestr.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-strcasestr.lo `test -f 'strcasestr.c' || echo '$(srcdir)/'`strcasestr.c
-
-libsu_la-memspn.lo: memspn.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-memspn.lo -MD -MP -MF "$(DEPDIR)/libsu_la-memspn.Tpo" -c -o libsu_la-memspn.lo `test -f 'memspn.c' || echo '$(srcdir)/'`memspn.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-memspn.Tpo" "$(DEPDIR)/libsu_la-memspn.Plo"; else rm -f "$(DEPDIR)/libsu_la-memspn.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='memspn.c' object='libsu_la-memspn.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-memspn.lo `test -f 'memspn.c' || echo '$(srcdir)/'`memspn.c
-
-libsu_la-memcspn.lo: memcspn.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-memcspn.lo -MD -MP -MF "$(DEPDIR)/libsu_la-memcspn.Tpo" -c -o libsu_la-memcspn.lo `test -f 'memcspn.c' || echo '$(srcdir)/'`memcspn.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-memcspn.Tpo" "$(DEPDIR)/libsu_la-memcspn.Plo"; else rm -f "$(DEPDIR)/libsu_la-memcspn.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='memcspn.c' object='libsu_la-memcspn.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-memcspn.lo `test -f 'memcspn.c' || echo '$(srcdir)/'`memcspn.c
-
-libsu_la-memccpy.lo: memccpy.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-memccpy.lo -MD -MP -MF "$(DEPDIR)/libsu_la-memccpy.Tpo" -c -o libsu_la-memccpy.lo `test -f 'memccpy.c' || echo '$(srcdir)/'`memccpy.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-memccpy.Tpo" "$(DEPDIR)/libsu_la-memccpy.Plo"; else rm -f "$(DEPDIR)/libsu_la-memccpy.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='memccpy.c' object='libsu_la-memccpy.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-memccpy.lo `test -f 'memccpy.c' || echo '$(srcdir)/'`memccpy.c
-
-libsu_la-inet_ntop.lo: inet_ntop.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-inet_ntop.lo -MD -MP -MF "$(DEPDIR)/libsu_la-inet_ntop.Tpo" -c -o libsu_la-inet_ntop.lo `test -f 'inet_ntop.c' || echo '$(srcdir)/'`inet_ntop.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-inet_ntop.Tpo" "$(DEPDIR)/libsu_la-inet_ntop.Plo"; else rm -f "$(DEPDIR)/libsu_la-inet_ntop.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='inet_ntop.c' object='libsu_la-inet_ntop.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-inet_ntop.lo `test -f 'inet_ntop.c' || echo '$(srcdir)/'`inet_ntop.c
-
-libsu_la-inet_pton.lo: inet_pton.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-inet_pton.lo -MD -MP -MF "$(DEPDIR)/libsu_la-inet_pton.Tpo" -c -o libsu_la-inet_pton.lo `test -f 'inet_pton.c' || echo '$(srcdir)/'`inet_pton.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-inet_pton.Tpo" "$(DEPDIR)/libsu_la-inet_pton.Plo"; else rm -f "$(DEPDIR)/libsu_la-inet_pton.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='inet_pton.c' object='libsu_la-inet_pton.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-inet_pton.lo `test -f 'inet_pton.c' || echo '$(srcdir)/'`inet_pton.c
-
-libsu_la-poll.lo: poll.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-poll.lo -MD -MP -MF "$(DEPDIR)/libsu_la-poll.Tpo" -c -o libsu_la-poll.lo `test -f 'poll.c' || echo '$(srcdir)/'`poll.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-poll.Tpo" "$(DEPDIR)/libsu_la-poll.Plo"; else rm -f "$(DEPDIR)/libsu_la-poll.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='poll.c' object='libsu_la-poll.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-poll.lo `test -f 'poll.c' || echo '$(srcdir)/'`poll.c
-
-libsu_la-getopt.lo: getopt.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-getopt.lo -MD -MP -MF "$(DEPDIR)/libsu_la-getopt.Tpo" -c -o libsu_la-getopt.lo `test -f 'getopt.c' || echo '$(srcdir)/'`getopt.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-getopt.Tpo" "$(DEPDIR)/libsu_la-getopt.Plo"; else rm -f "$(DEPDIR)/libsu_la-getopt.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='getopt.c' object='libsu_la-getopt.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-getopt.lo `test -f 'getopt.c' || echo '$(srcdir)/'`getopt.c
-
-libsu_la-su_tag_ref.lo: su_tag_ref.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_tag_ref.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_tag_ref.Tpo" -c -o libsu_la-su_tag_ref.lo `test -f 'su_tag_ref.c' || echo '$(srcdir)/'`su_tag_ref.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_tag_ref.Tpo" "$(DEPDIR)/libsu_la-su_tag_ref.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_tag_ref.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_tag_ref.c' object='libsu_la-su_tag_ref.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_tag_ref.lo `test -f 'su_tag_ref.c' || echo '$(srcdir)/'`su_tag_ref.c
-
-libsu_la-su_win32_port.lo: su_win32_port.c
- at am__fastdepCC_TRUE@	if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -MT libsu_la-su_win32_port.lo -MD -MP -MF "$(DEPDIR)/libsu_la-su_win32_port.Tpo" -c -o libsu_la-su_win32_port.lo `test -f 'su_win32_port.c' || echo '$(srcdir)/'`su_win32_port.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libsu_la-su_win32_port.Tpo" "$(DEPDIR)/libsu_la-su_win32_port.Plo"; else rm -f "$(DEPDIR)/libsu_la-su_win32_port.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='su_win32_port.c' object='libsu_la-su_win32_port.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsu_la_CFLAGS) $(CFLAGS) -c -o libsu_la-su_win32_port.lo `test -f 'su_win32_port.c' || echo '$(srcdir)/'`su_win32_port.c
-
 mostlyclean-libtool:
 	-rm -f *.lo
 
@@ -1265,7 +890,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -1426,92 +1051,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/addrinfo.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/addrinfo.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/addrinfo.c	Sat Feb 17 01:25:21 2007
@@ -1,7 +1,7 @@
 /*
  * This file is part of the Sofia-SIP package
  *
- * Copyright (C) 2005,2007 Nokia Corporation.
+ * Copyright (C) 2005 Nokia Corporation.
  *
  * Contact: Pekka Pessi <pekka.pessi at nokia.com>
  *
@@ -26,13 +26,12 @@
  * 
  * @section synopsis Synopsis
  *
- * <tt>addrinfo [-pcn46] service-name host</tt>
+ * <tt>addrinfo [-pcn46] host service</tt>
  *
  * @section description Description
  * 
  * The @em addrinfo utility will use su_getaddrinfo() to resolve the network
- * services and print resolved names. See sect 6.1 of RFC3493 and the getaddrinfo(3)
- * manual page of POSIX 1003.1g, for more information.
+ * services and print resolved names.
  *
  * @section options Options
  *
@@ -57,7 +56,7 @@
  * Written by Pekka Pessi <pekka -dot pessi -at- nokia -dot- com>
  *
  * @section copyright Copyright
- * Copyright (C) 2005,2007 Nokia Corporation.
+ * Copyright (C) 2005 Nokia Corporation.
  *
  * This program is free software; see the source for copying conditions.
  * There is @b NO warranty; not even for @b MERCHANTABILITY or <b>FITNESS
@@ -73,7 +72,7 @@
 #include "sofia-sip/su.h"
 
 char const help[] =
-"usage: addrinfo [-pnc46] <servicename> <domainname>\n"
+"usage: addrinfo [-pnc46] [domainname]\n"
 "\t-p query for passive open\n"
 "\t-n use numeric host names\n"
 "\t-c ask for canonic names\n"

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/run_test_su
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/run_test_su	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/run_test_su	Sat Feb 17 01:25:21 2007
@@ -2,33 +2,18 @@
 
 rc=0
 
-run=no
-
-for SU_PORT in select epoll poll ; do
-
-export SU_PORT
-
-grep -q -i '^#define have_'$SU_PORT ../../config.h ||
-continue
-
-run=yes
-
 if $VALGRIND ./test_su ; then
-    echo PASS: multithread test_su with $SU_PORT
+    echo PASS: multithread test_su
 else
-    echo FAIL: multithread test_su with $SU_PORT failed
+    echo FAIL: multithread test_su failed
     rc=1
 fi
 
 if $VALGRIND ./test_su -s ; then
-    echo PASS: singlethread test_su with $SU_PORT
+    echo PASS: singlethread test_su
 else
-    echo FAIL: singlethread test_su with $SU_PORT failed
+    echo FAIL: singlethread test_su failed
     rc=1
 fi
 
-done
-
-test $run = no && exit 77
-
 exit $rc

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_bm.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_bm.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_bm.h	Sat Feb 17 01:25:21 2007
@@ -45,15 +45,15 @@
 
 SOFIAPUBFUN bm_fwd_table_t *bm_memmem_study(char const *needle, size_t nlen);
 
-SOFIAPUBFUN char *bm_memmem(char const *haystack, size_t hlen,
-			    char const *needle, size_t nlen,
-			    bm_fwd_table_t *fwd);
+SOFIAPUBFUN char const* bm_memmem(char const *haystack, size_t hlen,
+				  char const *needle, size_t nlen,
+				  bm_fwd_table_t *fwd);
 
 SOFIAPUBFUN bm_fwd_table_t *bm_memcasemem_study(char const *needle, size_t);
 
-SOFIAPUBFUN char *bm_memcasemem(char const *haystack, size_t hlen,
-				char const *needle, size_t nlen,
-				bm_fwd_table_t *fwd);
+SOFIAPUBFUN char const* bm_memcasemem(char const *haystack, size_t hlen,
+				      char const *needle, size_t nlen,
+				      bm_fwd_table_t *fwd);
 
 SOFIA_END_DECLS
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_configure.h.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_configure.h.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_configure.h.in	Sat Feb 17 01:25:21 2007
@@ -75,12 +75,6 @@
 /** Define as 1 if you have OSX CoreFoundation interface */
 #undef SU_HAVE_OSX_CF_API
 
-/** Define as 1 if you want to enable experimental features.
- *
- * Use --enable-experimental with ./configure
- */
-#undef SU_HAVE_EXPERIMENTAL
-
 /** Define as 1 if you have inline functions */
 #undef SU_HAVE_INLINE
 /** Define as suitable declarator inline functions */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_tag.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_tag.h	Sat Feb 17 01:25:21 2007
@@ -174,7 +174,7 @@
 #if SU_HAVE_INLINE
 su_inline tag_value_t tag_int_v(int v) { return (tag_value_t)v; }
 su_inline tag_value_t tag_int_vr(int *vp) { return (tag_value_t)vp; }
-su_inline tag_value_t tag_uint_v(unsigned v) { return (tag_value_t)v; }
+su_inline tag_value_t tag_uint_v(size_t v) { return (tag_value_t)v; }
 su_inline tag_value_t tag_uint_vr(unsigned *vp) { return (tag_value_t)vp; }
 su_inline tag_value_t tag_usize_v(usize_t v) { return (tag_value_t)v; }
 su_inline tag_value_t tag_usize_vr(usize_t *vp) { return (tag_value_t)vp; }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h	Sat Feb 17 01:25:21 2007
@@ -101,71 +101,35 @@
 #define SU_WAIT_MAX    (64)
 
 #else
-/* If nothing works, try these */
+#define SU_WAIT_CMP(x, y) 
+#define SU_WAIT_IN      
+#define SU_WAIT_OUT     
+#define SU_WAIT_ERR     
+#define SU_WAIT_HUP     
+#define SU_WAIT_ACCEPT  
+#define SU_WAIT_FOREVER 
+#define SU_WAIT_TIMEOUT 
 
-#define	POLLIN		0x001
-#define	POLLPRI		0x002
-#define	POLLOUT		0x004
-
-#ifdef __USE_XOPEN
-#define	POLLRDNORM	0x040
-#define	POLLRDBAND	0x080
-#define	POLLWRNORM	0x100
-#define	POLLWRBAND	0x200
-#endif
-
-/* These for pollfd.revents */
-#define POLLERR         0x008
-#define POLLHUP         0x010
-#define POLLNVAL        0x020
-
-#define SU_WAIT_CMP(x, y) \
- (((x).fd - (y).fd) ? ((x).fd - (y).fd) : ((x).events - (y).events))
-
-#define SU_WAIT_IN      POLLIN
-#define SU_WAIT_OUT     POLLOUT
-#define SU_WAIT_CONNECT POLLOUT
-#define SU_WAIT_ERR     POLLERR
-#define SU_WAIT_HUP     POLLHUP
-#define SU_WAIT_ACCEPT  POLLIN
-#define SU_WAIT_FOREVER (-1)
-#define SU_WAIT_TIMEOUT (-2)
-
-#define SU_WAIT_INIT    { INVALID_SOCKET, 0, 0 }
-
-/** Maximum number of sources supported by su_wait() */
-#define SU_WAIT_MAX    (0x7fffffff)
+#define SU_WAIT_INIT
 
 #endif
 
 /* ---------------------------------------------------------------------- */
 /* Types */
 
-/** Wait object. */
-#if SU_HAVE_POLL
+#if 0
+typedef struct _pollfd {
+  su_socket_t fd;           /* file descriptor */
+  short events;     /* requested events */
+  short revents;    /* returned events */
+} su_wait_t;
+#elif SU_HAVE_POLL
 typedef struct pollfd su_wait_t;
 #elif SU_HAVE_WINSOCK
 typedef HANDLE su_wait_t;
 #else
-/* typedef struct os_specific su_wait_t; */
-typedef struct pollfd su_wait_t;
-struct pollfd {
-  su_socket_t fd;   /* file descriptor */
-  short events;     /* requested events */
-  short revents;    /* returned events */
-};
-
-
-/* Type used for the number of file descriptors.  */
-typedef unsigned long int nfds_t;
-
-/* Poll the file descriptors described by the NFDS structures starting at
-   FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
-   an event to occur; if TIMEOUT is -1, block until an event occurs.
-   Returns the number of file descriptors with events, zero if timed out,
-   or -1 for errors.  */
-int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
-
+/** Wait object. */
+typedef struct os_specific su_wait_t;
 #endif
 
 /* Used by AD */
@@ -227,7 +191,7 @@
  */
 typedef SU_WAKEUP_ARG_T su_wakeup_arg_t;
 
-/** Wakeup callback function pointer type. 
+/** Wakeup callback function prototype. 
  *
  * Whenever a registered wait object receives an event, the @link
  * ::su_wakeup_f callback function @endlink is invoked.
@@ -352,13 +316,9 @@
 #define SU_MSG_R_INIT   { NULL }
 
 /** Message delivery function type. */
-typedef void su_msg_function(su_root_magic_t *magic, 
-			     su_msg_r msg,
-			     su_msg_arg_t *arg);
-
-/** Message delivery function pointer type. */
-typedef su_msg_function *su_msg_f;
-
+typedef void (*su_msg_f)(su_root_magic_t *magic, 
+			 su_msg_r msg,
+			 su_msg_arg_t *arg);
 
 /* ---------------------------------------------------------------------- */
 
@@ -390,7 +350,7 @@
 SOFIAPUBFUN int su_wait_events(su_wait_t *wait, su_socket_t s);
 SOFIAPUBFUN int su_wait_mask(su_wait_t *dst, su_socket_t s, int events);
 
-#if !HAVE_WIN32 && (SU_HAVE_POLL || HAVE_SELECT)
+#if SU_HAVE_POLL
 static inline
 su_socket_t su_wait_socket(su_wait_t *wait)
 {
@@ -512,31 +472,6 @@
 SOFIAPUBFUN int su_clone_pause(su_clone_r);
 SOFIAPUBFUN int su_clone_resume(su_clone_r);
 
-/* ---------------------------------------------------------------------- */
-/* Different su_root_t implementations */
-
-typedef su_port_t *su_port_create_f(void);
-typedef int su_clone_start_f(su_root_t *parent,
-			    su_clone_r return_clone,
-			    su_root_magic_t *magic,
-			    su_root_init_f init,
-			    su_root_deinit_f deinit);
-
-SOFIAPUBFUN void su_port_prefer(su_port_create_f *f, su_clone_start_f *);
-
-SOFIAPUBFUN su_port_create_f su_default_port_create;
-SOFIAPUBFUN su_port_create_f su_epoll_port_create;
-SOFIAPUBFUN su_port_create_f su_poll_port_create;
-SOFIAPUBFUN su_port_create_f su_wsaevent_port_create;
-SOFIAPUBFUN su_port_create_f su_select_port_create;
-
-SOFIAPUBFUN su_clone_start_f su_default_clone_start;
-SOFIAPUBFUN su_clone_start_f su_epoll_clone_start;
-SOFIAPUBFUN su_clone_start_f su_poll_clone_start;
-SOFIAPUBFUN su_clone_start_f su_wsaevent_clone_start;
-SOFIAPUBFUN su_clone_start_f su_select_clone_start;
-
-
 SOFIA_END_DECLS
 
 #endif /* SU_WAIT_H */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su.c	Sat Feb 17 01:25:21 2007
@@ -32,15 +32,13 @@
 
 #include "config.h" 
 
-#include "sofia-sip/su.h"
-#include "sofia-sip/su_log.h"
-#include "sofia-sip/su_alloc.h"
-
 #include <stdio.h>
 #include <string.h>
-#if HAVE_SIGNAL
 #include <signal.h>
-#endif
+
+#include "sofia-sip/su.h"
+#include "sofia-sip/su_log.h"
+#include "sofia-sip/su_alloc.h"
 
 #if !SU_HAVE_BSDSOCK && !SU_HAVE_WINSOCK
 #error Bad configuration
@@ -69,9 +67,7 @@
 {
   su_home_threadsafe(NULL);
 
-#if HAVE_SIGPIPE
   signal(SIGPIPE, SIG_IGN);	/* we want to get EPIPE instead */
-#endif
 
   su_log_init(su_log_default);
   su_log_init(su_log_global);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc.c	Sat Feb 17 01:25:21 2007
@@ -87,8 +87,8 @@
  *
  * As you might have guessed, it is also possible to use reference counting
  * with home objects. The function su_home_ref() increases the reference
- * count, su_home_unref() decreases it. A newly allocated or initialized
- * home object has reference count of 1.
+ * count, su_home_unref() decreases. A newly allocated home object has
+ * reference count of 1.
  *
  * @note Please note that while it is possible to create new references to
  * secondary home objects which have a parent home, the secondary home
@@ -104,13 +104,10 @@
  * @note
  *
  * The su_home_destroy() function is deprecated as it does not free the home
- * object itself. Like su_home_deinit(), it should be called only on home
- * objects with reference count of 1.
+ * object itself.
  *
- * The function su_home_init() initializes a home object structure. When the
- * initialized home object is destroyed or deinitialized or its reference
- * count reaches zero, the memory allocate thorugh it reclaimed but the home
- * object structure itself is not freed.
+ * The function su_home_init() initializes a home object with infinite
+ * reference count. It must be deinitialized with su_home_deinit().
  *
  * @section su_home_destructor_usage Destructors
  *
@@ -151,20 +148,19 @@
  * @section su_alloc_threadsafe Threadsafe Operation
  *
  * If multiple threads need to access same home object, it must be marked as
- * @e threadsafe by calling su_home_threadsafe() with the home pointer as
+ * @c threadsafe by calling su_home_threadsafe() with the home pointer as
  * argument. The threadsafeness is not inherited by clones.
  *
  * The threadsafe home objects can be locked and unlocked with
- * su_home_mutex_lock() and su_home_mutex_unlock(). These operations are
- * no-op on home object that is not threadsafe.
+ * su_home_mutex_lock() and su_home_mutex_unlock().
  *
  * @section su_alloc_preloading Preloading a Memory Home
  *
- * In some situations there is quite heavy overhead if the global heap
- * allocator is used. The overhead caused by the large number of small
+ * In some situations there is quite heavy overhead when using the global
+ * heap allocator. The overhead caused by the large number of small
  * allocations can be reduced by using su_home_preload(): it allocates or
  * preloads some a memory to home to be used as a kind of private heap. The
- * preloaded memory area is then used to satisfy small enough allocations. 
+ * preloaded memory area is then used to satisfy small enough allocations.
  * For instance, the SIP parser typically preloads some 2K of memory when it
  * starts to parse the message.
  *
@@ -176,9 +172,10 @@
  * far as possible; if it is not enough, allocation is made from heap.
  *
  * The word @e auto refers to the automatic scope; however, the home object
- * that was initialized with su_home_auto() must be explicitly deinitialized
- * with su_home_deinit() or su_home_unref() when the program exits the scope
- * where the stack frame used in su_home_auto() was allocated.
+ * initialized with su_home_auto() must be explicitly deinitialized with
+ * su_home_deinit() when the program exits the scope where the stack frame
+ * used in su_home_auto() was allocate.
+ * 
  */
 
 #include <sofia-sip/su_config.h>
@@ -199,8 +196,6 @@
 void (*su_home_mutex_locker)(void *mutex);
 void (*su_home_mutex_unlocker)(void *mutex);
 
-void (*su_home_destroy_mutexes)(void *mutex);
-
 #define MEMLOCK(h)   \
   (((h) && (h)->suh_lock ? su_home_locker((h)->suh_lock) : (void)0), (h)->suh_blocks)
 #define UNLOCK(h) (((h) && (h)->suh_lock ? su_home_unlocker((h)->suh_lock) : (void)0), NULL)
@@ -226,10 +221,10 @@
 
 #define ALIGNMENT (8)
 #define ALIGN(n) (size_t)(((n) + (ALIGNMENT - 1)) & (size_t)~(ALIGNMENT - 1))
-#define SIZEBITS (sizeof (unsigned) * 8 - 1)
+#define SIZEBITS (sizeof (size_t) * 8 - 1)
 
 typedef struct {
-  unsigned sua_size:SIZEBITS;	/**< Size of the block */
+  size_t   sua_size:SIZEBITS;	/**< Size of the block */
   unsigned sua_home:1;		/**< Is this another home? */
   unsigned :0;
   void    *sua_data;		/**< Data pointer */
@@ -247,9 +242,8 @@
 
   unsigned    sub_prsize:16;	/**< Preload size */
   unsigned    sub_prused:16;	/**< Used from preload */
-  unsigned    sub_hauto:1;      /**< "Home" is not from malloc */
-  unsigned    sub_auto:1;	/**< struct su_block_s is not from malloc */
-  unsigned    sub_preauto:1;	/**< Preload is not from malloc */
+  unsigned    sub_auto:1;	/**< struct su_block_s is from stack! */
+  unsigned    sub_preauto:1;	/**< Preload is from stack! */
   unsigned    sub_auto_all:1;	/**< Everything is from stack! */
   unsigned :0;
 
@@ -261,7 +255,7 @@
 static void su_home_stats_alloc(su_block_t *, void *p, void *preload,
 				size_t size, int zero);
 static void su_home_stats_free(su_block_t *sub, void *p, void *preload,
-			       unsigned size);
+			       size_t size);
 
 static void _su_home_deinit(su_home_t *home);
 
@@ -351,7 +345,7 @@
   size_t size, term;
   assert(sua);
   if (sua) {
-    size = (size_t)sua->sua_size;
+    size = sua->sua_size;
     memcpy(&term, (char *)sua->sua_data + size, sizeof (term));
     assert(size - term == 0);
     return size - term == 0;
@@ -364,9 +358,8 @@
 
 /** Allocate the block hash table.
  *
- * @internal
- *
- * Allocate a block hash table of @a n elements.
+ * The function su_hash_alloc() allocates a block hash table of @a n
+ * elements.
  *
  * @param home  pointer to home object
  * @param n     number of buckets in hash table
@@ -379,12 +372,8 @@
 {
   su_block_t *b = calloc(1, offsetof(su_block_t, sub_nodes[n]));
 
-  if (b) {
-    /* Implicit su_home_init(); */
-    b->sub_ref = 1;
-    b->sub_hauto = 1;
+  if (b)
     b->sub_n = n;
-  }
 
   return b;
 }
@@ -393,8 +382,6 @@
 
 /** Allocate a memory block.
  *
- * @internal
- *
  * Precondition: locked home
  *
  * @param home home to allocate
@@ -412,10 +399,7 @@
 {
   void *data, *preload = NULL;
   
-  assert (size < (((size_t)1) << SIZEBITS));
-
-  if (size >= ((size_t)1) << SIZEBITS)
-    return (void)(errno = ENOMEM), NULL;
+  assert (size < (1UL << SIZEBITS));
 
   if (sub == NULL || 3 * sub->sub_used > 2 * sub->sub_n) {
     /* Resize the hash table */
@@ -445,7 +429,6 @@
       b2->sub_preload = sub->sub_preload;
       b2->sub_prsize = sub->sub_prsize;
       b2->sub_prused = sub->sub_prused;
-      b2->sub_hauto = sub->sub_hauto;
       b2->sub_preauto = sub->sub_preauto;
       b2->sub_destructor = sub->sub_destructor;
       /* auto_all is not copied! */
@@ -490,7 +473,7 @@
     if (!preload)
       sub->sub_auto_all = 0;
 
-    if (zero >= do_clone) {
+    if (zero == do_clone) {
       /* Prepare cloned home */ 
       su_home_t *subhome = data;
 
@@ -502,13 +485,13 @@
 
       subhome->suh_size = (unsigned)size;
       subhome->suh_blocks->sub_parent = home;
-      subhome->suh_blocks->sub_hauto = 0;
+      subhome->suh_blocks->sub_ref = 1;
     }
 
     /* OK, add the block to the hash table. */
 
     sua = su_block_add(sub, data); assert(sua);
-    sua->sua_size = (unsigned)size;
+    sua->sua_size = size;
     sua->sua_home = zero > 1;
 
     if (sub->sub_stats)
@@ -542,16 +525,16 @@
   assert(size >= sizeof (*home));
 
   if (size < sizeof (*home))
-    return (void)(errno = EINVAL), NULL;
+    return (errno = EINVAL), NULL;
   else if (size > INT_MAX)
-    return (void)(errno = ENOMEM), NULL;
+    return (errno = ENOMEM), NULL;
 
   home = calloc(1, size);
   if (home) {
     home->suh_size = (int)size;
     home->suh_blocks = su_hash_alloc(SUB_N);
     if (home->suh_blocks)
-      home->suh_blocks->sub_hauto = 0;
+      home->suh_blocks->sub_ref = 1;
     else
       free(home), home = NULL;
   }
@@ -629,10 +612,12 @@
 
 /**Unreference a su_home_t object.
  *
- * Decrements the reference count on home object and destroys and frees it
- * and the memory allocations using it if the reference count reaches 0.
+ * The function su_home_unref() decrements the reference count on a home
+ * object and destroys and frees it and the memory allocations using it.
+ *
+ * @param home memory pool object to be unreferences
  *
- * @param home memory pool object to be unreferenced
+ * The function return values is 
  *
  * @retval 1 if object was freed
  * @retval 0 if object is still alive
@@ -665,10 +650,8 @@
     return 1;
   }
   else {
-    int hauto = sub->sub_hauto;
     _su_home_deinit(home);
-    if (!hauto)
-      free(home);
+    free(home);
     /* UNLOCK(home); */
     return 1;
   }
@@ -742,7 +725,7 @@
 
 /** Allocate a memory block.
  *
- * Allocates a memory block of a given @a size.
+ * The function su_alloc() allocates a memory block of a given @a size.
  *
  * If @a home is NULL, this function behaves exactly like malloc().
  *
@@ -769,9 +752,9 @@
 
 /**Free a memory block.
  *
- * Frees a single memory block. The @a home must be the owner of the memory
- * block (usually the memory home used to allocate the memory block, or NULL
- * if no home was used).
+ * The function su_free() frees a single memory block. The @a home must be
+ * the owner of the memory block (usually the memory home used to allocate
+ * the memory block, or NULL if no home was used).
  *
  * @param home  pointer to home object
  * @param data  pointer to the memory block to be freed
@@ -809,7 +792,7 @@
       }
 
 #if MEMCHECK != 0
-      memset(data, 0xaa, (size_t)allocation->sua_size);
+      memset(data, 0xaa, allocation->sua_size);
 #endif
 
       memset(allocation, 0, sizeof (*allocation));
@@ -827,9 +810,9 @@
 
 /** Check home consistency.
  *
- * Ensures that the home structure and all memory blocks allocated through
- * it are consistent. It can be used to catch memory allocation and usage
- * errors.
+ * The function su_home_check() ensures that the home structure and all
+ * memory blocks allocated through it are consistent.  It can be used to
+ * catch memory allocation and usage errors.
  *
  * @param home Pointer to a memory home.
  */
@@ -868,10 +851,11 @@
 /**
  * Create an su_home_t object.
  *
- * Creates a home object. A home object is used to collect multiple memory
- * allocations, so that they all can be freed by calling su_home_unref().
+ * The function su_home_create() creates a home object.  A home object is
+ * used to collect multiple memory allocations, so that they all can be
+ * freed by calling su_home_unref().
  *
- * @return This function returns a pointer to an #su_home_t object, or 
+ * @return This function returns a pointer to an @c su_home_t object, or @c
  * NULL upon an error. 
  */
 su_home_t *su_home_create(void)
@@ -879,10 +863,10 @@
   return su_home_new(sizeof(su_home_t));
 }
 
-/** Destroy a home object
+/** Deinitialize a home object
  *
- * Frees all memory blocks associated with a home object. Note that the home
- * object structure is not freed.
+ * The function su_home_destroy() frees all memory blocks associated with a
+ * home object. Note that the home object is not freed.
  *
  * @param home pointer to a home object
  *
@@ -892,22 +876,14 @@
  */
 void su_home_destroy(su_home_t *home)
 {
-  if (MEMLOCK(home)) {
-    assert(home->suh_blocks);
-    assert(home->suh_blocks->sub_ref == 1);
-    if (!home->suh_blocks->sub_hauto)
-      /* should warn user */;
-    home->suh_blocks->sub_hauto = 1;
-    _su_home_deinit(home);
-    /* UNLOCK(home); */
-  }
+  su_home_deinit(home);
+  /* XXX - home itself is not destroyed */
 }
 
 /** Initialize an su_home_t struct.
  *
- * Initializes an su_home_t structure. It can be used when the home
- * structure is allocated from stack or when the home structure is part of
- * an another object.
+ * The function su_home_init() initializes an su_home_t structure. It can be
+ * used when the home structure is allocated from stack.
  *
  * @param home pointer to home object
  *
@@ -918,14 +894,10 @@
  */
 int su_home_init(su_home_t *home)
 {
-  su_block_t *sub;
-    
   if (home == NULL)
     return -1;
 
-  home->suh_blocks = sub = su_hash_alloc(SUB_N);
-  if (!sub)
-    return -1;
+  home->suh_blocks = su_hash_alloc(SUB_N);
 
   return 0;
 }
@@ -977,9 +949,6 @@
       free(b);
 
     home->suh_blocks = NULL;
-
-    if (home->suh_lock)
-      su_home_destroy_mutexes(home->suh_lock);
   }
 
   home->suh_lock = NULL;
@@ -987,9 +956,9 @@
 
 /** Free memory blocks allocated through home.
  *
- * Frees the memory blocks associated with the home object allocated. It
- * does not free the home object itself. Use su_home_unref() to free the
- * home object.
+ * The function @c su_home_deinit() frees the memory blocks associated with
+ * the home object allocated otherwise. It does not free the home object
+ * itself. Use su_home_unref() to free the home object.
  *
  * @param home pointer to home object
  *
@@ -998,9 +967,7 @@
 void su_home_deinit(su_home_t *home)
 {
   if (MEMLOCK(home)) {
-    assert(home->suh_blocks);
-    assert(home->suh_blocks->sub_ref == 1);
-    assert(home->suh_blocks->sub_hauto);
+    assert(home->suh_blocks && home->suh_blocks->sub_ref == 0);
     _su_home_deinit(home);
     /* UNLOCK(home); */
   }
@@ -1008,11 +975,11 @@
 
 /**Move allocations from a su_home_t object to another.
  *
- * Moves allocations made through the @a src home object under the @a dst
- * home object. It is handy, for example, if an operation allocates some
- * number of blocks that should be freed upon an error. It uses a temporary
- * home and moves the blocks from temporary to a proper home when
- * successful, but frees the temporary home upon an error.
+ * The function su_home_move() moves allocations made through the @a src
+ * home object under the @a dst home object. It is handy, for example, if an
+ * operation allocates some number of blocks that should be freed upon an
+ * error. It uses a temporary home and moves the blocks from temporary to a
+ * proper home when successful, but frees the temporary home upon an error.
  *
  * If @a src has destructor, it is called before starting to move.
  *
@@ -1144,8 +1111,8 @@
 
 /** Preload a memory home from stack.
  *
- * Initializes a memory home using an area allocated from stack. Poor man's
- * alloca().
+ * The function su_home_auto() initalizes a memory home using an area
+ * allocated from stack. Poor mans alloca().
  */
 su_home_t *su_home_auto(void *area, isize_t size)
 {
@@ -1175,12 +1142,10 @@
     size = prepsize + 65535;
 
   sub->sub_n = SUB_N_AUTO;
-  sub->sub_ref = 1;
   sub->sub_preload = p + prepsize;
   sub->sub_prsize = (unsigned)(size - prepsize);
-  sub->sub_hauto = 1;
-  sub->sub_auto = 1;
   sub->sub_preauto = 1;
+  sub->sub_auto = 1;
   sub->sub_auto_all = 1;
 
   return home;
@@ -1189,7 +1154,7 @@
 
 /** Reallocate a memory block.
  *
- *   Allocates a memory block of @a size bytes.
+ *   The function su_realloc() allocates a memory block of @a size bytes.
  *   It copies the old block contents to the new block and frees the old
  *   block.
  *
@@ -1200,7 +1165,7 @@
  *   @param size  size of the memory block to be allocated
  *   
  * @return
- *   A pointer to the allocated memory block or
+ *   This function returns a pointer to the allocated memory block or
  *   NULL if an error occurred.
  */
 void *su_realloc(su_home_t *home, void *data, isize_t size)
@@ -1251,7 +1216,7 @@
 #endif
       memset(sua, 0, sizeof *sua);
       sub->sub_used--;
-      su_block_add(sub, ndata)->sua_size = (unsigned)size;
+      su_block_add(sub, ndata)->sua_size = size;
     }
     UNLOCK(home);
 
@@ -1273,7 +1238,7 @@
       }
 
       sub->sub_prused = (unsigned)p2;
-      sua->sua_size = (unsigned)size;
+      sua->sua_size = size;
 
 #if MEMCHECK_EXTRA
       memcpy((char *)data + size, &term, sizeof (term));
@@ -1282,7 +1247,7 @@
       return data;
     }
   }
-  else if (size < (size_t)sua->sua_size) {
+  else if (size < sua->sua_size) {
     /* Reduce existing preload */
     if (sub->sub_stats) {
       su_home_stats_free(sub, data, data, sua->sua_size);
@@ -1291,7 +1256,7 @@
 #if MEMCHECK_EXTRA
     memcpy((char *)data + size, &term, sizeof (term));
 #endif
-    sua->sua_size = (unsigned)size;
+    sua->sua_size = size;
     UNLOCK(home);
     return data;
   }
@@ -1306,10 +1271,7 @@
 	su_home_stats_free(sub, data, data, sua->sua_size);
     }
     
-    memcpy(ndata, data,
-	   (size_t)sua->sua_size < size
-	   ? (size_t)sua->sua_size
-	   : size);
+    memcpy(ndata, data, sua->sua_size < size ? sua->sua_size : size);
 #if MEMCHECK_EXTRA
     memcpy((char *)ndata + size, &term, sizeof (term));
 #endif
@@ -1319,7 +1281,7 @@
 
     memset(sua, 0, sizeof *sua); sub->sub_used--;
 
-    su_block_add(sub, ndata)->sua_size = (unsigned)size;
+    su_block_add(sub, ndata)->sua_size = size;
   }
 
   UNLOCK(home);
@@ -1365,7 +1327,7 @@
 
 /**Allocate and zero a memory block.
  *
- * Allocates a memory block with a given size from
+ * The function su_zalloc() allocates a memory block with a given size from
  * given memory home @a home and zeroes the allocated block.
  *
  *  @param home  pointer to memory pool object
@@ -1397,9 +1359,9 @@
 
 /** Allocate a structure
  *
- * Allocates a structure with a given size, zeros
+ * The function su_salloc() allocates a structure with a given size, zeros
  * it, and initializes the size field to the given size.  The size field
- * is an int at the beginning of the structure. Note that it has type of int. 
+ * is the first in the structure. It has type of int. 
  *
  * @param home  pointer to memory pool object
  * @param size  size of the structure
@@ -1578,8 +1540,7 @@
 }
 
 static 
-void su_home_stats_free(su_block_t *sub, void *p, void *preload,
-			unsigned size)
+void su_home_stats_free(su_block_t *sub, void *p, void *preload, size_t size)
 {
   su_home_stat_t *hs = sub->sub_stats;
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc_lock.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc_lock.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_alloc_lock.c	Sat Feb 17 01:25:21 2007
@@ -39,7 +39,6 @@
 #if SU_HAVE_PTHREADS
 #include <pthread.h>
 #include <assert.h>
-#include <stdlib.h>
 
 extern void (*su_home_locker)(void *mutex);
 extern void (*su_home_unlocker)(void *mutex);
@@ -47,8 +46,6 @@
 extern void (*su_home_mutex_locker)(void *mutex);
 extern void (*su_home_mutex_unlocker)(void *mutex);
 
-extern void (*su_home_destroy_mutexes)(void *mutex);
-
 /** Mutex */
 static void mutex_locker(void *_mutex)
 {
@@ -61,15 +58,6 @@
   pthread_mutex_t *mutex = _mutex;
   pthread_mutex_unlock(mutex + 1);
 }
-
-static void mutex_destroy(void *_mutex)
-{
-  pthread_mutex_t *mutex = _mutex;
-  pthread_mutex_destroy(mutex + 0);
-  pthread_mutex_destroy(mutex + 1);
-  free(_mutex);
-}
-
 #endif
 
 
@@ -77,7 +65,7 @@
  *
  * Convert a memory home object as thread-safe by allocating mutexes and
  * modifying function pointers in su_alloc.c module.
- *
+
  * @param home memory home object to be converted thread-safe.
  *
  * @retval 0 when successful,
@@ -106,10 +94,9 @@
     su_home_mutex_unlocker = mutex_unlocker;
     su_home_locker = (void (*)(void *))pthread_mutex_lock;
     su_home_unlocker = (void (*)(void *))pthread_mutex_unlock;
-    su_home_destroy_mutexes = mutex_destroy;
   }
 
-  mutex = calloc(1, 2 * (sizeof *mutex));
+  mutex = su_alloc(home, 2 * sizeof (pthread_mutex_t));
   assert(mutex);
   if (mutex) {
     /* Mutex for memory operations */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_bm.c	Sat Feb 17 01:25:21 2007
@@ -108,7 +108,7 @@
 /** Search for a substring using Boyer-Moore algorithm.
  * @ingroup su_bm
  */
-char *
+char const*
 bm_memmem(char const *haystack, size_t hlen,
 	  char const *needle, size_t nlen,
 	  bm_fwd_table_t *fwd)
@@ -117,14 +117,14 @@
   bm_fwd_table_t fwd0[1];
 
   if (nlen == 0)
-    return (char *)haystack;
+    return haystack;
   if (needle == NULL || haystack == NULL || nlen > hlen)
     return NULL;
 
   if (nlen == 1) {
     for (i = 0; i < hlen; i++)
       if (haystack[i] == needle[0])
-	return (char *)haystack + i;
+	return haystack + i;
     return NULL;
   }
 
@@ -139,7 +139,7 @@
 		  (int)(i - j), "", (int)j, needle, needle + j + 1, 
 		  j == 0 ? "match!" : "back by 1"));
       if (j == 0)
-	return (char *)haystack + i;
+	return haystack + i;
       i--, j--;
     }
     else {
@@ -207,7 +207,7 @@
 /** Search for substring using Boyer-Moore algorithm.
  * @ingroup su_bm
  */
-char *
+char const*
 bm_memcasemem(char const *haystack, size_t hlen,
 	      char const *needle, size_t nlen,
 	      bm_fwd_table_t *fwd)
@@ -216,14 +216,14 @@
   bm_fwd_table_t fwd0[1];
 
   if (nlen == 0)
-    return (char *)haystack;
+    return haystack;
   if (needle == 0 || haystack == 0 || nlen > hlen)
     return NULL;
 
   if (nlen == 1) {
     for (i = 0; i < hlen; i++)
       if (haystack[i] == needle[0])
-	return (char *)haystack + i;
+	return haystack + i;
     return NULL;
   }
 
@@ -245,7 +245,7 @@
 		  (int)(i - j), "", (int)j, needle, needle + j + 1, 
 		  j == 0 ? "match!" : "back by 1"));
       if (j == 0)
-	return (char *)haystack + i;
+	return haystack + i;
       i--, j--;
     }
     else {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c	Sat Feb 17 01:25:21 2007
@@ -1045,9 +1045,7 @@
 {
   struct ifaddrs *ifa, *results;
   int error = 0;
-#if SU_HAVE_IN6
   int v4_mapped = (hints->li_flags & LI_V4MAPPED) != 0;
-#endif
   char *canonname = NULL;
 
   if (getifaddrs(&results) < 0) {
@@ -1059,10 +1057,7 @@
 
   for (ifa = results; ifa; ifa = ifa->ifa_next) {
     su_localinfo_t *li;
-    su_sockaddr_t *su;
-#if SU_HAVE_IN6
-    su_sockaddr_t su2[1];
-#endif
+    su_sockaddr_t *su, su2[1];
     socklen_t sulen;
     int scope, flags = 0, gni_flags = 0, if_index = 0;
     char const *ifname = 0;
@@ -1080,19 +1075,15 @@
     if (su->su_family == AF_INET) {
       sulen = sizeof(su->su_sin);
       scope = li_scope4(su->su_sin.sin_addr.s_addr);
-#if SU_HAVE_IN6
       if (v4_mapped)
 	sulen = sizeof(su->su_sin6);
-#endif
     }
-#if SU_HAVE_IN6
     else if (su->su_family == AF_INET6) {
       if (IN6_IS_ADDR_MULTICAST(&su->su_sin6.sin6_addr))
 	continue;
       sulen = sizeof(su->su_sin6);
       scope = li_scope6(&su->su_sin6.sin6_addr);
     }
-#endif
     else 
       continue;
 
@@ -1111,7 +1102,6 @@
     if (scope == LI_SCOPE_HOST || scope == LI_SCOPE_LINK)
       gni_flags = NI_NUMERICHOST;
 
-#if SU_HAVE_IN6
     if (v4_mapped && su->su_family == AF_INET) {
       /* Map IPv4 address to IPv6 address */
       memset(su2, 0, sizeof(*su2));
@@ -1120,7 +1110,6 @@
       ((int32_t*)&su2->su_sin6.sin6_addr)[3] = su->su_sin.sin_addr.s_addr;
       su = su2;
     }
-#endif
 
     if ((error = li_name(hints, gni_flags, su, &canonname)) < 0)
       break;
@@ -1199,7 +1188,7 @@
 int win_localinfo(su_localinfo_t const hints[1], su_localinfo_t **rresult)
 {
   /* This is Windows XP code, for both IPv6 and IPv4. */
-  ULONG iaa_size = 2048;
+  size_t iaa_size = 2048;
   IP_ADAPTER_ADDRESSES *iaa0, *iaa;
   int error, loopback_seen = 0;
   int v4_mapped = (hints->li_flags & LI_V4MAPPED) != 0;
@@ -1208,7 +1197,7 @@
   int flags = GAA_FLAG_SKIP_MULTICAST;
   *rresult = NULL; next = rresult;
 
-  iaa0 = malloc((size_t)iaa_size);
+  iaa0 = malloc(iaa_size);
   if (!iaa0) {
     SU_DEBUG_1(("su_localinfo: memory exhausted\n"));
     error = ELI_MEMORY;
@@ -1229,7 +1218,7 @@
     IP_ADAPTER_UNICAST_ADDRESS *ua;
     IP_ADAPTER_UNICAST_ADDRESS lua[1];
     int if_index = iaa->IfIndex;
-    size_t ifnamelen = 0;
+    int ifnamelen = 0;
     char ifname[16];
 
     for (ua = iaa->FirstUnicastAddress; ;ua = ua->Next) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_os_nw.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_os_nw.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_os_nw.c	Sat Feb 17 01:25:21 2007
@@ -46,14 +46,10 @@
 #include "sofia-sip/su_os_nw.h"
 #include "sofia-sip/su_debug.h"
 
-#if defined(__APPLE_CC__)
-# define SU_NW_CHANGE_PTHREAD 1
-#endif
+/* Works only with pthreads */
+#if SU_HAVE_PTHREADS
 
-#if defined (SU_NW_CHANGE_PTHREAD)
-# define SU_HAVE_NW_CHANGE 1
-# include <pthread.h>
-#endif
+#include <pthread.h>
 
 #if defined(__APPLE_CC__)
 #include <AvailabilityMacros.h>
@@ -72,9 +68,8 @@
   SCDynamicStoreRef           su_storeRef[1];
   CFRunLoopSourceRef          su_sourceRef[1];
 #endif
-#if defined (SU_NW_CHANGE_PTHREAD)
+
   pthread_t                   su_os_thread;
-#endif
 
   su_network_changed_f       *su_network_changed_cb;
   su_network_changed_magic_t *su_network_changed_magic;
@@ -114,7 +109,7 @@
 		    sizeof *snc) == SU_FAILURE) {
 
     return;
-  }
+  }    
 
   snc2 = su_msg_data(rmsg); assert(snc2);
   snc2->su_root = snc->su_root;
@@ -124,7 +119,7 @@
   snc2->su_os_thread = snc->su_os_thread;
   snc2->su_network_changed_cb = snc->su_network_changed_cb;
   snc2->su_network_changed_magic = snc->su_network_changed_magic;
-
+  
   if (su_msg_send(rmsg) == SU_FAILURE) {
     su_msg_destroy(rmsg);
     return;
@@ -224,7 +219,10 @@
 
     return err;
 }
+#endif /* __APPLE_CC__ */
+
 
+#if defined(__APPLE_CC__)
 static void *su_start_nw_os_thread(void *ptr)
 {
   su_network_changed_t *snc = (su_network_changed_t *) ptr;
@@ -251,13 +249,19 @@
 			     su_network_changed_f *network_changed_cb,
 			     su_network_changed_magic_t *magic)
 {
+#if defined (__APPLE_CC__)
   su_network_changed_t *snc = NULL;
+#endif
 
   assert(home && root && network_changed_cb && magic);
 
-#if defined (SU_HAVE_NW_CHANGE)
-  snc = su_zalloc(home, sizeof *snc);
+  /* Not implemented for others than OSX */
+#if !defined (__APPLE_CC__)
+  return NULL;
+#else
 
+  snc = su_zalloc(home, sizeof *snc);
+  
   if (!snc)
     return NULL;
 
@@ -265,16 +269,15 @@
   snc->su_root = root;
   snc->su_network_changed_cb = network_changed_cb;
   snc->su_network_changed_magic = magic;
-
-# if defined (SU_NW_CHANGE_PTHREAD)
+  
   if ((pthread_create(&(snc->su_os_thread), NULL,
 		      su_start_nw_os_thread,
 		      (void *) snc)) != 0) {
     return NULL;
   }
-# endif
-#endif
+
   return snc;
+#endif
 }
 
 /** Remove a callback registered for the network change event.
@@ -285,3 +288,20 @@
 {
   return -1;
 }
+
+#else
+
+su_network_changed_t
+*su_root_add_network_changed(su_home_t *home, su_root_t *root,
+			     su_network_changed_f *network_changed_cb,
+			     su_network_changed_magic_t *magic)
+{
+  return NULL;
+}
+
+int su_root_remove_network_changed(su_network_changed_t *snc)
+{
+  return -1;
+}
+
+#endif /* SU_HAVE_PTHREADS */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_osx_runloop.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_osx_runloop.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_osx_runloop.c	Sat Feb 17 01:25:21 2007
@@ -31,13 +31,22 @@
  * poll/select/WaitForMultipleObjects and message passing functionality.
  *
  * @author Pekka Pessi <Pekka.Pessi at nokia.com>
- * @author Martti Mela <martti.mela at nokia.com>
+ * @author Kai Vehmanen <kai.vehmanen at nokia.com>
  *
  * @date Created: Tue Sep 14 15:51:04 1999 ppessi
  */
 
 #include "config.h"
 
+/* React to multiple events per one poll() to make sure 
+ * that high-priority events can never completely mask other events.
+ * Enabled by default on all platforms except WIN32 */
+#ifndef WIN32
+#define SU_ENABLE_MULTISHOT_POLL 1
+#else
+#define SU_ENABLE_MULTISHOT_POLL 0
+#endif
+
 #include <stdlib.h>
 #include <assert.h>
 #include <stdarg.h>
@@ -46,8 +55,9 @@
 #include <limits.h>
 #include <errno.h>
 
-#define su_port_s su_osx_port_s 
+#define SU_PORT_IMPLEMENTATION 1
 
+#include "sofia-sip/su.h"
 #include "su_port.h"
 #include "sofia-sip/su_osx_runloop.h"
 #include "sofia-sip/su_alloc.h"
@@ -61,121 +71,163 @@
 #define enter (void)0
 #endif
 
+
+#if SU_HAVE_PTHREADS
+/* Pthread implementation */
+#include <pthread.h>
+#define SU_HAVE_MBOX 1
+#else
+#define SU_HAVE_MBOX 0
+#endif
+
+#if HAVE_SOCKETPAIR
+#define MBOX_SEND  1
+#else
+#define MBOX_SEND  0
+#endif
+
 static su_port_t *su_osx_runloop_create(void) __attribute__((__malloc__));
 
 /* Callback for CFObserver and CFSocket */
-static void cf_observer_cb(CFRunLoopObserverRef observer, 
-			   CFRunLoopActivity activity, 
-			   void *info);
-
-static void su_osx_port_socket_cb(CFSocketRef s, 
+static
+void cf_observer_cb(CFRunLoopObserverRef observer, 
+		    CFRunLoopActivity activity, 
+		    void *info);
+static void su_port_osx_socket_cb(CFSocketRef s, 
 				  CFSocketCallBackType callbackType, 
 				  CFDataRef address, 
 				  const void *data, 
 				  void *info);
-
-static void su_osx_port_deinit(void *arg);
-
-static void su_osx_port_decref(su_port_t *self, int blocking, char const *who)
-{
-  (void)su_base_port_decref(self, blocking, who);
-}
-
-
 static CFSocketCallBackType map_poll_event_to_cf_event(int events);
 
-static int su_osx_port_send(su_port_t *self, su_msg_r rmsg);
+static void su_port_osx_lock(su_port_t *self, char const *who);
+static void su_port_osx_unlock(su_port_t *self, char const *who);
+static void su_port_osx_incref(su_port_t *self, char const *who);
+static void su_port_osx_decref(su_port_t *self, int blocking, char const *who);
+
+static int su_port_osx_send(su_port_t *self, su_msg_r rmsg);
 
-static int su_osx_port_register(su_port_t *self,
+static int su_port_osx_register(su_port_t *self,
 			    su_root_t *root, 
 			    su_wait_t *wait, 
 			    su_wakeup_f callback,
 			    su_wakeup_arg_t *arg,
 			    int priority);
-static int su_osx_port_unregister(su_port_t *port,
+static int su_port_osx_unregister(su_port_t *port,
 			      su_root_t *root, 
 			      su_wait_t *wait,	
 			      su_wakeup_f callback, 
 			      su_wakeup_arg_t *arg);
 
-static int su_osx_port_deregister(su_port_t *self, int i);
+static int su_port_osx_deregister(su_port_t *self, int i);
 
-static int su_osx_port_unregister_all(su_port_t *self,
+static int su_port_osx_unregister_all(su_port_t *self,
 			   su_root_t *root);
 
-static int su_osx_port_eventmask(su_port_t *, int , int, int );
-static void su_osx_port_run(su_port_t *self);
-static void su_osx_port_break(su_port_t *self);
-static su_duration_t su_osx_port_step(su_port_t *self, su_duration_t tout);
+static int su_port_osx_getmsgs(su_port_t *self);
+static
+int su_port_osx_eventmask(su_port_t *self, int index, int socket, int events);
+static
+void su_port_osx_run(su_port_t *self);
+static
+void su_port_osx_break(su_port_t *self);
+static
+su_duration_t su_port_osx_step(su_port_t *self, su_duration_t tout);
 
-static int su_osx_port_multishot(su_port_t *port, int multishot);
+#if 0
+unsigned su_port_query(su_port_t *, su_wait_t *, unsigned n_waits);
+void su_port_event(su_port_t *, su_wait_t *waitobj);
+#endif
 
-static int su_osx_port_wait_events(su_port_t *self, su_duration_t tout);
+static
+int su_port_osx_own_thread(su_port_t const *port);
 
-static char const *su_osx_port_name(su_port_t const *self)
-{
-  return "CFRunLoop";
-}
+static
+int su_port_osx_add_prepoll(su_port_t *port,
+			su_root_t *root, 
+			su_prepoll_f *, 
+			su_prepoll_magic_t *);
+
+static
+int su_port_osx_remove_prepoll(su_port_t *port,
+			   su_root_t *root);
+
+static
+su_timer_t **su_port_osx_timers(su_port_t *port);
+
+static
+int su_port_osx_multishot(su_port_t *port, int multishot);
 
-su_port_vtable_t const su_osx_port_vtable[1] =
+static
+int su_port_osx_threadsafe(su_port_t *port);
+
+static
+int su_port_osx_yield(su_port_t *port);
+
+su_port_vtable_t const su_port_osx_vtable[1] =
   {{
-      /* su_vtable_size: */ sizeof su_osx_port_vtable,
-      su_pthread_port_lock,
-      su_pthread_port_unlock,
-      su_base_port_incref,
-      su_osx_port_decref,
-      su_base_port_gsource,
-      su_osx_port_send,
-      su_osx_port_register,
-      su_osx_port_unregister,
-      su_osx_port_deregister,
-      su_osx_port_unregister_all,
-      su_osx_port_eventmask,
-      su_osx_port_run,
-      su_osx_port_break,
-      su_osx_port_step,
-      su_pthread_port_own_thread,
-      su_base_port_add_prepoll,
-      su_base_port_remove_prepoll,
-      su_base_port_timers,
-      su_osx_port_multishot,
-      su_base_port_threadsafe,
-      su_base_port_yield,
-      su_osx_port_wait_events,
-      su_base_port_getmsgs,
-      su_base_port_getmsgs_from,
-      su_osx_port_name,
-      su_base_port_start_shared,
-      su_pthread_port_wait,
-      su_pthread_port_execute,
+      /* su_vtable_size: */ sizeof su_port_osx_vtable,
+      su_port_osx_lock,
+      su_port_osx_unlock,
+      su_port_osx_incref,
+      su_port_osx_decref,
+      NULL /* su_port_osx_runloop */, /* XXX - was: gsource, */
+      su_port_osx_send,
+      su_port_osx_register,
+      su_port_osx_unregister,
+      su_port_osx_deregister,
+      su_port_osx_unregister_all,
+      su_port_osx_eventmask,
+      su_port_osx_run,
+      su_port_osx_break,
+      su_port_osx_step,
+      su_port_osx_own_thread,
+      su_port_osx_add_prepoll,
+      su_port_osx_remove_prepoll,
+      su_port_osx_timers,
+      su_port_osx_multishot,
+      su_port_osx_threadsafe,
+      su_port_osx_yield
     }};
 
-/*
+static int su_port_osx_wait_events(su_port_t *self, su_duration_t tout);
+
+
+/* *
  * Port is a per-thread reactor.  
  *
  * Multiple root objects executed by single thread share a su_port_t object. 
  */
-struct su_osx_port_s {
-  su_socket_port_t sup_socket[1];
-
-#define sup_pthread sup_socket->sup_base
-#define sup_base sup_socket->sup_base->sup_base
-#define sup_home sup_socket->sup_base->sup_base->sup_home
+struct su_port_s {
+  su_home_t        sup_home[1];
 
+  su_port_vtable_t const *sup_vtable;
+  
+  unsigned         sup_running;
   unsigned         sup_source_fired;
 
+
+#if SU_HAVE_PTHREADS
+  pthread_t        sup_tid;
+  pthread_mutex_t  sup_mutex[1];
+#if __CYGWIN__
+  pthread_mutex_t  sup_reflock[1];
+  int              sup_ref;
+#else
+  pthread_rwlock_t sup_ref[1];
+#endif
+#else
+  int              sup_ref;
+#endif
+
+#if SU_HAVE_MBOX
+  su_socket_t      sup_mbox[MBOX_SEND + 1];
+  su_wait_t        sup_mbox_wait;
+#endif
+
   CFRunLoopRef        sup_main_loop;
   CFRunLoopSourceRef *sup_sources;
   CFSocketRef        *sup_sockets;
-
-  CFRunLoopObserverRef sup_observer;
-  CFRunLoopObserverContext sup_observer_cntx[1];
-  /* Struct for CFSocket callbacks; contains current CFSource index */
-  struct osx_magic {
-    su_port_t *o_port;
-    int        o_current;
-    int        o_count;
-  } osx_magic[1];
   
   unsigned         sup_multishot; /**< Multishot operation? */
 
@@ -205,10 +257,147 @@
   su_root_t      **sup_wait_roots; 
 
   su_wait_t       *sup_waits; 
+
+  /* Pre-poll callback */
+  su_prepoll_f    *sup_prepoll; 
+  su_prepoll_magic_t *sup_pp_magic;
+  su_root_t       *sup_pp_root;
+
+  /* Timer list */
+  su_timer_t      *sup_timers;
+
+  /* Message list - this is protected by lock  */
+  su_msg_t        *sup_head;
+  su_msg_t       **sup_tail;
+
+#if 0
+  int              sup_free_index;   /**< Number of first free index */
+  int             *sup_indices; /** Indices to registrations */
+
+  int             *sup_reverses; /** Reverse index */
+  su_wakeup_f     *sup_wait_cbs; 
+  su_wakeup_arg_t**sup_wait_args; 
+  su_root_t      **sup_wait_roots; 
+
+  su_wait_t       *sup_waits; 
+
+  /* Pre-poll callback */
+  su_prepoll_f    *sup_prepoll; 
+  su_prepoll_magic_t *sup_pp_magic;
+  su_root_t       *sup_pp_root;
+
+  /* Timer list */
+  su_timer_t      *sup_timers;
+
+  /* Message list - this is protected by lock  */
+  su_msg_t        *sup_head;
+  su_msg_t       **sup_tail;
+#endif
 };
 
 
-/* XXX - mela static void su_osx_port_destroy(su_port_t *self); */
+/* Struct for CFSocket callbacks; contains current CFSource index */
+typedef struct {
+  su_port_t *o_port;
+  int        o_current;
+  int        o_count;
+} osx_magic_t;
+
+
+#if SU_HAVE_PTHREADS
+#define SU_PORT_OSX_OWN_THREAD(p)   (pthread_equal((p)->sup_tid, pthread_self()))
+
+#if __CYGWIN__
+
+/* Debugging versions */
+#define SU_PORT_OSX_INITREF(p)      (pthread_mutex_init((p)->sup_reflock, NULL), printf("initref(%p)\n", (p)))
+#define SU_PORT_OSX_INCREF(p, f)    (pthread_mutex_lock(p->sup_reflock), p->sup_ref++, pthread_mutex_unlock(p->sup_reflock), printf("incref(%p) by %s\n", (p), f))
+#define SU_PORT_OSX_DECREF(p, f)    do {					\
+    pthread_mutex_lock(p->sup_reflock);	p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
+    if ((p->sup_ref) == 0) {			\
+      printf("decref(%p) to 0 by %s\n", (p), f); su_port_osx_destroy(p); }	\
+    else { printf("decref(%p) to %u by %s\n", (p), p->sup_ref, f); }  } while(0)
+
+#define SU_PORT_OSX_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
+    pthread_mutex_lock(p->sup_reflock);	p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
+  if ((p->sup_ref) != 0) { \
+    assert(!"SU_PORT_OSX_ZAPREF"); } \
+  su_port_osx_destroy(p); } while(0)
+
+#define SU_PORT_OSX_INITLOCK(p) \
+   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
+
+#define SU_PORT_OSX_LOCK(p, f)    \
+   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
+
+#define SU_PORT_OSX_UNLOCK(p, f)  \
+  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
+
+#elif 1
+#define SU_PORT_OSX_INITREF(p)      (pthread_rwlock_init(p->sup_ref, NULL))
+#define SU_PORT_OSX_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref))
+#define SU_PORT_OSX_DECREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
+  if (pthread_rwlock_trywrlock(p->sup_ref) == 0) su_port_osx_destroy(p); } while(0)
+
+#define SU_PORT_OSX_ZAPREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
+  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
+    assert(!"SU_PORT_OSX_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
+  su_port_osx_destroy(p); } while(0)
+
+#define SU_PORT_OSX_INITLOCK(p)     (pthread_mutex_init((p)->sup_mutex, NULL))
+#define SU_PORT_OSX_LOCK(p, f)      (pthread_mutex_lock((p)->sup_mutex))
+#define SU_PORT_OSX_UNLOCK(p, f)    (pthread_mutex_unlock((p)->sup_mutex))
+
+#else
+
+/* Debugging versions */
+#define SU_PORT_OSX_INITREF(p)      (pthread_rwlock_init((p)->sup_ref, NULL), printf("initref(%p)\n", (p)))
+#define SU_PORT_OSX_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref), printf("incref(%p) by %s\n", (p), f))
+#define SU_PORT_OSX_DECREF(p, f)    do {					\
+    pthread_rwlock_unlock(p->sup_ref);					\
+    if (pthread_rwlock_trywrlock(p->sup_ref) == 0) {			\
+      printf("decref(%p) to 0 by %s\n", (p), f); su_port_osx_destroy(p); }	\
+    else { printf("decref(%p) by %s\n", (p), f); }  } while(0)
+
+#define SU_PORT_OSX_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
+  pthread_rwlock_unlock(p->sup_ref); \
+  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
+    assert(!"SU_PORT_OSX_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
+  su_port_osx_destroy(p); } while(0)
+
+#define SU_PORT_OSX_INITLOCK(p) \
+   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
+
+#define SU_PORT_OSX_LOCK(p, f)    \
+   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
+
+#define SU_PORT_OSX_UNLOCK(p, f)  \
+  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
+
+#endif
+
+#else /* !SU_HAVE_PTHREADS */
+
+#define SU_PORT_OSX_OWN_THREAD(p)  1
+#define SU_PORT_OSX_INITLOCK(p)    (void)(p)
+#define SU_PORT_OSX_LOCK(p, f)      (void)(p)
+#define SU_PORT_OSX_UNLOCK(p, f)    (void)(p)
+#define SU_PORT_OSX_ZAPREF(p, f)    ((p)->sup_ref--)
+
+#define SU_PORT_OSX_INITREF(p)      ((p)->sup_ref = 1)
+#define SU_PORT_OSX_INCREF(p, f)    ((p)->sup_ref++)
+#define SU_PORT_OSX_DECREF(p, f) \
+do { if (--((p)->sup_ref) == 0) su_port_osx_destroy(p); } while (0);
+
+#endif
+
+#if SU_HAVE_MBOX
+static int su_port_osx_wakeup(su_root_magic_t *magic, 
+			  su_wait_t *w,
+			  su_wakeup_arg_t *arg);
+#endif
+
+static void su_port_osx_destroy(su_port_t *self);
 
 /** Create a reactor object.
  *
@@ -225,6 +414,7 @@
   return su_root_create_with_port(magic, su_osx_runloop_create());
 }
 
+
 void osx_enabler_cb(CFSocketRef s, 
 		    CFSocketCallBackType type, 
 		    CFDataRef address, 
@@ -232,32 +422,35 @@
 		    void *info)
 {
   CFRunLoopRef  rl;
-  struct osx_magic  *magic = (struct osx_magic *) info;
+  osx_magic_t  *magic = (osx_magic_t *) info;
   su_port_t    *self = magic->o_port;
   su_duration_t tout = 0;
   su_time_t     now = su_now();
   
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_base->sup_running) {
+  if (self->sup_running) {
     
-    if (self->sup_base->sup_prepoll)
-      self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
+    if (self->sup_prepoll)
+      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
     
-    if (self->sup_base->sup_head)
-      su_base_port_getmsgs(self);
+    if (self->sup_head)
+      su_port_osx_getmsgs(self);
     
-    if (self->sup_base->sup_timers)
-      su_timer_expire(&self->sup_base->sup_timers, &tout, now);
+    if (self->sup_timers)
+      su_timer_expire(&self->sup_timers, &tout, now);
   }
   
   CFRunLoopWakeUp(rl);
+  
 }
 
 
 /**@internal
  *
- * Allocates and initializes a message port.
+ * Allocates and initializes a message port. It creates a mailbox used to.
+ * wake up the tasks waiting on the port if needed.  Currently, the
+ * mailbox is simply an UDP socket connected to itself.
  *
  * @return
  *   If successful a pointer to the new message port is returned, otherwise
@@ -265,60 +458,142 @@
  */
 su_port_t *su_osx_runloop_create(void)
 {
-  su_port_t *self = su_home_new(sizeof *self);
+  su_port_t *self;
 
-  if (!self)
-    return self;
+  SU_DEBUG_9(("su_osx_runloop_create() called\n"));
 
-  enter;
+  self = su_home_clone(NULL, sizeof(*self));
 
-  if (su_home_destructor(su_port_home(self), su_osx_port_deinit) < 0)
-    return su_home_unref(su_port_home(self)), NULL;
+  if (self) {
+#if SU_HAVE_MBOX
+    int af;
+    su_socket_t mb = INVALID_SOCKET;
+    char const *why;
+#endif
+    CFRunLoopObserverRef cf_observer; 
+    osx_magic_t *osx_magic = NULL;
+    CFRunLoopObserverContext cf_observer_cntx[1] = {{0, NULL, NULL,
+						     NULL, NULL}};
 
-  self->sup_multishot = SU_ENABLE_MULTISHOT_POLL;
+    self->sup_vtable = su_port_osx_vtable;
+    
+    SU_PORT_OSX_INITREF(self);
+    SU_PORT_OSX_INITLOCK(self);
+    self->sup_tail = &self->sup_head;
 
-  if (su_socket_port_init(self->sup_base, su_osx_port_vtable) == 0) {
-    self->osx_magic->o_port = self;
-    self->sup_observer_cntx->info = self->osx_magic;
-    self->sup_observer =
-      CFRunLoopObserverCreate(NULL, 
-			      kCFRunLoopAfterWaiting | kCFRunLoopBeforeWaiting,
-			      TRUE, 0, cf_observer_cb, self->sup_observer_cntx);
-#if 0
+    self->sup_multishot = 0; /* XXX (SU_ENABLE_MULTISHOT_POLL) != 0; */
+
+#if SU_HAVE_PTHREADS
+    self->sup_tid = pthread_self();
+#endif
+  
+#if SU_HAVE_MBOX
+#if HAVE_SOCKETPAIR
+#if defined(AF_LOCAL)
+    af = AF_LOCAL;
+#else
+    af = AF_UNIX;
+#endif
+    if (socketpair(af, SOCK_STREAM, 0, self->sup_mbox) == -1) {
+      why = "su_port_osx_init: socketpair"; goto error;
+    }
+
+    mb = self->sup_mbox[0];
+    su_setblocking(self->sup_mbox[0], 0);
+    su_setblocking(self->sup_mbox[1], 0);
+#else
+    {
+      struct sockaddr_in sin = { sizeof(struct sockaddr_in), 0 };
+      socklen_t sinsize = sizeof sin;
+      struct sockaddr *sa = (struct sockaddr *)&sin;
+
+      af = PF_INET;
+
+      self->sup_mbox[0] = mb = su_socket(af, SOCK_DGRAM, IPPROTO_UDP);
+      if (mb == INVALID_SOCKET) {
+	why = "su_port_osx_init: socket"; goto error;
+      }
+  
+      sin.sin_family = AF_INET;
+      sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* 127.1 */
+      
+      /* Get a port for us */
+      if (bind(mb, sa, sizeof sin) == -1) {
+	why = "su_port_osx_init: bind"; goto error;
+      }
+
+      if (getsockname(mb, sa, &sinsize) == -1) {
+	why = "su_port_osx_init: getsockname"; goto error;
+      }
+    
+      if (connect(mb, sa, sinsize) == -1) {
+	why = "su_port_osx_init: connect"; goto error;
+      }
+    }
+#endif    
+
+    if (su_wait_create(&self->sup_mbox_wait, mb, SU_WAIT_IN) == -1) {
+      why = "su_port_osx_init: su_wait_create"; goto error;
+    }
+
+    if (su_port_osx_register(self, NULL, &self->sup_mbox_wait,
+			     su_port_osx_wakeup, 
+			     (su_wakeup_arg_t *)self->sup_mbox, 0)
+	== -1) {
+      why = "su_port_osx_create: su_port_osx_register"; goto error;
+    }
+
+    osx_magic = calloc(1, sizeof(*osx_magic));
+    osx_magic->o_port = self;
+    cf_observer_cntx->info = osx_magic;
+    
+    cf_observer =
+      CFRunLoopObserverCreate(NULL, kCFRunLoopAfterWaiting | kCFRunLoopBeforeWaiting,
+			      TRUE, 0, cf_observer_cb, cf_observer_cntx);
+    
     CFRunLoopAddObserver(CFRunLoopGetCurrent(),
-			 self->sup_observer,
+			 cf_observer,
 			 kCFRunLoopDefaultMode);
+    
+    SU_DEBUG_9(("su_port_osx_create() returns %p\n", self));
+    
+    return self;
+    
+  error:
+    su_perror(why);
+    su_port_osx_destroy(self), self = NULL;
 #endif
   }
-  else
-    return su_home_unref(su_port_home(self)), NULL;
-
+  
+  SU_DEBUG_9(("su_port_osx_create() returns %p\n", self));
+  
   return self;
 }
 
+
 static
 void cf_observer_cb(CFRunLoopObserverRef observer, 
 		    CFRunLoopActivity activity, 
 		    void *info)
 {
   CFRunLoopRef  rl;
-  struct osx_magic  *magic = (struct osx_magic *) info;
+  osx_magic_t  *magic = (osx_magic_t *) info;
   su_port_t    *self = magic->o_port;
   su_duration_t tout = 0;
   su_time_t     now = su_now();
 
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_base->sup_running) {
+  if (self->sup_running) {
 
-    if (self->sup_base->sup_prepoll)
-      self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
+    if (self->sup_prepoll)
+      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
     
-    if (self->sup_base->sup_head)
-      su_port_getmsgs(self);
+    if (self->sup_head)
+      su_port_osx_getmsgs(self);
     
-    if (self->sup_base->sup_timers)
-      su_timer_expire(&self->sup_base->sup_timers, &tout, now);
+    if (self->sup_timers)
+      su_timer_expire(&self->sup_timers, &tout, now);
   } else
     SU_DEBUG_9(("cf_observer_cb(): PORT IS NOT RUNNING!\n"));
 
@@ -328,13 +603,70 @@
 }
 
 /** @internal Destroy a port. */
-static void su_osx_port_deinit(void *arg)
+void su_port_osx_destroy(su_port_t *self)
 {
-  su_port_t *self = arg;
+  assert(self);
+
+  SU_DEBUG_9(("su_port_osx_destroy() called\n"));
+
+#if SU_HAVE_MBOX
+  if (self->sup_mbox[0] != INVALID_SOCKET) {
+    su_port_osx_unregister(self, NULL, &self->sup_mbox_wait, NULL, 
+		       (su_wakeup_arg_t *)self->sup_mbox);
+    su_wait_destroy(&self->sup_mbox_wait);
+    su_close(self->sup_mbox[0]); self->sup_mbox[0] = INVALID_SOCKET;
+#if HAVE_SOCKETPAIR
+    su_close(self->sup_mbox[1]); self->sup_mbox[1] = INVALID_SOCKET;
+#endif
+    SU_DEBUG_9(("su_port_osx_destroy() close mailbox\n"));
+  }
+#endif
+  if (self->sup_sources) 
+    free(self->sup_sources), self->sup_sources = NULL;
+  if (self->sup_sockets) 
+    free(self->sup_sockets), self->sup_sockets = NULL;
+  if (self->sup_waits) 
+    free(self->sup_waits), self->sup_waits = NULL;
+  if (self->sup_wait_cbs)
+    free(self->sup_wait_cbs), self->sup_wait_cbs = NULL;
+  if (self->sup_wait_args)
+    free(self->sup_wait_args), self->sup_wait_args = NULL;
+  if (self->sup_wait_roots)
+    free(self->sup_wait_roots), self->sup_wait_roots = NULL;
+  if (self->sup_reverses)
+    free(self->sup_reverses), self->sup_reverses = NULL;
+  if (self->sup_indices)
+    free(self->sup_indices), self->sup_indices = NULL;
+
+  SU_DEBUG_9(("su_port_osx_destroy() freed registrations\n"));
 
-  SU_DEBUG_9(("%s(%p) called\n", "su_osx_port_deinit", (void *)self));
+  su_home_zap(self->sup_home);
 
-  su_socket_port_deinit(self->sup_base);
+  SU_DEBUG_9(("su_port_osx_destroy() returns\n"));
+
+}
+
+static void su_port_osx_lock(su_port_t *self, char const *who)
+{
+  SU_PORT_OSX_LOCK(self, who);
+}
+
+static void su_port_osx_unlock(su_port_t *self, char const *who)
+{
+  SU_PORT_OSX_UNLOCK(self, who);
+}
+
+static void su_port_osx_incref(su_port_t *self, char const *who)
+{
+  SU_PORT_OSX_INCREF(self, who);
+}
+
+static void su_port_osx_decref(su_port_t *self, int blocking, char const *who)
+{
+  if (blocking)
+    SU_PORT_OSX_ZAPREF(self, who);
+  else
+    SU_PORT_OSX_DECREF(self, who);
 }
 
 static
@@ -360,7 +692,6 @@
 }
 
 
-#if 0
 static
 int map_cf_event_to_poll_event(CFSocketCallBackType type)
 {
@@ -380,18 +711,18 @@
 
   return event;
 }
-#endif
+
 
 static
-void su_osx_port_socket_cb(CFSocketRef s, 
+void su_port_osx_socket_cb(CFSocketRef s, 
 			   CFSocketCallBackType type, 
 			   CFDataRef address, 
 			   const void *data, 
 			   void *info)
 {
-  struct osx_magic *magic = (struct osx_magic *) info;
-  su_port_t        *self = magic->o_port;
-  int               curr = magic->o_current;
+  osx_magic_t       *magic = (osx_magic_t *) info;
+  su_port_t         *self = magic->o_port;
+  int                curr = magic->o_current;
   su_duration_t tout = 0;
   
 #if SU_HAVE_POLL
@@ -411,13 +742,13 @@
 			  &waits[n], 
 			  self->sup_wait_args[n]);
     
-    if (self->sup_base->sup_running) {
-      su_port_getmsgs(self);
+    if (self->sup_running) {
+      su_port_osx_getmsgs(self);
       
-      if (self->sup_base->sup_timers)
-	su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
+      if (self->sup_timers)
+	su_timer_expire(&self->sup_timers, &tout, su_now());
 
-      if (self->sup_base->sup_head)
+      if (self->sup_head)
 	tout = 0;
 
       /* CFRunLoopWakeUp(CFRunLoopGetCurrent()); */
@@ -430,20 +761,37 @@
   
 }
 
+#if SU_HAVE_MBOX
+/** @internal Message box wakeup function. */
+static int su_port_osx_wakeup(su_root_magic_t *magic, /* NULL */
+			      su_wait_t *w,
+			      su_wakeup_arg_t *arg)
+{
+  char buf[32];
+  su_socket_t s = *(su_socket_t *)arg;
+  su_wait_events(w, s);
+  recv(s, buf, sizeof(buf), 0);
+
+  /* CFRunLoopWakeUp(CFRunLoopGetCurrent()); */
+
+  return 0;
+}
+#endif
+
 /** @internal Send a message to the port. */
-int su_osx_port_send(su_port_t *self, su_msg_r rmsg)
+int su_port_osx_send(su_port_t *self, su_msg_r rmsg)
 {
   CFRunLoopRef rl;
 
   if (self) {
     int wakeup;
 
-    //XXX - mela SU_OSX_PORT_LOCK(self, "su_osx_port_send");
+    SU_PORT_OSX_LOCK(self, "su_port_osx_send");
     
-    wakeup = self->sup_base->sup_head == NULL;
+    wakeup = self->sup_head == NULL;
 
-    *self->sup_base->sup_tail = rmsg[0]; rmsg[0] = NULL;
-    self->sup_base->sup_tail = &(*self->sup_base->sup_tail)->sum_next;
+    *self->sup_tail = rmsg[0]; rmsg[0] = NULL;
+    self->sup_tail = &(*self->sup_tail)->sum_next;
 
 #if SU_HAVE_MBOX
     /* if (!pthread_equal(pthread_self(), self->sup_tid)) */
@@ -460,7 +808,7 @@
     }
 #endif
 
-    //XXX - mela SU_OSX_PORT_UNLOCK(self, "su_osx_port_send");
+    SU_PORT_OSX_UNLOCK(self, "su_port_osx_send");
 
     rl = CFRunLoopGetCurrent();
     CFRunLoopWakeUp(rl);
@@ -472,6 +820,48 @@
     return -1;
   }
 }
+
+/** @internal
+ * Execute the messages in the incoming queue until the queue is empty..
+ *
+ * @param self - pointer to a port object
+ *
+ * @retval Number of messages sent
+ */
+int su_port_osx_getmsgs(su_port_t *self)
+{
+  int n = 0;
+
+  if (self->sup_head) {
+    su_msg_f f;
+    su_msg_t *msg, *queue;
+
+    SU_PORT_OSX_LOCK(self, "su_port_getmsgs");
+
+    queue = self->sup_head;
+    self->sup_tail = &self->sup_head;
+    self->sup_head = NULL;
+
+    SU_PORT_OSX_UNLOCK(self, "su_port_osx_getmsgs");
+
+    for (msg = queue; msg; msg = queue) {
+      queue = msg->sum_next;
+      msg->sum_next = NULL;
+
+      f = msg->sum_func;
+      if (f) 
+	f(SU_ROOT_MAGIC(msg->sum_to->sut_root), &msg, msg->sum_data);
+      su_msg_delivery_report(&msg);
+      n++;
+    }
+
+    /* Check for wait events that may have been generated by messages */
+    su_port_osx_wait_events(self, 0);
+  }
+
+  return n;
+}
+
 static int o_count;
 
 /** @internal
@@ -492,9 +882,9 @@
  *              (0 is normal, 1 important, 2 realtime)
  * 
  * @return
- *   The function @su_osx_port_register returns nonzero index of the wait object, 
+ *   The function @su_port_osx_register returns nonzero index of the wait object, 
  *   or -1 upon an error.  */
-int su_osx_port_register(su_port_t *self,
+int su_port_osx_register(su_port_t *self,
 			 su_root_t *root, 
 			 su_wait_t *wait, 
 			 su_wakeup_f callback,
@@ -506,11 +896,11 @@
   CFRunLoopSourceRef *sources, source;
   CFSocketRef cf_socket, *sockets;
   int events = 0;
-  struct osx_magic *osx_magic = NULL;
+  osx_magic_t *osx_magic = NULL;
   CFSocketContext cf_socket_cntx[1] = {{0, NULL, NULL, NULL, NULL}};
   CFOptionFlags flags = 0;
 
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   n = self->sup_n_waits;
 
@@ -634,7 +1024,7 @@
 
   cf_socket = CFSocketCreateWithNative(NULL,
 				       (CFSocketNativeHandle) su_wait_socket(wait),
-				       events, su_osx_port_socket_cb, cf_socket_cntx);
+				       events, su_port_osx_socket_cb, cf_socket_cntx);
 
   flags = CFSocketGetSocketFlags(cf_socket);
   flags &= ~kCFSocketCloseOnInvalidate;
@@ -663,7 +1053,7 @@
 
 /** Deregister a su_wait_t object. */
 static
-int su_osx_port_deregister0(su_port_t *self, int i)
+int su_port_osx_deregister0(su_port_t *self, int i)
 {
   CFRunLoopRef rl;
   int n, N, *indices, *reverses;
@@ -737,7 +1127,7 @@
 
 /** Unregister a su_wait_t object.
  *  
- *  The function su_osx_port_unregister() unregisters a su_wait_t object. The
+ *  The function su_port_osx_unregister() unregisters a su_wait_t object. The
  *  wait object, a callback function and a argument are removed from the
  *  port object.
  * 
@@ -750,7 +1140,7 @@
  * 
  * @return Nonzero index of the wait object, or -1 upon an error.
  */
-int su_osx_port_unregister(su_port_t *self,
+int su_port_osx_unregister(su_port_t *self,
 		       su_root_t *root, 
 		       su_wait_t *wait,	
 		       su_wakeup_f callback, /* XXX - ignored */
@@ -759,13 +1149,13 @@
   int n, N;
 
   assert(self);
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   N = self->sup_n_waits;
 
   for (n = 0; n < N; n++) {
     if (SU_WAIT_CMP(wait[0], self->sup_waits[n]) == 0) {
-      return su_osx_port_deregister0(self, self->sup_reverses[n]);
+      return su_port_osx_deregister0(self, self->sup_reverses[n]);
     }
   }
 
@@ -776,7 +1166,7 @@
 
 /** Deregister a su_wait_t object.
  *  
- *  The function su_osx_port_deregister() deregisters a su_wait_t registrattion. 
+ *  The function su_port_osx_deregister() deregisters a su_wait_t registrattion. 
  *  The wait object, a callback function and a argument are removed from the
  *  port object.
  * 
@@ -785,13 +1175,13 @@
  * 
  * @return Index of the wait object, or -1 upon an error.
  */
-int su_osx_port_deregister(su_port_t *self, int i)
+int su_port_osx_deregister(su_port_t *self, int i)
 {
   su_wait_t wait[1] = { SU_WAIT_INIT };
   int retval;
 
   assert(self);
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   if (i <= 0 || i > self->sup_size_waits)
     return su_seterrno(EBADF);
@@ -799,7 +1189,7 @@
   if (self->sup_indices[i] < 0)
     return su_seterrno(EBADF);
     
-  retval = su_osx_port_deregister0(self, i);
+  retval = su_port_osx_deregister0(self, i);
 
   su_wait_destroy(wait);
 
@@ -810,7 +1200,7 @@
 /** @internal
  * Unregister all su_wait_t objects.
  *
- * The function su_osx_port_unregister_all() unregisters all su_wait_t objects
+ * The function su_port_osx_unregister_all() unregisters all su_wait_t objects
  * and destroys all queued timers associated with given root object.
  * 
  * @param  self     - pointer to port object
@@ -818,7 +1208,7 @@
  * 
  * @return Number of wait objects removed.
  */
-int su_osx_port_unregister_all(su_port_t *self, 
+int su_port_osx_unregister_all(su_port_t *self, 
 			   su_root_t *root)
 {
   int i, j, index, N;
@@ -831,7 +1221,7 @@
   CFRunLoopSourceRef *sources;
   CFSocketRef        *sockets;
 
-  // XXX - assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   N          = self->sup_n_waits;
   indices    = self->sup_indices;
@@ -905,7 +1295,7 @@
 
 /**Set mask for a registered event. @internal
  *
- * The function su_osx_port_eventmask() sets the mask describing events that can
+ * The function su_port_osx_eventmask() sets the mask describing events that can
  * signal the registered callback.
  *
  * @param port   pointer to port object
@@ -916,12 +1306,12 @@
  * @retval 0 when successful,
  * @retval -1 upon an error.
  */
-int su_osx_port_eventmask(su_port_t *self, int index, int socket, int events)
+int su_port_osx_eventmask(su_port_t *self, int index, int socket, int events)
 {
   int n, ret;
 
   assert(self);
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   if (index <= 0 || index > self->sup_size_waits)
     return su_seterrno(EBADF);
@@ -940,7 +1330,7 @@
 /** @internal
  *
  *  Copies the su_wait_t objects from the port. The number of wait objects
- *  can be found out by calling su_osx_port_query() with @a n_waits as zero.
+ *  can be found out by calling su_port_osx_query() with @a n_waits as zero.
  * 
  * @note This function is called only by friends.
  *
@@ -950,11 +1340,11 @@
  *
  * @return Number of wait objects, or 0 upon an error.
  */
-unsigned su_osx_port_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
+unsigned su_port_osx_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
 {
   unsigned n;
 
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   n = self->sup_n_waits;
 
@@ -970,7 +1360,7 @@
 
 /** @internal Enable multishot mode.
  *
- * The function su_osx_port_multishot() enables, disables or queries the
+ * The function su_port_osx_multishot() enables, disables or queries the
  * multishot mode for the port. The multishot mode determines how the events
  * are scheduled by port. If multishot mode is enabled, port serves all the
  * sockets that have received network events. If it is disables, only first
@@ -983,7 +1373,7 @@
  * @retval 1 multishot mode is enabled
  * @retval -1 an error occurred
  */
-int su_osx_port_multishot(su_port_t *self, int multishot)
+int su_port_osx_multishot(su_port_t *self, int multishot)
 {
   if (multishot < 0)
     return self->sup_multishot;
@@ -993,14 +1383,12 @@
     return (errno = EINVAL), -1;
 }
 
-#if 0
 /** @internal Enable threadsafe operation. */
 static
-int su_osx_port_threadsafe(su_port_t *port)
+int su_port_osx_threadsafe(su_port_t *port)
 {
   return su_home_threadsafe(port->sup_home);
 }
-#endif
 
 /** Prepare root to be run on OSX Run Loop.
  *
@@ -1020,23 +1408,23 @@
   CFRunLoopRef rl;
   su_duration_t tout = 0;
 
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   enter;
 
-  self->sup_base->sup_running = 1;
+  self->sup_running = 1;
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_base->sup_prepoll)
-    self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
+  if (self->sup_prepoll)
+    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
 
-  if (self->sup_base->sup_head)
-    su_port_getmsgs(self);
+  if (self->sup_head)
+    su_port_osx_getmsgs(self);
   
-  if (self->sup_base->sup_timers)
-    su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, su_now());
 
-  if (!self->sup_base->sup_running)
+  if (!self->sup_running)
     return;
 
   CFRetain(rl);
@@ -1047,45 +1435,45 @@
 
 /** @internal Main loop.
  * 
- * The function @c su_osx_port_run() waits for wait objects and the timers
+ * The function @c su_port_osx_run() waits for wait objects and the timers
  * associated with the port object.  When any wait object is signaled or
  * timer is expired, it invokes the callbacks, and returns waiting.
  * 
- * The function @c su_osx_port_run() runs until @c su_osx_port_break() is called
+ * The function @c su_port_osx_run() runs until @c su_port_osx_break() is called
  * from a callback.
  * 
  * @param self     pointer to port object
  * 
  */
-void su_osx_port_run(su_port_t *self)
+void su_port_osx_run(su_port_t *self)
 {
   CFRunLoopRef rl;
   su_duration_t tout = 0;
 
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
   enter;
 
-  self->sup_base->sup_running = 1;
+  self->sup_running = 1;
   rl = CFRunLoopGetCurrent();
 
-  if (self->sup_base->sup_prepoll)
-    self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
+  if (self->sup_prepoll)
+    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
 
-  if (self->sup_base->sup_head)
-    su_port_getmsgs(self);
+  if (self->sup_head)
+    su_port_osx_getmsgs(self);
   
-  if (self->sup_base->sup_timers)
-    su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, su_now());
 
-  if (!self->sup_base->sup_running)
+  if (!self->sup_running)
     return;
 
   CFRetain(rl);
   self->sup_main_loop = rl;
 
   /* if there are messages do a quick wait */
-  if (self->sup_base->sup_head)
+  if (self->sup_head)
     tout = 0;
 
   CFRunLoopRun();
@@ -1096,70 +1484,70 @@
 
 #if tuning
 /* This version can help tuning... */
-void su_osx_port_run_tune(su_port_t *self)
+void su_port_osx_run_tune(su_port_t *self)
 {
   int i;
   int timers = 0, messages = 0, events = 0;
   su_duration_t tout = 0, tout0;
   su_time_t started = su_now(), woken = started, bedtime = woken;
 
-  // XXX - mela assert(SU_OSX_PORT_OWN_THREAD(self));
+  assert(SU_PORT_OSX_OWN_THREAD(self));
 
-  for (self->sup_base->sup_running = 1; self->sup_base->sup_running;) {
+  for (self->sup_running = 1; self->sup_running;) {
     tout0 = tout, tout = 2000;
 
     timers = 0, messages = 0;
 
-    if (self->sup_base->sup_prepoll)
-      self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
+    if (self->sup_prepoll)
+      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
 
-    if (self->sup_base->sup_head)
-      messages = su_port_getmsgs(self);
+    if (self->sup_head)
+      messages = su_port_osx_getmsgs(self);
 
-    if (self->sup_base->sup_timers)
-      timers = su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
+    if (self->sup_timers)
+      timers = su_timer_expire(&self->sup_timers, &tout, su_now());
 
-    if (!self->sup_base->sup_running)
+    if (!self->sup_running)
       break;
 
-    if (self->sup_base->sup_head)      /* if there are messages do a quick wait */
+    if (self->sup_head)      /* if there are messages do a quick wait */
       tout = 0;
 
     bedtime = su_now();
 
-    events = su_osx_port_wait_events(self, tout);
+    events = su_port_osx_wait_events(self, tout);
 
     woken = su_now();
 
     if (messages || timers || events)
-      SU_DEBUG_1(("su_osx_port_run(%p): %.6f: %u messages %u timers %u "
+      SU_DEBUG_1(("su_port_osx_run(%p): %.6f: %u messages %u timers %u "
 		  "events slept %.6f/%.3f\n",
 		  self, su_time_diff(woken, started), messages, timers, events,
 		  su_time_diff(woken, bedtime), tout0 * 1e-3));
 
-    if (!self->sup_base->sup_running)
+    if (!self->sup_running)
       break;
   }
 }
 #endif
 
 /** @internal
- * The function @c su_osx_port_break() is used to terminate execution of @c
- * su_osx_port_run(). It can be called from a callback function.
+ * The function @c su_port_osx_break() is used to terminate execution of @c
+ * su_port_osx_run(). It can be called from a callback function.
  * 
  * @param self     pointer to port
  * 
  */
-void su_osx_port_break(su_port_t *self)
+void su_port_osx_break(su_port_t *self)
 {
   if (self->sup_main_loop)
     CFRunLoopStop(self->sup_main_loop);
 
-  self->sup_base->sup_running = 0; 
+  self->sup_running = 0; 
 }
 
 /** @internal
- * The function @c su_osx_port_wait_events() is used to poll() for wait objects
+ * The function @c su_port_osx_wait_events() is used to poll() for wait objects
  *
  * @param self     pointer to port
  * @param tout     timeout in milliseconds
@@ -1167,7 +1555,7 @@
  * @return number of events handled
  */
 static
-int su_osx_port_wait_events(su_port_t *self, su_duration_t tout)
+int su_port_osx_wait_events(su_port_t *self, su_duration_t tout)
 {
   int i, events = 0;
   su_wait_t *waits = self->sup_waits;
@@ -1212,6 +1600,21 @@
   return events;
 }
 
+/** @internal 
+ * Used to check wait events in callbacks that take lots of time
+ *
+ * This function does a timeout 0 poll() and runs wait objects.
+ *
+ * @param port     pointer to port
+ *
+ * @return number of events handled
+ */
+static
+int su_port_osx_yield(su_port_t *port)
+{
+  return su_port_osx_wait_events(port, 0);
+}
+
 /** @internal Block until wait object is signaled or timeout.
  *
  * This function waits for wait objects and the timers associated with 
@@ -1228,13 +1631,15 @@
  *   Milliseconds to the next invocation of timer, or @c SU_WAIT_FOREVER if
  *   there are no active timers.
  */
-su_duration_t su_osx_port_step(su_port_t *self, su_duration_t tout)
+su_duration_t su_port_osx_step(su_port_t *self, su_duration_t tout)
 {
   CFRunLoopRef rl;
   su_time_t now = su_now();
   CFAbsoluteTime start;
   int ret, timeout = tout > INT32_MAX ? INT32_MAX : tout;
 
+  assert(SU_PORT_OSX_OWN_THREAD(self));
+
   rl = CFRunLoopGetCurrent();
 
   if (!rl)
@@ -1245,33 +1650,138 @@
   if (tout < timeout)
     timeout = tout;
 
-  if (self->sup_base->sup_prepoll)
-    self->sup_base->sup_prepoll(self->sup_base->sup_pp_magic, self->sup_base->sup_pp_root);
+  if (self->sup_prepoll)
+    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
 
-  if (self->sup_base->sup_head)
-    su_base_port_getmsgs(self);
+  if (self->sup_head)
+    su_port_osx_getmsgs(self);
 
-  if (self->sup_base->sup_timers)
-    su_timer_expire(&self->sup_base->sup_timers, &tout, now);
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, now);
 
   /* if there are messages do a quick wait */
-  if (self->sup_base->sup_head)
+  if (self->sup_head)
     tout = 0;
 
-  ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
-			   tout/1000000.0,
-			   true);
-
-  CFRunLoopWakeUp(rl);
+  start = CFAbsoluteTimeGetCurrent();
+  for (;;) {
+    /* Run loop with only one pass, indicate if a source was processed */
+    ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
+			     0,
+			     TRUE);
+
+    /* Ok, one of our sources was fired */
+    if (self->sup_source_fired == 1) {
+      self->sup_source_fired = 0;
+      break;
+    }
 
-  if (self->sup_base->sup_head)
-    su_base_port_getmsgs(self);
+    /* Check how long to run this loop */
+    if (CFAbsoluteTimeGetCurrent() >= start + timeout / 1000)
+      break;
+  }
+  
+  if (self->sup_head)
+    su_port_osx_getmsgs(self);
 
-  if (self->sup_base->sup_timers)
-    su_timer_expire(&self->sup_base->sup_timers, &tout, su_now());
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, su_now());
 
-  if (self->sup_base->sup_head)
+  if (self->sup_head)
     tout = 0;
 
   return tout;
 }
+
+
+/** @internal
+ * Checks if the calling thread owns the port object.
+ *
+ * @param self pointer to a port object
+ *
+ * @retval true (nonzero) if the calling thread owns the port,
+ * @retval false (zero) otherwise.
+ */
+int su_port_osx_own_thread(su_port_t const *self)
+{
+  return self == NULL || SU_PORT_OSX_OWN_THREAD(self);
+}
+
+#if 0
+/** @internal
+ *  Prints out the contents of the port.
+ *
+ * @param self pointer to a port
+ * @param f    pointer to a file (if @c NULL, uses @c stdout).
+ */
+void su_port_osx_dump(su_port_t const *self, FILE *f)
+{
+  int i;
+#define IS_WAIT_IN(x) (((x)->events & SU_WAIT_IN) ? "IN" : "")
+#define IS_WAIT_OUT(x) (((x)->events & SU_WAIT_OUT) ? "OUT" : "")
+#define IS_WAIT_ACCEPT(x) (((x)->events & SU_WAIT_ACCEPT) ? "ACCEPT" : "")
+
+  if (f == NULL)
+    f = stdout;
+
+  fprintf(f, "su_port_osx_t at %p:\n", self);
+  fprintf(f, "\tport is%s running\n", self->sup_running ? "" : "not ");
+#if SU_HAVE_PTHREADS
+  fprintf(f, "\tport tid %p\n", (void *)self->sup_tid);
+#endif
+#if SU_HAVE_MBOX
+  fprintf(f, "\tport mbox %d (%s%s%s)\n", self->sup_mbox[0],
+	  IS_WAIT_IN(&self->sup_mbox_wait),
+	  IS_WAIT_OUT(&self->sup_mbox_wait),
+	  IS_WAIT_ACCEPT(&self->sup_mbox_wait));
+#endif
+  fprintf(f, "\t%d wait objects\n", self->sup_n_waits);
+  for (i = 0; i < self->sup_n_waits; i++) {
+    
+  }
+}
+
+#endif
+
+/* =========================================================================
+ * Pre-poll() callback
+ */
+
+int su_port_osx_add_prepoll(su_port_t *port,
+			su_root_t *root, 
+			su_prepoll_f *callback, 
+			su_prepoll_magic_t *magic)
+{
+  if (port->sup_prepoll)
+    return -1;
+
+  port->sup_prepoll = callback;
+  port->sup_pp_magic = magic;
+  port->sup_pp_root = root;
+
+  return 0;
+}
+
+int su_port_osx_remove_prepoll(su_port_t *port,
+			   su_root_t *root)
+{
+  if (port->sup_pp_root != root)
+    return -1;
+
+  port->sup_prepoll = NULL;
+  port->sup_pp_magic = NULL;
+  port->sup_pp_root = NULL;
+
+  return 0;
+}
+
+/* =========================================================================
+ * Timers
+ */
+
+static
+su_timer_t **su_port_osx_timers(su_port_t *self)
+{
+  return &self->sup_timers;
+}
+

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c	Sat Feb 17 01:25:21 2007
@@ -27,9 +27,8 @@
  *
  * OS-Independent Socket Syncronization Interface.
  *
- * This looks like nth reincarnation of "reactor". It implements the
- * poll/select/WaitForMultipleObjects and message passing functionality. 
- * This is virtual implementation:
+ * This looks like nth reincarnation of "reactor".  It implements the
+ * poll/select/WaitForMultipleObjects and message passing functionality.
  *
  * @author Pekka Pessi <Pekka.Pessi at nokia.com>
  * @author Kai Vehmanen <kai.vehmanen at nokia.com>
@@ -39,398 +38,1443 @@
 
 #include "config.h"
 
-#define SU_CLONE_T      su_msg_t
+/* React to multiple events per one poll() to make sure 
+ * that high-priority events can never completely mask other events.
+ * Enabled by default on all platforms except WIN32 */
+#ifndef WIN32
+#define SU_ENABLE_MULTISHOT_POLL 1
+#else
+#define SU_ENABLE_MULTISHOT_POLL 0
+#endif
+
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
 
-#define su_port_s su_virtual_port_s
+#define SU_PORT_IMPLEMENTATION 1
 
+#include "sofia-sip/su.h"
 #include "su_port.h"
+#include "sofia-sip/su_alloc.h"
 
-#include <string.h>
-#include <stdlib.h>
+#if SU_HAVE_PTHREADS
+/* Pthread implementation */
+#include <pthread.h>
+#define SU_HAVE_MBOX 1
+#else
+#define SU_HAVE_MBOX 0
+#endif
+
+#if HAVE_SOCKETPAIR
+#define MBOX_SEND  1
+#else
+#define MBOX_SEND  0
+#endif
 
-/** Create the default su_port_t implementation. */
-su_port_t *su_default_port_create(void)
-{
 #if HAVE_EPOLL
-  return su_epoll_port_create();
-#elif HAVE_POLL_PORT
-  return su_poll_port_create();
-#elif HAVE_WIN32
-  return su_wsaevent_port_create();
-#elif HAVE_SELECT
-  return su_select_port_create();
+#include <sys/epoll.h>
+
+#define POLL2EPOLL_NEEDED \
+  (POLLIN != EPOLLIN || POLLOUT != EPOLLOUT || POLLPRI != EPOLLPRI || \
+   POLLERR != EPOLLERR || POLLHUP != EPOLLHUP)
+ 
+#define POLL2EPOLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
+#define EPOLL2POLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
+
+#endif
+
+static void su_port_lock(su_port_t *self, char const *who);
+static void su_port_unlock(su_port_t *self, char const *who);
+static void su_port_incref(su_port_t *self, char const *who);
+static void su_port_decref(su_port_t *self, int blocking, char const *who);
+
+static struct _GSource *su_port_gsource(su_port_t *port);
+
+static int su_port_send(su_port_t *self, su_msg_r rmsg);
+
+static int su_port_register(su_port_t *self,
+			    su_root_t *root, 
+			    su_wait_t *wait, 
+			    su_wakeup_f callback,
+			    su_wakeup_arg_t *arg,
+			    int priority);
+static int su_port_unregister(su_port_t *port,
+			      su_root_t *root, 
+			      su_wait_t *wait,	
+			      su_wakeup_f callback, 
+			      su_wakeup_arg_t *arg);
+
+static int su_port_deregister(su_port_t *self, int i);
+
+static int su_port_unregister_all(su_port_t *self,
+			   su_root_t *root);
+static
+int su_port_eventmask(su_port_t *self, int index, int socket, int events);
+static
+void su_port_run(su_port_t *self);
+static
+void su_port_break(su_port_t *self);
+static
+su_duration_t su_port_step(su_port_t *self, su_duration_t tout);
+
+static
+int su_port_own_thread(su_port_t const *port);
+
+static
+int su_port_add_prepoll(su_port_t *port,
+			su_root_t *root, 
+			su_prepoll_f *, 
+			su_prepoll_magic_t *);
+
+static
+int su_port_remove_prepoll(su_port_t *port,
+			   su_root_t *root);
+
+static
+su_timer_t **su_port_timers(su_port_t *port);
+
+static
+int su_port_multishot(su_port_t *port, int multishot);
+
+static
+int su_port_threadsafe(su_port_t *port);
+
+static
+int su_port_yield(su_port_t *port);
+
+su_port_vtable_t const su_port_vtable[1] =
+  {{
+      /* su_vtable_size: */ sizeof su_port_vtable,
+      su_port_lock,
+      su_port_unlock,
+      su_port_incref,
+      su_port_decref,
+      su_port_gsource,
+      su_port_send,
+      su_port_register,
+      su_port_unregister,
+      su_port_deregister,
+      su_port_unregister_all,
+      su_port_eventmask,
+      su_port_run,
+      su_port_break,
+      su_port_step,
+      su_port_own_thread,
+      su_port_add_prepoll,
+      su_port_remove_prepoll,
+      su_port_timers,
+      su_port_multishot,
+      su_port_threadsafe,
+      su_port_yield
+    }};
+
+static int su_port_wait_events(su_port_t *self, su_duration_t tout);
+
+
+/** 
+ * Port is a per-thread reactor.  
+ *
+ * Multiple root objects executed by single thread share a su_port_t object. 
+ */
+struct su_port_s {
+  su_home_t        sup_home[1];
+
+  su_port_vtable_t const *sup_vtable;
+  
+  unsigned         sup_running;
+
+#if SU_HAVE_PTHREADS
+  pthread_t        sup_tid;
+  pthread_mutex_t  sup_mutex[1];
+#if __CYGWIN__
+  pthread_mutex_t  sup_reflock[1];
+  int              sup_ref;
 #else
-  return NULL;
+  pthread_rwlock_t sup_ref[1];
+#endif
+#else
+  int              sup_ref;
+#endif
+
+#if SU_HAVE_MBOX
+  su_socket_t      sup_mbox[MBOX_SEND + 1];
+  su_wait_t        sup_mbox_wait;
 #endif
-}
 
-int su_default_clone_start(su_root_t *parent,
-			   su_clone_r return_clone,
-			   su_root_magic_t *magic,
-			   su_root_init_f init,
-			   su_root_deinit_f deinit)
-{
 #if HAVE_EPOLL
-  return su_epoll_clone_start(parent, return_clone, magic, init, deinit);;
-#elif HAVE_POLL_PORT
-  return su_poll_clone_start(parent, return_clone, magic, init, deinit);;
-#elif HAVE_WIN32
-  return su_wsaevent_clone_start(parent, return_clone, magic, init, deinit);;
-#elif HAVE_SELECT
-  return su_select_clone_start(parent, return_clone, magic, init, deinit);;
+  /** epoll() fd */
+  int              sup_epoll;
+#endif
+
+  unsigned         sup_multishot; /**< Multishot operation? */
+
+  unsigned         sup_registers; /** Counter incremented by 
+				      su_port_register() or 
+				      su_port_unregister()
+				   */
+  int              sup_n_waits; /**< Active su_wait_t in su_waits */
+  int              sup_size_waits; /**< Size of allocate su_waits */
+
+  int              sup_pri_offset; /**< Offset to prioritized waits */
+
+#if !SU_HAVE_WINSOCK
+#define INDEX_MAX (0x7fffffff)
+#else 
+  /* We use WSAWaitForMultipleEvents() */
+#define INDEX_MAX (64)
+#endif
+
+  /** Indices from index returned by su_root_register() to tables below. 
+   *
+   * Free elements are negative. Free elements form a list, value of free
+   * element is (0 - index of next free element).
+   *
+   * First element sup_indices[0] points to first free element. 
+   */
+  int             *sup_indices;
+
+  int             *sup_reverses; /** Reverse index */
+  su_wakeup_f     *sup_wait_cbs; 
+  su_wakeup_arg_t**sup_wait_args; 
+  su_root_t      **sup_wait_roots; 
+
+  su_wait_t       *sup_waits; 
+
+  /* Pre-poll callback */
+  su_prepoll_f    *sup_prepoll; 
+  su_prepoll_magic_t *sup_pp_magic;
+  su_root_t       *sup_pp_root;
+
+  /* Timer list */
+  su_timer_t      *sup_timers;
+
+  /* Message list - this is protected by lock  */
+  su_msg_t        *sup_head;
+  su_msg_t       **sup_tail;
+};
+
+#if SU_HAVE_PTHREADS
+#define SU_PORT_OWN_THREAD(p)   (pthread_equal((p)->sup_tid, pthread_self()))
+
+#if __CYGWIN__
+
+/* Debugging versions */
+#define SU_PORT_INITREF(p)      (pthread_mutex_init((p)->sup_reflock, NULL), printf("initref(%p)\n", (p)))
+#define SU_PORT_INCREF(p, f)    (pthread_mutex_lock(p->sup_reflock), p->sup_ref++, pthread_mutex_unlock(p->sup_reflock), printf("incref(%p) by %s\n", (p), f))
+#define SU_PORT_DECREF(p, f)    do {					\
+    pthread_mutex_lock(p->sup_reflock);	p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
+    if ((p->sup_ref) == 0) {			\
+      printf("decref(%p) to 0 by %s\n", (p), f); su_port_destroy(p); }	\
+    else { printf("decref(%p) to %u by %s\n", (p), p->sup_ref, f); }  } while(0)
+
+#define SU_PORT_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
+    pthread_mutex_lock(p->sup_reflock);	p->sup_ref--; pthread_mutex_unlock(p->sup_reflock); \
+  if ((p->sup_ref) != 0) { \
+    assert(!"SU_PORT_ZAPREF"); } \
+  su_port_destroy(p); } while(0)
+
+#define SU_PORT_INITLOCK(p) \
+   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
+
+#define SU_PORT_LOCK(p, f)    \
+   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
+
+#define SU_PORT_UNLOCK(p, f)  \
+  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
+
+#elif 1
+#define SU_PORT_INITREF(p)      (pthread_rwlock_init(p->sup_ref, NULL))
+#define SU_PORT_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref))
+#define SU_PORT_DECREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
+  if (pthread_rwlock_trywrlock(p->sup_ref) == 0) su_port_destroy(p); } while(0)
+
+#define SU_PORT_ZAPREF(p, f)    do { pthread_rwlock_unlock(p->sup_ref); \
+  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
+    assert(!"SU_PORT_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
+  su_port_destroy(p); } while(0)
+
+#define SU_PORT_INITLOCK(p)     (pthread_mutex_init((p)->sup_mutex, NULL))
+#define SU_PORT_LOCK(p, f)      (pthread_mutex_lock((p)->sup_mutex))
+#define SU_PORT_UNLOCK(p, f)    (pthread_mutex_unlock((p)->sup_mutex))
+
 #else
-  errno = ENOSYS;
-  return -1;
+
+/* Debugging versions */
+#define SU_PORT_INITREF(p)      (pthread_rwlock_init((p)->sup_ref, NULL), printf("initref(%p)\n", (p)))
+#define SU_PORT_INCREF(p, f)    (pthread_rwlock_rdlock(p->sup_ref), printf("incref(%p) by %s\n", (p), f))
+#define SU_PORT_DECREF(p, f)    do {					\
+    pthread_rwlock_unlock(p->sup_ref);					\
+    if (pthread_rwlock_trywrlock(p->sup_ref) == 0) {			\
+      printf("decref(%p) to 0 by %s\n", (p), f); su_port_destroy(p); }	\
+    else { printf("decref(%p) by %s\n", (p), f); }  } while(0)
+
+#define SU_PORT_ZAPREF(p, f)    do { printf("zapref(%p) by %s\n", (p), f), \
+  pthread_rwlock_unlock(p->sup_ref); \
+  if (pthread_rwlock_trywrlock(p->sup_ref) != 0) { \
+    assert(!"SU_PORT_ZAPREF"); pthread_rwlock_wrlock(p->sup_ref); } \
+  su_port_destroy(p); } while(0)
+
+#define SU_PORT_INITLOCK(p) \
+   (pthread_mutex_init((p)->sup_mutex, NULL), printf("init_lock(%p)\n", p))
+
+#define SU_PORT_LOCK(p, f)    \
+   (printf("%ld at %s locking(%p)...", pthread_self(), f, p), pthread_mutex_lock((p)->sup_mutex), printf(" ...%ld at %s locked(%p)...", pthread_self(), f, p))
+
+#define SU_PORT_UNLOCK(p, f)  \
+  (pthread_mutex_unlock((p)->sup_mutex), printf(" ...%ld at %s unlocked(%p)\n", pthread_self(), f, p))
+
+#endif
+
+#else /* !SU_HAVE_PTHREADS */
+
+#define SU_PORT_OWN_THREAD(p)  1
+#define SU_PORT_INITLOCK(p)    (void)(p)
+#define SU_PORT_LOCK(p, f)      (void)(p)
+#define SU_PORT_UNLOCK(p, f)    (void)(p)
+#define SU_PORT_ZAPREF(p, f)    ((p)->sup_ref--)
+
+#define SU_PORT_INITREF(p)      ((p)->sup_ref = 1)
+#define SU_PORT_INCREF(p, f)    ((p)->sup_ref++)
+#define SU_PORT_DECREF(p, f) \
+do { if (--((p)->sup_ref) == 0) su_port_destroy(p); } while (0);
+
+#endif
+
+#if SU_HAVE_MBOX
+static int su_port_wakeup(su_root_magic_t *magic, 
+			  su_wait_t *w,
+			  su_wakeup_arg_t *arg);
 #endif
-}
 
-static su_port_create_f *preferred_su_port_create = su_default_port_create;
-static su_clone_start_f *preferred_su_clone_start;
+static void su_port_destroy(su_port_t *self);
 
-/** Explicitly set the preferred su_port_t implementation.
+/**@internal
  *
- * @sa su_epoll_port_create(), su_poll_port_create(), su_select_port_create()
+ * Allocates and initializes a message port. It creates a mailbox used to.
+ * wake up the tasks waiting on the port if needed.  Currently, the
+ * mailbox is simply an UDP socket connected to itself.
+ *
+ * @return
+ *   If successful a pointer to the new message port is returned, otherwise
+ *   NULL is returned.  
  */
-void su_port_prefer(su_port_create_f *create,
-		    su_clone_start_f *start)
+su_port_t *su_port_create(void)
 {
-  if (create) preferred_su_port_create = create;
-  if (start) preferred_su_clone_start = start;
-}
+  su_port_t *self;
 
-void su_port_set_system_preferences(char const *name)
-{
-  su_port_create_f *create = preferred_su_port_create;
-  su_clone_start_f *start = preferred_su_clone_start;
+  SU_DEBUG_9(("su_port_create() called\n"));
+
+  self = su_home_clone(NULL, sizeof(*self));
+
+  if (self) {
+#if SU_HAVE_MBOX
+    int af;
+    su_socket_t mb = INVALID_SOCKET;
+    char const *why;
+#endif
+
+    self->sup_vtable = su_port_vtable;
+    
+    SU_PORT_INITREF(self);
+    SU_PORT_INITLOCK(self);
+    self->sup_tail = &self->sup_head;
+
+    self->sup_multishot = (SU_ENABLE_MULTISHOT_POLL) != 0;
+
+#if SU_HAVE_PTHREADS
+    self->sup_tid = pthread_self();
+#endif
 
-  if (name == NULL)
-      ;
 #if HAVE_EPOLL
-  else if (strcmp(name, "epoll") == 0) {
-    create = su_epoll_port_create;
-    start = su_epoll_clone_start;
-  }
+    self->sup_epoll = epoll_create(su_root_size_hint);
+    if (self->sup_epoll == -1)
+      SU_DEBUG_3(("su_port(%p): epoll_create(): %s\n", self, strerror(errno)));
+    else
+      SU_DEBUG_9(("su_port(%p): epoll_create() => %u: OK\n",
+		  self, self->sup_epoll));
 #endif
-#if HAVE_POLL_PORT
-  else if (strcmp(name, "poll") == 0) {
-    create = su_poll_port_create;
-    start = su_poll_clone_start;
-  }
+  
+#if SU_HAVE_MBOX
+#if HAVE_SOCKETPAIR
+#if defined(AF_LOCAL)
+    af = AF_LOCAL;
+#else
+    af = AF_UNIX;
+#endif
+    if (socketpair(af, SOCK_STREAM, 0, self->sup_mbox) == -1) {
+      why = "su_port_init: socketpair"; goto error;
+    }
+
+    mb = self->sup_mbox[0];
+    su_setblocking(self->sup_mbox[0], 0);
+    su_setblocking(self->sup_mbox[1], 0);
+#else
+    {
+      struct sockaddr_in sin = { sizeof(struct sockaddr_in), 0 };
+      socklen_t sinsize = sizeof sin;
+      struct sockaddr *sa = (struct sockaddr *)&sin;
+
+      af = PF_INET;
+
+      self->sup_mbox[0] = mb = su_socket(af, SOCK_DGRAM, IPPROTO_UDP);
+      if (mb == INVALID_SOCKET) {
+	why = "su_port_init: socket"; goto error;
+      }
+  
+      sin.sin_family = AF_INET;
+      sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* 127.1 */
+      
+      /* Get a port for us */
+      if (bind(mb, sa, sizeof sin) == -1) {
+	why = "su_port_init: bind"; goto error;
+      }
+
+      if (getsockname(mb, sa, &sinsize) == -1) {
+	why = "su_port_init: getsockname"; goto error;
+      }
+    
+      if (connect(mb, sa, sinsize) == -1) {
+	why = "su_port_init: connect"; goto error;
+      }
+    }
+#endif    
+
+    if (su_wait_create(&self->sup_mbox_wait, mb, SU_WAIT_IN) == -1) {
+      why = "su_port_init: su_wait_create"; goto error;
+    }
+
+    if (su_port_register(self, NULL, &self->sup_mbox_wait, su_port_wakeup, 
+			 (su_wakeup_arg_t *)self->sup_mbox, 0)
+	== -1) {
+      why = "su_port_create: su_port_register"; goto error;
+    }
+
+    SU_DEBUG_9(("su_port_create() returns %p\n", self));
+
+    return self;
+
+  error:
+    su_perror(why);
+    su_port_destroy(self), self = NULL;
 #endif
-#if HAVE_WIN32
-  else if (strcasecmp(name, "wsaevent") == 0) {
-    create = su_wsaevent_port_create;
-    start = su_wsaevent_clone_start;
   }
+
+  SU_DEBUG_9(("su_port_create() returns %p\n", self));
+
+  return self;
+}
+
+/** @internal Destroy a port. */
+void su_port_destroy(su_port_t *self)
+{
+  assert(self);
+
+  SU_DEBUG_9(("su_port_destroy() called\n"));
+
+#if SU_HAVE_MBOX
+  if (self->sup_mbox[0] != INVALID_SOCKET) {
+    su_port_unregister(self, NULL, &self->sup_mbox_wait, NULL, 
+		       (su_wakeup_arg_t *)self->sup_mbox);
+    su_wait_destroy(&self->sup_mbox_wait);
+    su_close(self->sup_mbox[0]); self->sup_mbox[0] = INVALID_SOCKET;
+#if HAVE_SOCKETPAIR
+    su_close(self->sup_mbox[1]); self->sup_mbox[1] = INVALID_SOCKET;
 #endif
-#if HAVE_SELECT && !HAVE_WIN32
-  else if (strcmp(name, "select") == 0) {
-    create = su_select_port_create;
-    start = su_select_clone_start;
+    SU_DEBUG_9(("su_port_destroy() close mailbox\n"));
   }
 #endif
+  if (self->sup_waits) 
+    free(self->sup_waits), self->sup_waits = NULL;
+  if (self->sup_wait_cbs)
+    free(self->sup_wait_cbs), self->sup_wait_cbs = NULL;
+  if (self->sup_wait_args)
+    free(self->sup_wait_args), self->sup_wait_args = NULL;
+  if (self->sup_wait_roots)
+    free(self->sup_wait_roots), self->sup_wait_roots = NULL;
+  if (self->sup_reverses)
+    free(self->sup_reverses), self->sup_reverses = NULL;
+  if (self->sup_indices)
+    free(self->sup_indices), self->sup_indices = NULL;
 
-  if (create == NULL) 
-    create = su_default_port_create;
+  SU_DEBUG_9(("su_port_destroy() freed registrations\n"));
 
-  if (!preferred_su_port_create ||
-      preferred_su_port_create == su_default_port_create) 
-    preferred_su_port_create = create;
+  su_home_zap(self->sup_home);
 
-  if (start == NULL)
-    start = su_default_clone_start;
+  SU_DEBUG_9(("su_port_destroy() returns\n"));
 
-  if (!preferred_su_clone_start || 
-      preferred_su_clone_start == su_default_clone_start)
-    preferred_su_clone_start = start;
 }
 
-/** Create the preferred su_port_t implementation. */
-su_port_t *su_port_create(void)
+static void su_port_lock(su_port_t *self, char const *who)
+{
+  SU_PORT_LOCK(self, who);
+}
+
+static void su_port_unlock(su_port_t *self, char const *who)
+{
+  SU_PORT_UNLOCK(self, who);
+}
+
+static void su_port_incref(su_port_t *self, char const *who)
+{
+  SU_PORT_INCREF(self, who);
+}
+
+static void su_port_decref(su_port_t *self, int blocking, char const *who)
+{
+  if (blocking)
+    SU_PORT_ZAPREF(self, who);
+  else
+    SU_PORT_DECREF(self, who);
+}
+
+static struct _GSource *su_port_gsource(su_port_t *self)
 {
-  if (preferred_su_port_create == NULL)
-    su_port_set_system_preferences(getenv("SU_PORT"));
+  return NULL;
+}
 
-  return preferred_su_port_create();
+#if SU_HAVE_MBOX
+/** @internal Message box wakeup function. */
+static int su_port_wakeup(su_root_magic_t *magic, /* NULL */
+			  su_wait_t *w,
+			  su_wakeup_arg_t *arg)
+{
+  char buf[32];
+  su_socket_t s = *(su_socket_t *)arg;
+  su_wait_events(w, s);
+  recv(s, buf, sizeof(buf), 0);
+  return 0;
 }
+#endif
+
+/** @internal Send a message to the port. */
+int su_port_send(su_port_t *self, su_msg_r rmsg)
+{
+  if (self) {
+    int wakeup;
+
+    SU_PORT_LOCK(self, "su_port_send");
+    
+    wakeup = self->sup_head == NULL;
+
+    *self->sup_tail = rmsg[0]; rmsg[0] = NULL;
+    self->sup_tail = &(*self->sup_tail)->sum_next;
 
-/* ========================================================================
- * su_clone_t
+#if SU_HAVE_MBOX
+    /* if (!pthread_equal(pthread_self(), self->sup_tid)) */
+    if (wakeup)
+    {
+      assert(self->sup_mbox[MBOX_SEND] != INVALID_SOCKET);
+
+      if (send(self->sup_mbox[MBOX_SEND], "X", 1, 0) == -1) {
+#if HAVE_SOCKETPAIR
+	if (su_errno() != EWOULDBLOCK)
+#endif
+	  su_perror("su_msg_send: send()");
+      }
+    }
+#endif
+
+    SU_PORT_UNLOCK(self, "su_port_send");
+
+    return 0;
+  }
+  else {
+    su_msg_destroy(rmsg);
+    return -1;
+  }
+}
+
+/** @internal
+ * Execute the messages in the incoming queue until the queue is empty..
+ *
+ * @param self - pointer to a port object
+ *
+ * @retval Number of messages sent
  */
+int su_port_getmsgs(su_port_t *self)
+{
+  int n = 0;
 
-/**@ingroup su_wait
- * 
- * @page su_clone_t Clone Objects
+  if (self->sup_head) {
+    su_msg_f f;
+    su_msg_t *msg, *queue;
+
+    SU_PORT_LOCK(self, "su_port_getmsgs");
+
+    queue = self->sup_head;
+    self->sup_tail = &self->sup_head;
+    self->sup_head = NULL;
+
+    SU_PORT_UNLOCK(self, "su_port_getmsgs");
+
+    for (msg = queue; msg; msg = queue) {
+      queue = msg->sum_next;
+      msg->sum_next = NULL;
+
+      f = msg->sum_func;
+      if (f) 
+	f(SU_ROOT_MAGIC(msg->sum_to->sut_root), &msg, msg->sum_data);
+      su_msg_delivery_report(&msg);
+      n++;
+    }
+
+    /* Check for wait events that may have been generated by messages */
+    su_port_wait_events(self, 0);
+  }
+
+  return n;
+}
+
+/** @internal
+ *
+ *  Register a @c su_wait_t object. The wait object, a callback function and
+ *  a argument pointer is stored in the port object.  The callback function
+ *  will be called when the wait object is signaled.
  *
- * The process may be divided into many tasks via cloning. Several tasks may
- * run in context of one thread, or each task may be run by its own thread. 
- * However, only a single thread can execute code within a task. There can
- * be a 1-to-N mapping from thread to tasks. Thus, software using tasks can
- * be executed by multiple threads in a multithreaded environment and by a
- * single thread in a singlethreaded environment.
+ *  Please note if identical wait objects are inserted, only first one is
+ *  ever signalled.
  * 
- * The clones are useful for handling tasks that can be executed by a
- * separate threads, but which do not block excessively. When threads are
- * not available or they are not needed, clones can also be run in a
- * single-threaded mode. Running in single-threaded mode is especially
- * useful while debugging.
+ * @param self	     pointer to port
+ * @param root	     pointer to root object
+ * @param waits	     pointer to wait object
+ * @param callback   callback function pointer
+ * @param arg	     argument given to callback function when it is invoked
+ * @param priority   relative priority of the wait object 
+ *              (0 is normal, 1 important, 2 realtime)
  * 
- * A clone task is created with function su_clone_start(). Each clone has
- * its own root object (su_root_t), which holds a context pointer
- * (su_root_magic_t *). The context object can be different from that of 
- * parent task.
- *
- * When a clone is started, the clone initialization function is called. The
- * initialization function should do whatever initialization there is to be
- * performed, register I/O events and timers, and then return. If the
- * initialization is successful, the clone task reverts to run the event
- * loop and invoking the event callbacks until its parent stops it by
- * calling su_clone_wait() which invokes the deinit function. The clone task
- * is destroyed when the deinit function returns. 
+ * @return
+ *   Positive index of the wait object, 
+ *   or -1 upon an error.
+ */
+int su_port_register(su_port_t *self,
+		     su_root_t *root, 
+		     su_wait_t *wait, 
+		     su_wakeup_f callback,
+		     su_wakeup_arg_t *arg,
+		     int priority)
+{
+  int i, j, n;
+
+  assert(SU_PORT_OWN_THREAD(self));
+
+  n = self->sup_n_waits;
+
+  if (n >= SU_WAIT_MAX)
+    return su_seterrno(ENOMEM);
+
+  if (n >= self->sup_size_waits) {
+    /* Reallocate size arrays */
+    int size;
+    int *indices;
+    int *reverses;
+    su_wait_t *waits;
+    su_wakeup_f *wait_cbs;
+    su_wakeup_arg_t **wait_args;
+    su_root_t **wait_tasks;
+
+    if (self->sup_size_waits == 0)
+      size = su_root_size_hint;
+    else 
+      size = 2 * self->sup_size_waits;
+
+    if (size < SU_WAIT_MIN)
+      size = SU_WAIT_MIN;
+
+    /* Too large */
+    if (-3 - size > 0)
+      return (errno = ENOMEM), -1;
+
+    indices = realloc(self->sup_indices, (size + 1) * sizeof(*indices));
+    if (indices) {
+      self->sup_indices = indices;
+
+      if (self->sup_size_waits == 0)
+	indices[0] = -1;
+
+      for (i = self->sup_size_waits + 1; i <= size; i++)
+	indices[i] = -1 - i;
+    }
+
+    reverses = realloc(self->sup_reverses, size * sizeof(*waits));
+    if (reverses) {
+      for (i = self->sup_size_waits; i < size; i++)
+	reverses[i] = -1;
+      self->sup_reverses = reverses;
+    }
+      
+    waits = realloc(self->sup_waits, size * sizeof(*waits));
+    if (waits)
+      self->sup_waits = waits;
+
+    wait_cbs = realloc(self->sup_wait_cbs, size * sizeof(*wait_cbs));
+    if (wait_cbs)
+      self->sup_wait_cbs = wait_cbs;
+
+    wait_args = realloc(self->sup_wait_args, size * sizeof(*wait_args));
+    if (wait_args)
+      self->sup_wait_args = wait_args;
+
+    /* Add sup_wait_roots array, if needed */
+    wait_tasks = realloc(self->sup_wait_roots, size * sizeof(*wait_tasks));
+    if (wait_tasks) 
+      self->sup_wait_roots = wait_tasks;
+
+    if (!(indices && 
+	  reverses && waits && wait_cbs && wait_args && wait_tasks)) {
+      return -1;
+    }
+
+    self->sup_size_waits = size;
+  }
+
+  i = -self->sup_indices[0]; assert(i <= self->sup_size_waits);
+
+#if HAVE_EPOLL
+  if (self->sup_epoll != -1) {
+    struct epoll_event ev;
+
+    ev.events = POLL2EPOLL(wait->events);
+    ev.data.u64 = 0;
+    ev.data.u32 = (uint32_t)i;
+
+    if (epoll_ctl(self->sup_epoll, EPOLL_CTL_ADD, wait->fd, &ev) == -1) {
+      SU_DEBUG_0(("EPOLL_CTL_ADD(%u, %u) failed: %s\n",
+		  wait->fd, ev.events, strerror(errno)));
+      return -1;
+    }
+  }
+  else
+#endif  
+  if (priority > 0) {
+    /* Insert */
+    for (n = self->sup_n_waits; n > 0; n--) {
+      j = self->sup_reverses[n-1]; assert(self->sup_indices[j] == n - 1);
+      self->sup_indices[j] = n;
+      self->sup_reverses[n] = j;
+      self->sup_waits[n] = self->sup_waits[n-1];
+      self->sup_wait_cbs[n] = self->sup_wait_cbs[n-1];
+      self->sup_wait_args[n] = self->sup_wait_args[n-1];
+      self->sup_wait_roots[n] = self->sup_wait_roots[n-1];	
+    }
+
+    self->sup_pri_offset++;
+  }
+  else {
+    /* Append - no need to move anything */
+    n = self->sup_n_waits;
+  }
+
+  self->sup_n_waits++;
+
+  self->sup_indices[0] = self->sup_indices[i];  /* Free index */
+  self->sup_indices[i] = n;
+
+  self->sup_reverses[n] = i;
+  self->sup_waits[n] = *wait;
+  self->sup_wait_cbs[n] = callback;
+  self->sup_wait_args[n] = arg;
+  self->sup_wait_roots[n] = root;
+
+  self->sup_registers++;
+
+  /* Just like epoll, we return -1 or positive integer */
+
+  return i;
+}
+
+/** Deregister a su_wait_t object. */
+static
+int su_port_deregister0(su_port_t *self, int i)
+{
+  int n, N, *indices, *reverses;
+
+  indices = self->sup_indices;
+  reverses = self->sup_reverses;
+
+  n = indices[i]; assert(n >= 0);
+
+#if HAVE_EPOLL
+  if (self->sup_epoll != -1) {
+    su_wait_t *wait = &self->sup_waits[n];
+    struct epoll_event ev;
+
+    ev.events = POLL2EPOLL(wait->events);
+    ev.data.u64 = (uint64_t)0;
+    ev.data.u32 = (uint32_t)i;
+
+    if (epoll_ctl(self->sup_epoll, EPOLL_CTL_DEL, wait->fd, &ev) == -1) {
+      SU_DEBUG_1(("su_port(%p): EPOLL_CTL_DEL(%u): %s\n", self, 
+		  wait->fd, su_strerror(su_errno())));
+    }
+  }
+#endif
+
+  N = --self->sup_n_waits;
+  
+  if (n < self->sup_pri_offset) {
+    int j = --self->sup_pri_offset;
+    if (n != j) {
+      assert(reverses[j] > 0);
+      assert(indices[reverses[j]] == j);
+      indices[reverses[j]] = n;
+      reverses[n] = reverses[j];
+
+      self->sup_waits[n] = self->sup_waits[j];
+      self->sup_wait_cbs[n] = self->sup_wait_cbs[j];
+      self->sup_wait_args[n] = self->sup_wait_args[j];
+      self->sup_wait_roots[n] = self->sup_wait_roots[j];
+      n = j;
+    }
+  }
+
+  if (n < N) {
+    assert(reverses[N] > 0);
+    assert(indices[reverses[N]] == N);
+
+    indices[reverses[N]] = n;
+    reverses[n] = reverses[N];
+
+    self->sup_waits[n] = self->sup_waits[N];
+    self->sup_wait_cbs[n] = self->sup_wait_cbs[N];
+    self->sup_wait_args[n] = self->sup_wait_args[N];
+    self->sup_wait_roots[n] = self->sup_wait_roots[N];
+    n = N;
+  }
+
+  reverses[n] = -1;
+  memset(&self->sup_waits[n], 0, sizeof self->sup_waits[n]);
+  self->sup_wait_cbs[n] = NULL;
+  self->sup_wait_args[n] = NULL;
+  self->sup_wait_roots[n] = NULL;
+  
+  indices[i] = indices[0];
+  indices[0] = -i;
+
+  self->sup_registers++;
+
+  return i;
+}
+
+
+/** Unregister a su_wait_t object.
+ *  
+ *  The function su_port_unregister() unregisters a su_wait_t object. The
+ *  wait object, a callback function and a argument are removed from the
+ *  port object.
+ * 
+ * @param self     - pointer to port object
+ * @param root     - pointer to root object
+ * @param wait     - pointer to wait object
+ * @param callback - callback function pointer (may be NULL)
+ * @param arg      - argument given to callback function when it is invoked 
+ *                   (may be NULL)
  *
- * The public API consists of following functions:
- *    - su_clone_start()
- *    - su_clone_task()
- *    - su_clone_wait()
- *    - su_clone_forget()
+ * @deprecated Use su_port_deregister() instead. 
  *
- * @note 
- * There is only one event loop for each thread which can be shared by
- * multiple clone tasks. Therefore, the clone tasks can not explicitly run
- * or step the event loop, but they are limited to event callbacks. A clone
- * task may not call su_root_break(), su_root_run() or su_root_step().
+ * @return Nonzero index of the wait object, or -1 upon an error.
  */
-
-static int su_root_init_nothing(su_root_t *root, su_root_magic_t *magic)
+int su_port_unregister(su_port_t *self,
+		       su_root_t *root, 
+		       su_wait_t *wait,	
+		       su_wakeup_f callback, /* XXX - ignored */
+		       su_wakeup_arg_t *arg)
 {
-  return 0;
+  int n, N;
+
+  assert(self);
+  assert(SU_PORT_OWN_THREAD(self));
+
+  N = self->sup_n_waits;
+
+  for (n = 0; n < N; n++) {
+    if (SU_WAIT_CMP(wait[0], self->sup_waits[n]) == 0) {
+      return su_port_deregister0(self, self->sup_reverses[n]);
+    }
+  }
+
+  su_seterrno(ENOENT);
+
+  return -1;
 }
 
-static void su_root_deinit_nothing(su_root_t *root, su_root_magic_t *magic)
+/** Deregister a su_wait_t object.
+ *  
+ *  The function su_port_deregister() deregisters a su_wait_t registrattion. 
+ *  The wait object, a callback function and a argument are removed from the
+ *  port object.
+ * 
+ * @param self     - pointer to port object
+ * @param i        - registration index
+ * 
+ * @return Index of the wait object, or -1 upon an error.
+ */
+int su_port_deregister(su_port_t *self, int i)
 {
+  su_wait_t wait[1] = { SU_WAIT_INIT };
+  int retval;
+
+  assert(self);
+  assert(SU_PORT_OWN_THREAD(self));
+
+  if (i <= 0 || i > self->sup_size_waits)
+    return su_seterrno(EBADF);
+
+  if (self->sup_indices[i] < 0)
+    return su_seterrno(EBADF);
+    
+  retval = su_port_deregister0(self, i);
+
+  su_wait_destroy(wait);
+
+  return retval;
 }
 
-/** Start a clone task.
+
+/** @internal
+ * Unregister all su_wait_t objects.
  *
- * Allocate and initialize a sub-task. Depending on the su_root_threading()
- * settings, a separate thread may be created to execute the sub-task. The
- * sub-task is represented by clone handle to the rest of the application. 
- * The function su_clone_start() returns the clone handle in @a
- * return_clone. The clone handle is used to communicate with the newly
- * created clone task using messages.
- *
- * A new #su_root_t object is created for the sub-task with the @a magic as
- * the root context pointer. Because the sub-task may or may not have its
- * own thread, all its activity must be scheduled via this root object. In
- * other words, the sub-task can be schedule
- * -# I/O events with su_root_register()
- * -# timers with su_timer_set(), su_timer_set_at() or su_timer_run()
- * -# messages with su_msg_send().
- *
- * Messages can also be used to pass information between tasks or threads.
- *
- * In multi-threaded implementation, su_clone_start() launches a new thread,
- * and the initialization routine is executed by this newly created thread. 
- * The calling thread blocks until the initialization routine completes. If
- * the initialization routine returns #su_success (0), the sub-task is
- * considered to be created successfully. After the successful
- * initialization, the sub-task continues to execeute the function
- * su_root_run().
- *
- * In single-threaded implementations, just a new root object is created. 
- * The initialization routine is called directly from su_clone_start().
- *
- * If the initalization function @a init fails, the sub-task (either the
- * newly created thread or the current thread executing the su_clone_start()
- * function) calls the deinitialization function, and su_clone_start()
- * returns NULL.
- *
- * @param parent   root to be cloned
- * @param return_clone reference to a clone [OUT]
- * @param magic    pointer to user data
- * @param init     initialization function
- * @param deinit   deinitialization function
- *
- * @return 0 if successfull, -1 upon an error.
- *
- * @note Earlier documentation mentioned that @a parent could be NULL. That
- * feature has never been implemented, however.
- *
- * @sa su_root_threading(), su_clone_task(), su_clone_stop(), su_clone_wait(),
- * su_clone_forget().
- */
-int su_clone_start(su_root_t *parent,
-		   su_clone_r return_clone,
-		   su_root_magic_t *magic,
-		   su_root_init_f init,
-		   su_root_deinit_f deinit)
-{
-  su_port_vtable_t const *svp;
-
-  if (init == NULL)
-    init = su_root_init_nothing;
-  if (deinit == NULL)
-    deinit = su_root_deinit_nothing;
+ * The function su_port_unregister_all() unregisters all su_wait_t objects
+ * and destroys all queued timers associated with given root object.
+ * 
+ * @param  self     - pointer to port object
+ * @param  root     - pointer to root object
+ * 
+ * @return Number of wait objects removed.
+ */
+int su_port_unregister_all(su_port_t *self, 
+			   su_root_t *root)
+{
+  int i, j, index, N;
+  int             *indices, *reverses;
+  su_wait_t       *waits;
+  su_wakeup_f     *wait_cbs;
+  su_wakeup_arg_t**wait_args;
+  su_root_t      **wait_roots;
+
+  assert(SU_PORT_OWN_THREAD(self));
+
+  N          = self->sup_n_waits;
+  indices    = self->sup_indices;
+  reverses   = self->sup_reverses;
+  waits      = self->sup_waits; 
+  wait_cbs   = self->sup_wait_cbs; 
+  wait_args  = self->sup_wait_args;
+  wait_roots = self->sup_wait_roots; 
+  
+  for (i = j = 0; i < N; i++) {
+    index = reverses[i]; assert(index > 0 && indices[index] == i);
 
+    if (wait_roots[i] == root) {
+      /* XXX - we should free all resources associated with this, too */
+#if HAVE_EPOLL
+      if (self->sup_epoll != -1) {
+	int fd = waits[i].fd;
+	struct epoll_event ev;
+
+	ev.events = POLL2EPOLL(waits[i].events);
+	ev.data.u64 = (uint64_t)0;
+	ev.data.u32 = (uint32_t)index;
+
+	if (epoll_ctl(self->sup_epoll, EPOLL_CTL_DEL, fd, &ev) == -1) {
+	  SU_DEBUG_1(("EPOLL_CTL_DEL(%u): %s\n", 
+		      waits[i].fd, su_strerror(su_errno())));
+	}
+      }
+#endif
+      if (i < self->sup_pri_offset)
+	self->sup_pri_offset--;
+
+      indices[index] = indices[0];
+      indices[0] = -index;
+      continue;
+    }
+
+    if (i != j) {
+      indices[index] = j;
+      reverses[j]   = reverses[i];
+      waits[j]      = waits[i];
+      wait_cbs[j]   = wait_cbs[i];
+      wait_args[j]  = wait_args[i];
+      wait_roots[j] = wait_roots[i];
+    }
     
-  if (parent == NULL || parent->sur_threading) {
-    if (preferred_su_clone_start == NULL)
-      su_port_set_system_preferences(getenv("SU_PORT"));
-    return preferred_su_clone_start(parent, return_clone, magic, init, deinit);
+    j++;
   }
+  
+  for (i = j; i < N; i++) {
+    reverses[i] = -1;
+    wait_cbs[i] = NULL;
+    wait_args[i] = NULL;
+    wait_roots[i] = NULL;
+  }
+  memset(&waits[j], 0, (char *)&waits[N] - (char *)&waits[j]);
 
-  svp = parent->sur_task->sut_port->sup_vtable;
-
-  if (svp->su_port_start_shared == NULL)
-    return su_seterrno(EINVAL);
+  self->sup_n_waits = j;
+  self->sup_registers++;
 
-  /* Return a task sharing the same port. */
-  return svp->su_port_start_shared(parent, return_clone, magic, init, deinit);
+  return N - j;
 }
 
-/** Get reference to a clone task.
- * 
- * @param clone Clone pointer
+/**Set mask for a registered event. @internal
  *
- * @return A reference to the task structure of the clone.
+ * The function su_port_eventmask() sets the mask describing events that can
+ * signal the registered callback.
+ *
+ * @param port   pointer to port object
+ * @param index  registration index
+ * @param socket socket
+ * @param events new event mask
+ *
+ * @retval 0 when successful,
+ * @retval -1 upon an error.
  */
-_su_task_r su_clone_task(su_clone_r clone)
+int su_port_eventmask(su_port_t *self, int index, int socket, int events)
 {
-  return su_msg_to(clone);
+  int n;
+  assert(self);
+  assert(SU_PORT_OWN_THREAD(self));
+
+  if (index <= 0 || index > self->sup_size_waits)
+    return su_seterrno(EBADF);
+  n = self->sup_indices[index];
+  if (n < 0)
+    return su_seterrno(EBADF);
+
+#if HAVE_EPOLL
+  if (self->sup_epoll != -1) {
+    su_wait_t *wait = &self->sup_waits[n];
+    struct epoll_event ev;
+
+    wait->events = events;
+
+    ev.events = POLL2EPOLL(events);
+    ev.data.u64 = (uint64_t)0;
+    ev.data.u32 = (uint32_t)index;
+
+    if (epoll_ctl(self->sup_epoll, EPOLL_CTL_MOD, wait->fd, &ev) == -1) {
+      SU_DEBUG_1(("su_port(%p): EPOLL_CTL_MOD(%u): %s\n", self, 
+		  wait->fd, su_strerror(su_errno())));
+      return -1;
+    }
+  }
+#endif
+
+  return su_wait_mask(&self->sup_waits[n], socket, events);
 }
 
-/**Forget the clone.
+#if 0
+/** @internal
+ *
+ * Copies the su_wait_t objects from the port. The number of wait objects
+ * can be found out by calling su_port_query() with @a n_waits as zero.
  * 
- * Normally, the clone task executes until it is stopped.  If the parent
- * task does not need to stop the task, it can "forget" the clone.  The
- * clone exits independently of the parent task.
+ * @note This function is called only by friends.
+ *
+ * @param self     - pointer to port object
+ * @param waits    - pointer to array to which wait objects are copied
+ * @param n_waits  - number of wait objects fitting in array waits
  *
- * @param rclone Reference to the clone.
+ * @return Number of wait objects, or 0 upon an error.
  */
-void su_clone_forget(su_clone_r rclone)
+unsigned su_port_query(su_port_t *self, su_wait_t *waits, unsigned n_waits)
 {
-  su_msg_destroy(rclone);
+  unsigned n;
+
+  assert(SU_PORT_OWN_THREAD(self));
+
+  n = self->sup_n_waits;
+
+  if (n_waits != 0) {
+    if (waits && n_waits >= n)
+      memcpy(waits, self->sup_waits, n * sizeof(*waits));
+    else
+      n = 0;
+  }
+
+  return n;
 }
+#endif
 
-/** Stop the clone.
+/** @internal Enable multishot mode.
+ *
+ * The function su_port_multishot() enables, disables or queries the
+ * multishot mode for the port. The multishot mode determines how the events
+ * are scheduled by port. If multishot mode is enabled, port serves all the
+ * sockets that have received network events. If it is disables, only first
+ * socket event is served.
  *
- * This can used only if clone task has sent no report messages (messages
- * with delivery report sent back to clone).
+ * @param self      pointer to port object
+ * @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
  * 
- * @deprecated. Use su_clone_wait().
+ * @retval 0 multishot mode is disabled
+ * @retval 1 multishot mode is enabled
+ * @retval -1 an error occurred
  */
-void su_clone_stop(su_clone_r rclone)
+int su_port_multishot(su_port_t *self, int multishot)
 {
-  su_msg_send(rclone);
+  if (multishot < 0)
+    return self->sup_multishot;
+  else if (multishot == 0 || multishot == 1)
+    return self->sup_multishot = multishot;
+  else 
+    return (errno = EINVAL), -1;
 }
 
-/** Stop a clone and wait until it is has completed.
- *
- * The function su_clone_wait() is used to stop the clone task and wait
- * until it has cleaned up. The clone task is destroyed asynchronously. The
- * parent sends a message to clone, clone deinitializes itself and then
- * replies. After the reply message is received by the parent, it will send
- * a third message back to clone.
- *
- * The parent destroy all messages to or from clone task before calling
- * su_clone_wait(). The parent task may not send any messages to the clone
- * after calling su_clone_wait(). The su_clone_wait() function blocks until
- * the cloned task is destroyed. During that time, the parent task must be
- * prepared to process all the messages sent by clone task. This includes
- * all the messages sent by clone before destroy the message reached the
- * clone.
+/** @internal Enable threadsafe operation. */
+static
+int su_port_threadsafe(su_port_t *port)
+{
+  return su_home_threadsafe(port->sup_home);
+}
+
+/** @internal Main loop.
+ * 
+ * The function @c su_port_run() waits for wait objects and the timers
+ * associated with the port object.  When any wait object is signaled or
+ * timer is expired, it invokes the callbacks, and returns waiting.
+ * 
+ * The function @c su_port_run() runs until @c su_port_break() is called
+ * from a callback.
+ * 
+ * @param self     pointer to port object
+ * 
  */
-void su_clone_wait(su_root_t *root, su_clone_r rclone)
+void su_port_run(su_port_t *self)
 {
-  if (rclone[0]) {
-    assert(root == NULL || root == su_msg_from(rclone)->sut_root);
-    su_port_wait(rclone);
+  su_duration_t tout = 0;
+
+  assert(SU_PORT_OWN_THREAD(self));
+
+  for (self->sup_running = 1; self->sup_running;) {
+    tout = 2000;
+
+    if (self->sup_prepoll)
+      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+
+    if (self->sup_head)
+      su_port_getmsgs(self);
+
+    if (self->sup_timers)
+      su_timer_expire(&self->sup_timers, &tout, su_now());
+
+    if (!self->sup_running)
+      break;
+
+    if (self->sup_head)      /* if there are messages do a quick wait */
+      tout = 0;
+
+    su_port_wait_events(self, tout);
   }
 }
 
-/** Pause a clone.
- *
- * Obtain an exclusive lock on clone's private data.
+#if tuning
+/* This version can help tuning... */
+void su_port_run_tune(su_port_t *self)
+{
+  int i;
+  int timers = 0, messages = 0, events = 0;
+  su_duration_t tout = 0, tout0;
+  su_time_t started = su_now(), woken = started, bedtime = woken;
+
+  assert(SU_PORT_OWN_THREAD(self));
+
+  for (self->sup_running = 1; self->sup_running;) {
+    tout0 = tout, tout = 2000;
+
+    timers = 0, messages = 0;
+
+    if (self->sup_prepoll)
+      self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+
+    if (self->sup_head)
+      messages = su_port_getmsgs(self);
+
+    if (self->sup_timers)
+      timers = su_timer_expire(&self->sup_timers, &tout, su_now());
+
+    if (!self->sup_running)
+      break;
+
+    if (self->sup_head)      /* if there are messages do a quick wait */
+      tout = 0;
+
+    bedtime = su_now();
+
+    events = su_port_wait_events(self, tout);
+
+    woken = su_now();
+
+    if (messages || timers || events)
+      SU_DEBUG_1(("su_port_run(%p): %.6f: %u messages %u timers %u "
+		  "events slept %.6f/%.3f\n",
+		  self, su_time_diff(woken, started), messages, timers, events,
+		  su_time_diff(woken, bedtime), tout0 * 1e-3));
+
+    if (!self->sup_running)
+      break;
+  }
+}
+#endif
+
+/** @internal
+ * The function @c su_port_break() is used to terminate execution of @c
+ * su_port_run(). It can be called from a callback function.
+ * 
+ * @param self     pointer to port
+ * 
+ */
+void su_port_break(su_port_t *self)
+{
+  self->sup_running = 0; 
+}
+
+/** @internal
+ * The function @c su_port_wait_events() is used to poll() for wait objects
  *
- * @retval 0 if successful (and clone is paused)
- * @retval -1 upon an error
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
  *
- * @deprecated Never implemented.
+ * @return number of events handled
  */
-int su_clone_pause(su_clone_r rclone)
+static
+int su_port_wait_events(su_port_t *self, su_duration_t tout)
 {
-#if 0
-  su_root_t *cloneroot = su_task_root(su_msg_to(rclone));
+  int i, events = 0;
+  su_wait_t *waits = self->sup_waits;
+  int n = self->sup_n_waits;
+  su_root_t *root;
+#if HAVE_POLL
+  unsigned version = self->sup_registers;
+#endif
+#if HAVE_EPOLL
+  
+  if (self->sup_epoll != -1) {
+    int const M = 4;
+    struct epoll_event ev[M];
+    int j, index;
+    int *indices = self->sup_indices;
+    
+    n = epoll_wait(self->sup_epoll, ev, self->sup_multishot ? M : 1, tout);
 
-  if (!cloneroot)
-    return (errno = EFAULT), -1;
+    assert(n <= M);
 
-  if (SU_ROOT_OWN_THREAD(cloneroot))
-    /* We own it already */
-    return 0;
+    for (j = 0; j < n; j++) {
+      su_root_t *root;
+      su_root_magic_t *magic;
+
+      if (!ev[j].events || ev[j].data.u32 > INDEX_MAX)
+	continue;
+      index = (int)ev[j].data.u32;
+      assert(index > 0 && index <= self->sup_size_waits);
+      i = indices[index]; assert(i >= 0 && i <= self->sup_n_waits);
+      root = self->sup_wait_roots[i];
+      magic = root ? su_root_magic(root) : NULL;
+      waits[i].revents = ev[j].events;
+      self->sup_wait_cbs[i](magic, &waits[i], self->sup_wait_args[i]);
+      events++;
+      /* Callback function used su_register()/su_deregister() */
+      if (version != self->sup_registers)
+	break;
+    }
+    
+    return n < 0 ? n : events;
+  }
+#endif
 
-  return su_port_pause(cloneroot->sur_port);
-#else
-  return errno = ENOSYS, -1;
+  i = su_wait(waits, (unsigned)n, tout);
+
+  if (i >= 0 && i < n) {
+#if HAVE_POLL			
+    /* poll() can return events for multiple wait objects */
+    if (self->sup_multishot) {
+      for (; i < n; i++) {
+        if (waits[i].revents) {
+          root = self->sup_wait_roots[i];
+          self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
+                                &waits[i],
+                                self->sup_wait_args[i]);
+          events++;
+          /* Callback function used su_register()/su_deregister() */
+          if (version != self->sup_registers)
+            break;
+        }
+      }
+    }
+#else /* !HAVE_POLL */
+    if (0) {
+    }
 #endif
+    else {
+      root = self->sup_wait_roots[i];
+      self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
+                            &self->sup_waits[i],
+                            self->sup_wait_args[i]);
+      events++;
+    }
+  }
+
+  return events;
 }
 
-/** Resume a clone.
+/** @internal 
+ * Used to check wait events in callbacks that take lots of time
  *
- * Give up an exclusive lock on clone's private data.
+ * This function does a timeout 0 poll() and runs wait objects.
  *
- * @retval 0 if successful (and clone is resumed)
- * @retval -1 upon an error
+ * @param port     pointer to port
  *
- * @deprecated Never implemented.
+ * @return number of events handled
  */
-int su_clone_resume(su_clone_r rclone)
+static
+int su_port_yield(su_port_t *port)
 {
-#if 0
-  su_root_t *cloneroot = su_task_root(su_msg_to(rclone));
+  return su_port_wait_events(port, 0);
+}
 
-  if (!cloneroot)
-    return (errno = EFAULT), -1;
+/** @internal Block until wait object is signaled or timeout.
+ *
+ * This function waits for wait objects and the timers associated with 
+ * the root object.  When any wait object is signaled or timer is
+ * expired, it invokes the callbacks. 
+ * 
+ *   This function returns when a callback has been invoked or @c tout
+ *   milliseconds is elapsed. 
+ *
+ * @param self     pointer to port
+ * @param tout     timeout in milliseconds
+ * 
+ * @return
+ *   Milliseconds to the next invocation of timer, or @c SU_WAIT_FOREVER if
+ *   there are no active timers.
+ */
+su_duration_t su_port_step(su_port_t *self, su_duration_t tout)
+{
+  su_time_t now = su_now();
 
-  if (SU_ROOT_OWN_THREAD(cloneroot))
-    /* We cannot give it away */
-    return 0;
+  assert(SU_PORT_OWN_THREAD(self));
 
-  return su_port_resume(cloneroot->sur_port);
-#else
-  return errno = ENOSYS, -1;
-#endif
+  if (self->sup_prepoll)
+    self->sup_prepoll(self->sup_pp_magic, self->sup_pp_root);
+
+  if (self->sup_head)
+    su_port_getmsgs(self);
+
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, now);
+
+  /* if there are messages do a quick wait */
+  if (self->sup_head)
+    tout = 0;
+
+  if (su_port_wait_events(self, tout))
+    tout = 0;
+  else
+    tout = SU_WAIT_FOREVER;
+
+  if (self->sup_head)
+    su_port_getmsgs(self);
+
+  if (self->sup_timers)
+    su_timer_expire(&self->sup_timers, &tout, su_now());
+
+  if (self->sup_head)
+    tout = 0;
+
+  return tout;
 }
 
-void su_port_wait(su_clone_r rclone)
+
+/** @internal
+ * Checks if the calling thread owns the port object.
+ *
+ * @param self pointer to a port object
+ *
+ * @retval true (nonzero) if the calling thread owns the port,
+ * @retval false (zero) otherwise.
+ */
+int su_port_own_thread(su_port_t const *self)
 {
-  su_port_t *cloneport;
+  return self == NULL || SU_PORT_OWN_THREAD(self);
+}
 
-  cloneport = su_msg_to(rclone)->sut_port;
-  cloneport->sup_vtable->su_port_wait(rclone);
+#if 0
+/** @internal
+ *  Prints out the contents of the port.
+ *
+ * @param self pointer to a port
+ * @param f    pointer to a file (if @c NULL, uses @c stdout).
+ */
+void su_port_dump(su_port_t const *self, FILE *f)
+{
+  int i;
+#define IS_WAIT_IN(x) (((x)->events & SU_WAIT_IN) ? "IN" : "")
+#define IS_WAIT_OUT(x) (((x)->events & SU_WAIT_OUT) ? "OUT" : "")
+#define IS_WAIT_ACCEPT(x) (((x)->events & SU_WAIT_ACCEPT) ? "ACCEPT" : "")
+
+  if (f == NULL)
+    f = stdout;
+
+  fprintf(f, "su_port_t at %p:\n", self);
+  fprintf(f, "\tport is%s running\n", self->sup_running ? "" : "not ");
+#if SU_HAVE_PTHREADS
+  fprintf(f, "\tport tid %p\n", (void *)self->sup_tid);
+#endif
+#if SU_HAVE_MBOX
+  fprintf(f, "\tport mbox %d (%s%s%s)\n", self->sup_mbox[0],
+	  IS_WAIT_IN(&self->sup_mbox_wait),
+	  IS_WAIT_OUT(&self->sup_mbox_wait),
+	  IS_WAIT_ACCEPT(&self->sup_mbox_wait));
+#endif
+  fprintf(f, "\t%d wait objects\n", self->sup_n_waits);
+  for (i = 0; i < self->sup_n_waits; i++) {
+    
+  }
 }
 
-int su_port_execute(su_task_r const task,
-		    int (*function)(void *), void *arg,
-		    int *return_value)
+#endif
+
+/* =========================================================================
+ * Pre-poll() callback
+ */
+
+int su_port_add_prepoll(su_port_t *port,
+			su_root_t *root, 
+			su_prepoll_f *callback, 
+			su_prepoll_magic_t *magic)
 {
-  if (!task->sut_port->sup_vtable->su_port_execute)
-    return errno = ENOSYS, -1;
+  if (port->sup_prepoll)
+    return -1;
+
+  port->sup_prepoll = callback;
+  port->sup_pp_magic = magic;
+  port->sup_pp_root = root;
 
-  return task->sut_port->sup_vtable->
-    su_port_execute(task, function, arg, return_value);
+  return 0;
 }
 
-#if notyet && nomore
-int su_port_pause(su_port_t *self)
+int su_port_remove_prepoll(su_port_t *port,
+			   su_root_t *root)
 {
-  assert(self->sup_vtable->su_port_pause);
-  return self->sup_vtable->su_port_pause(self);
+  if (port->sup_pp_root != root)
+    return -1;
+
+  port->sup_prepoll = NULL;
+  port->sup_pp_magic = NULL;
+  port->sup_pp_root = NULL;
+
+  return 0;
 }
 
-int su_port_resume(su_port_t *self)
+/* =========================================================================
+ * Timers
+ */
+
+static
+su_timer_t **su_port_timers(su_port_t *self)
 {
-  assert(self->sup_vtable->su_port_resume);
-  return self->sup_vtable->su_port_resume(self);
+  return &self->sup_timers;
 }
-#endif

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.h	Sat Feb 17 01:25:21 2007
@@ -86,7 +86,7 @@
 #define SU_ROOT_MAGIC(r) ((r) ? (r)->sur_magic : NULL)
 
 /** Virtual function table for port */
-typedef struct su_port_vtable {
+typedef struct {
   unsigned su_vtable_size;
   void (*su_port_lock)(su_port_t *port, char const *who);
   void (*su_port_unlock)(su_port_t *port, char const *who);
@@ -128,110 +128,80 @@
   int (*su_port_multishot)(su_port_t *port, int multishot);
 
   int (*su_port_threadsafe)(su_port_t *port);
+  
   /* Extension from > 1.12.0 */
   int (*su_port_yield)(su_port_t *port);
-  /* Extension from >= 1.12.4 */
-  int (*su_port_wait_events)(su_port_t *port, su_duration_t timeout);
-  int (*su_port_getmsgs)(su_port_t *port);
-  /* Extension from >= 1.12.5 */
-  int (*su_port_getmsgs_from)(su_port_t *port, su_port_t *cloneport);
-  char const *(*su_port_name)(su_port_t const *port);
-  int (*su_port_start_shared)(su_root_t *root,
-			      su_clone_r return_clone,
-			      su_root_magic_t *magic,
-			      su_root_init_f init,
-			      su_root_deinit_f deinit);
-  void (*su_port_wait)(su_clone_r rclone);
-  int (*su_port_execute)(su_task_r const task,
-			 int (*function)(void *), void *arg,
-			 int *return_value);  
 } su_port_vtable_t;
 
 SOFIAPUBFUN su_port_t *su_port_create(void)
      __attribute__((__malloc__));
 
-/* Extension from >= 1.12.5 */
-
 SOFIAPUBFUN void su_msg_delivery_report(su_msg_r msg);
 SOFIAPUBFUN su_duration_t su_timer_next_expires(su_timer_t const * t,
 						su_time_t now);
 SOFIAPUBFUN su_root_t *su_root_create_with_port(su_root_magic_t *magic,
-						su_port_t *port)
-  __attribute__((__malloc__));
+						su_port_t *port);
 
-/* ---------------------------------------------------------------------- */
+#if SU_PORT_IMPLEMENTATION
 
-/* React to multiple events per one poll() to make sure 
- * that high-priority events can never completely mask other events.
- * Enabled by default on all platforms except WIN32 */
-#if !defined(WIN32)
-#define SU_ENABLE_MULTISHOT_POLL 1
 #else
-#define SU_ENABLE_MULTISHOT_POLL 0
-#endif
-
-/* ---------------------------------------------------------------------- */
-/* Virtual functions */
-
-typedef struct su_virtual_port_s {
-  su_home_t        sup_home[1];
+struct su_port_s {
+  su_home_t               sup_home[1];
   su_port_vtable_t const *sup_vtable;
-} su_virtual_port_t;
-
-static inline
-su_home_t *su_port_home(su_port_t const *self)
-{
-  return (su_home_t *)self;
-}
+};
 
 static inline
 void su_port_lock(su_port_t *self, char const *who)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base) base->sup_vtable->su_port_lock(self, who);
+  if (self) self->sup_vtable->su_port_lock(self, who);
 }
 
+#define SU_PORT_LOCK(p, f)      (su_port_lock(p, #f))
+ 
 static inline
 void su_port_unlock(su_port_t *self, char const *who)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base) base->sup_vtable->su_port_unlock(self, who);
+  if (self) self->sup_vtable->su_port_unlock(self, who);
 }
 
+#define SU_PORT_UNLOCK(p, f)    (su_port_unlock(p, #f))
+
 static inline
 void su_port_incref(su_port_t *self, char const *who)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base) base->sup_vtable->su_port_incref(self, who);
+  if (self) self->sup_vtable->su_port_incref(self, who);
 }
 
+#define SU_PORT_INCREF(p, f)    (su_port_incref(p, #f))
+ 
 static inline
 void su_port_decref(su_port_t *self, char const *who)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base) base->sup_vtable->su_port_decref(self, 0, who);
+  if (self) self->sup_vtable->su_port_decref(self, 0, who);
 }
 
+#define SU_PORT_DECREF(p, f)    (su_port_decref(p, #f))
+
 static inline
 void su_port_zapref(su_port_t *self, char const *who)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base) base->sup_vtable->su_port_decref(self, 1, who);
+  if (self) self->sup_vtable->su_port_decref(self, 1, who);
 }
 
+#define SU_PORT_ZAPREF(p, f)    (su_port_zapref(p, #f))
+
 static inline
 struct _GSource *su_port_gsource(su_port_t *self)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  return base ? base->sup_vtable->su_port_gsource(self) : NULL;
+  return self ? self->sup_vtable->su_port_gsource(self) : NULL;
 }
 
+
 static inline
 int su_port_send(su_port_t *self, su_msg_r rmsg)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base) 
-    return base->sup_vtable->su_port_send(self, rmsg);
+  if (self) 
+    return self->sup_vtable->su_port_send(self, rmsg);
   errno = EINVAL;
   return -1;
 }
@@ -245,9 +215,8 @@
 		     su_wakeup_arg_t *arg,
 		     int priority)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->su_port_register(self, root, wait,
+  if (self)
+    return self->sup_vtable->su_port_register(self, root, wait,
 					      callback, arg, priority);
   errno = EINVAL;
   return -1;
@@ -260,9 +229,8 @@
 		       su_wakeup_f callback, 
 		       su_wakeup_arg_t *arg)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->
+  if (self)
+    return self->sup_vtable->
       su_port_unregister(self, root, wait, callback, arg);
   errno = EINVAL;
   return -1;
@@ -271,9 +239,9 @@
 static inline
 int su_port_deregister(su_port_t *self, int i)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->su_port_deregister(self, i);
+  if (self)
+    return self->sup_vtable->
+      su_port_deregister(self, i);
   errno = EINVAL;
   return -1;
 }
@@ -282,9 +250,8 @@
 int su_port_unregister_all(su_port_t *self,
 			   su_root_t *root)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->
+  if (self)
+    return self->sup_vtable->
       su_port_unregister_all(self, root);
   errno = EINVAL;
   return -1;
@@ -293,11 +260,10 @@
 static inline
 int su_port_eventmask(su_port_t *self, int index, int socket, int events)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->
+  if (self)
+    return self->sup_vtable->
       su_port_eventmask(self, index, socket, events);
-  assert(base);
+  assert(self);
   errno = EINVAL;
   return -1;
 }
@@ -305,25 +271,22 @@
 static inline
 void su_port_run(su_port_t *self)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    base->sup_vtable->su_port_run(self);
+  if (self)
+    self->sup_vtable->su_port_run(self);
 }
 
 static inline
 void su_port_break(su_port_t *self)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    base->sup_vtable->su_port_break(self);
+  if (self)
+    self->sup_vtable->su_port_break(self);
 }
 
 static inline
 su_duration_t su_port_step(su_port_t *self, su_duration_t tout)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->su_port_step(self, tout);
+  if (self)
+    return self->sup_vtable->su_port_step(self, tout);
   errno = EINVAL;
   return (su_duration_t)-1;
 }
@@ -332,8 +295,7 @@
 static inline
 int su_port_own_thread(su_port_t const *self)
 {
-  su_virtual_port_t const *base = (su_virtual_port_t *)self;
-  return base == NULL || base->sup_vtable->su_port_own_thread(self);
+  return self == NULL || self->sup_vtable->su_port_own_thread(self);
 }
 
 static inline
@@ -342,9 +304,8 @@
 			su_prepoll_f *prepoll, 
 			su_prepoll_magic_t *magic)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->
+  if (self)
+    return self->sup_vtable->
       su_port_add_prepoll(self, root, prepoll, magic);
   errno = EINVAL;
   return -1;
@@ -354,9 +315,8 @@
 int su_port_remove_prepoll(su_port_t *self,
 			   su_root_t *root)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->su_port_remove_prepoll(self, root);
+  if (self)
+    return self->sup_vtable->su_port_remove_prepoll(self, root);
   errno = EINVAL;
   return -1;
 }
@@ -364,9 +324,8 @@
 static inline
 su_timer_t **su_port_timers(su_port_t *self)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->su_port_timers(self);
+  if (self)
+    return self->sup_vtable->su_port_timers(self);
   errno = EINVAL;
   return NULL;
 }
@@ -374,11 +333,10 @@
 static inline
 int su_port_multishot(su_port_t *self, int multishot)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->su_port_multishot(self, multishot);
+  if (self)
+    return self->sup_vtable->su_port_multishot(self, multishot);
 
-  assert(base);
+  assert(self);
   errno = EINVAL;
   return -1;
 }
@@ -386,200 +344,16 @@
 static inline
 int su_port_threadsafe(su_port_t *self)
 {
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-  if (base)
-    return base->sup_vtable->su_port_threadsafe(self);
+  if (self)
+    return self->sup_vtable->su_port_threadsafe(self);
 
-  assert(base);
+  assert(self);
   errno = EINVAL;
   return -1;
 }
 
-static inline
-int su_port_getmsgs(su_port_t *self)
-{
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-
-  return base->sup_vtable->su_port_getmsgs(self);
-}
-
-static inline
-int su_port_getmsgs_from(su_port_t *self, su_port_t *cloneport)
-{
-  su_virtual_port_t *base = (su_virtual_port_t *)self;
-
-  return base->sup_vtable->su_port_getmsgs_from(self, cloneport);
-}
-
-SOFIAPUBFUN void su_port_wait(su_clone_r rclone);
-
-SOFIAPUBFUN int su_port_execute(su_task_r const task,
-				int (*function)(void *), void *arg,
-				int *return_value);
-
-/* ---------------------------------------------------------------------- */
-
-/** Base port object.
- *
- * Port is a per-thread reactor. Multiple root objects executed by a single
- * thread share the su_port_t object.
- */
-typedef struct su_base_port_s {
-  su_home_t        sup_home[1];
-  su_port_vtable_t const *sup_vtable;
-
-  /* Implementation may vary stuff below, too. */
-  
-  /* Pre-poll callback */
-  su_prepoll_f    *sup_prepoll; 
-  su_prepoll_magic_t *sup_pp_magic;
-  su_root_t       *sup_pp_root;
-
-  /* Message list - this is protected by su_port_lock()/su_port_unlock() */
-  su_msg_t        *sup_head, **sup_tail;
-
-  /* Timer list */
-  su_timer_t      *sup_timers;
-
-  unsigned         sup_running;	  /**< In su_root_run() loop? */
-} su_base_port_t;
-
-/* Base methods */
 
-SOFIAPUBFUN int su_base_port_init(su_port_t *, su_port_vtable_t const *);
-SOFIAPUBFUN void su_base_port_deinit(su_port_t *self);
-
-SOFIAPUBFUN void su_base_port_lock(su_port_t *self, char const *who);
-SOFIAPUBFUN void su_base_port_unlock(su_port_t *self, char const *who);
-
-SOFIAPUBFUN int su_base_port_own_thread(su_port_t const *self);
-
-SOFIAPUBFUN void su_base_port_incref(su_port_t *self, char const *who);
-SOFIAPUBFUN int su_base_port_decref(su_port_t *self,
-				    int blocking,
-				    char const *who);
-
-SOFIAPUBFUN struct _GSource *su_base_port_gsource(su_port_t *self);
-
-SOFIAPUBFUN su_socket_t su_base_port_mbox(su_port_t *self);
-SOFIAPUBFUN int su_base_port_send(su_port_t *self, su_msg_r rmsg);
-SOFIAPUBFUN int su_base_port_getmsgs(su_port_t *self);
-SOFIAPUBFUN int su_base_port_getmsgs_from(su_port_t *self,
-					   su_port_t *from);
-
-SOFIAPUBFUN void su_base_port_run(su_port_t *self);
-SOFIAPUBFUN void su_base_port_break(su_port_t *self);
-SOFIAPUBFUN su_duration_t su_base_port_step(su_port_t *self,
-					    su_duration_t tout);
-
-SOFIAPUBFUN int su_base_port_add_prepoll(su_port_t *self,
-					 su_root_t *root, 
-					 su_prepoll_f *, 
-					 su_prepoll_magic_t *);
-
-SOFIAPUBFUN int su_base_port_remove_prepoll(su_port_t *self, su_root_t *root);
-
-SOFIAPUBFUN su_timer_t **su_base_port_timers(su_port_t *self);
-
-SOFIAPUBFUN int su_base_port_multishot(su_port_t *self, int multishot);
-SOFIAPUBFUN int su_base_port_threadsafe(su_port_t *self);
-SOFIAPUBFUN int su_base_port_yield(su_port_t *self);
-
-SOFIAPUBFUN int su_base_port_start_shared(su_root_t *parent,
-					  su_clone_r return_clone,
-					  su_root_magic_t *magic,
-					  su_root_init_f init,
-					  su_root_deinit_f deinit);
-SOFIAPUBFUN void su_base_port_wait(su_clone_r rclone);
-
-/* ---------------------------------------------------------------------- */
-
-#if SU_HAVE_PTHREADS
-
-#include <pthread.h>
-
-/** Pthread port object */ 
-typedef struct su_pthread_port_s {
-  su_base_port_t   sup_base[1];
-  struct su_pthread_port_waiting_parent 
-                  *sup_waiting_parent;
-  pthread_t        sup_tid;
-#if 0
-  pthread_mutex_t  sup_runlock[1];
-  pthread_cond_t   sup_resume[1];
-  short            sup_paused;	/**< True if thread is paused */
 #endif
-  short            sup_thread;	/**< True if thread is active */
-} su_pthread_port_t;
-
-/* Pthread methods */
-
-SOFIAPUBFUN int su_pthread_port_init(su_port_t *, su_port_vtable_t const *);
-SOFIAPUBFUN void su_pthread_port_deinit(su_port_t *self);
-
-SOFIAPUBFUN void su_pthread_port_lock(su_port_t *self, char const *who);
-SOFIAPUBFUN void su_pthread_port_unlock(su_port_t *self, char const *who);
-
-SOFIAPUBFUN int su_pthread_port_own_thread(su_port_t const *self);
-
-#if 0				/* not yet  */
-SOFIAPUBFUN int su_pthread_port_send(su_port_t *self, su_msg_r rmsg);
-
-SOFIAPUBFUN su_port_t *su_pthread_port_create(void);
-SOFIAPUBFUN su_port_t *su_pthread_port_start(su_root_t *parent,
-					     su_clone_r return_clone,
-					     su_root_magic_t *magic,
-					     su_root_init_f init,
-					     su_root_deinit_f deinit);
-#endif
-
-SOFIAPUBFUN int su_pthreaded_port_start(su_port_create_f *create,
-					su_root_t *parent,
-					su_clone_r return_clone,
-					su_root_magic_t *magic,
-					su_root_init_f init,
-					su_root_deinit_f deinit);
-
-SOFIAPUBFUN void su_pthread_port_wait(su_clone_r rclone);
-SOFIAPUBFUN int su_pthread_port_execute(su_task_r const task,
-					int (*function)(void *), void *arg,
-					int *return_value);
-
-
-#if 0
-SOFIAPUBFUN int su_pthread_port_pause(su_port_t *self);
-SOFIAPUBFUN int su_pthread_port_resume(su_port_t *self);
-#endif
-
-#else
-
-typedef su_base_port_t su_pthread_port_t;
-
-#define su_pthread_port_init   su_base_port_init
-#define su_pthread_port_deinit su_base_port_deinit
-#define su_pthread_port_lock   su_base_port_lock
-#define su_pthread_port_unlock su_base_port_unlock
-#define su_pthread_port_own_thread su_base_port_own_thread
-#define su_pthread_port_wait   su_base_port_wait
-#define su_pthread_port_execute  su_base_port_execute
-
-#endif
-
-/* ====================================================================== */
-/* Mailbox port using sockets */
-
-#define SU_MBOX_SIZE 2
-
-typedef struct su_socket_port_s {
-  su_pthread_port_t sup_base[1];
-  int               sup_mbox_index;
-  su_socket_t       sup_mbox[SU_MBOX_SIZE];
-} su_socket_port_t;
-
-SOFIAPUBFUN int su_socket_port_init(su_socket_port_t *, 
-				    su_port_vtable_t const *);
-SOFIAPUBFUN void su_socket_port_deinit(su_socket_port_t *self);
-SOFIAPUBFUN int su_socket_port_send(su_port_t *self, su_msg_r rmsg);
 
 SOFIA_END_DECLS
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_root.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_root.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_root.c	Sat Feb 17 01:25:21 2007
@@ -48,9 +48,22 @@
 
 struct su_root_s;
 
+typedef struct su_cloned_s {
+  struct su_root_s *sc_root;
+  int *sc_wait;
+#if SU_HAVE_PTHREADS
+  pthread_t  sc_tid;
+  pthread_mutex_t sc_pause[1];
+  pthread_cond_t sc_resume[1];
+  int sc_paused;
+#endif  
+} su_cloned_t;
+
 #define SU_ROOT_MAGIC_T struct su_root_magic_s
 #define SU_WAKEUP_ARG_T struct su_wakeup_arg_s
 #define SU_TIMER_ARG_T  struct su_timer_arg_s
+#define SU_CLONE_T      su_msg_t
+#define SU_MSG_ARG_T    struct su_cloned_s
 
 #include "su_port.h"
 #include "sofia-sip/su_alloc.h"
@@ -123,11 +136,11 @@
 
 #define SU_TASK_ZAP(t, f) \
   while (t->sut_port) { \
-   su_port_decref(t->sut_port, #f); t->sut_port = NULL; break; }
+   SU_PORT_DECREF(t->sut_port, f); t->sut_port = NULL; break; }
 
 #define SU_TASK_ZAPP(t, f) \
   do { if (t->sut_port) { \
-   su_port_decref(t->sut_port, #f); t->sut_port = NULL; } \
+   SU_PORT_DECREF(t->sut_port, f); t->sut_port = NULL; } \
    t->sut_root = NULL; } while(0)
 
 /**
@@ -173,7 +186,7 @@
 
   task->sut_root = root;
   if ((task->sut_port = port)) {
-    su_port_incref(port, "su_task_new");
+    SU_PORT_INCREF(port, su_task_new);
   }
   return task;
 }
@@ -194,14 +207,14 @@
 
   port = src->sut_port;
   if (port) {
-    su_port_incref(port, "su_task_copy");
+    SU_PORT_INCREF(port, su_task_copy);
   }
 
   dst[0] = src[0];
 }
 
 #define SU_TASK_COPY(d, s, by) (void)((d)[0]=(s)[0], \
-  (s)->sut_port?(void)su_port_incref(s->sut_port, #by):(void)0)
+  (s)->sut_port?(void)SU_PORT_INCREF(s->sut_port, by):(void)0)
 
 /**
  * Moves a task handle.
@@ -229,10 +242,8 @@
  */
 int su_task_cmp(su_task_r const a, su_task_r const b)
 {
-  intptr_t retval = (char *)a->sut_port - (char *)b->sut_port;
-
-  if (retval == 0)
-    retval = (char *)a->sut_root - (char *)b->sut_root;
+  intptr_t retval = a->sut_port - b->sut_port;
+  retval = retval ? retval : (char *)a->sut_root - (char *)b->sut_root;
 
   if (sizeof(retval) != sizeof(int)) {
     if (retval < 0)
@@ -318,7 +329,32 @@
   return task ? su_port_timers(task->sut_port) : NULL;
 }
 
-/** Execute the @a function by @a task thread.
+#if SU_HAVE_PTHREADS
+
+struct su_task_execute
+{
+  pthread_mutex_t mutex[1];
+  pthread_cond_t cond[1];
+  int (*function)(void *);
+  void *arg;
+  int value;
+};
+
+static void _su_task_execute(su_root_magic_t *m,
+			     su_msg_r msg,
+			     su_msg_arg_t *a)
+{
+  struct su_task_execute *frame = *(struct su_task_execute **)a;
+  pthread_mutex_lock(frame->mutex);
+  frame->value = frame->function(frame->arg);
+  frame->function = NULL;	/* Mark as completed */
+  pthread_cond_signal(frame->cond);
+  pthread_mutex_unlock(frame->mutex);
+}
+
+#endif
+
+/** Execute by task thread
  *
  * @retval 0 if successful
  * @retval -1 upon an error
@@ -331,7 +367,42 @@
     return (errno = EFAULT), -1;
 
   if (!su_port_own_thread(task->sut_port)) {
-    return su_port_execute(task, function, arg, return_value);
+#if SU_HAVE_PTHREADS
+    int success;
+    su_msg_r m = SU_MSG_R_INIT;
+    struct su_task_execute frame = {
+      { PTHREAD_MUTEX_INITIALIZER },
+      { PTHREAD_COND_INITIALIZER },
+      function, arg, 0
+    };
+
+    if (su_msg_create(m, task, su_task_null,
+		      _su_task_execute, (sizeof &frame)) < 0)
+      return -1;
+
+    *(struct su_task_execute **)su_msg_data(m) = &frame;
+
+    pthread_mutex_lock(frame.mutex);
+
+    success = su_msg_send(m);
+
+    if (success == 0)
+      while (frame.function)
+	pthread_cond_wait(frame.cond, frame.mutex);
+    else
+      su_msg_destroy(m);
+
+    pthread_mutex_unlock(frame.mutex);
+    pthread_mutex_destroy(frame.mutex);
+    pthread_cond_destroy(frame.cond);
+
+    if (return_value)
+      *return_value = frame.value;
+
+    return success;
+#else
+    return (errno = ENOSYS), -1;
+#endif
   }
   else {
     int value = function(arg);
@@ -349,6 +420,51 @@
 
 int su_timer_reset_all(su_timer_t **t0, su_task_r);
 
+/**@ingroup su_wait
+ * 
+ * @page su_clone_t Clone Objects
+ *
+ * The process may be divided into many tasks via cloning. Several tasks may
+ * run in context of one thread, or each task may be run by its own thread. 
+ * However, only a single thread can execute code within a task. There can
+ * be a 1-to-N mapping from thread to tasks. Thus, software using tasks can
+ * be executed by multiple threads in a multithreaded environment and by a
+ * single thread in a singlethreaded environment.
+ * 
+ * The clones are useful for handling tasks that can be executed by a
+ * separate threads, but which do not block excessively. When threads are
+ * not available or they are not needed, clones can also be run in a
+ * single-threaded mode. Running in single-threaded mode is especially
+ * useful while debugging.
+ * 
+ * A clone task is created with function su_clone_start(). Each clone has
+ * its own root object (su_root_t), which holds a context pointer
+ * (su_root_magic_t *). The context object can be different from that of 
+ * parent task.
+ *
+ * When a clone is started, the clone initialization function is called. The
+ * initialization function should do whatever initialization there is to be
+ * performed, register I/O events and timers, and then return. If the
+ * initialization is successful, the clone task reverts to run the event
+ * loop and invoking the event callbacks until its parent stops it by
+ * calling su_clone_wait() which invokes the deinit function. The clone task
+ * is destroyed when the deinit function returns. 
+ *
+ * The public API consists of following functions:
+ *    - su_clone_start()
+ *    - su_clone_task()
+ *    - su_clone_wait()
+ *    - su_clone_forget()
+ *
+ * @note 
+ * There is only one event loop for each thread which can be shared by
+ * multiple clone tasks. Therefore, the clone tasks can not explicitly run
+ * or step the event loop, but they are limited to event callbacks. A clone
+ * task may not call su_root_break(), su_root_run() or su_root_step().
+ */
+
+static void su_root_deinit(su_root_t *self);
+
 /* Note that is *not* necessary same as su_root_t,
  * as su_root_t can be extended */
 
@@ -370,13 +486,9 @@
   return su_root_create_with_port(magic, su_port_create());
 }
 
-/**@internal
- *
- * Create a reactor object using given message port.
+/** Create a reactor object using given message port.
  *
- * Allocate and initialize the instance of su_root_t. Note that this
- * function always uses a reference to su_port_t, even when creating the
- * root fails.
+ * Allocate and initialize the instance of su_root_t.
  *
  * @param magic     pointer to user data
  * @param port      pointer to a message port
@@ -391,7 +503,7 @@
   if (!port)
     return NULL;
 
-  self = su_salloc(su_port_home(port), sizeof(struct su_root_s));
+  self = su_salloc(NULL, sizeof(struct su_root_s));
 
   if (self) {
     self->sur_magic = magic;
@@ -400,17 +512,15 @@
 #else
     self->sur_threading = 0;
 #endif
-    /* This one creates a new reference to port */
     su_task_new(self->sur_task, self, port);
-    /* ... so we zap the old one below */
-  } 
-
-  su_port_decref(port, "su_root_create_with_port");
+  } else {
+    su_port_decref(port, "su_root_create");
+  }
 
   return self;
 }
 
-/** Destroy a root object.
+/** Destroy a synchronization object.
  * 
  *  Stop and free an instance of su_root_t
  *
@@ -418,14 +528,21 @@
  */
 void su_root_destroy(su_root_t *self)
 {
-  su_port_t *port;
-  int unregistered, reset;
-
-  if (!self)
-    return;
-
-  assert(SU_ROOT_OWN_THREAD(self));
+  if (self) {
+    assert(SU_ROOT_OWN_THREAD(self));
+    su_root_deinit(self);
+    su_free(NULL, self);
+  }
+}
 
+/** @internal Deinitialize a synchronization object.
+ *
+ *  Deinitialize an instance of su_root_t
+ *
+ * @param self     pointer to a root object.
+ */
+static void su_root_deinit(su_root_t *self)
+{
   self->sur_deiniting = 1;
 
   if (self->sur_deinit) {
@@ -435,21 +552,17 @@
     deinit(self, magic);
   }
 
-  port = self->sur_port; assert(port);
-
-  unregistered = su_port_unregister_all(port, self);
-  reset = su_timer_reset_all(su_task_timers(self->sur_task), self->sur_task);
-
-  if (unregistered || reset)
-    SU_DEBUG_1(("su_root_destroy: "
-		"%u registered waits, %u timers\n",
-		unregistered, reset));
-
-  SU_TASK_ZAP(self->sur_parent, su_root_destroy);
-
-  su_free(su_port_home(port), self);
+  if (self->sur_port) {
+    int n_w = su_port_unregister_all(self->sur_port, self);
+    int n_t = su_timer_reset_all(su_task_timers(self->sur_task), self->sur_task);
+
+    if (n_w || n_t)
+      SU_DEBUG_1(("su_root_deinit: "
+		  "%u registered waits, %u timers\n", n_w, n_t));
+  }
 
-  su_port_decref(port, "su_root_destroy");
+  SU_TASK_ZAP(self->sur_parent, su_root_deinit);
+  SU_TASK_ZAP(self->sur_task, su_root_deinit);
 }
 
 /** Set the context pointer.
@@ -647,6 +760,7 @@
   }
 }
 
+
 /** Run event and message loop.
  *
  * The function su_root_run() runs the root main loop. The root loop waits
@@ -738,20 +852,12 @@
 int su_root_yield(su_root_t *self)
 {
   if (self && self->sur_task[0].sut_port) {
-    su_virtual_port_t *port = (su_virtual_port_t *)self->sur_task[0].sut_port;
-    /* Make sure we have su_port_wait_events extension */
-    if (port->sup_vtable->su_vtable_size >= 
-	offsetof(su_port_vtable_t, su_port_wait_events) 
-	&& port->sup_vtable->su_port_wait_events)
-      return port->sup_vtable->
-	su_port_wait_events(self->sur_task[0].sut_port, 0);
-
+    su_port_t *port = self->sur_task[0].sut_port;
     /* Make sure we have su_port_yield extension */
     if (port->sup_vtable->su_vtable_size >= 
 	offsetof(su_port_vtable_t, su_port_yield) 
 	&& port->sup_vtable->su_port_yield)
-    return port->sup_vtable->
-      su_port_yield(self->sur_task[0].sut_port);
+      return port->sup_vtable->su_port_yield(port);
   }
   errno = EINVAL;
   return -1;
@@ -813,6 +919,467 @@
   return su_port_remove_prepoll(root->sur_port, root);
 }
 
+/* ========================================================================
+ * su_clone_t
+ */
+
+/* - su_clone_forget() */
+
+#if SU_HAVE_PTHREADS
+struct clone_args
+{
+  su_root_t      * self;
+  su_root_init_f   init;
+  su_root_deinit_f deinit;
+  pthread_mutex_t  mutex;
+  pthread_cond_t   cv;
+  int              retval;
+  su_msg_r         clone;
+  su_root_t const *parent;
+};
+
+static void su_clone_report2(su_root_magic_t *m,
+			     su_msg_r msg,
+			     su_cloned_t *sc);
+
+static void su_clone_signal_parent(void *varg)
+{
+  struct clone_args *arg = (struct clone_args *)varg;
+
+  pthread_mutex_lock(&arg->mutex);
+  pthread_cond_signal(&arg->cv);
+  pthread_mutex_unlock(&arg->mutex);
+}
+
+/** Message function for clone message.
+ *
+ * This calls the clone task deinitialization function, which should make
+ * sure that no more messages are sent by clone task.
+ *
+ * @sa su_clone_wait()
+ */
+static void su_clone_break(su_root_magic_t *m,
+			   su_msg_r msg,
+			   su_cloned_t *sc)
+{
+  su_root_t *root = sc->sc_root;
+
+  root->sur_deiniting = 1;
+
+  if (root->sur_deinit) {
+    su_root_deinit_f deinit = root->sur_deinit;
+    su_root_magic_t *magic = root->sur_magic;
+    root->sur_deinit = NULL;
+    deinit(root, magic);
+  }
+}
+
+/** Delivery report function for clone message.
+ *
+ * This is executed by parent task. This is the last message sent by clone task.
+ */
+static void su_clone_report(su_root_magic_t *m,
+			    su_msg_r msg,
+			    su_cloned_t *sc)
+{
+  su_msg_report(msg, su_clone_report2);
+}
+
+/** Back delivery report function for clone message.
+ *
+ * This is executed by clone task. It completes the three way handshake and
+ * it is used to signal clone that it can destroy its port.
+ */
+static void su_clone_report2(su_root_magic_t *m,
+			    su_msg_r msg,
+			    su_cloned_t *sc)
+{
+  su_root_break(sc->sc_root);
+  if (sc->sc_wait)
+    *sc->sc_wait = 0;
+}
+
+static void *su_clone_main(void *varg)
+{
+  struct clone_args *arg = (struct clone_args *)varg;
+  su_root_t *self = arg->self;
+  su_port_t *port;
+  su_cloned_t *sc;
+
+  pthread_cleanup_push(su_clone_signal_parent, varg);
+
+#if SU_HAVE_WINSOCK
+  su_init();
+#endif
+
+  port = su_port_create();
+  if (!port)
+    pthread_exit(NULL);
+  su_port_threadsafe(port);
+  SU_PORT_INCREF(port, su_clone_main);
+
+  /* Change task ownership */
+  SU_PORT_INCREF(self->sur_task->sut_port = port, su_clone_main);
+  self->sur_task->sut_root = self;
+
+  if (su_msg_create(arg->clone,
+		    self->sur_task, su_root_task(arg->parent),
+		    su_clone_break, sizeof(self)) != 0) {
+    su_port_decref(self->sur_port, "su_clone_main");
+    self->sur_port = NULL;
+    pthread_exit(NULL);
+  }
+
+  su_msg_report(arg->clone, su_clone_report);
+
+  sc = su_msg_data(arg->clone);
+  sc->sc_root = self;
+  sc->sc_tid = pthread_self();
+
+  pthread_mutex_init(sc->sc_pause, NULL);
+  pthread_cond_init(sc->sc_resume, NULL);
+  pthread_mutex_lock(sc->sc_pause);
+
+  if (arg->init && arg->init(self, self->sur_magic) != 0) {
+    if (arg->deinit)
+      arg->deinit(self, self->sur_magic);
+    su_msg_destroy(arg->clone);
+    su_port_decref(self->sur_port, "su_clone_main");
+    self->sur_port = NULL;
+    pthread_exit(NULL);
+  }
+
+  arg->retval = 0;
+
+  pthread_cleanup_pop(1);  /* signal change of ownership */
+
+  su_root_run(self);   /* Do the work */
+
+  su_root_destroy(self);   /* Cleanup root */   
+
+  SU_PORT_ZAPREF(port, su_clone_main);
+
+#if SU_HAVE_WINSOCK
+  su_deinit();
+#endif
+
+  return NULL;
+}
+#endif
+
+static void su_clone_xyzzy(su_root_magic_t *m,
+			   su_msg_r msg,
+			   su_cloned_t *sc)
+{
+  su_root_destroy(sc->sc_root);
+  if (sc->sc_wait)
+    *sc->sc_wait = 0;
+}
+
+/** Start a clone task.
+ *
+ * The function su_clone_start() allocates and initializes a sub-task. 
+ * Depending on the settings, a separate thread may be created to execute
+ * the sub-task. The sub-task is represented by clone handle to the rest of
+ * the application. The function su_clone_start() returns the clone handle
+ * in @a return_clone. The clone handle is used to communicate with the
+ * newly created clone task using messages.
+ *
+ * A new #su_root_t object is created for the sub-task with the @a magic as
+ * the root context pointer. Because the sub-task may or may not have its
+ * own thread, all its activity must be scheduled via this root object. In
+ * other words, the sub-task can be schedule
+ * -# I/O events with su_root_register()
+ * -# timers with su_timer_set(), su_timer_set_at() or su_timer_run()
+ * -# messages with su_msg_send().
+ *
+ * Messages can also be used to pass information between tasks or threads.
+ *
+ * In multi-threaded implementation, su_clone_start() launches a new thread,
+ * and the initialization routine is executed by this newly created thread. 
+ * The calling thread blocks until the initialization routine completes. If
+ * the initialization routine returns #su_success (0), the sub-task is
+ * considered to be created successfully. After the successful
+ * initialization, the sub-task continues to execeute the function
+ * su_root_run().
+ *
+ * In single-threaded implementations, just a new root object is created. 
+ * The initialization routine is called directly from su_clone_start().
+ *
+ * If the initalization function @a init fails, the sub-task (either the
+ * newly created thread or the current thread executing the su_clone_start()
+ * function) calls the deinitialization function, and su_clone_start()
+ * returns NULL.
+ *
+ * @param parent   root to be cloned (may be NULL if multi-threaded)
+ * @param return_clone reference to a clone [OUT]
+ * @param magic    pointer to user data
+ * @param init     initialization function
+ * @param deinit   deinitialization function
+ *
+ * @return 0 if successfull, -1 upon an error.
+ *
+ * @sa su_root_threading(), su_clone_task(), su_clone_stop(), su_clone_wait(),
+ * su_clone_forget().
+ */
+int su_clone_start(su_root_t *parent,
+		   su_clone_r return_clone,
+		   su_root_magic_t *magic,
+		   su_root_init_f init,
+		   su_root_deinit_f deinit)
+{
+  su_root_t *child;
+  int retval = -1;
+
+  if (parent) {
+    assert(SU_ROOT_OWN_THREAD(parent));
+    assert(parent->sur_port);
+  }
+#if !SU_HAVE_PTHREADS
+  else {
+    /* if we don't have threads, we *must* have parent root */
+    return -1;
+  }
+#endif
+
+  child = su_salloc(NULL, sizeof(struct su_root_s));
+
+#if SU_HAVE_PTHREADS
+  if (child && (parent == NULL || parent->sur_threading)) {
+    struct clone_args arg = {
+      NULL, NULL, NULL,
+      PTHREAD_MUTEX_INITIALIZER,
+      PTHREAD_COND_INITIALIZER,
+      -1,
+      SU_MSG_R_INIT,
+      NULL
+    };
+
+    int thread_created = 0;
+    pthread_t tid;
+
+    su_port_threadsafe(parent->sur_port);
+
+    arg.self = child;
+    arg.init = init;
+    arg.deinit = deinit;
+    arg.parent = parent;
+
+    child->sur_magic = magic;
+    child->sur_deinit = deinit;
+    child->sur_threading = parent->sur_threading;
+
+    SU_TASK_COPY(child->sur_parent, su_root_task(parent), su_clone_start);
+
+    pthread_mutex_lock(&arg.mutex);
+    if (pthread_create(&tid, NULL, su_clone_main, &arg) == 0) {
+      pthread_cond_wait(&arg.cv, &arg.mutex);
+      thread_created = 1;
+    }
+    pthread_mutex_unlock(&arg.mutex);
+
+    if (arg.retval != 0) {
+      if (thread_created)
+	pthread_join(tid, NULL);
+      su_root_destroy(child), child = NULL;
+    }
+    else {
+      retval = 0;
+      *return_clone = *arg.clone;
+    }
+  } else
+#endif
+  if (child) {
+    assert(parent);
+
+    child->sur_magic = magic;
+    child->sur_deinit = deinit;
+    child->sur_threading = parent->sur_threading;
+
+    SU_TASK_COPY(child->sur_parent, su_root_task(parent), su_clone_start);
+    SU_TASK_COPY(child->sur_task, child->sur_parent, su_clone_start);
+    su_task_attach(child->sur_task, child);
+
+    if (su_msg_create(return_clone,
+		      child->sur_task, su_root_task(parent),
+		      su_clone_xyzzy, sizeof(child)) == 0) {
+      if (init == NULL || init(child, magic) == 0) {
+	su_cloned_t *sc = su_msg_data(return_clone);
+	sc->sc_root = child;
+#if SU_HAVE_PTHREADS
+	sc->sc_tid = pthread_self();
+	pthread_mutex_init(sc->sc_pause, NULL);
+	pthread_cond_init(sc->sc_resume, NULL);
+	pthread_mutex_lock(sc->sc_pause);
+#endif
+	retval = 0;
+      } else {
+	if (deinit)
+	  deinit(child, magic);
+	su_msg_destroy(return_clone);
+	su_root_destroy(child), child = NULL;
+      }
+    }
+    else {
+      su_root_destroy(child), child = NULL;
+    }
+  }
+
+  return retval;
+}
+
+/** Get reference to clone task.
+ * 
+ * @param clone Clone pointer
+ *
+ * @return A reference to the task structure of the clone.
+ */
+_su_task_r su_clone_task(su_clone_r clone)
+{
+  return su_msg_to(clone);
+}
+
+/**Forget the clone.
+ * 
+ * Normally, the clone task executes until it is stopped.  If the parent
+ * task does not need to stop the task, it can "forget" the clone.  The
+ * clone exits independently of the parent task.
+ *
+ * @param rclone Reference to the clone.
+ */
+void su_clone_forget(su_clone_r rclone)
+{
+  su_msg_destroy(rclone);
+}
+
+/** Stop the clone.
+ *
+ * @deprecated. Use su_clone_wait().
+ */
+void su_clone_stop(su_clone_r rclone)
+{
+  su_msg_send(rclone);
+}
+
+/** Stop a clone and wait until it is has completed.
+ *
+ * The function su_clone_wait() is used to stop the clone task and wait
+ * until it has cleaned up. The clone task is destroyed asynchronously. The
+ * parent sends a message to clone, clone deinitializes itself and then
+ * replies. After the reply message is received by the parent, it will send
+ * a third message back to clone.
+ *
+ * The parent destroy all messages to or from clone task before calling
+ * su_clone_wait(). The parent task may not send any messages to the clone
+ * after calling su_clone_wait(). The su_clone_wait() function blocks until
+ * the cloned task is destroyed. During that time, the parent task must be
+ * prepared to process all the messages sent by clone task. This includes
+ * all the messages sent by clone before destroy message reached the clone.
+ */
+void su_clone_wait(su_root_t *root, su_clone_r rclone)
+{
+  su_cloned_t *sc = su_msg_data(rclone);
+
+  if (sc) {
+#if SU_HAVE_PTHREADS
+    pthread_t clone_tid = sc->sc_tid;
+#endif
+    int one = 1;
+    /* This does 3-way handshake. 
+     * First, su_clone_break() is executed by clone. 
+     * The message is returned to parent (this task), 
+     * which executes su_clone_report().
+     * Then the message is again returned to clone, 
+     * which executes su_clone_report2() and exits.
+     */
+    sc->sc_wait = &one;
+    su_msg_send(rclone);
+
+    su_root_step(root, 0);
+    su_root_step(root, 0);
+
+    while (one)
+      su_root_step(root, 10);
+
+#if SU_HAVE_PTHREADS
+    if (!pthread_equal(clone_tid, pthread_self()))
+      pthread_join(clone_tid, NULL);
+#endif
+  }
+}
+
+#if SU_HAVE_PTHREADS		/* No-op without threads */
+static
+void su_clone_paused(su_root_magic_t *magic, su_msg_r msg, su_msg_arg_t *arg)
+{
+  su_cloned_t *cloned = *(su_cloned_t **)arg;
+  assert(cloned);
+  pthread_cond_wait(cloned->sc_resume, cloned->sc_pause);
+}
+#endif
+
+/** Pause a clone.
+ *
+ * Obtain a exclusive lock on clone's private data.
+ *
+ * @retval 0 if successful (and clone is paused)
+ * @retval -1 upon an error
+ */
+int su_clone_pause(su_clone_r rclone)
+{
+#if SU_HAVE_PTHREADS		/* No-op without threads */
+  su_cloned_t *cloned = su_msg_data(rclone);
+  su_msg_r m = SU_MSG_R_INIT;
+
+  if (!cloned)
+    return (errno = EFAULT), -1;
+
+  if (pthread_equal(pthread_self(), cloned->sc_tid))
+    return 0;
+
+  if (su_msg_create(m, su_clone_task(rclone), su_task_null,
+		    su_clone_paused, sizeof cloned) < 0)
+    return -1;
+
+  *(su_cloned_t **)su_msg_data(m) = cloned;
+
+  if (su_msg_send(m) < 0)
+    return -1;
+
+  if (pthread_mutex_lock(cloned->sc_pause) < 0)
+    return -1;
+  pthread_cond_signal(cloned->sc_resume);
+#endif
+
+  return 0;
+}
+
+/** Resume a clone.
+ *
+ * Give up a exclusive lock on clone's private data.
+ *
+ * @retval 0 if successful (and clone is resumed)
+ * @retval -1 upon an error
+ */
+int su_clone_resume(su_clone_r rclone)
+{
+#if SU_HAVE_PTHREADS		/* No-op without threads */
+  su_cloned_t *cloned = su_msg_data(rclone);
+
+  if (!cloned)
+    return (errno = EFAULT), -1;
+
+  if (pthread_equal(pthread_self(), cloned->sc_tid))
+    return 0;
+
+  if (pthread_mutex_unlock(cloned->sc_pause) < 0)
+    return -1;
+#endif
+
+  return 0;
+}
+
+
 /* =========================================================================
  * Messages
  */
@@ -838,9 +1405,12 @@
 		  su_msg_f        wakeup,
 		  isize_t         size)
 {
+  su_port_t *port = to->sut_port;
   su_msg_t *msg;
 
-  msg = su_zalloc(NULL, sizeof(*msg) + size);
+  SU_PORT_LOCK(port, su_msg_create);
+  msg = su_zalloc(NULL /*port->sup_home*/, sizeof(*msg) + size);
+  SU_PORT_UNLOCK(port, su_msg_create);
 
   if (msg) {
     msg->sum_size = sizeof(*msg) + size;
@@ -952,14 +1522,14 @@
   if (rmsg[0]) {
     /* su_port_t *port = rmsg[0]->sum_to->sut_port; */
 
-    /* su_port_incref(port, "su_msg_destroy"); */
+    /* SU_PORT_INCREF(port, su_msg_destroy); */
     SU_TASK_ZAP(rmsg[0]->sum_to, su_msg_destroy);
     SU_TASK_ZAP(rmsg[0]->sum_from, su_msg_destroy);
 
     su_free(NULL /* port->sup_home */, rmsg[0]);
     /* SU_PORT_UNLOCK(port, su_msg_destroy); */
 
-    /* su_port_decref(port, "su_msg_destroy"); */
+    /* SU_PORT_DECREF(port, su_msg_destroy); */
   }
 
   rmsg[0] = NULL;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c	Sat Feb 17 01:25:21 2007
@@ -193,10 +193,7 @@
 	      IS_RED, SET_RED, IS_BLACK, SET_BLACK, COPY_COLOR,
 	      CMP, INSERT, REMOVE);
 
-/**@internal Set the timer. 
- *
- * @retval 0 when successful (always)
- */
+/** Set the timer. */
 static inline int
 su_timer_set0(su_timer_t **timers,
 	      su_timer_t *t,
@@ -215,10 +212,7 @@
   return timers_append(timers, t);
 }
 
-/**@internal Reset the timer. 
- *
- * @retval 0 when successful (always)
- */
+/** Reset the timer. */
 static inline int
 su_timer_reset0(su_timer_t **timers,
 		su_timer_t *t)
@@ -235,40 +229,6 @@
   return 0;
 }
 
-/**@internal Validate timer @a t and return pointer to per-port timer tree.
- * 
- * @retval pointer to pointer to timer tree when successful
- * @retval NULL upon an error
- */
-static
-su_timer_t **su_timer_tree(su_timer_t const *t,
-			   int use_sut_duration,
-			   char const *caller)
-{
-  su_timer_t **timers;
-
-  if (t == NULL) {
-    SU_DEBUG_1(("%s(%p): %s\n", caller, (void *)t,
-		"NULL argument"));
-    return NULL;
-  }
-
-  timers = su_task_timers(t->sut_task);
-
-  if (timers == NULL)
-    SU_DEBUG_1(("%s(%p): %s\n", caller, (void *)t,
-		"invalid timer"));
-
-  if (use_sut_duration && t->sut_duration == 0) {
-    assert(t->sut_duration > 0);
-    SU_DEBUG_1(("%s(%p): %s\n", caller, (void *)t, 
-		"timer without default duration"));
-    return NULL;
-  }
-
-  return timers;
-}
-
 
 /**Create a timer.
  *
@@ -331,12 +291,23 @@
 			  su_timer_arg_t *arg,
 			  su_duration_t interval)
 {
-  su_timer_t **timers = su_timer_tree(t, 0, "su_timer_set_interval");
+  char const *func = "su_timer_set_interval";
+  su_timer_t **timers;
 
-  if (t == NULL)
+  if (t == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
     return -1;
+  }
 
-  return su_timer_set0(timers, t, wakeup, arg, su_now(), interval);
+  timers = su_task_timers(t->sut_task);
+  if (timers == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
+    return -1;
+  }
+
+  su_timer_set0(timers, t, wakeup, arg, su_now(), interval);
+
+  return 0;
 }
 
 /** Set the timer for the default interval.
@@ -355,12 +326,18 @@
 		 su_timer_f wakeup,
 		 su_timer_arg_t *arg)
 {
-  su_timer_t **timers = su_timer_tree(t, 1, "su_timer_set");
+  char const *func = "su_timer_set";
+
+  if (t == NULL)
+    return -1;
 
-  if (timers == NULL)
+  assert(t->sut_duration > 0);
+  if (t->sut_duration == 0) {
+    SU_DEBUG_0(("%s(%p): %s\n", func, t, "timer without default duration"));
     return -1;
+  }
 
-  return su_timer_set0(timers, t, wakeup, arg, su_now(), t->sut_duration);
+  return su_timer_set_interval(t, wakeup, arg, t->sut_duration);
 }
 
 /** Set timer at known time.
@@ -379,12 +356,23 @@
 		    su_wakeup_arg_t *arg,
 		    su_time_t when)
 {
-  su_timer_t **timers = su_timer_tree(t, 0, "su_timer_set_at");
+  char const *func = "su_timer_set_at";
+  su_timer_t **timers;
 
-  if (timers == NULL)
+  if (t == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
     return -1;
+  }
 
-  return su_timer_set0(timers, t, wakeup, arg, when, 0);
+  timers = su_task_timers(t->sut_task);
+  if (timers == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
+    return -1;
+  }
+
+  su_timer_set0(timers, t, wakeup, arg, when, 0);
+
+  return 0;
 }
 
 /** Set the timer for regular intervals.
@@ -409,17 +397,34 @@
 		 su_timer_f wakeup,
 		 su_timer_arg_t *arg)
 {
-  su_timer_t **timers = su_timer_tree(t, 1, "su_timer_run");
-  su_time_t now;
+  char const *func = "su_timer_run";
+  su_timer_t **timers;
+  su_time_t now = su_now();
+
+  if (t == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
+    return -1;
+  }
+
+  assert(t->sut_duration > 0);
+  if (t->sut_duration == 0) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "timer without default duration"));
+    return -1;
+  }
 
-  if (timers == NULL)
+  timers = su_task_timers(t->sut_task);
+  if (timers == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
     return -1;
+  }
 
   t->sut_running = run_at_intervals;
-  t->sut_run = now = su_now();
+  t->sut_run = now;
   t->sut_woken = 0;
 
-  return su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
+  su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
+
+  return 0;
 }
 
 /**Set the timer for regular intervals.
@@ -442,19 +447,37 @@
 			  su_timer_f wakeup,
 			  su_timer_arg_t *arg)
 {
-  su_timer_t **timers = su_timer_tree(t, 1, "su_timer_set_for_ever");
-  su_time_t now;
+  char const *func = "su_timer_run";
+  su_timer_t **timers;
+  su_time_t now = su_now();
 
-  if (timers == NULL)
+  if (t == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
     return -1;
+  }
+
+  assert(t->sut_duration > 0);
+  if (t->sut_duration == 0) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "timer without default duration"));
+    return -1;
+  }
+
+  timers = su_task_timers(t->sut_task);
+  if (timers == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "invalid timer"));
+    return -1;
+  }
 
   t->sut_running = run_for_ever;
-  t->sut_run = now = su_now();
+  t->sut_run = now;
   t->sut_woken = 0;
 
-  return su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
+  su_timer_set0(timers, t, wakeup, arg, now, t->sut_duration);
+
+  return 0;
 }
 
+
 /**Reset the timer.
  *
  * Resets (stops) the given timer.
@@ -465,12 +488,19 @@
  */
 int su_timer_reset(su_timer_t *t)
 {
-  su_timer_t **timers = su_timer_tree(t, 0, "su_timer_reset");
+  char const *func = "su_timer_reset";
+  su_timer_t **timers;
 
-  if (timers == NULL)
+  if (t == NULL) {
+    SU_DEBUG_1(("%s(%p): %s\n", func, t, "NULL argument"));
     return -1;
+  }
 
-  return su_timer_reset0(timers, t);
+  timers = su_task_timers(t->sut_task);
+
+  su_timer_reset0(timers, t);
+
+  return 0;
 }
 
 /** @internal Check for expired timers in queue.
@@ -544,7 +574,6 @@
 }
 
 
-/** Calculate duration in milliseconds until next timer expires. */
 su_duration_t su_timer_next_expires(su_timer_t const * t, su_time_t now)
 {
   su_duration_t tout;
@@ -594,13 +623,14 @@
 
 /** Get the root object owning the timer.
  *
- * Return pointer to the root object owning the timer.
+ *   The function su_timer_root() return pointer to the root object owning the
+ *   timer.
  *
  * @param t pointer to the timer
  *
- * @return Pointer to the root object.
+ * @return Pointer to the root object owning the timer.
  */
 su_root_t *su_timer_root(su_timer_t const *t)
 {
-  return t ? su_task_root(t->sut_task) : NULL;
+  return su_task_root(t->sut_task);
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_wait.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_wait.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_wait.c	Sat Feb 17 01:25:21 2007
@@ -149,7 +149,7 @@
 
   *newwait = h;
 
-#elif SU_HAVE_POLL || HAVE_SELECT
+#elif SU_HAVE_POLL
   int mode;
 
   if (newwait == NULL || events == 0 || socket == INVALID_SOCKET) {
@@ -187,9 +187,7 @@
   su_wait_t w0 = NULL;
   if (*waitobj)
     WSACloseEvent(*waitobj);
-#elif SU_HAVE_POLL || HAVE_SELECT
-  su_wait_t w0 = { INVALID_SOCKET, 0, 0 };
-#else
+#elif SU_HAVE_POLL
   su_wait_t w0 = { INVALID_SOCKET, 0, 0 };
 #endif
   assert(waitobj != NULL);
@@ -233,7 +231,7 @@
   else
     return i;
 
-#elif SU_HAVE_POLL || HAVE_SELECT
+#elif SU_HAVE_POLL
   for (;;) {
     int i = poll(waits, n, timeout);
 
@@ -275,7 +273,7 @@
 
   return net_events.lNetworkEvents;
 
-#elif SU_HAVE_POLL || HAVE_SELECT
+#elif SU_HAVE_POLL
   /* poll(e, 1, 0); */
   return waitobj->revents;
 #endif
@@ -304,7 +302,7 @@
     WSASetLastError(error);
     return -1;
   }
-#elif SU_HAVE_POLL || HAVE_SELECT
+#elif SU_HAVE_POLL
   waitobj->fd = s;
   waitobj->events = events;
   waitobj->revents = 0;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/tag_dll.awk
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/tag_dll.awk	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/tag_dll.awk	Sat Feb 17 01:25:21 2007
@@ -110,11 +110,6 @@
   print "" > DLL;
 }
 
-/SU_HAVE_EXPERIMENTAL/ { 
-  print $0 > REF; 
-  print $0 > DLL; 
-}
-
 !DEFS && /^tag_typedef_t/ { DEFS = 1; }
 
 DEFS && /tag_typedef_t/ {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/test_su.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/test_su.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/test_su.c	Sat Feb 17 01:25:21 2007
@@ -36,6 +36,13 @@
 
 #include "config.h"
 
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+
+#include <assert.h>
+
 struct pinger;
 #define SU_ROOT_MAGIC_T struct pinger
 #define SU_INTERNAL_P   su_root_t *
@@ -46,12 +53,6 @@
 #include "sofia-sip/su_log.h"
 #include "sofia-sip/su_debug.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <assert.h>
-
 char const name[] = "su_test";
 
 #if HAVE_FUNC
@@ -409,6 +410,14 @@
   }
 }
 
+static
+RETSIGTYPE term(int n)
+{
+  enter;
+
+  exit(1);
+}
+
 void
 time_test(void)
 {
@@ -431,12 +440,10 @@
     printf("time_test: passed\n");
 }
 
-#if HAVE_SIGNAL
+#if HAVE_ALARM
 #include <unistd.h>
 #include <signal.h>
 
-#if HAVE_ALARM
-
 static RETSIGTYPE sig_alarm(int s)
 {
   enter;
@@ -449,18 +456,6 @@
 static char const no_alarm[] = "";
 #endif
 
-static
-RETSIGTYPE term(int n)
-{
-  enter;
-
-  exit(1);
-}
-#else
-static char const no_alarm[] = "";
-#endif
-
-
 void
 usage(int exitcode)
 {
@@ -524,10 +519,11 @@
     }
   }
 
+  signal(SIGTERM, term);
+
   su_init(); atexit(su_deinit);
 
-#if HAVE_SIGNAL
-  signal(SIGTERM, term);
+  time_test();
 
 #if HAVE_ALARM
   if (opt_alarm) {
@@ -536,10 +532,6 @@
   }
 #endif
 
-#endif
-
-  time_test();
-
   root = su_root_create(NULL);
   if (!root) perror("su_root_create"), exit(1);
   

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su.c	Sat Feb 17 01:25:21 2007
@@ -47,7 +47,7 @@
 #define TSTFLAGS tstflags
 #include <sofia-sip/tstdef.h>
 
-char const *name = "torture_su";
+char const *name = "su_torture";
 
 static int test_sockaddr(void);
 
@@ -100,7 +100,7 @@
   TEST(su_setblocking(s, 1), 0);
   TEST(su_close(s), 0);
 
-  su_freelocalinfo(res), res = NULL;
+  su_freelocalinfo(res);
 
 #if SU_HAVE_IN6
   hints->li_family = AF_INET6;
@@ -111,17 +111,16 @@
   for (li = res; li; li = li->li_next)
     TEST(li->li_family, AF_INET6);
 
-  su_freelocalinfo(res), res = NULL;
+  su_freelocalinfo(res);
 #endif
 
   hints->li_flags |= LI_NUMERIC;
   TEST(su_getlocalinfo(hints, &res), 0);
-  su_freelocalinfo(res), res = NULL;
 
-  res = NULL;
   hints->li_flags |= LI_NAMEREQD;
+  res = NULL;
   su_getlocalinfo(hints, &res);
-  su_freelocalinfo(res), res = NULL;
+  su_freelocalinfo(res);
 
   memset(a, 0, sizeof *a); 
   memset(b, 0, sizeof *b); 
@@ -162,7 +161,7 @@
 
 int test_sendrecv(void)
 {
-  su_socket_t s, l, a;
+  int s, l, a;
   int n;
   su_sockaddr_t su, csu;
   socklen_t sulen = sizeof su.su_sin, csulen = sizeof csu.su_sin;
@@ -261,120 +260,6 @@
   END();
 }
 
-#if HAVE_SELECT 
-
-#if HAVE_WIN32
-int test_select(void)
-{
-  return 0;
-}
-#else
-
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#elif HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#include <sys/types.h>
-#include <unistd.h>
-
-#ifndef __NFDBITS
-#define __NFDBITS (8 * sizeof (long int))
-#endif
-
-#undef howmany
-/* Size of fd set in bytes. Sorry, octets. */
-#define howmany(n) (((n) + __NFDBITS - 1) / __NFDBITS * (__NFDBITS / 8))
-
-#define FD_ZERO_TO(maxfd, set) \
-  memset((set), 0, howmany(maxfd))
-
-/* Test assumptions in su_select_port implementation */
-int test_select(void)
-{
-  su_socket_t s;
-  su_sockaddr_t su;
-  socklen_t sulen = sizeof su.su_sin;
-  size_t bytes;
-  fd_set *rset, *wset;
-  struct timeval tv;
-
-  BEGIN();
-
-  s = su_socket(AF_INET, SOCK_DGRAM, 0); TEST_1(s != -1);
-
-  memset(&su, 0, sulen);
-  su.su_len = sulen;
-  su.su_family = AF_INET;
-  TEST(inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
-  TEST(bind(s, &su.su_sa, sulen), 0);
-  TEST(getsockname(s, &su.su_sa, &sulen), 0);
-  
-  tv.tv_sec = 0; tv.tv_usec = 1000;
-  TEST(select(0, NULL, NULL, NULL, &tv), 0);
-
-  bytes = howmany(s);
-  TEST_1(rset = malloc(bytes));
-  TEST_1(wset = malloc(bytes));
-
-  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); FD_SET(s, wset);
-  tv.tv_sec = 0, tv.tv_usec = 1000;
-  TEST(select(s + 1, NULL, wset, NULL, &tv), 1);
-  TEST_1(FD_ISSET(s, wset));
-
-  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
-  FD_SET(s, rset); FD_SET(s, wset);
-  tv.tv_sec = 0, tv.tv_usec = 1000;
-  TEST(select(s + 1, rset, wset, NULL, &tv), 1);
-  TEST_1(!FD_ISSET(s, rset));
-  TEST_1(FD_ISSET(s, wset));
-
-  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
-  FD_SET(s, rset); FD_SET(s, wset);
-  tv.tv_sec = 0, tv.tv_usec = 1000;
-  TEST(select(s + 1, rset, NULL, NULL, &tv), 0);
-  TEST_1(!FD_ISSET(s, rset));
-
-  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
-  FD_SET(s, rset); FD_CLR(s, wset);
-  tv.tv_sec = 0, tv.tv_usec = 1000;
-  TEST(select(s + 1, rset, wset, NULL, &tv), 0);
-  TEST_1(!FD_ISSET(s, rset));
-  TEST_1(!FD_ISSET(s, wset));
-
-  TEST(su_sendto(s, "foo", 3, 0, &su, sulen), 3);
-
-  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
-  FD_SET(s, rset); FD_CLR(s, wset);
-  tv.tv_sec = 0, tv.tv_usec = 1000;
-  TEST(select(s + 1, rset, wset, NULL, &tv), 1);
-  TEST_1(FD_ISSET(s, rset));
-  TEST_1(!FD_ISSET(s, wset));
-
-  FD_ZERO_TO(s, rset); FD_ZERO_TO(s, wset); 
-  FD_SET(s, rset); FD_SET(s, wset);
-  tv.tv_sec = 0, tv.tv_usec = 1000;
-  TEST(select(s + 1, rset, wset, NULL, &tv), 2);
-  TEST_1(FD_ISSET(s, rset));
-  TEST_1(FD_ISSET(s, wset));
-
-  su_close(s);
-
-  free(wset);
-  free(rset);
-
-  END();
-}
-#endif
-
-#else
-int test_select(void)
-{
-  return 0;
-}
-#endif
-
 #include <sofia-sip/su_md5.h>
 
 int test_md5(void)
@@ -510,10 +395,10 @@
   
   retval |= test_sockaddr();
   retval |= test_sendrecv();
-  retval |= test_select();
   retval |= test_md5(); fflush(stdout);
 
   su_deinit();
 
   return retval;
 }
+

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_alloc.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_alloc.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_alloc.c	Sat Feb 17 01:25:21 2007
@@ -59,12 +59,6 @@
   (*ex->p)++;
 }
 
-void test_destructor(void *a)
-{
-  su_home_t *h = a;
-  h->suh_size = 13;
-}
-
 /** Test basic memory home operations  */
 static int test_alloc(void)
 {
@@ -84,8 +78,8 @@
 
   d0 = d1a = d1 = d2 = d3 = 0;
   h0->p = &d0; h1->p = &d1a;
-  TEST(su_home_destructor(h0->home, exdestructor), 0);
-  TEST(su_home_destructor(h1->home, exdestructor), 0);
+  TEST(su_home_desctructor(h0->home, exdestructor), 0);
+  TEST(su_home_desctructor(h1->home, exdestructor), 0);
 
   TEST_1(h2 = su_home_ref(h0->home));
   su_home_unref(h0->home);
@@ -101,7 +95,7 @@
   TEST(d1a, destructed_once);
 
   TEST_1(h1 = su_home_clone(h0->home, sizeof(*h1)));
-  TEST(su_home_destructor(h1->home, exdestructor), 0);
+  TEST(su_home_desctructor(h1->home, exdestructor), 0);
   h1->p = &d1;
 
   for (i = 0; i < 128; i++)
@@ -131,7 +125,7 @@
 
   TEST_1(su_in_home(h2->home, m));
   TEST_1(!su_in_home(h2->home, (char *)m + 1));
-  TEST_1(!su_in_home(h2->home, (void *)(intptr_t)su_in_home));
+  TEST_1(!su_in_home(h2->home, su_in_home));
   TEST_1(!su_in_home(h3->home, m));
   TEST_1(!su_in_home(NULL, m));
   TEST_1(!su_in_home(h3->home, NULL));
@@ -167,25 +161,6 @@
   su_home_check(h0->home);
   su_home_zap(h0->home);
 
-  {
-    su_home_t h1[1];
-
-    memset(h1, 0, sizeof h1);
-
-    TEST(su_home_init(h1), 0);
-    TEST(su_home_threadsafe(h1), 0);
-
-    TEST_1(su_home_ref(h1));
-    TEST_1(su_home_ref(h1));
-
-    TEST(su_home_destructor(h1, test_destructor), 0);
-
-    TEST_1(!su_home_unref(h1));
-    TEST_1(!su_home_unref(h1));
-    TEST_1(su_home_unref(h1));
-    TEST(h1->suh_size, 13);
-  }
-
   END();
 }
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_bm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_bm.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_bm.c	Sat Feb 17 01:25:21 2007
@@ -192,8 +192,6 @@
 
     s = bm_memmem(hs, strlen(hs), needle, nlen, fwd);
 
-    free(fwd);
-
     TEST_S(s, hs + 1919);
 
     TEST_1(bm_memmem(hs, strlen(hs), Needle, nlen, NULL) == 0);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_port.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_port.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_port.c	Sat Feb 17 01:25:21 2007
@@ -24,7 +24,7 @@
 
 /**
  * @file torture_su_port.c
- * @brief Test su_poll_port interface
+ * @brief Test su_port interface
  *
  * @author Pekka Pessi <Pekka.Pessi at nokia.com>
  * @date Created: Wed Mar 10 17:05:23 2004 ppessi
@@ -39,10 +39,7 @@
 
 #define SU_ROOT_MAGIC_T struct su_root_magic_s
 
-#include "su_poll_port.c"
-
-#undef HAVE_EPOLL
-#define HAVE_EPOLL 0
+#include "su_port.c"
 
 #if HAVE_FUNC
 #elif HAVE_FUNCTION
@@ -59,7 +56,7 @@
 
 char const *name = "torture_su_port";
 
-int const N0 = SU_MBOX_SIZE > 0, N = 128, I = 129;
+int N0 = SU_HAVE_MBOX, N = 128, I = 128 + 1;
 
 int test_sup_indices(su_port_t const *port)
 {
@@ -124,7 +121,7 @@
 
   magic->wakeups[i]++;
 
-#if HAVE_POLL || HAVE_SELECT
+#if HAVE_POLL
   if (w->fd != magic->sockets[i])
     return ++magic->error;
 #endif
@@ -147,8 +144,7 @@
       su_perror("getsockname"), exit(1);
     if (su_sendto(magic->sockets[1], "X", 1, 0, su, sulen) < 0)
       su_perror("su_sendto"), exit(1);
-    n = su_poll_port_wait_events(port, 100);
-
+    n = su_port_wait_events(port, 100);
     if (n != 1)
       return 1;
     if (magic->error)
@@ -192,10 +188,9 @@
 
   su_root_size_hint = 16;
 
-  TEST_1(port = su_poll_port_create());
+  TEST_1(port = su_port_create());
   TEST(su_port_threadsafe(port), 0);
-  /* Before 1.12.4 su_port_create() had reference count 0 after creation */
-  /* su_port_incref(port, "test_register"); */
+  SU_PORT_INCREF(port, __func__);
 
   TEST_1(test_sup_indices(port));
 
@@ -297,7 +292,7 @@
     TEST(su_port_deregister(port, reg[i]), -1);
   }
 
-  TEST_VOID(su_port_decref(port, __func__));
+  TEST_VOID(su_port_decref(port, 1, __func__));
 
   END();
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_root.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_root.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_root.c	Sat Feb 17 01:25:21 2007
@@ -54,19 +54,15 @@
 
 #include <sofia-sip/su_wait.h>
 #include <sofia-sip/su_alloc.h>
-#include <sofia-sip/su_log.h>
 
-struct test_ep_s {
-  test_ep_t     *next, **prev, **list;
+typedef struct test_ep_s {
   int           i;
   int           s;
   su_wait_t     wait[1];
   int           registered;
   socklen_t     addrlen;
   su_sockaddr_t addr[1];
-};
-
-typedef struct test_ep_s   test_ep_at[1];
+} test_ep_at[1];
 
 struct root_test_s {
   su_home_t  rt_home[1];
@@ -85,15 +81,7 @@
   unsigned   rt_success_init:1;
   unsigned   rt_success_deinit:1;
 
-  unsigned   rt_sent_reporter:1;
-  unsigned   rt_recv_reporter:1;
-  unsigned   rt_reported_reporter:1;
-
-  unsigned :0;
-
   test_ep_at rt_ep[5];
-
-  int rt_sockets, rt_woken;
 };
 
 /** Test root initialization */
@@ -191,6 +179,7 @@
 static
 su_wakeup_f wakeups[5] = { wakeup0, wakeup1, wakeup2, wakeup3, wakeup4 };
 
+
 static
 void test_run(root_test_t *rt)
 {
@@ -282,133 +271,6 @@
   END();
 }
 
-
-int wakeup_remove(root_test_t *rt, su_wait_t *w, test_ep_t *node)
-{
-  char buffer[64];
-  ssize_t x;
-  test_ep_t *n = node->next; 
-
-  su_wait_events(w, node->s);
-
-  x = recv(node->s, buffer, sizeof(buffer), 0);
-
-  if (x < 0)
-    fprintf(stderr, "%s: %s\n", "recv", su_strerror(su_errno()));
-
-  if (node->prev) {		/* first run */
-    *node->prev = n;
-
-    if (n) {
-      *node->prev = node->next;    
-      node->next->prev = node->prev;
-      sendto(n->s, "foo", 3, 0, (void *)n->addr, n->addrlen);
-    }
-
-    node->next = NULL;
-    node->prev = NULL;
-    
-    if (!*node->list) {
-      su_root_break(rt->rt_root);
-    }
-  }
-  else {			/* second run */
-    if (++rt->rt_woken == rt->rt_sockets)
-      su_root_break(rt->rt_root);
-  }
-
-  return 0;
-}
-
-
-int event_test(root_test_t rt[1])
-{
-  BEGIN();
-  int i = 0, N = 2048;
-  test_ep_t *n, *nodes, *list = NULL;
-  su_sockaddr_t su[1];
-  socklen_t sulen;
-  
-  TEST_1(nodes = calloc(N, sizeof *nodes));
-  
-  memset(su, 0, sulen = sizeof su->su_sin);
-  su->su_len = sizeof su->su_sin;
-  su->su_family = AF_INET;
-  su->su_sin.sin_addr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */
-
-  for (i = 0; i < N; i++) {
-    n = nodes + i;
-    n->s = su_socket(AF_INET, SOCK_DGRAM, 0);
-
-    if (n->s == INVALID_SOCKET)
-      break;
-
-    n->addrlen = sizeof n->addr;
-
-    n->addr->su_len = sizeof n->addr;
-
-    if (bind(n->s, (void *)su, sulen) < 0) {
-      su_perror("bind()");
-      su_close(n->s);
-      break;
-    }
-      
-    if (getsockname(n->s, (void *)n->addr, &n->addrlen)) {
-      su_perror("getsockname()");
-      su_close(n->s);
-      break;
-    }
-
-    if (su_wait_create(n->wait, n->s, SU_WAIT_IN)) {
-      su_perror("su_wait_create()");
-      su_close(n->s);
-      break;
-    }
-
-    n->registered = su_root_register(rt->rt_root, n->wait, wakeup_remove, n, 0);
-    if (n->registered < 0) {
-      su_wait_destroy(n->wait);
-      su_close(n->s);
-      break;
-    }
-    
-    n->list = &list, n->prev = &list;
-    if ((n->next = list))
-      n->next->prev = &n->next;
-    list = n;
-  }
-
-  TEST_1(i >= 1);
-
-  N = i;
-
-  /* Wake up socket at a time */
-  n = list; sendto(n->s, "foo", 3, 0, (void *)n->addr, n->addrlen);
-
-  su_root_run(rt->rt_root);
-
-  for (i = 0; i < N; i++) {
-    n = nodes + i;
-    TEST_1(n->prev == NULL);
-    sendto(n->s, "bar", 3, 0, (void *)n->addr, n->addrlen);
-  }
-
-  rt->rt_sockets = N;
-
-  /* Wake up all sockets */
-  su_root_run(rt->rt_root);
-
-  for (i = 0; i < N; i++) {
-    n = nodes + i;
-    su_root_deregister(rt->rt_root, n->registered);
-    TEST_1(su_close(n->s) == 0);
-  }
-
-  free(nodes);
-
-  END();
-}
-
 int fail_init(su_root_t *root, root_test_t *rt)
 {
   rt->rt_fail_init = 1;
@@ -431,49 +293,14 @@
   rt->rt_success_deinit = 1;
 }
 
-void receive_a_reporter(root_test_t *rt, 
-			su_msg_r msg,
-			su_msg_arg_t *arg)
-{
-  rt->rt_recv_reporter = 1;
-}
-
-void receive_recv_report(root_test_t *rt, 
-			 su_msg_r msg,
-			 su_msg_arg_t *arg)
-{
-  rt->rt_reported_reporter = 1;
-}
-
-void send_a_reporter_msg(root_test_t *rt, 
-			 su_msg_r msg,
-			 su_msg_arg_t *arg)
-{
-  su_msg_r m = SU_MSG_R_INIT;
-
-  if (su_msg_create(m,
-		    su_msg_from(msg),
-		    su_msg_to(msg),
-		    receive_a_reporter,
-		    0) == 0 &&
-      su_msg_report(m, receive_recv_report) == 0 &&
-      su_msg_send(m) == 0)
-    rt->rt_sent_reporter = 1;
-}
-
 static int clone_test(root_test_t rt[1])
 {
   BEGIN();
 
-  su_msg_r m = SU_MSG_R_INIT;
-
   rt->rt_fail_init = 0;
   rt->rt_fail_deinit = 0;
   rt->rt_success_init = 0;
   rt->rt_success_deinit = 0;
-  rt->rt_sent_reporter = 0;
-  rt->rt_recv_reporter = 0;
-  rt->rt_reported_reporter = 0;
 
   TEST(su_clone_start(rt->rt_root,
 		      rt->rt_clone,
@@ -491,36 +318,10 @@
   TEST_1(rt->rt_success_init);
   TEST_1(!rt->rt_success_deinit);
 
-  /* Make sure 3-way handshake is done as expected */
-  TEST(su_msg_create(m,
-		     su_clone_task(rt->rt_clone),
-		     su_root_task(rt->rt_root),
-		     send_a_reporter_msg,
-		     0), 0);
-  TEST(su_msg_send(m), 0);
-
   TEST_VOID(su_clone_wait(rt->rt_root, rt->rt_clone));
 
   TEST_1(rt->rt_success_deinit);
-  TEST_1(rt->rt_sent_reporter);
-  TEST_1(rt->rt_recv_reporter);
-  TEST_1(rt->rt_reported_reporter);
-
-  rt->rt_recv_reporter = 0;
-
-  /* Make sure we can handle messages done as expected */
-  TEST(su_msg_create(m,
-		     su_root_task(rt->rt_root),
-		     su_task_null,
-		     receive_a_reporter,
-		     0), 0);
-  TEST(su_msg_send(m), 0);
-  su_root_step(rt->rt_root, 0);
-  TEST_1(rt->rt_recv_reporter);
-
-  rt->rt_success_init = 0;
-  rt->rt_success_deinit = 0;
-
+  
   END();
 }
 
@@ -533,30 +334,10 @@
 
 int main(int argc, char *argv[])
 {
-  root_test_t *rt, rt0[1] = {{{ SU_HOME_INIT(rt0) }}}, rt1[1];
+  root_test_t rt[1] = {{{ SU_HOME_INIT(rt) }}};
   int retval = 0;
   int i;
 
-  struct {
-    su_port_create_f *create;
-    su_clone_start_f *start;
-    char const *preference;
-  } prefer[] =
-      {
-	{ NULL, NULL, "default" },
-#if HAVE_POLL_PORT
-#if HAVE_EPOLL
-	{ su_epoll_port_create, su_epoll_clone_start, "epoll", },
-#endif
-	{ su_poll_port_create, su_poll_clone_start, "poll" },
-#endif
-#if HAVE_SELECT
-	{ su_select_port_create, su_select_clone_start, "select" },
-#endif
-	{ NULL, NULL }
-      };
-
-  rt = rt0;
   rt->rt_family = AF_INET;
 
   for (i = 1; argv[i]; i++) {
@@ -570,23 +351,12 @@
       usage();
   }
 
-  i = 0;
-
-  do {
-    rt = rt1, *rt = *rt0;
-    printf("%s: testing %s implementation\n",
-	   name, prefer[i].preference);
-    su_port_prefer(prefer[i].create, prefer[i].start);
-
-    retval |= init_test(rt);
-    retval |= register_test(rt);
-    retval |= event_test(rt);
-    su_root_threading(rt->rt_root, 1);
-    retval |= clone_test(rt);
-    su_root_threading(rt->rt_root, 0);
-    retval |= clone_test(rt);
-    retval |= deinit_test(rt);
-  } while (prefer[++i].create);
+  retval |= init_test(rt);
+  retval |= register_test(rt);
+  retval |= clone_test(rt);
+  su_root_threading(rt->rt_root, 0);
+  retval |= clone_test(rt);
+  retval |= deinit_test(rt);
 
   return retval;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_timer.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_timer.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/torture_su_timer.c	Sat Feb 17 01:25:21 2007
@@ -39,6 +39,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <signal.h>
 
 #include <assert.h>
 
@@ -90,10 +91,6 @@
   putchar('X'); fflush(stdout);
 }
 
-#if HAVE_SIGNAL
-
-#include <signal.h>
-
 su_msg_r intr_msg = SU_MSG_R_INIT;
 
 static RETSIGTYPE intr_handler(int signum)
@@ -106,8 +103,6 @@
   su_root_break(tester->root);
 }
 
-#endif
-
 void
 end_test(struct tester *tester, su_timer_t *t, struct timing *ti)
 {
@@ -187,7 +182,6 @@
 
   tester->root = root = su_root_create(tester);
 
-#if HAVE_SIGNAL
   su_msg_create(intr_msg,
 		su_root_task(root),
 		su_root_task(root),
@@ -195,10 +189,10 @@
 
   signal(SIGINT, intr_handler);
 #if HAVE_SIGPIPE
+  signal(SIGPIPE, intr_handler);
   signal(SIGQUIT, intr_handler);
   signal(SIGHUP, intr_handler);
 #endif
-#endif
 
   t = su_timer_create(su_root_task(root), interval);
   t1 = su_timer_create(su_root_task(root), 1);
@@ -223,9 +217,7 @@
 
   su_root_run(root);
 
-#if HAVE_SIGNAL
   su_msg_destroy(intr_msg);
-#endif
 
   su_timer_destroy(t);
   su_timer_destroy(t1);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -35,28 +35,20 @@
 			sofia-sip/tport_plugins.h
 
 TLS_SRC =		tport_type_tls.c tport_tls.c tport_tls.h
+
 if HAVE_TLS
 USE_TLS_SRC = 		$(TLS_SRC)
 endif
 
-STUN_SRC =		tport_stub_stun.c tport_type_stun.c
-if HAVE_STUN
-USE_STUN_SRC = 		$(STUN_SRC)
-endif
-
-HTTP_SRC =		tport_type_connect.c
-if HAVE_NTH
-USE_HTTP_SRC = 		$(HTTP_SRC)
-endif
-
 libtport_la_SOURCES = 	tport.c tport_logging.c \
-			tport_stub_sigcomp.c \
+			tport_stub_stun.c tport_stub_sigcomp.c \
 			tport_type_udp.c tport_type_tcp.c tport_type_sctp.c \
+			tport_type_connect.c tport_type_stun.c \
 			tport_internal.h \
-			tport_tag.c tport_tag_ref.c $(USE_HTTP_SRC) $(USE_TLS_SRC) $(USE_STUN_SRC)
+			tport_tag.c tport_tag_ref.c $(USE_TLS_SRC)
 
 # to make sure all files end up in the dist package
-EXTRA_libtport_la_SOURCES = $(TLS_SRC) $(STUN_SRC) $(HTTP_SRC)
+EXTRA_libtport_la_SOURCES = $(TLS_SRC) 
 
 # Disable for now
 EXTRA_libtport_la_SOURCES += tport_sigcomp.c tport_threadpool.c
@@ -86,5 +78,4 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
-
+include ../sofia.am

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 
@@ -81,12 +56,8 @@
 target_triplet = @target@
 bin_PROGRAMS =
 check_PROGRAMS = test_tport$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/tport
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -102,20 +73,16 @@
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libtport_la_LIBADD =
 am__libtport_la_SOURCES_DIST = tport.c tport_logging.c \
-	tport_stub_sigcomp.c tport_type_udp.c tport_type_tcp.c \
-	tport_type_sctp.c tport_internal.h tport_tag.c tport_tag_ref.c \
-	tport_type_connect.c tport_type_tls.c tport_tls.c tport_tls.h \
-	tport_stub_stun.c tport_type_stun.c
-am__objects_1 = tport_type_connect.lo
- at HAVE_NTH_TRUE@am__objects_2 = $(am__objects_1)
-am__objects_3 = tport_type_tls.lo tport_tls.lo
- at HAVE_TLS_TRUE@am__objects_4 = $(am__objects_3)
-am__objects_5 = tport_stub_stun.lo tport_type_stun.lo
- at HAVE_STUN_TRUE@am__objects_6 = $(am__objects_5)
-am_libtport_la_OBJECTS = tport.lo tport_logging.lo \
+	tport_stub_stun.c tport_stub_sigcomp.c tport_type_udp.c \
+	tport_type_tcp.c tport_type_sctp.c tport_type_connect.c \
+	tport_type_stun.c tport_internal.h tport_tag.c tport_tag_ref.c \
+	tport_type_tls.c tport_tls.c tport_tls.h
+am__objects_1 = tport_type_tls.lo tport_tls.lo
+ at HAVE_TLS_TRUE@am__objects_2 = $(am__objects_1)
+am_libtport_la_OBJECTS = tport.lo tport_logging.lo tport_stub_stun.lo \
 	tport_stub_sigcomp.lo tport_type_udp.lo tport_type_tcp.lo \
-	tport_type_sctp.lo tport_tag.lo tport_tag_ref.lo \
-	$(am__objects_2) $(am__objects_4) $(am__objects_6)
+	tport_type_sctp.lo tport_type_connect.lo tport_type_stun.lo \
+	tport_tag.lo tport_tag_ref.lo $(am__objects_2)
 libtport_la_OBJECTS = $(am_libtport_la_OBJECTS)
 am__installdirs = "$(DESTDIR)$(bindir)" \
 	"$(DESTDIR)$(include_sofiadir)"
@@ -155,7 +122,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -202,12 +168,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -251,7 +213,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -328,22 +289,19 @@
 
 TLS_SRC = tport_type_tls.c tport_tls.c tport_tls.h
 @HAVE_TLS_TRUE at USE_TLS_SRC = $(TLS_SRC)
-STUN_SRC = tport_stub_stun.c tport_type_stun.c
- at HAVE_STUN_TRUE@USE_STUN_SRC = $(STUN_SRC)
-HTTP_SRC = tport_type_connect.c
- at HAVE_NTH_TRUE@USE_HTTP_SRC = $(HTTP_SRC)
 libtport_la_SOURCES = tport.c tport_logging.c \
-			tport_stub_sigcomp.c \
+			tport_stub_stun.c tport_stub_sigcomp.c \
 			tport_type_udp.c tport_type_tcp.c tport_type_sctp.c \
+			tport_type_connect.c tport_type_stun.c \
 			tport_internal.h \
-			tport_tag.c tport_tag_ref.c $(USE_HTTP_SRC) $(USE_TLS_SRC) $(USE_STUN_SRC)
+			tport_tag.c tport_tag_ref.c $(USE_TLS_SRC)
 
 
 # to make sure all files end up in the dist package
 
 # Disable for now
-EXTRA_libtport_la_SOURCES = $(TLS_SRC) $(STUN_SRC) $(HTTP_SRC) \
-	tport_sigcomp.c tport_threadpool.c
+EXTRA_libtport_la_SOURCES = $(TLS_SRC) tport_sigcomp.c \
+	tport_threadpool.c
 BUILT_SOURCES = tport_tag_ref.c
 COVERAGE_INPUT = $(libtport_la_SOURCES) $(include_sofia_HEADERS)
 LDADD = libtport.la \
@@ -363,8 +321,7 @@
 EXTRA_DIST = Doxyfile tport.docs \
 			certificates.html agent.pem cafile.pem
 
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -390,14 +347,12 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -671,7 +626,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -824,92 +779,6 @@
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
 
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
 # ----------------------------------------------------------------------
 # Sofia specific rules
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/sofia-sip/tport_tag.h	Sat Feb 17 01:25:21 2007
@@ -389,8 +389,6 @@
  * Use with tport_tcreate(), tport_tbind(), tport_set_params(), nua_create(),
  * nta_agent_create(), nta_agent_add_tport(), nth_engine_create(), or
  * initial nth_site_create().
- *
- * @NEW_1_12_5
  */
 #define TPTAG_TOS(x) tptag_tos, tag_int_v((x))
 
@@ -404,8 +402,6 @@
  * nth_engine_create(), or initial nth_site_create().
  *
  * @sa #TPORT_DUMP, TPTAG_DUMP()
- *
- * @NEW_1_12_5
  */
 #define TPTAG_LOG(x) tptag_log, tag_bool_v((x))
 
@@ -419,8 +415,6 @@
  * nth_engine_create(), or initial nth_site_create().
  *
  * @sa #TPORT_DUMP, TPTAG_LOG().
- *
- * @NEW_1_12_5
  */
 #define TPTAG_DUMP(x) tptag_dump, tag_str_v((x))
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/test_tport.c	Sat Feb 17 01:25:21 2007
@@ -381,7 +381,7 @@
 {
   tt->tt_status = -1;
   fprintf(stderr, "tp_test_error(%p): error %d (%s) from %s\n", 
-	  (void *)tp, errcode, su_strerror(errcode), 
+	  tp, errcode, su_strerror(errcode), 
 	  remote ? remote : "<unknown destination>");
 }
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c	Sat Feb 17 01:25:21 2007
@@ -292,7 +292,7 @@
 }
 
 /** MTU for transport  */
-static inline unsigned tport_mtu(tport_t const *self)
+static inline usize_t tport_mtu(tport_t const *self)
 {
   return self->tp_params->tpp_mtu;
 }
@@ -453,7 +453,7 @@
   if (!mr)
     return NULL;
 
-  SU_DEBUG_7(("%s(): %p\n", "tport_create", (void *)mr));
+  SU_DEBUG_7(("%s(): %p\n", "tport_create", mr));
 
   mr->mr_stack = stack;
   mr->mr_tpac = tpac;
@@ -492,9 +492,7 @@
   if (tick < 200)
     tick = 200;
 
-#if HAVE_SOFIA_STUN
   tport_init_stun_server(mr, ta_args(ta));
-#endif
 
   mr->mr_timer = su_timer_create(su_root_task(root), tick);
   su_timer_set(mr->mr_timer, tport_tick, mr);
@@ -518,7 +516,7 @@
 	/* tpac_address */ NULL
       }};
 
-  SU_DEBUG_7(("%s(%p)\n", __func__, (void *)self));
+  SU_DEBUG_7(("%s(%p)\n", __func__, self));
 
   if (self == NULL)
     return;
@@ -533,9 +531,7 @@
   while (mr->mr_primaries)
     tport_zap_primary(mr->mr_primaries);
 
-#if HAVE_SOFIA_STUN
   tport_deinit_stun_server(mr);
-#endif
 
   if (mr->mr_dump_file)
     fclose(mr->mr_dump_file), mr->mr_dump_file = NULL;
@@ -583,8 +579,7 @@
     if (!pri->pri_public)
       tp->tp_addrinfo->ai_addr = &tp->tp_addr->su_sa;
 
-    SU_DEBUG_5(("%s(%p): new primary tport %p\n", __func__, (void *)mr,
-		(void *)pri));
+    SU_DEBUG_5(("%s(%p): new primary tport %p\n", __func__, mr, pri));
   }
 
   *next = pri; 
@@ -711,7 +706,7 @@
   pri->pri_primary->tp_has_connection = 0;
 
   SU_DEBUG_5(("%s(%p): %s " TPN_FORMAT "\n", 
-			  __func__, (void *)pri, "listening at",
+	      __func__, pri, "listening at",
 	      TPN_ARGS(pri->pri_primary->tp_name)));
 
   return pri;
@@ -783,8 +778,8 @@
 
   if (self->tp_pri->pri_vtable->vtp_set_events)
     return self->tp_pri->pri_vtable->vtp_set_events(self);
-  
-  SU_DEBUG_7(("tport_set_events(%p): events%s%s%s\n", (void *)self,
+
+  SU_DEBUG_7(("tport_set_events(%p): events%s%s%s\n", self,
 	      (events & SU_WAIT_IN) ? " IN" : "",
 	      (events & SU_WAIT_OUT) ? " OUT" : "",
 	      SU_WAIT_CONNECT != SU_WAIT_OUT &&
@@ -823,7 +818,7 @@
   self = su_home_clone(mr->mr_home, pri->pri_vtable->vtp_secondary_size);
 
   if (self) {
-	  SU_DEBUG_7(("%s(%p): new secondary tport %p\n", __func__, (void *)pri, (void *)self));
+    SU_DEBUG_7(("%s(%p): new secondary tport %p\n", __func__, pri, self));
 
     self->tp_refs = -1;			/* Freshly allocated  */
     self->tp_master = mr;
@@ -922,8 +917,8 @@
 	    su_wait_destroy(wait),				     \
 	    (SU_LOG_LEVEL >= errlevel ?				     \
 	     su_llog(tport_log, errlevel,			     \
-		     "%s(%p): %s(pf=%d %s/%s): %s\n",			\
-				 __func__, (void *)pri, #what, ai->ai_family,	\
+		     "%s(%p): %s(pf=%d %s/%s): %s\n",		     \
+		     __func__, pri, #what, ai->ai_family,	     \
 		     tpn->tpn_proto,				     \
 		     tport_hostport(buf, sizeof(buf),		     \
 				    (void *)ai->ai_addr, 2),	     \
@@ -988,11 +983,11 @@
 
   if (ai == real_ai) {
     SU_DEBUG_5(("%s(%p): %s to " TPN_FORMAT "\n", 
-				__func__, (void *)self, what, TPN_ARGS(self->tp_name)));
+		__func__, self, what, TPN_ARGS(self->tp_name)));
   }
   else {
     SU_DEBUG_5(("%s(%p): %s via %s to " TPN_FORMAT "\n",
-				__func__, (void *)self, what,
+		__func__, self, what,
 		tport_hostport(buf, sizeof(buf), (void *)ai->ai_addr, 2),
 		TPN_ARGS(self->tp_name)));
   }
@@ -1021,7 +1016,7 @@
   if (self->tp_msg) {
     msg_destroy(self->tp_msg), self->tp_msg = NULL;
     SU_DEBUG_3(("%s(%p): zapped partially received message\n", 
-				__func__, (void *)self));
+		__func__, self));
   }
 
   if (self->tp_queue && self->tp_queue[self->tp_qhead]) {
@@ -1031,18 +1026,16 @@
       n++;
     }
     SU_DEBUG_3(("%s(%p): zapped %lu queued messages\n", 
-				__func__, (void *)self, (LU)n));
+		__func__, self, (LU)n));
   }
 
   if (self->tp_pused) {
-	  SU_DEBUG_3(("%s(%p): zapped with pending requests\n", __func__, (void *)self));
+    SU_DEBUG_3(("%s(%p): zapped with pending requests\n", __func__, self));
   }
 
   mr = self->tp_master;
 
-#if HAVE_SOFIA_STUN
   tport_stun_server_remove_socket(self);
-#endif
 
   if (self->tp_index)
     su_root_deregister(mr->mr_root, self->tp_index);
@@ -1117,7 +1110,7 @@
     || !tport_is_primary(self) || !tport_is_dgram(self);
 
   n = tl_tgets(ta_args(ta),
-	       TPTAG_MTU((usize_t)tpp->tpp_mtu),
+	       TPTAG_MTU(tpp->tpp_mtu),
 	       TPTAG_REUSE(self->tp_reusable),
 	       TPTAG_CONNECT(connect),
 	       TPTAG_QUEUESIZE(tpp->tpp_qsize),
@@ -1153,16 +1146,14 @@
   ta_list ta;
   int n;
   tport_params_t tpp[1], *tpp0;
-  
-  usize_t mtu;
+
   int connect, sdwn_error, reusable, stun_server;
-  
+
   if (self == NULL)
     return su_seterrno(EINVAL);
 
   memcpy(tpp, tpp0 = self->tp_params, sizeof *tpp);
 
-  mtu = tpp->tpp_mtu;
   connect = tpp->tpp_conn_orient;
   sdwn_error = tpp->tpp_sdwn_error;
   reusable = self->tp_reusable;
@@ -1171,7 +1162,7 @@
   ta_start(ta, tag, value);
 
   n = tl_gets(ta_args(ta),
-	      TPTAG_MTU_REF(mtu),
+	      TPTAG_MTU_REF(tpp->tpp_mtu),
 	      TAG_IF(!self->tp_queue, TPTAG_QUEUESIZE_REF(tpp->tpp_qsize)),
 	      TPTAG_IDLE_REF(tpp->tpp_idle),
 	      TPTAG_TIMEOUT_REF(tpp->tpp_timeout),
@@ -1204,9 +1195,6 @@
   if (tpp->tpp_qsize >= 1000)
     tpp->tpp_qsize = 1000;
 
-  if (mtu > UINT_MAX)
-    mtu = UINT_MAX;
-  tpp->tpp_mtu = (unsigned)mtu;
   /* Currently only primary UDP transport can *not* be connection oriented */ 
   tpp->tpp_conn_orient = connect; 
   tpp->tpp_sdwn_error = sdwn_error;
@@ -1238,9 +1226,7 @@
 
 tport_vtable_t const *tport_vtables[TPORT_NUMBER_OF_TYPES + 1] =
 {
-#if HAVE_SOFIA_NTH
   &tport_http_connect_vtable,
-#endif
 #if HAVE_TLS
   &tport_tls_client_vtable,
   &tport_tls_vtable,
@@ -1308,9 +1294,7 @@
     tport_server_bind_set,
     tport_client_bind_set,
     tport_threadpool_set,
-#if HAVE_SOFIA_NTH
     tport_http_connect_set,
-#endif
 #if HAVE_TLS
     tport_tls_set,
 #endif
@@ -1422,8 +1406,8 @@
 
   if (public == tport_type_local)
     public = tport_type_client;
-  
-  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, (void *)mr, TPN_ARGS(tpn)));
+
+  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, mr, TPN_ARGS(tpn)));
 
   memset(tpn0, 0, sizeof(tpn0));
 
@@ -1482,8 +1466,8 @@
   unsigned short step = 0;
 
   bind6only_check(mr);
-  
-  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, (void *)mr, TPN_ARGS(tpn)));
+
+  SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n", __func__, mr, TPN_ARGS(tpn)));
 
   if (tpn->tpn_host == NULL || strcmp(tpn->tpn_host, tpn_any) == 0) {
     /* Use a local IP address */
@@ -1551,7 +1535,7 @@
       tpname->tpn_host = host;
 
       SU_DEBUG_9(("%s(%p): calling tport_listen for %s\n", 
-		  __func__, (void *)mr, ai->ai_canonname));
+		  __func__, mr, ai->ai_canonname));
 
       pri = tport_listen(mr, vtable, tpname, ainfo, tags);
       if (!pri) {
@@ -1598,7 +1582,7 @@
       break;
 
     SU_DEBUG_3(("%s(%p): cannot bind all transports to port %u, trying %u\n", 
-				__func__, (void *)mr, old, port));
+		__func__, mr, old, port));
   }
 
   tport_freeaddrinfo(res);
@@ -1703,7 +1687,7 @@
     int error = tport_getaddrinfo(host, service, hints, return_addrinfo);
     if (error || !*return_addrinfo) {
       SU_DEBUG_3(("%s(%p): su_getaddrinfo(%s, %s) for %s: %s\n", 
-				  __func__, (void *)mr, host ? host : "\"\"", service, protocol,
+		  __func__, mr, host ? host : "\"\"", service, protocol,
 		  su_gai_strerror(error)));
       return su_seterrno(error != EAI_MEMORY ? ENOENT : ENOMEM);
     }
@@ -1754,13 +1738,13 @@
   if (error) {
 #if SU_HAVE_IN6
     SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n", 
-				__func__, (void *)mr, 
+		__func__, mr, 
 		family == AF_INET6 ? "ip6" 
 		: family == AF_INET ? "ip4" : "ip",
 		su_gli_strerror(error)));
 #else
     SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n", 
-				__func__, (void *)mr, 
+		__func__, mr, 
 		family == AF_INET ? "ip4" : "ip",
 		su_gli_strerror(error)));
 #endif
@@ -1957,7 +1941,7 @@
  */
 void tport_close(tport_t *self)
 {
-	SU_DEBUG_5(("%s(%p): " TPN_FORMAT "\n", "tport_close", (void *)self,
+  SU_DEBUG_5(("%s(%p): " TPN_FORMAT "\n", "tport_close", self,
 	      TPN_ARGS(self->tp_name)));
 
   self->tp_closed = 1;
@@ -2006,8 +1990,8 @@
 {
   if (!tport_is_secondary(self))
     return -1;
-  
-  SU_DEBUG_7(("%s(%p, %d)\n", "tport_shutdown", (void *)self, how));
+
+  SU_DEBUG_7(("%s(%p, %d)\n", "tport_shutdown", self, how));
 
   if (!tport_is_tcp(self) ||
       how < 0 || 
@@ -2073,7 +2057,7 @@
 	tp_next = tprb_succ(tp);
 	if (tp->tp_queue && tp->tp_queue[tp->tp_qhead]) {
 	  SU_DEBUG_9(("tport_tick(%p) - trying to send to %s/%s:%s\n", 
-				  (void *)tp, tp->tp_protoname, tp->tp_host, tp->tp_port));
+		      tp, tp->tp_protoname, tp->tp_host, tp->tp_port));
 	  tport_send_queue(tp);
 	}
       }      
@@ -2089,7 +2073,7 @@
 	  (int)tp->tp_params->tpp_timeout < ts - (int)tp->tp_time &&
 	  !msg_is_streaming(msg)) {
 	SU_DEBUG_5(("tport_tick(%p): incomplete message idle for %d ms\n",
-				(void *)tp, ts - (int)tp->tp_time));
+		    tp, ts - (int)tp->tp_time));
 	msg_set_streaming(msg, 0);
 	msg_set_flags(msg, MSG_FLG_ERROR | MSG_FLG_TRUNC | MSG_FLG_TIMEOUT);
 	tport_deliver(tp, msg, NULL, NULL, now);
@@ -2110,10 +2094,10 @@
       }
 
       if (closed) {
-		  SU_DEBUG_5(("tport_tick(%p): closed, zapping\n", (void *)tp));
+	SU_DEBUG_5(("tport_tick(%p): closed, zapping\n", tp));
       } else {
 	SU_DEBUG_5(("tport_tick(%p): unused for %d ms, closing and zapping\n",
-				(void *)tp, ts - (int)tp->tp_time));
+		    tp, ts - (int)tp->tp_time));
 	if (!tport_is_closed(tp))
 	  tport_close(tp);
       }
@@ -2141,7 +2125,7 @@
       continue;
 
     SU_DEBUG_1(("tport_flush(%p): %szapping\n",
-				(void *)tp, tport_is_closed(tp) ? "" : "closing and "));
+		tp, tport_is_closed(tp) ? "" : "closing and "));
     if (!tport_is_closed(tp))
       tport_close(tp);
     tport_zap_secondary(tp);
@@ -2380,10 +2364,10 @@
   }
   else {
     if (tport_is_primary(self))
-		SU_DEBUG_3(("%s(%p): %s (with %s)\n", __func__, (void *)self, 
+      SU_DEBUG_3(("%s(%p): %s (with %s)\n", __func__, self, 
 		  errmsg, self->tp_protoname));
     else
-		SU_DEBUG_3(("%s(%p): %s (with %s/%s:%s)\n", __func__, (void *)self, 
+      SU_DEBUG_3(("%s(%p): %s (with %s/%s:%s)\n", __func__, self, 
 		  errmsg, self->tp_protoname, self->tp_host, self->tp_port));
   }
 
@@ -2449,7 +2433,7 @@
 
       if (tport_setname(self, pri->pri_protoname, ai, NULL) != -1) {
 	SU_DEBUG_5(("%s(%p): new connection from " TPN_FORMAT "\n", 
-				__func__,  (void *)self, TPN_ARGS(self->tp_name)));
+		    __func__,  self, TPN_ARGS(self->tp_name)));
 
 	tprb_append(&pri->pri_secondary, self);
 
@@ -2502,8 +2486,8 @@
   su_wait_t wait[1] =  { SU_WAIT_INIT };
 
   int error;
-  
-  SU_DEBUG_7(("tport_connected(%p): events%s%s\n", (void *)self,
+
+  SU_DEBUG_7(("tport_connected(%p): events%s%s\n", self,
 	      events & SU_WAIT_CONNECT ? " CONNECTED" : "",
 	      events & SU_WAIT_ERR ? " ERR" : ""));
 
@@ -2528,7 +2512,7 @@
 
   su_root_deregister(mr->mr_root, self->tp_index);
   self->tp_index = -1;
-  self->tp_events = SU_WAIT_IN | SU_WAIT_ERR | SU_WAIT_HUP;
+  self->tp_events = SU_WAIT_IN | SU_WAIT_ERR;
   if (su_wait_create(wait, self->tp_socket, self->tp_events) == -1 ||
       (self->tp_index = su_root_register(mr->mr_root, 
 					 wait, tport_wakeup, self, 0))
@@ -2553,7 +2537,7 @@
 #endif
 
   SU_DEBUG_7(("%s(%p): events%s%s%s%s%s%s\n", 
-			  "tport_wakeup_pri", (void *)self,
+	      "tport_wakeup_pri", self,
 	      events & SU_WAIT_IN ? " IN" : "",
 	      SU_WAIT_ACCEPT != SU_WAIT_IN && 
 	      (events & SU_WAIT_ACCEPT) ? " ACCEPT" : "",
@@ -2579,7 +2563,7 @@
 #endif
 
   SU_DEBUG_7(("%s(%p): events%s%s%s%s%s\n", 
-			  "tport_wakeup", (void *)self,
+	      "tport_wakeup", self,
 	      events & SU_WAIT_IN ? " IN" : "",
 	      events & SU_WAIT_OUT ? " OUT" : "",
 	      events & SU_WAIT_HUP ? " HUP" : "",
@@ -2633,7 +2617,7 @@
  */
 void tport_hup_event(tport_t *self)
 {
-	SU_DEBUG_7(("%s(%p)\n", __func__, (void *)self));
+  SU_DEBUG_7(("%s(%p)\n", __func__, self));
 
   if (self->tp_msg) {
     su_time_t now = su_now();
@@ -2666,8 +2650,8 @@
 {
   su_time_t now;
   int again;
-  
-  SU_DEBUG_7(("%s(%p)\n", "tport_recv_event", (void *)self));
+
+  SU_DEBUG_7(("%s(%p)\n", "tport_recv_event", self));
 
   do {
     now = su_now(); 
@@ -2677,10 +2661,8 @@
 
     self->tp_time = su_time_ms(now);
 
-#if HAVE_SOFIA_STUN
     if (again == 3) /* STUN keepalive */
       return;
-#endif
 
     if (again < 0) {
       int error = su_errno();
@@ -2736,7 +2718,7 @@
 
     if (msg_get_flags(msg, MSG_FLG_TOOLARGE))
       SU_DEBUG_3(("%s(%p): too large message from " TPN_FORMAT "\n",
-				  __func__, (void *)self, TPN_ARGS(self->tp_name)));
+		  __func__, self, TPN_ARGS(self->tp_name)));
 
     /* Do not try to read anymore from this connection? */
     if (tport_is_stream(self) && 
@@ -2824,9 +2806,9 @@
 
   SU_DEBUG_7(("%s(%p): %smsg %p ("MOD_ZU" bytes)"
 	      " from " TPN_FORMAT " next=%p\n", 
-	      __func__, (void *)self, error ? "bad " : "",
-	      (void *)msg, (size_t)msg_size(msg),
-	      TPN_ARGS(d->d_from), (void *)next));
+	      __func__, self, error ? "bad " : "",
+	      msg, (size_t)msg_size(msg),
+	      TPN_ARGS(d->d_from), next));
 
   ref = tport_incref(self);
 
@@ -2913,7 +2895,7 @@
     if (!(*in_out_msg = msg = tport_msg_alloc(self, N))) {
       SU_DEBUG_7(("%s(%p): cannot allocate msg for "MOD_ZU" bytes "
 		  "from (%s/%s:%s)\n", 
-				  __func__, (void *)self, N, 
+		  __func__, self, N, 
 		  self->tp_protoname, self->tp_host, self->tp_port));
       return -1;
     }
@@ -2932,7 +2914,7 @@
     int err = su_errno();
     SU_DEBUG_7(("%s(%p): cannot get msg %p buffer for "MOD_ZU" bytes "
 		"from (%s/%s:%s): %s\n", 
-				__func__, (void *)self, (void *)msg, N, 
+		__func__, self, msg, N, 
 		self->tp_protoname, self->tp_host, self->tp_port,
 		su_strerror(err)));
     su_seterrno(err);
@@ -2943,8 +2925,8 @@
 
   SU_DEBUG_7(("%s(%p) msg %p from (%s/%s:%s) has "MOD_ZU" bytes, "
 	      "veclen = "MOD_ZD"\n",
-              __func__, (void *)self, 
-			  (void *)msg, self->tp_protoname, self->tp_host, self->tp_port, 
+              __func__, self, 
+	      msg, self->tp_protoname, self->tp_host, self->tp_port, 
 	      N, veclen));
 
   for (i = 0; veclen > 1 && i < veclen; i++) {
@@ -2995,9 +2977,8 @@
   }
 
   *tpn = *_tpn;
-  
-  SU_DEBUG_7(("tport_tsend(%p) tpn = " TPN_FORMAT "\n",
-	      (void *)self, TPN_ARGS(tpn)));
+
+  SU_DEBUG_7(("tport_tsend(%p) tpn = " TPN_FORMAT "\n", self, TPN_ARGS(tpn)));
 
   if (tport_is_master(self)) {
     primary = (tport_primary_t *)tport_primary_by_name(self, tpn);
@@ -3049,7 +3030,7 @@
   if (tpn->tpn_comp) {
     ai->ai_flags |= TP_AI_COMPRESSED;
     SU_DEBUG_9(("%s: compressed msg(%p) with %s\n", 
-				__func__, (void *)msg, tpn->tpn_comp));
+		__func__, msg, tpn->tpn_comp));
   } 
 
   if (!tpn->tpn_comp || cc == NONE)
@@ -3159,7 +3140,7 @@
     return -1;
   }
 
-  if (msg_size(msg) > (usize_t)(mtu ? mtu : tport_mtu(self))) {
+  if (msg_size(msg) > (mtu ? mtu : tport_mtu(self))) {
     msg_set_errno(msg, EMSGSIZE);
     return -1;
   }
@@ -3255,9 +3236,9 @@
       }
       else {
 	char const *comp = tpn->tpn_comp;
-	
+
 	SU_DEBUG_1(("tport(%p): send truncated for %s/%s:%s%s%s\n", 
-				(void *)self, tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port,
+		    self, tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port,
 		    comp ? ";comp=" : "", comp ? comp : ""));
 
 	su_seterrno(EIO);
@@ -3321,9 +3302,9 @@
 
     if (tpn == NULL || tport_is_connection_oriented(self))
       tpn = self->tp_name;
-    
+
     SU_DEBUG_7(("tport_vsend(%p): "MOD_ZU" bytes of "MOD_ZU" to %s/%s:%s%s\n", 
-				(void *)self, n, m, tpn->tpn_proto, tpn->tpn_host, 
+		self, n, m, tpn->tpn_proto, tpn->tpn_host, 
 		tpn->tpn_port, 
 		(ai->ai_flags & TP_AI_COMPRESSED) ? ";comp=sigcomp" : ""));
   }
@@ -3345,7 +3326,7 @@
 
   if (su_is_blocking(error)) {
     SU_DEBUG_5(("tport_vsend(%p): %s with (s=%d %s/%s:%s%s)\n", 
-				(void *)self, "EAGAIN", (int)self->tp_socket, 
+		self, "EAGAIN", (int)self->tp_socket, 
 		tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port, comp));
     return 0;
   }
@@ -3354,7 +3335,7 @@
 
   if (self->tp_addrinfo->ai_family == AF_INET) {
     SU_DEBUG_3(("tport_vsend(%p): %s with (s=%d %s/%s:%s%s)\n", 
-				(void *)self, su_strerror(error), (int)self->tp_socket, 
+		self, su_strerror(error), (int)self->tp_socket, 
 		tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port, comp));
   }
 #if SU_HAVE_IN6
@@ -3362,7 +3343,7 @@
     su_sockaddr_t const *su = (su_sockaddr_t const *)ai->ai_addr;
     SU_DEBUG_3(("tport_vsend(%p): %s with "
 		"(s=%d, IP6=%s/%s:%s%s (scope=%i) addrlen=%u)\n", 
-				(void *)self, su_strerror(error), (int)self->tp_socket, 
+		self, su_strerror(error), (int)self->tp_socket, 
 		tpn->tpn_proto, tpn->tpn_host, tpn->tpn_port, comp,
 		su->su_scope_id, (unsigned)ai->ai_addrlen));
   }
@@ -3370,7 +3351,7 @@
   else {
     SU_DEBUG_3(("\ttport_vsend(%p): %s with "
 		"(s=%d, AF=%u addrlen=%u)%s\n", 
-				(void *)self, su_strerror(error), 
+		self, su_strerror(error), 
 		(int)self->tp_socket, ai->ai_family, (unsigned)ai->ai_addrlen, comp));
   }
 
@@ -3378,7 +3359,7 @@
   int i;
   for (i = 0; i < iovused; i++)
     SU_DEBUG_7(("\t\tiov[%d] = { %d bytes @ %p }\n", 
-		i, iov[i].siv_len, (void *)iov[i].siv_base));
+		i, iov[i].siv_len, iov[i].siv_base));
 #endif
 
   if (tport_is_connection_oriented(self)) {
@@ -3499,9 +3480,9 @@
 {
   unsigned short qhead = self->tp_qhead;
   unsigned short N = self->tp_params->tpp_qsize;
-  
+
   SU_DEBUG_7(("tport_queue(%p): queueing %p for %s/%s:%s\n", 
-			  (void *)self, (void *)msg, self->tp_protoname, self->tp_host, self->tp_port));
+	      self, msg, self->tp_protoname, self->tp_host, self->tp_port));
 
   if (self->tp_queue == NULL) {
     assert(N > 0);
@@ -3637,9 +3618,9 @@
 void tport_send_event(tport_t *self)
 {
   assert(tport_is_connection_oriented(self));
-  
+
   SU_DEBUG_7(("tport_send_event(%p) - ready to send to (%s/%s:%s)\n", 
-			  (void *)self, self->tp_protoname, self->tp_host, self->tp_port));
+	      self, self->tp_protoname, self->tp_host, self->tp_port));
   tport_send_queue(self);
 }
 
@@ -3866,9 +3847,9 @@
 
   if (self == NULL || msg == NULL || callback == NULL || client == NULL)
     return -1;
-  
+
   SU_DEBUG_7(("tport_pend(%p): pending %p for %s/%s:%s (already %u)\n", 
-			  (void *)self, (void *)msg, 
+	      self, msg, 
 	      self->tp_protoname, self->tp_host, self->tp_port,
 	      self->tp_pused));
 
@@ -3923,13 +3904,13 @@
 
   if (pending->p_client != client || 
       pending->p_msg != msg) {
-	  SU_DEBUG_1(("tport_release(%p): %u %p by %p not pending\n", (void *)self, 
-				  pendd, (void *)msg, (void *)client));
+    SU_DEBUG_1(("tport_release(%p): %u %p by %p not pending\n", self, 
+		pendd, msg, client));
     return su_seterrno(EINVAL), -1;
   }
-  
+
   SU_DEBUG_7(("tport_release(%p): %p by %p with %p%s\n", 
-			  (void *)self, (void *)msg, (void *)client, (void *)reply,
+	      self, msg, client, reply,
 	      still_pending ? " (preliminary)" : ""));
 
   /* sigcomp can here associate request (msg) with response (reply) */
@@ -4268,7 +4249,7 @@
     }
     else {
       SU_DEBUG_7(("tport(%p): EXPENSIVE unresolved " TPN_FORMAT "\n",
-				  (void *)self, TPN_ARGS(tpn)));
+		  self, TPN_ARGS(tpn)));
 
       sub = tprb_first(sub);
     }
@@ -4288,11 +4269,11 @@
 	if ((socklen_t)sub->tp_addrlen != sulen ||
 	    memcmp(sub->tp_addr, su, sulen)) {
 	  SU_DEBUG_7(("tport(%p): not found by name " TPN_FORMAT "\n",
-				  (void *)self, TPN_ARGS(tpn)));
+		      self, TPN_ARGS(tpn)));
 	  break;
 	}
 	SU_DEBUG_7(("tport(%p): found %p by name " TPN_FORMAT "\n",
-				(void *)self, (void *)sub, TPN_ARGS(tpn)));
+		    self, sub, TPN_ARGS(tpn)));
       }
       else if ((strcasecmp(canon, sub->tp_canon) &&
 		strcasecmp(host, sub->tp_host)) ||
@@ -4373,10 +4354,10 @@
 
   if (sub)
     SU_DEBUG_7(("%s(%p): found %p by name " TPN_FORMAT "\n",
-				__func__, (void *)pri, (void *)sub, TPN_ARGS(tpn)));
+		__func__, pri, sub, TPN_ARGS(tpn)));
   else
     SU_DEBUG_7(("%s(%p): not found by name " TPN_FORMAT "\n",
-				__func__, (void *)pri, TPN_ARGS(tpn)));
+		__func__, pri, TPN_ARGS(tpn)));
 
   return (tport_t *)sub;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h	Sat Feb 17 01:25:21 2007
@@ -91,7 +91,7 @@
 
 /** Transport parameters */
 typedef struct {
-  unsigned tpp_mtu;		/**< Maximum packet size */
+  usize_t  tpp_mtu;		/**< Maximum packet size */
   unsigned tpp_idle;		/**< Allowed connection idle time. */
   unsigned tpp_timeout;		/**< Allowed idle time for message. */
   unsigned tpp_sigcomp_lifetime;  /**< SigComp compartment lifetime  */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_stub_stun.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_stub_stun.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_stub_stun.c	Sat Feb 17 01:25:21 2007
@@ -155,7 +155,7 @@
     }
     else
       SU_DEBUG_7(("tport(%p): recv_stun_dgram(): "
-		  "ignoring request with "MOD_ZU" bytes\n", (void *)self, n));
+		  "ignoring request with "MOD_ZU" bytes\n", self, n));
   }
   else if (request[0] == 0 && self->tp_master->mr_stun_server) {
     tport_stun_server_vtable_t const *vst = tport_stun_server_vtable;
@@ -178,7 +178,7 @@
     elen = (elen + 3) & -4;	/* Round up to 4 */
 
     SU_DEBUG_7(("tport(%p): recv_stun_dgram(): "
-		"responding %u %s\n", (void *)self, status, error));
+		"responding %u %s\n", self, status, error));
   /*
      0                   1                   2                   3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -237,7 +237,7 @@
 #undef set16
   }
   else {
-    SU_DEBUG_0(("tport(%p): recv_stun_dgram(): internal error\n", (void *)self));
+    SU_DEBUG_0(("tport(%p): recv_stun_dgram(): internal error\n", self));
     su_seterrno(EBADMSG);
     retval = -1;
   }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c	Sat Feb 17 01:25:21 2007
@@ -55,10 +55,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#if HAVE_SIGPIPE
 #include <signal.h>
-#endif
 
 #include "tport_tls.h"
 
@@ -165,10 +162,8 @@
     }
   }
 
-#if HAVE_SIGPIPE
   /* Avoid possible SIGPIPE when sending close_notify */
   signal(SIGPIPE, SIG_IGN);
-#endif
 
   if (tls->bio_err == NULL)
     tls->bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
@@ -300,9 +295,7 @@
   unsigned char sessionId[32] = "sofia/tls"; 
   tls_t *tls;
 
-#if HAVE_SIGPIPE
   signal(SIGPIPE, SIG_IGN);  /* Ignore spurios SIGPIPE from OpenSSL */
-#endif
 
   tls_set_default(ti);
 
@@ -618,7 +611,7 @@
   }
 
   if (0)
-    fprintf(stderr, "tls_read(%p) called on %s (events %u)\n", (void *)tls,
+    fprintf(stderr, "tls_read(%p) called on %s (events %u)\n", tls,
 	    tls->type == tls_slave ? "server" : "client",
 	    tls->read_events);
 
@@ -681,7 +674,7 @@
 
   if (0) 
     fprintf(stderr, "tls_write(%p, %p, "MOD_ZU") called on %s\n", 
-	    (void *)tls, buf, size,
+	    tls, buf, size,
 	    tls && tls->type == tls_slave ? "server" : "client");
 
   if (tls == NULL || buf == NULL) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_sctp.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_sctp.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_sctp.c	Sat Feb 17 01:25:21 2007
@@ -37,6 +37,8 @@
 
 #include "config.h"
 
+#if HAVE_SCTP
+
 #include "tport_internal.h"
 
 #if HAVE_NETINET_SCTP_H
@@ -74,8 +76,6 @@
 
 #define TP_SCTP_MSG_MAX (65536)
 
-#if HAVE_SCTP
-
 static int tport_sctp_init_primary(tport_primary_t *, 
 				   tp_name_t tpn[1], 
 				   su_addrinfo_t *, tagi_t const *,

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c	Sat Feb 17 01:25:21 2007
@@ -230,7 +230,7 @@
   }
   if (N == -1) {
     err = su_errno();
-    SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, (void *)self,
+    SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, self,
 		su_strerror(err), err));
     return -1;
   }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tls.c	Sat Feb 17 01:25:21 2007
@@ -187,7 +187,7 @@
     ti.CAfile = su_sprintf(autohome, "%s/%s", path, "cafile.pem");
     ti.version = tls_version;
 
-    SU_DEBUG_9(("%s(%p): tls key = %s\n", __func__, (void *)pri, ti.key));
+    SU_DEBUG_9(("%s(%p): tls key = %s\n", __func__, pri, ti.key));
 
     if (ti.key && ti.CAfile && ti.randFile) {
       tlspri->tlspri_master = tls_init_master(&ti);
@@ -271,7 +271,7 @@
   int mask = tls_events(tlstp->tlstp_context, self->tp_events);
 
   SU_DEBUG_7(("%s(%p): logical events%s%s real%s%s\n",
-	      "tport_tls_set_events", (void *)self, 
+	      "tport_tls_set_events", self, 
 	      (self->tp_events & SU_WAIT_IN) ? " IN" : "",
 	      (self->tp_events & SU_WAIT_OUT) ? " OUT" : "",
 	      (mask & SU_WAIT_IN) ? " IN" : "",
@@ -325,7 +325,7 @@
     return 0;
 
   SU_DEBUG_7(("%s(%p): logical events%s%s real%s%s\n",
-	      "tport_tls_events", (void *)self, 
+	      "tport_tls_events", self, 
 	      (events & SU_WAIT_IN) ? " IN" : "",
 	      (events & SU_WAIT_OUT) ? " OUT" : "",
 	      (mask & SU_WAIT_IN) ? " IN" : "",
@@ -358,7 +358,7 @@
 
   N = tls_read(tlstp->tlstp_context);
 
-  SU_DEBUG_7(("%s(%p): tls_read() returned "MOD_ZD"\n", __func__, (void *)self, N));
+  SU_DEBUG_7(("%s(%p): tls_read() returned "MOD_ZD"\n", __func__, self, N));
 
   if (N == 0) /* End-of-stream */
     return 0;
@@ -462,7 +462,7 @@
 #endif
 
     SU_DEBUG_9(("tport_tls_writevec: vec %p %p %lu ("MOD_ZD")\n",  
-		(void *)tlstp->tlstp_context, (void *)iov[i].siv_base, (LU)iov[i].siv_len, 
+		tlstp->tlstp_context, iov[i].siv_base, (LU)iov[i].siv_len, 
 		nerror));
 
     if (nerror == -1) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c	Sat Feb 17 01:25:21 2007
@@ -166,9 +166,7 @@
 
   tport_check_trunc(pri->pri_primary, ai);
 
-#if HAVE_SOFIA_STUN
   tport_stun_server_add_socket(pri->pri_primary);
-#endif
 
   return 0;
 }
@@ -235,7 +233,7 @@
   if (self->tp_params->tpp_drop && 
       (unsigned)su_randint(0, 1000) < self->tp_params->tpp_drop) {
     su_recv(self->tp_socket, sample, 1, 0);
-    SU_DEBUG_3(("tport(%p): simulated packet loss!\n", (void *)self));
+    SU_DEBUG_3(("tport(%p): simulated packet loss!\n", self));
     return 0;
   }
 
@@ -248,7 +246,7 @@
   N = (ssize_t)su_getmsgsize(self->tp_socket);
   if (N == -1) {
     int err = su_errno();
-    SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, (void *)self,
+    SU_DEBUG_1(("%s(%p): su_getmsgsize(): %s (%d)\n", __func__, self,
 		su_strerror(err), err));
     return -1;
   }
@@ -278,8 +276,7 @@
       return -1;
   }
   else if (n <= 1) {
-    SU_DEBUG_1(("%s(%p): runt of "MOD_ZD" bytes\n",
-		"tport_recv_dgram", (void *)self, n));
+    SU_DEBUG_1(("%s(%p): runt of "MOD_ZD" bytes\n", "tport_recv_dgram", self, n));
     msg_destroy(msg), self->tp_msg = NULL;
     return 0;
   }
@@ -298,11 +295,9 @@
     /* SigComp */
     return tport_recv_comp_dgram(self, self->tp_comp, &self->tp_msg, 
 				 from, fromlen);
-#if HAVE_SOFIA_STUN
   else if (sample[0] == 0 || sample[0] == 1)
     /* STUN request or response */
     return tport_recv_stun_dgram(self, &self->tp_msg, from, fromlen);
-#endif
   else
     return 0;
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -52,6 +52,6 @@
 # ----------------------------------------------------------------------
 # Sofia specific rules
 
-include $(top_srcdir)/rules/sofia.am
+include ../sofia.am
 
 TAG_DLL_FLAGS = 	DLLREF=1

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -24,33 +24,8 @@
 # ----------------------------------------------------------------------
 # Header paths
 
-# common Makefile targets for libsofia-sip-ua(-glib) modules
-# ----------------------------------------------------------
-
-# 
-# run tests with valgrind
-#
-
-# Copyright (C) 2007 Nokia Corporation.
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-
-# This file contains free software from Makefile.in by the Free Software
-# Foundation:
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
+# common Makefile targets for libsofia-sip-ua modules
+# ---------------------------------------------------
 
 
 SOURCES = $(liburl_la_SOURCES) $(test_urlmap_SOURCES) torture_url.c
@@ -79,12 +54,8 @@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = torture_url$(EXEEXT) test_urlmap$(EXEEXT)
-DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(top_srcdir)/rules/sofia.am \
-	$(top_srcdir)/rules/valcheck.am ChangeLog
-
-# Use with --enable-ndebug
- at NDEBUG_TRUE@am__append_1 = -DNDEBUG
+DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
 subdir = libsofia-sip-ua/url
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
@@ -136,7 +107,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -183,12 +153,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -232,7 +198,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -319,8 +284,7 @@
 # ----------------------------------------------------------------------
 # Tests
 TESTS = torture_url test_urlmap
-AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) \
-	$(am__append_1)
+AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS) 
 DISTCLEANFILES = $(BUILT_SOURCES)
 
 # rules for building tag files
@@ -346,8 +310,6 @@
 	-I$(srcdir)/../url -I../url \
 	-I$(srcdir)/../su -I../su
 
-VALGRIND = valgrind 
-VALGRINDFLAGS = --tool=memcheck
 
 # ----------------------------------------------------------------------
 # Sofia specific rules
@@ -357,7 +319,7 @@
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/sofia.am $(top_srcdir)/rules/valcheck.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -609,7 +571,7 @@
 	else :; fi
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/../../rules $(distdir)/sofia-sip
+	$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -759,92 +721,6 @@
  ../sresolv/libsresolv.la ../stun/libstun.la ../su/libsu.la \
  ../tport/libtport.la ../url/liburl.la:
 	$(MAKE) -C $(@D) $(@F)
-
-valcheck: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-am
-
-valcheck-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) valcheck-TESTS
-
-# Run tests with valgrind in 
-valcheck-TESTS:	$(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list='$(TESTS)'; \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if case $$tst in \
-            run*) VALGRIND="$(VALGRIND) $(VALGRINDFLAGS)" \
-		  $(TESTS_ENVIRONMENT) $${dir}$$tst ;; \
-	    *) $(TESTS_ENVIRONMENT) $(VALGRIND) $(VALGRINDFLAGS) \
-	       $${dir}$$tst ;; \
-	    esac ; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
-	      ;; \
-	      *) \
-		echo "PASS: $$tst"; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *" $$tst "*) \
-		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
-	    fi; \
-	  done; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
-	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
-	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
-	  echo "$$banner"; \
-	  test -z "$$skipped" || echo "$$skipped"; \
-	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h	Sat Feb 17 01:25:21 2007
@@ -34,32 +34,29 @@
 #ifndef URL_H_TYPES
 #define URL_H_TYPES
 
-/** Recognized URL schemes (value of url_t.url_type). 
- *
- * @sa &lt;<a href="http://www.iana.org/assignments/uri-schemes.html">http://www.iana.org/assignments/uri-schemes.html</a>&gt;
- */
+/** Recognized URL schemes (value of url_t.url_type). */
 enum url_type_e {
-  url_invalid = -2,	/**< Invalid url. */
-  url_unknown = -1,	/**< Unknown scheme. */
-  url_any = 0,		/**< "*" */
-  url_sip,		/**< "sip:". @sa @RFC3261 */
-  url_sips,		/**< "sips:". @sa @RFC3261 */
-  url_tel,		/**< "tel:" @sa RFC3966 */
-  url_fax,		/**< "fax:". @note Obsolete. @sa @RFC2806 */
-  url_modem,		/**< "modem:". @note Obsolete. @sa @RFC2806  */
-  url_http,		/**< "http:". @sa @RFC2616, @RFC3986 */
-  url_https,		/**< "https:". @sa @RFC2618, @RFC3986 */
-  url_ftp,		/**< "ftp:". @sa @RFC1738 */
-  url_file,		/**< "file:" @sa @RFC1738 */
-  url_rtsp,		/**< "rtsp:" @sa @RFC2326 */
-  url_rtspu,		/**< "rtspu:" @sa @RFC2326 */
-  url_mailto,		/**< "mailto:" @sa @RFC2368 */
-  url_im,		/**< "im:" (simple instant messaging). @sa @RFC3860 */
-  url_pres,		/**< "pres:" (simple presence). @sa @RFC3859  */
-  url_cid,		/**< "cid:" (Content-ID). @sa @RFC2392 */
-  url_msrp,		/**< "msrp:" (message session relay)  */
-  url_msrps,		/**< "msrps:" (new in @VERSION_1_12_2) */
-  url_wv,		/**< "wv:" (Wireless village) */
+  url_invalid = -2,		/**< Invalid url. */
+  url_unknown = -1,		/**< Unknown scheme. */
+  url_any = 0,			/**< @c "*" */
+  url_sip,			/**< @c "sip:" */
+  url_sips,			/**< @c "sips:" */
+  url_tel,			/**< @c "tel:" */
+  url_fax,			/**< @c "fax:" */
+  url_modem,			/**< @c "modem:" */
+  url_http,			/**< @c "http:" */
+  url_https,			/**< @c "https:" */
+  url_ftp,			/**< @c "ftp:" */
+  url_file,			/**< @c "file:" */
+  url_rtsp,			/**< @c "rtsp:" */
+  url_rtspu,			/**< @c "rtspu:" */
+  url_mailto,			/**< @c "mailto:" */
+  url_im,			/**< @c "im:" (simple instant messaging) */
+  url_pres,			/**< @c "pres:" (simple presence) */
+  url_cid,			/**< @c "cid:" (Content-ID) */
+  url_msrp,			/**< @c "msrp:" (message session relay)  */
+  url_msrps,			/**< @c "msrps:" (new in @VERSION_1_12_2) */
+  url_wv,			/**< @c "wv:" (Wireless village) */
   _url_none
 };
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c	Sat Feb 17 01:25:21 2007
@@ -108,7 +108,7 @@
   TEST_S(url_escape(unreserved, UNRESERVED, NULL), UNRESERVED);
   TEST_S(url_unescape(unreserved, UNRESERVED), UNRESERVED);
 
-  d = "%53ip:%75@%48";		/* Sip:u at H */
+  d = "%73ip:%55@%68";
   u = url_hdup(home, (url_t *)d); TEST_1(u);
   url_digest(hash1, sizeof(hash1), u, NULL);
   url_digest(hash2, sizeof(hash2), (url_t const *)d, NULL);
@@ -125,11 +125,9 @@
   d = url_as_string(home, u); TEST_1(d);
   TEST_S(d, c);
 
-  d = "sip:&=+$,;?/:&=+$,@[::1]:56001;param=+$,/:@&;another=@"
+  d = "sip:&=+$,;?/:&=+$, at host:56001;param=+$,/:@&;another=@"
     "?header=" RESERVED "&%3b%2f%3f%3a%40%26%3d%2b%24%2c";
   u = url_hdup(home, (url_t *)d); TEST_1(u);
-  TEST_S(u->url_user, "&=+$,;?/");
-  TEST_S(u->url_host, "[::1]");
   TEST_S(u->url_headers, "header=" RESERVED "&%3B%2F%3F%3A%40%26%3D%2B%24%2C");
   url_digest(hash1, sizeof(hash1), u, NULL);
   url_digest(hash2, sizeof(hash2), (url_t const *)d, NULL);
@@ -139,10 +137,8 @@
   d = url_as_string(home, u); TEST_1(d);
   TEST_S(d, c);
 
-  d = "http://&=+$,;:&=+$,;@host:8080/foo;param=+$,/:@&;another=@"
-    "?query=" RESERVED;
+  d = "http://&=+$,;:&=+$,;@host:8080/foo;param=+$,/:@&;another=@?query=" RESERVED;
   u = url_hdup(home, (url_t *)d); TEST_1(u);
-  TEST_S(u->url_user, "&=+$,;"); TEST_S(u->url_password, "&=+$,;");
   url_digest(hash1, sizeof(hash1), u, NULL);
   url_digest(hash2, sizeof(hash2), (url_t const *)d, NULL);
   TEST(memcmp(hash1, hash2, sizeof(hash1)), 0);
@@ -337,13 +333,6 @@
   TEST_P(url_hdup(home, (url_t*)"sip:test at 127.0.0.1:55:"), NULL);
   TEST_P(url_hdup(home, (url_t*)"sip:test at 127.0.0.1:sip"), NULL);
 
-  u = url_hdup(home, (url_t*)"SIP:#**00**#;foo=/bar at 127.0.0.1"); TEST_1(u);
-  TEST(u->url_type, url_sip);
-  TEST_S(u->url_user, "#**00**#;foo=/bar");
-
-  TEST_1(!url_hdup(home, (url_t*)"SIP:#**00**#;foo=/bar@#127.0.0.1"));
-  TEST_1(!url_hdup(home, (url_t*)"SIP:#**00**#;foo=/bar;127.0.0.1"));
-
   for (i = 32; i <= 256; i++) {
     char pu[512];
     char param[512];
@@ -639,7 +628,7 @@
 int test_file(void)
 {
   /* Test a url with path like file:/foo/bar  */
-  char fileurl[] = "file:///foo/bar";
+  char fileurl[] = "file:/foo/bar";
   url_t file[1] = { URL_INIT_AS(file) };
   su_home_t home[1] = { SU_HOME_INIT(home) };
   char *tst;
@@ -653,9 +642,7 @@
 
   TEST_1(tst = su_strdup(home, fileurl));
   TEST(url_d(url, tst), 0);
-  TEST_S(url->url_host, "");
   file->url_root = '/';
-  file->url_host = "";
   file->url_path = "foo/bar";
   TEST(url_cmp(file, url), 0);
   TEST(url->url_type, url_file);
@@ -840,16 +827,6 @@
   TEST_S(url->url_host, "some.host");
   TEST_S(url->url_headers, "query");
   TEST_S(url->url_params, NULL);
-
-  TEST_1(u = url_hdup(home, (void *)"http://[::1]/test;ing?here"));
-  TEST_S(u->url_host, "[::1]");
-  TEST_S(u->url_path, "test;ing");
-  TEST_S(u->url_headers, "here");
-
-  url_digest(hash1, sizeof(hash1), u, NULL);
-  url_digest(hash2, sizeof(hash2), (url_t *)"http://[::1]/test;ing?here", 
-	     NULL);
-  TEST(memcmp(hash1, hash2, sizeof(hash1)), 0);
     
   su_home_deinit(home);
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/url.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/url.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/url/url.c	Sat Feb 17 01:25:21 2007
@@ -556,8 +556,8 @@
 int _url_d(url_t *url, char *s)
 {
   size_t n, p;
-  char *s0, rest_c, *host, *user;
-  int have_authority = 1;
+  char *s0, rest_c, *host;
+  int net_path = 1;
 
   memset(url, 0, sizeof(*url));
   
@@ -582,131 +582,112 @@
 
     url->url_type = url_get_type(url->url_scheme, n);
 
-    have_authority = !url_type_is_opaque(url->url_type);
+    net_path = !url_type_is_opaque(url->url_type);
   }
   else {
     url->url_type = url_unknown;
   }
 
-  user = NULL, host = s;
+  host = s;
 
   if (url->url_type == url_sip || url->url_type == url_sips) {
-    /* SIP URL may have /;? in user part but no path */
-    /* user-unreserved  =  "&" / "=" / "+" / "$" / "," / ";" / "?" / "/" */
-    /* Some #*@#* phones include unescaped # there, too */
-    n = strcspn(s, "@/;?#");
-    p = strcspn(s + n, "@");
-    if (s[n + p] == '@') {
-      n += p;
-      user = s;
-      host = s + n + 1;
-    }
-
+    /* SIP URL may have /; in user part */
+	n = strcspn(s, "@#");   /* Opaque part */
+	if ((p = strcspn(s, "#")) == n) {
+	  n = strcspn(s, "@");
+      if (s[n] != '@')
+        n = 0;
+	}
     n += strcspn(s + n, "/;?#");
   }
-  else if (have_authority) {
-    if (url->url_type == url_wv) {
-      /* WV URL may have / in user part */
-      n = strcspn(s, "@#?;");
-      if (s[n] == '@') {
-	user = s;
-	host = s + n + 1;
-	n += strcspn(s + n, ";?#");
-      }
-    }
-    else if (host[0] == '/' && host[1] != '/') {
-      /* foo:/bar or /bar - no authority, just path */
-      url->url_root = '/';	/* Absolute path */
-      host = NULL, n = 0;
-    }
-    else {
-      if (host[0] == '/' && host[1] == '/') {
-	/* We have authority, / / foo or foo */
-	host += 2; s += 2, url->url_root = '/';
-	n = strcspn(s, "/?#@[]");
-      }
-      else 
-	n = strcspn(s, "@;/?#");
-
-      if (s[n] == '@')
-	user = host, host = user + n + 1;
+  else if (url->url_type == url_wv) {
+    /* WV URL may have / in user part */
+    n = strcspn(s, "@#?;");
+    if (s[n] == '@')
+      n += strcspn(s + n, ";?#");
+  }
+  else if (url->url_type == url_invalid) {
+    n = strcspn(s, "#");
+  }
+  else if (net_path && host[0] == '/') {
+    url->url_root = host[0];	/* Absolute path */
 
-      n += strcspn(s + n, ";/?#");	/* Find path, query and/or fragment */
+    if (host[1] == '/') {	/* We have host-part */
+      host += 2; s += 2;
     }
+    else 
+      host = NULL;
+    n = strcspn(s, "/;?#");	/* Find path, query and/or fragment */
   }
-  else /* !have_authority */ {
-    user = host, host = NULL;
-    if (url->url_type != url_invalid)
-      n = strcspn(s, "/;?#");	/* Find params, query and/or fragment */
-    else
-      n = strcspn(s, "#");
+  else {
+    n = strcspn(s, "/;?#");	/* Find params, query and/or fragment */
   }
 
   rest_c = s[n]; s[n] = 0; s = rest_c ? s + n + 1 : NULL;
 
-  if (user) {
-    if (host) host[-1] = '\0';
-    url->url_user = user;
-    if (url->url_type != url_unknown) {
-      n = strcspn(user, ":");
-      if (user[n]) {
-	user[n] = '\0';
-	url->url_password = user + n + 1;
-      }
-    }
-  }
-
   if (host) {
-    url->url_host = host;
-    /* IPv6 (and in some cases, IPv4) addresses are quoted with [] */
-    if (host[0] == '[') {
-      n = strcspn(host, "]");
-      if (host[n] && (host[n + 1] == '\0' || host[n + 1] == ':'))
-	n++;
-      else
-	n = 0;
-    }
-    else {
-      n = strcspn(host, ":");
-    }
+    char *atsign, *port;
 
-    /* We allow empty host by default */
-    if (n == 0) switch (url->url_type) {
-    case url_sip:
-    case url_sips:
-    case url_im:
-    case url_pres:
-      return -1;
-    default:
-      break;
+    if (!net_path) {
+      url->url_user = host;
+      host = NULL;
+    }
+    else if ((atsign = strchr(host, '@'))) {
+      char *user;
+
+      url->url_user = user = host;
+
+      if (atsign)
+	*atsign++ = '\0';
+      host = atsign;
+
+      if (url->url_type != url_unknown) {
+	char *colon = strchr(user, ':');
+	if (colon)
+	  *colon++ = '\0';
+	url->url_password = colon;
+      }
     }
-    
-    if (host[n] == ':') {
-      char *port = host + n + 1;
-      url->url_port = port;
-      switch (url->url_type) {
-      case url_any:
-      case url_sip:
-      case url_sips:
-      case url_http:
-      case url_https:
-      case url_ftp:
-      case url_file:
-      case url_rtsp:
-      case url_rtspu:
-	if (!url_canonize2(port, port, SIZE_MAX, RESERVED_MASK))
-	  return -1;
 
-	/* Check that port is really numeric or wildcard */
-	/* Port can be *digit, empty string or "*" */
-	while (*port >= '0' && *port <= '9')
-	  port++;
-	
-	if (port != url->url_port ? port[0] != '\0' 
-	    : (port[0] != '*' || port[1] != '\0'))
+    if ((url->url_host = host)) {
+      /* IPv6 (and in some cases, IPv4) addresses are quoted with [] */
+      if (host[0] == '[') {
+	port = strchr(host, ']');
+	if (!port)
 	  return -1;
+	port = strchr(port + 1, ':');
+      }
+      else 
+	port = strchr(host, ':');
+
+      if (port) {
+	*port++ = '\0';
+	url->url_port = port;
+	switch (url->url_type) {
+	case url_any:
+	case url_sip:
+	case url_sips:
+	case url_http:
+	case url_https:
+	case url_ftp:
+	case url_file:
+	case url_rtsp:
+	case url_rtspu:
+	  
+	  if (!url_canonize2(port, port, SIZE_MAX, RESERVED_MASK))
+	    return -1;
+
+	  /* Check that port is really numeric or wildcard */
+	  /* Port can be *digit, empty string or "*" */
+	  while (*port >= '0' && *port <= '9')
+	    port++;
+	  if (port != url->url_port 
+	      ? port[0] != '\0' 
+	      : port[0] != '\0'
+	      && (port[0] != '*' || port[1] != '\0'))
+	    return -1;
+	}
       }
-      host[n] = 0;
     }
   }
 
@@ -761,15 +742,12 @@
     if (s && !url_canonize(s, s, SIZE_MAX, SIP_USER_UNRESERVED))
       return -1;
 
-    /* Having different charset in user and password does not make sense */
-    /* but that is how it is defined in RFC 3261 */
 #   define SIP_PASS_UNRESERVED "&=+$,"
     s = (char *)url->url_password;
     if (s && !url_canonize(s, s, SIZE_MAX, SIP_PASS_UNRESERVED))
       return -1;
 
-  }
-  else {
+  } else {
 
 #   define USER_UNRESERVED "&=+$,;"
     s = (char *)url->url_user;
@@ -965,7 +943,7 @@
 }
 
 
-/** Calculate the length of URL when encoded. 
+/** Calculate the lengh of URL when encoded. 
  *
  */
 isize_t url_len(url_t const * url)
@@ -1911,8 +1889,8 @@
 static
 void url_string_update(su_md5_t *md5, char const *s)
 {
-  size_t n, p;
-  int have_authority = 1;
+  size_t n;
+  int hostpart = 1;
   enum url_type_e type = url_any;
   char const *at, *colon;
   char schema[48];
@@ -1932,7 +1910,7 @@
     type = url_get_type(schema, at - schema);
     su_md5_iupdate(md5, schema, at - schema);
 
-    have_authority = !url_type_is_opaque(type);
+    hostpart = !url_type_is_opaque(type);
     s += n + 1;
   }
   else {
@@ -1940,71 +1918,62 @@
   }
   
   if (type == url_sip || type == url_sips) {
-    /* SIP URL may have /;? in user part but no path */
-    /* user-unreserved  =  "&" / "=" / "+" / "$" / "," / ";" / "?" / "/" */
-    /* Some #*@#* phones include unescaped # there, too */
-    n = strcspn(s, "@/;?#");
-    p = strcspn(s + n, "@");
-    if (s[n + p] == '@') {
-      n += p;
-      /* Ignore password in hash */
-      colon = memchr(s, ':', n);
-      p = colon ? (size_t)(colon - s) : n;
-      canon_update(md5, s, p, SIP_USER_UNRESERVED);
-      s += n + 1; n = 0;
-    }
-    else
-      su_md5_iupdate(md5, "", 1);	/* user */
+    n = strcspn(s, "@#");	/* Opaque part */
+    if (s[n] != '@')
+      n = 0;
     n += strcspn(s + n, "/;?#");
   }
-  else if (have_authority) {
-    if (type == url_wv) {    /* WV URL may have / in user part */
-      n = strcspn(s, "@;?#");
-    }
-    else if (type != url_wv && s[0] == '/' && s[1] != '/') {
-      /* foo:/bar */
-      su_md5_update(md5, "\0\0", 2); /* user, host */
-      su_md5_striupdate(md5, url_port_default(type));
-      return;
-    }
-    else if (s[0] == '/' && s[1] == '/') {
-      /* We have authority, / / foo or foo */
-      s += 2;
-      n = strcspn(s, "/?#@[]");
-    }
-    else 
-      n = strcspn(s, "@;/?#");
-
-    if (s[n] == '@') {
-      /* Ignore password in hash */
-      colon = type != url_unknown ? memchr(s, ':', n) : NULL;
-      p = colon ? (size_t)(colon - s) : n;
-      canon_update(md5, s, p, SIP_USER_UNRESERVED);
-      s += n + 1;
-      n = strcspn(s, "/;?#");	/* Until path, query or fragment */
-    }
-    else {
-      su_md5_iupdate(md5, "", 1);	/* user */
-      n += strcspn(s + n, "/;?#");	/* Until path, query or fragment */
-    }
+  else if (type == url_wv) {    /* WV URL may have / in user part */
+    n = strcspn(s, "@#?;");
+    if (s[n] == '@')
+      n += strcspn(s + n, ";?#");
+  }
+  else if (!hostpart || s[0] != '/') {
+    n = strcspn(s, "/;?#");	/* Opaque part */
+  }
+  else if (s[1] == '/') {
+    s += 2;
+    n = strcspn(s, "/;?#");	/* Until host, path, query or fragment */
+  }
+  else {
+    /* foo:/bar */
+    su_md5_update(md5, "\0\0", 2); /* user, host */
+    su_md5_striupdate(md5, url_port_default(type));
+    return;
   }
-  else /* if (!have_authority) */ {
-    n = strcspn(s, ":/;?#");	/* Until pass, path, query or fragment */
+  
+  if (!hostpart) {
+    char const *colon = memchr(s, ':', n);
     
+    if (colon) n = colon - s;
     canon_update(md5, s, n, ""); /* user */
     su_md5_update(md5, "\0", 1); /* host, no port */
     su_md5_striupdate(md5, url_port_default(type));
     return;
   }
 
-  if (n > 0 && s[0] == '[') {	/* IPv6reference */
-    colon = memchr(s, ']', n);
-    if (colon == NULL || ++colon == s + n || *colon != ':')
-      colon = NULL;
+  at = memchr(s, '@', n);
+
+  if (at) {
+    char const *allow = 
+      (type == url_sip || type == url_sips) 
+      ? SIP_USER_UNRESERVED
+      : USER_UNRESERVED;
+
+    colon = type == url_unknown ? NULL : memchr(s, ':', at - s);
+
+    /* Updated only user part */
+    if (colon)
+      canon_update(md5, s, colon - s, allow);
+    else
+      canon_update(md5, s, at - s, allow);
+    n = n - (at + 1 - s);
+    s = at + 1;
   }
-  else 
-    colon = memchr(s, ':', n);
+  else
+    su_md5_iupdate(md5, "", 1);	/* user */
 
+  colon = memchr(s, ':', n);	/* XXX - IPv6! */
   if (colon) {
     canon_update(md5, s, colon - s, ""); /* host */
     canon_update(md5, colon + 1, (s + n) - (colon + 1), "");

Modified: freeswitch/trunk/libs/sofia-sip/ltmain.sh
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/ltmain.sh	(original)
+++ freeswitch/trunk/libs/sofia-sip/ltmain.sh	Sat Feb 17 01:25:21 2007
@@ -1,7 +1,7 @@
 # ltmain.sh - Provide generalized library-building support services.
 # NOTE: Changing this file will not affect anything until you rerun configure.
 #
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
 # Free Software Foundation, Inc.
 # Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 #
@@ -17,7 +17,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -33,6 +33,9 @@
 # function.
 progpath="$0"
 
+# RH: define SED for historic ltconfig's generated by Libtool 1.3
+[ -z "$SED" ] && SED=sed
+
 # The name of this program:
 progname=`echo "$progpath" | $SED $basename`
 modename="$progname"
@@ -43,14 +46,9 @@
 
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=1.5.22
-TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
+VERSION=1.5.6
+TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42)"
 
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes.
-if test -n "${ZSH_VERSION+set}" ; then
-  setopt NO_GLOB_SUBST
-fi
 
 # Check that we have a working $echo.
 if test "X$1" = X--no-reexec; then
@@ -88,15 +86,14 @@
 Xsed="${SED}"' -e 1s/^X//'
 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
 # test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  SP2NL='tr \040 \012'
-  NL2SP='tr \015\012 \040\040'
+case `echo A|tr A '\301'` in
+ A) # EBCDIC based system
+  SP2NL="tr '\100' '\n'"
+  NL2SP="tr '\r\n' '\100\100'"
   ;;
- *) # EBCDIC based system
-  SP2NL='tr \100 \n'
-  NL2SP='tr \r\n \100\100'
+ *) # Assume ASCII based system
+  SP2NL="tr '\040' '\012'"
+  NL2SP="tr '\015\012' '\040\040'"
   ;;
 esac
 
@@ -113,9 +110,8 @@
 fi
 
 # Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
+: ${IFS=" 	
+"}
 
 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
   $echo "$modename: not configured to build any kind of library" 1>&2
@@ -132,8 +128,6 @@
 show="$echo"
 show_help=
 execute_dlfiles=
-duplicate_deps=no
-preserve_args=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
 
@@ -141,51 +135,13 @@
 # Shell function definitions:
 # This seems to be the best place for them
 
-# func_mktempdir [string]
-# Make a temporary directory that won't clash with other running
-# libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
-func_mktempdir ()
-{
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
-
-    if test "$run" = ":"; then
-      # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
-    else
-
-      # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
-
-      if test ! -d "$my_tmpdir"; then
-	# Failing that, at least try and use $RANDOM to avoid a race
-	my_tmpdir="${my_template}-${RANDOM-0}$$"
-
-	save_mktempdir_umask=`umask`
-	umask 0077
-	$mkdir "$my_tmpdir"
-	umask $save_mktempdir_umask
-      fi
-
-      # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || {
-        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
-	exit $EXIT_FAILURE
-      }
-    fi
-
-    $echo "X$my_tmpdir" | $Xsed
-}
-
-
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
 # Need a lot of goo to handle *both* DLLs and import libs
 # Has to be a shell function in order to 'eat' the argument
 # that is supplied when $file_magic_command is called.
-func_win32_libid ()
-{
+func_win32_libid () {
   win32_libid_type="unknown"
   win32_fileres=`file -L $1 2>/dev/null`
   case $win32_fileres in
@@ -196,11 +152,12 @@
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
       $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
       win32_nmres=`eval $NM -f posix -A $1 | \
-	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
-      case $win32_nmres in
-      import*)  win32_libid_type="x86 archive import";;
-      *)        win32_libid_type="x86 archive static";;
-      esac
+	sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
+      if test "X$win32_nmres" = "Ximport" ; then
+        win32_libid_type="x86 archive import"
+      else
+        win32_libid_type="x86 archive static"
+      fi
     fi
     ;;
   *DLL*)
@@ -224,8 +181,7 @@
 # Only attempt this if the compiler in the base compile
 # command doesn't match the default compiler.
 # arg is usually of the form 'gcc ...'
-func_infer_tag ()
-{
+func_infer_tag () {
     if test -n "$available_tags" && test -z "$tagname"; then
       CC_quoted=
       for arg in $CC; do
@@ -282,116 +238,12 @@
       esac
     fi
 }
-
-
-# func_extract_an_archive dir oldlib
-func_extract_an_archive ()
-{
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-
-    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
-    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
-    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
-     :
-    else
-      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
-      exit $EXIT_FAILURE
-    fi
-}
-
-# func_extract_archives gentop oldlib ...
-func_extract_archives ()
-{
-    my_gentop="$1"; shift
-    my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
-    my_status=""
-
-    $show "${rm}r $my_gentop"
-    $run ${rm}r "$my_gentop"
-    $show "$mkdir $my_gentop"
-    $run $mkdir "$my_gentop"
-    my_status=$?
-    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
-      exit $my_status
-    fi
-
-    for my_xlib in $my_oldlibs; do
-      # Extract the objects.
-      case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
-	*) my_xabs=`pwd`"/$my_xlib" ;;
-      esac
-      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
-      my_xdir="$my_gentop/$my_xlib"
-
-      $show "${rm}r $my_xdir"
-      $run ${rm}r "$my_xdir"
-      $show "$mkdir $my_xdir"
-      $run $mkdir "$my_xdir"
-      exit_status=$?
-      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
-	exit $exit_status
-      fi
-      case $host in
-      *-darwin*)
-	$show "Extracting $my_xabs"
-	# Do not bother doing anything if just a dry run
-	if test -z "$run"; then
-	  darwin_orig_dir=`pwd`
-	  cd $my_xdir || exit $?
-	  darwin_archive=$my_xabs
-	  darwin_curdir=`pwd`
-	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
-	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
-	  if test -n "$darwin_arches"; then 
-	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
-	    darwin_arch=
-	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
-	      cd "$darwin_curdir"
-	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
-	    done # $darwin_arches
-      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
-	    darwin_file=
-	    darwin_files=
-	    for darwin_file in $darwin_filelist; do
-	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
-	      lipo -create -output "$darwin_file" $darwin_files
-	    done # $darwin_filelist
-	    ${rm}r unfat-$$
-	    cd "$darwin_orig_dir"
-	  else
-	    cd "$darwin_orig_dir"
- 	    func_extract_an_archive "$my_xdir" "$my_xabs"
-	  fi # $darwin_arches
-	fi # $run
-	;;
-      *)
-        func_extract_an_archive "$my_xdir" "$my_xabs"
-        ;;
-      esac
-      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
-    done
-    func_extract_archives_result="$my_oldobjs"
-}
 # End of Shell function definitions
 #####################################
 
 # Darwin sucks
 eval std_shrext=\"$shrext_cmds\"
 
-disable_libs=no
-
 # Parse our command line options once, thoroughly.
 while test "$#" -gt 0
 do
@@ -456,10 +308,10 @@
   --version)
     $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
     $echo
-    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
+    $echo "Copyright (C) 2003  Free Software Foundation, Inc."
     $echo "This is free software; see the source for copying conditions.  There is NO"
     $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-    exit $?
+    exit $EXIT_SUCCESS
     ;;
 
   --config)
@@ -468,7 +320,7 @@
     for tagname in $taglist; do
       ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
     done
-    exit $?
+    exit $EXIT_SUCCESS
     ;;
 
   --debug)
@@ -493,7 +345,7 @@
     else
       $echo "disable static libraries"
     fi
-    exit $?
+    exit $EXIT_SUCCESS
     ;;
 
   --finish) mode="finish" ;;
@@ -508,11 +360,7 @@
     preserve_args="$preserve_args $arg"
     ;;
 
-  --tag)
-    prevopt="--tag"
-    prev=tag
-    preserve_args="$preserve_args --tag"
-    ;;
+  --tag) prevopt="--tag" prev=tag ;;
   --tag=*)
     set tag "$optarg" ${1+"$@"}
     shift
@@ -544,18 +392,6 @@
   exit $EXIT_FAILURE
 fi
 
-case $disable_libs in
-no) 
-  ;;
-shared)
-  build_libtool_libs=no
-  build_old_libs=yes
-  ;;
-static)
-  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
-  ;;
-esac
-
 # If this variable is set in any of the actions, the command in it
 # will be execed at the end.  This prevents here-documents from being
 # left over by shells.
@@ -566,7 +402,7 @@
   # Infer the operation mode.
   if test -z "$mode"; then
     $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
-    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
+    $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
     case $nonopt in
     *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
       mode=link
@@ -632,7 +468,7 @@
 
     for arg
     do
-      case $arg_mode in
+      case "$arg_mode" in
       arg  )
 	# do not "continue".  Instead, add this to base_compile
 	lastarg="$arg"
@@ -714,10 +550,7 @@
       case $lastarg in
       # Double-quote args containing other shell metacharacters.
       # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, and some SunOS ksh mistreat backslash-escaping
-      # in scan sets (worked around with variable expansion),
-      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
-      # at all, so we specify them separately.
+      # in scan sets, so we specify it separately.
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
 	lastarg="\"$lastarg\""
 	;;
@@ -791,14 +624,6 @@
       esac
     done
 
-    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
-    case $qlibobj in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	qlibobj="\"$qlibobj\"" ;;
-    esac
-    test "X$libobj" != "X$qlibobj" \
-	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
-	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
     objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
     xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
     if test "X$xdir" = "X$obj"; then
@@ -871,17 +696,12 @@
 	$run $rm $removelist
 	exit $EXIT_FAILURE
       fi
-      $echo "$srcfile" > "$lockfile"
+      $echo $srcfile > "$lockfile"
     fi
 
     if test -n "$fix_srcfile_path"; then
       eval srcfile=\"$fix_srcfile_path\"
     fi
-    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
-    case $qsrcfile in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-      qsrcfile="\"$qsrcfile\"" ;;
-    esac
 
     $run $rm "$libobj" "${libobj}T"
 
@@ -903,18 +723,18 @@
       fbsd_hideous_sh_bug=$base_compile
 
       if test "$pic_mode" != no; then
-	command="$base_compile $qsrcfile $pic_flag"
+	command="$base_compile $srcfile $pic_flag"
       else
 	# Don't build PIC code
-	command="$base_compile $qsrcfile"
+	command="$base_compile $srcfile"
       fi
 
       if test ! -d "${xdir}$objdir"; then
 	$show "$mkdir ${xdir}$objdir"
 	$run $mkdir ${xdir}$objdir
-	exit_status=$?
-	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
-	  exit $exit_status
+	status=$?
+	if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
+	  exit $status
 	fi
       fi
 
@@ -986,9 +806,9 @@
     if test "$build_old_libs" = yes; then
       if test "$pic_mode" != yes; then
 	# Don't build PIC code
-	command="$base_compile $qsrcfile"
+	command="$base_compile $srcfile"
       else
-	command="$base_compile $qsrcfile $pic_flag"
+	command="$base_compile $srcfile $pic_flag"
       fi
       if test "$compiler_c_o" = yes; then
 	command="$command -o $obj"
@@ -1117,7 +937,6 @@
     no_install=no
     objs=
     non_pic_objects=
-    notinst_path= # paths that contain not-installed libtool libraries
     precious_files_regex=
     prefer_static_libs=no
     preload=no
@@ -1146,15 +965,14 @@
 	  if test -n "$link_static_flag"; then
 	    dlopen_self=$dlopen_self_static
 	  fi
-	  prefer_static_libs=yes
 	else
 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
 	    dlopen_self=$dlopen_self_static
 	  fi
-	  prefer_static_libs=built
 	fi
 	build_libtool_libs=no
 	build_old_libs=yes
+	prefer_static_libs=yes
 	break
 	;;
       esac
@@ -1329,11 +1147,6 @@
 		  if test -z "$pic_object" || test "$pic_object" = none ; then
 		    arg="$non_pic_object"
 		  fi
-		else
-		  # If the PIC object exists, use it instead.
-		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
-		  non_pic_objects="$non_pic_objects $non_pic_object"
 		fi
 	      else
 		# Only an error if not doing a dry-run.
@@ -1417,13 +1230,6 @@
 	  prev=
 	  continue
 	  ;;
-	darwin_framework|darwin_framework_skip)
-	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
-	  compile_command="$compile_command $arg"
-	  finalize_command="$finalize_command $arg"
-	  prev=
-	  continue
-	  ;;
 	*)
 	  eval "$prev=\"\$arg\""
 	  prev=
@@ -1482,18 +1288,6 @@
 	continue
 	;;
 
-      -framework|-arch|-isysroot)
-	case " $CC " in
-	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
-		prev=darwin_framework_skip ;;
-	  *) compiler_flags="$compiler_flags $arg"
-	     prev=darwin_framework ;;
-	esac
-	compile_command="$compile_command $arg"
-	finalize_command="$finalize_command $arg"
-	continue
-	;;
-
       -inst-prefix-dir)
 	prev=inst_prefix
 	continue
@@ -1520,8 +1314,7 @@
 	  absdir=`cd "$dir" && pwd`
 	  if test -z "$absdir"; then
 	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
-	    absdir="$dir"
-	    notinst_path="$notinst_path $dir"
+	    exit $EXIT_FAILURE
 	  fi
 	  dir="$absdir"
 	  ;;
@@ -1535,15 +1328,10 @@
 	esac
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$dir:"*) ;;
 	  *) dllsearchpath="$dllsearchpath:$dir";;
 	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  *) dllsearchpath="$dllsearchpath:$testbindir";;
-	  esac
 	  ;;
 	esac
 	continue
@@ -1552,15 +1340,15 @@
       -l*)
 	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
 	  case $host in
-	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
+	  *-*-cygwin* | *-*-pw32* | *-*-beos*)
 	    # These systems don't actually have a C or math library (as such)
 	    continue
 	    ;;
-	  *-*-os2*)
+	  *-*-mingw* | *-*-os2*)
 	    # These systems don't actually have a C library (as such)
 	    test "X$arg" = "X-lc" && continue
 	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	  *-*-openbsd* | *-*-freebsd*)
 	    # Do not include libc due to us having libc/libc_r.
 	    test "X$arg" = "X-lc" && continue
 	    ;;
@@ -1568,19 +1356,10 @@
 	    # Rhapsody C and math libraries are in the System framework
 	    deplibs="$deplibs -framework System"
 	    continue
-	    ;;
-	  *-*-sco3.2v5* | *-*-sco5v6*)
-	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
-	    ;;
 	  esac
 	elif test "X$arg" = "X-lc_r"; then
 	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	 *-*-openbsd* | *-*-freebsd*)
 	   # Do not include libc_r directly, use -pthread flag.
 	   continue
 	   ;;
@@ -1590,20 +1369,8 @@
 	continue
 	;;
 
-      # Tru64 UNIX uses -model [arg] to determine the layout of C++
-      # classes, name mangling, and exception handling.
-      -model)
-	compile_command="$compile_command $arg"
-	compiler_flags="$compiler_flags $arg"
-	finalize_command="$finalize_command $arg"
-	prev=xcompiler
-	continue
-	;;
-
      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
-	compiler_flags="$compiler_flags $arg"
-	compile_command="$compile_command $arg"
-	finalize_command="$finalize_command $arg"
+	deplibs="$deplibs $arg"
 	continue
 	;;
 
@@ -1612,19 +1379,13 @@
 	continue
 	;;
 
-      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
-      # -r[0-9][0-9]* specifies the processor on the SGI compiler
-      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
-      # +DA*, +DD* enable 64-bit mode on the HP compiler
-      # -q* pass through compiler args for the IBM compiler
-      # -m* pass through architecture-specific compiler args for GCC
-      # -m*, -t[45]*, -txscale* pass through architecture-specific
-      # compiler args for GCC
-      # -pg pass through profiling flag for GCC
-      # @file GCC response files
-      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
-      -t[45]*|-txscale*|@*)
-
+      # gcc -m* arguments should be passed to the linker via $compiler_flags
+      # in order to pass architecture information to the linker
+      # (e.g. 32 vs 64-bit).  This may also be accomplished via -Wl,-mfoo
+      # but this is not reliable with gcc because gcc may use -mfoo to
+      # select a different linker, different libraries, etc, while
+      # -Wl,-mfoo simply passes -mfoo to the linker.
+      -m*)
 	# Unknown arguments in both finalize_command and compile_command need
 	# to be aesthetically quoted because they are evaled later.
 	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
@@ -1635,7 +1396,9 @@
 	esac
         compile_command="$compile_command $arg"
         finalize_command="$finalize_command $arg"
-        compiler_flags="$compiler_flags $arg"
+        if test "$with_gcc" = "yes" ; then
+          compiler_flags="$compiler_flags $arg"
+        fi
         continue
         ;;
 
@@ -1873,11 +1636,6 @@
 	    if test -z "$pic_object" || test "$pic_object" = none ; then
 	      arg="$non_pic_object"
 	    fi
-	  else
-	    # If the PIC object exists, use it instead.
-	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
-	    non_pic_objects="$non_pic_objects $non_pic_object"
 	  fi
 	else
 	  # Only an error if not doing a dry-run.
@@ -1983,9 +1741,9 @@
     if test ! -d "$output_objdir"; then
       $show "$mkdir $output_objdir"
       $run $mkdir $output_objdir
-      exit_status=$?
-      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
-	exit $exit_status
+      status=$?
+      if test "$status" -ne 0 && test ! -d "$output_objdir"; then
+	exit $status
       fi
     fi
 
@@ -2048,6 +1806,7 @@
     newlib_search_path=
     need_relink=no # whether we're linking any uninstalled libtool libraries
     notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
     case $linkmode in
     lib)
 	passes="conv link"
@@ -2099,7 +1858,7 @@
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
-	    compiler_flags="$compiler_flags $deplib"
+	    deplibs="$deplib $deplibs"
 	  fi
 	  continue
 	  ;;
@@ -2108,6 +1867,10 @@
 	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
 	    continue
 	  fi
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	    continue
+	  fi
 	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
 	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
 	    for search_ext in .la $std_shrext .so .a; do
@@ -2218,22 +1981,7 @@
 	  fi
 	  case $linkmode in
 	  lib)
-	    valid_a_lib=no
-	    case $deplibs_check_method in
-	      match_pattern*)
-		set dummy $deplibs_check_method
-	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
-		if eval $echo \"$deplib\" 2>/dev/null \
-		    | $SED 10q \
-		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		  valid_a_lib=yes
-		fi
-		;;
-	      pass_all)
-		valid_a_lib=yes
-		;;
-            esac
-	    if test "$valid_a_lib" != yes; then
+	    if test "$deplibs_check_method" != pass_all; then
 	      $echo
 	      $echo "*** Warning: Trying to link with static lib archive $deplib."
 	      $echo "*** I have the capability to make that library automatically link in when"
@@ -2283,7 +2031,7 @@
 	esac # case $deplib
 	if test "$found" = yes || test -f "$lib"; then :
 	else
-	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
+	  $echo "$modename: cannot find the library \`$lib'" 1>&2
 	  exit $EXIT_FAILURE
 	fi
 
@@ -2307,8 +2055,6 @@
 	# it will not redefine variables installed, or shouldnotlink
 	installed=yes
 	shouldnotlink=no
-	avoidtemprpath=
-
 
 	# Read the .la file
 	case $lib in
@@ -2407,19 +2153,11 @@
 	    dir="$libdir"
 	    absdir="$libdir"
 	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
 	else
-	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    # Remove this search path later
-	    notinst_path="$notinst_path $abs_ladir"
-	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
-	    # Remove this search path later
-	    notinst_path="$notinst_path $abs_ladir"
-	  fi
+	  dir="$ladir/$objdir"
+	  absdir="$abs_ladir/$objdir"
+	  # Remove this search path later
+	  notinst_path="$notinst_path $abs_ladir"
 	fi # $installed = yes
 	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
 
@@ -2492,12 +2230,12 @@
 	  if test -n "$library_names" &&
 	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
 	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	    if test -n "$shlibpath_var"; then
 	      # Make sure the rpath contains only unique directories.
 	      case "$temp_rpath " in
 	      *" $dir "*) ;;
 	      *" $absdir "*) ;;
-	      *) temp_rpath="$temp_rpath $absdir" ;;
+	      *) temp_rpath="$temp_rpath $dir" ;;
 	      esac
 	    fi
 
@@ -2534,12 +2272,8 @@
 	fi
 
 	link_static=no # Whether the deplib will be linked statically
-	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes ; then
-	  use_static_libs=no
-	fi
 	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	   { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
 	  if test "$installed" = no; then
 	    notinst_deplibs="$notinst_deplibs $lib"
 	    need_relink=yes
@@ -2652,15 +2386,11 @@
 	      if test "$hardcode_direct" = no; then
 		add="$dir/$linklib"
 		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
-		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
+		  *-*-sco3.2v5* ) add_dir="-L$dir" ;;
 		  *-*-darwin* )
 		    # if the lib is a module then we can not link against
 		    # it, someone is ignoring the new warnings I added
-		    if /usr/bin/file -L $add 2> /dev/null |
-                      $EGREP ": [^:]* bundle" >/dev/null ; then
+		    if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
 		      $echo "** Warning, lib $linklib is a module, not a shared library"
 		      if test -z "$old_library" ; then
 		        $echo
@@ -2691,7 +2421,7 @@
 		add_dir="-L$dir"
 		# Try looking first in the location we're being installed to.
 		if test -n "$inst_prefix_dir"; then
-		  case $libdir in
+		  case "$libdir" in
 		    [\\/]*)
 		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
 		      ;;
@@ -2764,7 +2494,7 @@
 	      add_dir="-L$libdir"
 	      # Try looking first in the location we're being installed to.
 	      if test -n "$inst_prefix_dir"; then
-		case $libdir in
+		case "$libdir" in
 		  [\\/]*)
 		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
 		    ;;
@@ -2825,6 +2555,8 @@
 	      fi
 	    fi
 	  else
+	    convenience="$convenience $dir/$old_library"
+	    old_convenience="$old_convenience $dir/$old_library"
 	    deplibs="$dir/$old_library $deplibs"
 	    link_static=yes
 	  fi
@@ -2942,13 +2674,13 @@
 	      *) continue ;;
 	      esac
 	      case " $deplibs " in
-	      *" $path "*) ;;
-	      *) deplibs="$path $deplibs" ;;
-	      esac
-	      case " $deplibs " in
 	      *" $depdepl "*) ;;
 	      *) deplibs="$depdepl $deplibs" ;;
 	      esac
+	      case " $deplibs " in
+	      *" $path "*) ;;
+	      *) deplibs="$deplibs $path" ;;
+	      esac
 	    done
 	  fi # link_all_deplibs != no
 	fi # linkmode = lib
@@ -3212,27 +2944,27 @@
 
 	# Check that each of the things are valid numbers.
 	case $current in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	[0-9]*) ;;
 	*)
-	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
+	  $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
 	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
 	  exit $EXIT_FAILURE
 	  ;;
 	esac
 
 	case $revision in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	[0-9]*) ;;
 	*)
-	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
+	  $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
 	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
 	  exit $EXIT_FAILURE
 	  ;;
 	esac
 
 	case $age in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	[0-9]*) ;;
 	*)
-	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
+	  $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
 	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
 	  exit $EXIT_FAILURE
 	  ;;
@@ -3258,7 +2990,7 @@
 	  versuffix="$major.$age.$revision"
 	  # Darwin ld doesn't like 0 for these options...
 	  minor_current=`expr $current + 1`
-	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
 	  ;;
 
 	freebsd-aout)
@@ -3411,9 +3143,9 @@
 
       # Eliminate all temporary directories.
       for path in $notinst_path; do
-	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
-	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
-	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
+	lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
+	deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
+	dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
       done
 
       if test -n "$xrpath"; then
@@ -3464,14 +3196,9 @@
 	  *-*-netbsd*)
 	    # Don't link with libc until the a.out ld.so is fixed.
 	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	  *-*-openbsd* | *-*-freebsd*)
 	    # Do not include libc due to us having libc/libc_r.
-	    ;;
-	  *-*-sco3.2v5* | *-*-sco5v6*)
-	    # Causes problems with __ctype
-	    ;;
-	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-	    # Compiler inserts libc in the correct place for threads to work
+	    test "X$arg" = "X-lc" && continue
 	    ;;
  	  *)
 	    # Add libc to deplibs on all other systems if necessary.
@@ -3515,11 +3242,11 @@
 	  int main() { return 0; }
 EOF
 	  $rm conftest
-	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
+	  $LTCC -o conftest conftest.c $deplibs
 	  if test "$?" -eq 0 ; then
 	    ldd_output=`ldd conftest`
 	    for i in $deplibs; do
-	      name=`expr $i : '-l\(.*\)'`
+	      name="`expr $i : '-l\(.*\)'`"
 	      # If $name is empty we are operating on a -L argument.
               if test "$name" != "" && test "$name" -ne "0"; then
 		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
@@ -3556,11 +3283,11 @@
 	    # Error occurred in the first compile.  Let's try to salvage
 	    # the situation: Compile a separate program for each library.
 	    for i in $deplibs; do
-	      name=`expr $i : '-l\(.*\)'`
+	      name="`expr $i : '-l\(.*\)'`"
 	      # If $name is empty we are operating on a -L argument.
               if test "$name" != "" && test "$name" != "0"; then
 		$rm conftest
-		$LTCC $LTCFLAGS -o conftest conftest.c $i
+		$LTCC -o conftest conftest.c $i
 		# Did it work?
 		if test "$?" -eq 0 ; then
 		  ldd_output=`ldd conftest`
@@ -3608,7 +3335,7 @@
 	  set dummy $deplibs_check_method
 	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
 	  for a_deplib in $deplibs; do
-	    name=`expr $a_deplib : '-l\(.*\)'`
+	    name="`expr $a_deplib : '-l\(.*\)'`"
 	    # If $name is empty we are operating on a -L argument.
             if test "$name" != "" && test  "$name" != "0"; then
 	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
@@ -3677,7 +3404,7 @@
 	  set dummy $deplibs_check_method
 	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
 	  for a_deplib in $deplibs; do
-	    name=`expr $a_deplib : '-l\(.*\)'`
+	    name="`expr $a_deplib : '-l\(.*\)'`"
 	    # If $name is empty we are operating on a -L argument.
 	    if test -n "$name" && test "$name" != "0"; then
 	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
@@ -3807,35 +3534,6 @@
 	deplibs=$newdeplibs
       fi
 
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-	case " $new_libs " in
-	*" -L$path/$objdir "*) ;;
-	*)
-	  case " $deplibs " in
-	  *" -L$path/$objdir "*)
-	    new_libs="$new_libs -L$path/$objdir" ;;
-	  esac
-	  ;;
-	esac
-      done
-      for deplib in $deplibs; do
-	case $deplib in
-	-L*)
-	  case " $new_libs " in
-	  *" $deplib "*) ;;
-	  *) new_libs="$new_libs $deplib" ;;
-	  esac
-	  ;;
-	*) new_libs="$new_libs $deplib" ;;
-	esac
-      done
-      deplibs="$new_libs"
-
-
       # All the library-specific variables (install_libdir is set above).
       library_names=
       old_library=
@@ -3919,7 +3617,6 @@
 	fi
 
 	lib="$output_objdir/$realname"
-	linknames=
 	for link
 	do
 	  linknames="$linknames $link"
@@ -3948,9 +3645,6 @@
 	        # The command line is too long to execute in one step.
 	        $show "using reloadable object file for export list..."
 	        skipped_export=:
-		# Break out early, otherwise skipped_export may be
-		# set to false by a later but shorter cmd.
-		break
 	      fi
 	    done
 	    IFS="$save_ifs"
@@ -3984,13 +3678,67 @@
 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
 	  else
 	    gentop="$output_objdir/${outputname}x"
+	    $show "${rm}r $gentop"
+	    $run ${rm}r "$gentop"
+	    $show "$mkdir $gentop"
+	    $run $mkdir "$gentop"
+	    status=$?
+	    if test "$status" -ne 0 && test ! -d "$gentop"; then
+	      exit $status
+	    fi
 	    generated="$generated $gentop"
 
-	    func_extract_archives $gentop $convenience
-	    libobjs="$libobjs $func_extract_archives_result"
+	    for xlib in $convenience; do
+	      # Extract the objects.
+	      case $xlib in
+	      [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	      *) xabs=`pwd`"/$xlib" ;;
+	      esac
+	      xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	      xdir="$gentop/$xlib"
+
+	      $show "${rm}r $xdir"
+	      $run ${rm}r "$xdir"
+	      $show "$mkdir $xdir"
+	      $run $mkdir "$xdir"
+	      status=$?
+	      if test "$status" -ne 0 && test ! -d "$xdir"; then
+		exit $status
+	      fi
+	      # We will extract separately just the conflicting names and we will no
+	      # longer touch any unique names. It is faster to leave these extract
+	      # automatically by $AR in one run.
+	      $show "(cd $xdir && $AR x $xabs)"
+	      $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+	      if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+		:
+	      else
+		$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+		$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+		$AR t "$xabs" | sort | uniq -cd | while read -r count name
+		do
+		  i=1
+		  while test "$i" -le "$count"
+		  do
+		   # Put our $i before any first dot (extension)
+		   # Never overwrite any file
+		   name_to="$name"
+		   while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+		   do
+		     name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+		   done
+		   $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+		   $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+		   i=`expr $i + 1`
+		  done
+		done
+	      fi
+
+	      libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+	    done
 	  fi
 	fi
-	
+
 	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
 	  eval flag=\"$thread_safe_flag_spec\"
 	  linker_flags="$linker_flags $flag"
@@ -4020,8 +3768,7 @@
 	  fi
 	fi
 
-	if test "X$skipped_export" != "X:" &&
-	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+	if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` &&
 	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
 	  :
 	else
@@ -4040,7 +3787,6 @@
 	    save_libobjs=$libobjs
 	  fi
 	  save_output=$output
-	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
 
 	  # Clear the reloadable object creation command queue and
 	  # initialize k to one.
@@ -4050,13 +3796,13 @@
 	  delfiles=
 	  last_robj=
 	  k=1
-	  output=$output_objdir/$output_la-${k}.$objext
+	  output=$output_objdir/$save_output-${k}.$objext
 	  # Loop over the list of objects to be linked.
 	  for obj in $save_libobjs
 	  do
 	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
 	    if test "X$objlist" = X ||
-	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+	       { len=`expr "X$test_cmds" : ".*"` &&
 		 test "$len" -le "$max_cmd_len"; }; then
 	      objlist="$objlist $obj"
 	    else
@@ -4070,9 +3816,9 @@
 		# the last one created.
 		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
 	      fi
-	      last_robj=$output_objdir/$output_la-${k}.$objext
+	      last_robj=$output_objdir/$save_output-${k}.$objext
 	      k=`expr $k + 1`
-	      output=$output_objdir/$output_la-${k}.$objext
+	      output=$output_objdir/$save_output-${k}.$objext
 	      objlist=$obj
 	      len=1
 	    fi
@@ -4092,13 +3838,13 @@
 	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
           fi
 
-	  # Set up a command to remove the reloadable object files
+	  # Set up a command to remove the reloadale object files
 	  # after they are used.
 	  i=0
 	  while test "$i" -lt "$k"
 	  do
 	    i=`expr $i + 1`
-	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
+	    delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
 	  done
 
 	  $echo "creating a temporary reloadable object file: $output"
@@ -4146,30 +3892,13 @@
 	  IFS="$save_ifs"
 	  eval cmd=\"$cmd\"
 	  $show "$cmd"
-	  $run eval "$cmd" || {
-	    lt_exit=$?
-
-	    # Restore the uninstalled library and exit
-	    if test "$mode" = relink; then
-	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
-	    fi
-
-	    exit $lt_exit
-	  }
+	  $run eval "$cmd" || exit $?
 	done
 	IFS="$save_ifs"
 
 	# Restore the uninstalled library and exit
 	if test "$mode" = relink; then
 	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
-
-	  if test -n "$convenience"; then
-	    if test -z "$whole_archive_flag_spec"; then
-	      $show "${rm}r $gentop"
-	      $run ${rm}r "$gentop"
-	    fi
-	  fi
-
 	  exit $EXIT_SUCCESS
 	fi
 
@@ -4247,10 +3976,64 @@
 	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
 	else
 	  gentop="$output_objdir/${obj}x"
+	  $show "${rm}r $gentop"
+	  $run ${rm}r "$gentop"
+	  $show "$mkdir $gentop"
+	  $run $mkdir "$gentop"
+	  status=$?
+	  if test "$status" -ne 0 && test ! -d "$gentop"; then
+	    exit $status
+	  fi
 	  generated="$generated $gentop"
 
-	  func_extract_archives $gentop $convenience
-	  reload_conv_objs="$reload_objs $func_extract_archives_result"
+	  for xlib in $convenience; do
+	    # Extract the objects.
+	    case $xlib in
+	    [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	    *) xabs=`pwd`"/$xlib" ;;
+	    esac
+	    xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	    xdir="$gentop/$xlib"
+
+	    $show "${rm}r $xdir"
+	    $run ${rm}r "$xdir"
+	    $show "$mkdir $xdir"
+	    $run $mkdir "$xdir"
+	    status=$?
+	    if test "$status" -ne 0 && test ! -d "$xdir"; then
+	      exit $status
+	    fi
+	    # We will extract separately just the conflicting names and we will no
+	    # longer touch any unique names. It is faster to leave these extract
+	    # automatically by $AR in one run.
+	    $show "(cd $xdir && $AR x $xabs)"
+	    $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+	    if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+	      :
+	    else
+	      $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+	      $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+	      $AR t "$xabs" | sort | uniq -cd | while read -r count name
+	      do
+		i=1
+		while test "$i" -le "$count"
+		do
+		 # Put our $i before any first dot (extension)
+		 # Never overwrite any file
+		 name_to="$name"
+		 while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+		 do
+		   name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+		 done
+		 $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+		 $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+		 i=`expr $i + 1`
+		done
+	      done
+	    fi
+
+	    reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+	  done
 	fi
       fi
 
@@ -4351,35 +4134,6 @@
         ;;
       esac
 
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-	case " $new_libs " in
-	*" -L$path/$objdir "*) ;;
-	*)
-	  case " $compile_deplibs " in
-	  *" -L$path/$objdir "*)
-	    new_libs="$new_libs -L$path/$objdir" ;;
-	  esac
-	  ;;
-	esac
-      done
-      for deplib in $compile_deplibs; do
-	case $deplib in
-	-L*)
-	  case " $new_libs " in
-	  *" $deplib "*) ;;
-	  *) new_libs="$new_libs $deplib" ;;
-	  esac
-	  ;;
-	*) new_libs="$new_libs $deplib" ;;
-	esac
-      done
-      compile_deplibs="$new_libs"
-
-
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 
@@ -4424,15 +4178,10 @@
 	fi
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
 	  *) dllsearchpath="$dllsearchpath:$libdir";;
 	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  *) dllsearchpath="$dllsearchpath:$testbindir";;
-	  esac
 	  ;;
 	esac
       done
@@ -4546,25 +4295,13 @@
 
 	    # Prepare the list of exported symbols
 	    if test -z "$export_symbols"; then
-	      export_symbols="$output_objdir/$outputname.exp"
+	      export_symbols="$output_objdir/$output.exp"
 	      $run $rm $export_symbols
-	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
-              case $host in
-              *cygwin* | *mingw* )
-	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
-                ;;
-              esac
+	      $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
 	    else
-	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
-	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+	      $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
+	      $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
 	      $run eval 'mv "$nlist"T "$nlist"'
-              case $host in
-              *cygwin* | *mingw* )
-	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
-                ;;
-              esac
 	    fi
 	  fi
 
@@ -4615,26 +4352,7 @@
 #endif
 
 /* The mapping between symbol names and symbols. */
-"
-
-	    case $host in
-	    *cygwin* | *mingw* )
-	  $echo >> "$output_objdir/$dlsyms" "\
-/* DATA imports from DLLs on WIN32 can't be const, because
-   runtime relocations are performed -- see ld's documentation
-   on pseudo-relocs */
-struct {
-"
-	      ;;
-	    * )
-	  $echo >> "$output_objdir/$dlsyms" "\
 const struct {
-"
-	      ;;
-	    esac
-
-
-	  $echo >> "$output_objdir/$dlsyms" "\
   const char *name;
   lt_ptr address;
 }
@@ -4681,29 +4399,16 @@
 	  esac
 
 	  # Now compile the dynamic symbol file.
-	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
-	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+	  $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+	  $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
 
 	  # Clean up the generated files.
 	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
 	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
 
 	  # Transform the symbol file into the correct name.
-          case $host in
-          *cygwin* | *mingw* )
-            if test -f "$output_objdir/${outputname}.def" ; then
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
-            else
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-             fi
-            ;;
-          * )
-            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-            ;;
-          esac
+	  compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+	  finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
 	  ;;
 	*)
 	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
@@ -4728,7 +4433,7 @@
 	# We have no uninstalled library dependencies, so finalize right now.
 	$show "$link_command"
 	$run eval "$link_command"
-	exit_status=$?
+	status=$?
 
 	# Delete the generated files.
 	if test -n "$dlsyms"; then
@@ -4736,7 +4441,7 @@
 	  $run $rm "$output_objdir/${outputname}S.${objext}"
 	fi
 
-	exit $exit_status
+	exit $status
       fi
 
       if test -n "$shlibpath_var"; then
@@ -4876,12 +4581,10 @@
 	esac
 	case $host in
 	  *cygwin* | *mingw* )
-            output_name=`basename $output`
-            output_path=`dirname $output`
-            cwrappersource="$output_path/$objdir/lt-$output_name.c"
-            cwrapper="$output_path/$output_name.exe"
-            $rm $cwrappersource $cwrapper
-            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+	    cwrappersource=`$echo ${objdir}/lt-${output}.c`
+	    cwrapper=`$echo ${output}.exe`
+	    $rm $cwrappersource $cwrapper
+	    trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
 	    cat > $cwrappersource <<EOF
 
@@ -4906,9 +4609,6 @@
 #include <malloc.h>
 #include <stdarg.h>
 #include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/stat.h>
 
 #if defined(PATH_MAX)
 # define LT_PATHMAX PATH_MAX
@@ -4919,19 +4619,15 @@
 #endif
 
 #ifndef DIR_SEPARATOR
-# define DIR_SEPARATOR '/'
-# define PATH_SEPARATOR ':'
+#define DIR_SEPARATOR '/'
 #endif
 
 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
   defined (__OS2__)
-# define HAVE_DOS_BASED_FILE_SYSTEM
-# ifndef DIR_SEPARATOR_2
-#  define DIR_SEPARATOR_2 '\\'
-# endif
-# ifndef PATH_SEPARATOR_2
-#  define PATH_SEPARATOR_2 ';'
-# endif
+#define HAVE_DOS_BASED_FILE_SYSTEM
+#ifndef DIR_SEPARATOR_2
+#define DIR_SEPARATOR_2 '\\'
+#endif
 #endif
 
 #ifndef DIR_SEPARATOR_2
@@ -4941,32 +4637,17 @@
         (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
 #endif /* DIR_SEPARATOR_2 */
 
-#ifndef PATH_SEPARATOR_2
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
-#else /* PATH_SEPARATOR_2 */
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
-#endif /* PATH_SEPARATOR_2 */
-
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
   if (stale) { free ((void *) stale); stale = 0; } \
 } while (0)
 
-/* -DDEBUG is fairly common in CFLAGS.  */
-#undef DEBUG
-#if defined DEBUGWRAPPER
-# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
-#else
-# define DEBUG(format, ...)
-#endif
-
 const char *program_name = NULL;
 
 void * xmalloc (size_t num);
 char * xstrdup (const char *string);
-const char * base_name (const char *name);
-char * find_executable(const char *wrapper);
-int    check_executable(const char *path);
+char * basename (const char *name);
+char * fnqualify(const char *path);
 char * strendzap(char *str, const char *pat);
 void lt_fatal (const char *message, ...);
 
@@ -4976,51 +4657,29 @@
   char **newargz;
   int i;
 
-  program_name = (char *) xstrdup (base_name (argv[0]));
-  DEBUG("(main) argv[0]      : %s\n",argv[0]);
-  DEBUG("(main) program_name : %s\n",program_name);
+  program_name = (char *) xstrdup ((char *) basename (argv[0]));
   newargz = XMALLOC(char *, argc+2);
 EOF
 
-            cat >> $cwrappersource <<EOF
-  newargz[0] = (char *) xstrdup("$SHELL");
+	    cat >> $cwrappersource <<EOF
+  newargz[0] = "$SHELL";
 EOF
 
-            cat >> $cwrappersource <<"EOF"
-  newargz[1] = find_executable(argv[0]);
-  if (newargz[1] == NULL)
-    lt_fatal("Couldn't find %s", argv[0]);
-  DEBUG("(main) found exe at : %s\n",newargz[1]);
+	    cat >> $cwrappersource <<"EOF"
+  newargz[1] = fnqualify(argv[0]);
   /* we know the script has the same name, without the .exe */
   /* so make sure newargz[1] doesn't end in .exe */
   strendzap(newargz[1],".exe");
   for (i = 1; i < argc; i++)
     newargz[i+1] = xstrdup(argv[i]);
   newargz[argc+1] = NULL;
-
-  for (i=0; i<argc+1; i++)
-  {
-    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
-    ;
-  }
-
 EOF
 
-            case $host_os in
-              mingw*)
-                cat >> $cwrappersource <<EOF
-  execv("$SHELL",(char const **)newargz);
-EOF
-              ;;
-              *)
-                cat >> $cwrappersource <<EOF
+	    cat >> $cwrappersource <<EOF
   execv("$SHELL",newargz);
 EOF
-              ;;
-            esac
 
-            cat >> $cwrappersource <<"EOF"
-  return 127;
+	    cat >> $cwrappersource <<"EOF"
 }
 
 void *
@@ -5040,148 +4699,48 @@
 ;
 }
 
-const char *
-base_name (const char *name)
+char *
+basename (const char *name)
 {
   const char *base;
 
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
   /* Skip over the disk name in MSDOS pathnames. */
-  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
+  if (isalpha (name[0]) && name[1] == ':')
     name += 2;
 #endif
 
   for (base = name; *name; name++)
     if (IS_DIR_SEPARATOR (*name))
       base = name + 1;
-  return base;
-}
-
-int
-check_executable(const char * path)
-{
-  struct stat st;
-
-  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
-  if ((!path) || (!*path))
-    return 0;
-
-  if ((stat (path, &st) >= 0) &&
-      (
-        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
-#if defined (S_IXOTH)
-       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
-#endif
-#if defined (S_IXGRP)
-       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
-#endif
-       ((st.st_mode & S_IXUSR) == S_IXUSR))
-      )
-    return 1;
-  else
-    return 0;
+  return (char *) base;
 }
 
-/* Searches for the full path of the wrapper.  Returns
-   newly allocated full path name if found, NULL otherwise */
 char *
-find_executable (const char* wrapper)
+fnqualify(const char *path)
 {
-  int has_slash = 0;
-  const char* p;
-  const char* p_next;
-  /* static buffer for getcwd */
+  size_t size;
+  char *p;
   char tmp[LT_PATHMAX + 1];
-  int tmp_len;
-  char* concat_name;
 
-  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
+  assert(path != NULL);
 
-  if ((wrapper == NULL) || (*wrapper == '\0'))
-    return NULL;
-
-  /* Absolute path? */
+  /* Is it qualified already? */
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
-  {
-    concat_name = xstrdup (wrapper);
-    if (check_executable(concat_name))
-      return concat_name;
-    XFREE(concat_name);
-  }
-  else
-  {
-#endif
-    if (IS_DIR_SEPARATOR (wrapper[0]))
-    {
-      concat_name = xstrdup (wrapper);
-      if (check_executable(concat_name))
-        return concat_name;
-      XFREE(concat_name);
-    }
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  }
+  if (isalpha (path[0]) && path[1] == ':')
+    return xstrdup (path);
 #endif
+  if (IS_DIR_SEPARATOR (path[0]))
+    return xstrdup (path);
 
-  for (p = wrapper; *p; p++)
-    if (*p == '/')
-    {
-      has_slash = 1;
-      break;
-    }
-  if (!has_slash)
-  {
-    /* no slashes; search PATH */
-    const char* path = getenv ("PATH");
-    if (path != NULL)
-    {
-      for (p = path; *p; p = p_next)
-      {
-        const char* q;
-        size_t p_len;
-        for (q = p; *q; q++)
-          if (IS_PATH_SEPARATOR(*q))
-            break;
-        p_len = q - p;
-        p_next = (*q == '\0' ? q : q + 1);
-        if (p_len == 0)
-        {
-          /* empty path: current directory */
-          if (getcwd (tmp, LT_PATHMAX) == NULL)
-            lt_fatal ("getcwd failed");
-          tmp_len = strlen(tmp);
-          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
-          memcpy (concat_name, tmp, tmp_len);
-          concat_name[tmp_len] = '/';
-          strcpy (concat_name + tmp_len + 1, wrapper);
-        }
-        else
-        {
-          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
-          memcpy (concat_name, p, p_len);
-          concat_name[p_len] = '/';
-          strcpy (concat_name + p_len + 1, wrapper);
-        }
-        if (check_executable(concat_name))
-          return concat_name;
-        XFREE(concat_name);
-      }
-    }
-    /* not found in PATH; assume curdir */
-  }
-  /* Relative path | not found in path: prepend cwd */
+  /* prepend the current directory */
+  /* doesn't handle '~' */
   if (getcwd (tmp, LT_PATHMAX) == NULL)
     lt_fatal ("getcwd failed");
-  tmp_len = strlen(tmp);
-  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
-  memcpy (concat_name, tmp, tmp_len);
-  concat_name[tmp_len] = '/';
-  strcpy (concat_name + tmp_len + 1, wrapper);
-
-  if (check_executable(concat_name))
-    return concat_name;
-  XFREE(concat_name);
-  return NULL;
+  size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
+  p = XMALLOC(char, size);
+  sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
+  return p;
 }
 
 char *
@@ -5225,16 +4784,16 @@
   va_end (ap);
 }
 EOF
-          # we should really use a build-platform specific compiler
-          # here, but OTOH, the wrappers (shell script and this C one)
-          # are only useful if you want to execute the "real" binary.
-          # Since the "real" binary is built for $host, then this
-          # wrapper might as well be built for $host, too.
-          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
-          ;;
-        esac
-        $rm $output
-        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
+	  # we should really use a build-platform specific compiler
+	  # here, but OTOH, the wrappers (shell script and this C one)
+	  # are only useful if you want to execute the "real" binary.
+	  # Since the "real" binary is built for $host, then this
+	  # wrapper might as well be built for $host, too.
+	  $run $LTCC -s -o $cwrapper $cwrappersource
+	  ;;
+	esac
+	$rm $output
+	trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
 
 	$echo > $output "\
 #! $SHELL
@@ -5255,7 +4814,7 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
 
 relink_command=\"$relink_command\"
 
@@ -5384,13 +4943,13 @@
 	# Backslashes separate directories on plain windows
 	*-*-mingw | *-*-os2*)
 	  $echo >> $output "\
-      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+      exec \$progdir\\\\\$program \${1+\"\$@\"}
 "
 	  ;;
 
 	*)
 	  $echo >> $output "\
-      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+      exec \$progdir/\$program \${1+\"\$@\"}
 "
 	  ;;
 	esac
@@ -5400,7 +4959,7 @@
     fi
   else
     # The program doesn't exist.
-    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
     \$echo \"This script is just a wrapper for \$program.\" 1>&2
     $echo \"See the $PACKAGE documentation for more information.\" 1>&2
     exit $EXIT_FAILURE
@@ -5432,73 +4991,71 @@
 
       if test -n "$addlibs"; then
 	gentop="$output_objdir/${outputname}x"
+	$show "${rm}r $gentop"
+	$run ${rm}r "$gentop"
+	$show "$mkdir $gentop"
+	$run $mkdir "$gentop"
+	status=$?
+	if test "$status" -ne 0 && test ! -d "$gentop"; then
+	  exit $status
+	fi
 	generated="$generated $gentop"
 
-	func_extract_archives $gentop $addlibs
-	oldobjs="$oldobjs $func_extract_archives_result"
+	# Add in members from convenience archives.
+	for xlib in $addlibs; do
+	  # Extract the objects.
+	  case $xlib in
+	  [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	  *) xabs=`pwd`"/$xlib" ;;
+	  esac
+	  xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	  xdir="$gentop/$xlib"
+
+	  $show "${rm}r $xdir"
+	  $run ${rm}r "$xdir"
+	  $show "$mkdir $xdir"
+	  $run $mkdir "$xdir"
+	  status=$?
+	  if test "$status" -ne 0 && test ! -d "$xdir"; then
+	    exit $status
+	  fi
+	  # We will extract separately just the conflicting names and we will no
+	  # longer touch any unique names. It is faster to leave these extract
+	  # automatically by $AR in one run.
+	  $show "(cd $xdir && $AR x $xabs)"
+	  $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+	  if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+	    :
+	  else
+	    $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+	    $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+	    $AR t "$xabs" | sort | uniq -cd | while read -r count name
+	    do
+	      i=1
+	      while test "$i" -le "$count"
+	      do
+	       # Put our $i before any first dot (extension)
+	       # Never overwrite any file
+	       name_to="$name"
+	       while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+	       do
+		 name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+	       done
+	       $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+	       $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+	       i=`expr $i + 1`
+	      done
+	    done
+	  fi
+
+	  oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
+	done
       fi
 
       # Do each command in the archive commands.
       if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
        cmds=$old_archive_from_new_cmds
       else
-	# POSIX demands no paths to be encoded in archives.  We have
-	# to avoid creating archives with duplicate basenames if we
-	# might have to extract them afterwards, e.g., when creating a
-	# static archive out of a convenience library, or when linking
-	# the entirety of a libtool archive into another (currently
-	# not supported by libtool).
-	if (for obj in $oldobjs
-	    do
-	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
-	    done | sort | sort -uc >/dev/null 2>&1); then
-	  :
-	else
-	  $echo "copying selected object files to avoid basename conflicts..."
-
-	  if test -z "$gentop"; then
-	    gentop="$output_objdir/${outputname}x"
-	    generated="$generated $gentop"
-
-	    $show "${rm}r $gentop"
-	    $run ${rm}r "$gentop"
-	    $show "$mkdir $gentop"
-	    $run $mkdir "$gentop"
-	    exit_status=$?
-	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
-	      exit $exit_status
-	    fi
-	  fi
-
-	  save_oldobjs=$oldobjs
-	  oldobjs=
-	  counter=1
-	  for obj in $save_oldobjs
-	  do
-	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
-	    case " $oldobjs " in
-	    " ") oldobjs=$obj ;;
-	    *[\ /]"$objbase "*)
-	      while :; do
-		# Make sure we don't pick an alternate name that also
-		# overlaps.
-		newobj=lt$counter-$objbase
-		counter=`expr $counter + 1`
-		case " $oldobjs " in
-		*[\ /]"$newobj "*) ;;
-		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
-		esac
-	      done
-	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
-	      $run ln "$obj" "$gentop/$newobj" ||
-	      $run cp "$obj" "$gentop/$newobj"
-	      oldobjs="$oldobjs $gentop/$newobj"
-	      ;;
-	    *) oldobjs="$oldobjs $obj" ;;
-	    esac
-	  done
-	fi
-
 	eval cmds=\"$old_archive_cmds\"
 
 	if len=`expr "X$cmds" : ".*"` &&
@@ -5512,7 +5069,20 @@
 	  objlist=
 	  concat_cmds=
 	  save_oldobjs=$oldobjs
-
+	  # GNU ar 2.10+ was changed to match POSIX; thus no paths are
+	  # encoded into archives.  This makes 'ar r' malfunction in
+	  # this piecewise linking case whenever conflicting object
+	  # names appear in distinct ar calls; check, warn and compensate.
+	    if (for obj in $save_oldobjs
+	    do
+	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
+	    done | sort | sort -uc >/dev/null 2>&1); then
+	    :
+	  else
+	    $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
+	    $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
+	    AR_FLAGS=cq
+	  fi
 	  # Is there a better way of finding the last object in the list?
 	  for obj in $save_oldobjs
 	  do
@@ -5523,7 +5093,7 @@
 	    oldobjs="$objlist $obj"
 	    objlist="$objlist $obj"
 	    eval test_cmds=\"$old_archive_cmds\"
-	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+	    if len=`expr "X$test_cmds" : ".*"` &&
 	       test "$len" -le "$max_cmd_len"; then
 	      :
 	    else
@@ -5720,11 +5290,11 @@
     # install_prog (especially on Windows NT).
     if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
        # Allow the use of GNU shtool's install command.
-       $echo "X$nonopt" | grep shtool > /dev/null; then
+       $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
       # Aesthetically quote it.
       arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
       case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
 	arg="\"$arg\""
 	;;
       esac
@@ -5733,14 +5303,14 @@
       shift
     else
       install_prog=
-      arg=$nonopt
+      arg="$nonopt"
     fi
 
     # The real first argument should be the name of the installation program.
     # Aesthetically quote it.
     arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
     case $arg in
-    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
       arg="\"$arg\""
       ;;
     esac
@@ -5758,31 +5328,28 @@
     do
       if test -n "$dest"; then
 	files="$files $dest"
-	dest=$arg
+	dest="$arg"
 	continue
       fi
 
       case $arg in
       -d) isdir=yes ;;
-      -f) 
-      	case " $install_prog " in
-	*[\\\ /]cp\ *) ;;
-	*) prev=$arg ;;
-	esac
-	;;
-      -g | -m | -o) prev=$arg ;;
+      -f) prev="-f" ;;
+      -g) prev="-g" ;;
+      -m) prev="-m" ;;
+      -o) prev="-o" ;;
       -s)
 	stripme=" -s"
 	continue
 	;;
-      -*)
-	;;
+      -*) ;;
+
       *)
 	# If the previous option needed an argument, then skip it.
 	if test -n "$prev"; then
 	  prev=
 	else
-	  dest=$arg
+	  dest="$arg"
 	  continue
 	fi
 	;;
@@ -5791,7 +5358,7 @@
       # Aesthetically quote the argument.
       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
       case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
 	arg="\"$arg\""
 	;;
       esac
@@ -5960,14 +5527,11 @@
 
 	  if test "$#" -gt 0; then
 	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
-	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
-	    # so we also need to try rm && ln -s.
 	    for linkname
 	    do
 	      if test "$linkname" != "$realname"; then
-                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
-                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+		$show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+		$run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
 	      fi
 	    done
 	  fi
@@ -5980,16 +5544,7 @@
 	    IFS="$save_ifs"
 	    eval cmd=\"$cmd\"
 	    $show "$cmd"
-	    $run eval "$cmd" || {
-	      lt_exit=$?
-
-	      # Restore the uninstalled library and exit
-	      if test "$mode" = relink; then
-		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
-	      fi
-
-	      exit $lt_exit
-	    }
+	    $run eval "$cmd" || exit $?
 	  done
 	  IFS="$save_ifs"
 	fi
@@ -6083,15 +5638,17 @@
 	  notinst_deplibs=
 	  relink_command=
 
-	  # Note that it is not necessary on cygwin/mingw to append a dot to
-	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
-	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-	  # `FILE.' does not work on cygwin managed mounts.
-	  #
+	  # To insure that "foo" is sourced, and not "foo.exe",
+	  # finese the cygwin/MSYS system by explicitly sourcing "foo."
+	  # which disallows the automatic-append-.exe behavior.
+	  case $build in
+	  *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+	  *) wrapperdot=${wrapper} ;;
+	  esac
 	  # If there is no directory component, then add one.
-	  case $wrapper in
-	  */* | *\\*) . ${wrapper} ;;
-	  *) . ./${wrapper} ;;
+	  case $file in
+	  */* | *\\*) . ${wrapperdot} ;;
+	  *) . ./${wrapperdot} ;;
 	  esac
 
 	  # Check the variables that should have been set.
@@ -6119,21 +5676,34 @@
 	  done
 
 	  relink_command=
-	  # Note that it is not necessary on cygwin/mingw to append a dot to
-	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
-	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-	  # `FILE.' does not work on cygwin managed mounts.
-	  #
+	  # To insure that "foo" is sourced, and not "foo.exe",
+	  # finese the cygwin/MSYS system by explicitly sourcing "foo."
+	  # which disallows the automatic-append-.exe behavior.
+	  case $build in
+	  *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+	  *) wrapperdot=${wrapper} ;;
+	  esac
 	  # If there is no directory component, then add one.
-	  case $wrapper in
-	  */* | *\\*) . ${wrapper} ;;
-	  *) . ./${wrapper} ;;
+	  case $file in
+	  */* | *\\*) . ${wrapperdot} ;;
+	  *) . ./${wrapperdot} ;;
 	  esac
 
 	  outputname=
 	  if test "$fast_install" = no && test -n "$relink_command"; then
 	    if test "$finalize" = yes && test -z "$run"; then
-	      tmpdir=`func_mktempdir`
+	      tmpdir="/tmp"
+	      test -n "$TMPDIR" && tmpdir="$TMPDIR"
+	      tmpdir="$tmpdir/libtool-$$"
+	      save_umask=`umask`
+	      umask 0077
+	      if $mkdir "$tmpdir"; then
+	        umask $save_umask
+	      else
+	        umask $save_umask
+		$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
+		continue
+	      fi
 	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
 	      outputname="$tmpdir/$file"
 	      # Replace the output file specification.
@@ -6157,7 +5727,7 @@
 	fi
 
 	# remove .exe since cygwin /usr/bin/install will append another
-	# one anyway 
+	# one anyways
 	case $install_prog,$host in
 	*/usr/bin/install*,*cygwin*)
 	  case $file:$destfile in
@@ -6257,7 +5827,7 @@
     # Exit here if they wanted silent mode.
     test "$show" = : && exit $EXIT_SUCCESS
 
-    $echo "X----------------------------------------------------------------------" | $Xsed
+    $echo "----------------------------------------------------------------------"
     $echo "Libraries have been installed in:"
     for libdir in $libdirs; do
       $echo "   $libdir"
@@ -6290,7 +5860,7 @@
     $echo
     $echo "See any operating system documentation about shared libraries for"
     $echo "more information, such as the ld(1) and ld.so(8) manual pages."
-    $echo "X----------------------------------------------------------------------" | $Xsed
+    $echo "----------------------------------------------------------------------"
     exit $EXIT_SUCCESS
     ;;
 
@@ -6507,17 +6077,9 @@
 	    rmfiles="$rmfiles $objdir/$n"
 	  done
 	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+	  test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
 
-	  case "$mode" in
-	  clean)
-	    case "  $library_names " in
-	    # "  " in the beginning catches empty $dlname
-	    *" $dlname "*) ;;
-	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
-	    esac
-	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
-	    ;;
-	  uninstall)
+	  if test "$mode" = uninstall; then
 	    if test -n "$library_names"; then
 	      # Do each command in the postuninstall commands.
 	      cmds=$postuninstall_cmds
@@ -6550,8 +6112,7 @@
 	      IFS="$save_ifs"
 	    fi
 	    # FIXME: should reinstall the best remaining shared library.
-	    ;;
-	  esac
+	  fi
 	fi
 	;;
 
@@ -6836,7 +6397,7 @@
 $echo
 $echo "Try \`$modename --help' for more information about other modes."
 
-exit $?
+exit $EXIT_SUCCESS
 
 # The TAGs below are defined such that we never get into a situation
 # in which we disable both kinds of libraries.  Given conflicting
@@ -6850,11 +6411,12 @@
 # configuration.  But we'll never go from static-only to shared-only.
 
 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-disable_libs=shared
+build_libtool_libs=no
+build_old_libs=yes
 # ### END LIBTOOL TAG CONFIG: disable-shared
 
 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
-disable_libs=static
+build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
 # ### END LIBTOOL TAG CONFIG: disable-static
 
 # Local Variables:

Modified: freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4	(original)
+++ freeswitch/trunk/libs/sofia-sip/m4/sac-general.m4	Sat Feb 17 01:25:21 2007
@@ -276,7 +276,7 @@
 AC_DEFUN([AC_C_VAR_FUNC],
 [AC_REQUIRE([AC_PROG_CC])
 AC_CACHE_CHECK(whether $CC recognizes __func__, ac_cv_c_var_func,
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[const char *s = __func__;
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[char *s = __func__;
 ]])],[ac_cv_c_var_func=yes],[ac_cv_c_var_func=no]))
 if test $ac_cv_c_var_func = "yes"; then
 AC_DEFINE([HAVE_FUNC], 1, [Define to 1 if the C compiler supports __func__]) 

Modified: freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4	(original)
+++ freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4	Sat Feb 17 01:25:21 2007
@@ -46,14 +46,6 @@
   SAC_SU_DEFINE([SU_HAVE_PTHREADS], 1, [Sofia SU uses pthreads])
 fi
 
-AC_ARG_ENABLE(experimental,
-[  --enable-experimental       enable experimental features (disabled)],
- , enable_experimental=no)
-
-if test $enable_experimental = yes ; then
-  SAC_SU_DEFINE([SU_HAVE_EXPERIMENTAL], 1, [Enable experimental features])
-fi
-
 dnl ===========================================================================
 dnl Checks for typedefs, headers, structures, and compiler characteristics.
 dnl ===========================================================================
@@ -127,17 +119,21 @@
 ### Test if we have stack suitable for handling tags directly
 ###
 
+test -z "$ac_cv_tagstack" && 
+case "$target" in 
+i?86-*-* ) ac_cv_tagstack=yes ;;
+esac
+
 AC_CACHE_CHECK([for stack suitable for tags],[ac_cv_tagstack],[
 ac_cv_tagstack=no
 
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
+AC_RUN_IFELSE([
 #if HAVE_INTTYPES_H
 #include <inttypes.h>
 #endif
 #if HAVE_STDINT_H
 #include <stdint.h>
 #endif
-
 #include <stdarg.h>
 
 typedef void *tp;
@@ -173,12 +169,7 @@
 	       (tv)1, (tv)2, (tv)3, (tv)4, (tv)5,
 	       (tv)6, (tv)7, (tv)8, (tv)9, (tv)10);
 }
-]])],[ac_cv_tagstack=yes],[ac_cv_tagstack=no],[
-case "$target" in 
-i?86-*-* ) ac_cv_tagstack=yes ;;
-* ) ac_cv_tagstack=no ;;
-esac
-])])
+],[ac_cv_tagstack=yes],[ac_cv_tagstack=no],[ac_cv_tagstack=no])])
 
 if test $ac_cv_tagstack = yes ; then
 SAC_SU_DEFINE([SU_HAVE_TAGSTACK], 1, [
@@ -236,10 +227,9 @@
      GetSystemTimeAsFileTime().])
 ],[
 dnl no winsock2
-
 SAC_SU_DEFINE([SU_HAVE_BSDSOCK], 1, [Define to 1 if you have BSD socket interface])
 AC_CHECK_HEADERS([sys/socket.h sys/ioctl.h sys/filio.h sys/sockio.h \
-		  sys/select.h sys/epoll.h])
+		  sys/select.h])
 AC_CHECK_HEADERS([netinet/in.h arpa/inet.h netdb.h \
                   net/if.h net/if_types.h ifaddr.h netpacket/packet.h],,,
 		[
@@ -439,12 +429,9 @@
 AC_SEARCH_LIBS(gethostbyname, xnet nsl)
 AC_SEARCH_LIBS(getaddrinfo, xnet socket nsl)
 
-AC_FUNC_ALLOCA
-
-AC_CHECK_FUNCS([gettimeofday strerror random initstate tcsetattr flock \
+AC_CHECK_FUNCS([gettimeofday strerror random initstate tcsetattr flock alarm \
                 socketpair gethostname gethostbyname getipnodebyname \
                 poll epoll_create select if_nameindex \
-		signal alarm \
 	        getaddrinfo getnameinfo freeaddrinfo gai_strerror getifaddrs \
                 getline getdelim getpass])
 # getline getdelim getpass are _GNU_SOURCE stuff
@@ -453,8 +440,7 @@
   SAC_SU_DEFINE([SU_HAVE_POLL], 1, [Define to 1 if you have poll().])
 fi
 
-if test $ac_cv_func_epoll_create = yes && test $ac_cv_header_sys_epoll_h = yes
-then
+if test $ac_cv_func_epoll_create = yes ; then
   AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if you have epoll interface.])
 fi
 
@@ -469,32 +455,8 @@
 fi
 
 SAC_REPLACE_FUNCS([memmem memccpy memspn memcspn strcasestr strtoull \
-		   inet_ntop inet_pton poll])
-
-if test $ac_cv_func_signal = yes ; then
-AC_CHECK_DECL([SIGPIPE], [
-AC_DEFINE([HAVE_SIGPIPE], 1, [Define to 1 if you have SIGPIPE])],,[
-#include <signal.h>
-])
-dnl add SIGHUP SIGQUIT if needed
-fi
+		   inet_ntop inet_pton])
 
-# ===========================================================================
-# Check how to implement su_port
-# ===========================================================================
-
-AC_ARG_ENABLE(poll-port,
-[  --disable-poll-port              disable su_poll_port (enabled)
-                                   Use this option in systems emulating poll
-                                   with select], , enable_poll_port=maybe)
-
-if test $enable_poll_port = maybe ; then
-  if test $ac_cv_func_poll = yes ; then
-    AC_DEFINE([HAVE_POLL_PORT], 1, [Define to 1 if you use poll in su_port.])
-  fi
-elif test $enable_poll_port = yes ; then
-    AC_DEFINE([HAVE_POLL_PORT], 1, [Define to 1 if you use poll in su_port.])
-fi
 
 # ===========================================================================
 # Check pthread_rwlock_unlock()

Modified: freeswitch/trunk/libs/sofia-sip/packages/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/packages/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/packages/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -78,7 +78,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -125,12 +124,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -174,7 +169,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@

Modified: freeswitch/trunk/libs/sofia-sip/packages/sofia-sip.spec.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/packages/sofia-sip.spec.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/packages/sofia-sip.spec.in	Sat Feb 17 01:25:21 2007
@@ -12,15 +12,15 @@
 
 BuildRequires: pkgconfig
 
-%define opt_with() %{expand:%%global with_%{1} %%{?_with_%{1}:1}%%{?!_with_%{1}:0}}
-%define opt_without() %{expand:%%global with_%{1} %%{!?_without_%{1}:1}%%{?_without_%{1}:0}}
+%{!?bcond_with:%define bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}}
+%{!?bcond_without:%define bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}}
 
 # Options: 
-%opt_with doxygen	- Generate documents using doxygen and dot
-%opt_with check		- Run tests
-%opt_with openssl	- Always use OpenSSL (TLS)
-%opt_with glib		- Always use glib-2.0 (>= 2.2)
-%opt_with sctp		- Include SCTP transport
+%bcond_with doxygen	- Generate documents using doxygen and dot
+%bcond_with check	- Run tests
+%bcond_with openssl	- Always use OpenSSL (TLS)
+%bcond_with glib	- Always use glib-2.0 (>= 2.2)
+%bcond_with sctp	- Include SCTP transport
 
 %define have_doxygen %{?_with_doxygen:1}%{!?_with_doxygen:0}
 %define have_openssl %(%{?!_with_openssl:pkg-config 'openssl >= 0.9.7'&&}echo 1||echo 0)
@@ -49,7 +49,7 @@
 %if !%{have_glib}
 options="$options --without-glib"
 %endif
-%if %{with_sctp}
+%if %{with sctp}
 options="$options --enable-sctp"
 %endif
 
@@ -62,7 +62,7 @@
 
 # XXX comment next line to build with non-check aware rpmbuild.
 %check
-%if %{with_check}
+%if %{with check}
 make check
 %endif
 
@@ -126,7 +126,7 @@
 Development package for Sofia SIP UA library. This package includes 
 static libraries and include files.
 
-%if !%{with_doxygen}
+%if %{without doxygen}
 The reference documentation for Sofia SIP UA library is available at 
 <http://sofia-sip.sourceforge.net/development.html>
 %endif

Modified: freeswitch/trunk/libs/sofia-sip/utils/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/utils/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/utils/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -104,7 +104,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -151,12 +150,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -200,7 +195,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@

Modified: freeswitch/trunk/libs/sofia-sip/utils/sip-options.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/utils/sip-options.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/utils/sip-options.c	Sat Feb 17 01:25:21 2007
@@ -331,7 +331,7 @@
   return context->c_retval;
 }
 
-/** Handle responses to OPTIONS request */
+/** Handle responses to registration request */
 static
 int response_to_options(context_t *context,
 			nta_outgoing_t *oreq,
@@ -355,17 +355,13 @@
 	    sip_is_content_length(h))
 	  continue;
       }
-
-      if (h->sh_class->hc_name == NULL) {
-	sl_header_print(stdout, NULL, h);
-      } 
-      else if (h->sh_class->hc_name[0] == '\0') {
-	sl_header_print(stdout, "%s\n", h); 
-      }
-      else {
+      if (h->sh_class->hc_name) {
 	snprintf(hname, sizeof hname, "%s: %%s\n", h->sh_class->hc_name);
 	sl_header_print(stdout, hname, h); 
       }
+      else {
+	sl_header_print(stdout, NULL, h); 
+      }
     }
   }
   

Modified: freeswitch/trunk/libs/sofia-sip/win32/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/win32/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/win32/Makefile.am	Sat Feb 17 01:25:21 2007
@@ -44,31 +44,6 @@
 	autogen.cmd build_sources.cmd version_files.cmd version.awk \
 	install.cmd check.cmd
 
-# VC2005 Project files
-EXTRA_DIST += SofiaSIP.sln \
-    libsofia-sip-ua-static/libsofia_sip_ua_static.vcproj \
-    libsofia-sip-ua/libsofia_sip_ua.vcproj \
-    tests/test_htable/test_htable.vcproj \
-    tests/test_memmem/test_memmem.vcproj \
-    tests/test_nta/test_nta.vcproj \
-    tests/test_nua/test_nua.vcproj \
-    tests/test_su/test_su.vcproj \
-    tests/test_tport/test_tport.vcproj \
-    tests/torture_rbtree/torture_rbtree.vcproj \
-    tests/torture_su/torture_su.vcproj \
-    tests/torture_su_alloc/torture_su_alloc.vcproj \
-    tests/torture_su_bm/torture_su_bm.vcproj \
-    tests/torture_su_port/torture_su_port.vcproj \
-    tests/torture_su_root/torture_su_root.vcproj \
-    tests/torture_su_tag/torture_su_tag.vcproj \
-    tests/torture_su_time/torture_su_time.vcproj \
-    tests/torture_su_timer/torture_su_timer.vcproj \
-    utils/localinfo/localinfo.vcproj \
-    utils/sip_dig/sip_dig.vcproj \
-    utils/sip_options/sip_options.vcproj \
-    utils/sip_options_static/sip_options_static.vcproj \
-    utils/stunc/stunc.vcproj
-
 PTHREAD_DIST = \
 	pthread/ChangeLog \
 	pthread/md5.sum.txt \

Modified: freeswitch/trunk/libs/sofia-sip/win32/Makefile.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/win32/Makefile.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/win32/Makefile.in	Sat Feb 17 01:25:21 2007
@@ -71,7 +71,6 @@
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
-ALLOCA = @ALLOCA@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -118,12 +117,8 @@
 HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
 HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
 HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
-HAVE_NTH_FALSE = @HAVE_NTH_FALSE@
-HAVE_NTH_TRUE = @HAVE_NTH_TRUE@
 HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
 HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
-HAVE_STUN_FALSE = @HAVE_STUN_FALSE@
-HAVE_STUN_TRUE = @HAVE_STUN_TRUE@
 HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
 HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
@@ -167,7 +162,6 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SOFIA_CFLAGS = @SOFIA_CFLAGS@
-SOFIA_COVERAGE = @SOFIA_COVERAGE@
 SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
 STRIP = @STRIP@
 TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
@@ -223,13 +217,14 @@
 target_os = @target_os@
 target_vendor = @target_vendor@
 noinst_HEADERS = sofia-sip/su_configure.h unistd.h config.h
-
-# VC2005 Project files
-EXTRA_DIST = SofiaSIP.dsw libsofia-sip-ua/libsofia_sip_ua.dsp \
+EXTRA_DIST = SofiaSIP.dsw \
+	libsofia-sip-ua/libsofia_sip_ua.dsp \
 	libsofia-sip-ua/sofia-sip-ua.def \
 	libsofia-sip-ua-static/libsofia_sip_ua_static.dsp \
-	tests/test_nua/test_nua.dsp tests/test_nua/test_nat_tags.cpp \
-	tests/test_nta/test_nta.dsp tests/test_tport/test_tport.dsp \
+	tests/test_nua/test_nua.dsp \
+	tests/test_nua/test_nat_tags.cpp \
+	tests/test_nta/test_nta.dsp \
+	tests/test_tport/test_tport.dsp \
 	tests/test_tport/test_class.cpp \
 	tests/test_tport/test_table.cpp \
 	tests/torture_su_alloc/torture_su_alloc.dsp \
@@ -245,30 +240,14 @@
 	tests/torture_su_bm/torture_su_bm.dsp \
 	tests/torture_su_port/torture_su_port.dsp \
 	utils/localinfo/localinfo.dsp \
-	utils/sip_options/sip_options.dsp utils/sip_dig/sip_dig.dsp \
-	utils/stunc/stunc.dsp $(PTHREAD_DIST) README.txt autogen.cmd \
-	build_sources.cmd version_files.cmd version.awk install.cmd \
-	check.cmd SofiaSIP.sln \
-	libsofia-sip-ua-static/libsofia_sip_ua_static.vcproj \
-	libsofia-sip-ua/libsofia_sip_ua.vcproj \
-	tests/test_htable/test_htable.vcproj \
-	tests/test_memmem/test_memmem.vcproj \
-	tests/test_nta/test_nta.vcproj tests/test_nua/test_nua.vcproj \
-	tests/test_su/test_su.vcproj \
-	tests/test_tport/test_tport.vcproj \
-	tests/torture_rbtree/torture_rbtree.vcproj \
-	tests/torture_su/torture_su.vcproj \
-	tests/torture_su_alloc/torture_su_alloc.vcproj \
-	tests/torture_su_bm/torture_su_bm.vcproj \
-	tests/torture_su_port/torture_su_port.vcproj \
-	tests/torture_su_root/torture_su_root.vcproj \
-	tests/torture_su_tag/torture_su_tag.vcproj \
-	tests/torture_su_time/torture_su_time.vcproj \
-	tests/torture_su_timer/torture_su_timer.vcproj \
-	utils/localinfo/localinfo.vcproj utils/sip_dig/sip_dig.vcproj \
-	utils/sip_options/sip_options.vcproj \
-	utils/sip_options_static/sip_options_static.vcproj \
-	utils/stunc/stunc.vcproj
+	utils/sip_options/sip_options.dsp \
+	utils/sip_dig/sip_dig.dsp \
+	utils/stunc/stunc.dsp \
+	$(PTHREAD_DIST) \
+	README.txt \
+	autogen.cmd build_sources.cmd version_files.cmd version.awk \
+	install.cmd check.cmd
+
 PTHREAD_DIST = \
 	pthread/ChangeLog \
 	pthread/md5.sum.txt \
@@ -372,7 +351,7 @@
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-	$(mkdir_p) $(distdir)/libsofia-sip-ua $(distdir)/libsofia-sip-ua-static $(distdir)/pthread $(distdir)/sofia-sip $(distdir)/tests/test_htable $(distdir)/tests/test_memmem $(distdir)/tests/test_nta $(distdir)/tests/test_nua $(distdir)/tests/test_su $(distdir)/tests/test_tport $(distdir)/tests/torture_rbtree $(distdir)/tests/torture_su $(distdir)/tests/torture_su_alloc $(distdir)/tests/torture_su_bm $(distdir)/tests/torture_su_port $(distdir)/tests/torture_su_root $(distdir)/tests/torture_su_tag $(distdir)/tests/torture_su_time $(distdir)/tests/torture_su_timer $(distdir)/utils/localinfo $(distdir)/utils/sip_dig $(distdir)/utils/sip_options $(distdir)/utils/sip_options_static $(distdir)/utils/stunc
+	$(mkdir_p) $(distdir)/libsofia-sip-ua $(distdir)/libsofia-sip-ua-static $(distdir)/pthread $(distdir)/sofia-sip $(distdir)/tests/test_htable $(distdir)/tests/test_memmem $(distdir)/tests/test_nta $(distdir)/tests/test_nua $(distdir)/tests/test_su $(distdir)/tests/test_tport $(distdir)/tests/torture_rbtree $(distdir)/tests/torture_su $(distdir)/tests/torture_su_alloc $(distdir)/tests/torture_su_bm $(distdir)/tests/torture_su_port $(distdir)/tests/torture_su_root $(distdir)/tests/torture_su_tag $(distdir)/tests/torture_su_time $(distdir)/tests/torture_su_timer $(distdir)/utils/localinfo $(distdir)/utils/sip_dig $(distdir)/utils/sip_options $(distdir)/utils/stunc
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \

Modified: freeswitch/trunk/libs/sofia-sip/win32/build_sources.cmd
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/win32/build_sources.cmd	(original)
+++ freeswitch/trunk/libs/sofia-sip/win32/build_sources.cmd	Sat Feb 17 01:25:21 2007
@@ -3,22 +3,21 @@
 ::
 
 @setlocal
- at if x%AWK%==x set AWK=mawk
+ at if x%AWK%==x set AWK=gawk
 @set CHECK=@IF errorlevel 1 GOTO failed
 
 :: Check that we really have awk
 @%AWK% "{ exit(0); }" < NUL >NUL
 @if not errorlevel 9009 goto have_awk
- at echo *** install %AWK% (mawk or GNU awk) into your PATH ***
- at echo *** see http://gnuwin32.sourceforge.net/packages/mawk.htm ***
+ at echo *** install %AWK% (GNU awk) into your PATH ***
 @goto failed
 :have_awk
 
- at set MSG_AWK=%AWK% -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk
+ at set MSG_AWK=gawk -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk
 :: in Win32 exit 0; from gawk 3.1.3 gets converted to errorlevel 1
 :: If you have gawk 3.1.3 uncomment the following line
-:: @set MSG_AWK=%AWK% -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk success=-1
- at set TAG_AWK=%AWK% -f ../libsofia-sip-ua/su/tag_dll.awk BINMODE=rw
+:: @set MSG_AWK=gawk -v BINMODE=rw -f ../libsofia-sip-ua/msg/msg_parser.awk success=-1
+ at set TAG_AWK=gawk -f ../libsofia-sip-ua/su/tag_dll.awk BINMODE=rw
 
 @set IN=../libsofia-sip-ua/msg/test_class.h
 @set PR=../libsofia-sip-ua/msg/test_protos.h

Modified: freeswitch/trunk/libs/sofia-sip/win32/check.cmd
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/win32/check.cmd	(original)
+++ freeswitch/trunk/libs/sofia-sip/win32/check.cmd	Sat Feb 17 01:25:21 2007
@@ -63,5 +63,5 @@
 tests\torture_su_bm\Debug\torture_su_bm.exe
 @if errorlevel 1 ( echo torture_su_bm: FAIL ) else echo torture_su_bm: PASS
 
-:: tests\torture_su_port\Debug\torture_su_port.exe
-:: @if errorlevel 1 ( echo torture_su_port: FAIL ) else echo torture_su_port: PASS
+tests\torture_su_port\Debug\torture_su_port.exe
+ at if errorlevel 1 ( echo torture_su_port: FAIL ) else echo torture_su_port: PASS

Modified: freeswitch/trunk/libs/sofia-sip/win32/config.h.in
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/win32/config.h.in	(original)
+++ freeswitch/trunk/libs/sofia-sip/win32/config.h.in	Sat Feb 17 01:25:21 2007
@@ -32,10 +32,10 @@
  * @date Created: Tue Sep 12 19:22:54 2000 ppessi
  */
 
-/* Define to as the random number source name. */
+/* Define this as the random number source name. */
 #undef DEV_URANDOM
 
-/* Define to 1 if you have addrinfo structure. */
+/* Define this as 1 if you have addrinfo structure. */
 #define HAVE_ADDRINFO 1
 
 /* Define to 1 if you have the `alarm' function. */
@@ -50,21 +50,15 @@
 /* Define to 1 if you have the `clock_gettime' function. */
 #undef HAVE_CLOCK_GETTIME
 
-/* Define to 1 if you have /dev/urandom. */
+/* Define this as 1 if you have /dev/urandom. */
 #undef HAVE_DEV_URANDOM
 
-/* Define to 1 if you have the <dirent.h> header file. */
-#undef HAVE_DIRENT_H
-
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
-/* Define to 1 if you have epoll interface. */
+/* Define to 1 if you have the `epoll' function. */
 #undef HAVE_EPOLL
 
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
 /* Define this as 1 if you have WIN32 FILETIME type and
    GetSystemTimeAsFileTime(). */
 #define HAVE_FILETIME 1
@@ -75,10 +69,10 @@
 /* Define to 1 if you have the `freeaddrinfo' function. */
 #define HAVE_FREEADDRINFO 1
 
-/* Define to 1 if the C compiler supports __func__ */
+/* Define as 1 if the C compiler supports __func__ */
 #undef HAVE_FUNC
 
-/* Define to 1 if the C compiler supports __FUNCTION__ */
+/* Define as 1 if the C compiler supports __FUNCTION__ */
 #undef HAVE_FUNCTION
 
 /* Define to 1 if you have the `gai_strerror' function. */
@@ -117,16 +111,16 @@
 /* Define to 1 if you have the <ifaddr.h> header file. */
 #undef HAVE_IFADDR_H
 
-/* Define to 1 if you have SIOCGIFCONF */
+/* Define this as 1 if you have SIOCGIFCONF */
 #undef HAVE_IFCONF
 
-/* Define to 1 if you have SIOCGIFNUM ioctl */
+/* Define this as 1 if you have SIOCGIFNUM ioctl */
 #undef HAVE_IFNUM
 
-/* Define to 1 if you have ifr_ifindex in <net/if.h> */
+/* Define this as 1 if you have ifr_ifindex in <net/if.h> */
 #undef HAVE_IFR_IFINDEX
 
-/* Define to 1 if you have ifr_index in <net/if.h> */
+/* Define this as 1 if you have ifr_index in <net/if.h> */
 #undef HAVE_IFR_INDEX
 
 /* Define to 1 if you have the `if_nameindex' function. */
@@ -141,27 +135,23 @@
 /* Define to 1 if you have the `initstate' function. */
 #undef HAVE_INITSTATE
 
-/* Define to 1 if you have inlining compiler */
+/* Define this as 1 if you have inlining compiler */
 #define HAVE_INLINE 1
 
-/* Define to 1 if you have WIN32 INTERFACE_INFO_EX type. */
+/* Define this as 1 if you have WIN32 INTERFACE_INFO_EX type. */
 #undef HAVE_INTERFACE_INFO_EX
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the <iphlpapi.h> header file. */
-#if _MSC_VER > 1200 
-#define HAVE_IPHLPAPI_H 1
-#else
-// XXX: vehmanek-win32-fix for VC6
+/* Define as 1 you have WIN32 <iphlpapi.h> */
+// XXX: vehmanek-win32-fix:
 #undef HAVE_IPHLPAPI_H
-#endif
 
-/* Define to 1 if you have IPV6_RECVERR in <netinet/in6.h> */
+/* Define this as 1 if you have IPV6_RECVERR in <netinet/in6.h> */
 #undef HAVE_IPV6_RECVERR
 
-/* Define to 1 if you have IP_RECVERR in <netinet/in.h> */
+/* Define this as 1 if you have IP_RECVERR in <netinet/in.h> */
 #undef HAVE_IP_RECVERR
 
 /* Define to 1 if you have the `crypto' library (-lcrypto). */
@@ -191,12 +181,9 @@
 /* Define to 1 if you have the `memspn' function. */
 #undef HAVE_MEMSPN
 
-/* Define to 1 if you are compiling in MinGW environment */
+/* Define this as 1 if you are compiling in MinGW environment */
 #undef HAVE_MINGW
 
-/* Define to 1 if you have MSG_TRUNC flag */
-#undef HAVE_MSG_TRUNC
-
 /* Define to 1 if you have the <netdb.h> header file. */
 #undef HAVE_NETDB_H
 
@@ -218,7 +205,7 @@
 /* Define to 1 if you have the <net/if_types.h> header file. */
 #undef HAVE_NET_IF_TYPES_H
 
-/* Define to 1 if you have OpenSSL */
+/* Define this as 1 if you have OpenSSL */
 #undef HAVE_OPENSSL
 
 /* Define to 1 if you have the <openssl/tls1.h> header file. */
@@ -227,19 +214,9 @@
 /* Define to 1 if you have the `poll' function. */
 #undef HAVE_POLL
 
-/* Define to 1 if you use poll in su_port. */
-#undef HAVE_POLL_PORT
-
-/* Define to 1 if you have /proc/net/if_inet6 control file */
+/* Define this as 1 if you have /proc/net/if_inet6 control file */
 #undef HAVE_PROC_NET_IF_INET6
 
-/* Define to 1 if you have working pthread_rwlock_t implementation. A thread
-   may hold multiple concurrent read locks on rwlock - that is, successfully
-   call the pthread_rwlock_rdlock() function n times. If so, the application
-   shall ensure that the thread performs matching unlocks - that is, it calls
-   the pthread_rwlock_unlock() function n times. */
-#undef HAVE_PTHREAD_RWLOCK
-
 /* Define to 1 if you have the <pthread.h> header file. */
 #define HAVE_PTHREAD_H 1
 
@@ -247,61 +224,52 @@
 /* See later */
 #define HAVE_RANDOM 1
 
-/* Define to 1 if you have sa_len in struct sockaddr */
+/* Define this as 1 if you have sa_len in struct sockaddr */
 #undef HAVE_SA_LEN
 
-/* Define to 1 if you have SCTP */
+/* Define this a 1 if you have SCTP */
 #undef HAVE_SCTP
 
 /* Define to 1 if you have the `select' function. */
 #undef HAVE_SELECT
 
-/* Define to 1 if you have Sofia sigcomp >= 2.5 */
+/* Define this as 1 if you have Sofia sigcomp >= 2.5 */
 #undef HAVE_SIGCOMP
 
 /* Define to 1 if you have the <sigcomp.h> header file. */
 #undef HAVE_SIGCOMP_H
 
-/* Define to 1 if you have the `signal' function. */
-#define HAVE_SIGNAL 1
-
-/* Define to 1 if you have SIGPIPE */
+/* Define as 1 if you have SIGPIPE */
 #undef HAVE_SIGPIPE
 
-/* Define to 1 if you have IPv6 structures and constants */
+/* Define this as 1 if you have IPv6 structures and constants */
 #define HAVE_SIN6 1
 
-/* Define to 1 if you have WIN32 WSAIoctl SIO_ADDRESS_LIST_QUERY. */
+/* Define this as 1 if you have WIN32 WSAIoctl SIO_ADDRESS_LIST_QUERY. */
 #define HAVE_SIO_ADDRESS_LIST_QUERY 1
 
 /* Define to 1 if you have the `socketpair' function. */
 #undef HAVE_SOCKETPAIR
 
-/* Define to 1 if we use NTH library */
-#define HAVE_SOFIA_NTH 1
-
-/* Define to 1 if we use NTLM library */
-#undef HAVE_SOFIA_NTLM
-
-/* Define to 1 if you have Sofia sigcomp >= 2.5 */
+/* Define this as 1 if you have Sofia sigcomp >= 2.5 */
 #undef HAVE_SOFIA_SIGCOMP
 
-/* Define to 1 always */
+/* Define as 1 always */
 #define HAVE_SOFIA_SIP 1
 
-/* Define to 1 if we use S/MIME library */
+/* Define as 1 if we use S/MIME library */
 #undef HAVE_SOFIA_SMIME
 
-/* Define to 1 if we use DNS library */
+/* Define as 1 if we use DNS library */
 #define HAVE_SOFIA_SRESOLV 1
 
-/* Define to 1 if we use STUN library */
+/* Define as 1 if we use STUN library */
 #undef HAVE_SOFIA_STUN
 
-/* Define to 1 always */
+/* Define as 1 always */
 #define HAVE_SOFIA_SU 1
 
-/* Define to 1 if we use SRTP */
+/* Define as 1 if we use SRTP */
 #undef HAVE_SRTP
 
 /* Define to 1 if you have the <stdint.h> header file. */
@@ -325,21 +293,15 @@
 /* Define to 1 if you have the `strtoull' function. */
 #undef HAVE_STRTOULL
 
-/* Define to 1 if your CC supports C99 struct initialization */
+/* Define this as 1 if your CC supports C99 struct initialization */
 #undef HAVE_STRUCT_KEYWORDS
 
 /* Define to 1 if you have the <sofia-sip/su_wait.h> header file. */
 #define HAVE_SU_WAIT_H 1
 
-/* Define to 1 if you have the <sys/epoll.h> header file. */
-#undef HAVE_SYS_EPOLL_H
-
 /* Define to 1 if you have the <sys/filio.h> header file. */
 #undef HAVE_SYS_FILIO_H
 
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#undef HAVE_SYS_IOCTL_H
-
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
@@ -361,16 +323,16 @@
 /* Define to 1 if you have the `tcsetattr' function. */
 #undef HAVE_TCSETATTR
 
-/* Define to 1 if you have TLS */
+/* Define this as 1 if you have TLS */
 #undef HAVE_TLS
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/* Define to 1 if we use UPnP */
+/* Define as 1 if we use UPnP */
 #undef HAVE_UPNP
 
-/* Define to 1 you have WIN32 */
+/* Define as 1 you have WIN32 */
 #define HAVE_WIN32 1
 
 /* Define to 1 if you have the <windef.h> header file. */
@@ -382,13 +344,13 @@
 /* Define to 1 if you have the <ws2tcpip.h> header file. */
 #define HAVE_WS2TCPIP_H 1
 
-/* Define to format (%lli) for long long */
+/* Define as format (%lli) for long long */
 #define LLI "%I64i"
 
-/* Define to format (%llu) for unsigned long long */
+/* Define as format (%llu) for unsigned long long */
 #define LLU "%I64u"
 
-/* Define to format (%llx) for long long hex */
+/* Define as format (%llx) for long long hex */
 #define LLX "%I64x"
 
 /* Name of package */
@@ -465,20 +427,20 @@
 /* This is GCC magic  */
 #define __attribute__(x)
 
-/* Define to 1 if you have TimeGetTime() */
+/* Define this as 1 if you have TimeGetTime() */
 #define HAVE_TIMEGETTIME     1
 
 #define PATH_MAX _MAX_PATH
 
 #define HAVE_WINMM 1
 
-/* Define to 1 if you have FILETIME */
+/* Define this as 1 if you have FILETIME */
 #define HAVE_FILETIME 1
 
-/* Define to 1 if you have WinSock2 ioctl SIO_ADDRESS_LIST_QUERY */
+/* Define this as 1 if you have WinSock2 ioctl SIO_ADDRESS_LIST_QUERY */
 #define HAVE_SIO_ADDRESS_LIST_QUERY 1
 
-/* Define to 1 if you have INTERFACE_INFO ioctl */
+/* Define this as 1 if you have INTERFACE_INFO ioctl */
 #define HAVE_INTERFACE_INFO 	   (1) 
 
 /* Ignore certain warnings */

Modified: freeswitch/trunk/libs/sofia-sip/win32/version_files.cmd
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/win32/version_files.cmd	(original)
+++ freeswitch/trunk/libs/sofia-sip/win32/version_files.cmd	Sat Feb 17 01:25:21 2007
@@ -26,15 +26,14 @@
 ::
 
 @setlocal
- at if x%AWK%==x set AWK=mawk
+ at if x%AWK%==x set AWK=gawk
 @set VERSION=%AWK% -v BINMODE="rw" -f version.awk
 @set AC=..\configure.ac
 
 :: Check that we really have awk
 @%AWK% "{ exit(0); }" < NUL >NUL
 @if not errorlevel 9009 goto have_awk
- at echo *** install %AWK% (mawk or GNU awk) into your PATH ***
- at echo *** see http://gnuwin32.sourceforge.net/packages/mawk.htm ***
+ at echo *** install %AWK% (GNU awk) into your PATH ***
 @goto end
 :have_awk
 

Modified: freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj
==============================================================================
--- freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj	(original)
+++ freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj	Sat Feb 17 01:25:21 2007
@@ -54,7 +54,6 @@
 				ProgramDataBaseFileName=".\Debug/"
 				BrowseInformation="1"
 				WarningLevel="4"
-				WarnAsError="true"
 				SuppressStartupBanner="true"
 				Detect64BitPortabilityProblems="true"
 				DebugInformationFormat="3"
@@ -134,7 +133,6 @@
 				ProgramDataBaseFileName=".\Release/"
 				BrowseInformation="1"
 				WarningLevel="4"
-				WarnAsError="true"
 				SuppressStartupBanner="true"
 				Detect64BitPortabilityProblems="true"
 			/>
@@ -184,758 +182,247 @@
 				Name="su"
 				Filter="su*.c"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\inet_ntop.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\inet_pton.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_addrinfo.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_alloc.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_alloc_lock.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_base_port.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_bm.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_default_log.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_errno.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_global_log.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_localinfo.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_log.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_md5.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_os_nw.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_port.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_pthread_port.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_root.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_socket_port.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_sprintf.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_strdup.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_strlst.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_tag_io.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_taglist.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_time.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_time0.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_timer.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_uniqueid.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_vector.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_wait.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_win32_port.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\inet_ntop.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\inet_pton.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_addrinfo.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_alloc.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_alloc_lock.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_bm.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_default_log.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_errno.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_global_log.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_localinfo.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_log.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_md5.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_os_nw.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_port.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_root.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_sprintf.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_strdup.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_strlst.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_tag_io.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_taglist.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_time.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_time0.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_timer.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_uniqueid.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_vector.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_wait.c"></File>
 			</Filter>
 			<Filter
 				Name="ipt"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\base64.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\rc4.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\string0.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\token64.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\base64.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\rc4.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\string0.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\token64.c"></File>
 			</Filter>
 			<Filter
 				Name="url"
 				Filter="url*.c"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\url.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\url_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\url_tag_ref.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\url.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\url_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\url_tag_ref.c"></File>
 			</Filter>
 			<Filter
 				Name="features"
 				Filter="features*.c"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\features\features.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\features\features.c"></File>
 			</Filter>
 			<Filter
 				Name="bnf"
 				Filter="bnf*.c"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\bnf\bnf.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\bnf\bnf.c"></File>
 			</Filter>
 			<Filter
 				Name="msg"
 				Filter="msg*.c"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_auth.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_basic.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_date.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_generic.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_header_copy.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_header_make.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_mclass.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_mime.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_mime_table.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_parser.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_parser_util.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_tag.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_auth.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_basic.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_date.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_generic.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_header_copy.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_header_make.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_mclass.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_mime.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_mime_table.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_parser.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_parser_util.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_tag.c"></File>
 			</Filter>
 			<Filter
 				Name="clib replacement"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\memcspn.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\memmem.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\memspn.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\strcasestr.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\strtoull.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\memcspn.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\memmem.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\memspn.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\strcasestr.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\strtoull.c"></File>
 			</Filter>
 			<Filter
 				Name="sip"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_basic.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_caller_prefs.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_event.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_extra.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_feature.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_header.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_mime.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_parser.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_parser_table.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_prack.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_pref_util.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_reason.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_refer.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_security.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_session.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_status.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_tag_class.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_tag_ref.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_time.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_util.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_basic.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_caller_prefs.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_event.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_extra.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_feature.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_header.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_mime.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_parser.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_parser_table.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_prack.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_pref_util.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_reason.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_refer.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_security.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_session.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_status.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_tag_class.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_tag_ref.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_time.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_util.c"></File>
 			</Filter>
 			<Filter
 				Name="http"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_basic.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_extra.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_header.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_parser.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_parser_table.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_status.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_tag_class.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_tag_ref.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_basic.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_extra.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_header.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_parser.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_parser_table.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_status.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_tag_class.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\http_tag_ref.c"></File>
 			</Filter>
 			<Filter
 				Name="nth"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_client.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_server.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_tag_ref.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_client.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_server.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\nth_tag_ref.c"></File>
 			</Filter>
 			<Filter
 				Name="sresolv"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sres.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sres_blocking.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sres_cache.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sresolv.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sres.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sres_blocking.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sres_cache.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sresolv.c"></File>
 			</Filter>
 			<Filter
 				Name="nea"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_debug.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_event.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_server.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_tag_ref.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_debug.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_event.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_server.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_tag_ref.c"></File>
 			</Filter>
 			<Filter
 				Name="iptsec"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_client.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_common.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_digest.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_module.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_module_http.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_module_sip.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_plugin.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_plugin_delayed.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_tag_ref.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\iptsec_debug.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_client.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_common.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_digest.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_module.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_module_http.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_module_sip.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_plugin.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_plugin_delayed.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\auth_tag_ref.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\iptsec_debug.c"></File>
 			</Filter>
 			<Filter
 				Name="stun"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_common.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_dns.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_internal.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_mini.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_tag_ref.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_common.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_dns.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_internal.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_mini.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\stun_tag_ref.c"></File>
 			</Filter>
 			<Filter
 				Name="nua"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_common.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_dialog.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_dialog.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_event_server.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_extension.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_message.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_notifier.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_options.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_params.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_params.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_publish.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_register.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_registrar.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_session.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_stack.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_stack.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_subnotref.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_tag_ref.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\outbound.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_common.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_dialog.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_dialog.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_event_server.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_extension.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_message.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_notifier.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_options.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_params.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_params.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_publish.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_register.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_registrar.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_session.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_stack.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_stack.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_subnotref.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\nua_tag_ref.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\outbound.c"></File>
 			</Filter>
 			<Filter
 				Name="nta"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_check.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_tag_ref.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sl_read_payload.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sl_utils_log.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sl_utils_print.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_check.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_tag_ref.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sl_read_payload.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sl_utils_log.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sl_utils_print.c"></File>
 			</Filter>
 			<Filter
 				Name="tport"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_internal.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_logging.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_stub_sigcomp.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_stub_stun.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_tag_ref.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_type_connect.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_type_tcp.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_type_udp.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_internal.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_logging.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_stub_sigcomp.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_stub_stun.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_tag_ref.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_type_connect.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_type_tcp.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_type_udp.c"></File>
 			</Filter>
 			<Filter
 				Name="sdp"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_parse.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_print.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_tag_ref.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_parse.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_print.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sdp_tag_ref.c"></File>
 			</Filter>
 			<Filter
 				Name="soa"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa_session.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa_static.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa_tag.c"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa_tag_ref.c"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa_session.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa_static.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa_tag.c"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\soa_tag_ref.c"></File>
 			</Filter>
 		</Filter>
 		<Filter
@@ -946,533 +433,194 @@
 				Name="su headers"
 				Filter="su*.h"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\htable.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\htable2.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\rbtree.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_addrinfo.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_alloc.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_alloc_stat.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_bm.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_config.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_debug.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_errno.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_localinfo.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_log.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_md5.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_module_debug.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_os_nw.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_port.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_source.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_strlst.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag_class.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag_inline.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag_io.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tagarg.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_time.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_types.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_uniqueid.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_vector.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_wait.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\tstdef.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\htable.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\htable2.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\rbtree.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_addrinfo.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_alloc.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_alloc_stat.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_bm.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_config.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_debug.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_errno.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_localinfo.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_log.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_md5.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_module_debug.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_os_nw.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_port.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_source.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_strlst.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag_class.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag_inline.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tag_io.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_tagarg.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_time.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_types.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_uniqueid.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_vector.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_wait.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\tstdef.h"></File>
 			</Filter>
 			<Filter
 				Name="win32 headers"
 				>
-				<File
-					RelativePath="..\config.h"
-					>
-				</File>
-				<File
-					RelativePath="..\sofia-sip\su_configure.h"
-					>
-				</File>
-				<File
-					RelativePath="..\unistd.h"
-					>
-				</File>
+				<File RelativePath="..\config.h"></File>
+				<File RelativePath="..\sofia-sip\su_configure.h"></File>
+				<File RelativePath="..\unistd.h"></File>
 			</Filter>
 			<Filter
 				Name="ipt headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\base64.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\rc4.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\string0.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\token64.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\base64.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\rc4.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\string0.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\ipt\sofia-sip\token64.h"></File>
 			</Filter>
 			<Filter
 				Name="url headers"
 				Filter="url*.h"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\sofia-sip\url.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\sofia-sip\url_tag.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\sofia-sip\url_tag_class.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\sofia-sip\url.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\sofia-sip\url_tag.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\url\sofia-sip\url_tag_class.h"></File>
 			</Filter>
 			<Filter
 				Name="features headers"
 				Filter="features*.h"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\features\sofia-sip\sofia_features.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\features\sofia-sip\sofia_features.h"></File>
 			</Filter>
 			<Filter
 				Name="bnf headers"
 				Filter="bnf*.h"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\bnf\sofia-sip\bnf.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\bnf\sofia-sip\hostdomain.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\bnf\sofia-sip\bnf.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\bnf\sofia-sip\hostdomain.h"></File>
 			</Filter>
 			<Filter
 				Name="msg headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_addr.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_bnf.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_buffer.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_date.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_header.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_internal.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mclass.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mclass_hash.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mime.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mime_protos.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_parser.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_protos.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_tag_class.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_types.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_addr.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_bnf.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_buffer.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_date.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_header.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\msg_internal.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mclass.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mclass_hash.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mime.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_mime_protos.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_parser.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_protos.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_tag_class.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\msg\sofia-sip\msg_types.h"></File>
 			</Filter>
 			<Filter
 				Name="sip headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_extensions.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_hclasses.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_header.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_internal.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_parser.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_protos.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_status.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_tag.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_tag_class.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_util.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_extensions.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_hclasses.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_header.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sip_internal.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_parser.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_protos.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_status.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_tag.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_tag_class.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sip\sofia-sip\sip_util.h"></File>
 			</Filter>
 			<Filter
 				Name="http headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_hclasses.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_header.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_parser.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_protos.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_status.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_tag.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_tag_class.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_hclasses.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_header.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_parser.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_protos.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_status.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_tag.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\http\sofia-sip\http_tag_class.h"></File>
 			</Filter>
 			<Filter
 				Name="nth headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\sofia-sip\nth.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\sofia-sip\nth_tag.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\sofia-sip\nth.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nth\sofia-sip\nth_tag.h"></File>
 			</Filter>
 			<Filter
 				Name="sresolv headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres_async.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres_cache.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres_record.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-sip\sresolv.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres_async.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres_cache.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-resolv\sres_record.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sresolv\sofia-sip\sresolv.h"></File>
 			</Filter>
 			<Filter
 				Name="nea headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\sofia-sip\nea.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_debug.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\sofia-sip\nea_tag.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\sofia-sip\nea.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\nea_debug.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nea\sofia-sip\nea_tag.h"></File>
 			</Filter>
 			<Filter
 				Name="iptsec headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_client.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_digest.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_module.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_ntlm.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_plugin.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\iptsec_debug.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_client.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_digest.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_module.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_ntlm.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\sofia-sip\auth_plugin.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\iptsec\iptsec_debug.h"></File>
 			</Filter>
 			<Filter
 				Name="stun headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\sofia-sip\stun.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\sofia-sip\stun_common.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\sofia-sip\stun_tag.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\sofia-sip\stun.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\sofia-sip\stun_common.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\stun\sofia-sip\stun_tag.h"></File>
 			</Filter>
 			<Filter
 				Name="nua headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\sofia-sip\nua.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\sofia-sip\nua_tag.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\sofia-sip\nua.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nua\sofia-sip\nua_tag.h"></File>
 			</Filter>
 			<Filter
 				Name="nta headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_internal.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta_stateless.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta_tag.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta_tport.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\sl_utils.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\nta_internal.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta_stateless.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta_tag.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\nta_tport.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\nta\sofia-sip\sl_utils.h"></File>
 			</Filter>
 			<Filter
 				Name="tport headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\sofia-sip\tport.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\sofia-sip\tport_plugins.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\sofia-sip\tport_tag.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_tls.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\sofia-sip\tport.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\sofia-sip\tport_plugins.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\sofia-sip\tport_tag.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\tport\tport_tls.h"></File>
 			</Filter>
 			<Filter
 				Name="sdp headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sofia-sip\sdp.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sofia-sip\sdp_tag.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sofia-sip\sdp.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\sdp\sofia-sip\sdp_tag.h"></File>
 			</Filter>
 			<Filter
 				Name="soa headers"
 				>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa_add.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa_tag.h"
-					>
-				</File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa_add.h"></File>
+				<File RelativePath="..\..\sofia-sip\libsofia-sip-ua\soa\sofia-sip\soa_tag.h"></File>
 			</Filter>
 		</Filter>
 	</Files>



More information about the Freeswitch-svn mailing list