Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Nov 2011 21:40:51 GMT
From:      Mikolaj Golub <trociny@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/162956: New port: devel/bmkdep: Construct Makefile dependency list
Message-ID:  <201111292140.pATLepA2059357@red.freebsd.org>
Resent-Message-ID: <201111292150.pATLoAST090735@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         162956
>Category:       ports
>Synopsis:       New port: devel/bmkdep: Construct Makefile dependency list
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 29 21:50:10 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Mikolaj Golub
>Release:        
>Organization:
>Environment:
>Description:
NetBSD's version of mkdep.

Because it is a C program and does all postprocessing and file
handling without calling any external programs, it is up to 10-percent
faster than the original BSD mkdep shell script.

Also it contains options not available in FreeBSD's mkdep.

WWW: http://netbsd.org

I need this program for devel/mk-congigure: `mkcmake depend' does not work with FreeBSD's mkdep.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	bmkdep
#	bmkdep/Makefile
#	bmkdep/pkg-descr
#	bmkdep/src
#	bmkdep/src/mkdep.c
#	bmkdep/src/findcc.h
#	bmkdep/src/findcc.c
#	bmkdep/src/Makefile
#	bmkdep/src/bmkdep.1
#
echo c - bmkdep
mkdir -p bmkdep > /dev/null 2>&1
echo x - bmkdep/Makefile
sed 's/^X//' >bmkdep/Makefile << '8ba121e4699a7d0138e95bc2510bd587'
X# New ports collection makefile for:		bmkdep
X# Date created:					29 November 2011
X# Whom:						trociny
X#
X# $FreeBSD: $
X#
X# This port is self contained in the src directory.
X#
X
XPORTNAME=	bmkdep
XPORTVERSION=	20111111
XCATEGORIES=	devel
XMASTER_SITES=	# none
XDISTFILES=	# none
X
XMAINTAINER=	trociny@FreeBSD.org
XCOMMENT=	Construct Makefile dependency list
X
XNO_WRKSUBDIR=	yes
X
XMAKEFILE=	${PKGDIR}/src/Makefile
XMAKE_ENV=	PKGDIR="${PKGDIR}" NO_OBJ=YES
X
XMAN1=		bmkdep.1
XMANCOMPRESSED=	yes
XPLIST_FILES=	bin/bmkdep
X
X.include <bsd.port.mk>
8ba121e4699a7d0138e95bc2510bd587
echo x - bmkdep/pkg-descr
sed 's/^X//' >bmkdep/pkg-descr << 'cfd8214ce25ae9631d152bdde3310d5f'
XNetBSD's version of mkdep.
X
XBecause it is a C program and does all postprocessing and file
Xhandling without calling any external programs, it is up to 10-percent
Xfaster than the original BSD mkdep shell script.
X
XAlso it contains options not available in FreeBSD's mkdep.
X
XWWW: http://netbsd.org
cfd8214ce25ae9631d152bdde3310d5f
echo c - bmkdep/src
mkdir -p bmkdep/src > /dev/null 2>&1
echo x - bmkdep/src/mkdep.c
sed 's/^X//' >bmkdep/src/mkdep.c << '71ff88d70b7e3223a6ea4c795b2cbddb'
X/* $NetBSD: mkdep.c,v 1.40 2011/09/04 20:30:06 joerg Exp $ */
X
X/*-
X * Copyright (c) 1999 The NetBSD Foundation, Inc.
X * All rights reserved.
X *
X * This code is derived from software contributed to The NetBSD Foundation
X * by Matthias Scheler.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X *
X * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
X * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
X * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
X * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
X * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
X * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
X * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
X * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
X * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
X * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
X * POSSIBILITY OF SUCH DAMAGE.
X */
X
X#if HAVE_NBTOOL_CONFIG_H
X#include "nbtool_config.h"
X#endif
X
X#include <sys/cdefs.h>
X#if !defined(lint)
X__COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\
X All rights reserved.");
X__RCSID("$NetBSD: mkdep.c,v 1.40 2011/09/04 20:30:06 joerg Exp $");
X#endif /* not lint */
X
X#include <sys/mman.h>
X#include <sys/param.h>
X#include <sys/wait.h>
X#include <ctype.h>
X#include <err.h>
X#include <fcntl.h>
X#include <getopt.h>
X#include <locale.h>
X#include <paths.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include <unistd.h>
X
X#include "findcc.h"
X
Xtypedef struct opt opt_t;
Xstruct opt {
X	opt_t	*left;
X	opt_t	*right;
X	int	len;
X	int	count;
X	char	name[4];
X};
X
Xtypedef struct suff_list {
X	size_t	len;
X	char	*suff;
X	struct suff_list *next;
X} suff_list_t;
X
X/* tree of includes for -o processing */
Xstatic opt_t *opt;
Xstatic int width;
X
X#define DEFAULT_PATH		_PATH_DEFPATH
X#define DEFAULT_FILENAME	".depend"
X
Xstatic void save_for_optional(const char *, const char *);
Xstatic int write_optional(int, opt_t *, int);
X
Xstatic inline void *
Xdeconst(const void *p)
X{
X	return (const char *)p - (const char *)0 + (char *)0;
X}
X
Xstatic void
Xusage(void)
X{
X	(void)fprintf(stderr,
X	    "usage: %s [-aDdopq] [-f file] [-s suffixes] -- [flags] file ...\n",
X	    getprogname());
X	exit(EXIT_FAILURE);
X}
X
Xstatic int
Xrun_cc(int argc, char **argv, const char **fname)
X{
X	const char *CC, *tmpdir;
X	char * volatile pathname;
X	static char tmpfilename[MAXPATHLEN];
X	char **args;
X	int tmpfd;
X	pid_t pid, cpid;
X	int status;
X
X	if ((CC = getenv("CC")) == NULL)
X		CC = DEFAULT_CC;
X	if ((pathname = findcc(CC)) == NULL)
X		if (!setenv("PATH", DEFAULT_PATH, 1))
X			pathname = findcc(CC);
X	if (pathname == NULL)
X		err(EXIT_FAILURE, "%s: not found", CC);
X	if ((args = malloc((argc + 3) * sizeof(char *))) == NULL)
X		err(EXIT_FAILURE, "malloc");
X
X	args[0] = deconst(CC);
X	args[1] = deconst("-M");
X	(void)memcpy(&args[2], argv, (argc + 1) * sizeof(char *));
X
X	if ((tmpdir = getenv("TMPDIR")) == NULL)
X		tmpdir = _PATH_TMP;
X	(void)snprintf(tmpfilename, sizeof (tmpfilename), "%s/%s", tmpdir,
X	    "mkdepXXXXXX");
X	if ((tmpfd = mkstemp(tmpfilename)) < 0)
X		err(EXIT_FAILURE,  "Unable to create temporary file %s",
X		    tmpfilename);
X	(void)unlink(tmpfilename);
X	*fname = tmpfilename;
X
X	switch (cpid = vfork()) {
X	case 0:
X		(void)dup2(tmpfd, STDOUT_FILENO);
X		(void)close(tmpfd);
X
X		(void)execv(pathname, args);
X		_exit(EXIT_FAILURE);
X		/* NOTREACHED */
X
X	case -1:
X		err(EXIT_FAILURE, "unable to fork");
X	}
X
X	free(pathname);
X	free(args);
X
X	while (((pid = wait(&status)) != cpid) && (pid >= 0))
X		continue;
X
X	if (status)
X		errx(EXIT_FAILURE, "compile failed.");
X
X	return tmpfd;
X}
X
Xstatic const char *
Xread_fname(void)
X{
X	static char *fbuf;
X	static int fbuflen;
X	int len, ch;
X
X	for (len = 0; (ch = getchar()) != EOF; len++) {
X		if (isspace(ch)) {
X			if (len != 0)
X				break;
X			len--;
X			continue;
X		}
X		if (len >= fbuflen - 1) {
X			fbuf = realloc(fbuf, fbuflen += 32);
X			if (fbuf == NULL)
X				err(EXIT_FAILURE, "no memory");
X		}
X		fbuf[len] = ch;
X	}
X	if (len == 0)
X		return NULL;
X	fbuf[len] = 0;
X	return fbuf;
X}
X
Xstatic struct option longopt[] = {
X	{ "sysroot", 1, NULL, 'R' },
X	{ NULL, 0, NULL, '\0' },
X};
X
Xstatic void
Xaddsuff(suff_list_t **l, const char *s, size_t len)
X{
X	suff_list_t *p = calloc(1, sizeof(*p));
X	if (p == NULL)
X		err(1, "calloc");
X	p->suff = malloc(len + 1);
X	if (p->suff == NULL)
X		err(1, "malloc");
X	memcpy(p->suff, s, len);
X	p->suff[len] = '\0';
X	p->len = len;
X	p->next = *l;
X	*l = p;
X}
X
Xint
Xmain(int argc, char **argv)
X{
X	int 	aflag, dflag, oflag, qflag;
X	const char *filename;
X	int	dependfile;
X	char	*buf, *lim, *ptr, *line, *suf, *colon, *eol;
X	int	ok_ind, ch;
X	size_t	sz;
X	int	fd;
X	size_t  slen;
X	const char *fname;
X	const char *suffixes = NULL, *s;
X	suff_list_t *suff_list = NULL, *sl;
X
X	suf = NULL;		/* XXXGCC -Wuninitialized [sun2] */
X	sl = NULL;		/* XXXGCC -Wuninitialized [sun2] */
X
X	setlocale(LC_ALL, "");
X	setprogname(argv[0]);
X
X	aflag = O_WRONLY | O_APPEND | O_CREAT | O_TRUNC;
X	dflag = 0;
X	oflag = 0;
X	qflag = 0;
X	filename = DEFAULT_FILENAME;
X	dependfile = -1;
X
X	opterr = 0;	/* stop getopt() bleating about errors. */
X	for (;;) {
X		ok_ind = optind;
X		ch = getopt_long(argc, argv, "aDdf:opqRs:", longopt, NULL);
X		switch (ch) {
X		case -1:
X			ok_ind = optind;
X			break;
X		case 'a':	/* Append to output file */
X			aflag &= ~O_TRUNC;
X			continue;
X		case 'D':	/* Process *.d files (don't run cc -M) */
X			dflag = 2;	/* Read names from stdin */
X			opterr = 1;
X			continue;
X		case 'd':	/* Process *.d files (don't run cc -M) */
X			dflag = 1;
X			opterr = 1;
X			continue;
X		case 'f':	/* Name of output file */
X			filename = optarg;
X			continue;
X		case 'o':	/* Mark dependent files .OPTIONAL */
X			oflag = 1;
X			continue;
X		case 'p':	/* Program mode (x.o: -> x:) */
X			suffixes = "";
X			continue;
X		case 'q':	/* Quiet */
X			qflag = 1;
X			continue;
X		case 'R':
X			/* sysroot = optarg */
X			continue;
X		case 's':	/* Suffix list */
X			suffixes = optarg;
X			continue;
X		default:
X			if (dflag)
X				usage();
X			/* Unknown arguments are passed to "${CC} -M" */
X			break;
X		}
X		break;
X	}
X
X	argc -= ok_ind;
X	argv += ok_ind;
X	if ((argc == 0 && !dflag) || (argc != 0 && dflag == 2))
X		usage();
X
X	if (suffixes != NULL) {
X		if (*suffixes) {
X			for (s = suffixes; (sz = strcspn(s, ", ")) != 0;) {
X				addsuff(&suff_list, s, sz);
X				s += sz;
X				while (*s && strchr(", ", *s))
X					s++;
X			}
X		} else
X			addsuff(&suff_list, "", 0);
X	}
X
X	dependfile = open(filename, aflag, 0666);
X	if (dependfile == -1)
X		err(EXIT_FAILURE, "unable to %s to file %s\n",
X		    aflag & O_TRUNC ? "write" : "append", filename);
X
X	while (dflag == 2 || *argv != NULL) {
X		if (dflag) {
X			if (dflag == 2) {
X				fname = read_fname();
X				if (fname == NULL)
X					break;
X			} else
X				fname = *argv++;
X			fd = open(fname, O_RDONLY, 0);
X			if (fd == -1) {
X				if (!qflag)
X					warn("ignoring %s", fname);
X				continue;
X			}
X		} else {
X			fd = run_cc(argc, argv, &fname);
X			/* consume all args... */
X			argv += argc;
X		}
X
X		sz = lseek(fd, 0, SEEK_END);
X		if (sz == 0) {
X			close(fd);
X			continue;
X		}
X		buf = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
X		close(fd);
X
X		if (buf == MAP_FAILED)
X			err(EXIT_FAILURE, "unable to mmap file %s", fname);
X		lim = buf + sz - 1;
X
X		/* Remove leading "./" from filenames */
X		for (ptr = buf; ptr < lim; ptr++) {
X			if (ptr[1] != '.' || ptr[2] != '/'
X			    || !isspace((unsigned char)ptr[0]))
X				continue;
X			ptr[1] = ' ';
X			ptr[2] = ' ';
X		}
X
X		for (line = eol = buf; eol <= lim;) {
X			while (eol <= lim && *eol++ != '\n')
X				/* Find end of this line */
X				continue;
X			if (line == eol - 1) {
X				/* empty line - ignore */
X				line = eol;
X				continue;
X			}
X			if (eol[-2] == '\\')
X				/* Assemble continuation lines */
X				continue;
X			for (colon = line; *colon != ':'; colon++) {
X				if (colon >= eol) {
X					colon = NULL;
X					break;
X				}
X			}
X			if (isspace((unsigned char)*line) || colon == NULL) {
X				/* No dependency - just transcribe line */
X				write(dependfile, line, eol - line);
X				line = eol;
X				continue;
X			}
X			if (suff_list != NULL) {
X				/* Find the .o: */
X				/* First allow for any whitespace */
X				for (suf = colon; suf > buf; suf--) {
X					if (!isspace((unsigned char)suf[-1]))
X						break;
X				}
X				if (suf == buf)
X					errx(EXIT_FAILURE,
X					    "Corrupted file `%s'", fname);
X				/* Then look for any valid suffix */
X				for (sl = suff_list; sl != NULL;
X				    sl = sl->next) {
X					if (sl->len && buf <= suf - sl->len &&
X					    !memcmp(suf - sl->len, sl->suff,
X						    sl->len))
X						break;
X				}
X				/*
X				 * Not found, check for .o, since the
X				 * original file will have it.
X				 */
X				if (sl == NULL) {
X					if (memcmp(suf - 2, ".o", 2) == 0)
X						slen = 2;
X					else
X						slen = 0;
X				} else
X					slen = sl->len;
X			}
X			if (suff_list != NULL && slen != 0) {
X				suf -= slen;
X				for (sl = suff_list; sl != NULL; sl = sl->next)
X				{
X					if (sl != suff_list)
X						write(dependfile, " ", 1);
X					write(dependfile, line, suf - line);
X					write(dependfile, sl->suff, sl->len);
X				}
X				write(dependfile, colon, eol - colon);
X			} else
X				write(dependfile, line, eol - line);
X
X			if (oflag)
X				save_for_optional(colon + 1, eol);
X			line = eol;
X		}
X		munmap(buf, sz);
X	}
X
X	if (oflag && opt != NULL) {
X		write(dependfile, ".OPTIONAL:", 10);
X		width = 9;
X		sz = write_optional(dependfile, opt, 0);
X		/* 'depth' is about 39 for an i386 kernel */
X		/* fprintf(stderr, "Recursion depth %d\n", sz); */
X	}
X	close(dependfile);
X
X	exit(EXIT_SUCCESS);
X}
X
X
X/*
X * Only save each file once - the kernel .depend is 3MB and there is
X * no point doubling its size.
X * The data seems to be 'random enough' so the simple binary tree
X * only has a reasonable depth.
X */
Xstatic void
Xsave_for_optional(const char *start, const char *limit)
X{
X	opt_t **l, *n;
X	const char *name, *end;
X	int c;
X
X	while (start < limit && strchr(" \t\n\\", *start)) 
X		start++;
X	for (name = start; ; name = end) {
X		while (name < limit && strchr(" \t\n\\", *name)) 
X			name++;
X		for (end = name; end < limit && !strchr(" \t\n\\", *end);)
X			end++;
X		if (name >= limit)
X			break;
X		if (end[-1] == 'c' && end[-2] == '.' && name == start)
X			/* ignore dependency on the files own .c */
X			continue;
X		for (l = &opt;;) {
X			n = *l;
X			if (n == NULL) {
X				n = malloc(sizeof *n + (end - name));
X				n->left = n->right = 0;
X				n->len = end - name;
X				n->count = 1;
X				n->name[0] = ' ';
X				memcpy(n->name + 1, name, end - name);
X				*l = n;
X				break;
X			}
X			c = (end - name) - n->len;
X			if (c == 0)
X				c = memcmp(n->name + 1, name, (end - name));
X			if (c == 0) {
X				/* Duplicate */
X				n->count++;
X				break;
X			}
X			if (c < 0)
X				l = &n->left;
X			else
X				l = &n->right;
X		}
X	}
X}
X
Xstatic int
Xwrite_optional(int fd, opt_t *node, int depth)
X{
X	int d1 = ++depth;
X
X	if (node->left)
X		d1 = write_optional(fd, node->left, d1);
X	if (width > 76 - node->len) {
X		write(fd, " \\\n ", 4);
X		width = 1;
X	}
X	width += 1 + node->len;
X	write(fd, node->name, 1 + node->len);
X	if (node->right)
X		depth = write_optional(fd, node->right, depth);
X	return d1 > depth ? d1 : depth;
X}
71ff88d70b7e3223a6ea4c795b2cbddb
echo x - bmkdep/src/findcc.h
sed 's/^X//' >bmkdep/src/findcc.h << '447c9b2a91e29830a24cbac89ba02280'
X#define DEFAULT_CC		"cc"
X
Xchar *findcc(const char *);
447c9b2a91e29830a24cbac89ba02280
echo x - bmkdep/src/findcc.c
sed 's/^X//' >bmkdep/src/findcc.c << '8bfc28d9af4215cb97e7c350096cb83e'
X/* $NetBSD: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $ */
X
X/*-
X * Copyright (c) 1999 The NetBSD Foundation, Inc.
X * All rights reserved.
X *
X * This code is derived from software contributed to The NetBSD Foundation
X * by Matthias Scheler.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X *
X * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
X * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
X * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
X * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
X * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
X * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
X * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
X * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
X * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
X * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
X * POSSIBILITY OF SUCH DAMAGE.
X */
X
X#if HAVE_NBTOOL_CONFIG_H
X#include "nbtool_config.h"
X#endif
X
X#include <sys/cdefs.h>
X#if !defined(lint)
X__COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\
X All rights reserved.");
X__RCSID("$NetBSD: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $");
X#endif /* not lint */
X
X#include <sys/param.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include <unistd.h>
X
X#include "findcc.h"
X
Xchar *
Xfindcc(const char *progname)
X{
X	char   *path, *dir, *next;
X	char   buffer[MAXPATHLEN];
X
X	if ((next = strchr(progname, ' ')) != NULL) {
X		*next = '\0';
X	}
X
X	if (strchr(progname, '/') != NULL)
X		return access(progname, X_OK) ? NULL : strdup(progname);
X
X	if (((path = getenv("PATH")) == NULL) ||
X	    ((path = strdup(path)) == NULL))
X		return NULL;
X
X	dir = path;
X	while (dir != NULL) {
X		if ((next = strchr(dir, ':')) != NULL)
X			*next++ = '\0';
X
X		if (snprintf(buffer, sizeof(buffer),
X		    "%s/%s", dir, progname) < (int)sizeof(buffer)) {
X			if (!access(buffer, X_OK)) {
X				free(path);
X				return strdup(buffer);
X			}
X		}
X		dir = next;
X	}
X
X	free(path);
X	return NULL;
X}
X
8bfc28d9af4215cb97e7c350096cb83e
echo x - bmkdep/src/Makefile
sed 's/^X//' >bmkdep/src/Makefile << '0de87aaa8118086d5075ba7d5567eb9c'
X#	$NetBSD: Makefile,v 1.17 2009/04/12 14:23:30 lukem Exp $
X#	@(#)Makefile	8.1 (Berkeley) 6/6/93
X#	$FreeBSD: $
X
X.PATH:	${PKGDIR}/src
X
X#CFLAGS+=-g
XMAN=	bmkdep.1
XPROG=	bmkdep
XSRCS=	mkdep.c findcc.c
X
XBINDIR=	${PREFIX}/bin
XMANDIR=	${PREFIX}/man/man
X
X.include <bsd.prog.mk>
0de87aaa8118086d5075ba7d5567eb9c
echo x - bmkdep/src/bmkdep.1
sed 's/^X//' >bmkdep/src/bmkdep.1 << '8dadd6972af7b0f943f63b1d74d08730'
X.\"	$NetBSD: mkdep.1,v 1.16 2011/06/30 20:09:42 wiz Exp $
X.\"
X.\" Copyright (c) 1987, 1990, 1993
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"     @(#)mkdep.1	8.1 (Berkeley) 6/6/93
X.\"
X.Dd October 15, 2010
X.Dt MKDEP 1
X.Os
X.Sh NAME
X.Nm mkdep
X.Nd construct Makefile dependency list
X.Sh SYNOPSIS
X.Nm
X.Op Fl aDdopq
X.Op Fl f Ar file
X.Op Fl s Ar suffixes
X.Li --
X.Op Ar flags
X.Ar file ...
X.Sh DESCRIPTION
X.Nm
Xtakes a set of flags for the C compiler and a list
Xof C source files as arguments and constructs a set of include
Xfile dependencies which are written into the file ``.depend''.
XAn example of its use in a Makefile might be:
X.Bd -literal -offset indent
XCFLAGS= -O -I../include
XSRCS= file1.c file2.c
X
Xdepend:
X	mkdep -- ${CFLAGS} ${SRCS}
X.Ed
X.Pp
Xwhere the macro SRCS is the list of C source files and the macro
XCFLAGS is the list of flags for the C compiler.
X.Pp
XThe options are as follows:
X.Bl -tag -width Ds
X.It Fl a
XAppend to the output file,
Xso that multiple
X.Nm Ns 's
Xmay be run from a single Makefile.
X.It Fl D
XPost process (as
X.Fl d )
Xbut read the list of filenames from stdin.
X.It Fl d
XPost process and merge previously created (for example by
X.Dq cc -MD x.c )
Xdepend files into a single file.
X.It Fl f
XWrite the include file dependencies to
X.Ar file ,
Xinstead of the default ``.depend''.
X.It Fl o
XAdd an additional .OPTIONAL line for each dependent file.
X.It Fl p
XCause
X.Nm
Xto produce dependencies of the form:
X.Bd -literal -offset indent
Xprogram: program.c
X.Ed
X.Pp
Xso that subsequent makes will produce
X.Ar program
Xdirectly from its C module rather than using an intermediate
X.Pa \&.o
Xmodule.
XThis is useful for programs whose source is contained in a single
Xmodule.
X.Fl p
Xis equivalent to specifying a null suffix with
X.Fl s .
X.It Fl q
XDo not print a warning for inaccessible files when
X.Fl d
Xis given.
X.It Fl s
XExpand each target filename to a list, replacing the
X.Ql \&.o
Xsuffix with each element of
X.Ar suffixes .
XThe list of suffixes may be space or comma separated.
X.El
X.Sh FILES
X.Bl -tag -width .depend -compact
X.It Pa .depend
XFile containing list of dependencies.
X.El
X.Sh SEE ALSO
X.Xr cc 1 ,
X.Xr cpp 1 ,
X.Xr make 1
X.Sh HISTORY
XThe
X.Nm
Xcommand appeared in
X.Bx 4.3 Tahoe .
X.Sh BUGS
XSome characters special to
X.Xr make 1 ,
Xmost notably the comment character, are not escaped correctly if they
Xappear in file names.
XThis can lead to unparseable output or silently cause dependencies to
Xbe lost.
X.\" (This problem is actually in gcc -M.)
8dadd6972af7b0f943f63b1d74d08730
exit



>Release-Note:
>Audit-Trail:
>Unformatted:



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