bsd.incs.mk: include subdirectories
Bryan Drewery
bdrewery at FreeBSD.org
Mon May 16 16:45:10 UTC 2016
On 5/11/16 1:08 PM, Demetrius Siluanius wrote:
> Hello everyone!
>
> Recently I started porting a number of my projects to BSD world. I realized it
> would be great if I could use a native make(1) tool instead of GNU make. I'm
> really impressed how easy it is to create a makefile for a library with almost
> a single '.include bsd.lib.mk' statement. Thank you guys for such an amazing
> build system!
>
> The only thing I couldn't deal with is when headers must be placed into
> subdirectories. For simplicity let's assume that project's headers hierarchy is
> the following one:
> include/
> mylib/
> A/
> A0.h
> A1.h
> B/
> B0.h
> B1.h
> base.h
>
> The only header that will be used is "mylib/base.h", but it includes other
> headers using statements '#include "A/A0.h". What should I do to install files
> like this? I can't really understand what's happening inside of bsd.incs.mk
> file, but I guess there should be something simpler than overriding the default
> 'installincludes' target.
>
> I could't find any relevant information; I tried to find an example Makefile
> which could have a similar headers hierarchy, but didn't succeed. Could you
> help me, please? Thank you!
If I understand correctly then you want something like this in the Makefile:
INCSGROUPS= A B INCS
INCS= base.h
INCSDIR= /usr/include/mylib
A= A0.h A1.h
ADIR= ${INCSDIR}/A
B= B0.h B1.h
BDIR= ${INCSDIR}/B
The trick is that INCSGROUPS defines a <var> and you can use <var>DIR
<var>MODE <var>GRP <var>OWN and <var> to define multiple groups of
includes and where and how they should be installed. The default value
for INCSGROUPS is just 'INCS' which is why INCSDIR and INCSOWN, etc, work.
Regards,
Bryan Drewery
More information about the freebsd-hackers
mailing list