make NetBSD specific (bmake) notes

This page is about the NetBSD make, not GNU Make. In this site, we will also find the make (portable) notes page that has interesting information about Makefile creation and techniques for building portable Makefiles.

Interesting links:

make(1)

GNU Make

make (portable) notes page

Troubleshooting

Make cannot find a file included by .include <file.mk>

.include's in make is very similar to C's #include's. It searchs for file surrounded by "" (double quotes) in the local path and files surrounded by <> in system path (usually, /u../../share/mk).

To override system path, pass the -m option. It is highly recommended that it be a absolute path, if you use relative paths, subfiles parsed (included?) by this file will look for the same filepath, but relative to them -> this can yield problems if they are in a different directory level.

The -I option can be used to specify individual files.

For example, to compile kernel modules for NetBSD-current (5.99) I did::

    $ cd src/sys/modules
    $ make -m /disk/spare/netbsd-current/s../../share/mk/ TOOLDIR=/disk/spare/netbsd-current/tools/

Error bmake: no system rules (sys.mk)

If you receive an error like that (probably if you installed bmake in a non-default directory), export the MAKESYSPATH variable to the directory where sys.mk can be found::

$ export MAKESYSPATH=/opt/bmake/share/mk

"bmake: no system rules (sys.mk)" when trying to build OS161 on Mandriva - Stack Overflow