xref: /freebsd/usr.bin/mkdep/mkdep.1 (revision a8445737e740901f5f2c8d24c12ef7fc8b00134e)
1.\" Copyright (c) 1987, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)mkdep.1	8.1 (Berkeley) 6/6/93
33.\"
34.Dd June 6, 1993
35.Dt MKDEP 1
36.Os BSD 4.2
37.Sh NAME
38.Nm mkdep
39.Nd construct Makefile dependency list
40.Sh SYNOPSIS
41.Nm
42.Op Fl ap
43.Op Fl f Ar file
44.Op Ar flags
45.Ar file ...
46.Sh DESCRIPTION
47.Nm Mkdep
48takes a set of flags for the C compiler and a list
49of C source files as arguments and constructs a set of include
50file dependencies which are written into the file ``.depend''.
51An example of its use in a Makefile might be:
52.Bd -literal -offset indent
53CFLAGS= -O -I../include
54SRCS= file1.c file2.c
55
56depend:
57	mkdep ${CFLAGS} ${SRCS}
58.Ed
59.Pp
60where the macro SRCS is the list of C source files and the macro
61CFLAGS is the list of flags for the C compiler.
62.Pp
63The user has the ability to change the preprocessor and preprocessor options
64used.  For instance, to use Gcc as the preprocessor and to ignore system
65headers, one would use
66.Bd -literal -offset indent
67depend:
68	env MKDEP_CPP="gcc -E" MKDEP_CPP_OPTS=-MM mkdep \\
69		${CFLAGS} ${SRCS}
70.Ed
71.Pp
72The options are as follows:
73.Bl -tag -width Ds
74.It Fl a
75Append to the output file,
76so that multiple
77.Nm mkdep Ns 's
78may be run from a single Makefile.
79.It Fl f
80Write the include file dependencies to
81.Ar file ,
82instead of the default ``.depend''.
83.It Fl p
84Cause
85.Nm
86to produce dependencies of the form:
87.Bd -literal -offset indent
88program: program.c
89.Ed
90.Pp
91so that subsequent makes will produce
92.Ar program
93directly from its C module rather than using an intermediate
94.Pa \&.o
95module.
96This is useful for programs whose source is contained in a single
97module.
98.Sh ENVIRONMENT
99.Bl -tag -width MKDEP_CPP_OPTS
100.It Ev CC
101Specifies the C compiler to use.  The specified compiler is expected to have
102options consistant with the Gnu C compiler.
103.It Ev MKDEP_CPP
104Specifies the preprocessor to use.  The default is "${CC} -E".
105.It Ev MKDEP_CPP_OPTS
106Specifie the non-CFLAGS options for the preprocessor.  The default is
107"-M".
108.El
109.Sh SEE ALSO
110.Xr cc 1 ,
111.Xr cpp 1 ,
112.Xr make 1
113.Sh FILES
114.Bl -tag -width .depend -compact
115.It Pa .depend
116File containing list of dependencies.
117.El
118.Sh HISTORY
119The
120.Nm
121command appeared in
122.Bx 4.3 Tahoe .
123