Subject: Re: BSD .mk files and multiple programs
To: Harlan Stenn <>
From: Simon J. Gerraty <>
List: tech-userlevel
Date: 11/29/2002 16:36:01
On Fri, 29 Nov 2002 18:09:39 -0500, Harlan Stenn writes:
>> >Could I snarf you stuff/chagnes?  The amount of stuff I found on google was
>> My changes are in NetBSD's make.
>As in "already committed to NetBSD's make"?  If not, could I get a copy?

Yes, already committed for a couple of years.

>Too slow.  My goal (at the moment) is to have Makefile's contain information
>very similar to an automake's, which means:
> bin_PROGRAMS = foo1 foo1
> foo1_SOURCES = ...
> foo1_CFLAGS = ...
> foo2_SOURCES = ...
> foo2_LDADD = ...
> noinst_LTLIBRARIES =
> libabc_la_SOURCES = ...
> libdef_la_sources = ...	(Needs work - I don't want to require libtool)
> htmldir = ${Prefix}/share/html
> html_DATA = index.html
>and when I "make install" everything gets built and the _PROGRAMS and _DATA
>targets are properly installed.
>I believe (but do not know) that using a shell loop to get the variables
>will be Slow; I suspect I will want to automate a loop that would do
>something like:

You don't need to know all the var names.  They are provided for you
in a couple of well know vars.  

>and then the same for other "primaries" (like SCRIPTS, DATA, MANS, INCLUDES,

Yes but this is a well defined set - they are not (should not) be

For example:

# multi-target test

LIBS=one two three
PROGS=four five six

one_SRCS=a.c b.c c.c
two_SRCS=d.c e.c
four_SRCS=f.c g.c

.if defined(LIB)

.include <>

.elif defined(PROG)

.include <>


.for val in ${${var}}
	cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} ${var:S/S$//}=${val}


$ make -n -f multi
cd /homes/sjg/make-tests && make -f /homes/sjg/make-tests/multi LIB=one
cd /homes/sjg/make-tests && make -f /homes/sjg/make-tests/multi LIB=two
cd /homes/sjg/make-tests && make -f /homes/sjg/make-tests/multi LIB=three
cd /homes/sjg/make-tests && make -f /homes/sjg/make-tests/multi PROG=four
cd /homes/sjg/make-tests && make -f /homes/sjg/make-tests/multi PROG=five
cd /homes/sjg/make-tests && make -f /homes/sjg/make-tests/multi PROG=six