Other Automatically create .OBJDIR subdirectories with bmake

ybungalobill

Member

Reaction score: 11
Messages: 35

I have the following directory structure:

Code:
/xxx/obj/
/xxx/src/deep.cpp
/xxx/flat.cpp
/xxx/makefile

The content of makefile is as follows:

Code:
flat.out: flat.o

deep.out: src/deep.o

I have no problem building flat:

Code:
/xxx $ make flat.out
c++ -O2 -pipe -c /xxx/flat.cpp -o flat.o
cc -O2 -pipe  flat.o  -o flat.out
/xxx $ ls obj
flat.o          flat.out

But when I try to build deep it fails:

Code:
/xxx $ make deep.out
c++ -O2 -pipe -c /xxx/src/deep.cpp -o src/deep.o
error: unable to open output file 'src/deep.o': 'No such file or directory'
1 error generated.
*** Error code 1

Stop.
make: stopped in /xxx

If I then create /xxx/obj/src manually it succeeds:

Code:
/xxx $ mkdir obj/src
/xxx $ make deep.out
c++ -O2 -pipe -c /xxx/src/deep.cpp -o src/deep.o
cc -O2 -pipe  src/deep.o  -o deep.out
/xxx $ ls obj
deep.out        flat.o          flat.out        src
/xxx $ ls obj/src
deep.o

According to this source bmake supports automatic creation of out-of-source OBJDIRs, but I cannot figure out how exactly.

How do I configure bmake(1) to create the relevant directories automatically, in the general case?

Thank you in advance,
YG
 
OP
Y

ybungalobill

Member

Reaction score: 11
Messages: 35

I've already read that file in my attempts to solve this problem. I tried setting

Code:
MKOBJDIRS=auto

and including:

Code:
.include <auto.obj.mk>

But this didn't change anything at all.

I cannot find anywhere an example of how it is supposed to be done, nor I understand enough of the innards of bmake to infer that from the sources. Can you post such an example?
 
OP
Y

ybungalobill

Member

Reaction score: 11
Messages: 35

Ok, thanks, but that doesn't really answer my question. I was assuming that bmake supports auto-creation of directories for arbitrary targets written by me, but on a second inspection it appears that it does not.
 

cpm@

Moderator
Staff member
Moderator
Developer

Reaction score: 953
Messages: 2,140

Top