bug-make
[Top][All Lists]
Advanced

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

Re: Macro question


From: David Boyce
Subject: Re: Macro question
Date: Wed, 9 Dec 2015 08:09:42 -0800

First, I think there’s some missing context as you seem to have an
unusual environment. You’re mixing Unix (cat, rm) and Windows (link)
invocations; is it Cygwin, GNUWin32, MKS, ???

Second, I suspect the macro is a red herring and thus this is not
really a “Macro question”. The macro should just expand to the same
text you’d get by typing it out. What happens when the macro is
replaced by the equivalent 3-line recipe?

Third, there should be nothing you have to do differently because this
should work as desired. Since you’re not joining the 3 lines together
with && and \, the result should be a 3-line recipe in which each line
should abort the recipe on failure.

I suspect the problem will turn out to be an interaction between the
shell you use and the Win32 make build you use, but you should start
by disentangling it from the macro.

Two other little notes: (1) I don’t understand how you can be
capturing error messages with > redirection, unless link.exe is dumb
enough to send errors to stdout. And (2) the second and third macro
lines could be a little more robust by using $(basename $1) rather
than assuming the extensions to be .dll and .lib.

-David Boyce

On Wed, Dec 9, 2015 at 7:19 AM, Gisle Vanem <address@hidden> wrote:
> I have a question regarding a GNU-make macro like this
> (which I use to link a MSVC .dll):
>
>   define do_link_DLL
>     link $(LDFLAGS) -dll -out:$(1) -implib:$(2) \
>          -pdb:$(1:.dll=.pdb) -map:$(1:.dll=.map) $(3) > link.tmp
>     cat link.tmp >> $(1:.dll=.map)
>     rm -f $(2:.lib=.exp) link.tmp
>   endef
>
> Using this as (in a Wireshark makefile):
>
>   wiretap.dll: $(WIRETAP_OBJ)
>      $(call do_link_DLL,wiretap.dll,wiretap_imp.lib, $^ $(EXTRA_LIBS))
>
> AFAICS, if the 'link' stage fails, the rule continues to the 'cat' + 'rm' part
> regardless. But from gmake's perspective all the commands succeeds (since
> cat+rm returns 0). No?
>
> How can I define my macro for gmake to quit on 'link' error?
> Can the macro be written into a Perl-like:
>   exec("link $args") || die "link failed";
>
> If so, how?
>
> PS. Since I have '-verbose' in LDFLAGS, it is handy to redirect those
>   (error) messages into 'link.tmp' in case of a link-failure.
>
> --
> --gv
>
> _______________________________________________
> Bug-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-make



reply via email to

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