From owner-freebsd-hackers Thu Dec 29 21:15:11 1994 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id VAA12335 for hackers-outgoing; Thu, 29 Dec 1994 21:15:11 -0800 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.34]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id VAA12325 for ; Thu, 29 Dec 1994 21:15:04 -0800 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id QAA31064; Fri, 30 Dec 1994 16:14:03 +1100 Date: Fri, 30 Dec 1994 16:14:03 +1100 From: Bruce Evans Message-Id: <199412300514.QAA31064@godzilla.zeta.org.au> To: hackers@freebsd.org, roberto@blaise.ibp.fr Subject: Re: Pb with adduser's Makefile Sender: hackers-owner@freebsd.org Precedence: bulk >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 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 --- 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