Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Dec 1994 16:14:03 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        hackers@freebsd.org, roberto@blaise.ibp.fr
Subject:   Re: Pb with adduser's Makefile
Message-ID:  <199412300514.QAA31064@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>334 [21:56] root@keltia:usr.sbin/adduser# make
>make: don't know how to make adduser.c. Stop
>335 [21:56] root@keltia:usr.sbin/adduser# 

>cat adduser/Makefile
>STRIP=   
>PROG= adduser

>cleandir:
>clean:
>obj:

>.include <bsd.prog.mk>

Writing small Makefiles for standard FreeBSD utilities is not as simple
as it should be.  You have to know a little bit about bmake and a lot
about the defaults provided by bsd.prog.mk.  bsd.prog.mk doesn't provide
much support for installing shell scripts.  I usually look at the
Makefiles for shell scripts, copy the best one and change some names.
The best one for shell scripts that don't require any substitutions and
have a man page is lorder.sh.  This has one bug: ${DESTDIR}/{${BINDIR}
should be ${DESTDIR}${BINDIR} because it expands to something starting
with // for the default ${DESTDIR}.  Pathnames starting with // are
special and other system Makefiles are careful to avoid them.

I use the above approach to obtain the following Makefile for adduser:
---
MAN1=	adduser.1

beforeinstall:
	install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
	    ${.CURDIR}/adduser ${DESTDIR}${BINDIR}/adduser

.include <bsd.prog.mk>
---

There are still (at least :-) 2 bugs: adduser.1 should be adduser.8
(a few other programs in /usr/src/usr.sbin have the same bug); adduser
should be named adduser.sh for consistency and to allow automating the
beforeinstall rule.

The original Makefile had the following things wrong:

>STRIP=   

This only applies to binaries.

>PROG= adduser

This only applies to binaries too.  There must be a C file named
${PROG}.c or there must be a list of C files given in ${SRCS}.

>cleandir:
>clean:

bsd.prog.mk provides suitable defaults for these, even for non-binaries.
In general, scattered Makefiles shouldn't even know what the defaults
are.

>obj:

bsd.prog.mk provides a currently unsuitable default for this, but I
didn't override the default because of the previous rule.  Man pages
might be built in the object directory.  They currently aren't, but
scattered Makefiles shouldn't know about this detail.

All the other Makefiles for shell scripts in /usr/src/usr.sbin have
instructive minor bugs:

manctl/Makefile:
	Bogus `all' target; `install' target should be `beforeinstall'
	target for consistency (`install' works because there is no man
	page and this is not handled in the standard way by defining
	NOMAN); hardcoded binary directory and mode.

spkrtest/Makefile:
	Knows about too many targets; `install' should be `beforeinstall';
	// bug.

tzsetup/Makefile:
	Bogus macro `NOPROG'; knows about too many targets.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199412300514.QAA31064>