help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: for sub in $(SUBMAKES); but $(SUBMAKES) is empty


From: Noel Yap
Subject: Re: for sub in $(SUBMAKES); but $(SUBMAKES) is empty
Date: Fri, 17 Sep 2004 12:51:34 -0400
User-agent: Mozilla Thunderbird 0.5 (Windows/20040212)

This is a shell issue, not a make issue.

It sounds like on some of your platforms, the shell emits errors when there's 
nothing to loop through.  If you have control over the shell that's running, 
change that, if not, change the action.

Noel

Alexander Farber wrote:

Hi,

thanks for your help! But aside from the discussion
about the recursive makefiles (I really don't have a
choice at the moment and have to use them ), is this below supposed to work or not?


    linux72:afarber {331} cat Makefile
    SUBMAKES=

    all:
            for i in $(SUBMAKES); do \
                    echo $$i; \
            done

It fails for me on some Linux PCs and HP-UX machines (with bash 2.05) and works on others (bash 2.05b, 3.0):

    boclu21:afarber {53} gmake
    for i in ; do \
            echo $i; \
    done
    /bin/sh: -c: line 1: syntax error near unexpected token `;'
    /bin/sh: -c: line 1: `for i in ; do  echo $i;  done'
    gmake: *** [all] Error 2

Do I really have to modify my makefiles to contain:

    all clean: $(SUBMAKES)
            test -z "$(SUBMAKES)" || for sub in "$(SUBMAKES)"; do \
                    $(MAKE) -f $$sub $@; \
            done

This feels so awkward to me. How do others deal with this?

Regards
Alex


On Fri, Sep 17, 2004 at 12:11:54PM -0400, Noel Yap wrote:

Short-term answer: you could change the action to test the contents of $(SUBMAKES) prior to doing the for loop:

        if [ ! -z "$(SUBMAKES)" ]
        then
                for sub in ...
                do
                done
        fi


Long-term answer: don't use recursive make. See http://aegis.sourceforge.net/auug97.pdf.

Alexander Farber wrote:

does anybody please know, how to deal with the following problem?
I have several GNU makefiles which call other makefiles like this:

  MMPFILES =
  SUBMAKES = $(foreach FILE, $(MMPFILES), $(FILE).$(PLAT).mbs)
  all clean: $(SUBMAKES)
            for sub in $(SUBMAKES); do \
                    $(MAKE) -f $$sub $@; \
            done

For few of the makefiles the MMPFILES variable is empty (as above).
This still works on some Linux-PC's here but fails on others:

  boclu21:group {557} gmake -f Makefile.WINS.mbs
  for sub in ; do \
            gmake -f $sub all; \
  done
  /bin/sh: -c: line 1: syntax error near unexpected token `;'
  /bin/sh: -c: line 1: `for sub in ; do  gmake -f $sub all;  done'
  gmake: *** [all] Error 2

Looks like the reason is the bash version. The line below works fine on 2.05b.0(1):

  bolinux72:calimero {321} for sub in; do echo gmake -f $sub all; done
bolinux72:calimero {322}
But on the PC with the GNU bash 2.05.8(1) it fails:

  boclu21:group {323} for sub in; do echo gmake -f $sub all; done
  bash: syntax error near unexpected token `;'



_______________________________________________
Help-make mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-make





reply via email to

[Prev in Thread] Current Thread [Next in Thread]