Import bmake-20080215

This commit is contained in:
joerg 2008-03-09 19:39:31 +00:00
parent a56a864b83
commit cbeeb7c811
55 changed files with 2746 additions and 1962 deletions

View file

@ -56,6 +56,7 @@ lst.lib/lstLast.c
lst.lib/lstMember.c
lst.lib/lstNext.c
lst.lib/lstOpen.c
lst.lib/lstPrev.c
lst.lib/lstRemove.c
lst.lib/lstReplace.c
lst.lib/lstSucc.c
@ -84,6 +85,9 @@ wait.h
unit-tests/Makefile.in
unit-tests/cond1
unit-tests/comment
unit-tests/export
unit-tests/export-all
unit-tests/moderrs
unit-tests/modmatch
unit-tests/modorder
unit-tests/modts
@ -92,3 +96,5 @@ unit-tests/posix
unit-tests/ternary
unit-tests/test.exp
unit-tests/varcmd
unit-tests/modmisc
unit-tests/dotwait

View file

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */
/* $NetBSD: arch.c,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: arch.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: arch.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $");
__RCSID("$NetBSD: arch.c,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -288,19 +288,18 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* so we can safely advance beyond it...
*/
int length;
Boolean freeIt;
void *freeIt;
char *result;
result=Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
if (freeIt)
free(freeIt);
if (result == var_Error) {
return(FAILURE);
} else {
subLibName = TRUE;
}
if (freeIt) {
free(result);
}
cp += length-1;
}
}
@ -330,19 +329,18 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* so we can safely advance beyond it...
*/
int length;
Boolean freeIt;
void *freeIt;
char *result;
result=Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
if (freeIt)
free(freeIt);
if (result == var_Error) {
return(FAILURE);
} else {
doSubst = TRUE;
}
if (freeIt) {
free(result);
}
cp += length;
} else {
cp++;
@ -412,7 +410,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
return(FAILURE);
} else {
gn->type |= OP_ARCHV;
(void)Lst_AtEnd(nodeLst, (ClientData)gn);
(void)Lst_AtEnd(nodeLst, gn);
}
} else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) {
/*
@ -454,7 +452,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* end of the provided list.
*/
gn->type |= OP_ARCHV;
(void)Lst_AtEnd(nodeLst, (ClientData)gn);
(void)Lst_AtEnd(nodeLst, gn);
}
}
Lst_Destroy(members, NOFREE);
@ -476,7 +474,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
* provided list.
*/
gn->type |= OP_ARCHV;
(void)Lst_AtEnd(nodeLst, (ClientData)gn);
(void)Lst_AtEnd(nodeLst, gn);
}
}
if (doSubst) {
@ -578,7 +576,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
member = cp + 1;
}
ln = Lst_Find(archives, (ClientData) archive, ArchFindArchive);
ln = Lst_Find(archives, archive, ArchFindArchive);
if (ln != NILLNODE) {
ar = (Arch *)Lst_Datum(ln);
@ -589,7 +587,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
} else {
/* Try truncated name */
char copy[AR_MAX_NAME_LEN+1];
int len = strlen(member);
size_t len = strlen(member);
if (len > AR_MAX_NAME_LEN) {
len = AR_MAX_NAME_LEN;
@ -711,7 +709,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
memName[elen] = '\0';
fseek(arch, -elen, SEEK_CUR);
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("ArchStat: Extended format entry for %s\n", memName);
fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName);
}
}
#endif
@ -725,7 +723,7 @@ ArchStatMember(char *archive, char *member, Boolean hash)
fclose(arch);
(void)Lst_AtEnd(archives, (ClientData) ar);
(void)Lst_AtEnd(archives, ar);
/*
* Now that the archive has been read and cached, we can look into
@ -782,7 +780,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
if (ar->fnametab != NULL) {
if (DEBUG(ARCH)) {
printf("Attempted to redefine an SVR4 name table\n");
fprintf(debug_file, "Attempted to redefine an SVR4 name table\n");
}
return -1;
}
@ -796,7 +794,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
if (fread(ar->fnametab, size, 1, arch) != 1) {
if (DEBUG(ARCH)) {
printf("Reading an SVR4 name table failed\n");
fprintf(debug_file, "Reading an SVR4 name table failed\n");
}
return -1;
}
@ -815,7 +813,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
break;
}
if (DEBUG(ARCH)) {
printf("Found svr4 archive name table with %lu entries\n",
fprintf(debug_file, "Found svr4 archive name table with %lu entries\n",
(u_long)entry);
}
return 0;
@ -827,20 +825,20 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
entry = (size_t)strtol(&name[1], &eptr, 0);
if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
if (DEBUG(ARCH)) {
printf("Could not parse SVR4 name %s\n", name);
fprintf(debug_file, "Could not parse SVR4 name %s\n", name);
}
return 2;
}
if (entry >= ar->fnamesize) {
if (DEBUG(ARCH)) {
printf("SVR4 entry offset %s is greater than %lu\n",
fprintf(debug_file, "SVR4 entry offset %s is greater than %lu\n",
name, (u_long)ar->fnamesize);
}
return 2;
}
if (DEBUG(ARCH)) {
printf("Replaced %s with %s\n", name, &ar->fnametab[entry]);
fprintf(debug_file, "Replaced %s with %s\n", name, &ar->fnametab[entry]);
}
(void)strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
@ -882,7 +880,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
int size; /* Size of archive member */
char *cp; /* Useful character pointer */
char magic[SARMAG];
int len, tlen;
size_t len, tlen;
arch = fopen(archive, mode);
if (arch == NULL) {
@ -954,7 +952,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
isdigit((unsigned char)arhPtr->AR_NAME[sizeof(AR_EFMT1) - 1])) {
unsigned int elen = atoi(&arhPtr->AR_NAME[sizeof(AR_EFMT1)-1]);
char ename[MAXPATHLEN];
char ename[MAXPATHLEN + 1];
if (elen > MAXPATHLEN) {
fclose(arch);
@ -966,7 +964,7 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
}
ename[elen] = '\0';
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("ArchFind: Extended format entry for %s\n", ename);
fprintf(debug_file, "ArchFind: Extended format entry for %s\n", ename);
}
if (strncmp(ename, member, len) == 0) {
/* Found as extended name */
@ -1290,7 +1288,7 @@ Arch_LibOODate(GNode *gn)
modTimeTOC = (int)strtol(arhPtr->AR_DATE, NULL, 10);
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
fprintf(debug_file, "%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
}
oodate = (gn->cmtime > modTimeTOC);
} else {
@ -1298,7 +1296,7 @@ Arch_LibOODate(GNode *gn)
* A library w/o a table of contents is out-of-date
*/
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("No t.o.c....");
fprintf(debug_file, "No t.o.c....");
}
oodate = TRUE;
}

View file

