From d9a103bd5bc8470e37aa5381547de62534c1eb89 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sun, 29 Nov 2009 04:58:51 +0000 Subject: [PATCH] an attempt at working --srcdir builds for the modules. (FSBUILD-211) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15704 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- build/modmake.rules.in | 12 ++++++------ src/mod/Makefile.am | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/build/modmake.rules.in b/build/modmake.rules.in index 2e9186d9e5..6351de00bb 100644 --- a/build/modmake.rules.in +++ b/build/modmake.rules.in @@ -20,7 +20,7 @@ LIBCURL_DEPS=@LIBCURL_DEPS@ LIBCURL=@LIBCURL@ LIBCURL_CPPFLAGS=@LIBCURL_CPPFLAGS@ CURL_DIR=$(switch_srcdir)/libs/curl -CURLLA=$(CURL_DIR)/lib/libcurl.la +CURLLA=$(switch_builddir)/libs/curl/lib/libcurl.la OPENSSL_LIBS=@openssl_LIBS@ OPENSSL_CFLAGS=@openssl_CFLAGS@ @@ -50,14 +50,14 @@ CXXCOMPILE = $(CXX) $(ALL_CXXFLAGS) $(DEFS) LTCXXCOMPILE = $(LIBTOOL) --mode=compile --tag=CXX $(CXXCOMPILE) CXXLINK = $(LIBTOOL) --mode=link --tag=CXX $(CXXLD) $(ALL_CXXFLAGS) $(LDFLAGS) -shared -module -avoid-version -rpath $(MODINSTDIR) -o $@ -CSOURCEFILE=$(MODNAME).c -CXXSOURCEFILE=$(MODNAME).cpp +CSOURCEFILE=$(MODDIR)/$(MODNAME).c +CXXSOURCEFILE=$(MODDIR)/$(MODNAME).cpp TOUCH_TARGET=@TOUCH_TARGET@ #MAKE_OPTS = `if test -z "$(VERBOSE)" ; then $(MAKE) --help | grep silent | grep "\-s" 2>&1 >/dev/null && echo -s;fi` MAKE_OPTS = `test -n "$(VERBOSE)" || echo -s` RECURSE_MODNAME=`pwd | sed -e 's|^.*/||'` -RECURSE_SOURCEFILE=`if test -f $$modname.cpp; then echo $$modname.cpp; else echo $$modname.c; fi` +RECURSE_SOURCEFILE=`if test -f "$(MODDIR)/$$modname.cpp"; then echo "$(MODDIR)/$$modname.cpp"; else echo "$(MODDIR)/$$modname.c"; fi` RECURSE_OUR_DEPS=`test -z "$(WANT_CURL)" || if test ! -z "$(LIBCURL_DEPS)"; then echo $(CURLLA); fi ` RECURSE_OUR_CFLAGS=`test -z "$(WANT_CURL)" || echo $(LIBCURL_CPPFLAGS) ; $(LOCAL_INSERT_CFLAGS) ` RECURSE_OUR_LDFLAGS=`test -z "$(WANT_CURL)" || echo $(LIBCURL) ; $(LOCAL_INSERT_LDFLAGS) ` @@ -68,7 +68,7 @@ RECURSE_MAKE=+modname="$(RECURSE_MODNAME)" ; \ ourcflags="$(RECURSE_OUR_CFLAGS)" ; \ ourldflags="$(RECURSE_OUR_LDFLAGS)" ; \ insertobjs="`$(LOCAL_INSERT_OBJS)`" ; \ - $(MAKE) $(MAKE_OPTS) MODNAME="$$modname" SOURCEFILE="$$sourcefile" \ + $(MAKE) $(MAKE_OPTS) MODNAME="$$modname" SOURCEFILE="$$sourcefile" MODDIR="$(MODDIR)" \ OUR_DEPS="$$ourdefs" OUR_CFLAGS="$$ourcflags" OUR_LDFLAGS="$$ourldflags" OUR_OBJS="$$insertobjs" all: Makefile @@ -96,7 +96,7 @@ extraclean-modules: distclean local_extraclean Makefile: @if test ! -f $@; then \ - if ! pwd | grep $(switch_srcdir)/src/mod ; then rulesdir=$(switch_srcdir) ; else rulesdir=../../../.. ; fi ; \ + if ! pwd | grep $(switch_builddir)/src/mod ; then rulesdir=$(switch_builddir) ; else rulesdir=../../../.. ; fi ; \ echo BASE=$$rulesdir > Makefile ; \ echo 'include $$(BASE)/build/modmake.rules' >> Makefile ; \ fi ; diff --git a/src/mod/Makefile.am b/src/mod/Makefile.am index 40afee177b..e4510d4fcf 100644 --- a/src/mod/Makefile.am +++ b/src/mod/Makefile.am @@ -8,10 +8,16 @@ $(OUR_MODULES) $(OUR_CLEAN_MODULES) $(OUR_INSTALL_MODULES) $(OUR_UNINSTALL_MODUL target=`echo $@ | sed -e 's|^.*-||'`; \ modname=`echo $@ | sed -e 's|-.*||' | sed -e 's|^.*/||'`; \ confmoddir=`cat $(switch_builddir)/modules.conf | sed -e 's| ||' | grep $$modname$$ | sed -e 's|#||' | head -n 1`; \ - if test -z "$$confmoddir" ; then moddir=$@ ; else \ + if test -z "$$confmoddir" ; then \ + moddir=$@ ; \ + buildmoddir=$(switch_builddir)/src/mod/$@ ;\ + else \ if test -d "$(switch_srcdir)/src/mod/$$confmoddir" ; then \ - moddir="$(switch_srcdir)/src/mod/$$confmoddir" ; else \ + moddir="$(switch_srcdir)/src/mod/$$confmoddir" ; \ + buildmoddir="$(switch_builddir)/src/mod/$$confmoddir" ; \ + else \ moddir="$$confmoddir" ; \ + buildmoddir="$(switch_builddir)/src/mod/$$confmoddir" ; \ fi ; \ fi ; \ if test -z "$$target" ; then target="all" ; fi ; \ @@ -20,8 +26,10 @@ $(OUR_MODULES) $(OUR_CLEAN_MODULES) $(OUR_INSTALL_MODULES) $(OUR_UNINSTALL_MODUL echo ;\ echo making $$target $$modname ;\ (if test -f "$$moddir/Makefile" ; then \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) $$target; else\ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules $$target ;\ + test -f "$$buildmoddir/Makefile" || cp $$moddir/Makefile $$buildmoddir/Makefile ; \ + cd $$buildmoddir && MODDIR=$$moddir MODNAME=$$modname BASE=$(switch_srcdir) $(MAKE) $(AM_MAKEFLAGS) $$target; \ + else\ + cd $$buildmoddir && MODDIR=$$moddir MODNAME=$$modname BASE=$(switch_srcdir) $(MAKE) $(AM_MAKEFLAGS) -f $(switch_builddir)/build/modmake.rules $$target ;\ fi;) || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ fi; \ test -z "$$fail" ;