[Top][All Lists]

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

Re: parameter replacement in make during rule execution

From: Bob Proulx
Subject: Re: parameter replacement in make during rule execution
Date: Fri, 10 Oct 2014 18:45:24 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

Hello Vincent,

Perhaps someone here in help-gnu-utils will know the answer to your
question.  I do not and therefore cannot answer.  But I think you
would have an excellent result if you were to ask your question in the mailing list.  That is dedicated to GNU make and is
where all of the GNU make expertise is discussed.  I suggest you ask
your question there.

If it were me I would do everything in the shell instead of trying to
do it in make.  I would either use shell substitution or use sed or a
combination.  In the end it probably depends upon what you know better.

  case $option in *=) : okay, has equal ;; *) option=$option= ;; esac

Also, use of 'echo -n' isn't portable.  Consider using 'printf' when
you don't want to print a newline for portable operation.

> my problem is with the for loop shown. OPTIONS variable has various
> fields in it. Some fields have a '=' in them ie. FOO=512 and some
> don't. Because I have a broken tool which gets confused by variables
> which don't have an equal sign in them I am trying to go through
> them and convert "FOO=512 BAR" into "FOO=512 BAR=".

Pesky CAD tools.  :-)

> The trouble is that the findstring never finds anything and I get
> "FOO=512= BAR=". When I replace the whole findstring command with 1,
> I get the then case of the 'if' but no amount trial made findstring
> work. Any ideas what my problem is or how to do what I need
> differently?

Perhaps this?

        [many echo commands] >> sim.tcl
        for option in $(OPTIONS); do  \
          case \$option in *=) : has equal ;; *) option=\$option= ;; esac  \
          printf "%s" "$option" >> sim.tcl;  \
        [more echo command] >> sim.tcl

Or perhaps you could post process the file?

        [many echo commands] >> sim.tcl
        for option in $(OPTIONS); do  \
          echo "$option";  \
        done | sed 's/$/=/;s/==*$/=/' | tr "\n" " " >> sim.tcl;
        [more echo command] >> sim.tcl


reply via email to

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