Where to put common Makefile code
Julio Merino
julio at meroh.net
Sun Jan 12 23:44:34 UTC 2014
On Jan 12, 2014, at 15:43, Dimitry Andric <dim at FreeBSD.org> wrote:
> On 12 Jan 2014, at 11:25, Julio Merino <julio at meroh.net> wrote:
>>
>> I have some common Makefile boilerplate code for both lib/atf/ and
>> usr.bin/atf/ that I'm unsure about where to best put it.
>>
>> The code in question is the definition of a set of useful variables
>> and target rules that can be depended on where necessary to, e.g.
>> obtain atf's version number from the files in contrib/atf/
>>
>> The fragment is not "long enough" to be a big deal if it were
>> duplicated in 3 different Makefiles, but obviously I'd prefer to avoid
>> the copy/paste.
>>
>> So where would you put this?
>
> For an example (admittedly not the most elegant, but it works), have a
> look at lib/clang/clang.build.mk, which contains the common make-related
> bits for clang and llvm. This is included by the clang and llvm
> libraries (which live under lib/clang) via lib/clang/clang.lib.mk, and
> by the clang and llvm programs (which live under usr.bin/clang) via
> usr.bin/clang/clang.prog.mk.
OK, so because there was prior art in just adding a file to the corresponding lib/ subdirectory and using it outside of lib/, I went ahead and did it.
Thanks!
More information about the freebsd-hackers
mailing list