[Top][All Lists]

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

make -B and the order-only prerequisites

From: John Gamboa
Subject: make -B and the order-only prerequisites
Date: Tue, 1 May 2012 00:27:14 +0200

Hello makers...

I'm having problems with the "make -B" option and the order-only
prerequisites. I've created a simple Makefile to exemplify the problem.
Please consider the following file:

# just "calls" the other prerequisite
all: bin/pseh

# makes the "mkdir" targets phony (cause they don't create any file)
.PHONY: obj bin
        mkdir obj
        mkdir bin

# rules to create the files
bin/pseh: obj/foo | bin
        touch bin/pseh

obj/foo: | obj
        touch obj/foo

 When I run this make file for the first time, it works perfectly: before
creating the bin/pseh file, it calls the "bin" rule (i.e., creates the bin
directory); and before creating the obj/foo file, it calls the "obj" rule
(and creates the obj directory). The problem is: when I run "make -B", make
tries to call "obj" and "bin", and mkdir returns and error, that causes
make to stop.

I'd like to know if there is a proper way (and what should be this way) to
write a Makefile that does what I want, i.e., creates my folders only if
they aren't there (that is the idea of using order-only prerequisites,
AFAICT) *and* works when I decide to "remake" everything.

For now, as a pseudo-solution, I'm using a rule called "clean" that deletes
everything so I can recreate the folders again without the complaints of

Thanks in advance...

John Gamboa

reply via email to

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