This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: rfc: new libgcc build mechanism


Donn Terry <donnte@microsoft.com>:
> 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.

But anyway.  in this case, I don't see why you need the
outer $(echo).  you can just delete it.

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)

--

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]