David Whitney wrote:
> Hello,
>
> I am writing a Makefile to build glibc in Chapter 10 of the CLFS
> guide. I am trying to setup something like the following:
>
> ARCH = `cut -d- -f1 <<< ${MACHTYPE}`
> CONFIG_ENV = CFLAGS="-march=$(ARCH) -mtune=generic -g -O2"
>
> When I am at the shell prompt and run this command, echo $MACHTYPE,
> the result is i686-redhat-linux-gnu. When I run the Makefile to echo
> $(ARCH), I receive this error:
>
> echo `cut -d- -f1 <<< `
> /bin/sh: command substitution: line 0: syntax error near unexpected
> token `newline'
> /bin/sh: command substitution: line 0: `cut -d- -f1 <<< '
>
> I used a similar style way of defining ARCH when I built glibc for the
> cross-tools, however in that case it was not MACHTYPE that was
> referenced, but instead the CLFS_TARGET environment variable. How can
> I get this latest Makefile to "see" MACHTYPE? I realize that MACHTYPE
> is not an environment variable. Is there a work around (other than
> hard-coding)?
Some good reading would be the make info pages.
Double up the $, so you get $$MACHTYPE. Otherwise make will treat
${MACHTYPE} as 2 entities "${""MACHTYPE}"
On a side note, each time you reference $(ARCH) it's going to fork off a
process and recalculate the value. If you use := to assign the value, it
won't try to re-calculate it's value each time you reference it. Another
thing you might want todo in combination with that is evaluate that
result when you assign the value, so each time you reference $(ARCH) it
doesn't fork off a process.
ARCH := $(shell cut -d- -f1 <<< $$MACHTYPE)
_______________________________________________
Clfs-support mailing list
[email protected]
http://lists.cross-lfs.org/cgi-bin/mailman/listinfo/clfs-support