@ -1,7 +1,7 @@
MAKE(1) NetBSD General Commands Manual MAKE(1)
MAKE(1) BSD General Commands Manual MAKE(1)
NNAAMMEE
bbmmaakkee - maintain program dependencies
bbmmaakkee -- maintain program dependencies
SSYYNNOOPPSSIISS
bbmmaakkee [--BBeeiikkNNnnqqrrssttWWXX] [--DD _v_a_r_i_a_b_l_e] [--dd _f_l_a_g_s] [--ff _m_a_k_e_f_i_l_e]
@ -11,15 +11,18 @@ SSYYNNOOPPSSIISS
DDEESSCCRRIIPPTTIIOONN
bbmmaakkee is a program designed to simplify the maintenance of other pro-
grams. Its input is a list of specifications as to the files upon which
programs and other files depend. If the file `_m_a_k_e_f_i_l_e' exists, it is
read for this list of specifications. If it does not exist, the file
`_M_a_k_e_f_i_l_e' is read. If the file `_._d_e_p_e_n_d' exists, it is read (see
programs and other files depend. If no --ff _m_a_k_e_f_i_l_e makefile option is
given, bbmmaakkee will try to open `_m_a_k_e_f_i_l_e' then `_M_a_k_e_f_i_l_e' in order to find
the specifications. If the file `_._d_e_p_e_n_d' exists, it is read (see
mkdep(1)).
This manual page is intended as a reference document only. For a more
thorough description of bbmmaakkee and makefiles, please refer to _M_a_k_e _- _A
_T_u_t_o_r_i_a_l.
bbmmaakkee will prepend the contents of the _M_A_K_E_F_L_A_G_S environment variable to
the command line arguments before parsing them.
The options are as follows:
--BB Try to be backwards compatible by executing a single shell per
@ -29,10 +32,12 @@ DDEESSCCRRIIPPTTIIOONN
--DD _v_a_r_i_a_b_l_e
Define _v_a_r_i_a_b_l_e to be 1, in the global context.
--dd _f_l_a_g_s
--dd _[_-_]_f_l_a_g_s
Turn on debugging, and specify which portions of bbmmaakkee are to
print debugging information. _F_l_a_g_s is one or more of the follow-
ing:
print debugging information. Unless the flags are preceded by
`-' they are added to the _M_A_K_E_F_L_A_G_S environment variable and will
be processed by any child make processes. _F_l_a_g_s is one or more
of the following:
_A Print all possible debugging information; equivalent to
specifying all of the debugging flags.
@ -48,6 +53,10 @@ DDEESSCCRRIIPPTTIIOONN
_e Print debugging information about failed commands and
targets.
_F Use the rest of `flags' as the name of the file to which
the debug output is written. If the filename ends `.%d'
then the `%d' is replaced by the pid.
_f Print debugging information about loop evaluation.
_g_1 Print the input graph before making anything.
@ -60,9 +69,20 @@ DDEESSCCRRIIPPTTIIOONN
_j Print debugging information about running multiple
shells.
_l Print commands in Makefiles regardless of whether or not
they are prefixed by `@' or other "quiet" flags. Also
known as "loud" behavior.
_m Print debugging information about making targets, includ-
ing modification dates.
_n Don't delete the temporary command scripts created in
_/_t_m_p when running commands. These are created via
mkstemp(3) and have names of the form _/_t_m_p_/_m_a_k_e_X_X_X_X_X.
_N_O_T_E: This can create many file in _/_t_m_p so use with care.
_p Print debugging information about makefile parsing.
_s Print debugging information about suffix-transformation
rules.
@ -243,7 +263,9 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
::== Assign with expansion, i.e. expand the value before assigning it
to the variable. Normally, expansion is not done until the vari-
able is referenced.
able is referenced. _N_O_T_E: References to undefined variables are
_n_o_t expanded. This can cause problems when variable modifiers
are used.
!!== Expand the value and pass it to the shell for execution and
assign the result to the variable. Any newlines in the result
@ -322,15 +344,37 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
evaluated during Makefile parsing, lists only those tar-
gets encountered thus far.
_._C_U_R_D_I_R A path to the directory where bbmmaakkee was executed.
_._C_U_R_D_I_R A path to the directory where bbmmaakkee was executed. Refer
to the description of `PWD' for more details.
MAKE The name that bbmmaakkee was executed with (_a_r_g_v_[_0_]). For
compatibily bbmmaakkee also sets _._M_A_K_E with the same value.
compatibility bbmmaakkee also sets _._M_A_K_E with the same value.
The preferred variable to use is the environment variable
MAKE because it is more compatible with other versions of
bbmmaakkee and cannot be confused with the special target with
the same name.
_._M_A_K_E_._E_X_P_O_R_T_E_D The list of variables exported by bbmmaakkee.
_._M_A_K_E_._M_A_K_E_F_I_L_E_S
The list of makefiles read by bbmmaakkee, which is useful for
tracking dependencies. Each makefile is recorded only
once, regardless of the number of times read.
_._M_A_K_E_._P_I_D The process-id of bbmmaakkee.
_._M_A_K_E_._P_P_I_D The parent process-id of bbmmaakkee.
_._M_A_K_E_._J_O_B_._P_R_E_F_I_X
If bbmmaakkee is run with _j then output for each target is
prefixed with a token `--- target ---' the first part of
which can be controlled via _._M_A_K_E_._J_O_B_._P_R_E_F_I_X.
For example:
.MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
would produce tokens like `---make[1234] target ---' mak-
ing it easier to track the degree of parallelism being
achieved.
MAKEFLAGS The environment variable `MAKEFLAGS' may contain anything
that may be specified on bbmmaakkee's command line. Anything
specified on bbmmaakkee's command line is appended to the
@ -358,7 +402,37 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
`_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R' could be done as
${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
_._O_B_J_D_I_R A path to the directory where the targets are built.
_._O_B_J_D_I_R A path to the directory where the targets are built. Its
value is determined by trying to chdir(2) to the follow-
ing directories in order and using the first match:
1. ${MAKEOBJDIRPREFIX}${.CURDIR}
(Only if `MAKEOBJDIRPREFIX' is set in the environ-
ment or on the command line.)
2. ${MAKEOBJDIR}
(Only if `MAKEOBJDIR' is set in the environment or
on the command line.)
3. ${.CURDIR}_/_o_b_j_.${MACHINE}
4. ${.CURDIR}_/_o_b_j
5. _/_u_s_r_/_o_b_j_/${.CURDIR}
6. ${.CURDIR}
Variable expansion is performed on the value before it's
used, so expressions such as
${.CURDIR:C,^/usr/src,/var/obj,}
may be used.
`_._O_B_J_D_I_R' may be modified in the makefile as a global
variable. In all cases, bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R'
and set `PWD' to that directory before executing any tar-
gets.
_._P_A_R_S_E_D_I_R A path to the directory of the current `_M_a_k_e_f_i_l_e' being
parsed.
@ -377,19 +451,31 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
However, if the environment variable `PWD' is set and
gives a path to the current directory, then bbmmaakkee sets
`_._C_U_R_D_I_R' to the value of `PWD' instead. This behaviour
is disabled if `MAKEOBJDIRPREFIX' is set. `PWD' is set
to the value of `_._O_B_J_D_I_R' for all programs which bbmmaakkee
executes.
is disabled if `MAKEOBJDIRPREFIX' is set or `MAKEOBJDIR'
contains a variable transform. `PWD' is set to the value
of `_._O_B_J_D_I_R' for all programs which bbmmaakkee executes.
VVaarriiaabbllee mmooddiiffiieerrss
Variable expansion may be modified to select or modify each word of the
variable (where a ``word'' is white-space delimited sequence of charac-
ters). The general format of a variable expansion is as follows:
{variable[:modifier[:...]]}
${variable[:modifier[:...]]}
Each modifier begins with a colon, which may be escaped with a backslash
(`\'). The supported modifiers are:
(`\').
A set of modifiers can be specified via a variable, as follows:
modifier_variable=modifier[:...]
${variable:${modifier_variable}[:...]}
In this case the first modifier in the modifier_variable does not start
with a colon, since that must appear in the referencing variable. If any
of the modifiers in the modifier_variable contain a dollar sign (`$'),
these must be doubled to avoid early expansion.
The supported modifiers are:
::EE Replaces each word in the variable with its suffix.
@ -620,6 +706,13 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
Conditional expressions are also preceded by a single dot as the first
character of a line. The possible conditionals are as follows:
..eexxppoorrtt _v_a_r_i_a_b_l_e
Export the specified global variable. If no variable is pro-
vided, all globals are exported except for internal variables
(those that start with `.' ). This is not affected by the --XX
flag, so should be used with caution. Appending a variable name
to _._M_A_K_E_._E_X_P_O_R_T_E_D is equivalent to exporting a variable.
..uunnddeeff _v_a_r_i_a_b_l_e
Un-define the specified global variable. Only global variables
may be un-defined.
@ -733,7 +826,7 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
CCOOMMMMEENNTTSS
Comments begin with a hash (`#') character, anywhere but in a shell com-
mand line, and continue to the end of the line.
mand line, and continue to the end of an unescaped new line.
SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
..EEXXEECC Target is never out of date, but always execute commands any-
@ -765,8 +858,9 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
--tt option.
..PPRREECCIIOOUUSS
When bbmmaakkee is interrupted, it removes any partially made tar-
gets. This source prevents the target from being removed.
When bbmmaakkee is interrupted, it normally removes any partially
made targets. This source prevents the target from being
removed.
..RREECCUURRSSIIVVEE
Synonym for ..MMAAKKEE.
@ -786,8 +880,23 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
..WWAAIITT If ..WWAAIITT appears in a dependency line, the sources that precede
it are made before the sources that succeed it in the line.
Loops are not detected and targets that form loops will be
silently ignored.
Since the dependents of files are not made until the file
itself could be made, this also stops the dependents being
built unless they are needed for another branch of the depen-
dency tree. So given:
x: a .WAIT b
echo x
a:
echo a
b: b1
echo b
b1:
echo b1
the output is always `b1', `b', `a', `x'.
The ordering imposed by ..WWAAIITT is only relevant for parallel
makes.
SSPPEECCIIAALL TTAARRGGEETTSS
Special targets may not be included with other targets, i.e. they must be
@ -831,7 +940,17 @@ SSPPEECCIIAALL TTAARRGGEETTSS
Synonym for ..NNOOTTPPAARRAALLLLEELL, for compatibility with other pmake
variants.
..OORRDDEERR The named targets are made in sequence.
..OORRDDEERR The named targets are made in sequence. This ordering does not
add targets to the list of targets to be made. Since the depen-
dents of a target do not get built until the target itself could
be built, unless `a' is built by another part of the dependency
graph, the following is a dependency loop:
.ORDER a b
b: a
The ordering imposed by ..OORRDDEERR is only relevant for parallel
makes.
..PPAATTHH The sources are directories which are to be searched for files
not found in the current directory. If no sources are speci-
@ -872,12 +991,16 @@ SSPPEECCIIAALL TTAARRGGEETTSS
_e_c_h_o_F_l_a_g The flag to pass the shell to enable command echo-
ing.
_n_e_w_l_i_n_e The string literal to pass the shell that results in
a single newline character when used outside of any
quoting characters.
Example:
.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \
check="set -e" ignore="set +e" \
echo="set -v" quiet="set +v" filter="set +v" \
echoFlag=v errFlag=e
echoFlag=v errFlag=e newline="'\n'"
..SSIILLEENNTT Apply the ..SSIILLEENNTT attribute to any specified sources. If no
sources are specified, the ..SSIILLEENNTT attribute is applied to every
@ -892,11 +1015,9 @@ EENNVVIIRROONNMMEENNTT
MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX, MAKESYSPATH,
and PWD.
If MAKEOBJDIRPREFIX is set, then bbmmaakkee will chdir(2) to ${MAKEOBJDIRPRE-
FIX}${.CURDIR} if it exists. Otherwise if MAKEOBJDIR and the named
directory exists bbmmaakkee will chdir(2) to it. These actions are taken
before any makefiles are read which is why they need to be set in the
environment.
MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on
the command line to bbmmaakkee and not as makefile variables; see the descrip-
tion of `_._O_B_J_D_I_R' for more details.
FFIILLEESS
.depend list of dependencies
@ -905,6 +1026,15 @@ FFIILLEESS
sys.mk system makefile
/usr/share/mk system makefile directory
CCOOMMPPAATTIIBBIILLIITTYY
The basic make syntax is compatible between different versions of make,
however the special variables, variable modifiers and conditionals are
not.
The way that parallel makes are scheduled changed in NetBSD 4.0 so that
.ORDER and .WAIT apply recursively to the dependant nodes. The algo-
rithms used may change again in the future.
SSEEEE AALLSSOO
mkdep(1)
@ -912,4 +1042,4 @@ HHIISSTTOORRYY
bbmmaakkee is derived from NetBSD's make(1). It uses autoconf to facilitate
portability to other platforms.
NetBSD 2.0 June 1, 2005 NetBSD 2.0
BSD November 19, 2006 BSD

View file

@ -1,4 +1,4 @@
/* $NetBSD: buf.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */
/* $NetBSD: buf.c,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: buf.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $";
static char rcsid[] = "$NetBSD: buf.c,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: buf.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $");
__RCSID("$NetBSD: buf.c,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $");
#endif
#endif /* not lint */
#endif

View file

@ -1,4 +1,4 @@
/* $NetBSD: buf.h,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */
/* $NetBSD: buf.h,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.

View file

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */
/* $NetBSD: dir.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: dir.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: dir.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $");
__RCSID("$NetBSD: dir.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -303,7 +303,7 @@ Dir_InitCur(const char *cdname)
* We've been here before, cleanup.
*/
cur->refCount -= 1;
Dir_Destroy((ClientData) cur);
Dir_Destroy(cur);
}
cur = p;
}
@ -329,7 +329,7 @@ Dir_InitDot(void)
LstNode ln;
/* Remove old entry from openDirectories, but do not destroy. */
ln = Lst_Member(openDirectories, (ClientData)dot);
ln = Lst_Member(openDirectories, dot);
(void)Lst_Remove(openDirectories, ln);
}
@ -366,12 +366,12 @@ Dir_End(void)
#ifdef CLEANUP
if (cur) {
cur->refCount -= 1;
Dir_Destroy((ClientData) cur);
Dir_Destroy(cur);
}
dot->refCount -= 1;
dotLast->refCount -= 1;
Dir_Destroy((ClientData) dotLast);
Dir_Destroy((ClientData) dot);
Dir_Destroy(dotLast);
Dir_Destroy(dot);
Dir_ClearPath(dirSearchPath);
Lst_Destroy(dirSearchPath, NOFREE);
Dir_ClearPath(openDirectories);
@ -726,7 +726,7 @@ DirExpandInt(const char *word, Lst path, Lst expansions)
static int
DirPrintWord(ClientData word, ClientData dummy)
{
printf("%s ", (char *)word);
fprintf(debug_file, "%s ", (char *)word);
return(dummy ? 0 : 0);
}
@ -757,7 +757,7 @@ Dir_Expand(const char *word, Lst path, Lst expansions)
const char *cp;
if (DEBUG(DIR)) {
printf("Expanding \"%s\"... ", word);
fprintf(debug_file, "Expanding \"%s\"... ", word);
}
cp = strchr(word, '{');
@ -841,8 +841,8 @@ Dir_Expand(const char *word, Lst path, Lst expansions)
}
}
if (DEBUG(DIR)) {
Lst_ForEach(expansions, DirPrintWord, (ClientData) 0);
fputc('\n', stdout);
Lst_ForEach(expansions, DirPrintWord, NULL);
fprintf(debug_file, "\n");
}
}
@ -866,7 +866,7 @@ DirLookup(Path *p, const char *name __unused, const char *cp,
char *file; /* the current filename to check */
if (DEBUG(DIR)) {
printf(" %s ...\n", p->name);
fprintf(debug_file, " %s ...\n", p->name);
}
if (Hash_FindEntry(&p->files, cp) == NULL)
@ -874,7 +874,7 @@ DirLookup(Path *p, const char *name __unused, const char *cp,
file = str_concat(p->name, cp, STR_ADDSLASH);
if (DEBUG(DIR)) {
printf(" returning %s\n", file);
fprintf(debug_file, " returning %s\n", file);
}
p->hits += 1;
hits += 1;
@ -913,7 +913,7 @@ DirLookupSubdir(Path *p, const char *name)
}
if (DEBUG(DIR)) {
printf("checking %s ...\n", file);
fprintf(debug_file, "checking %s ...\n", file);
}
if (stat(file, &stb) == 0) {
@ -922,7 +922,7 @@ DirLookupSubdir(Path *p, const char *name)
* to fetch it again.
*/
if (DEBUG(DIR)) {
printf(" Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
file);
}
entry = Hash_CreateEntry(&mtimes, (char *)file, NULL);
@ -956,7 +956,7 @@ DirLookupAbs(Path *p, const char *name, const char *cp)
const char *p2; /* pointer into name */
if (DEBUG(DIR)) {
printf(" %s ...\n", p->name);
fprintf(debug_file, " %s ...\n", p->name);
}
/*
@ -974,7 +974,7 @@ DirLookupAbs(Path *p, const char *name, const char *cp)
if (Hash_FindEntry(&p->files, cp) == NULL) {
if (DEBUG(DIR)) {
printf(" must be here but isn't -- returning\n");
fprintf(debug_file, " must be here but isn't -- returning\n");
}
/* Return empty string: terminates search */
return estrdup("");
@ -983,7 +983,7 @@ DirLookupAbs(Path *p, const char *name, const char *cp)
p->hits += 1;
hits += 1;
if (DEBUG(DIR)) {
printf(" returning %s\n", name);
fprintf(debug_file, " returning %s\n", name);
}
return (estrdup(name));
}
@ -1007,7 +1007,7 @@ DirFindDot(Boolean hasSlash __unused, const char *name, const char *cp)
if (Hash_FindEntry(&dot->files, cp) != NULL) {
if (DEBUG(DIR)) {
printf(" in '.'\n");
fprintf(debug_file, " in '.'\n");
}
hits += 1;
dot->hits += 1;
@ -1016,7 +1016,7 @@ DirFindDot(Boolean hasSlash __unused, const char *name, const char *cp)
if (cur &&
Hash_FindEntry(&cur->files, cp) != NULL) {
if (DEBUG(DIR)) {
printf(" in ${.CURDIR} = %s\n", cur->name);
fprintf(debug_file, " in ${.CURDIR} = %s\n", cur->name);
}
hits += 1;
cur->hits += 1;
@ -1054,7 +1054,7 @@ Dir_FindFile(const char *name, Lst path)
LstNode ln; /* a list element */
char *file; /* the current filename to check */
Path *p; /* current path member */
const char *cp; /* index of first slash, if any */
const char *cp; /* Terminal name of file */
Boolean hasLastDot = FALSE; /* true we should search dot last */
Boolean hasSlash; /* true if 'name' contains a / */
struct stat stb; /* Buffer for stat, if necessary */
@ -1074,12 +1074,12 @@ Dir_FindFile(const char *name, Lst path)
}
if (DEBUG(DIR)) {
printf("Searching for %s ...", name);
fprintf(debug_file, "Searching for %s ...", name);
}
if (Lst_Open(path) == FAILURE) {
if (DEBUG(DIR)) {
printf("couldn't open path, file not found\n");
fprintf(debug_file, "couldn't open path, file not found\n");
}
misses += 1;
return (NULL);
@ -1090,11 +1090,11 @@ Dir_FindFile(const char *name, Lst path)
if (p == dotLast) {
hasLastDot = TRUE;
if (DEBUG(DIR))
printf("[dot last]...");
fprintf(debug_file, "[dot last]...");
}
}
if (DEBUG(DIR)) {
printf("\n");
fprintf(debug_file, "\n");
}
/*
@ -1102,7 +1102,7 @@ Dir_FindFile(const char *name, Lst path)
* directory component is exactly `./', consult the cached contents
* of each of the directories on the search path.
*/
if ((!hasSlash || (cp - name == 2 && *name == '.'))) {
if (!hasSlash || (cp - name == 2 && *name == '.')) {
/*
* We look through all the directories on the path seeking one which
* contains the final component of the given name. If such a beast
@ -1129,7 +1129,7 @@ Dir_FindFile(const char *name, Lst path)
continue;
if ((file = DirLookup(p, name, cp, hasSlash)) != NULL) {
Lst_Close(path);
return file;
return file;
}
}
@ -1157,7 +1157,7 @@ Dir_FindFile(const char *name, Lst path)
*/
if (!hasSlash) {
if (DEBUG(DIR)) {
printf(" failed.\n");
fprintf(debug_file, " failed.\n");
}
misses += 1;
return (NULL);
@ -1167,7 +1167,7 @@ Dir_FindFile(const char *name, Lst path)
Boolean checkedDot = FALSE;
if (DEBUG(DIR)) {
printf(" Trying subdirectories...\n");
fprintf(debug_file, " Trying subdirectories...\n");
}
if (!hasLastDot) {
@ -1213,7 +1213,7 @@ Dir_FindFile(const char *name, Lst path)
* so no point in proceeding...
*/
if (DEBUG(DIR)) {
printf(" Checked . already, returning NULL\n");
fprintf(debug_file, " Checked . already, returning NULL\n");
}
return(NULL);
}
@ -1230,7 +1230,7 @@ Dir_FindFile(const char *name, Lst path)
* returning an empty string.
*/
if (DEBUG(DIR)) {
printf(" Trying exact path matches...\n");
fprintf(debug_file, " Trying exact path matches...\n");
}
if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
@ -1289,27 +1289,27 @@ Dir_FindFile(const char *name, Lst path)
}
#else /* !notdef */
if (DEBUG(DIR)) {
printf(" Looking for \"%s\" ...\n", name);
fprintf(debug_file, " Looking for \"%s\" ...\n", name);
}
bigmisses += 1;
entry = Hash_FindEntry(&mtimes, name);
if (entry != NULL) {
if (DEBUG(DIR)) {
printf(" got it (in mtime cache)\n");
fprintf(debug_file, " got it (in mtime cache)\n");
}
return(estrdup(name));
} else if (stat(name, &stb) == 0) {
entry = Hash_CreateEntry(&mtimes, name, NULL);
if (DEBUG(DIR)) {
printf(" Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
name);
}
Hash_SetValue(entry, (long)stb.st_mtime);
return (estrdup(name));
} else {
if (DEBUG(DIR)) {
printf(" failed. Returning NULL\n");
fprintf(debug_file, " failed. Returning NULL\n");
}
return (NULL);
}
@ -1428,8 +1428,12 @@ Dir_MTime(GNode *gn)
} else if (gn->path == NULL) {
if (gn->type & OP_NOPATH)
fullName = NULL;
else
else {
fullName = Dir_FindFile(gn->name, Suff_FindPath(gn));
if (DEBUG(DIR))
fprintf(debug_file, "Found '%s' as '%s'\n",
gn->name, fullName ? fullName : "(not found)" );
}
} else {
fullName = gn->path;
}
@ -1446,7 +1450,7 @@ Dir_MTime(GNode *gn)
* to the file system.
*/
if (DEBUG(DIR)) {
printf("Using cached time %s for %s\n",
fprintf(debug_file, "Using cached time %s for %s\n",
Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName);
}
stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
@ -1497,27 +1501,26 @@ Dir_AddDir(Lst path, const char *name)
struct dirent *dp; /* entry in directory */
if (strcmp(name, ".DOTLAST") == 0) {
ln = Lst_Find(path, (ClientData)UNCONST(name), DirFindName);
ln = Lst_Find(path, UNCONST(name), DirFindName);
if (ln != NILLNODE)
return (Path *)Lst_Datum(ln);
else {
dotLast->refCount += 1;
(void)Lst_AtFront(path, (ClientData)dotLast);
(void)Lst_AtFront(path, dotLast);
}
}
if (path)
ln = Lst_Find(openDirectories, (ClientData)UNCONST(name), DirFindName);
ln = Lst_Find(openDirectories, UNCONST(name), DirFindName);
if (ln != NILLNODE) {
p = (Path *)Lst_Datum(ln);
if (Lst_Member(path, (ClientData)p) == NILLNODE) {
if (path && Lst_Member(path, p) == NILLNODE) {
p->refCount += 1;
(void)Lst_AtEnd(path, (ClientData)p);
(void)Lst_AtEnd(path, p);
}
} else {
if (DEBUG(DIR)) {
printf("Caching %s ...", name);
fflush(stdout);
fprintf(debug_file, "Caching %s ...", name);
}
if ((d = opendir(name)) != NULL) {
@ -1541,12 +1544,12 @@ Dir_AddDir(Lst path, const char *name)
(void)Hash_CreateEntry(&p->files, dp->d_name, NULL);
}
(void)closedir(d);
(void)Lst_AtEnd(openDirectories, (ClientData)p);
(void)Lst_AtEnd(openDirectories, p);
if (path != NULL)
(void)Lst_AtEnd(path, (ClientData)p);
(void)Lst_AtEnd(path, p);
}
if (DEBUG(DIR)) {
printf("done\n");
fprintf(debug_file, "done\n");
}
}
return p;
@ -1571,7 +1574,7 @@ Dir_CopyDir(ClientData p)
{
((Path *)p)->refCount += 1;
return ((ClientData)p);
return (p);
}
/*-
@ -1646,7 +1649,7 @@ Dir_Destroy(ClientData pp)
if (p->refCount == 0) {
LstNode ln;
ln = Lst_Member(openDirectories, (ClientData)p);
ln = Lst_Member(openDirectories, p);
(void)Lst_Remove(openDirectories, ln);
Hash_DeleteTable(&p->files);
@ -1678,7 +1681,7 @@ Dir_ClearPath(Lst path)
Path *p;
while (!Lst_IsEmpty(path)) {
p = (Path *)Lst_DeQueue(path);
Dir_Destroy((ClientData) p);
Dir_Destroy(p);
}
}
@ -1709,9 +1712,9 @@ Dir_Concat(Lst path1, Lst path2)
for (ln = Lst_First(path2); ln != NILLNODE; ln = Lst_Succ(ln)) {
p = (Path *)Lst_Datum(ln);
if (Lst_Member(path1, (ClientData)p) == NILLNODE) {
if (Lst_Member(path1, p) == NILLNODE) {
p->refCount += 1;
(void)Lst_AtEnd(path1, (ClientData)p);
(void)Lst_AtEnd(path1, p);
}
}
}
@ -1723,16 +1726,16 @@ Dir_PrintDirectories(void)
LstNode ln;
Path *p;
printf("#*** Directory Cache:\n");
printf("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
fprintf(debug_file, "#*** Directory Cache:\n");
fprintf(debug_file, "# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
hits, misses, nearmisses, bigmisses,
(hits+bigmisses+nearmisses ?
hits * 100 / (hits + bigmisses + nearmisses) : 0));
printf("# %-20s referenced\thits\n", "directory");
fprintf(debug_file, "# %-20s referenced\thits\n", "directory");
if (Lst_Open(openDirectories) == SUCCESS) {
while ((ln = Lst_Next(openDirectories)) != NILLNODE) {
p = (Path *)Lst_Datum(ln);
printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
fprintf(debug_file, "# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
}
Lst_Close(openDirectories);
}
@ -1741,12 +1744,12 @@ Dir_PrintDirectories(void)
static int
DirPrintDir(ClientData p, ClientData dummy)
{
printf("%s ", ((Path *)p)->name);
fprintf(debug_file, "%s ", ((Path *)p)->name);
return (dummy ? 0 : 0);
}
void
Dir_PrintPath(Lst path)
{
Lst_ForEach(path, DirPrintDir, (ClientData)0);
Lst_ForEach(path, DirPrintDir, NULL);
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: dir.h,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */
/* $NetBSD: dir.h,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.

View file

@ -1,4 +1,4 @@
/* $NetBSD: for.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */
/* $NetBSD: for.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: for.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $";
static char rcsid[] = "$NetBSD: for.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: for.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $");
__RCSID("$NetBSD: for.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -164,7 +164,7 @@ For_Eval(char *line)
* a for.
*/
if (ptr[0] != 'f' || ptr[1] != 'o' || ptr[2] != 'r' ||
!isspace((unsigned char) ptr[3]))
!isspace((unsigned char) ptr[3]))
return FALSE;
ptr += 3;
@ -228,7 +228,7 @@ For_Eval(char *line)
#define ADDWORD() \
Buf_AddBytes(buf, ptr - wrd, (Byte *)wrd), \
Buf_AddByte(buf, (Byte)'\0'), \
Lst_AtFront(accumFor.lst, (ClientData)Buf_GetAll(buf, &varlen)), \
Lst_AtFront(accumFor.lst, Buf_GetAll(buf, &varlen)), \
Buf_Destroy(buf, FALSE)
for (ptr = sub; *ptr && isspace((unsigned char) *ptr); ptr++)
@ -245,9 +245,9 @@ For_Eval(char *line)
if (DEBUG(FOR)) {
int i;
for (i = 0; i < accumFor.nvars; i++) {
(void)fprintf(stderr, "For: variable %s\n", accumFor.vars[i]);
(void)fprintf(debug_file, "For: variable %s\n", accumFor.vars[i]);
}
(void)fprintf(stderr, "For: list %s\n", sub);
(void)fprintf(debug_file, "For: list %s\n", sub);
}
if (ptr - wrd > 0)
ADDWORD();
@ -259,25 +259,25 @@ For_Eval(char *line)
forLevel++;
return 1;
}
else if (*ptr == '.') {
if (*ptr == '.') {
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
continue;
if (strncmp(ptr, "endfor", 6) == 0 &&
(isspace((unsigned char) ptr[6]) || !ptr[6])) {
(isspace((unsigned char) ptr[6]) || !ptr[6])) {
if (DEBUG(FOR))
(void)fprintf(stderr, "For: end for %d\n", forLevel);
(void)fprintf(debug_file, "For: end for %d\n", forLevel);
if (--forLevel < 0) {
Parse_Error(level, "for-less endfor");
return 0;
}
}
else if (strncmp(ptr, "for", 3) == 0 &&
} else if (strncmp(ptr, "for", 3) == 0 &&
isspace((unsigned char) ptr[3])) {
forLevel++;
if (DEBUG(FOR))
(void)fprintf(stderr, "For: new loop %d\n", forLevel);
(void)fprintf(debug_file, "For: new loop %d\n", forLevel);
}
}
@ -286,9 +286,8 @@ For_Eval(char *line)
Buf_AddByte(accumFor.buf, (Byte)'\n');
return 1;
}
else {
return 0;
}
return 0;
}
@ -351,7 +350,7 @@ For_Run(int lineno)
for (i = 0; i < arg.nvars; i++) {
Var_Set(arg.vars[i], values[i], VAR_GLOBAL, 0);
if (DEBUG(FOR))
(void)fprintf(stderr, "--- %s = %s\n", arg.vars[i],
(void)fprintf(debug_file, "--- %s = %s\n", arg.vars[i],
values[i]);
}
@ -372,7 +371,7 @@ For_Run(int lineno)
if (old_guy != orig_guy)
free(old_guy);
}
Parse_FromString(guy, lineno);
Parse_SetInput(NULL, lineno, -1, guy);
for (i = 0; i < arg.nvars; i++)
Var_Delete(arg.vars[i], VAR_GLOBAL);

View file

@ -1,4 +1,4 @@
/* $NetBSD: lst.h,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lst.h,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -89,8 +89,8 @@
* basic typedef. This is what the Lst_ functions handle
*/
typedef struct Lst *Lst;
typedef struct LstNode *LstNode;
typedef struct List *Lst;
typedef struct ListNode *LstNode;
typedef ClientData DuplicateProc(ClientData);
typedef void FreeProc(ClientData);
@ -125,9 +125,9 @@ Boolean Lst_IsEmpty(Lst);
* Functions to modify a list
*/
/* Insert an element before another */
ReturnStatus Lst_Insert(Lst, LstNode, ClientData);
ReturnStatus Lst_InsertBefore(Lst, LstNode, ClientData);
/* Insert an element after another */
ReturnStatus Lst_Append(Lst, LstNode, ClientData);
ReturnStatus Lst_InsertAfter(Lst, LstNode, ClientData);
/* Place an element at the front of a lst. */
ReturnStatus Lst_AtFront(Lst, ClientData);
/* Place an element at the end of a lst. */
@ -148,6 +148,8 @@ LstNode Lst_First(Lst);
LstNode Lst_Last(Lst);
/* Return successor to given element */
LstNode Lst_Succ(LstNode);
/* Return predecessor to given element */
LstNode Lst_Prev(LstNode);
/* Get datum from LstNode */
ClientData Lst_Datum(LstNode);
@ -165,13 +167,13 @@ LstNode Lst_FindFrom(Lst, LstNode, ClientData,
*/
LstNode Lst_Member(Lst, ClientData);
/* Apply a function to all elements of a lst */
void Lst_ForEach(Lst, int (*)(ClientData, ClientData), ClientData);
int Lst_ForEach(Lst, int (*)(ClientData, ClientData), ClientData);
/*
* Apply a function to all elements of a lst starting from a certain point.
* If the list is circular, the application will wrap around to the
* beginning of the list again.
*/
void Lst_ForEachFrom(Lst, LstNode, int (*)(ClientData, ClientData),
int Lst_ForEachFrom(Lst, LstNode, int (*)(ClientData, ClientData),
ClientData);
/*
* these functions are for dealing with a list as a table, of sorts.

View file

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $
# $NetBSD: Makefile,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $
OBJ=lstAppend.o lstDupl.o lstInit.o lstOpen.o lstAtEnd.o lstEnQueue.o \
lstInsert.o lstAtFront.o lstIsAtEnd.o lstClose.o lstFind.o lstIsEmpty.o \
lstRemove.o lstConcat.o lstFindFrom.o lstLast.o lstReplace.o lstFirst.o \
lstDatum.o lstForEach.o lstMember.o lstSucc.o lstDeQueue.o \
lstForEachFrom.o lstDestroy.o lstNext.o
lstForEachFrom.o lstDestroy.o lstNext.o lstPrev.o
CPPFLAGS=-I${.CURDIR}/..
all: ${OBJ}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstAppend.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstAppend.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstAppend.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstAppend.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstAppend.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstAppend.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -54,7 +54,7 @@ __RCSID("$NetBSD: lstAppend.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
/*-
*-----------------------------------------------------------------------
* Lst_Append --
* Lst_InsertAfter --
* Create a new node and add it to the given list after the given node.
*
* Input:
@ -74,7 +74,7 @@ __RCSID("$NetBSD: lstAppend.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
*-----------------------------------------------------------------------
*/
ReturnStatus
Lst_Append(Lst l, LstNode ln, ClientData d)
Lst_InsertAfter(Lst l, LstNode ln, ClientData d)
{
List list;
ListNode lNode;
@ -89,8 +89,8 @@ Lst_Append(Lst l, LstNode ln, ClientData d)
}
ok:
list = (List)l;
lNode = (ListNode)ln;
list = l;
lNode = ln;
PAlloc (nLNode, ListNode);
nLNode->datum = d;

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstAtEnd.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstAtEnd.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstAtEnd.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstAtEnd.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -75,5 +75,5 @@ Lst_AtEnd(Lst l, ClientData d)
LstNode end;
end = Lst_Last(l);
return (Lst_Append(l, end, d));
return (Lst_InsertAfter(l, end, d));
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstAtFront.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstAtFront.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstAtFront.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstAtFront.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstAtFront.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstAtFront.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -72,5 +72,5 @@ Lst_AtFront(Lst l, ClientData d)
LstNode front;
front = Lst_First(l);
return (Lst_Insert(l, front, d));
return (Lst_InsertBefore(l, front, d));
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstClose.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstClose.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstClose.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstClose.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstClose.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstClose.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -76,7 +76,7 @@ __RCSID("$NetBSD: lstClose.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
void
Lst_Close(Lst l)
{
List list = (List) l;
List list = l;
if (LstValid(l) == TRUE) {
list->isOpen = FALSE;

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstConcat.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstConcat.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstConcat.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstConcat.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstConcat.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstConcat.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -82,8 +82,8 @@ Lst_Concat(Lst l1, Lst l2, int flags)
ListNode nln; /* new LstNode */
ListNode last; /* the last element in the list. Keeps
* bookkeeping until the end */
List list1 = (List)l1;
List list2 = (List)l2;
List list1 = l1;
List list2 = l2;
if (!LstValid (l1) || !LstValid (l2)) {
return (FAILURE);

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstDatum.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstDatum.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstDatum.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstDatum.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstDatum.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstDatum.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -69,7 +69,7 @@ ClientData
Lst_Datum(LstNode ln)
{
if (ln != NILLNODE) {
return (((ListNode)ln)->datum);
return ((ln)->datum);
} else {
return ((ClientData) NIL);
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstDeQueue.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstDeQueue.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstDeQueue.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstDeQueue.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstDeQueue.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstDeQueue.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -72,13 +72,13 @@ Lst_DeQueue(Lst l)
ClientData rd;
ListNode tln;
tln = (ListNode) Lst_First(l);
tln = Lst_First(l);
if (tln == NilListNode) {
return ((ClientData) NIL);
}
rd = tln->datum;
if (Lst_Remove(l, (LstNode)tln) == FAILURE) {
if (Lst_Remove(l, tln) == FAILURE) {
return ((ClientData) NIL);
} else {
return (rd);

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstDestroy.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstDestroy.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstDestroy.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstDestroy.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstDestroy.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstDestroy.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -72,7 +72,7 @@ Lst_Destroy(Lst l, FreeProc *freeProc)
{
ListNode ln;
ListNode tln = NilListNode;
List list = (List)l;
List list = l;
if (l == NILLST || ! l) {
/*

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstDupl.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstDupl.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstDupl.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstDupl.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstDupl.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstDupl.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -75,7 +75,7 @@ Lst_Duplicate(Lst l, DuplicateProc *copyProc)
{
Lst nl;
ListNode ln;
List list = (List)l;
List list = l;
if (!LstValid (l)) {
return (NILLST);

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstEnQueue.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstEnQueue.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstEnQueue.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstEnQueue.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstEnQueue.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstEnQueue.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -58,7 +58,7 @@ __RCSID("$NetBSD: lstEnQueue.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
* Add the datum to the tail of the given list.
*
* Results:
* SUCCESS or FAILURE as returned by Lst_Append.
* SUCCESS or FAILURE as returned by Lst_InsertAfter.
*
* Side Effects:
* the lastPtr field is altered all the time and the firstPtr field
@ -73,6 +73,6 @@ Lst_EnQueue(Lst l, ClientData d)
return (FAILURE);
}
return (Lst_Append(l, Lst_Last(l), d));
return (Lst_InsertAfter(l, Lst_Last(l), d));
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstFindFrom.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstFindFrom.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstFindFrom.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstFindFrom.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstFindFrom.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstFindFrom.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -78,7 +78,7 @@ Lst_FindFrom(Lst l, LstNode ln, ClientData d,
return (NILLNODE);
}
tln = (ListNode)ln;
tln = ln;
do {
if ((*cProc) (tln->datum, d) == 0) {
@ -87,10 +87,10 @@ Lst_FindFrom(Lst l, LstNode ln, ClientData d,
} else {
tln = tln->nextPtr;
}
} while (tln != (ListNode)ln && tln != NilListNode);
} while (tln != ln && tln != NilListNode);
if (found) {
return ((LstNode)tln);
return (tln);
} else {
return (NILLNODE);
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstFirst.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstFirst.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstFirst.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstFirst.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstFirst.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstFirst.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -71,7 +71,7 @@ Lst_First(Lst l)
if (!LstValid (l) || LstIsEmpty (l)) {
return (NILLNODE);
} else {
return ((LstNode)((List)l)->firstPtr);
return (l->firstPtr);
}
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstForEach.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstForEach.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstForEach.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstForEach.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstForEach.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstForEach.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -68,9 +68,9 @@ __RCSID("$NetBSD: lstForEach.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
*-----------------------------------------------------------------------
*/
/*VARARGS2*/
void
int
Lst_ForEach(Lst l, int (*proc)(ClientData, ClientData), ClientData d)
{
Lst_ForEachFrom(l, Lst_First(l), proc, d);
return Lst_ForEachFrom(l, Lst_First(l), proc, d);
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstForEachFrom.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstForEachFrom.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstForEachFrom.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstForEachFrom.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -69,18 +69,18 @@ __RCSID("$NetBSD: lstForEachFrom.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
*-----------------------------------------------------------------------
*/
/*VARARGS2*/
void
int
Lst_ForEachFrom(Lst l, LstNode ln, int (*proc)(ClientData, ClientData),
ClientData d)
{
ListNode tln = (ListNode)ln;
List list = (List)l;
ListNode tln = ln;
List list = l;
ListNode next;
Boolean done;
int result;
if (!LstValid (list) || LstIsEmpty (list)) {
return;
return 0;
}
do {
@ -120,5 +120,6 @@ Lst_ForEachFrom(Lst l, LstNode ln, int (*proc)(ClientData, ClientData),
tln = next;
} while (!result && !LstIsEmpty(list) && !done);
return result;
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstInit.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstInit.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstInit.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstInit.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstInit.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstInit.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -81,5 +81,5 @@ Lst_Init(Boolean circ)
nList->isCirc = circ;
nList->atEnd = Unknown;
return ((Lst)nList);
return (nList);
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstInsert.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstInsert.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstInsert.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstInsert.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstInsert.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstInsert.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -54,7 +54,7 @@ __RCSID("$NetBSD: lstInsert.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
/*-
*-----------------------------------------------------------------------
* Lst_Insert --
* Lst_InsertBefore --
* Insert a new node with the given piece of data before the given
* node in the given list.
*
@ -73,11 +73,11 @@ __RCSID("$NetBSD: lstInsert.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
*-----------------------------------------------------------------------
*/
ReturnStatus
Lst_Insert(Lst l, LstNode ln, ClientData d)
Lst_InsertBefore(Lst l, LstNode ln, ClientData d)
{
ListNode nLNode; /* new lnode for d */
ListNode lNode = (ListNode)ln;
List list = (List)l;
ListNode lNode = ln;
List list = l;
/*

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstIsAtEnd.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstIsAtEnd.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -79,7 +79,7 @@ __RCSID("$NetBSD: lstIsAtEnd.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
Boolean
Lst_IsAtEnd(Lst l)
{
List list = (List) l;
List list = l;
return (!LstValid (l) || !list->isOpen ||
(list->atEnd == Head) || (list->atEnd == Tail));

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstLast.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstLast.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstLast.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstLast.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstLast.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstLast.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -71,7 +71,7 @@ Lst_Last(Lst l)
if (!LstValid(l) || LstIsEmpty (l)) {
return (NILLNODE);
} else {
return ((LstNode)((List)l)->lastPtr);
return (l->lastPtr);
}
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstMember.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstMember.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstMember.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstMember.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstMember.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstMember.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -55,7 +55,7 @@ __RCSID("$NetBSD: lstMember.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
LstNode
Lst_Member(Lst l, ClientData d)
{
List list = (List) l;
List list = l;
ListNode lNode;
lNode = list->firstPtr;
@ -65,7 +65,7 @@ Lst_Member(Lst l, ClientData d)
do {
if (lNode->datum == d) {
return (LstNode)lNode;
return lNode;
}
lNode = lNode->nextPtr;
} while (lNode != NilListNode && lNode != list->firstPtr);

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstNext.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstNext.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstNext.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstNext.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstNext.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstNext.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -76,7 +76,7 @@ LstNode
Lst_Next(Lst l)
{
ListNode tln;
List list = (List)l;
List list = l;
if ((LstValid (l) == FALSE) ||
(list->isOpen == FALSE)) {
@ -115,6 +115,6 @@ Lst_Next(Lst l)
}
}
return ((LstNode)tln);
return (tln);
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstOpen.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstOpen.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstOpen.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstOpen.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstOpen.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstOpen.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -78,9 +78,9 @@ Lst_Open(Lst l)
if (LstValid (l) == FALSE) {
return (FAILURE);
}
((List) l)->isOpen = TRUE;
((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
((List) l)->curPtr = NilListNode;
(l)->isOpen = TRUE;
(l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
(l)->curPtr = NilListNode;
return (SUCCESS);
}

View file

@ -0,0 +1,79 @@
/* $NetBSD: lstPrev.c,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstPrev.c,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstPrev.c,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
/*-
* LstPrev.c --
* return the predecessor to a given node
*/
#include "lstInt.h"
/*-
*-----------------------------------------------------------------------
* Lst_Prev --
* Return the predecessor to the given node on its list.
*
* Results:
* The predecessor of the node, if it exists (note that on a circular
* list, if the node is the only one in the list, it is its own
* predecessor).
*
* Side Effects:
* None.
*
*-----------------------------------------------------------------------
*/
LstNode
Lst_Prev(LstNode ln)
{
if (ln == NILLNODE) {
return (NILLNODE);
} else {
return (ln->prevPtr);
}
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstRemove.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstRemove.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstRemove.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstRemove.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -70,8 +70,8 @@ __RCSID("$NetBSD: lstRemove.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
ReturnStatus
Lst_Remove(Lst l, LstNode ln)
{
List list = (List) l;
ListNode lNode = (ListNode) ln;
List list = l;
ListNode lNode = ln;
if (!LstValid (l) ||
!LstNodeValid (ln, l)) {

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstReplace.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstReplace.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstReplace.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstReplace.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstReplace.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstReplace.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -71,7 +71,7 @@ Lst_Replace(LstNode ln, ClientData d)
if (ln == NILLNODE) {
return (FAILURE);
} else {
((ListNode) ln)->datum = d;
(ln)->datum = d;
return (SUCCESS);
}
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: lstSucc.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: lstSucc.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstSucc.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: lstSucc.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lstSucc.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: lstSucc.c,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -73,7 +73,7 @@ Lst_Succ(LstNode ln)
if (ln == NILLNODE) {
return (NILLNODE);
} else {
return ((LstNode) ((ListNode) ln)->nextPtr);
return (ln->nextPtr);
}
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: make-conf.h,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */
/* $NetBSD: make-conf.h,v 1.1.1.2 2008/03/09 19:39:32 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -72,10 +72,6 @@
* from: @(#)config.h 8.1 (Berkeley) 6/6/93
*/
#ifndef DEFSHELL
#define DEFSHELL 1 /* Bourne shell */
#endif
/*
* DEFMAXJOBS
* DEFMAXLOCAL
@ -145,13 +141,6 @@
*/
#define SUNSHCMD
/*
* USE_PGRP
* Kill the process group of the job so that all the progeny of the
* current job dies, instead of just the one forked.
*/
#define USE_PGRP
/*
* USE_IOVEC
* We have writev(2)

View file

@ -1,4 +1,4 @@
.\" $NetBSD: make.1,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $
.\" $NetBSD: make.1,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
.Dd June 27, 2005
.Dd November 19, 2006
.Dt MAKE 1
.Os
.Sh NAME
@ -74,12 +74,15 @@
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.
If the file
If no
.Fl f Ar makefile
makefile option is given,
.Nm
will try to open
.Ql Pa makefile
exists, it is read for this list of specifications.
If it does not exist, the file
then
.Ql Pa Makefile
is read.
in order to find the specifications.
If the file
.Ql Pa .depend
exists, it is read (see
@ -91,6 +94,11 @@ For a more thorough description of
and makefiles, please refer to
.%T "Make \- A Tutorial" .
.Pp
.Nm
will prepend the contents of the
.Va MAKEFLAGS
environment variable to the command line arguments before parsing them.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl B
@ -100,10 +108,15 @@ by executing the commands to make the sources of a dependency line in sequence.
Define
.Ar variable
to be 1, in the global context.
.It Fl d Ar flags
.It Fl d Ar [-]flags
Turn on debugging, and specify which portions of
.Nm
are to print debugging information.
Unless the flags are preceded by
.Ql -
they are added to the
.Va MAKEFLAGS
environment variable and will be processed by any child make processes.
.Ar Flags
is one or more of the following:
.Bl -tag -width Ds
@ -118,6 +131,15 @@ Print debugging information about conditional evaluation.
Print debugging information about directory searching and caching.
.It Ar e
Print debugging information about failed commands and targets.
.It Ar F
Use the rest of
.Ql flags
as the name of the file to which the debug output is written.
If the filename ends
.Ql .%d
then the
.Ql %d
is replaced by the pid.
.It Ar f
Print debugging information about loop evaluation.
.It Ar "g1"
@ -129,6 +151,11 @@ on error.
Print the input graph before exiting on error.
.It Ar j
Print debugging information about running multiple shells.
.It Ar l
Print commands in Makefiles regardless of whether or not they are prefixed by
.Ql @
or other "quiet" flags.
Also known as "loud" behavior.
.It Ar m
Print debugging information about making targets, including modification
dates.
@ -140,8 +167,12 @@ These are created via
.Xr mkstemp 3
and have names of the form
.Pa /tmp/makeXXXXX .
.Em NOTE:
This can create many file in /tmp so use with care.
.Em NOTE :
This can create many file in
.Pa /tmp
so use with care.
.It Ar p
Print debugging information about makefile parsing.
.It Ar s
Print debugging information about suffix-transformation rules.
.It Ar t
@ -413,6 +444,11 @@ Assign the value to the variable if it is not already defined.
Assign with expansion, i.e. expand the value before assigning it
to the variable.
Normally, expansion is not done until the variable is referenced.
.Em NOTE :
References to undefined variables are
.Em not
expanded.
This can cause problems when variable modifiers are used.
.It Ic \&!=
Expand the value and pass it to the shell for execution and assign
the result to the variable.
@ -539,7 +575,7 @@ The name that
.Nm
was executed with
.Pq Va argv[0] .
For compatibily
For compatibility
.Nm
also sets
.Va .MAKE
@ -549,6 +585,35 @@ The preferred variable to use is the environment variable
because it is more compatible with other versions of
.Nm
and cannot be confused with the special target with the same name.
.It Va .MAKE.EXPORTED
The list of variables exported by
.Nm .
.It Va .MAKE.MAKEFILES
The list of makefiles read by
.Nm ,
which is useful for tracking dependencies.
Each makefile is recorded only once, regardless of the number of times read.
.It Va .MAKE.PID
The process-id of
.Nm .
.It Va .MAKE.PPID
The parent process-id of
.Nm .
.It Va .MAKE.JOB.PREFIX
If
.Nm
is run with
.Ar j
then output for each target is prefixed with a token
.Ql --- target ---
the first part of which can be controlled via
.Va .MAKE.JOB.PREFIX .
.br
For example:
.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
would produce tokens like
.Ql ---make[1234] target ---
making it easier to track the degree of parallelism being achieved.
.It Ev MAKEFLAGS
The environment variable
.Ql Ev MAKEFLAGS
@ -692,11 +757,24 @@ Variable expansion may be modified to select or modify each word of the
variable (where a ``word'' is white-space delimited sequence of characters).
The general format of a variable expansion is as follows:
.Pp
.Dl {variable[:modifier[:...]]}
.Dl ${variable[:modifier[:...]]}
.Pp
Each modifier begins with a colon,
which may be escaped with a backslash
.Pq Ql \e .
.Pp
A set of modifiers can be specified via a variable, as follows:
.Pp
.Dl modifier_variable=modifier[:...]
.Dl ${variable:${modifier_variable}[:...]}
.Pp
In this case the first modifier in the modifier_variable does not
start with a colon, since that must appear in the referencing
variable.
If any of the modifiers in the modifier_variable contain a dollar sign
.Pq Ql $ ,
these must be doubled to avoid early expansion.
.Pp
The supported modifiers are:
.Bl -tag -width EEE
.It Cm \&:E
@ -1117,6 +1195,18 @@ Conditional expressions are also preceded by a single dot as the first
character of a line.
The possible conditionals are as follows:
.Bl -tag -width Ds
.It Ic .export Ar variable
Export the specified global variable.
If no variable is provided, all globals are exported
except for internal variables (those that start with
.Ql \&.
).
This is not affected by the
.Fl X
flag, so should be used with caution.
Appending a variable name to
.Va .MAKE.EXPORTED
is equivalent to exporting a variable.
.It Ic .undef Ar variable
Un-define the specified global variable.
Only global variables may be un-defined.
@ -1380,7 +1470,7 @@ option.
.It Ic .PRECIOUS
When
.Nm
is interrupted, it removes any partially made targets.
is interrupted, it normally removes any partially made targets.
This source prevents the target from being removed.
.It Ic .RECURSIVE
Synonym for
@ -1413,8 +1503,30 @@ If
.Ic .WAIT
appears in a dependency line, the sources that precede it are
made before the sources that succeed it in the line.
Loops are not
detected and targets that form loops will be silently ignored.
Since the dependents of files are not made until the file itself
could be made, this also stops the dependents being built unless they
are needed for another branch of the dependency tree.
So given:
.Bd -literal
x: a .WAIT b
echo x
a:
echo a
b: b1
echo b
b1:
echo b1
.Ed
the output is always
.Ql b1 ,
.Ql b ,
.Ql a ,
.Ql x .
.br
The ordering imposed by
.Ic .WAIT
is only relevant for parallel makes.
.El
.Sh SPECIAL TARGETS
Special targets may not be included with other targets, i.e. they must be
@ -1480,6 +1592,20 @@ Synonym for
for compatibility with other pmake variants.
.It Ic .ORDER
The named targets are made in sequence.
This ordering does not add targets to the list of targets to be made.
Since the dependents of a target do not get built until the target itself
could be built, unless
.Ql a
is built by another part of the dependency graph,
the following is a dependency loop:
.Bd -literal
\&.ORDER a b
b: a
.Ed
.Pp
The ordering imposed by
.Ic .ORDER
is only relevant for parallel makes.
.\" XXX: NOT YET!!!!
.\" .It Ic .PARALLEL
.\" The named targets are executed in parallel mode.
@ -1543,13 +1669,16 @@ It is typically identical to
The flag to pass the shell to enable error checking.
.It Ar echoFlag
The flag to pass the shell to enable command echoing.
.It Ar newline
The string literal to pass the shell that results in a single newline
character when used outside of any quoting characters.
.El
Example:
.Bd -literal
\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \\
check="set -e" ignore="set +e" \\
echo="set -v" quiet="set +v" filter="set +v" \\
echoFlag=v errFlag=e
echoFlag=v errFlag=e newline="'\\n'"
.Ed
.It Ic .SILENT
Apply the
@ -1599,6 +1728,14 @@ system makefile
.It /usr/share/mk
system makefile directory
.El
.Sh COMPATIBILITY
The basic make syntax is compatible between different versions of make,
however the special variables, variable modifiers and conditionals are not.
.Pp
The way that parallel makes are scheduled changed in
.Nx 4.0
so that .ORDER and .WAIT apply recursively to the dependant nodes.
The algorithms used may change again in the future.
.Sh SEE ALSO
.Xr mkdep 1
.Sh HISTORY

View file

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: make.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: make.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: make.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: make.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: make.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -112,8 +112,7 @@ __RCSID("$NetBSD: make.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
* Make_HandleUse See if a child is a .USE node for a parent
* and perform the .USE actions if so.
*
* Make_ExpandUse Expand .USE nodes and return the new list of
* targets.
* Make_ExpandUse Expand .USE nodes
*/
#include "make.h"
@ -121,14 +120,12 @@ __RCSID("$NetBSD: make.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
#include "dir.h"
#include "job.h"
static unsigned int checked = 1;/* Sequence # to detect recursion */
static Lst toBeMade; /* The current fringe of the graph. These
* are nodes which await examination by
* MakeOODate. It is added to by
* Make_Update and subtracted from by
* MakeStartJobs */
static int numNodes; /* Number of nodes to be processed. If this
* is non-zero when Job_Empty() returns
* TRUE, there's a cycle in the graph */
static int MakeAddChild(ClientData, ClientData);
static int MakeFindChild(ClientData, ClientData);
@ -138,6 +135,22 @@ static int MakeTimeStamp(ClientData, ClientData);
static int MakeHandleUse(ClientData, ClientData);
static Boolean MakeStartJobs(void);
static int MakePrintStatus(ClientData, ClientData);
static int MakeCheckOrder(ClientData, ClientData);
static int MakeBuildChild(ClientData, ClientData);
static int MakeBuildParent(ClientData, ClientData);
static void
make_abort(GNode *gn, int line)
{
static int two = 2;
fprintf(debug_file, "make_abort from line %d\n", line);
Targ_PrintNode(gn, &two);
Lst_ForEach(toBeMade, Targ_PrintNode, &two);
Targ_PrintGraph(3);
abort();
}
/*-
*-----------------------------------------------------------------------
* Make_TimeStamp --
@ -211,9 +224,9 @@ Make_OODate(GNode *gn)
(void)Dir_MTime(gn);
if (DEBUG(MAKE)) {
if (gn->mtime != 0) {
printf("modified %s...", Targ_FmtTime(gn->mtime));
fprintf(debug_file, "modified %s...", Targ_FmtTime(gn->mtime));
} else {
printf("non-existent...");
fprintf(debug_file, "non-existent...");
}
}
}
@ -238,13 +251,13 @@ Make_OODate(GNode *gn)
* no matter *what*.
*/
if (DEBUG(MAKE)) {
printf(".USE node...");
fprintf(debug_file, ".USE node...");
}
oodate = FALSE;
} else if ((gn->type & OP_LIB) &&
((gn->mtime==0) || Arch_IsLib(gn))) {
if (DEBUG(MAKE)) {
printf("library...");
fprintf(debug_file, "library...");
}
/*
@ -259,10 +272,10 @@ Make_OODate(GNode *gn)
* out-of-date if any of its children was out-of-date.
*/
if (DEBUG(MAKE)) {
printf(".JOIN node...");
fprintf(debug_file, ".JOIN node...");
}
if (DEBUG(MAKE)) {
printf("source %smade...", gn->flags & CHILDMADE ? "" : "not ");
fprintf(debug_file, "source %smade...", gn->flags & CHILDMADE ? "" : "not ");
}
oodate = (gn->flags & CHILDMADE) ? TRUE : FALSE;
} else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
@ -272,11 +285,11 @@ Make_OODate(GNode *gn)
*/
if (DEBUG(MAKE)) {
if (gn->type & OP_FORCE) {
printf("! operator...");
fprintf(debug_file, "! operator...");
} else if (gn->type & OP_PHONY) {
printf(".PHONY node...");
fprintf(debug_file, ".PHONY node...");
} else {
printf(".EXEC node...");
fprintf(debug_file, ".EXEC node...");
}
}
oodate = TRUE;
@ -294,11 +307,11 @@ Make_OODate(GNode *gn)
*/
if (DEBUG(MAKE)) {
if (gn->mtime < gn->cmtime) {
printf("modified before source...");
fprintf(debug_file, "modified before source...");
} else if (gn->mtime == 0) {
printf("non-existent and no sources...");
fprintf(debug_file, "non-existent and no sources...");
} else {
printf(":: operator and no sources...");
fprintf(debug_file, ":: operator and no sources...");
}
}
oodate = TRUE;
@ -312,7 +325,7 @@ Make_OODate(GNode *gn)
*/
if (DEBUG(MAKE)) {
if (gn->flags & FORCE)
printf("non existing child...");
fprintf(debug_file, "non existing child...");
}
oodate = (gn->flags & FORCE) ? TRUE : FALSE;
}
@ -325,7 +338,7 @@ Make_OODate(GNode *gn)
* thinking they're out-of-date.
*/
if (!oodate) {
Lst_ForEach(gn->parents, MakeTimeStamp, (ClientData)gn);
Lst_ForEach(gn->parents, MakeTimeStamp, gn);
}
return (oodate);
@ -355,7 +368,10 @@ MakeAddChild(ClientData gnp, ClientData lp)
Lst l = (Lst) lp;
if ((gn->flags & REMAKE) == 0 && !(gn->type & (OP_USE|OP_USEBEFORE))) {
(void)Lst_EnQueue(l, (ClientData)gn);
if (DEBUG(MAKE))
fprintf(debug_file, "MakeAddChild: need to examine %s%s\n",
gn->name, gn->cohort_num);
(void)Lst_EnQueue(l, gn);
}
return (0);
}
@ -422,7 +438,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
#ifdef DEBUG_SRC
if ((cgn->type & (OP_USE|OP_USEBEFORE|OP_TRANSFORM)) == 0) {
printf("Make_HandleUse: called for plain node %s\n", cgn->name);
fprintf(debug_file, "Make_HandleUse: called for plain node %s\n", cgn->name);
return;
}
#endif
@ -525,7 +541,7 @@ MakeHandleUse(ClientData cgnp, ClientData pgnp)
* children the parent has. This is used by Make_Run to decide
* whether to queue the parent or examine its children...
*/
if ((ln = Lst_Member(pgn->children, (ClientData) cgn)) != NILLNODE) {
if ((ln = Lst_Member(pgn->children, cgn)) != NILLNODE) {
Lst_Remove(pgn->children, ln);
pgn->unmade--;
}
@ -605,17 +621,17 @@ Make_Recheck(GNode *gn)
* the target is made now. Otherwise archives with ... rules
* don't work!
*/
if (NoExecute(gn) ||
(gn->type & OP_SAVE_CMDS) || mtime == 0) {
if (NoExecute(gn) || (gn->type & OP_SAVE_CMDS) ||
(mtime == 0 && !(gn->type & OP_WAIT))) {
if (DEBUG(MAKE)) {
printf(" recheck(%s): update time to now: %s\n",
fprintf(debug_file, " recheck(%s): update time from %s to now\n",
gn->name, Targ_FmtTime(gn->mtime));
}
gn->mtime = now;
}
else {
if (DEBUG(MAKE)) {
printf(" recheck(%s): current update time: %s\n",
fprintf(debug_file, " recheck(%s): current update time: %s\n",
gn->name, Targ_FmtTime(gn->mtime));
}
}
@ -665,10 +681,16 @@ Make_Update(GNode *cgn)
Lst parents;
GNode *centurion;
/* It is save to re-examine any nodes again */
checked++;
cname = Var_Value(TARGET, cgn, &p1);
if (p1)
free(p1);
if (DEBUG(MAKE))
fprintf(debug_file, "Make_Update: %s%s\n", cgn->name, cgn->cohort_num);
/*
* If the child was actually made, see what its modification time is
* now -- some rules won't actually update the file. If the file still
@ -684,27 +706,50 @@ Make_Update(GNode *cgn)
*/
if ((centurion = cgn->centurion) != NULL) {
if (!Lst_IsEmpty(cgn->parents))
Punt("%s: cohort has parents", cgn->name);
Punt("%s%s: cohort has parents", cgn->name, cgn->cohort_num);
centurion->unmade_cohorts -= 1;
if (centurion->unmade_cohorts < 0)
Error("Graph cycles through centurion %s", centurion->name);
parents = centurion->parents;
} else {
centurion = cgn;
parents = cgn->parents;
}
parents = centurion->parents;
/* If this was a .ORDER node, schedule the RHS */
Lst_ForEach(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
/* Now mark all the parents as having one less unmade child */
if (Lst_Open(parents) == SUCCESS) {
while ((ln = Lst_Next(parents)) != NILLNODE) {
pgn = (GNode *)Lst_Datum(ln);
if (mtime == 0)
pgn->flags |= FORCE;
/*
* If the parent has the .MADE attribute, it has already
* been queued on the `toBeMade' list in Make_ExpandUse()
* and its unmade children counter is zero.
*/
if ((pgn->flags & REMAKE) == 0 || (pgn->type & OP_MADE) != 0)
if (DEBUG(MAKE))
fprintf(debug_file, "inspect parent %s%s: flags %x, "
"type %x, made %d, unmade %d ",
pgn->name, pgn->cohort_num, pgn->flags,
pgn->type, pgn->made, pgn->unmade-1);
if (!(pgn->flags & REMAKE)) {
/* This parent isn't needed */
if (DEBUG(MAKE))
fprintf(debug_file, "- not needed\n");
continue;
}
if (mtime == 0 && !(cgn->type & OP_WAIT))
pgn->flags |= FORCE;
/*
* If the parent has the .MADE attribute, its timestamp got
* updated to that of its newest child, and its unmake
* child count got set to zero in Make_ExpandUse().
* However other things might cause us to build one of its
* children - and so we mustn't do any processing here when
* the child build finishes.
*/
if (pgn->type & OP_MADE) {
if (DEBUG(MAKE))
fprintf(debug_file, "- .MADE\n");
continue;
}
if ( ! (cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE))) {
if (cgn->made == MADE)
@ -716,40 +761,60 @@ Make_Update(GNode *cgn)
* A parent must wait for the completion of all instances
* of a `::' dependency.
*/
if (centurion->unmade_cohorts != 0 || centurion->made == UNMADE)
if (centurion->unmade_cohorts != 0 || centurion->made < MADE) {
if (DEBUG(MAKE))
fprintf(debug_file,
"- centurion made %d, %d unmade cohorts\n",
centurion->made, centurion->unmade_cohorts);
continue;
}
/* One more child of this parent is now made */
pgn->unmade -= 1;
if (pgn->unmade == 0) {
/*
* Queue the node up -- any unmade predecessors will
* be dealt with in MakeStartJobs.
*/
(void)Lst_EnQueue(toBeMade, (ClientData)pgn);
} else if (pgn->unmade < 0) {
Error("Graph cycles through %s", pgn->name);
if (pgn->unmade < 0) {
if (DEBUG(MAKE)) {
fprintf(debug_file, "Graph cycles through %s%s\n",
pgn->name, pgn->cohort_num);
Targ_PrintGraph(2);
}
Error("Graph cycles through %s%s", pgn->name, pgn->cohort_num);
}
/* We must always rescan the parents of .WAIT and .ORDER nodes. */
if (pgn->unmade != 0 && !(centurion->type & OP_WAIT)
&& !(centurion->flags & DONE_ORDER)) {
if (DEBUG(MAKE))
fprintf(debug_file, "- unmade children\n");
continue;
}
if (pgn->made != DEFERRED) {
/*
* Either this parent is on a different branch of the tree,
* or it on the RHS of a .WAIT directive
* or it is already on the toBeMade list.
*/
if (DEBUG(MAKE))
fprintf(debug_file, "- not deferred\n");
continue;
}
if (pgn->order_pred
&& Lst_ForEach(pgn->order_pred, MakeCheckOrder, 0)) {
/* A .ORDER rule stops us building this */
continue;
}
if (DEBUG(MAKE)) {
static int two = 2;
fprintf(debug_file, "- %s%s made, schedule %s%s (made %d)\n",
cgn->name, cgn->cohort_num,
pgn->name, pgn->cohort_num, pgn->made);
Targ_PrintNode(pgn, &two);
}
/* Ok, we can schedule the parent again */
pgn->made = REQUESTED;
(void)Lst_EnQueue(toBeMade, pgn);
}
Lst_Close(parents);
}
/*
* Deal with successor nodes. If any is marked for making and has an unmade
* count of 0, has not been made and isn't in the examination queue,
* it means we need to place it in the queue as it restrained itself
* before.
*/
for (ln = Lst_First(centurion->successors); ln != NILLNODE;
ln = Lst_Succ(ln)) {
GNode *succ = (GNode *)Lst_Datum(ln);
if ((succ->flags & REMAKE) != 0 && succ->unmade == 0 &&
succ->made == UNMADE &&
Lst_Member(toBeMade, (ClientData)succ) == NILLNODE)
{
(void)Lst_EnQueue(toBeMade, (ClientData)succ);
}
}
/*
* Set the .PREFIX and .IMPSRC variables for all the implied parents
@ -893,8 +958,8 @@ MakeAddAllSrc(ClientData cgnp, ClientData pgnp)
void
Make_DoAllVar(GNode *gn)
{
Lst_ForEach(gn->children, MakeUnmark, (ClientData) gn);
Lst_ForEach(gn->children, MakeAddAllSrc, (ClientData) gn);
Lst_ForEach(gn->children, MakeUnmark, gn);
Lst_ForEach(gn->children, MakeAddAllSrc, gn);
if (!Var_Exists (OODATE, gn)) {
Var_Set(OODATE, "", gn, 0);
@ -927,63 +992,136 @@ Make_DoAllVar(GNode *gn)
*
*-----------------------------------------------------------------------
*/
static int
MakeCheckOrder(ClientData v_bn, ClientData ignore __unused)
{
GNode *bn = v_bn;
if (bn->made >= MADE || !(bn->flags & REMAKE))
return 0;
if (DEBUG(MAKE))
fprintf(debug_file, "MakeCheckOrder: Waiting for .ORDER node %s%s\n",
bn->name, bn->cohort_num);
return 1;
}
static int
MakeBuildChild(ClientData v_cn, ClientData toBeMade_next)
{
GNode *cn = v_cn;
if (DEBUG(MAKE))
fprintf(debug_file, "MakeBuildChild: inspect %s%s, made %d, type %x\n",
cn->name, cn->cohort_num, cn->made, cn->type);
if (cn->made > DEFERRED)
return 0;
/* If this node is on the RHS of a .ORDER, check LHSs. */
if (cn->order_pred && Lst_ForEach(cn->order_pred, MakeCheckOrder, 0)) {
/* Can't build this (or anything else in this child list) yet */
cn->made = DEFERRED;
return 1;
}
if (DEBUG(MAKE))
fprintf(debug_file, "MakeBuildChild: schedule %s%s\n",
cn->name, cn->cohort_num);
cn->made = REQUESTED;
if (toBeMade_next == NILLNODE)
Lst_AtEnd(toBeMade, cn);
else
Lst_InsertBefore(toBeMade, toBeMade_next, cn);
if (cn->unmade_cohorts != 0)
Lst_ForEach(cn->cohorts, MakeBuildChild, toBeMade_next);
/*
* If this node is a .WAIT node with unmade chlidren
* then don't add the next sibling.
*/
return cn->type & OP_WAIT && cn->unmade > 0;
}
/* When a .ORDER RHS node completes we do this on each LHS */
static int
MakeBuildParent(ClientData v_pn, ClientData toBeMade_next)
{
GNode *pn = v_pn;
if (pn->made != DEFERRED)
return 0;
if (MakeBuildChild(pn, toBeMade_next) == 0) {
/* Mark so that when this node is built we reschedule its parents */
pn->flags |= DONE_ORDER;
}
return 0;
}
static Boolean
MakeStartJobs(void)
{
GNode *gn;
int have_token = 0;
while (!Lst_IsEmpty (toBeMade)) {
gn = (GNode *)Lst_DeQueue(toBeMade);
if (DEBUG(MAKE)) {
printf("Examining %s...", gn->name);
}
/*
* Make sure any and all predecessors that are going to be made,
* have been.
*/
if (!Lst_IsEmpty(gn->preds)) {
LstNode ln;
for (ln = Lst_First(gn->preds); ln != NILLNODE; ln = Lst_Succ(ln)){
GNode *pgn = (GNode *)Lst_Datum(ln);
if ((pgn->flags & REMAKE) &&
(pgn->made == UNMADE || pgn->unmade_cohorts != 0)) {
if (DEBUG(MAKE)) {
printf("predecessor %s not made yet.\n", pgn->name);
}
break;
}
}
/*
* If ln isn't nil, there's a predecessor as yet unmade, so we
* just drop this node on the floor. When the node in question
* has been made, it will notice this node as being ready to
* make but as yet unmade and will place the node on the queue.
*/
if (ln != NILLNODE) {
continue;
}
}
if (!Job_TokenWithdraw()) {
Lst_AtFront(toBeMade, gn);
/* Get token now to avoid cycling job-list when we only have 1 token */
if (!have_token && !Job_TokenWithdraw())
break;
have_token = 1;
gn = (GNode *)Lst_DeQueue(toBeMade);
if (DEBUG(MAKE))
fprintf(debug_file, "Examining %s%s...\n",
gn->name, gn->cohort_num);
if (gn->made != REQUESTED) {
if (DEBUG(MAKE))
fprintf(debug_file, "state %d\n", gn->made);
make_abort(gn, __LINE__);
}
numNodes--;
if (gn->checked == checked) {
/* We've already looked at this node since a job finished... */
if (DEBUG(MAKE))
fprintf(debug_file, "already checked %s%s\n",
gn->name, gn->cohort_num);
gn->made = DEFERRED;
continue;
}
gn->checked = checked;
if (gn->unmade != 0) {
/*
* We can't build this yet, add all unmade children to toBeMade,
* just before the current first element.
*/
gn->made = DEFERRED;
Lst_ForEach(gn->children, MakeBuildChild, Lst_First(toBeMade));
/* and drop this node on the floor */
if (DEBUG(MAKE))
fprintf(debug_file, "dropped %s%s\n", gn->name, gn->cohort_num);
continue;
}
gn->made = BEINGMADE;
if (Make_OODate(gn)) {
if (DEBUG(MAKE)) {
printf("out-of-date\n");
fprintf(debug_file, "out-of-date\n");
}
if (queryFlag) {
return (TRUE);
}
Make_DoAllVar(gn);
Job_Make(gn);
have_token = 0;
} else {
if (DEBUG(MAKE)) {
printf("up-to-date\n");
fprintf(debug_file, "up-to-date\n");
}
gn->made = UPTODATE;
if (gn->type & OP_JOIN) {
@ -995,10 +1133,13 @@ MakeStartJobs(void)
*/
Make_DoAllVar(gn);
}
Job_TokenReturn();
Make_Update(gn);
}
}
if (have_token)
Job_TokenReturn();
return (FALSE);
}
@ -1024,39 +1165,97 @@ MakeStartJobs(void)
*-----------------------------------------------------------------------
*/
static int
MakePrintStatus(ClientData gnp, ClientData cyclep)
MakePrintStatusOrder(ClientData ognp, ClientData gnp)
{
GNode *ogn = ognp;
GNode *gn = gnp;
if (!(ogn->flags & REMAKE) || ogn->made > REQUESTED)
/* not waiting for this one */
return 0;
printf(" `%s%s' has .ORDER dependency against %s%s "
"(made %d, flags %x, type %x)\n",
gn->name, gn->cohort_num,
ogn->name, ogn->cohort_num, ogn->made, ogn->flags, ogn->type);
if (DEBUG(MAKE) && debug_file != stdout)
fprintf(debug_file, " `%s%s' has .ORDER dependency against %s%s "
"(made %d, flags %x, type %x)\n",
gn->name, gn->cohort_num,
ogn->name, ogn->cohort_num, ogn->made, ogn->flags, ogn->type);
return 0;
}
static int
MakePrintStatus(ClientData gnp, ClientData v_errors)
{
GNode *gn = (GNode *)gnp;
Boolean cycle = *(Boolean *)cyclep;
if (gn->made == UPTODATE) {
printf("`%s' is up to date.\n", gn->name);
} else if (gn->unmade != 0) {
if (cycle) {
Boolean t = TRUE;
/*
* If printing cycles and came to one that has unmade children,
* print out the cycle by recursing on its children. Note a
* cycle like:
* a : b
* b : c
* c : b
* will cause this to erroneously complain about a being in
* the cycle, but this is a good approximation.
*/
if (gn->made == CYCLE) {
Error("Graph cycles through `%s'", gn->name);
gn->made = ENDCYCLE;
Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t);
gn->made = UNMADE;
} else if (gn->made != ENDCYCLE) {
gn->made = CYCLE;
Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t);
}
} else {
printf("`%s' not remade because of errors.\n", gn->name);
int *errors = v_errors;
if (gn->flags & DONECYCLE)
/* We've completely processed this node before, don't do it again. */
return 0;
if (gn->unmade == 0) {
gn->flags |= DONECYCLE;
switch (gn->made) {
case UPTODATE:
printf("`%s%s' is up to date.\n", gn->name, gn->cohort_num);
break;
case MADE:
break;
case UNMADE:
case DEFERRED:
case REQUESTED:
case BEINGMADE:
(*errors)++;
printf("`%s%s' was not built (made %d, flags %x, type %x)!\n",
gn->name, gn->cohort_num, gn->made, gn->flags, gn->type);
if (DEBUG(MAKE) && debug_file != stdout)
fprintf(debug_file,
"`%s%s' was not built (made %d, flags %x, type %x)!\n",
gn->name, gn->cohort_num, gn->made, gn->flags, gn->type);
/* Most likely problem is actually caused by .ORDER */
Lst_ForEach(gn->order_pred, MakePrintStatusOrder, gn);
break;
default:
/* Errors - already counted */
printf("`%s%s' not remade because of errors.\n",
gn->name, gn->cohort_num);
if (DEBUG(MAKE) && debug_file != stdout)
fprintf(debug_file, "`%s%s' not remade because of errors.\n",
gn->name, gn->cohort_num);
break;
}
return 0;
}
return (0);
if (DEBUG(MAKE))
fprintf(debug_file, "MakePrintStatus: %s%s has %d unmade children\n",
gn->name, gn->cohort_num, gn->unmade);
/*
* If printing cycles and came to one that has unmade children,
* print out the cycle by recursing on its children.
*/
if (!(gn->flags & CYCLE)) {
/* Fist time we've seen this node, check all children */
gn->flags |= CYCLE;
Lst_ForEach(gn->children, MakePrintStatus, errors);
/* Mark that this node needn't be processed again */
gn->flags |= DONECYCLE;
return 0;
}
/* Only output the error once per node */
gn->flags |= DONECYCLE;
Error("Graph cycles through `%s%s'", gn->name, gn->cohort_num);
if ((*errors)++ > 100)
/* Abandon the whole error report */
return 1;
/* Reporting for our children will give the rest of the loop */
Lst_ForEach(gn->children, MakePrintStatus, errors);
return 0;
}
@ -1068,24 +1267,16 @@ MakePrintStatus(ClientData gnp, ClientData cyclep)
* Input:
* targs the initial list of targets
*
* Results:
* The new list of targets.
*
* Side Effects:
* numNodes is set to the number of elements in the list of targets.
*-----------------------------------------------------------------------
*/
Lst
void
Make_ExpandUse(Lst targs)
{
GNode *gn; /* a temporary pointer */
Lst examine; /* List of targets to examine */
Lst ntargs; /* List of new targets to be made */
ntargs = Lst_Init(FALSE);
examine = Lst_Duplicate(targs, NOCOPY);
numNodes = 0;
/*
* Make an initial downward pass over the graph, marking nodes to be made
@ -1097,63 +1288,174 @@ Make_ExpandUse(Lst targs)
*/
while (!Lst_IsEmpty (examine)) {
gn = (GNode *)Lst_DeQueue(examine);
if (gn->flags & REMAKE)
/* We've looked at this one already */
continue;
gn->flags |= REMAKE;
if (DEBUG(MAKE))
fprintf(debug_file, "Make_ExpandUse: examine %s%s\n",
gn->name, gn->cohort_num);
if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts)) {
/* Append all the 'cohorts' to the list of things to examine */
Lst new;
new = Lst_Duplicate(gn->cohorts, NOCOPY);
Lst_Concat(new, examine, LST_CONCLINK);
examine = new;
}
if ((gn->flags & REMAKE) == 0) {
gn->flags |= REMAKE;
numNodes++;
/*
* Apply any .USE rules before looking for implicit dependencies
* to make sure everything has commands that should...
* Make sure that the TARGET is set, so that we can make
* expansions.
*/
if (gn->type & OP_ARCHV) {
char *eoa, *eon;
eoa = strchr(gn->name, '(');
eon = strchr(gn->name, ')');
if (eoa == NULL || eon == NULL)
continue;
*eoa = '\0';
*eon = '\0';
Var_Set(MEMBER, eoa + 1, gn, 0);
Var_Set(ARCHIVE, gn->name, gn, 0);
*eoa = '(';
*eon = ')';
}
(void)Dir_MTime(gn);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
Lst_ForEach(gn->children, MakeUnmark, (ClientData)gn);
Lst_ForEach(gn->children, MakeHandleUse, (ClientData)gn);
if ((gn->type & OP_MADE) == 0)
Suff_FindDeps(gn);
else {
/* Pretend we made all this node's children */
Lst_ForEach(gn->children, MakeFindChild, (ClientData)gn);
if (gn->unmade != 0)
printf("Warning: %s still has %d unmade children\n",
gn->name, gn->unmade);
}
if (gn->unmade != 0) {
Lst_ForEach(gn->children, MakeAddChild, (ClientData)examine);
} else {
(void)Lst_EnQueue(ntargs, (ClientData)gn);
}
/*
* Apply any .USE rules before looking for implicit dependencies
* to make sure everything has commands that should...
* Make sure that the TARGET is set, so that we can make
* expansions.
*/
if (gn->type & OP_ARCHV) {
char *eoa, *eon;
eoa = strchr(gn->name, '(');
eon = strchr(gn->name, ')');
if (eoa == NULL || eon == NULL)
continue;
*eoa = '\0';
*eon = '\0';
Var_Set(MEMBER, eoa + 1, gn, 0);
Var_Set(ARCHIVE, gn->name, gn, 0);
*eoa = '(';
*eon = ')';
}
(void)Dir_MTime(gn);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
Lst_ForEach(gn->children, MakeUnmark, gn);
Lst_ForEach(gn->children, MakeHandleUse, gn);
if ((gn->type & OP_MADE) == 0)
Suff_FindDeps(gn);
else {
/* Pretend we made all this node's children */
Lst_ForEach(gn->children, MakeFindChild, gn);
if (gn->unmade != 0)
printf("Warning: %s%s still has %d unmade children\n",
gn->name, gn->cohort_num, gn->unmade);
}
if (gn->unmade != 0)
Lst_ForEach(gn->children, MakeAddChild, examine);
}
Lst_Destroy(examine, NOFREE);
}
/*-
*-----------------------------------------------------------------------
* Make_ProcessWait --
* Convert .WAIT nodes into dependencies
*
* Input:
* targs the initial list of targets
*
*-----------------------------------------------------------------------
*/
static int
link_parent(ClientData cnp, ClientData pnp)
{
GNode *cn = cnp;
GNode *pn = pnp;
Lst_AtEnd(pn->children, cn);
Lst_AtEnd(cn->parents, pn);
pn->unmade++;
return 0;
}
static int
add_wait_dep(void *v_cn, void *v_wn)
{
GNode *cn = v_cn;
GNode *wn = v_wn;
if (cn == wn)
return 1;
if (cn == NULL || wn == NULL) {
printf("bad wait dep %p %p\n", cn, wn);
exit(4);
}
if (DEBUG(MAKE))
fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n",
cn->name, cn->cohort_num, wn->name);
Lst_AtEnd(wn->children, cn);
wn->unmade++;
Lst_AtEnd(cn->parents, wn);
return 0;
}
static void
Make_ProcessWait(Lst targs)
{
GNode *pgn; /* 'parent' node we are examining */
GNode *cgn; /* Each child in turn */
LstNode owln; /* Previous .WAIT node */
Lst examine; /* List of targets to examine */
LstNode ln;
/*
* We need all the nodes to have a common parent in order for the
* .WAIT and .ORDER scheduling to work.
* Perhaps this should be done earlier...
*/
pgn = Targ_NewGN(".MAIN");
pgn->flags = REMAKE;
pgn->type = OP_PHONY | OP_DEPENDS;
/* Get it displayed in the diag dumps */
Lst_AtFront(Targ_List(), pgn);
Lst_ForEach(targs, link_parent, pgn);
/* Start building with the 'dummy' .MAIN' node */
MakeBuildChild(pgn, NILLNODE);
examine = Lst_Init(FALSE);
Lst_AtEnd(examine, pgn);
while (!Lst_IsEmpty (examine)) {
pgn = Lst_DeQueue(examine);
/* We only want to process each child-list once */
if (pgn->flags & DONE_WAIT)
continue;
pgn->flags |= DONE_WAIT;
if (DEBUG(MAKE))
fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name);
if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (pgn->cohorts)) {
/* Append all the 'cohorts' to the list of things to examine */
Lst new;
new = Lst_Duplicate(pgn->cohorts, NOCOPY);
Lst_Concat(new, examine, LST_CONCLINK);
examine = new;
}
owln = Lst_First(pgn->children);
Lst_Open(pgn->children);
for (; (ln = Lst_Next(pgn->children)) != NILLNODE; ) {
cgn = Lst_Datum(ln);
if (cgn->type & OP_WAIT) {
/* Make the .WAIT node depend on the previous children */
Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn);
owln = ln;
} else {
Lst_AtEnd(examine, cgn);
}
}
Lst_Close(pgn->children);
}
Lst_Destroy(examine, NOFREE);
return ntargs;
}
/*-
@ -1185,7 +1487,16 @@ Make_Run(Lst targs)
{
int errors; /* Number of errors the Job module reports */
toBeMade = Make_ExpandUse(targs);
/* Start trying to make the current targets... */
toBeMade = Lst_Init(FALSE);
Make_ExpandUse(targs);
Make_ProcessWait(targs);
if (DEBUG(MAKE)) {
fprintf(debug_file, "#***# full graph\n");
Targ_PrintGraph(1);
}
if (queryFlag) {
/*
@ -1194,16 +1505,15 @@ Make_Run(Lst targs)
* to see if any of the targets was out of date)
*/
return (MakeStartJobs());
} else {
/*
* Initialization. At the moment, no jobs are running and until some
* get started, nothing will happen since the remaining upward
* traversal of the graph is performed by the routines in job.c upon
* the finishing of a job. So we fill the Job table as much as we can
* before going into our loop.
*/
(void)MakeStartJobs();
}
/*
* Initialization. At the moment, no jobs are running and until some
* get started, nothing will happen since the remaining upward
* traversal of the graph is performed by the routines in job.c upon
* the finishing of a job. So we fill the Job table as much as we can
* before going into our loop.
*/
(void)MakeStartJobs();
/*
* Main Loop: The idea here is that the ending of jobs will take
@ -1215,9 +1525,8 @@ Make_Run(Lst targs)
* Note that the Job module will exit if there were any errors unless the
* keepgoing flag was given.
*/
while (!Lst_IsEmpty(toBeMade) || !Job_Empty ()) {
while (!Lst_IsEmpty(toBeMade) || jobTokensRunning > 0) {
Job_CatchOutput();
Job_CatchChildren(!usePipes);
(void)MakeStartJobs();
}
@ -1227,8 +1536,15 @@ Make_Run(Lst targs)
* Print the final status of each target. E.g. if it wasn't made
* because some inferior reported an error.
*/
errors = ((errors == 0) && (numNodes != 0));
Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors);
return (TRUE);
if (DEBUG(MAKE))
fprintf(debug_file, "done: errors %d\n", errors);
if (errors == 0) {
Lst_ForEach(targs, MakePrintStatus, &errors);
if (DEBUG(MAKE)) {
fprintf(debug_file, "done: errors %d\n", errors);
if (errors)
Targ_PrintGraph(4);
}
}
return errors != 0;
}

View file

@ -1,4 +1,4 @@
/* $NetBSd: make.h,v 1.53 2005/05/01 01:25:36 christos Exp $ */
/* $NetBSD: make.h,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -145,20 +145,25 @@
* 7) the number of its children that are, as yet, unmade
* 8) its modification time
* 9) the modification time of its youngest child (qv. make.c)
* 10) a list of nodes for which this is a source
* 11) a list of nodes on which this depends
* 10) a list of nodes for which this is a source (parents)
* 11) a list of nodes on which this depends (children)
* 12) a list of nodes that depend on this, as gleaned from the
* transformation rules.
* 13) a list of nodes of the same name created by the :: operator
* 14) a list of nodes that must be made (if they're made) before
* this node can be, but that do no enter into the datedness of
* transformation rules (iParents)
* 13) a list of ancestor nodes, which includes parents, iParents,
* and recursive parents of parents
* 14) a list of nodes of the same name created by the :: operator
* 15) a list of nodes that must be made (if they're made) before
* this node can be, but that do not enter into the datedness of
* this node.
* 15) a list of nodes that must be made (if they're made) after
* 16) a list of nodes that must be made (if they're made) before
* this node or any child of this node can be, but that do not
* enter into the datedness of this node.
* 17) a list of nodes that must be made (if they're made) after
* this node is, but that do not depend on this node, in the
* normal sense.
* 16) a Lst of ``local'' variables that are specific to this target
* 18) a Lst of ``local'' variables that are specific to this target
* and this target only (qv. var.c [$@ $< $?, etc.])
* 17) a Lst of strings that are commands to be given to a shell
* 19) a Lst of strings that are commands to be given to a shell
* to create this target.
*/
typedef struct GNode {
@ -166,34 +171,32 @@ typedef struct GNode {
char *uname; /* The unexpanded name of a .USE node */
char *path; /* The full pathname of the file */
int type; /* Its type (see the OP flags, below) */
int order; /* Its wait weight */
int flags;
#define REMAKE 0x1 /* this target needs to be remade */
#define REMAKE 0x1 /* this target needs to be (re)made */
#define CHILDMADE 0x2 /* children of this target were made */
#define FORCE 0x4 /* children don't exist, and we pretend made */
enum {
UNMADE, BEINGMADE, MADE, UPTODATE, ERROR, ABORTED,
CYCLE, ENDCYCLE
#define DONE_WAIT 0x8 /* Set by Make_ProcessWait() */
#define DONE_ORDER 0x10 /* Build requested by .ORDER processing */
#define FROM_DEPEND 0x20 /* Node created from .depend */
#define CYCLE 0x1000 /* Used by MakePrintStatus */
#define DONECYCLE 0x2000 /* Used by MakePrintStatus */
enum enum_made {
UNMADE, DEFERRED, REQUESTED, BEINGMADE,
MADE, UPTODATE, ERROR, ABORTED
} made; /* Set to reflect the state of processing
* on this node:
* UNMADE - Not examined yet
* DEFERRED - Examined once (building child)
* REQUESTED - on toBeMade list
* BEINGMADE - Target is already being made.
* Indicates a cycle in the graph. (compat
* mode only)
* Indicates a cycle in the graph.
* MADE - Was out-of-date and has been made
* UPTODATE - Was already up-to-date
* ERROR - An error occurred while it was being
* made (used only in compat mode)
* ABORTED - The target was aborted due to
* an error making an inferior (compat).
* CYCLE - Marked as potentially being part of
* a graph cycle. If we come back to a
* node marked this way, it is printed
* and 'made' is changed to ENDCYCLE.
* ENDCYCLE - the cycle has been completely
* printed. Go back and unmark all its
* members.
*/
int unmade; /* The number of unmade children */
@ -206,12 +209,15 @@ typedef struct GNode {
Lst cohorts; /* Other nodes for the :: operator */
Lst parents; /* Nodes that depend on this one */
Lst children; /* Nodes on which this one depends */
Lst successors; /* Nodes that must be made after this one */
Lst preds; /* Nodes that must be made before this one */
Lst order_pred; /* .ORDER nodes we need made */
Lst order_succ; /* .ORDER nodes who need us */
char cohort_num[8]; /* #n for this cohort */
int unmade_cohorts;/* # of unmade instances on the
cohorts list */
struct GNode *centurion; /* Pointer to the first instance of a ::
node; only set when on a cohorts list */
unsigned int checked; /* Last time we tried to makle this node */
Hash_Table context; /* The local variables */
Lst commands; /* Creation commands */
@ -219,7 +225,7 @@ typedef struct GNode {
struct _Suff *suffix; /* Suffix for the node (determined by
* Suff_FindDeps and opaque to everyone
* but the Suff module) */
char *fname; /* filename where the GNode got defined */
const char *fname; /* filename where the GNode got defined */
int lineno; /* line number where the GNode got defined */
} GNode;
@ -272,6 +278,7 @@ typedef struct GNode {
* target' processing in parse.c */
#define OP_PHONY 0x00010000 /* Not a file target; run always */
#define OP_NOPATH 0x00020000 /* Don't search for file in the path */
#define OP_WAIT 0x00040000 /* .WAIT phony node */
/* Attributes applied by PMake */
#define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */
#define OP_MEMBER 0x40000000 /* Target is a member of an archive */
@ -301,19 +308,9 @@ typedef struct GNode {
* table of all targets and its address returned. If TARG_NOCREATE is given,
* a NIL pointer will be returned.
*/
#define TARG_CREATE 0x01 /* create node if not found */
#define TARG_NOCREATE 0x00 /* don't create it */
/*
* There are several places where expandable buffers are used (parse.c and
* var.c). This constant is merely the starting point for those buffers. If
* lines tend to be much shorter than this, it would be best to reduce BSIZE.
* If longer, it should be increased. Reducing it will cause more copying to
* be done for longer lines, but will save space for shorter ones. In any
* case, it ought to be a power of two simply because most storage allocation
* schemes allocate in powers of two.
*/
#define MAKE_BSIZE 256 /* starting size for expandable buffers */
#define TARG_CREATE 0x01 /* create node if not found */
#define TARG_NOHASH 0x02 /* don't look in/add to hash table */
/*
* These constants are all used by the Str_Concat function to decide how the
@ -380,13 +377,10 @@ extern Boolean keepgoing; /* True if should continue on unaffected
* in one portion */
extern Boolean touchFlag; /* TRUE if targets should just be 'touched'
* if out of date. Set by the -t flag */
extern Boolean usePipes; /* TRUE if should capture the output of
* subshells by means of pipes. Otherwise it
* is routed to temporary files from which it
* is retrieved when the shell exits */
extern Boolean queryFlag; /* TRUE if we aren't supposed to really make
* anything, just see if the targets are out-
* of-date */
extern Boolean doing_depend; /* TRUE if processing .depend */
extern Boolean checkEnvFirst; /* TRUE if environment should be searched for
* variables before the global context */
@ -421,12 +415,16 @@ extern char *progname; /* The program name */
#define MAKEFLAGS ".MAKEFLAGS"
#define MAKEOVERRIDES ".MAKEOVERRIDES"
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
#define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */
#define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all the makefiles we read */
/*
* debug control:
* There is one bit per module. It is up to the module what debug
* information to print.
*/
FILE *debug_file; /* Output written here - default stdout */
extern int debug;
#define DEBUG_ARCH 0x0001
#define DEBUG_COND 0x0002
@ -441,8 +439,10 @@ extern int debug;
#define DEBUG_FOR 0x0400
#define DEBUG_SHELL 0x0800
#define DEBUG_ERROR 0x1000
#define DEBUG_GRAPH3 0x10000
#define DEBUG_LOUD 0x2000
#define DEBUG_GRAPH3 0x10000
#define DEBUG_SCRIPT 0x20000
#define DEBUG_PARSE 0x40000
#define CONCAT(a,b) a##b
@ -456,7 +456,7 @@ extern int debug;
int Make_TimeStamp(GNode *, GNode *);
Boolean Make_OODate(GNode *);
Lst Make_ExpandUse(Lst);
void Make_ExpandUse(Lst);
time_t Make_Recheck(GNode *);
void Make_HandleUse(GNode *, GNode *);
void Make_Update(GNode *);

View file

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: nonints.h,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -97,7 +97,8 @@ int Compat_Make(ClientData, ClientData);
/* cond.c */
int Cond_EvalExpression(int, char *, Boolean *, int);
int Cond_Eval(char *);
void Cond_End(void);
void Cond_restore_depth(unsigned int);
unsigned int Cond_save_depth(void);
/* for.c */
int For_Eval(char *);
@ -115,10 +116,16 @@ void Punt(const char *, ...)
void DieHorribly(void) __attribute__((__noreturn__));
int PrintAddr(ClientData, ClientData);
void Finish(int);
#ifndef HAVE_EMALLOC
char *estrdup(const char *);
char *strndup(const char *, size_t);
char *estrndup(const char *, size_t);
void *emalloc(size_t);
void *erealloc(void *, size_t);
void enomem(void);
#else
#include <util.h>
#endif
int eunlink(const char *);
void execError(const char *, const char *);
@ -129,10 +136,10 @@ Boolean Parse_AnyExport(void);
Boolean Parse_IsVar(char *);
void Parse_DoVar(char *, GNode *);
void Parse_AddIncludeDir(char *);
void Parse_File(const char *, FILE *);
void Parse_File(const char *, int);
void Parse_Init(void);
void Parse_End(void);
void Parse_FromString(char *, int);
void Parse_SetInput(const char *, int, int, char *);
Lst Parse_MainName(void);
/* str.c */
@ -172,10 +179,12 @@ Boolean Targ_Silent(GNode *);
Boolean Targ_Precious(GNode *);
void Targ_SetMain(GNode *);
int Targ_PrintCmd(ClientData, ClientData);
int Targ_PrintNode(ClientData, ClientData);
char *Targ_FmtTime(time_t);
void Targ_PrintType(int);
void Targ_PrintGraph(int);
void Targ_Propagate(void);
void Targ_Propagate_Wait(void);
/* var.c */
void Var_Delete(const char *, GNode *);
@ -183,10 +192,12 @@ void Var_Set(const char *, const char *, GNode *, int);
void Var_Append(const char *, const char *, GNode *);
Boolean Var_Exists(const char *, GNode *);
char *Var_Value(const char *, GNode *, char **);
char *Var_Parse(const char *, GNode *, Boolean, int *, Boolean *);
char *Var_Parse(const char *, GNode *, Boolean, int *, void **);
char *Var_Subst(const char *, const char *, GNode *, Boolean);
char *Var_GetTail(const char *);
char *Var_GetHead(const char *);
void Var_Init(void);
void Var_End(void);
void Var_Dump(GNode *);
void Var_ExportVars(void);
void Var_Export(char *, int);

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $NetBSD: str.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: str.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: str.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: str.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
__RCSID("$NetBSD: str.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: str.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -128,8 +128,14 @@ str_concat(const char *s1, const char *s2, int flags)
* spaces) taking quotation marks into account. Leading tabs/spaces
* are ignored.
*
* If expand is TRUE, quotes are removed and escape sequences
* such as \r, \t, etc... are expanded.
*
* returns --
* Pointer to the array of pointers to the words.
* Memory containing the actual words in *buffer.
* Both of these must be free'd by the caller.
* Number of words in *store_argc.
*/
char **
brk_string(const char *str, int *store_argc, Boolean expand, char **buffer)
@ -170,6 +176,8 @@ brk_string(const char *str, int *store_argc, Boolean expand, char **buffer)
/* Don't miss "" or '' */
if (start == NULL && p[1] == inquote) {
start = t + 1;
p++;
inquote = '\0';
break;
}
}
@ -211,6 +219,8 @@ brk_string(const char *str, int *store_argc, Boolean expand, char **buffer)
if (!start)
start = t;
*t++ = '\\';
if (*(p+1) == '\0') // catch '\' at end of line
continue;
ch = *++p;
break;
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: targ.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: targ.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: targ.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: targ.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: targ.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -118,6 +118,11 @@ __RCSID("$NetBSD: targ.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
* Targ_Precious Return TRUE if the target is precious and
* should not be removed if we are interrupted.
*
* Targ_Propagate Propagate information between related
* nodes. Should be called after the
* makefiles are parsed but before any
* action is taken.
*
* Debugging:
* Targ_PrintGraph Print out the entire graphm all variables
* and statistics for the directory cache. Should
@ -141,7 +146,6 @@ static Hash_Table targets; /* a hash table of same */
static int TargPrintOnlySrc(ClientData, ClientData);
static int TargPrintName(ClientData, ClientData);
static int TargPrintNode(ClientData, ClientData);
#ifdef CLEANUP
static void TargFreeGN(ClientData);
#endif
@ -240,17 +244,18 @@ Targ_NewGN(const char *name)
}
gn->unmade = 0;
gn->unmade_cohorts = 0;
gn->cohort_num[0] = 0;
gn->centurion = NULL;
gn->made = UNMADE;
gn->flags = 0;
gn->order = 0;
gn->checked = 0;
gn->mtime = gn->cmtime = 0;
gn->iParents = Lst_Init(FALSE);
gn->cohorts = Lst_Init(FALSE);
gn->parents = Lst_Init(FALSE);
gn->children = Lst_Init(FALSE);
gn->successors = Lst_Init(FALSE);
gn->preds = Lst_Init(FALSE);
gn->order_pred = Lst_Init(FALSE);
gn->order_succ = Lst_Init(FALSE);
Hash_InitTable(&gn->context, 0);
gn->commands = Lst_Init(FALSE);
gn->suffix = NULL;
@ -260,7 +265,7 @@ Targ_NewGN(const char *name)
#ifdef CLEANUP
if (allGNs == NULL)
allGNs = Lst_Init(FALSE);
Lst_AtEnd(allGNs, (ClientData) gn);
Lst_AtEnd(allGNs, gn);
#endif
return (gn);
@ -290,15 +295,14 @@ TargFreeGN(ClientData gnp)
free(gn->uname);
if (gn->path)
free(gn->path);
if (gn->fname)
free(gn->fname);
/* gn->fname points to name allocated when file was opened, don't free */
Lst_Destroy(gn->iParents, NOFREE);
Lst_Destroy(gn->cohorts, NOFREE);
Lst_Destroy(gn->parents, NOFREE);
Lst_Destroy(gn->children, NOFREE);
Lst_Destroy(gn->successors, NOFREE);
Lst_Destroy(gn->preds, NOFREE);
Lst_Destroy(gn->order_succ, NOFREE);
Lst_Destroy(gn->order_pred, NOFREE);
Hash_DeleteTable(&gn->context);
Lst_Destroy(gn->commands, NOFREE);
free(gn);
@ -329,28 +333,31 @@ GNode *
Targ_FindNode(const char *name, int flags)
{
GNode *gn; /* node in that element */
Hash_Entry *he; /* New or used hash entry for node */
Hash_Entry *he = NULL; /* New or used hash entry for node */
Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */
/* an entry for the node */
if (flags & TARG_CREATE) {
he = Hash_CreateEntry(&targets, name, &isNew);
if (isNew) {
gn = Targ_NewGN(name);
Hash_SetValue(he, gn);
Var_Append(".ALLTARGETS", name, VAR_GLOBAL);
(void)Lst_AtEnd(allTargets, (ClientData)gn);
}
} else {
if (!(flags & (TARG_CREATE | TARG_NOHASH))) {
he = Hash_FindEntry(&targets, name);
if (he == NULL)
return (NILGNODE);
return (GNode *)Hash_GetValue(he);
}
if (he == NULL) {
return (NILGNODE);
} else {
return ((GNode *)Hash_GetValue(he));
if (!(flags & TARG_NOHASH)) {
he = Hash_CreateEntry(&targets, name, &isNew);
if (!isNew)
return (GNode *)Hash_GetValue(he);
}
gn = Targ_NewGN(name);
if (!(flags & TARG_NOHASH))
Hash_SetValue(he, gn);
Var_Append(".ALLTARGETS", name, VAR_GLOBAL);
(void)Lst_AtEnd(allTargets, gn);
if (doing_depend)
gn->flags |= FROM_DEPEND;
return gn;
}
/*-
@ -394,7 +401,7 @@ Targ_FindList(Lst names, int flags)
* are added to the list in the order in which they were
* encountered in the makefile.
*/
(void)Lst_AtEnd(nodes, (ClientData)gn);
(void)Lst_AtEnd(nodes, gn);
} else if (flags == TARG_NOCREATE) {
Error("\"%s\" -- target unknown.", name);
}
@ -504,28 +511,20 @@ Targ_SetMain(GNode *gn)
}
static int
TargPrintName(ClientData gnp, ClientData ppath)
TargPrintName(ClientData gnp, ClientData pflags __unused)
{
GNode *gn = (GNode *)gnp;
printf("%s ", gn->name);
#ifdef notdef
if (ppath) {
if (gn->path) {
printf("[%s] ", gn->path);
}
if (gn == mainTarg) {
printf("(MAIN NAME) ");
}
}
#endif /* notdef */
return (ppath ? 0 : 0);
fprintf(debug_file, "%s%s ", gn->name, gn->cohort_num);
return 0;
}
int
Targ_PrintCmd(ClientData cmd, ClientData dummy)
{
printf("\t%s\n", (char *)cmd);
fprintf(debug_file, "\t%s\n", (char *)cmd);
return (dummy ? 0 : 0);
}
@ -571,8 +570,8 @@ Targ_PrintType(int type)
{
int tbit;
#define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break
#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG))printf("." #attr " "); break
#define PRINTBIT(attr) case CONCAT(OP_,attr): fprintf(debug_file, "." #attr " "); break
#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG))fprintf(debug_file, "." #attr " "); break
type &= ~OP_OPMASK;
@ -593,7 +592,7 @@ Targ_PrintType(int type)
PRINTBIT(NOTMAIN);
PRINTDBIT(LIB);
/*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
case OP_MEMBER: if (DEBUG(TARG))printf(".MEMBER "); break;
case OP_MEMBER: if (DEBUG(TARG))fprintf(debug_file, ".MEMBER "); break;
PRINTDBIT(ARCHV);
PRINTDBIT(MADE);
PRINTDBIT(PHONY);
@ -601,74 +600,103 @@ Targ_PrintType(int type)
}
}
static const char *
made_name(enum enum_made made)
{
switch (made) {
case UNMADE: return "unmade";
case DEFERRED: return "deferred";
case REQUESTED: return "requested";
case BEINGMADE: return "being made";
case MADE: return "made";
case UPTODATE: return "up-to-date";
case ERROR: return "error when made";
case ABORTED: return "aborted";
default: return "unknown enum_made value";
}
}
/*-
*-----------------------------------------------------------------------
* TargPrintNode --
* print the contents of a node
*-----------------------------------------------------------------------
*/
static int
TargPrintNode(ClientData gnp, ClientData passp)
int
Targ_PrintNode(ClientData gnp, ClientData passp)
{
GNode *gn = (GNode *)gnp;
int pass = *(int *)passp;
int pass = passp ? *(int *)passp : 0;
fprintf(debug_file, "# %s%s, flags %x, type %x, made %d\n",
gn->name, gn->cohort_num, gn->flags, gn->type, gn->made);
if (gn->flags == 0)
return 0;
if (!OP_NOP(gn->type)) {
printf("#\n");
fprintf(debug_file, "#\n");
if (gn == mainTarg) {
printf("# *** MAIN TARGET ***\n");
fprintf(debug_file, "# *** MAIN TARGET ***\n");
}
if (pass == 2) {
if (pass >= 2) {
if (gn->unmade) {
printf("# %d unmade children\n", gn->unmade);
fprintf(debug_file, "# %d unmade children\n", gn->unmade);
} else {
printf("# No unmade children\n");
fprintf(debug_file, "# No unmade children\n");
}
if (! (gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC))) {
if (gn->mtime != 0) {
printf("# last modified %s: %s\n",
fprintf(debug_file, "# last modified %s: %s\n",
Targ_FmtTime(gn->mtime),
(gn->made == UNMADE ? "unmade" :
(gn->made == MADE ? "made" :
(gn->made == UPTODATE ? "up-to-date" :
"error when made"))));
made_name(gn->made));
} else if (gn->made != UNMADE) {
printf("# non-existent (maybe): %s\n",
(gn->made == MADE ? "made" :
(gn->made == UPTODATE ? "up-to-date" :
(gn->made == ERROR ? "error when made" :
"aborted"))));
fprintf(debug_file, "# non-existent (maybe): %s\n",
made_name(gn->made));
} else {
printf("# unmade\n");
fprintf(debug_file, "# unmade\n");
}
}
if (!Lst_IsEmpty (gn->iParents)) {
printf("# implicit parents: ");
Lst_ForEach(gn->iParents, TargPrintName, (ClientData)0);
fputc('\n', stdout);
fprintf(debug_file, "# implicit parents: ");
Lst_ForEach(gn->iParents, TargPrintName, NULL);
fprintf(debug_file, "\n");
}
} else {
if (gn->unmade)
fprintf(debug_file, "# %d unmade children\n", gn->unmade);
}
if (!Lst_IsEmpty (gn->parents)) {
printf("# parents: ");
Lst_ForEach(gn->parents, TargPrintName, (ClientData)0);
fputc('\n', stdout);
fprintf(debug_file, "# parents: ");
Lst_ForEach(gn->parents, TargPrintName, NULL);
fprintf(debug_file, "\n");
}
if (!Lst_IsEmpty (gn->order_pred)) {
fprintf(debug_file, "# order_pred: ");
Lst_ForEach(gn->order_pred, TargPrintName, NULL);
fprintf(debug_file, "\n");
}
if (!Lst_IsEmpty (gn->order_succ)) {
fprintf(debug_file, "# order_succ: ");
Lst_ForEach(gn->order_succ, TargPrintName, NULL);
fprintf(debug_file, "\n");
}
printf("%-16s", gn->name);
fprintf(debug_file, "%-16s", gn->name);
switch (gn->type & OP_OPMASK) {
case OP_DEPENDS:
printf(": "); break;
fprintf(debug_file, ": "); break;
case OP_FORCE:
printf("! "); break;
fprintf(debug_file, "! "); break;
case OP_DOUBLEDEP:
printf(":: "); break;
fprintf(debug_file, ":: "); break;
}
Targ_PrintType(gn->type);
Lst_ForEach(gn->children, TargPrintName, (ClientData)0);
fputc('\n', stdout);
Lst_ForEach(gn->commands, Targ_PrintCmd, (ClientData)0);
printf("\n\n");
Lst_ForEach(gn->children, TargPrintName, NULL);
fprintf(debug_file, "\n");
Lst_ForEach(gn->commands, Targ_PrintCmd, NULL);
fprintf(debug_file, "\n\n");
if (gn->type & OP_DOUBLEDEP) {
Lst_ForEach(gn->cohorts, TargPrintNode, (ClientData)&pass);
Lst_ForEach(gn->cohorts, Targ_PrintNode, &pass);
}
}
return (0);
@ -688,13 +716,18 @@ TargPrintNode(ClientData gnp, ClientData passp)
*-----------------------------------------------------------------------
*/
static int
TargPrintOnlySrc(ClientData gnp, ClientData dummy)
TargPrintOnlySrc(ClientData gnp, ClientData dummy __unused)
{
GNode *gn = (GNode *)gnp;
if (OP_NOP(gn->type))
printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
if (!OP_NOP(gn->type))
return 0;
return (dummy ? 0 : 0);
fprintf(debug_file, "#\t%s [%s] ",
gn->name, gn->path ? gn->path : gn->name);
Targ_PrintType(gn->type);
fprintf(debug_file, "\n");
return 0;
}
/*-
@ -716,21 +749,73 @@ TargPrintOnlySrc(ClientData gnp, ClientData dummy)
void
Targ_PrintGraph(int pass)
{
printf("#*** Input graph:\n");
Lst_ForEach(allTargets, TargPrintNode, (ClientData)&pass);
printf("\n\n");
printf("#\n# Files that are only sources:\n");
Lst_ForEach(allTargets, TargPrintOnlySrc, (ClientData) 0);
printf("#*** Global Variables:\n");
fprintf(debug_file, "#*** Input graph:\n");
Lst_ForEach(allTargets, Targ_PrintNode, &pass);
fprintf(debug_file, "\n\n");
fprintf(debug_file, "#\n# Files that are only sources:\n");
Lst_ForEach(allTargets, TargPrintOnlySrc, NULL);
fprintf(debug_file, "#*** Global Variables:\n");
Var_Dump(VAR_GLOBAL);
printf("#*** Command-line Variables:\n");
fprintf(debug_file, "#*** Command-line Variables:\n");
Var_Dump(VAR_CMD);
printf("\n");
fprintf(debug_file, "\n");
Dir_PrintDirectories();
printf("\n");
fprintf(debug_file, "\n");
Suff_PrintAll();
}
/*-
*-----------------------------------------------------------------------
* TargPropagateNode --
* Propagate information from a single node to related nodes if
* appropriate.
*
* Input:
* gnp The node that we are processing.
*
* Results:
* Always returns 0, for the benefit of Lst_ForEach().
*
* Side Effects:
* Information is propagated from this node to cohort or child
* nodes.
*
* If the node was defined with "::", then TargPropagateCohort()
* will be called for each cohort node.
*
* If the node has recursive predecessors, then
* TargPropagateRecpred() will be called for each recursive
* predecessor.
*-----------------------------------------------------------------------
*/
static int
TargPropagateNode(ClientData gnp, ClientData junk __unused)
{
GNode *gn = (GNode *)gnp;
if (gn->type & OP_DOUBLEDEP)
Lst_ForEach(gn->cohorts, TargPropagateCohort, gnp);
return (0);
}
/*-
*-----------------------------------------------------------------------
* TargPropagateCohort --
* Propagate some bits in the type mask from a node to
* a related cohort node.
*
* Input:
* cnp The node that we are processing.
* gnp Another node that has cnp as a cohort.
*
* Results:
* Always returns 0, for the benefit of Lst_ForEach().
*
* Side Effects:
* cnp's type bitmask is modified to incorporate some of the
* bits from gnp's type bitmask. (XXX need a better explanation.)
*-----------------------------------------------------------------------
*/
static int
TargPropagateCohort(ClientData cgnp, ClientData pgnp)
{
@ -741,17 +826,22 @@ TargPropagateCohort(ClientData cgnp, ClientData pgnp)
return (0);
}
static int
TargPropagateNode(ClientData gnp, ClientData junk __unused)
{
GNode *gn = (GNode *)gnp;
if (gn->type & OP_DOUBLEDEP)
Lst_ForEach(gn->cohorts, TargPropagateCohort, gnp);
return (0);
}
/*-
*-----------------------------------------------------------------------
* Targ_Propagate --
* Propagate information between related nodes. Should be called
* after the makefiles are parsed but before any action is taken.
*
* Results:
* none
*
* Side Effects:
* Information is propagated between related nodes throughout the
* graph.
*-----------------------------------------------------------------------
*/
void
Targ_Propagate(void)
{
Lst_ForEach(allTargets, TargPropagateNode, (ClientData)0);
Lst_ForEach(allTargets, TargPropagateNode, NULL);
}

View file

@ -1,4 +1,4 @@
/* $NetBSD: trace.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: trace.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -38,11 +38,11 @@
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: trace.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: trace.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trace.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: trace.c,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $");
#endif /* not lint */
#endif
@ -103,9 +103,9 @@ Trace_Log(TrEvent event, Job *job)
gettimeofday(&rightnow, NULL);
fprintf(trfile, "%ld.%06d %d %d %s %d %s",
fprintf(trfile, "%ld.%06d %d %s %d %s",
rightnow.tv_sec, (int)rightnow.tv_usec,
jobTokensRunning, jobTokensFree,
jobTokensRunning,
evname[event], trpid, trwd);
if (job != NULL) {
fprintf(trfile, " %s %d %x %x", job->node->name,

View file

@ -1,4 +1,4 @@
/* $NetBSD: trace.h,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: trace.h,v 1.1.1.2 2008/03/09 19:39:33 joerg Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.

View file

@ -1,6 +1,6 @@
# $Id: Makefile.in,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $
# $Id: Makefile.in,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $
#
# $NetBSD: Makefile.in,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $
# $NetBSD: Makefile.in,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $
#
# Unit tests for make(1)
# The main targets are:
@ -25,7 +25,12 @@ UNIT_TESTS:= ${srcdir}
SUBFILES= \
comment \
cond1 \
export \
export-all \
dotwait \
moderrs \
modmatch \
modmisc \
modorder \
modts \
modword \
@ -37,6 +42,7 @@ all: ${SUBFILES}
# the tests are actually done with sub-makes.
.PHONY: ${SUBFILES}
.PRECIOUS: ${SUBFILES}
${SUBFILES}:
-@${.MAKE} -k -f ${UNIT_TESTS}/$@
@ -55,10 +61,10 @@ TEST_MAKE?= ${.MAKE}
test:
@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
sed -e 's,^${TEST_MAKE:T}:,make:,' \
sed -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
-e '/stopped/s, /.*, unit-tests,' \
-e 's,${.CURDIR}/,,g' \
-e 's,${UNIT_TESTS}/,,g' > ${.TARGET}.out || { \
-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
diff @diff_u@ ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out

View file

@ -0,0 +1,61 @@
# $NetBSD: dotwait,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $
THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE}
TESTS= simple recursive shared cycle
PAUSE= sleep 1
# Use a .for loop rather than dependencies here, to ensure
# that the tests are run one by one, with parallelism
# only within tests.
# Ignore "--- target ---" lines printed by parallel make.
all:
.for t in ${TESTS}
@${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- "
.endfor
#
# Within each test, the names of the sub-targets follow these
# conventions:
# * If it's expected that two or more targets may be made in parallel,
# then the target names will differ only in an alphabetic component
# such as ".a" or ".b".
# * If it's expected that two or more targets should be made in sequence
# then the target names will differ in numeric components, such that
# lexical ordering of the target names matches the expected order
# in which the targets should be made.
#
# Targets may echo ${PARALLEL_TARG} to print a modified version
# of their own name, in which alphabetic components like ".a" or ".b"
# are converted to ".*". Two targets that are expected to
# be made in parallel will thus print the same strings, so that the
# output is independent of the order in which these targets are made.
#
PARALLEL_TARG= ${.TARGET:C/\.[a-z]/.*/g:Q}
.DEFAULT:
@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
_ECHOUSE: .USE
@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
# simple: no recursion, no cycles
simple: simple.1 .WAIT simple.2
# recursive: all children of the left hand side of the .WAIT
# must be made before any child of the right hand side.
recursive: recursive.1.99 .WAIT recursive.2.99
recursive.1.99: recursive.1.1.a recursive.1.1.b _ECHOUSE
recursive.2.99: recursive.2.1.a recursive.2.1.b _ECHOUSE
# shared: both shared.1.99 and shared.2.99 depend on shared.0.
# shared.0 must be made first, even though it is a child of
# the right hand side of the .WAIT.
shared: shared.1.99 .WAIT shared.2.99
shared.1.99: shared.0 _ECHOUSE
shared.2.99: shared.2.1 shared.0 _ECHOUSE
# cycle: the cyclic dependency must not cause infinite recursion
# leading to stack overflow and a crash.
cycle: cycle.1.99 .WAIT cycle.2.99
cycle.2.99: cycle.2.98 _ECHOUSE
cycle.2.98: cycle.2.97 _ECHOUSE
cycle.2.97: cycle.2.99 _ECHOUSE

View file

@ -0,0 +1,22 @@
# $Id: export,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $
UT_TEST=export
UT_FOO=foo${BAR}
UT_FU=fubar
UT_ZOO=hoopie
UT_NO=all
# belive it or not, we expect this one to come out with $UT_FU unexpanded.
UT_DOLLAR= This is $$UT_FU
.export UT_FU UT_FOO
.export UT_DOLLAR
# this one will be ignored
.export .MAKE.PID
BAR=bar is ${UT_FU}
.MAKE.EXPORTED+= UT_ZOO UT_TEST
all:
@env | grep '^UT_' | sort

View file

@ -0,0 +1,11 @@
# $Id: export-all,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $
UT_OK=good
UT_F=fine
.export
.include "export"
UT_TEST=export-all
UT_ALL=even this gets exported

View file

@ -0,0 +1,31 @@
# $Id: moderrs,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $
#
# various modifier error tests
VAR=TheVariable
# incase we have to change it ;-)
MOD_UNKN=Z
MOD_TERM=S,V,v
MOD_S:= ${MOD_TERM},
all: modunkn modunknV varterm vartermV modtermV
modunkn:
@echo "Expect: Unknown modifier 'Z'"
@echo "VAR:Z=${VAR:Z}"
modunknV:
@echo "Expect: Unknown modifier 'Z'"
@echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}"
varterm:
@echo "Expect: Unclosed variable specification for VAR"
@echo VAR:S,V,v,=${VAR:S,V,v,
vartermV:
@echo "Expect: Unclosed variable specification for VAR"
@echo VAR:${MOD_TERM},=${VAR:${MOD_S}
modtermV:
@echo "Expect: Unclosed substitution for VAR (, missing)"
-@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"

View file

@ -0,0 +1,33 @@
# $Id: modmisc,v 1.1.1.1 2008/03/09 19:39:35 joerg Exp $
#
# miscellaneous modifier tests
path=:/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:.
# strip cwd from path.
MOD_NODOT=S/:/ /g:N.:ts:
# and decorate, note that $'s need to be doubled. Also note that
# the modifier_variable can be used with other modifiers.
MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@
# another mod - pretend it is more interesting
MOD_HOMES=S,/home/,/homes/,
MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
MOD_SEP=S,:, ,g
all: modvar modvarloop
modvar:
@echo "path='${path}'"
@echo "path='${path:${MOD_NODOT}}'"
@echo "path='${path:S,home,homes,:${MOD_NODOT}}'"
@echo "path=${path:${MOD_NODOTX}:ts:}"
@echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}"
.for d in ${path:${MOD_SEP}:N.} /usr/xbin
path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/
paths+= ${d:${MOD_OPT}:${MOD_HOMES}}
.endfor
modvarloop:
@echo "path_/usr/xbin=${path_/usr/xbin}"
@echo "paths=${paths}"
@echo "PATHS=${paths:tu}"

View file

@ -1,6 +1,6 @@
# $NetBSD: modorder,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $
# $NetBSD: modorder,v 1.1.1.2 2008/03/09 19:39:35 joerg Exp $
LIST= one two three four five six seven eigth nine ten
LIST= one two three four five six seven eight nine ten
LISTX= ${LIST:Ox}
LISTSX:= ${LIST:Ox}
TEST_RESULT= && echo Ok || echo Failed

View file

@ -20,6 +20,64 @@ Passed:
4 is not prime
5 is prime
UT_DOLLAR=This is $UT_FU
UT_FOO=foobar is fubar
UT_FU=fubar
UT_TEST=export
UT_ZOO=hoopie
UT_ALL=even this gets exported
UT_DOLLAR=This is $UT_FU
UT_F=fine
UT_FOO=foobar is fubar
UT_FU=fubar
UT_NO=all
UT_OK=good
UT_TEST=export-all
UT_ZOO=hoopie
simple.1
simple.1
simple.2
simple.2
recursive.1.1.*
recursive.1.1.*
recursive.1.1.*
recursive.1.1.*
recursive.1.99
recursive.1.99
recursive.2.1.*
recursive.2.1.*
recursive.2.1.*
recursive.2.1.*
recursive.2.99
recursive.2.99
shared.0
shared.0
shared.1.99
shared.1.99
shared.2.1
shared.2.1
shared.2.99
shared.2.99
make: Graph cycles through `cycle.2.99'
make: Graph cycles through `cycle.2.98'
make: Graph cycles through `cycle.2.97'
cycle.1.99
cycle.1.99
Expect: Unknown modifier 'Z'
make: Unknown modifier 'Z'
VAR:Z=
Expect: Unknown modifier 'Z'
make: Unknown modifier 'Z'
VAR:Z=
Expect: Unclosed variable specification for VAR
make: Unclosed variable specification for VAR
VAR:S,V,v,=Thevariable
Expect: Unclosed variable specification for VAR
make: Unclosed variable specification for VAR
VAR:S,V,v,=Thevariable
Expect: Unclosed substitution for VAR (, missing)
make: Unclosed substitution for VAR (, missing)
VAR:S,V,v=
LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a"
LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a"
LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A"
@ -35,12 +93,16 @@ LIB=d X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBD.A"
LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a"
LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a"
LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
LIST = one two three four five six seven eigth nine ten
LIST:O = eigth five four nine one seven six ten three two
# Note that 1 in every 10! trials two independently generated
# randomized orderings will be the same. The test framework doesn't
# support checking probabilistic output, so we accept that the test
# will incorrectly fail with probability 2.8E-7.
path=':/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:.'
path='/bin:/usr/bin:/sbin:/usr/sbin:/home/user/bin'
path='/bin:/usr/bin:/sbin:/usr/sbin:/homes/user/bin'
path='/bin':'/usr/bin':'/sbin':'/usr/sbin':'/home/user/bin'
path='/bin':'/usr/bin':'/sbin':'/usr/sbin':'/homes/user/bin'
path_/usr/xbin=/opt/xbin/
paths=/bin /usr/bin /sbin /usr/sbin /homes/user/bin /opt/xbin
PATHS=/BIN /USR/BIN /SBIN /USR/SBIN /HOMES/USER/BIN /OPT/XBIN
LIST = one two three four five six seven eight nine ten
LIST:O = eight five four nine one seven six ten three two
LIST:Ox = Ok
LIST:O:Ox = Ok
LISTX = Ok

View file

@ -1,18 +1,18 @@
/* $NetBSD: util.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $ */
/* $NetBSD: util.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $ */
/*
* Missing stuff from OS's
*
* $Id: util.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $
* $Id: util.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $
*/
#include "make.h"
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: util.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $";
static char rcsid[] = "$NetBSD: util.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $";
#else
#ifndef lint
__RCSID("$NetBSD: util.c,v 1.1.1.1 2005/12/02 00:03:00 sjg Exp $");
__RCSID("$NetBSD: util.c,v 1.1.1.2 2008/03/09 19:39:34 joerg Exp $");
#endif
#endif
@ -59,6 +59,33 @@ strdup(const char *str)
}
#endif
#if !defined(HAVE_EMALLOC) && !defined(HAVE_STRNDUP)
#include <string.h>
/* strndup
*
* Make a duplicate of a string, up to a maximum length.
* For systems which lack this function.
*/
char *
strndup(const char *str, size_t maxlen)
{
size_t len;
char *p;
if (str == NULL)
return NULL;
len = strlen(str);
if (len > maxlen)
len = maxlen;
p = emalloc(len + 1);
memcpy(p, str, len);
p[len] = '\0';
return p;
}
#endif
#if !defined(HAVE_SETENV)
int
setenv(const char *name, const char *value, int dum)
@ -90,6 +117,14 @@ setenv(const char *name, const char *value, int dum)
}
#endif
#if !defined(HAVE_UNSETENV)
int
unsetenv(const char *name)
{
return -1; /* XXX not worth it? */
}
#endif
#if defined(__hpux__) || defined(__hpux)
/* strrcpy():
* Like strcpy, going backwards and returning the new pointer
@ -145,14 +180,11 @@ char *sys_siglist[] = {
#if defined(__hpux__) || defined(__hpux)
#include <sys/types.h>
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/signal.h>
#include <sys/stat.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
int
@ -510,3 +542,13 @@ strftime(char *buf, size_t len, const char *fmt, const struct tm *tm)
}
}
#endif
#if !defined(HAVE_KILLPG)
#if !defined(__hpux__) && !defined(__hpux)
int
killpg(int pid, int sig)
{
return kill(-pid, sig);
}
#endif
#endif