Comments below.
(Remember, I didn't invent this mess, so I don't really
have all that much control over it. It's just that
I'm one of the relatively few who need it to work.)
If it's to be totally overhauled, it needs to be done
by (or with the active support of) a maintainer, so
it doesn't languish and "rot".
> Donn Terry <[EMAIL PROTECTED]>:
> > PREPEND_DOTDOT_TO_RELATIVE_PATHS = sed \
> > -e 's|^ *[^ /][^ /]*/|%&|' \
> > -e 's| -B| -B%|g' \
> > -e 's|% *[^- /]|%&|g' \
> > -e 's|%% *|../|g' \
> > -e 's|%||g'
> > SUBDIR_FLAGS_TO_PASS = $(ORDINARY_FLAGS_TO_PASS) \
> > "CC=$$(echo $$(case '$(CC)' in (stage*) echo
> '$(CC)' | sed -e
> > 's|stage|../stage|g';; (*) echo '$(CC)';; esac) |
> > $(PREPEND_DOTDOT_TO_RELATIVE_PATHS) )"
>
> ugh. I'm generally against complicated constructs in
> Makefiles. ideally, I want my build scripts to have no
> conditionals or substitutions in them. my preferred
> strategy is to have a meta-build script that emits a very
> simple build script that is linear and easy to understand.
That would be nice... in fact configure HAS done a meta
build to presumably fix as much as it can. However, CC can
be passed in on the make command line, and thus needs to be
munged at make time, so the munging needs to be in the makefile.
(This (except for being recast in $() form) is what's in
gcc/Makefile.in and gcc/configure.)
>
> But anyway. in this case, I don't see why you need the
> outer $(echo). you can just delete it.
I don't follow. The inner echo outputs the value of the
CC macro, and munges it for the "stage" change. The outer
echo makes it a string (as opposed to a command to be
executed) to pass it to the second sed to do .. insertion.
That resulting string needs to be passed as an argument
to be used as the value for CC in lower level scripts.
(One echo could be omitted except that there's another
level of macro involved (the @...@ stuff I mentioned in
another mail) that constrains where the "breaks" in the
sequence go.)
> but in the general case... ok, you want to do something like:
>
> vars= "x=1" "y=`foo 1`" "z=$$(bar $$(foo 1))"
> recurse:
> (cd subdir; make $(vars))
>
> my first instinct is to extract the '$(bar $(foo))' into a
> single function, by using a shell script, call it barfoo.sh.
>
> #!/bin/sh
> x=`foo "$@"`
> bar "$x"
>
> and then you can write the makefile as:
>
> vars= "x=1" "y=`foo 1`" "z=`$(aux)/barfoo.sh 1`"
> recurse:
> (cd subdir; make $(vars))
>
> my second instinct is to evaluate all those vars and write
> their values into a file, and use
>
> recurse: $(tmp)/vars.mk
> (cd subdir; make -f $(tmp)/vars.mk -f Makefile)
Yes... those would work, but now it's getting to be enough
of a change to be "a big deal" in its own right. (E.g.
is barfoo.sh something in CVS, or is it made by configure,
or is it made by make (or something else)?) If the
"powers that be" would care to address that issue, then
a solution like this might work.
(I actually kinda like the second one, because there are
LOTS of other similar instances that tend to create long
and complicated recursive makes that this (if vars.mk
was created dynamically) would clean up.)
Donn