From a48da3b46cc653fe37dde6bdb884ead7a6f2e9d6 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Fri, 4 Nov 2011 21:04:29 +0100 Subject: [PATCH] FS-3638: Rework platform library/linker flags handling and libfreeswitch _LDFLAGS/_LIBS to fix applications This fixes the linking order problems reported in FS-3638. Clean up libfreeswitch dependency handling: PLATFORM_CORE_LDFLAGS - Non-library linker flags, specific to this platform PLATFORM_CORE_LIBS - Library flags/libraries need to build libfreeswitch on this platform Drop LDADD dependencies from tone2wav and fs_encode, except for libfreeswitch.la, which will "automagically" pull in all other libraries, now that we fixed libfreeswitch. Signed-off-by: Stefan Knoblich --- Makefile.am | 12 ++++++------ configure.in | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index e26b21e0c7..eb10f9810a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -133,8 +133,8 @@ endif ## lib_LTLIBRARIES = libfreeswitch.la libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS) -libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_DEPLIBS) -libfreeswitch_la_LIBADD = $(CORE_LIBS) +libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) +libfreeswitch_la_LIBADD = $(CORE_LIBS) $(PLATFORM_CORE_LIBS) libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES) if HAVE_ODBC @@ -299,16 +299,16 @@ endif ## fs_encode_SOURCES = src/fs_encode.c fs_encode_CFLAGS = $(AM_CFLAGS) -fs_encode_LDFLAGS = $(AM_LDFLAGS) $(CORE_LIBS) -fs_encode_LDADD = libfreeswitch.la -lcrypt -lrt +fs_encode_LDFLAGS = $(AM_LDFLAGS) +fs_encode_LDADD = libfreeswitch.la ## ## tone2wav () ## tone2wav_SOURCES = src/tone2wav.c tone2wav_CFLAGS = $(AM_CFLAGS) -tone2wav_LDFLAGS = $(AM_LDFLAGS) $(CORE_LIBS) -tone2wav_LDADD = libfreeswitch.la -lcrypt -lrt +tone2wav_LDFLAGS = $(AM_LDFLAGS) +tone2wav_LDADD = libfreeswitch.la ## ## fs_ivrd () diff --git a/configure.in b/configure.in index cb2abd9d12..c369a7986b 100644 --- a/configure.in +++ b/configure.in @@ -407,7 +407,8 @@ APR_ADDTO(SWITCH_AM_LDFLAGS, -lresolv) fi ESL_LDFLAGS= -PLATFORM_CORE_DEPLIBS= +PLATFORM_CORE_LDFLAGS= +PLATFORM_CORE_LIBS= # tweak platform specific flags case "$host" in *darwin10.*) @@ -417,23 +418,30 @@ case "$host" in APR_ADDTO(CXXFLAGS, -pipe) APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) if test "x$enable_core_odbc_support" != "xno"; then - APR_ADDTO(PLATFORM_CORE_DEPLIBS, --framework CoreFoundation) + APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) fi + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt]) ;; *darwin*) APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX) APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC) if test "x$enable_core_odbc_support" != "xno"; then - APR_ADDTO(PLATFORM_CORE_DEPLIBS, --framework CoreFoundation) + APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation]) fi + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt]) ;; *-solaris2*) APR_ADDTO(SWITCH_AM_CFLAGS, -DPATH_MAX=2048 -D__EXTENSIONS__) APR_ADDTO(SWITCH_AM_LDFLAGS, -lsendfile -lresolv -lsocket -lnsl -luuid) APR_ADDTO(ESL_LDFLAGS, -lnsl -lsocket) + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt -lsendfile -lresolv -lsocket -lnsl -luuid]) ;; *bsd*) APR_ADDTO(SWITCH_AM_CFLAGS, -I/usr/local/include) + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt]) + ;; + *linux*) + APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl -lcrypt -lrt]) ;; esac @@ -444,7 +452,8 @@ AC_SUBST(SWITCH_ANSI_CFLAGS) AC_SUBST(SWITCH_AM_CXXFLAGS) AC_SUBST(SWITCH_AM_LDFLAGS) AC_SUBST(ESL_LDFLAGS) -AC_SUBST(PLATFORM_CORE_DEPLIBS) +AC_SUBST(PLATFORM_CORE_LDFLAGS) +AC_SUBST(PLATFORM_CORE_LIBS) AC_SUBST(SOLINK) AC_SUBST(DYNAMIC_LIB_EXTEN) AC_SUBST(LIBTOOL_LIB_EXTEN)