This is the mail archive of the gcc-patches@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: cpplib: Implement -MP for phony targets [was re: -MT]


Hi Tom,

Tom Tromey wrote:-

> How do I do this?  I'd imagine that `gcj -M -o H.o Hello.java' would
> automatically set the output target to `H.o'.  But the `-o' argument
> to gcj isn't passed to jc1.
> 
> Is there a way to do this?  Maybe have a spec %{o*:Mx%*}, where -Mx is a
> jc1 option that lets us capture this info?  That seems fairly ugly.

OK.  Here are the specs that handle it for CPP (and, yes, it's not
pretty).

This gets the target right, if -o given:-

%{M|MD|MM|MMD:%{o*:-MQ %*}}

and this gets the file location correct (to depend on -o if given):-

%{MD:-M -MF %{!o: %b.d}%{o*:%.d%*}} %{MMD:-MM -MF %{!o: %b.d}%{o*:%.d%*}}

A new SPEC spec :-), "%.", needed to support this was added by
Nathan's patch which I committed yesterday.  Depending upon how you
want dependencies in Java, you may need to tweak these in a minor way,
though I suspect they work out of the box. [I don't know if you want
to support -MD and -MMD from the driver, I suspect you do.]

If deps generation has been requested (through -M or -MM), you should
call deps_add_default_target after switch processing with whatever you
want the default target to be named after (probably the full input
filename).  The function will alter the suffix for you.  The important
thing is that if any other target has been given through -MQ or -MT
(i.e. by calling deps_add_target), then the function does nothing -
and you don't need to track this yourself.

I'd also suggest you change the -MT implementation so that it calls
deps_add_target with "quoted" as 0, and maybe add support for -MQ, if
only for consistency with CPP.

I also generate an error if any of the -M options was specified without
specifying -M or -MM, viz:-

  if (CPP_OPTION (pfile, print_deps) == 0 &&
      (CPP_OPTION (pfile, print_deps_missing_files)
       || CPP_OPTION (pfile, deps_file)
       || CPP_OPTION (pfile, deps_phony_targets)))
    cpp_fatal (pfile, "you must additionally specify either -M or -MM");

Hope that's what you wanted to know.  If in doubt, have a look at
cppinit.c - it's fairly straight forward I think.

Neil.

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