help-make
[Top][All Lists]
Advanced

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

Re: explicitly given rules are not used.


From: Paul Smith
Subject: Re: explicitly given rules are not used.
Date: Wed, 30 Dec 2020 16:53:56 -0500
User-agent: Evolution 3.36.4-0ubuntu1

On Wed, 2020-12-30 at 11:04 +0100, andreas graeper via Users list for
the GNU implementation of make wrote:
> now i add n.o (os=n.o -> $(os) not empty anymore)
> and a new rule for objects ( i tried to change the order of rules )
> 
> %.o: TAB %.c %.h

(not relevant to anything, but TAB is not required in the line above.
TAB is only meaningful as the first character on a recipe line;
anywhere else it's just treated the same as any other whitespace).

> TAB $(cc) $(in) -o $@ -c $<
> 
> when i call
>  make n.o             ## n.o is build
>  make x1              ## x1 (now depending on n.o) is build
> the explicit given rules are used.
> 
> when i call `make` (after `make clean` -> no x and no n.o)
> then the explicit rule for x is not found, and so dependencies $(os)
> are not build.
> `make x1` does not work, too, if n.o does not exist.
> 
> long time ago, when i used make for the first time, i cannot remember
> such problems.
> 
>  i`d like to have two rules, one for executables, one for objects
> 
>  (1) %    : %.c $(os)          $^
>  (2) %.o : %.c %.h            $<

Unfortunately I don't understand the problem you're having.  Rather
than showing a working makefile, please concentrate on the non-working
makefile.  Also please check your email carefully to make sure it's
accurate.  For example you say "explicit rule for x is not found";
there's no explicit rule anywhere in the makefile you've shown, and
there's no rule for x anywhere in your makefile.  Did you really mean
implicit rules, and did you really mean x1 not x?

Please create an MCE (minimal, complete example) that shows the
problem, then show how you invoked make, then show the output you got
(please use cut and paste rather than paraphrasing) and explain what is
wrong with that result and what you wanted instead.

One question is, where did this "n.o" come from?  Is this an object
file that you want make to build?  Or is it some object file that
already exists somewhere that you're just linking?

I will say one thing, it's unusual and potentially problematic to
include explicit object files in pattern rules.  Best practice has only
the pattern prerequisites in the pattern rule, then declare the other
prerequisites separately.




reply via email to

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