help-make
[Top][All Lists]
Advanced

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

explicitly given rules are not used.


From: andreas graeper
Subject: explicitly given rules are not used.
Date: Wed, 30 Dec 2020 11:04:26 +0100

hi,
some years ago i already asked for help in same situation. but maybe i was
not able to explain the problem. second attempt:

i like to generate x (executable) depending on *.o (object)

--1--
i started without n.o (everything in x*.c : main(), ..)

cc=gcc -Wall -Wextra -Werror ...
xs=x1 x2 x3 x4
os=     (still empty)
in=-Ipath    (actually empty)
ln=-lname   (empty)

all: $(xs)        ## generate all in list 'xs'

%: TAB %.c $(os)     ## os still empty
TAB $(cc) $(in) -o $@ $(ln)

`make` generates x1..x4 with explicit given rule. this works fine.

--2--
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
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            $<

thanks in advance,
Andreas.


reply via email to

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