Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make - pattern rule target wrongly treated as intermediate

Tags:

makefile

I have a makefile that does something like this:

.INTERMEDIATE: gen0.tmp gen1.tmp
.PHONY: %_test
%_test: tests/%.so
    ln -fs $< test.so
tests/%.so: gen.o test_src/%.c
    cc -shared $^ -o $@
gen.c: gen0.tmp gen1.tmp
    cat $^ > $@
gen%.tmp:
    seds and awks and non-relevant stuff    

As far as i have understood make's documentation, all files created from implicit rules are treated as intermediate, but that is not true for pattern rules, yet whatever .so i create with %_test rule is being deleted with other intermediate files, unless it existed before calling make. What is wrong here?

Also

.SECONDARY: tests/%.so

Doesn't work and

.SECONDARY:

does, but then targets explicitly marked as .INTERMEDIATE aren't beeing deleted, and i don't think marking my main target as .SECONDARY is good practice.

PS: i use make version 3.81

like image 787
Ryba Avatar asked Oct 24 '25 02:10

Ryba


1 Answers

I don't understand your statement all files created from implicit rules are treated as intermediate, but that is not true for pattern rules.

A pattern rule IS a (type of) implicit rule. It absolutely is the case that targets which are created as a result of a pattern rule may be considered intermediate.

like image 171
MadScientist Avatar answered Oct 26 '25 16:10

MadScientist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!