Merge style- and trivial- only changes from OpenBSD (dated 1999/07/29-19:55+1).

Obtained from:	OpenBSD, sometimes indirected from NetBSD; myself
This commit is contained in:
Tim Vanderhoek 1999-08-17 00:39:26 +00:00
parent bfbacbd93f
commit 9bd2d6eee4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=49938
23 changed files with 535 additions and 290 deletions

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: arch.c,v 1.9 1998/10/15 13:00:34 jkoshy Exp $
* $Id: arch.c,v 1.10 1998/10/15 16:09:56 jdp Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-
@ -146,13 +151,12 @@ ArchFree(ap)
/* Free memory from hash entries */
for (entry = Hash_EnumFirst(&a->members, &search);
entry != (Hash_Entry *)NULL;
entry != NULL;
entry = Hash_EnumNext(&search))
free((Address) Hash_GetValue (entry));
free(a->name);
if (a->fnametab)
free(a->fnametab);
efree(a->fnametab);
Hash_DeleteTable(&a->members);
free((Address) a);
}
@ -474,9 +478,8 @@ ArchStatMember (archive, member, hash)
* the comparisons easier...
*/
cp = strrchr (member, '/');
if (cp != (char *) NULL) {
if (cp != NULL)
member = cp + 1;
}
ln = Lst_Find (archives, (ClientData) archive, ArchFindArchive);
if (ln != NILLNODE) {
@ -484,7 +487,7 @@ ArchStatMember (archive, member, hash)
he = Hash_FindEntry (&ar->members, member);
if (he != (Hash_Entry *) NULL) {
if (he != NULL) {
return ((struct ar_hdr *) Hash_GetValue (he));
} else {
/* Try truncated name */
@ -498,7 +501,7 @@ ArchStatMember (archive, member, hash)
}
if ((he = Hash_FindEntry (&ar->members, copy)) != NULL)
return ((struct ar_hdr *) Hash_GetValue (he));
return ((struct ar_hdr *) NULL);
return (NULL);
}
}
@ -514,8 +517,8 @@ ArchStatMember (archive, member, hash)
arch = ArchFindMember(archive, member, &sarh, "r");
if (arch == (FILE *)NULL) {
return ((struct ar_hdr *)NULL);
if (arch == NULL) {
return (NULL);
} else {
fclose(arch);
return (&sarh);
@ -527,8 +530,8 @@ ArchStatMember (archive, member, hash)
* everything that's in it and cache it so we can get at it quickly.
*/
arch = fopen (archive, "r");
if (arch == (FILE *) NULL) {
return ((struct ar_hdr *) NULL);
if (arch == NULL) {
return (NULL);
}
/*
@ -538,7 +541,7 @@ ArchStatMember (archive, member, hash)
if ((fread (magic, SARMAG, 1, arch) != 1) ||
(strncmp (magic, ARMAG, SARMAG) != 0)) {
fclose (arch);
return ((struct ar_hdr *) NULL);
return (NULL);
}
ar = (Arch *)emalloc (sizeof (Arch));
@ -609,19 +612,19 @@ ArchStatMember (archive, member, hash)
if (fread (memName, elen, 1, arch) != 1)
goto badarch;
memName[elen] = '\0';
fseek (arch, -elen, 1);
fseek (arch, -elen, SEEK_CUR);
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("ArchStat: Extended format entry for %s\n", memName);
}
}
#endif
he = Hash_CreateEntry (&ar->members, memName, (Boolean *)NULL);
he = Hash_CreateEntry (&ar->members, memName, NULL);
Hash_SetValue (he, (ClientData)emalloc (sizeof (struct ar_hdr)));
memcpy ((Address)Hash_GetValue (he), (Address)&arh,
sizeof (struct ar_hdr));
}
fseek (arch, (size + 1) & ~1, 1);
fseek (arch, (size + 1) & ~1, SEEK_CUR);
}
fclose (arch);
@ -634,19 +637,18 @@ ArchStatMember (archive, member, hash)
*/
he = Hash_FindEntry (&ar->members, member);
if (he != (Hash_Entry *) NULL) {
if (he != NULL) {
return ((struct ar_hdr *) Hash_GetValue (he));
} else {
return ((struct ar_hdr *) NULL);
return (NULL);
}
badarch:
fclose (arch);
Hash_DeleteTable (&ar->members);
if (ar->fnametab)
free(ar->fnametab);
efree(ar->fnametab);
free ((Address)ar);
return ((struct ar_hdr *) NULL);
return (NULL);
}
#ifdef SVR4ARCHIVES
@ -786,8 +788,8 @@ ArchFindMember (archive, member, arhPtr, mode)
int len, tlen;
arch = fopen (archive, mode);
if (arch == (FILE *) NULL) {
return ((FILE *) NULL);
if (arch == NULL) {
return (NULL);
}
/*
@ -797,7 +799,7 @@ ArchFindMember (archive, member, arhPtr, mode)
if ((fread (magic, SARMAG, 1, arch) != 1) ||
(strncmp (magic, ARMAG, SARMAG) != 0)) {
fclose (arch);
return ((FILE *) NULL);
return (NULL);
}
/*
@ -822,7 +824,7 @@ ArchFindMember (archive, member, arhPtr, mode)
* and there's no way we can recover...
*/
fclose (arch);
return ((FILE *) NULL);
return (NULL);
} else if (strncmp (member, arhPtr->ar_name, tlen) == 0) {
/*
* If the member's name doesn't take up the entire 'name' field,
@ -841,7 +843,7 @@ ArchFindMember (archive, member, arhPtr, mode)
* the file at the actual member, rather than its header, but
* not here...
*/
fseek (arch, -sizeof(struct ar_hdr), 1);
fseek (arch, -sizeof(struct ar_hdr), SEEK_CUR);
return (arch);
}
} else
@ -871,10 +873,10 @@ ArchFindMember (archive, member, arhPtr, mode)
}
if (strncmp(ename, member, len) == 0) {
/* Found as extended name */
fseek (arch, -sizeof(struct ar_hdr) - elen, 1);
fseek (arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
return (arch);
}
fseek (arch, -elen, 1);
fseek (arch, -elen, SEEK_CUR);
goto skip;
} else
#endif
@ -889,7 +891,7 @@ skip:
*/
arhPtr->ar_size[sizeof(arhPtr->ar_size)-1] = '\0';
size = (int) strtol(arhPtr->ar_size, NULL, 10);
fseek (arch, (size + 1) & ~1, 1);
fseek (arch, (size + 1) & ~1, SEEK_CUR);
}
}
@ -898,7 +900,7 @@ skip:
* archive and return NULL -- an error.
*/
fclose (arch);
return ((FILE *) NULL);
return (NULL);
}
/*-
@ -927,13 +929,11 @@ Arch_Touch (gn)
arch = ArchFindMember(Var_Value (ARCHIVE, gn, &p1),
Var_Value (TARGET, gn, &p2),
&arh, "r+");
if (p1)
free(p1);
if (p2)
free(p2);
efree(p1);
efree(p2);
sprintf(arh.ar_date, "%-12ld", (long) now);
if (arch != (FILE *) NULL) {
if (arch != NULL) {
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
fclose (arch);
}
@ -966,7 +966,7 @@ Arch_TouchLib (gn)
arch = ArchFindMember (gn->path, RANLIBMAG, &arh, "r+");
sprintf(arh.ar_date, "%-12ld", (long) now);
if (arch != (FILE *) NULL) {
if (arch != NULL) {
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch);
fclose (arch);
@ -1001,12 +1001,10 @@ Arch_MTime (gn)
arhPtr = ArchStatMember (Var_Value (ARCHIVE, gn, &p1),
Var_Value (TARGET, gn, &p2),
TRUE);
if (p1)
free(p1);
if (p2)
free(p2);
efree(p1);
efree(p2);
if (arhPtr != (struct ar_hdr *) NULL) {
if (arhPtr != NULL) {
modTime = (int) strtol(arhPtr->ar_date, NULL, 10);
} else {
modTime = 0;
@ -1113,7 +1111,7 @@ Arch_FindLib (gn, path)
#ifdef LIBRARIES
Var_Set (TARGET, gn->name, gn);
#else
Var_Set (TARGET, gn->path == (char *) NULL ? gn->name : gn->path, gn);
Var_Set (TARGET, gn->path == NULL ? gn->name : gn->path, gn);
#endif /* LIBRARIES */
}
@ -1170,7 +1168,7 @@ Arch_LibOODate (gn)
arhPtr = ArchStatMember (gn->path, RANLIBMAG, FALSE);
if (arhPtr != (struct ar_hdr *)NULL) {
if (arhPtr != NULL) {
modTimeTOC = (int) strtol(arhPtr->ar_date, NULL, 10);
if (DEBUG(ARCH) || DEBUG(MAKE)) {

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: buf.c,v 1.8 1997/02/22 19:27:06 peter Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-
@ -126,7 +131,7 @@ void
Buf_AddBytes (bp, numBytes, bytesPtr)
register Buffer bp;
int numBytes;
Byte *bytesPtr;
const Byte *bytesPtr;
{
BufExpand (bp, numBytes);
@ -454,7 +459,7 @@ Buf_Destroy (buf, freeData)
void
Buf_ReplaceLastByte (buf, byte)
Buffer buf; /* buffer to augment */
Byte byte; /* byte to be written */
int byte; /* byte to be written */
{
if (buf->inPtr == buf->outPtr)
Buf_AddByte(buf, byte);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)buf.h 8.1 (Berkeley) 6/6/93
* $Id$
* $Id: buf.h,v 1.7 1997/02/22 19:27:06 peter Exp $
*/
/*-
@ -67,7 +67,7 @@ typedef struct Buffer {
#define BUF_ERROR 256
void Buf_OvAddByte __P((Buffer, int));
void Buf_AddBytes __P((Buffer, int, Byte *));
void Buf_AddBytes __P((Buffer, int, const Byte *));
void Buf_UngetByte __P((Buffer, int));
void Buf_UngetBytes __P((Buffer, int, Byte *));
int Buf_GetByte __P((Buffer));
@ -77,6 +77,6 @@ void Buf_Discard __P((Buffer, int));
int Buf_Size __P((Buffer));
Buffer Buf_Init __P((int));
void Buf_Destroy __P((Buffer, Boolean));
void Buf_ReplaceLastByte __P((Buffer, Byte));
void Buf_ReplaceLastByte __P((Buffer, int));
#endif /* _BUF_H */

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: compat.c,v 1.12 1998/09/09 05:15:38 jkoshy Exp $
* $Id: compat.c,v 1.13 1999/07/31 20:38:22 hoek Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
static const char rcsid[] =
"$Id$";
#endif
#endif /* not lint */
/*-
@ -115,8 +120,7 @@ CompatInterrupt (signo)
if (!noExecute && eunlink(file) != -1) {
printf ("*** %s removed\n", file);
}
if (p1)
free(p1);
efree(p1);
/*
* Run .INTERRUPT only if hit with interrupt signal
@ -214,7 +218,7 @@ CompatRunCommand (cmdp, gnp)
cmdStart = Var_Subst (NULL, cmd, gn, FALSE);
/*
* brk_string will return an argv with a NULL in av[1], thus causing
* brk_string will return an argv with a NULL in av[0], thus causing
* execvp to choke and die horribly. Besides, how can we execute a null
* command? In any case, we warn the user that the command expanded to
* nothing (is this the right thing to do?).
@ -448,8 +452,7 @@ CompatMake (gnp, pgnp)
if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
char *p1;
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
if (p1)
free(p1);
efree(p1);
}
/*
@ -586,7 +589,10 @@ CompatMake (gnp, pgnp)
} else if (keepgoing) {
pgn->make = FALSE;
} else {
printf ("\n\nStop.\n");
char *p1;
printf ("\n\nStop in %s.\n", Var_Value(".CURDIR", gn, &p1));
efree(p1);
exit (1);
}
} else if (gn->made == ERROR) {
@ -599,8 +605,7 @@ CompatMake (gnp, pgnp)
if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
char *p1;
Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
if (p1)
free(p1);
efree(p1);
}
switch(gn->made) {
case BEINGMADE:

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cond.c,v 1.8 1999/05/25 13:45:08 hoek Exp $
* $Id: cond.c,v 1.9 1999/08/12 13:30:08 hoek Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-
@ -290,8 +295,7 @@ CondDoDefined (argLen, arg)
} else {
result = FALSE;
}
if (p1)
free(p1);
efree(p1);
arg[argLen] = savec;
return (result);
}

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: dir.c,v 1.7 1997/02/22 19:27:08 peter Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-

View File

@ -30,11 +30,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: for.c,v 1.7 1997/02/22 19:27:09 peter Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: hash.c,v 1.6 1997/02/22 19:27:10 peter Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/* hash.c --

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: job.c,v 1.11 1998/11/14 16:15:04 dg Exp $
* $Id: job.c,v 1.12 1999/02/14 22:22:42 dt Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
#ifndef OLD_JOKE
@ -1054,7 +1059,7 @@ Job_Touch(gn, silent)
* modification time, then close the file.
*/
if (read(streamID, &c, 1) == 1) {
(void) lseek(streamID, 0L, L_SET);
(void) lseek(streamID, 0L, SEEK_SET);
(void) write(streamID, &c, 1);
}
@ -1107,8 +1112,7 @@ Job_CheckCommands(gn, abortProc)
*/
Make_HandleUse(DEFAULT, gn);
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
if (p1)
free(p1);
efree(p1);
} else if (Dir_MTime(gn) == 0) {
/*
* The node wasn't the target of an operator we have no .DEFAULT
@ -1228,7 +1232,7 @@ JobExec(job, argv)
if (dup2(FILENO(job->cmdFILE), 0) == -1)
Punt("Cannot dup2: %s", strerror(errno));
(void) fcntl(0, F_SETFD, 0);
(void) lseek(0, 0, L_SET);
(void) lseek(0, 0, SEEK_SET);
if (usePipes) {
/*

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)lst.h 8.1 (Berkeley) 6/6/93
* $Id$
* $Id: lst.h,v 1.7 1997/02/22 19:27:13 peter Exp $
*/
/*-
@ -46,11 +46,11 @@
#ifndef _LST_H_
#define _LST_H_
#include <sprite.h>
#include <sys/param.h>
#if __STDC__
#ifdef __STDC__
#include <stdlib.h>
#endif
#include "sprite.h"
/*
* basic typedef. This is what the Lst_ functions handle

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93
* $Id$
* $Id: lstInt.h,v 1.5 1997/02/22 19:27:40 peter Exp $
*/
/*-
@ -109,4 +109,4 @@ typedef struct {
*/
#define LstIsEmpty(l) (((List)l)->firstPtr == NilListNode)
#endif _LSTINT_H_
#endif /* _LSTINT_H_ */

View File

@ -45,9 +45,10 @@ static const char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#endif
#else
static const char rcsid[] =
"$Id: main.c,v 1.31 1999/07/31 20:40:23 hoek Exp $";
"$Id: main.c,v 1.32 1999/07/31 20:53:01 hoek Exp $";
#endif
#endif /* not lint */
/*-
@ -96,7 +97,7 @@ static const char rcsid[] =
#include <fcntl.h>
#include <stdio.h>
#include <sysexits.h>
#if __STDC__
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
@ -211,8 +212,9 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
maxLocal = strtol(optarg, &endptr, 10);
if (maxLocal < 0 || *endptr != '\0') {
errx(EX_USAGE,
"illegal argument to -L -- %s", optarg);
warnx("illegal number, -L argument -- %s",
optarg);
usage();
}
Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL);
Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
@ -306,8 +308,9 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
forceJobs = TRUE;
maxJobs = strtol(optarg, &endptr, 10);
if (maxJobs <= 0 || *endptr != '\0') {
errx(EX_USAGE,
"illegal argument to -j -- %s", optarg);
warnx("illegal number, -j argument -- %s",
optarg);
usage();
}
#ifndef REMOTE
maxLocal = maxJobs;
@ -570,9 +573,10 @@ main(argc, argv)
* 2. MAKEOBJDIR
* 3. _PATH_OBJDIR.${MACHINE}
* 4. _PATH_OBJDIR
* 5. _PATH_OBJDIRPREFIX${MACHINE}
* 5. _PATH_OBJDIRPREFIX`cwd`
*
* If all fails, use the current directory to build.
* If one of the first two fails, use the current directory.
* If the remaining three all fail, use the current directory.
*
* Once things are initted,
* have to add the original directory to the search path,
@ -759,8 +763,7 @@ main(argc, argv)
(void)ReadMakefile(".depend", NULL);
Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
if (p1)
free(p1);
efree(p1);
/* Install all the flags into the MAKE envariable. */
if (((p = Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1)) != NULL) && *p)
@ -769,8 +772,7 @@ main(argc, argv)
#else
setenv("MAKE", p, 1);
#endif
if (p1)
free(p1);
efree(p1);
/*
* For compatibility, look at the directories in the VPATH variable
@ -1083,7 +1085,7 @@ bad:
*/
/* VARARGS */
void
#if __STDC__
#ifdef __STDC__
Error(char *fmt, ...)
#else
Error(va_alist)
@ -1091,7 +1093,7 @@ Error(va_alist)
#endif
{
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap, fmt);
#else
char *fmt;
@ -1118,7 +1120,7 @@ Error(va_alist)
*/
/* VARARGS */
void
#if __STDC__
#ifdef __STDC__
Fatal(char *fmt, ...)
#else
Fatal(va_alist)
@ -1126,7 +1128,7 @@ Fatal(va_alist)
#endif
{
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap, fmt);
#else
char *fmt;
@ -1160,7 +1162,7 @@ Fatal(va_alist)
*/
/* VARARGS */
void
#if __STDC__
#ifdef __STDC__
Punt(char *fmt, ...)
#else
Punt(va_alist)

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\" $Id: make.1,v 1.21 1999/08/12 20:49:20 chris Exp $
.\" $Id: make.1,v 1.22 1999/08/14 06:47:13 chris Exp $
.\"
.Dd March 19, 1994
.Dt MAKE 1
@ -40,7 +40,7 @@
.Nd maintain program dependencies
.Sh SYNOPSIS
.Nm make
.Op Fl Beiknqrstv
.Op Fl BPSeiknqrstv
.Op Fl D Ar variable
.Op Fl d Ar flags
.Op Fl E Ar variable
@ -51,29 +51,30 @@
.Op Fl m Ar directory
.Ek
.Op Fl V Ar variable
.Op Ar variable=value
.Op Ar variable Ns No = Ns Ar value
.Op Ar target ...
.Sh DESCRIPTION
.Nm Make
is a program designed to simplify the maintenance of other programs.
Its input is a list of specifications as to the files upon which programs
and other files depend.
.Nm Make
searches a built-in path for this list.
If the file
Its input is a list of specifications
describing dependency relationships between the generation of
files and programs.
The first of
.Ql Pa makefile
exists along this path, it is read for this list of specifications.
If it does not exist, the file
and
.Ql Pa Makefile
is used.
that can be found in either the current directory or a special object directory
(see
.Ql Va .OBJDIR )
will be read for this list of specifications.
If the file
.Ql Pa .depend
exists, it is also read (see
can be found, it is also read (see
.Xr mkdep 1) .
.Pp
This manual page is intended as a reference document only.
For a more thorough description of
.Nm make
For a more thorough introduction to
.Nm
and makefiles, please refer to
.%T "Make \- A Tutorial" .
.Pp
@ -82,15 +83,19 @@ The options are as follows:
.It Fl B
Try to be backwards compatible by executing a single shell per command and
by executing the commands to make the sources of a dependency line in sequence.
This is turned on by default unless
.Fl j
is used.
.It Fl D Ar variable
Define
.Ar variable
to be 1, in the global context.
.It Fl d Ar flags
Turn on debugging, and specify which portions of
.Nm make
.Nm
are to print debugging information.
.Ar Flags
Argument
.Ar flags
is one or more of the following:
.Bl -tag -width Ds
.It Ar A
@ -102,6 +107,9 @@ Print debugging information about archive searching and caching.
Print debugging information about conditional evaluation.
.It Ar d
Print debugging information about directory searching and caching.
.It Ar f
Print debugging information about the execution of for loops. Currently a
no-op.
.It Ar "g1"
Print the input graph before making anything.
.It Ar "g2"
@ -133,9 +141,9 @@ and
If
.Ar makefile
is
.Ql Fl ,
.Ql \- ,
standard input is read.
Multiple makefile's may be specified, and are read in the order specified.
Multiple makefiles may be specified, and are read in the order specified.
.It Fl I Ar directory
Specify a directory in which to search for makefiles and included makefiles.
The system makefile directory (or directories, see the
@ -144,11 +152,11 @@ option) is automatically included as part of this list.
.It Fl i
Ignore non-zero exit of shell commands in the makefile.
Equivalent to specifying
.Ql Fl
.Ql \-
before each command line in the makefile.
.It Fl j Ar max_jobs
Specify the maximum number of jobs that
.Nm make
.Nm
may have running at any one time. Turns compatibility mode off, unless the
.Ar B
flag is also specified.
@ -158,19 +166,31 @@ that do not depend on the target whose creation caused the error.
.It Fl m Ar directory
Specify a directory in which to search for sys.mk and makefiles included
via the <...> style. Multiple directories can be added to form a search path.
This path will override the default system include path: /usr/share/mk.
Furthermore the system include path will be appended to the search path used
This path will override the default system include path:
.Pa /usr/share/mk .
Furthermore, the system include path will be appended to the search path used
for "..."-style inclusions (see the
.Fl I
option).
.It Fl n
Display the commands that would have been executed, but do not actually
execute them.
.It Fl P
Collate the output of a given job and display it only when the job finishes,
instead of mixing the output of parallel jobs together.
This option has no effect unless
.Fl j
is used too.
.It Fl q
Do not execute any commands, but exit 0 if the specified targets are
up-to-date and 1, otherwise.
.It Fl r
Do not use the built-in rules specified in the system makefile.
.It Fl S
Stop processing when an error is encountered.
Default behaviour. This is needed to negate the
.Fl k
option during recursive builds.
.It Fl s
Do not echo any commands as they are executed.
Equivalent to specifying
@ -192,7 +212,7 @@ with a blank line for each null or undefined variable.
.It Fl v
Be extra verbose.
For multi-job makes, this will cause file banners to be generated.
.It Ar variable=value
.It Ar variable Ns No = Ns Ar value
Set the value of the variable
.Ar variable
to
@ -211,7 +231,9 @@ line are compressed into a single space.
.Sh FILE DEPENDENCY SPECIFICATIONS
Dependency lines consist of one or more targets, an operator, and zero
or more sources.
This creates a relationship where the targets ``depend'' on the sources
This creates a relationship where the targets
.Dq depend
on the sources
and are usually created from them.
The exact relationship between the target and the source is determined
by the operator that separates them.
@ -223,7 +245,7 @@ those of any of its sources.
Sources for a target accumulate over dependency lines when this operator
is used.
The target is removed if
.Nm make
.Nm
is interrupted.
.It Ic \&!
Targets are always re-created, but not until all sources have been
@ -231,7 +253,7 @@ examined and re-created as necessary.
Sources for a target accumulate over dependency lines when this operator
is used.
The target is removed if
.Nm make
.Nm
is interrupted.
.It Ic \&::
If no sources are specified, the target is always re-created.
@ -240,17 +262,17 @@ been modified more recently than the target.
Sources for a target do not accumulate over dependency lines when this
operator is used.
The target will not be removed if
.Nm make
.Nm
is interrupted.
.El
.Pp
Targets and sources may contain the shell wildcard values
Targets and sources may contain the shell wildcard expressions
.Ql ? ,
.Ql * ,
.Ql []
and
.Ql {} .
The values
The expressions
.Ql ? ,
.Ql *
and
@ -258,7 +280,7 @@ and
may only be used as part of the final
component of the target or source, and must be used to describe existing
files.
The value
The expression
.Ql {}
need not necessarily be used to describe existing files.
Expansion is in directory order, not alphabetically as done in the shell.
@ -285,7 +307,9 @@ A
.Ql Ic \-
causes any non-zero exit status of the command line to be ignored.
.Sh VARIABLE ASSIGNMENTS
Variables in make are much like variables in the shell, and, by tradition,
Variables in
.Nm
are much like variables in the shell, and, by tradition,
consist of all upper-case letters.
The five operators that can be used to assign values to variables are as
follows:
@ -307,7 +331,7 @@ the result to the variable.
Any newlines in the result are replaced with spaces.
.El
.Pp
Any white-space before the assigned
Any whitespace before the assigned
.Ar value
is removed; if the value is being appended, a single space is inserted
between the previous contents of the variable and the appended value.
@ -349,13 +373,17 @@ The seven local variables are as follows:
The list of all sources for this target; also known as
.Ql Va \&> .
.It Va .ARCHIVE
The name of the archive file.
The name of the archive file; also known as
.Ql Va \&! .
.It Va .IMPSRC
The name/path of the source from which the target is to be transformed
(the ``implied'' source); also known as
(the
.Dq implied
source); also known as
.Ql Va \&< .
.It Va .MEMBER
The name of the archive member.
The name of the archive member; also known as
.Ql Va \&% .
.It Va .OODATE
The list of sources for this target that were deemed out-of-date; also
known as
@ -371,8 +399,11 @@ The name of the target; also known as
.Pp
The shorter forms
.Ql Va @ ,
.Ql Va ! ,
.Ql Va \&< ,
.Ql Va \&% ,
.Ql Va ? ,
.Ql Va \&>
.Ql Va \&> ,
and
.Ql Va *
are permitted for backward
@ -382,7 +413,7 @@ The six variables
.Ql Va "@D" ,
.Ql Va "<F" ,
.Ql Va "<D" ,
.Ql Va "*F"
.Ql Va "*F" ,
and
.Ql Va "*D"
are
@ -398,10 +429,12 @@ These variables are
.Ql Va .ARCHIVE ,
and
.Ql Va .MEMBER .
.El
.Pp
In addition,
.Nm make
sets or knows about the following variables:
.Nm
sets or knows about the following internal variables or environment
variables:
.Bl -tag -width MAKEFLAGS
.It Va \&$
A single dollar sign
@ -412,57 +445,129 @@ expands to a single dollar
sign.
.It Va .MAKE
The name that
.Nm make
.Nm
was executed with
.Pq Va argv Op 0
.Pq Va argv Ns Op 0 .
.It Va .CURDIR
A path to the directory where
.Nm make
.Nm
was executed.
.It Va .OBJDIR
A path to the directory where the targets are built.
.It Ev MAKEFLAGS
At startup,
.Nm
searches for an alternate directory to place target files.
It will attempt to change into this special directory
and will search this directory for makefiles
not found in the current directory.
The following directories are tried in order:
.Pp
.Bl -enum -compact
.It
${MAKEOBJDIRPREFIX}/`cwd`
.It
${MAKEOBJDIR}
.It
obj.${MACHINE}
.It
obj
.It
/usr/obj/`cwd`
.El
.Pp
The first directory that
.Nm
successfully changes into is used.
If either
.Ev MAKEOBJDIRPREFIX
or
.Ev MAKEOBJDIR
is defined but
.Nm
is unable to change into the corresponding directory,
then the current directory is used
without checking the remainder of the list.
If they are undefined and
.Nm
is unable to change into any of the remaining three directories,
then the current directory is used.
.It Va .MAKEFLAGS
The environment variable
.Ql Ev MAKEFLAGS
.Ev MAKEFLAGS
may contain anything that
may be specified on
.Nm make Ns 's
command line.
command line. Its contents are stored in
.Nm make Ns 's
.Va .MAKEFLAGS
variable.
Anything specified on
.Nm make Ns 's
command line is appended to the
.Ql Ev MAKEFLAGS
.Va .MAKEFLAGS
variable which is then
entered into the environment for all programs which
.Nm make
entered into the environment as
.Ev MAKEFLAGS
for all programs which
.Nm
executes.
.It Va MFLAGS
A synonym for
.Va .MAKEFLAGS
provided for backward compatibility.
.It Ev PWD
Alternate path to the current directory. Supported if built with WANT_ENV_PWD
defined.
.Nm make
Alternate path to the current directory.
Supported if built with WANT_ENV_PWD defined.
.Nm
normally sets
.Ql Va .CURDIR
to the canonical path given by
.Xr getcwd 3 .
However, if the environment variable
.Ql Ev PWD
.Ev PWD
is set and gives a path to the current directory, then
.Nm make
.Nm
sets
.Ql Va .CURDIR
to the value of
.Ql Ev PWD
.Ev PWD
instead.
.Ql Ev PWD
is set to the value of
.Ev PWD
is always set to the value of
.Ql Va .OBJDIR
for all programs which
.Nm make
.Nm
executes.
.It Va .TARGETS
List of targets
.Nm
is currently building.
.It Va .INCLUDES
See
.Ic .INCLUDES
special target.
.It Va .LIBS
See
.Ic .LIBS
special target.
.It Va MACHINE
Name of the machine architecture
.Nm
is running on, obtained from the
.Ev MACHINE
environment variable, or through
.Xr uname 2
if not defined.
.It Va MACHINE_ARCH
Name of the machine architecture
.Nm
was compiled for, defined at compilation time.
.El
.Pp
Variable expansion may be modified to select or modify each word of the
variable (where a ``word'' is white-space delimited sequence of characters).
variable (where a
.Dq word
is whitespace delimited sequence of characters).
The general format of a variable expansion is as follows:
.Pp
.Dl {variable[:modifier[:...]]}
@ -489,7 +594,7 @@ The wildcard characters may be escaped with a backslash
.Pq Ql \e .
.It Cm N Ns Ar pattern
This is identical to
.Ql Cm M ,
.Cm M ,
but selects all words which do not match
the rest of the modifier.
.It Cm Q
@ -499,27 +604,27 @@ safely through recursive invocations of
.It Cm R
Replaces each word in the variable with everything but its suffix.
.Sm off
.It Cm S No \&/ Ar old_pattern Xo
.No \&/ Ar new_pattern
.It Cm S No \&/ Ar old_string Xo
.No \&/ Ar new_string
.No \&/ Op Cm g
.Xc
.Sm on
Modify the first occurrence of
.Ar old_pattern
in each word to be replaced with
.Ar new_pattern .
.Ar old_string
in each word of the variable's value, replacing it with
.Ar new_string .
If a
.Ql g
is appended to the last slash of the pattern, all occurrences
in each word are replaced.
If
.Ar old_pattern
begins with a carat
.Ar old_string
begins with a caret
.Pq Ql ^ ,
.Ar old_pattern
.Ar old_string
is anchored at the beginning of each word.
If
.Ar old_pattern
.Ar old_string
ends with a dollar sign
.Pq Ql \&$ ,
it is anchored at the end of each word.
@ -528,10 +633,10 @@ Inside
an ampersand
.Pq Ql &
is replaced by
.Ar old_pattern .
.Ar old_string .
Any character may be used as a delimiter for the parts of the modifier
string.
The anchoring, ampersand and delimiter characters may be escaped with a
The anchoring, ampersand, and delimiter characters may be escaped with a
backslash
.Pq Ql \e .
.Pp
@ -541,7 +646,7 @@ and
.Ar new_string
with the single exception that a backslash is used to prevent the expansion
of a dollar sign
.Pq Ql \&$
.Pq Ql \&$ ,
not a preceding dollar sign as is usual.
.It Cm T
Replaces each word in the variable with its last component.
@ -565,8 +670,8 @@ is the substring of
to be replaced in
.Ar new_string
.El
.Sh DIRECTIVES, CONDITIONALS AND FOR LOOPS
Directives, conditionals and for loops reminiscent
.Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS
Directives, conditionals, and for loops reminiscent
of the C programming language are provided in
.Nm make .
All such structures are identified by a line beginning with a single
@ -694,7 +799,7 @@ of higher precedence than
.El
.Pp
As in C,
.Nm make
.Nm
will only evaluate a conditional as far as is necessary to determine
its value.
Parentheses may be used to change the order of evaluation.
@ -732,7 +837,8 @@ Takes a target name as an argument and evaluates to true if the target
has been defined.
.El
.Pp
.Ar Expression
An
.Ar expression
may also be an arithmetic or string comparison. Variable expansion is
performed on both sides of the comparison, after which the integral
values are compared. A value is interpreted as hexadecimal if it is
@ -749,20 +855,26 @@ If no relational operator is given, it is assumed that the expanded
variable is being compared against 0.
.Pp
When
.Nm make
is evaluating one of these conditional expression, and it encounters
a word it doesn't recognize, either the ``make'' or ``defined''
.Nm
is evaluating one of these conditional expressions, and it encounters
a word it doesn't recognize, either the
.Dq make
or
.Dq defined
expression is applied to it, depending on the form of the conditional.
If the form is
.Ql Ic .ifdef
or
.Ql Ic .ifndef ,
the ``defined'' expression
is applied.
the
.Dq defined
expression is applied.
Similarly, if the form is
.Ql Ic .ifmake
or
.Ql Ic .ifnmake , the ``make''
.Ql Ic .ifnmake ,
the
.Dq make
expression is applied.
.Pp
If the conditional evaluates to true the parsing of the makefile continues
@ -791,10 +903,10 @@ The syntax of a for loop is:
.Xc
.El
After the for
.Ic expression
.Ar expression
is evaluated, it is split into words. The
iteration
.Ic variable
.Ar variable
is successively set to each word, and substituted in the
.Ic make-rules
inside the body of the for loop.
@ -819,18 +931,18 @@ Normally used to mark recursive
.Nm make Ns 's .
.It Ic .NOTMAIN
Normally
.Nm make
.Nm
selects the first target it encounters as the default target to be built
if no target was specified.
This source prevents this target from being selected.
.It Ic .OPTIONAL
If a target is marked with this attribute and
.Nm make
.Nm
can't figure out how to create it, it will ignore this fact and assume
the file isn't needed or already exists.
.It Ic .PRECIOUS
When
.Nm make
.Nm
is interrupted, it removes any partially made targets.
This source prevents the target from being removed.
.It Ic .SILENT
@ -839,7 +951,7 @@ as if they all were preceded by an at sign
.Pq Ql @ .
.It Ic .USE
Turn the target into
.Nm make Ns 's .
.Nm make Ns 's
version of a macro.
When the target is used as a source for another target, the other target
acquires the commands, sources, and attributes (except for
@ -869,7 +981,7 @@ This is sort of a
.Ic .USE
rule for any target (that was used only as a
source) that
.Nm make
.Nm
can't figure out any other way to create.
Only the shell script is used.
The
@ -888,17 +1000,38 @@ attribute.
If no sources are specified, this is the equivalent of specifying the
.Fl i
option.
.It Ic .INCLUDES
A list of suffixes that indicate files that can be included in a source
file. The suffix must have already been declared with
.Ic .SUFFIXES ;
any suffix so declared will have the directories on its search path (see
.Ic .PATH )
placed in the
.Va .INCLUDES
special variable, each preceeded by a
.Fl I
flag.
.It Ic .INTERRUPT
If
.Nm make
.Nm
is interrupted, the commands for this target will be executed.
.It Ic .LIBS
This does for libraries what
.Ic .INCLUDES
does for include files, except that the flag used is
.Fl L .
.It Ic .MAIN
If no target is specified when
.Nm make
.Nm
is invoked, this target will be built.
This is always set, either
explicitly, or implicitly when
.Nm
selects the default target, to give the user a way to refer to the default
target on the command line.
.It Ic .MAKEFLAGS
This target provides a way to specify flags for
.Nm make
.Nm
when the makefile is used.
The flags are as if typed to the shell, though the
.Fl f
@ -928,6 +1061,17 @@ The variable
.Ql Ev VPATH
used to add directories to the search path is permitted only for backward
compatibility, and is not recommended for use in new Makefiles.
.It Ic .PATH\fIsuffix\fR
The sources are directories which are to be searched for suffixed files
not found in the current directory.
.Nm Make
first searches the suffixed search path, before reverting to the default
path if the file is not found there.
This form is required for
.Ic .LIBS
and
.Ic .INCLUDES
to work.
.It Ic .PHONY
Apply the
.Ic .PHONY
@ -953,36 +1097,26 @@ command in the file.
Each source specifies a suffix to
.Nm make .
If no sources are specified, any previous specified suffices are deleted.
.Sh SEARCH PATH
.Nm Make
searches for
.Ql Pa Makefile
in the following directories, in order:
.Sh COMPATIBILITY
Older versions of
.Nm
used
.Ev MAKE
instead of
.Ev MAKEFLAGS .
This was removed for POSIX compatibility.
The internal variable
.Va MAKE
is set to the same value as
.Va .MAKE ;
support for this may be removed in the future.
.Pp
.Bl -enum -compact
.It
${MAKEOBJDIRPREFIX}`cwd`
.It
${MAKEOBJDIR}
.It
obj.${MACHINE}
.It
obj
.It
/usr/obj${MACHINE}`cwd`
.It
The current directory (`cwd`).
.El
.Pp
If
.Nm make
finds the
.Ql Pa Makefile
someplace other than the current working directory, it adds the CWD to
the search path.
Most of the more esoteric features of
.Nm
should probably be avoided for greater compatibility.
.Sh ENVIRONMENT
.Nm Make
utilizes the following environment variables, if they exist:
uses the following environment variables, if they exist:
.Ev MACHINE ,
.Ev MAKE ,
.Ev MAKEFLAGS ,
@ -992,23 +1126,60 @@ and
.Ev PWD .
.Sh FILES
.Bl -tag -width /usr/share/doc/psd/12.make -compact
.It .depend
.It Pa .depend
list of dependencies
.It Makefile
.It Pa Makefile
list of dependencies
.It makefile
.It Pa makefile
list of dependencies
.It obj
object directory
.It sys.mk
.It Pa sys.mk
system makefile
.It /usr/share/mk
.It Pa /usr/share/mk
system makefile directory
.It /usr/share/doc/psd/12.make
PMake tutorial
.It /usr/obj
system object directory prefix
.It Pa /usr/obj
default
.Ev MAKEOBJDIRPREFIX
directory.
.El
.Sh BUGS
The determination of
.Va .OBJDIR
is contorted to the point of absurdity.
.Pp
In the presence of several
.Ic .MAIN
special targets,
.Nm
silently ignores all but the first.
.Pp
.Va .TARGETS
is not set to the default target when
.Nm
is invoked without a target name and no
.Ic .MAIN
special target exists.
.Pp
The evaluation of
.Ar expression
in a test is very simple-minded. Currently, the only form that works is
.Ql .if ${VAR} op something
For instance, you should write tests as
.Ql .if ${VAR} = "string"
not the other way around, which doesn't work.
.Pp
For loops are expanded before tests, so a fragment such as:
.Bd -literal
\&.for TMACHINE in ${SHARED_ARCHS}
\&.if ${TMACHINE} = ${MACHINE}
...
\&.endif
\&.endfor
.Ed
won't work, and should be rewritten the other way around.
.Sh SEE ALSO
.Xr mkdep 1
.Rs
@ -1016,6 +1187,6 @@ system object directory prefix
.Re
.Sh HISTORY
A
.Nm Make
.Nm
command appeared in
.At v7 .

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: make.c,v 1.8 1997/02/22 19:27:16 peter Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] =
"$Id$";
#endif
#endif /* not lint */
/*-
@ -70,7 +75,7 @@ static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
*
* Make_OODate Determine if a target is out-of-date.
*
* Make_HandleUse See if a child is a .USE node for a parent
* Make_HandleUse See if a child is a .USE node for a parent
* and perform the .USE actions if so.
*/
@ -291,12 +296,13 @@ MakeAddChild (gnp, lp)
{
GNode *gn = (GNode *) gnp;
Lst l = (Lst) lp;
if (!gn->make && !(gn->type & OP_USE)) {
(void)Lst_EnQueue (l, (ClientData)gn);
}
return (0);
}
/*-
*-----------------------------------------------------------------------
* Make_HandleUse --
@ -325,7 +331,7 @@ Make_HandleUse (cgn, pgn)
register GNode *cgn; /* The .USE node */
register GNode *pgn; /* The target of the .USE node */
{
register GNode *gn; /* A child of the .USE node */
register GNode *gn; /* A child of the .USE node */
register LstNode ln; /* An element in the children list */
if (cgn->type & (OP_USE|OP_TRANSFORM)) {
@ -360,7 +366,7 @@ Make_HandleUse (cgn, pgn)
* whether to queue the parent or examine its children...
*/
if (cgn->type & OP_USE) {
pgn->unmade -= 1;
pgn->unmade--;
}
}
return (0);
@ -408,8 +414,7 @@ Make_Update (cgn)
char *p1;
cname = Var_Value (TARGET, cgn, &p1);
if (p1)
free(p1);
efree(p1);
/*
* If the child was actually made, see what its modification time is
@ -538,8 +543,7 @@ Make_Update (cgn)
Var_Set (PREFIX, cpref, pgn);
}
}
if (p1)
free(p1);
efree(p1);
Lst_Close (cgn->iParents);
}
}
@ -610,8 +614,7 @@ MakeAddAllSrc (cgnp, pgnp)
*/
Var_Append(OODATE, child, pgn);
}
if (p1)
free(p1);
efree(p1);
}
return (0);
}
@ -654,8 +657,7 @@ Make_DoAllVar (gn)
if (gn->type & OP_JOIN) {
char *p1;
Var_Set (TARGET, Var_Value (ALLSRC, gn, &p1), gn);
if (p1)
free(p1);
efree(p1);
}
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)make.h 8.3 (Berkeley) 6/13/95
* $Id: make.h,v 1.8 1998/11/14 16:15:04 dg Exp $
* $Id: make.h,v 1.9 1999/07/31 20:53:02 hoek Exp $
*/
/*-
@ -48,21 +48,32 @@
#define _MAKE_H_
#include <sys/types.h>
#include <sys/param.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#if !defined(MAKE_BOOTSTRAP) && defined(BSD)
#include <sys/cdefs.h>
#if !defined(MAKE_BOOTSTRAP) && defined(BSD4_4)
# include <sys/cdefs.h>
#else
#ifndef __P
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#else
#define __P(protos) () /* traditional C preprocessor */
# ifndef __P
# if defined(__STDC__) || defined(__cplusplus)
# define __P(protos) protos /* full-blown ANSI C */
# else
# define __P(protos) () /* traditional C preprocessor */
# endif
# endif
# ifndef __STDC__
# ifndef const
# define const
# endif
# ifndef volatile
# define volatile
# endif
# endif
#endif
#endif
#endif
#if __STDC__
#ifdef __STDC__
#include <stdlib.h>
#include <unistd.h>
#endif
@ -108,7 +119,7 @@ typedef struct GNode {
Boolean make; /* TRUE if this target needs to be remade */
enum {
UNMADE, BEINGMADE, MADE, UPTODATE, ERROR, ABORTED,
CYCLE, ENDCYCLE,
CYCLE, ENDCYCLE
} made; /* Set to reflect the state of processing
* on this node:
* UNMADE - Not examined yet

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)nonints.h 8.3 (Berkeley) 3/19/94
* $Id$
* $Id: nonints.h,v 1.6 1997/02/22 19:27:17 peter Exp $
*/
/* arch.c */
@ -73,6 +73,9 @@ int PrintAddr __P((ClientData, ClientData));
void Finish __P((int));
char *estrdup __P((const char *));
void *emalloc __P((size_t));
/* efree(x) works when x==NULL. STDC behavior, may need some different
* definition for cross-builds on deficient systems */
#define efree free
void *erealloc __P((void *, size_t));
void enomem __P((void));
int eunlink __P((const char *));

View File

@ -39,9 +39,10 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#endif
#else
static const char rcsid[] =
"$Id: parse.c,v 1.19 1998/05/25 03:28:37 steve Exp $";
"$Id: parse.c,v 1.20 1999/01/08 18:37:34 jkh Exp $";
#endif
#endif /* not lint */
/*-
@ -86,7 +87,7 @@ static const char rcsid[] =
* Parse_MainName Returns a Lst of the main target to create.
*/
#if __STDC__
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
@ -313,7 +314,7 @@ ParseFindKeyword (str)
*/
/* VARARGS */
void
#if __STDC__
#ifdef __STDC__
Parse_Error(int type, char *fmt, ...)
#else
Parse_Error(va_alist)
@ -321,7 +322,7 @@ Parse_Error(va_alist)
#endif
{
va_list ap;
#if __STDC__
#ifdef __STDC__
va_start(ap, fmt);
#else
int type; /* Error type (PARSE_WARNING, PARSE_FATAL) */
@ -470,7 +471,7 @@ ParseDoOp (gnp, opp)
*
*---------------------------------------------------------------------
*/
int
static int
ParseAddDep(pp, sp)
ClientData pp;
ClientData sp;
@ -2615,18 +2616,18 @@ Parse_End()
Lst
Parse_MainName()
{
Lst main; /* result list */
Lst listmain; /* result list */
main = Lst_Init (FALSE);
listmain = Lst_Init (FALSE);
if (mainNode == NILGNODE) {
Punt ("no target to make.");
/*NOTREACHED*/
} else if (mainNode->type & OP_DOUBLEDEP) {
(void) Lst_AtEnd (main, (ClientData)mainNode);
Lst_Concat(main, mainNode->cohorts, LST_CONCNEW);
(void) Lst_AtEnd (listmain, (ClientData)mainNode);
Lst_Concat(listmain, mainNode->cohorts, LST_CONCNEW);
}
else
(void) Lst_AtEnd (main, (ClientData)mainNode);
return (main);
(void) Lst_AtEnd (listmain, (ClientData)mainNode);
return (listmain);
}

View File

@ -31,11 +31,21 @@
* SUCH DAMAGE.
*
* from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90
* $Id$
* $Id: pathnames.h,v 1.7 1997/02/22 19:27:20 peter Exp $
*/
#ifndef _PATH_OBJDIR
#define _PATH_OBJDIR "obj"
#endif /* ! _PATH_OBJDIR */
#ifndef _PATH_OBJDIRPREFIX
#define _PATH_OBJDIRPREFIX "/usr/obj"
#endif /* ! _PATH_OBJDIRPREFIX */
#ifndef _PATH_DEFSHELLDIR
#define _PATH_DEFSHELLDIR "/bin"
#endif /* ! _PATH_DEFSHELLDIR */
#ifndef _PATH_DEFSYSMK
#define _PATH_DEFSYSMK "sys.mk"
#endif /* ! _PATH_DEFSYSMK */
#ifndef _PATH_DEFSYSPATH
#define _PATH_DEFSYSPATH "/usr/share/mk"
#endif /* ! _PATH_DEFSYSPATH */

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)sprite.h 8.1 (Berkeley) 6/6/93
* $Id$
* $Id: sprite.h,v 1.7 1997/02/22 19:27:21 peter Exp $
*/
/*
@ -57,10 +57,10 @@
typedef int Boolean;
#ifndef TRUE
#define TRUE 1
#endif TRUE
#endif /* TRUE */
#ifndef FALSE
#define FALSE 0
#endif FALSE
#endif /* FALSE */
/*
* Functions that must return a status can return a ReturnStatus to
@ -91,7 +91,7 @@ typedef int ReturnStatus;
#define USER_NIL 0
#ifndef NULL
#define NULL 0
#endif NULL
#endif /* NULL */
/*
* An address is just a pointer in C. It is defined as a character pointer

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: str.c,v 1.9 1997/02/22 19:27:23 peter Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
static const char rcsid[] =
"$Id$";
#endif
#endif /* not lint */
#include "make.h"
@ -165,12 +170,12 @@ brk_string(str, store_argc, expand)
switch(ch = *p) {
case '"':
case '\'':
if (inquote)
if (inquote) {
if (inquote == ch)
inquote = '\0';
else
break;
else {
} else {
inquote = (char) ch;
/* Don't miss "" or '' */
if (start == NULL && p[1] == inquote) {

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: suff.c,v 1.8 1997/02/22 19:27:23 peter Exp $
* $Id: suff.c,v 1.9 1998/04/26 09:44:48 phk Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-
@ -660,7 +665,7 @@ Suff_EndTransform(gnp, dummy)
(void)SuffParseTransform(gn->name, &s, &t);
if (DEBUG(SUFF)) {
printf("deleting transformation from %s to %s\n",
printf("deleting transformation from `%s' to `%s'\n",
s->name, t->name);
}
@ -1697,8 +1702,7 @@ SuffFindArchiveDeps(gn, slst)
for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) {
char *p1;
Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn);
if (p1)
free(p1);
efree(p1);
}
@ -2032,8 +2036,7 @@ sfnd_abort:
gn->suffix = (targ == NULL) ? NULL : targ->suff;
if (gn->suffix)
gn->suffix->refCount++;
if (gn->path != NULL)
free(gn->path);
efree(gn->path);
gn->path = estrdup(gn->name);
}
@ -2133,8 +2136,7 @@ sfnd_abort:
/*
* So Dir_MTime doesn't go questing for it...
*/
if (gn->path)
free(gn->path);
efree(gn->path);
gn->path = estrdup(gn->name);
/*

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: targ.c,v 1.7 1997/02/22 19:27:24 peter Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-
@ -210,8 +215,7 @@ TargFreeGN (gnp)
free(gn->name);
if (gn->path)
free(gn->path);
efree(gn->path);
Lst_Destroy(gn->iParents, NOFREE);
Lst_Destroy(gn->cohorts, NOFREE);
@ -462,17 +466,12 @@ Targ_FmtTime (time)
time_t time;
{
struct tm *parts;
static char buf[40];
static char *months[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
static char buf[128];
parts = localtime(&time);
sprintf (buf, "%d:%02d:%02d %s %d, %d",
parts->tm_hour, parts->tm_min, parts->tm_sec,
months[parts->tm_mon], parts->tm_mday, 1900 + parts->tm_year);
strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
buf[sizeof(buf) - 1] = '\0';
return(buf);
}

View File

@ -35,11 +35,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: var.c,v 1.12 1999/04/19 07:30:04 imp Exp $
* $Id: var.c,v 1.13 1999/07/31 20:53:02 hoek Exp $
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
static const char rcsid[] =
"$Id";
#endif
#endif /* not lint */
/*-
@ -141,15 +146,17 @@ typedef struct Var {
* modified variables */
} Var;
/* Var*Pattern flags */
#define VAR_SUB_GLOBAL 0x01 /* Apply substitution globally */
#define VAR_MATCH_START 0x08 /* Match at start of word */
#define VAR_MATCH_END 0x10 /* Match at end of word */
typedef struct {
char *lhs; /* String to match */
int leftLen; /* Length of string */
char *rhs; /* Replacement string (w/ &'s removed) */
int rightLen; /* Length of replacement */
int flags;
#define VAR_SUB_GLOBAL 1 /* Apply substitution globally */
#define VAR_MATCH_START 2 /* Match at start of word */
#define VAR_MATCH_END 4 /* Match at end of word */
} VarPattern;
static int VarCmp __P((ClientData, ClientData));
@ -266,8 +273,7 @@ VarFind (name, ctxt, flags)
(int (*)(ClientData, ClientData)) strcmp) != NILLNODE)
{
localCheckEnvFirst = TRUE;
}
else {
} else {
localCheckEnvFirst = FALSE;
}
@ -1150,7 +1156,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
{
register char *tstr; /* Pointer into str */
Var *v; /* Variable in invocation */
register char *cp; /* Secondary pointer into str (place marker
char *cp; /* Secondary pointer into str (place marker
* for tstr) */
Boolean haveModifier;/* TRUE if have modifiers for the variable */
register char endc; /* Ending character when variable in parens
@ -1196,6 +1202,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
* specially as they are the only four that will be set
* when dynamic sources are expanded.
*/
/* XXX: It looks like $% and $! are reversed here */
switch (str[1]) {
case '@':
return("$(.TARGET)");
@ -1501,6 +1508,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
pattern.flags = 0;
delim = tstr[1];
tstr += 2;
/*
* If pattern begins with '^', it is anchored to the
* start of the word -- skip over it and flag pattern.