Search code examples
makefilefreebsdbsd

How do you specify that a FreeBSD Makefile place the objects (*.o) into a different directory?


If I have some source files in another directory and I want to make some libraries using the source files, I want to have the *.o, *.po, and *.So files in the local directory. It isn't clear how to accomplish this. The transformation rules in bsd.lib.mk always point the .o into the source directory.

How do I get the results of the ${CC} -c to be in the local directory?


Solution

  • The file bsd.lib.mk inclused bsd.obj.mak, so you can use the MAKEOBJDIR environment variable.

    Edit: If you cannot control how make is called, then don't use bsd.lib.mk and make explicit dependencies in your Makefile;

    foo.o: ../bar/foo.c