diff --git a/build/modmake.rules.in b/build/modmake.rules.in index d41dc5f8d8..2c0a24fae1 100644 --- a/build/modmake.rules.in +++ b/build/modmake.rules.in @@ -49,7 +49,8 @@ extraclean: distclean local_extraclean Makefile: @if test ! -f $@; then \ - echo include $(switch_srcdir)/build/modmake.rules > Makefile ; \ + echo MODNAME=$(MODNAME) > Makefile ; \ + echo include $(switch_srcdir)/build/modmake.rules >> Makefile ; \ fi ; $(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).o $(LOCAL_OBJS) $(SOURCEFILE) diff --git a/src/mod/Makefile.am b/src/mod/Makefile.am index 801b7075a0..fe9d5d9aae 100644 --- a/src/mod/Makefile.am +++ b/src/mod/Makefile.am @@ -1,41 +1,42 @@ -MODULES = `grep -v "\#" $(switch_builddir)/modules.conf` +CONF_MODULES=$(shell grep -v "\#" $(switch_builddir)/modules.conf) +FOUND_MODULES=$(shell find . -type d -name mod_\*) +OUR_MODULES=`if test -z $(MODULES) ; then echo $(CONF_MODULES) ; else echo $(MODULES) ; fi ;` +OUR_CLEAN_MODULES=`if test -z $(MODULES) ; then echo $(CONF_MODULES) $(FOUND_MODULES) ; else echo $(MODULES) ; fi ;` +MOD_NAME=`echo $$i | sed -e 's|^.*/||'` +MOD_DIR=`if test -d $(switch_srcdir)/src/mod/$$i ; then echo $(switch_srcdir)/src/mod/$$i ; else echo $$i ; fi;` + all: @if [ ! -f $(switch_builddir)/modules.conf ] ; then cp $(switch_builddir)/modules.conf.in $(switch_builddir)/modules.conf ; fi @echo making modules - @for i in $(MODULES) ; do \ + @for i in $(OUR_MODULES) ; do \ echo making $$i ; \ - modname=`echo $$i | sed "s/^.*\///g"`; \ - if test -z $$modname ; then modname=$$i ; fi; \ - if test -d $(switch_srcdir)/src/mod/$$i ; then moddir=$(switch_srcdir)/src/mod/$$i ; else moddir=$$i ; fi; \ + moddir=$(MOD_DIR); \ + echo $(MOD_NAME); \ if test -f $$moddir/Makefile ; then \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) ; else \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules ; \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) ; else \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules ; \ fi; \ done clean: - @for i in `find . -type d -name mod_\*` ; do \ + @for i in $(OUR_CLEAN_MODULES) ; do \ echo making clean $$i ; \ - modname=`echo $$i | sed "s/^.*\///g"`; \ - if test -z $$modname ; then modname=$$i ; fi; \ - if test -d $(switch_srcdir)/src/mod/$$i ; then moddir=$(switch_srcdir)/src/mod/$$i ; else moddir=$$i ; fi; \ + moddir=$(MOD_DIR); \ if test -f $$moddir/Makefile ; then \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) clean ; else \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) clean ; else \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ fi; \ done install: @echo Installing Modules - @for i in $(MODULES) ; do \ + @for i in $(OUR_MODULES) ; do \ echo making install $$i ; \ - modname=`echo $$i | sed "s/^.*\///g"`; \ - if test -z $$modname ; then modname=$$i ; fi; \ - if test -d $(switch_srcdir)/src/mod/$$i ; then moddir=$(switch_srcdir)/src/mod/$$i ; else moddir=$$i ; fi; \ + moddir=$(MOD_DIR); \ if test -f $$moddir/Makefile ; then \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) install ; else \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) install ; else \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ fi; \ done @echo done diff --git a/src/mod/Makefile.in b/src/mod/Makefile.in index 5f38102b03..110d10c0a2 100644 --- a/src/mod/Makefile.in +++ b/src/mod/Makefile.in @@ -182,7 +182,12 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ uint64_t_fmt = @uint64_t_fmt@ voidp_size = @voidp_size@ -MODULES = `grep -v "\#" $(switch_builddir)/modules.conf` +CONF_MODULES = $(shell grep -v "\#" $(switch_builddir)/modules.conf) +FOUND_MODULES = $(shell find . -type d -name mod_\*) +OUR_MODULES = `if test -z $(MODULES) ; then echo $(CONF_MODULES) ; else echo $(MODULES) ; fi ;` +OUR_CLEAN_MODULES = `if test -z $(MODULES) ; then echo $(CONF_MODULES) $(FOUND_MODULES) ; else echo $(MODULES) ; fi ;` +MOD_NAME = `echo $$i | sed -e 's|^.*/||'` +MOD_DIR = `if test -d $(switch_srcdir)/src/mod/$$i ; then echo $(switch_srcdir)/src/mod/$$i ; else echo $$i ; fi;` all: all-am .SUFFIXES: @@ -344,39 +349,34 @@ uninstall-am: uninstall-info-am all: @if [ ! -f $(switch_builddir)/modules.conf ] ; then cp $(switch_builddir)/modules.conf.in $(switch_builddir)/modules.conf ; fi @echo making modules - @for i in $(MODULES) ; do \ + @for i in $(OUR_MODULES) ; do \ echo making $$i ; \ - modname=`echo $$i | sed "s/^.*\///g"`; \ - if test -z $$modname ; then modname=$$i ; fi; \ - if test -d $(switch_srcdir)/src/mod/$$i ; then moddir=$(switch_srcdir)/src/mod/$$i ; else moddir=$$i ; fi; \ + moddir=$(MOD_DIR); \ + echo $(MOD_NAME); \ if test -f $$moddir/Makefile ; then \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) ; else \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules ; \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) ; else \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules ; \ fi; \ done clean: - @for i in `find . -type d -name mod_\*` ; do \ + @for i in $(OUR_CLEAN_MODULES) ; do \ echo making clean $$i ; \ - modname=`echo $$i | sed "s/^.*\///g"`; \ - if test -z $$modname ; then modname=$$i ; fi; \ - if test -d $(switch_srcdir)/src/mod/$$i ; then moddir=$(switch_srcdir)/src/mod/$$i ; else moddir=$$i ; fi; \ + moddir=$(MOD_DIR); \ if test -f $$moddir/Makefile ; then \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) clean ; else \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) clean ; else \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ fi; \ done install: @echo Installing Modules - @for i in $(MODULES) ; do \ + @for i in $(OUR_MODULES) ; do \ echo making install $$i ; \ - modname=`echo $$i | sed "s/^.*\///g"`; \ - if test -z $$modname ; then modname=$$i ; fi; \ - if test -d $(switch_srcdir)/src/mod/$$i ; then moddir=$(switch_srcdir)/src/mod/$$i ; else moddir=$$i ; fi; \ + moddir=$(MOD_DIR); \ if test -f $$moddir/Makefile ; then \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) install ; else \ - cd $$moddir && MODNAME=$$modname BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) install ; else \ + cd $$moddir && MODNAME=$(MOD_NAME) BASE=$(switch_builddir) $(MAKE) -f $(switch_builddir)/build/modmake.rules clean ; \ fi; \ done @echo done