bug-make
[Top][All Lists]
Advanced

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

Re: unexpected behaviour of make


From: Paul Smith
Subject: Re: unexpected behaviour of make
Date: Sat, 03 Jan 2015 09:55:37 -0500

On Sat, 2015-01-03 at 10:19 +0100, Sergio Villone wrote:
> I think I ran into a make or documentation  bug or  bad version use
> as requested I acclude a stripped down makefile
> make --version says:
> GNU Make 3.81  (perhaps too old? this is what Apple gives as tool...!)

Apple refuses to provide any software licensed under GPLv3.  You can get
newer versions of GNU software using MacPorts or Homebrew.

However your problem is not because of old versions.  Your problem is
that your makefiles are wrong.

First:

> dirs := a b c d
> $(foreach dir,$(dirs),echo "->$(dir)<-")

Make is not the shell and a makefile is not a shell script.  The above
text will be read by make, after expansion, as:

  echo "->a<-" echo "->b<-" echo "->c<-" echo "->d<-"

Make doesn't have an "echo" command, so this is a nonsensical command
that make doesn't understand.  Make's generic "I don't know what you
said" message is "missing separator".

Make has an $(info ...) function that will print things out, so you can
do this if you want:

  $(foreach dir,$(dirs),$(info "->$(dir)<-"))

However, then later you write:

> macsyd :;
>         echo "----"
> files :=(foreach dir,$(dirs),$(wildcard $(dir)/*))
>         echo "----"
>         echo "files : $(files)"

This is also not right, because the variable assignment of "files"
causes the parsing of the macsyd rule to stop, then the echo statements
afterwards are also illegal (not part of the rule).

You have to write this as (adding in the missing $):

  files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
  macsyd :
          echo "----"
          echo "----"
          echo "files : $(files)"

You should read the GNU make manual introduction sections and sections
on the syntax for writing rules.




reply via email to

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