MFH: r280643-r281852

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Glen Barber 2015-04-22 12:58:16 +00:00
commit 7263c8c099
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/release-arm-redux/; revision=281853
4093 changed files with 868549 additions and 248200 deletions

View File

@ -1,5 +1,4 @@
{
"project.name": "S",
"phabricator.uri" : "https://reviews.freebsd.org/",
"history.immutable" : true
"phabricator.uri" : "https://reviews.freebsd.org/"
}

View File

@ -1,9 +1,25 @@
{
"exclude": "(contrib|crypto)",
"linters": {
"python": {
"type": "pep8",
"exclude": "(contrib)",
"include": "(\\.py$)"
},
"spelling": {
"type": "spelling"
},
"chmod": {
"type": "chmod"
},
"merge-conflict": {
"type": "merge-conflict"
},
"filename": {
"type": "filename"
},
"json": {
"type": "json",
"include": "(\\.arclint|\\.json$)"
}
}
}

View File

@ -374,6 +374,17 @@ kernel-toolchains:
#
.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
TARGETS?=amd64 arm i386 mips pc98 powerpc sparc64
# XXX Add arm64 to universe only if we have an external binutils installed.
# It does not build with the in-tree linnker.
.if exists(/usr/local/aarch64-freebsd/bin/ld)
TARGETS+=arm64
TARGET_ARCHES_arm64?= aarch64
.else
universe: universe_arm64_skip
universe_epilogue: universe_arm64_skip
universe_arm64_skip: universe_prologue
@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
.endif
TARGET_ARCHES_arm?= arm armeb armv6 armv6hf
TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32
TARGET_ARCHES_powerpc?= powerpc powerpc64

View File

@ -344,7 +344,8 @@ X${COMPILER}?= ${${COMPILER}}
.endfor
XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
.for BINUTIL in ${XBINUTILS}
.if defined(CROSS_BINUTILS_PREFIX)
.if defined(CROSS_BINUTILS_PREFIX) && \
exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
.else
X${BINUTIL}?= ${${BINUTIL}}
@ -384,9 +385,9 @@ DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
TARGET_ABI?= unknown
TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
XCFLAGS+= -target ${TARGET_TRIPLE}
.endif
XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
.endif
.else
.if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
@ -411,8 +412,9 @@ LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
MACHINE_CPU="i686 mmx sse sse2"
LIB32WMAKEFLAGS= \
AS="${AS} --32" \
LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
AS="${XAS} --32" \
LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
OBJCOPY="${XOBJCOPY}"
.elif ${TARGET_ARCH} == "powerpc64"
.if empty(TARGET_CPUTYPE)
@ -422,7 +424,8 @@ LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
.endif
LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
LIB32WMAKEFLAGS= \
LD="${LD} -m elf32ppc_fbsd"
LD="${XLD} -m elf32ppc_fbsd" \
OBJCOPY="${XOBJCOPY}"
.endif
@ -1278,10 +1281,6 @@ _m4= lib/libohash \
${_bt}-usr.bin/m4: ${_bt}-lib/libohash
.endif
.if ${BOOTSTRAPPING} < 1000014
_crunch= usr.sbin/crunch
.endif
.if ${BOOTSTRAPPING} < 1000026
_nmtree= lib/libnetbsd \
usr.sbin/nmtree
@ -1297,16 +1296,18 @@ _cat= bin/cat
_lex= usr.bin/lex
.endif
.if ${BOOTSTRAPPING} < 1001507
_crunch= usr.sbin/crunch
.endif
.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
_awk= usr.bin/awk
.endif
.if ${BOOTSTRAPPING} < 1001506
_yacc= lib/liby \
usr.bin/yacc
${_bt}-usr.bin/yacc: ${_bt}-lib/liby
.endif
.if ${MK_BSNMP} != "no"
_gensnmptree= usr.sbin/bsnmpd/gensnmptree
@ -1356,8 +1357,7 @@ _kerberos5_bootstrap_tools= \
kerberos5/tools/slc \
usr.bin/compile_et
${_bt}-kerberos5/tools/slc: ${_bt}-kerberos5/lib/libroken
${_bt}-kerberos5/tools/asn1_compile: ${_bt}-kerberos5/lib/libroken
.ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
.endif
bootstrap-tools: .PHONY
@ -1463,12 +1463,9 @@ _btxld= usr.sbin/btxld
.endif
.endif
.if ${TARGET_ARCH} != ${MACHINE_ARCH}
.if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
.if ${MK_RESCUE} != "no"
_crunchide= usr.sbin/crunch/crunchide
.endif
.if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
_kgzip= usr.sbin/kgzip
.endif
.endif
# If we're given an XAS, don't build binutils.
@ -1514,7 +1511,6 @@ cross-tools: .MAKE
${_cc} \
${_btxld} \
${_crunchide} \
${_kgzip} \
sys/boot/usb/tools
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_tool} && \

View File

@ -38,6 +38,42 @@
# xargs -n1 | sort | uniq -d;
# done
# 20150418
OLD_FILES+=sbin/mount_oldnfs
OLD_FILES+=usr/share/man/man8/mount_oldnfs.8.gz
# 20150416: ALTQ moved to net/altq
OLD_FILES+=usr/include/altq/altq_rmclass_debug.h
OLD_FILES+=usr/include/altq/altq.h
OLD_FILES+=usr/include/altq/altq_cdnr.h
OLD_FILES+=usr/include/altq/altq_hfsc.h
OLD_FILES+=usr/include/altq/altq_priq.h
OLD_FILES+=usr/include/altq/altqconf.h
OLD_FILES+=usr/include/altq/altq_classq.h
OLD_FILES+=usr/include/altq/altq_red.h
OLD_FILES+=usr/include/altq/if_altq.h
OLD_FILES+=usr/include/altq/altq_var.h
OLD_FILES+=usr/include/altq/altq_rmclass.h
OLD_FILES+=usr/include/altq/altq_cbq.h
OLD_FILES+=usr/include/altq/altq_rio.h
OLD_DIRS+=usr/include/altq
# 20150410
OLD_FILES+=usr/share/doc/usd/10.exref/paper.ascii.gz
OLD_FILES+=usr/share/doc/usd/10.exref/summary.ascii.gz
OLD_DIRS+=usr/share/doc/usd/10.exref
OLD_FILES+=usr/share/doc/usd/11.edit/paper.ascii.gz
OLD_DIRS+=usr/share/doc/usd/11.edit
OLD_FILES+=usr/share/doc/usd/12.vi/paper.ascii.gz
OLD_FILES+=usr/share/doc/usd/12.vi/summary.ascii.gz
OLD_FILES+=usr/share/doc/usd/12.vi/viapwh.ascii.gz
OLD_DIRS+=usr/share/doc/usd/12.vi
OLD_FILES+=usr/share/doc/usd/13.viref/paper.ascii.gz
OLD_DIRS+=usr/share/doc/usd/13.viref
# 20150329
.if ${TARGET_ARCH} == "arm"
OLD_FILES+=usr/include/bootconfig.h
.endif
# 20150326
OLD_FILES+=usr/share/man/man1/pmcstudy.1.gz
# 20150315: new clang import which bumps version from 3.5.1 to 3.6.0.
OLD_FILES+=usr/include/clang/3.5.1/__wmmintrin_aes.h
OLD_FILES+=usr/include/clang/3.5.1/__wmmintrin_pclmul.h

36
README
View File

@ -8,39 +8,32 @@ sources in this tree - please see the specific source directories for
more information).
The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree, the most
commonly used one being ``world'', which rebuilds and installs
everything in the FreeBSD system from the source tree except the
kernel, the kernel-modules and the contents of /etc. The ``world''
target should only be used in cases where the source tree has not
changed from the currently running version. See:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
building components (or all) of the FreeBSD source tree. See build(7)
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
for more information, including setting make(1) variables.
The ``buildkernel'' and ``installkernel'' targets build and install
The `buildkernel` and `installkernel` targets build and install
the kernel and the modules (see below). Please see the top of
the Makefile in this directory for more information on the
standard build targets and compile-time flags.
Building a kernel is a somewhat more involved process, documentation
for which can be found at:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
And in the config(8) man page.
Building a kernel is a somewhat more involved process. See build(7), config(8),
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
for more information.
Note: If you want to build and install the kernel with the
``buildkernel'' and ``installkernel'' targets, you might need to build
`buildkernel` and `installkernel` targets, you might need to build
world before. More information is available in the handbook.
The sample kernel configuration files reside in the sys/<arch>/conf
sub-directory (assuming that you've installed the kernel sources), the
file named GENERIC being the one used to build your initial installation
kernel. The file NOTES contains entries and documentation for all possible
devices, not just those commonly used. It is the successor of the ancient
LINT file, but in contrast to LINT, it is not buildable as a kernel but a
pure reference and documentation file.
The kernel configuration files reside in the sys/<arch>/conf
sub-directory. GENERIC is the default configuration used in release builds.
NOTES contains entries and documentation for all possible
devices, not just those commonly used.
Source Roadmap:
---------------
bin System/user commands.
cddl Various commands and libraries under the Common Development
@ -77,6 +70,9 @@ share Shared resources.
sys Kernel sources.
tests Regression tests which can be run by Kyua. See tests/README
for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.

View File

@ -31,6 +31,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20150415:
The const qualifier has been removed from iconv(3) to comply with
POSIX. The ports tree is aware of this from r384038 onwards.
20150416:
Libraries specified by LIBADD in Makefiles must have a corresponding
DPADD_<lib> variable to ensure correct dependencies. This is now
enforced in src.libnames.mk.
20150324:
From legacy ata(4) driver was removed support for SATA controllers
supported by more functional drivers ahci(4), siis(4) and mvs(4).

View File

@ -198,7 +198,7 @@
#define HAVE_WCWIDTH 1
/* Define as const if the declaration of iconv() needs const. */
#define ICONV_CONST const
#define ICONV_CONST
/* Support NLS. */
#define NLS 1

View File

@ -30,7 +30,7 @@
#define _ICONV_H_
typedef void *iconv_t;
typedef size_t dl_iconv_t(iconv_t, const char **, size_t *, char **, size_t *);
typedef size_t dl_iconv_t(iconv_t, char **, size_t *, char **, size_t *);
typedef int dl_iconv_close_t(iconv_t);
extern iconv_t dl_iconv_open(const char *, const char *);

View File

@ -60,7 +60,7 @@ build_active_list(int isgcmd)
return ERR;
if (isbinary)
NUL_TO_NEWLINE(s, lp->len);
if (!regexec(pat, s, 0, NULL, 0) == isgcmd &&
if (!(regexec(pat, s, 0, NULL, 0) == isgcmd) &&
set_active_node(lp) < 0)
return ERR;
}
@ -153,7 +153,7 @@ set_active_node(line_t *lp)
if (active_list != NULL) {
#endif
if ((ts = (line_t **) realloc(active_list,
(ti += MINBUFSZ) * sizeof(line_t **))) == NULL) {
(ti += MINBUFSZ) * sizeof(line_t *))) == NULL) {
fprintf(stderr, "%s\n", strerror(errno));
errmsg = "out of memory";
SPL0();

View File

@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$
.\"
.Dd February 22, 2015
.Dd April 18, 2015
.Dt SH 1
.Os
.Sh NAME
@ -2574,8 +2574,7 @@ the former causes the specified signal to be ignored
and the latter causes the default action to be taken.
Omitting the
.Ar action
is another way to request the default action, for compatibility reasons this
usage is not recommended though.
and using only signal numbers is another way to request the default action.
In a subshell or utility environment,
the shell resets trapped (but not ignored) signals to the default action.
The

View File

@ -137,6 +137,8 @@ FILES+= trap11.0
FILES+= trap12.0
FILES+= trap13.0
FILES+= trap14.0
FILES+= trap15.0
FILES+= trap16.0
FILES+= trap2.0
FILES+= trap3.0
FILES+= trap4.0

View File

@ -0,0 +1,5 @@
# $FreeBSD$
(${SH} -c 'term(){ exit 5;}; trap term TERM; kill -TERM $$') &
wait >/dev/null 2>&1 $!
[ $? -eq 5 ]

View File

@ -0,0 +1,20 @@
# $FreeBSD$
traps=$(${SH} -c 'trap "echo bad" 0; trap - 0; trap')
[ -z "$traps" ] || exit 1
traps=$(${SH} -c 'trap "echo bad" 0; trap "" 0; trap')
expected_traps=$(${SH} -c 'trap "" EXIT; trap')
[ "$traps" = "$expected_traps" ] || exit 2
traps=$(${SH} -c 'trap "echo bad" 0; trap 0; trap')
[ -z "$traps" ] || exit 3
traps=$(${SH} -c 'trap "echo bad" 0; trap -- 0; trap')
[ -z "$traps" ] || exit 4
traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap - 0 1 2; trap')
[ -z "$traps" ] || exit 5
traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap "" 0 1 2; trap')
expected_traps=$(${SH} -c 'trap "" EXIT HUP INT; trap')
[ "$traps" = "$expected_traps" ] || exit 6
traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap 0 1 2; trap')
[ -z "$traps" ] || exit 7
traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap -- 0 1 2; trap')
[ -z "$traps" ] || exit 8

View File

@ -49,6 +49,8 @@ FILES+= ifs2.0
FILES+= ifs3.0
FILES+= ifs4.0
FILES+= ifs5.0
FILES+= ifs6.0
FILES+= ifs7.0
FILES+= length1.0
FILES+= length2.0
FILES+= length3.0

View File

@ -0,0 +1,6 @@
# $FreeBSD$
IFS=': '
x=': :'
set -- $x
[ "$#|$1|$2|$3" = "2|||" ]

View File

@ -0,0 +1,5 @@
# $FreeBSD$
IFS=2
set -- $((123))
[ "$#|$1|$2|$3" = "2|1|3|" ]

View File

@ -183,7 +183,7 @@ trapcmd(int argc __unused, char **argv)
return 0;
}
action = NULL;
if (*argv && sigstring_to_signum(*argv) == -1) {
if (*argv && !is_number(*argv)) {
if (strcmp(*argv, "-") == 0)
argv++;
else {

View File

@ -21,7 +21,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 5, 2013
.Dd April 18, 2015
.Dt DTRACE 1
.Os
.Sh NAME
@ -670,7 +670,8 @@ Invalid command line options or arguments were specified.
.Sh SEE ALSO
.Xr cpp 1 ,
.Xr dtruss 1 ,
.Xr elf 5
.Xr elf 5 ,
.Xr SDT 9
.Rs
.%T Solaris Dynamic Tracing Guide
.Re

View File

@ -35,11 +35,11 @@ BEGIN
this->b = -2;
system("echo %s %d %d", "foo", this->a, this->b);
system("ping localhost");
system("ping -q -c 1 localhost 2>/dev/null | grep -v '^round-trip '");
system("echo %d", ++this->a);
system("ping localhost");
system("ping -q -c 1 localhost 2>/dev/null | grep -v '^round-trip '");
system("echo %d", ++this->a);
system("ping localhost");
system("ping -q -c 1 localhost 2>/dev/null | grep -v '^round-trip '");
system("echo %d", ++this->a);
exit(0);
}

View File

@ -1,8 +1,17 @@
foo 9 -2
localhost is alive
PING localhost (127.0.0.1): 56 data bytes
--- localhost ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
10
localhost is alive
PING localhost (127.0.0.1): 56 data bytes
--- localhost ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
11
localhost is alive
PING localhost (127.0.0.1): 56 data bytes
--- localhost ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
12

View File

@ -45,12 +45,13 @@ fi
dtrace=$1
local=127.0.0.1
$dtrace -c "/sbin/ping $local 3" -qs /dev/stdin <<EOF | sort -n
$dtrace -c "/sbin/ping -q -c 1 -t 3 $local" -qs /dev/stdin <<EOF | sort -n | \
grep -v -e '^round-trip ' -e '^--- '
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_ICMP/
{
printf("1 ip:::send (");
printf("2 ip:::send (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[4]: %d %d %d %d %d)\n",
args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
@ -61,7 +62,7 @@ ip:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_ICMP/
{
printf("2 ip:::receive (");
printf("3 ip:::receive (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[4]: %d %d %d %d %d)\n",
args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,

View File

@ -1,6 +1,8 @@
1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255)
2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255)
127.0.0.1 is alive
PING 127.0.0.1 (127.0.0.1): 56 data bytes
1 packets transmitted, 1 packets received, 0.0% packet loss
2 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 64)
2 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 64)
3 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 64)
3 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 64)

View File

@ -73,6 +73,7 @@ cat > test.pl <<-EOPERL
Timeout => 3);
die "Could not connect to host $local port $tcpport" unless \$s;
close \$s;
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE

View File

@ -76,6 +76,7 @@ cat > test.pl <<-EOPERL
Timeout => 3);
die "Could not connect to host $dest port $tcpport" unless \$s;
close \$s;
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE

View File

@ -55,12 +55,13 @@ else
removeinet6=0
fi
$dtrace -c "/sbin/ping -A inet6 $local 3" -qs /dev/stdin <<EOF | sort -n
$dtrace -c "/sbin/ping6 -q -c 1 -X 3 $local" -qs /dev/stdin <<EOF | sort -n | \
grep -v -e '^round-trip ' -e '^--- '
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
{
printf("1 ip:::send (");
printf("2 ip:::send (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[5]: %d %d %d)\n",
args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
@ -70,7 +71,7 @@ ip:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
{
printf("2 ip:::receive (");
printf("3 ip:::receive (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[5]: %d %d %d)\n",
args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);

View File

@ -1,6 +1,8 @@
::1 is alive
1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)
2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)
PING6(56=40+8+8 bytes) ::1 --> ::1
1 packets transmitted, 1 packets received, 0.0% packet loss
2 ip:::send (args[2]: 6 16, args[5]: 6 0 16)
2 ip:::send (args[2]: 6 16, args[5]: 6 0 16)
3 ip:::receive (args[2]: 6 16, args[5]: 6 0 16)
3 ip:::receive (args[2]: 6 16, args[5]: 6 0 16)

View File

@ -79,6 +79,7 @@ cat > test.pl <<-EOPERL
die "Could not connect to host $local port $tcpport" unless \$s;
print \$s "testing state machine transitions";
close \$s;
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE

View File

@ -84,6 +84,7 @@ cat > test.pl <<-EOPERL
die "Could not connect to host $dest port $tcpport" unless \$s;
print \$s "testing state machine transitions";
close \$s;
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE

View File

@ -147,6 +147,9 @@ dtrace_dof_init(void)
dh.dofhp_dof = (uintptr_t)dof;
dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0;
#ifdef __FreeBSD__
dh.dofhp_pid = getpid();
#endif
if (lmid == 0) {
(void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod),
@ -184,7 +187,7 @@ dtrace_dof_init(void)
else {
dprintf(1, "DTrace ioctl succeeded for DOF at %p\n", dof);
#ifdef __FreeBSD__
gen = dh.gen;
gen = dh.dofhp_gen;
#endif
}

View File

@ -727,8 +727,8 @@ dt_print_packed(dtrace_hdl_t *dtp, FILE *fp,
utf8 = B_TRUE;
} else if ((term = getenv("TERM")) != NULL &&
(strcmp(term, "sun") == 0 ||
strcmp(term, "sun-color") == 0) ||
strcmp(term, "dumb") == 0) {
strcmp(term, "sun-color") == 0 ||
strcmp(term, "dumb") == 0)) {
utf8 = B_FALSE;
} else {
utf8 = B_TRUE;

View File

@ -1785,11 +1785,17 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
"failed to open %s: %s", file, strerror(errno)));
}
#else
snprintf(tfile, sizeof(tfile), "%s.XXXXXX", file);
if ((fd = mkstemp(tfile)) == -1)
return (dt_link_error(dtp, NULL, -1, NULL,
"failed to create temporary file %s: %s",
tfile, strerror(errno)));
if (dtp->dt_lazyload) {
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0666)) < 0)
return (dt_link_error(dtp, NULL, -1, NULL,
"failed to open %s: %s", file, strerror(errno)));
} else {
snprintf(tfile, sizeof(tfile), "%s.XXXXXX", file);
if ((fd = mkstemp(tfile)) == -1)
return (dt_link_error(dtp, NULL, -1, NULL,
"failed to create temporary file %s: %s",
tfile, strerror(errno)));
}
#endif
/*

View File

@ -44,11 +44,16 @@
#include <dt_program.h>
#include <dt_pid.h>
#include <dt_string.h>
#ifndef illumos
#include <libproc_compat.h>
#endif
#include <dt_module.h>
#ifndef illumos
#include <sys/sysctl.h>
#include <unistd.h>
#include <libproc_compat.h>
#include <libelf.h>
#include <gelf.h>
#endif
typedef struct dt_pid_probe {
dtrace_hdl_t *dpp_dtp;
dt_pcb_t *dpp_pcb;
@ -566,6 +571,12 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
prsyminfo_t sip;
dof_helper_t dh;
GElf_Half e_type;
#ifdef __FreeBSD__
dof_hdr_t hdr;
size_t sz;
uint64_t dofmax;
void *dof;
#endif
const char *mname;
const char *syms[] = { "___SUNW_dof", "__SUNW_dof" };
int i, fd = -1;
@ -595,17 +606,61 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
continue;
}
#ifdef __FreeBSD__
dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr;
if (Pread(P, &hdr, sizeof (hdr), sym.st_value) !=
sizeof (hdr)) {
dt_dprintf("read of DOF header failed\n");
continue;
}
sz = sizeof(dofmax);
if (sysctlbyname("kern.dtrace.dof_maxsize", &dofmax, &sz,
NULL, 0) != 0) {
dt_dprintf("failed to read dof_maxsize: %s\n",
strerror(errno));
continue;
}
if (dofmax < hdr.dofh_loadsz) {
dt_dprintf("DOF load size exceeds maximum\n");
continue;
}
if ((dof = malloc(hdr.dofh_loadsz)) == NULL)
return (-1);
if (Pread(P, dof, hdr.dofh_loadsz, sym.st_value) !=
hdr.dofh_loadsz) {
free(dof);
dt_dprintf("read of DOF section failed\n");
continue;
}
dh.dofhp_dof = (uintptr_t)dof;
dh.dofhp_pid = proc_getpid(P);
dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod),
sip.prs_lmid, mname);
if (fd == -1 &&
(fd = open("/dev/dtrace/helper", O_RDWR, 0)) < 0) {
dt_dprintf("open of helper device failed: %s\n",
strerror(errno));
free(dof);
return (-1); /* errno is set for us */
}
if (ioctl(fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0)
dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod);
free(dof);
#else
dh.dofhp_dof = sym.st_value;
dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr;
dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod),
#ifdef illumos
sip.prs_lmid, mname);
#else
0, mname);
#endif
#ifdef illumos
if (fd == -1 &&
(fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) {
dt_dprintf("pr_open of helper device failed: %s\n",
@ -618,8 +673,10 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
#endif
}
#ifdef illumos
if (fd != -1)
#ifdef __FreeBSD__
(void) close(fd);
#else
(void) pr_close(P, fd);
#endif
@ -634,7 +691,6 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
int ret = 0;
assert(DT_MUTEX_HELD(&dpr->dpr_lock));
#ifdef illumos
(void) Pupdate_maps(P);
if (Pobject_iter(P, dt_pid_usdt_mapping, P) != 0) {
ret = -1;
@ -646,9 +702,6 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
(int)proc_getpid(P), strerror(errno));
#endif
}
#else
ret = 0;
#endif
/*
* Put the module name in its canonical form.

View File

@ -59,6 +59,6 @@
#define Pstate proc_state
#define Psymbol_iter_by_addr proc_iter_symbyaddr
#define Punsetflags proc_clearflags
#define Pupdate_maps(p) do { } while (0)
#define Pupdate_maps proc_rdagent
#define Pupdate_syms proc_updatesyms
#define Pxecbkpt proc_bkptexec

View File

@ -33,7 +33,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
-I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
DPADD= ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
LDADD= -ldwarf -lelf -lz -lpthread
LIBADD= elf z pthread
.include <bsd.prog.mk>

View File

@ -8,10 +8,8 @@ TESTS_SUBDIRS+= common
.PATH: ${.CURDIR:H:H:H:H}/tests
KYUAFILE= YES
.PATH: ${.CURDIR:H:H:H}/contrib/opensolaris/cmd/dtrace/test/cmd/scripts
.PATH: ${.CURDIR}/tools
SCRIPTSDIR= ${TESTSDIR}
SCRIPTS= dtest.pl
SUBDIR_PARALLEL=
SCRIPTS= dtest.sh
.include <bsd.test.mk>

View File

@ -16,7 +16,6 @@ ${TESTGROUP}EXEDIR= ${TESTSDIR}
TESTWRAPPER= t_dtrace_contrib
ATF_TESTS_SH+= ${TESTWRAPPER}
TEST_METADATA.t_dtrace_contrib+= required_files="/usr/local/bin/perl"
TEST_METADATA.t_dtrace_contrib+= required_files="/usr/local/bin/ksh"
TEST_METADATA.t_dtrace_contrib+= required_user="root"

View File

@ -0,0 +1,129 @@
# $FreeBSD$
usage()
{
cat >&2 <<__EOF__
A harness for test cases in the DTrace test suite.
usage: $(basename $0) <testfile>
__EOF__
exit 1
}
gettag()
{
local tag
tag=$(basename $1)
tag=${tag#*.}
tag=${tag%%[a-z.]*}
echo $tag
}
runtest()
{
local dflags exe exstatus pid retval status
exstatus=0
retval=0
case $TFILE in
drp.DTRACEDROP_*.d|err.*.d|tst.*.d)
case $TFILE in
drp.DTRACEDROP_*.d)
dflags="-x droptags"
tag=$(gettag "$TFILE")
;;
err.D_*.d)
exstatus=1
dflags="-x errtags"
tag=$(gettag "$TFILE")
;;
err.*.d)
exstatus=1
;;
esac
exe=${TFILE%.*}.exe
if [ -f "$exe" -a -x "$exe" ]; then
./$exe &
pid=$!
dflags="$dflags ${pid}"
fi
dtrace -C -s "${TFILE}" $dflags >$STDOUT 2>$STDERR
status=$?
if [ $status -ne $exstatus ]; then
ERRMSG="dtrace exited with status ${status}, expected ${exstatus}"
retval=1
elif [ -n "${tag}" ] && ! grep -Fq " [${tag}] " ${STDERR}; then
ERRMSG="dtrace's error output did not contain expected tag ${tag}"
retval=1
fi
if [ -n "$pid" ]; then
kill -0 $pid >/dev/null 2>&1 && kill -9 $pid >/dev/null 2>&1
wait
fi
;;
err.*.ksh|tst.*.ksh)
expr "$TFILE" : 'err.*' >/dev/null && exstatus=1
ksh "$TFILE" /usr/sbin/dtrace >$STDOUT 2>$STDERR
status=$?
if [ $status -ne $exstatus ]; then
ERRMSG="script exited with status ${status}, expected ${exstatus}"
retval=1
fi
;;
*)
ERRMSG="unexpected test file name $TFILE"
retval=1
;;
esac
return $retval
}
[ $# -eq 1 ] || usage
readonly STDERR=$(mktemp)
readonly STDOUT=$(mktemp)
readonly TFILE=$(basename $1)
readonly EXOUT=${TFILE}.out
kldstat -q -m dtrace_test || kldload dtrace_test
cd $(dirname $1)
runtest
RESULT=$?
if [ $RESULT -eq 0 -a -f $EXOUT -a -r $EXOUT ] && \
! cmp $STDOUT $EXOUT >/dev/null 2>&1; then
ERRMSG="test output mismatch"
RESULT=1
fi
if [ $RESULT -ne 0 ]; then
echo "test $TFILE failed: $ERRMSG" >&2
if [ $(stat -f '%z' $STDOUT) -gt 0 ]; then
cat >&2 <<__EOF__
test stdout:
--
$(cat $STDOUT)
--
__EOF__
fi
if [ $(stat -f '%z' $STDERR) -gt 0 ]; then
cat >&2 <<__EOF__
test stderr:
--
$(cat $STDERR)
--
__EOF__
fi
fi
rm -f $STDERR $STDOUT
exit $RESULT

View File

@ -33,8 +33,8 @@ ${tcase}_head()
${tcase}_body()
{
$mod
atf_check -s exit:0 -o ignore -e ignore \\
"\$(atf_get_srcdir)/../../dtest" -n "\$(atf_get_srcdir)/${tfile}"
atf_check -s exit:0 -o empty -e empty \\
"\$(atf_get_srcdir)/../../dtest" "\$(atf_get_srcdir)/${tfile}"
}
__EOF__
}

View File

@ -1286,7 +1286,7 @@ struct elf_find_verdep_info
};
/* The maximum number of known object attributes for any target. */
#define NUM_KNOWN_OBJ_ATTRIBUTES 32
#define NUM_KNOWN_OBJ_ATTRIBUTES 71
/* The value of an object attribute. type & 1 indicates whether there
is an integer value; type & 2 indicates whether there is a string

View File

@ -6835,6 +6835,8 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
case Tag_ABI_FP_number_model:
case Tag_ABI_align8_preserved:
case Tag_ABI_HardFP_use:
case Tag_CPU_unaligned_access:
case Tag_FP_HP_extension:
/* Use the largest value specified. */
if (in_attr[i].i > out_attr[i].i)
out_attr[i].i = in_attr[i].i;
@ -6951,7 +6953,9 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
}
break;
default: /* All known attributes should be explicitly covered. */
abort ();
/* XXX Not now */
/* abort (); */
break;
}
}

View File

@ -271,7 +271,11 @@ enum
Tag_ABI_optimization_goals,
Tag_ABI_FP_optimization_goals,
/* 32 is generic. */
Tag_CPU_unaligned_access = 34,
Tag_FP_HP_extension = 36,
Tag_ABI_FP_16bit_format = 38,
Tag_MPextension_use = 42,
Tag_DIV_use = 44,
Tag_Virtualization_use = 68,
};

View File

@ -1,8 +1,76 @@
2015-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20150418
Merge with NetBSD make, pick up
o job.c: use memmove() rather than memcpy()
* unit-tests/varshell.mk: SunOS cannot handle the TERMINATED_BY_SIGNAL
case, so skip it.
2015-04-11 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20150411
bump version - only mk/ changes.
2015-04-10 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20150410
Merge with NetBSD make, pick up
o document different handling of '-' in jobs mode vs compat
o fix jobs mode so that '-' only applies to whole job
when shell lacks hasErrCtl
o meta.c: use separate vars to track lcwd and latestdir (read)
per process
2015-04-01 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20150401
Merge with NetBSD make, pick up
o meta.c: close meta file in child
* Makefile: use BINDIR.bmake if set.
Same for MANDIR and SHAREDIR
Handy for testing release candidates
in various environments.
2015-03-26 Simon J. Gerraty <sjg@bad.crufty.net>
* move initialization of savederr to block where it is used
to avoid spurious warning from gcc5
2014-11-11 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20141111
just a cooler number
2014-11-05 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20141105
Merge with NetBSD make, pick up
o revert major overhaul of suffix handling
and POSIX compliance - too much breakage
and impossible to make backwards compatible.
o we still have the new unit test structure which is ok.
o meta.c ensure "-- filemon" is at start of line.
2014-09-17 Simon J. Gerraty <sjg@bad.crufty.net>
* configure.in: test that result of getconf PATH_MAX is numeric
and discard if not. Apparently needed for Hurd.
2014-08-30 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20140830
Merge with NetBSD make, pick up
o major overhaul of suffix handling
o improved POSIX compliance
o overhauled unit-tests
2014-06-20 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20140620
Merge with NetBSD make, pick up
o var.c return varNoError rather than var_Error for ::= modidiers.
o var.c return varNoError rather than var_Error for ::= modifiers.
2014-05-22 Simon J. Gerraty <sjg@bad.crufty.net>

View File

@ -92,35 +92,74 @@ targ.c
trace.c
trace.h
unit-tests/Makefile.in
unit-tests/comment
unit-tests/cond1
unit-tests/doterror
unit-tests/dotwait
unit-tests/error
unit-tests/export
unit-tests/export-all
unit-tests/export-env
unit-tests/forloop
unit-tests/forsubst
unit-tests/hash
unit-tests/misc
unit-tests/moderrs
unit-tests/modmatch
unit-tests/modmisc
unit-tests/modorder
unit-tests/modts
unit-tests/modword
unit-tests/order
unit-tests/phony-end
unit-tests/posix
unit-tests/qequals
unit-tests/sunshcmd
unit-tests/sysv
unit-tests/ternary
unit-tests/test.exp
unit-tests/unexport
unit-tests/unexport-env
unit-tests/varcmd
unit-tests/comment.exp
unit-tests/comment.mk
unit-tests/cond1.exp
unit-tests/cond1.mk
unit-tests/doterror.exp
unit-tests/doterror.mk
unit-tests/dotwait.exp
unit-tests/dotwait.mk
unit-tests/error.exp
unit-tests/error.mk
unit-tests/escape.exp
unit-tests/escape.mk
unit-tests/export-all.exp
unit-tests/export-all.mk
unit-tests/export-env.exp
unit-tests/export-env.mk
unit-tests/export.exp
unit-tests/export.mk
unit-tests/forloop.exp
unit-tests/forloop.mk
unit-tests/forsubst.exp
unit-tests/forsubst.mk
unit-tests/hash.exp
unit-tests/hash.mk
unit-tests/impsrc.exp
unit-tests/impsrc.mk
unit-tests/misc.exp
unit-tests/misc.mk
unit-tests/moderrs.exp
unit-tests/moderrs.mk
unit-tests/modmatch.exp
unit-tests/modmatch.mk
unit-tests/modmisc.exp
unit-tests/modmisc.mk
unit-tests/modorder.exp
unit-tests/modorder.mk
unit-tests/modts.exp
unit-tests/modts.mk
unit-tests/modword.exp
unit-tests/modword.mk
unit-tests/order.exp
unit-tests/order.mk
unit-tests/phony-end.exp
unit-tests/phony-end.mk
unit-tests/posix.exp
unit-tests/posix.mk
unit-tests/posix1.exp
unit-tests/posix1.mk
unit-tests/qequals.exp
unit-tests/qequals.mk
unit-tests/suffixes.exp
unit-tests/suffixes.mk
unit-tests/sunshcmd.exp
unit-tests/sunshcmd.mk
unit-tests/sysv.exp
unit-tests/sysv.mk
unit-tests/ternary.exp
unit-tests/ternary.mk
unit-tests/unexport-env.exp
unit-tests/unexport-env.mk
unit-tests/unexport.exp
unit-tests/unexport.mk
unit-tests/varcmd.exp
unit-tests/varcmd.mk
unit-tests/varmisc.exp
unit-tests/varmisc.mk
unit-tests/varshell.exp
unit-tests/varshell.mk
util.c
var.c
wait.h

View File

@ -1,7 +1,7 @@
# $Id: Makefile,v 1.27 2014/06/20 14:51:54 sjg Exp $
# $Id: Makefile,v 1.36 2015/04/18 19:58:53 sjg Exp $
# Base version on src date
MAKE_VERSION= 20140620
MAKE_VERSION= 20150418
PROG= bmake
@ -180,9 +180,9 @@ COPTS.parse.c += -Wno-format-nonliteral
COPTS.var.c += -Wno-format-nonliteral
# Force these
SHAREDIR= ${prefix}/share
BINDIR= ${prefix}/bin
MANDIR= ${SHAREDIR}/man
SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
BINDIR= ${BINDIR.bmake:U${prefix}/bin}
MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}
.if !exists(.depend)
${OBJS}: config.h

View File

@ -1,8 +1,10 @@
# $NetBSD: Makefile,v 1.2 1995/06/14 15:20:23 christos Exp $
# $NetBSD: Makefile,v 1.4 2014/07/05 19:22:43 dholland Exp $
# @(#)Makefile 8.1 (Berkeley) 8/14/93
DIR= psd/12.make
SECTION=reference/ref1
ARTICLE=make
SRCS= tutorial.ms
MACROS= -ms
EXTRAHTMLFILES=make1.png make2.png
.include <bsd.doc.mk>

View File

@ -1,4 +1,4 @@
.\" $NetBSD: tutorial.ms,v 1.11 2011/08/18 15:19:30 sjg Exp $
.\" $NetBSD: tutorial.ms,v 1.12 2014/09/30 21:33:14 christos Exp $
.\" Copyright (c) 1988, 1989, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@ -67,6 +67,16 @@
.\"
.EH 'PSD:12-%''PMake \*- A Tutorial'
.OH 'PMake \*- A Tutorial''PSD:12-%'
.\" Ix is an indexing macro similar to .IX but I've disabled it for now
.\" Since that would require 2 passes and I am not in the mood for that.
.de Ix
..
.\" Rd is section (region) define and Rm is region mention? Again disable for
.\" now.
.de Rd
..
.de Rm
..
.\" xH is a macro to provide numbered headers that are automatically stuffed
.\" into a table-of-contents, properly indented, etc. If the first argument
.\" is numeric, it is taken as the depth for numbering (as for .NH), else

View File

@ -1,4 +1,4 @@
.\" $NetBSD: make.1,v 1.229 2014/01/19 10:23:29 apb Exp $
.\" $NetBSD: make.1,v 1.247 2015/04/10 08:43:32 wiz 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 February 14, 2014
.Dd April 9, 2015
.Dt MAKE 1
.Os
.Sh NAME
@ -209,8 +209,6 @@ Force the
option to print raw values of variables.
.It Ar v
Print debugging information about variable assignment.
.It Ar w
Print entering and leaving directory messages, pre and post processing.
.It Ar x
Run shell commands with
.Fl x
@ -352,6 +350,8 @@ contains a
then the value will be expanded before printing.
.It Fl W
Treat any warnings during makefile parsing as errors.
.It Fl w
Print entering and leaving directory messages, pre and post processing.
.It Fl X
Don't export variables passed on the command line to the environment
individually.
@ -441,17 +441,29 @@ The value
need not necessarily be used to describe existing files.
Expansion is in directory order, not alphabetically as done in the shell.
.Sh SHELL COMMANDS
Each target may have associated with it a series of shell commands, normally
Each target may have associated with it one or more lines of shell
commands, normally
used to create the target.
Each of the commands in this script
Each of the lines in this script
.Em must
be preceded by a tab.
While any target may appear on a dependency line, only one of these
dependencies may be followed by a creation script, unless the
(For historical reasons, spaces are not accepted.)
While targets can appear in many dependency lines if desired, by
default only one of these rules may be followed by a creation
script.
If the
.Ql Ic \&::
operator is used.
operator is used, however, all rules may include scripts and the
scripts are executed in the order found.
.Pp
If the first characters of the command line are any combination of
Each line is treated as a separate shell command, unless the end of
line is escaped with a backslash
.Pq Ql \e
in which case that line and the next are combined.
.\" The escaped newline is retained and passed to the shell, which
.\" normally ignores it.
.\" However, the tab at the beginning of the following line is removed.
If the first characters of the command are any combination of
.Ql Ic @ ,
.Ql Ic + ,
or
@ -469,6 +481,7 @@ This is similar to the effect of the .MAKE special source,
except that the effect can be limited to a single line of a script.
A
.Ql Ic \-
in compatibility mode
causes any non-zero exit status of the command line to be ignored.
.Pp
When
@ -477,13 +490,45 @@ is run in jobs mode with
.Fl j Ar max_jobs ,
the entire script for the target is fed to a
single instance of the shell.
.Pp
In compatibility (non-jobs) mode, each command is run in a separate process.
If the command contains any shell meta characters
.Pq Ql #=|^(){};&<>*?[]:$`\e\en
it will be passed to the shell, otherwise
it will be passed to the shell; otherwise
.Nm
will attempt direct execution.
If a line starts with
.Ql Ic \-
and the shell has ErrCtl enabled then failure of the command line
will be ignored as in compatibility mode.
Otherwise
.Ql Ic \-
affects the entire job;
the script will stop at the first command line that fails,
but the target will not be deemed to have failed.
.Pp
Makefiles should be written so that the mode of
.Nm
operation does not change their behavior.
For example, any command which needs to use
.Dq cd
or
.Dq chdir
without potentially changing the directory for subsequent commands
should be put in parentheses so it executes in a subshell.
To force the use of one shell, escape the line breaks so as to make
the whole script one command.
For example:
.Bd -literal -offset indent
avoid-chdir-side-effects:
@echo Building $@ in `pwd`
@(cd ${.CURDIR} && ${MAKE} $@)
@echo Back in `pwd`
ensure-one-shell-regardless-of-mode:
@echo Building $@ in `pwd`; \e
(cd ${.CURDIR} && ${MAKE} $@); \e
echo Back in `pwd`
.Ed
.Pp
Since
.Nm
@ -493,27 +538,6 @@ to
.Ql Va .OBJDIR
before executing any targets, each child process
starts with that as its current working directory.
.Pp
Makefiles should be written so that the mode of
.Nm
operation does not change their behavior.
For example, any command which needs to use
.Dq cd
or
.Dq chdir ,
without side-effect should be put in parenthesis:
.Bd -literal -offset indent
avoid-chdir-side-effects:
@echo Building $@ in `pwd`
@(cd ${.CURDIR} && ${.MAKE} $@)
@echo Back in `pwd`
ensure-one-shell-regardless-of-mode:
@echo Building $@ in `pwd`; \\
(cd ${.CURDIR} && ${.MAKE} $@); \\
echo Back in `pwd`
.Ed
.Sh VARIABLE ASSIGNMENTS
Variables in make are much like variables in the shell, and, by tradition,
consist of all upper-case letters.
@ -624,13 +648,19 @@ Variables defined in the makefile or in included makefiles.
Variables defined as part of the command line.
.It Local variables
Variables that are defined specific to a certain target.
.El
.Pp
Local variables are all built in and their values vary magically from
target to target.
It is not currently possible to define new local variables.
The seven local variables are as follows:
.Bl -tag -width ".ARCHIVE"
.Bl -tag -width ".ARCHIVE" -offset indent
.It Va .ALLSRC
The list of all sources for this target; also known as
.Ql Va \&\*[Gt] .
.It Va .ARCHIVE
The name of the archive file.
The name of the archive file; also known as
.Ql Va \&! .
.It Va .IMPSRC
In suffix-transformation rules, the name/path of the source from which the
target is to be transformed (the
@ -639,7 +669,8 @@ source); also known as
.Ql Va \&\*[Lt] .
It is not defined in explicit rules.
.It Va .MEMBER
The name of the archive member.
The name of the archive member; also known as
.Ql Va % .
.It Va .OODATE
The list of sources for this target that were deemed out-of-date; also
known as
@ -648,31 +679,41 @@ known as
The file prefix of the target, containing only the file portion, no suffix
or preceding directory components; also known as
.Ql Va * .
The suffix must be one of the known suffixes declared with
.Ic .SUFFIXES
or it will not be recognized.
.It Va .TARGET
The name of the target; also known as
.Ql Va @ .
.El
.Pp
The shorter forms
.Ql Va @ ,
.Ql ( Va \*[Gt] ,
.Ql Va \&! ,
.Ql Va \*[Lt] ,
.Ql Va % ,
.Ql Va \&? ,
.Ql Va \&\*[Lt] ,
.Ql Va \&\*[Gt] ,
.Ql Va * ,
and
.Ql Va *
.Ql Va @ )
are permitted for backward
compatibility with historical makefiles and are not recommended.
The six variables
.Ql Va "@F" ,
.Ql Va "@D" ,
.Ql Va "\*[Lt]F" ,
.Ql Va "\*[Lt]D" ,
.Ql Va "*F" ,
compatibility with historical makefiles and legacy POSIX make and are
not recommended.
.Pp
Variants of these variables with the punctuation followed immediately by
.Ql D
or
.Ql F ,
e.g.
.Ql Va $(@D) ,
are legacy forms equivalent to using the
.Ql :H
and
.Ql Va "*D"
are permitted for compatibility with
.Ql :T
modifiers.
These forms are accepted for compatibility with
.At V
makefiles and are not recommended.
makefiles and POSIX but are not recommended.
.Pp
Four of the local variables may be used in sources on dependency lines
because they expand to the proper value for each target on the line.
@ -682,7 +723,6 @@ These variables are
.Ql Va .ARCHIVE ,
and
.Ql Va .MEMBER .
.El
.Ss Additional built-in variables
In addition,
.Nm
@ -2119,19 +2159,87 @@ system makefile
system makefile directory
.El
.Sh COMPATIBILITY
The basic make syntax is compatible between different versions of make,
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
NetBSD 4.0
so that .ORDER and .WAIT apply recursively to the dependent nodes.
The algorithms used may change again in the future.
.Ss Older versions
An incomplete list of changes in older versions of
.Nm :
.Pp
The way that .for loop variables are substituted changed after
NetBSD 5.0
so that they still appear to be variable expansions.
In particular this stops them being treated as syntax, and removes some
obscure problems using them in .if statements.
.Pp
The way that parallel makes are scheduled changed in
NetBSD 4.0
so that .ORDER and .WAIT apply recursively to the dependent nodes.
The algorithms used may change again in the future.
.Ss Other make dialects
Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
support most of the features of
.Nm
as described in this manual.
Most notably:
.Bl -bullet -offset indent
.It
The
.Ic .WAIT
and
.Ic .ORDER
declarations and most functionality pertaining to parallelization.
(GNU make supports parallelization but lacks these features needed to
control it effectively.)
.It
Directives, including for loops and conditionals and most of the
forms of include files.
(GNU make has its own incompatible and less powerful syntax for
conditionals.)
.It
All built-in variables that begin with a dot.
.It
Most of the special sources and targets that begin with a dot,
with the notable exception of
.Ic .PHONY ,
.Ic .PRECIOUS ,
and
.Ic .SUFFIXES .
.It
Variable modifiers, except for the
.Dl :old=new
string substitution, which does not portably support globbing with
.Ql %
and historically only works on declared suffixes.
.It
The
.Ic $>
variable even in its short form; most makes support this functionality
but its name varies.
.El
.Pp
Some features are somewhat more portable, such as assignment with
.Ic += ,
.Ic ?= ,
and
.Ic != .
The
.Ic .PATH
functionality is based on an older feature
.Ic VPATH
found in GNU make and many versions of SVR4 make; however,
historically its behavior is too ill-defined (and too buggy) to rely
upon.
.Pp
The
.Ic $@
and
.Ic $<
variables are more or less universally portable, as is the
.Ic $(MAKE)
variable.
Basic use of suffix rules (for files only in the current directory,
not trying to chain transformations together, etc.) is also reasonably
portable.
.Sh SEE ALSO
.Xr mkdep 1
.Sh HISTORY

View File

@ -122,9 +122,6 @@ DDEESSCCRRIIPPTTIIOONN
_v Print debugging information about variable assignment.
_w Print entering and leaving directory messages, pre and
post processing.
_x Run shell commands with --xx so the actual commands are
printed as they are executed.
@ -221,6 +218,9 @@ DDEESSCCRRIIPPTTIIOONN
--WW Treat any warnings during makefile parsing as errors.
--ww Print entering and leaving directory messages, pre and post pro-
cessing.
--XX Don't export variables passed on the command line to the environ-
ment individually. Variables passed on the command line are
still exported via the _M_A_K_E_F_L_A_G_S environment variable. This
@ -273,46 +273,55 @@ FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOO
done in the shell.
SSHHEELLLL CCOOMMMMAANNDDSS
Each target may have associated with it a series of shell commands, nor-
mally used to create the target. Each of the commands in this script
_m_u_s_t be preceded by a tab. While any target may appear on a dependency
line, only one of these dependencies may be followed by a creation
script, unless the `::::' operator is used.
Each target may have associated with it one or more lines of shell com-
mands, normally used to create the target. Each of the lines in this
script _m_u_s_t be preceded by a tab. (For historical reasons, spaces are
not accepted.) While targets can appear in many dependency lines if
desired, by default only one of these rules may be followed by a creation
script. If the `::::' operator is used, however, all rules may include
scripts and the scripts are executed in the order found.
If the first characters of the command line are any combination of `@@',
`++', or `--', the command is treated specially. A `@@' causes the command
not to be echoed before it is executed. A `++' causes the command to be
executed even when --nn is given. This is similar to the effect of the
.MAKE special source, except that the effect can be limited to a single
line of a script. A `--' causes any non-zero exit status of the command
line to be ignored.
Each line is treated as a separate shell command, unless the end of line
is escaped with a backslash (`\') in which case that line and the next
are combined. If the first characters of the command are any combination
of `@@', `++', or `--', the command is treated specially. A `@@' causes the
command not to be echoed before it is executed. A `++' causes the command
to be executed even when --nn is given. This is similar to the effect of
the .MAKE special source, except that the effect can be limited to a sin-
gle line of a script. A `--' in compatibility mode causes any non-zero
exit status of the command line to be ignored.
When bbmmaakkee is run in jobs mode with --jj _m_a_x___j_o_b_s, the entire script for
the target is fed to a single instance of the shell.
In compatibility (non-jobs) mode, each command is run in a separate
process. If the command contains any shell meta characters
(`#=|^(){};&<>*?[]:$`\\n') it will be passed to the shell, otherwise
bbmmaakkee will attempt direct execution.
Since bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R' before executing any targets, each
child process starts with that as its current working directory.
the target is fed to a single instance of the shell. In compatibility
(non-jobs) mode, each command is run in a separate process. If the com-
mand contains any shell meta characters (`#=|^(){};&<>*?[]:$`\\n') it
will be passed to the shell; otherwise bbmmaakkee will attempt direct execu-
tion. If a line starts with `--' and the shell has ErrCtl enabled then
failure of the command line will be ignored as in compatibility mode.
Otherwise `--' affects the entire job; the script will stop at the first
command line that fails, but the target will not be deemed to have
failed.
Makefiles should be written so that the mode of bbmmaakkee operation does not
change their behavior. For example, any command which needs to use
``cd'' or ``chdir'', without side-effect should be put in parenthesis:
``cd'' or ``chdir'' without potentially changing the directory for subse-
quent commands should be put in parentheses so it executes in a subshell.
To force the use of one shell, escape the line breaks so as to make the
whole script one command. For example:
avoid-chdir-side-effects:
@echo Building $@ in `pwd`
@(cd ${.CURDIR} && ${.MAKE} $@)
@(cd ${.CURDIR} && ${MAKE} $@)
@echo Back in `pwd`
ensure-one-shell-regardless-of-mode:
@echo Building $@ in `pwd`; \
(cd ${.CURDIR} && ${.MAKE} $@); \
(cd ${.CURDIR} && ${MAKE} $@); \
echo Back in `pwd`
Since bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R' before executing any targets, each
child process starts with that as its current working directory.
VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Variables in make are much like variables in the shell, and, by tradi-
tion, consist of all upper-case letters.
@ -402,40 +411,47 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Variables defined as part of the command line.
Local variables
Variables that are defined specific to a certain target. The
seven local variables are as follows:
Variables that are defined specific to a certain target.
_._A_L_L_S_R_C The list of all sources for this target; also known as
`_>'.
Local variables are all built in and their values vary magically from
target to target. It is not currently possible to define new local vari-
ables. The seven local variables are as follows:
_._A_R_C_H_I_V_E The name of the archive file.
_._A_L_L_S_R_C The list of all sources for this target; also known as
`_>'.
_._I_M_P_S_R_C In suffix-transformation rules, the name/path of the
source from which the target is to be transformed (the
``implied'' source); also known as `_<'. It is not
defined in explicit rules.
_._A_R_C_H_I_V_E The name of the archive file; also known as `_!'.
_._M_E_M_B_E_R The name of the archive member.
_._I_M_P_S_R_C In suffix-transformation rules, the name/path of the
source from which the target is to be transformed (the
``implied'' source); also known as `_<'. It is not
defined in explicit rules.
_._O_O_D_A_T_E The list of sources for this target that were deemed
out-of-date; also known as `_?'.
_._M_E_M_B_E_R The name of the archive member; also known as `_%'.
_._P_R_E_F_I_X The file prefix of the target, containing only the file
portion, no suffix or preceding directory components;
also known as `_*'.
_._O_O_D_A_T_E The list of sources for this target that were deemed out-
of-date; also known as `_?'.
_._T_A_R_G_E_T The name of the target; also known as `_@'.
_._P_R_E_F_I_X The file prefix of the target, containing only the file
portion, no suffix or preceding directory components;
also known as `_*'. The suffix must be one of the known
suffixes declared with ..SSUUFFFFIIXXEESS or it will not be recog-
nized.
The shorter forms `_@', `_?', `_<', `_>', and `_*' are permitted for
backward compatibility with historical makefiles and are not rec-
ommended. The six variables `_@_F', `_@_D', `_<_F', `_<_D', `_*_F', and
`_*_D' are permitted for compatibility with AT&T System V UNIX
makefiles and are not recommended.
_._T_A_R_G_E_T The name of the target; also known as `_@'.
Four of the local variables may be used in sources on dependency
lines because they expand to the proper value for each target on
the line. These variables are `_._T_A_R_G_E_T', `_._P_R_E_F_I_X', `_._A_R_C_H_I_V_E',
and `_._M_E_M_B_E_R'.
The shorter forms (`_>', `_!', `_<', `_%', `_?', `_*', and `_@') are permitted
for backward compatibility with historical makefiles and legacy POSIX
make and are not recommended.
Variants of these variables with the punctuation followed immediately by
`D' or `F', e.g. `_$_(_@_D_)', are legacy forms equivalent to using the `:H'
and `:T' modifiers. These forms are accepted for compatibility with AT&T
System V UNIX makefiles and POSIX but are not recommended.
Four of the local variables may be used in sources on dependency lines
because they expand to the proper value for each target on the line.
These variables are `_._T_A_R_G_E_T', `_._P_R_E_F_I_X', `_._A_R_C_H_I_V_E', and `_._M_E_M_B_E_R'.
AAddddiittiioonnaall bbuuiilltt--iinn vvaarriiaabblleess
In addition, bbmmaakkee sets or knows about the following variables:
@ -1356,19 +1372,58 @@ FFIILLEESS
/usr/share/mk system makefile directory
CCOOMMPPAATTIIBBIILLIITTYY
The basic make syntax is compatible between different versions of make,
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 dependent nodes. The algo-
rithms used may change again in the future.
OOllddeerr vveerrssiioonnss
An incomplete list of changes in older versions of bbmmaakkee:
The way that .for loop variables are substituted changed after NetBSD 5.0
so that they still appear to be variable expansions. In particular this
stops them being treated as syntax, and removes some obscure problems
using them in .if statements.
The way that parallel makes are scheduled changed in NetBSD 4.0 so that
.ORDER and .WAIT apply recursively to the dependent nodes. The algo-
rithms used may change again in the future.
OOtthheerr mmaakkee ddiiaalleeccttss
Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not sup-
port most of the features of bbmmaakkee as described in this manual. Most
notably:
++oo The ..WWAAIITT and ..OORRDDEERR declarations and most functionality per-
taining to parallelization. (GNU make supports parallelization
but lacks these features needed to control it effectively.)
++oo Directives, including for loops and conditionals and most of
the forms of include files. (GNU make has its own incompatible
and less powerful syntax for conditionals.)
++oo All built-in variables that begin with a dot.
++oo Most of the special sources and targets that begin with a dot,
with the notable exception of ..PPHHOONNYY, ..PPRREECCIIOOUUSS, and ..SSUUFFFFIIXXEESS.
++oo Variable modifiers, except for the
:old=new
string substitution, which does not portably support globbing
with `%' and historically only works on declared suffixes.
++oo The $$>> variable even in its short form; most makes support this
functionality but its name varies.
Some features are somewhat more portable, such as assignment with ++==, ??==,
and !!==. The ..PPAATTHH functionality is based on an older feature VVPPAATTHH found
in GNU make and many versions of SVR4 make; however, historically its
behavior is too ill-defined (and too buggy) to rely upon.
The $$@@ and $$<< variables are more or less universally portable, as is the
$$((MMAAKKEE)) variable. Basic use of suffix rules (for files only in the cur-
rent directory, not trying to chain transformations together, etc.) is
also reasonably portable.
SSEEEE AALLSSOO
mkdep(1)
@ -1394,4 +1449,4 @@ BBUUGGSS
There is no way of escaping a space character in a filename.
NetBSD 5.1 February 14, 2014 NetBSD 5.1
NetBSD 5.1 April 9, 2015 NetBSD 5.1

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.94 2014/01/03 00:02:01 sjg Exp $ */
/* $NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 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: compat.c,v 1.94 2014/01/03 00:02:01 sjg Exp $";
static char rcsid[] = "$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: compat.c,v 1.94 2014/01/03 00:02:01 sjg Exp $");
__RCSID("$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $");
#endif
#endif /* not lint */
#endif

View File

@ -4247,6 +4247,8 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
if test -x /usr/bin/getconf; then
bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
# only a numeric response is useful
test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
fi
bmake_path_max=${bmake_path_max:-1024}
if test $bmake_path_max -gt 1024; then

View File

@ -1,6 +1,6 @@
dnl
dnl RCSid:
dnl $Id: configure.in,v 1.52 2014/02/15 22:27:59 sjg Exp $
dnl $Id: configure.in,v 1.53 2014/11/06 01:49:40 sjg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
@ -82,6 +82,8 @@ dnl
dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
if test -x /usr/bin/getconf; then
bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
# only a numeric response is useful
test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
fi
bmake_path_max=${bmake_path_max:-1024}
if test $bmake_path_max -gt 1024; then

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $ */
/* $NetBSD: job.c,v 1.180 2015/04/16 13:31:03 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: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $";
static char rcsid[] = "$NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $");
__RCSID("$NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -744,7 +744,6 @@ JobPrintCommand(void *cmdp, void *jobp)
shutUp = DEBUG(LOUD) ? FALSE : TRUE;
break;
case '-':
job->flags |= JOB_IGNERR;
errOff = TRUE;
break;
case '+':
@ -823,6 +822,7 @@ JobPrintCommand(void *cmdp, void *jobp)
* to ignore errors. Set cmdTemplate to use the weirdness
* instead of the simple "%s\n" template.
*/
job->flags |= JOB_IGNERR;
if (!(job->flags & JOB_SILENT) && !shutUp) {
if (commandShell->hasEchoCtl) {
DBPRINTF("%s\n", commandShell->echoOff);
@ -1376,7 +1376,8 @@ JobExec(Job *job, char **argv)
(void)fcntl(0, F_SETFD, 0);
(void)lseek(0, (off_t)0, SEEK_SET);
if (Always_pass_job_queue || (job->node->type & OP_MAKE)) {
if (Always_pass_job_queue ||
(job->node->type & (OP_MAKE | OP_SUBMAKE))) {
/*
* Pass job token pipe to submakes.
*/
@ -1910,16 +1911,16 @@ JobDoOutput(Job *job, Boolean finish)
(void)fflush(stdout);
}
}
if (i < max - 1) {
/* shift the remaining characters down */
(void)memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
/*
* max is the last offset still in the buffer. Move any remaining
* characters to the start of the buffer and update the end marker
* curPos.
*/
if (i < max) {
(void)memmove(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
job->curPos = max - (i + 1);
} else {
/*
* We have written everything out, so we just start over
* from the start of the buffer. No copying. No nothing.
*/
assert(i == max);
job->curPos = 0;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lst.h,v 1.18 2009/01/23 21:58:27 dsl Exp $ */
/* $NetBSD: lst.h,v 1.20 2014/09/07 20:55:34 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstInt.h,v 1.20 2009/01/24 14:43:29 dsl Exp $ */
/* $NetBSD: lstInt.h,v 1.22 2014/09/07 20:55:34 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993

View File

@ -1,4 +1,4 @@
/* $NetBSD: lstRemove.c,v 1.14 2008/12/13 15:19:29 dsl Exp $ */
/* $NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -33,14 +33,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.14 2008/12/13 15:19:29 dsl Exp $";
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 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.14 2008/12/13 15:19:29 dsl Exp $");
__RCSID("$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $");
#endif
#endif /* not lint */
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $ */
/* $NetBSD: main.c,v 1.232 2015/03/26 22:20:42 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.232 2015/03/26 22:20:42 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $");
__RCSID("$NetBSD: main.c,v 1.232 2015/03/26 22:20:42 sjg Exp $");
#endif
#endif /* not lint */
#endif
@ -99,14 +99,14 @@ __RCSID("$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $");
*
* Error Print a tagged error message. The global
* MAKE variable must have been defined. This
* takes a format string and two optional
* arguments for it.
* takes a format string and optional arguments
* for it.
*
* Fatal Print an error message and exit. Also takes
* a format string and two arguments.
* a format string and arguments for it.
*
* Punt Aborts all jobs and exits with a message. Also
* takes a format string and two arguments.
* takes a format string and arguments for it.
*
* Finish Finish things up by printing the number of
* errors which occurred, as passed to it, and
@ -1522,7 +1522,8 @@ Cmd_Exec(const char *cmd, const char **errnum)
WAIT_T status; /* command exit status */
Buffer buf; /* buffer to store the result */
char *cp;
int cc;
int cc; /* bytes read, or -1 */
int savederr; /* saved errno */
*errnum = NULL;
@ -1579,6 +1580,7 @@ Cmd_Exec(const char *cmd, const char **errnum)
*/
(void)close(fds[1]);
savederr = 0;
Buf_Init(&buf, 0);
do {
@ -1588,6 +1590,8 @@ Cmd_Exec(const char *cmd, const char **errnum)
Buf_AddBytes(&buf, cc, result);
}
while (cc > 0 || (cc == -1 && errno == EINTR));
if (cc == -1)
savederr = errno;
/*
* Close the input side of the pipe.
@ -1604,7 +1608,7 @@ Cmd_Exec(const char *cmd, const char **errnum)
cc = Buf_Size(&buf);
res = Buf_Destroy(&buf, FALSE);
if (cc == 0)
if (savederr != 0)
*errnum = "Couldn't read shell's output for \"%s\"";
if (WIFSIGNALED(status))

View File

@ -1,4 +1,4 @@
.\" $NetBSD: make.1,v 1.230 2014/02/15 18:55:30 sjg Exp $
.\" $NetBSD: make.1,v 1.247 2015/04/10 08:43:32 wiz 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 February 14, 2014
.Dd April 9, 2015
.Dt MAKE 1
.Os
.Sh NAME
@ -209,8 +209,6 @@ Force the
option to print raw values of variables.
.It Ar v
Print debugging information about variable assignment.
.It Ar w
Print entering and leaving directory messages, pre and post processing.
.It Ar x
Run shell commands with
.Fl x
@ -352,6 +350,8 @@ contains a
then the value will be expanded before printing.
.It Fl W
Treat any warnings during makefile parsing as errors.
.It Fl w
Print entering and leaving directory messages, pre and post processing.
.It Fl X
Don't export variables passed on the command line to the environment
individually.
@ -441,17 +441,29 @@ The value
need not necessarily be used to describe existing files.
Expansion is in directory order, not alphabetically as done in the shell.
.Sh SHELL COMMANDS
Each target may have associated with it a series of shell commands, normally
Each target may have associated with it one or more lines of shell
commands, normally
used to create the target.
Each of the commands in this script
Each of the lines in this script
.Em must
be preceded by a tab.
While any target may appear on a dependency line, only one of these
dependencies may be followed by a creation script, unless the
(For historical reasons, spaces are not accepted.)
While targets can appear in many dependency lines if desired, by
default only one of these rules may be followed by a creation
script.
If the
.Ql Ic \&::
operator is used.
operator is used, however, all rules may include scripts and the
scripts are executed in the order found.
.Pp
If the first characters of the command line are any combination of
Each line is treated as a separate shell command, unless the end of
line is escaped with a backslash
.Pq Ql \e
in which case that line and the next are combined.
.\" The escaped newline is retained and passed to the shell, which
.\" normally ignores it.
.\" However, the tab at the beginning of the following line is removed.
If the first characters of the command are any combination of
.Ql Ic @ ,
.Ql Ic + ,
or
@ -469,6 +481,7 @@ This is similar to the effect of the .MAKE special source,
except that the effect can be limited to a single line of a script.
A
.Ql Ic \-
in compatibility mode
causes any non-zero exit status of the command line to be ignored.
.Pp
When
@ -477,13 +490,45 @@ is run in jobs mode with
.Fl j Ar max_jobs ,
the entire script for the target is fed to a
single instance of the shell.
.Pp
In compatibility (non-jobs) mode, each command is run in a separate process.
If the command contains any shell meta characters
.Pq Ql #=|^(){};&<>*?[]:$`\e\en
it will be passed to the shell, otherwise
it will be passed to the shell; otherwise
.Nm
will attempt direct execution.
If a line starts with
.Ql Ic \-
and the shell has ErrCtl enabled then failure of the command line
will be ignored as in compatibility mode.
Otherwise
.Ql Ic \-
affects the entire job;
the script will stop at the first command line that fails,
but the target will not be deemed to have failed.
.Pp
Makefiles should be written so that the mode of
.Nm
operation does not change their behavior.
For example, any command which needs to use
.Dq cd
or
.Dq chdir
without potentially changing the directory for subsequent commands
should be put in parentheses so it executes in a subshell.
To force the use of one shell, escape the line breaks so as to make
the whole script one command.
For example:
.Bd -literal -offset indent
avoid-chdir-side-effects:
@echo Building $@ in `pwd`
@(cd ${.CURDIR} && ${MAKE} $@)
@echo Back in `pwd`
ensure-one-shell-regardless-of-mode:
@echo Building $@ in `pwd`; \e
(cd ${.CURDIR} && ${MAKE} $@); \e
echo Back in `pwd`
.Ed
.Pp
Since
.Nm
@ -493,27 +538,6 @@ to
.Ql Va .OBJDIR
before executing any targets, each child process
starts with that as its current working directory.
.Pp
Makefiles should be written so that the mode of
.Nm
operation does not change their behavior.
For example, any command which needs to use
.Dq cd
or
.Dq chdir ,
without side-effect should be put in parenthesis:
.Bd -literal -offset indent
avoid-chdir-side-effects:
@echo Building $@ in `pwd`
@(cd ${.CURDIR} && ${.MAKE} $@)
@echo Back in `pwd`
ensure-one-shell-regardless-of-mode:
@echo Building $@ in `pwd`; \\
(cd ${.CURDIR} && ${.MAKE} $@); \\
echo Back in `pwd`
.Ed
.Sh VARIABLE ASSIGNMENTS
Variables in make are much like variables in the shell, and, by tradition,
consist of all upper-case letters.
@ -624,13 +648,19 @@ Variables defined in the makefile or in included makefiles.
Variables defined as part of the command line.
.It Local variables
Variables that are defined specific to a certain target.
.El
.Pp
Local variables are all built in and their values vary magically from
target to target.
It is not currently possible to define new local variables.
The seven local variables are as follows:
.Bl -tag -width ".ARCHIVE"
.Bl -tag -width ".ARCHIVE" -offset indent
.It Va .ALLSRC
The list of all sources for this target; also known as
.Ql Va \&\*[Gt] .
.It Va .ARCHIVE
The name of the archive file.
The name of the archive file; also known as
.Ql Va \&! .
.It Va .IMPSRC
In suffix-transformation rules, the name/path of the source from which the
target is to be transformed (the
@ -639,7 +669,8 @@ source); also known as
.Ql Va \&\*[Lt] .
It is not defined in explicit rules.
.It Va .MEMBER
The name of the archive member.
The name of the archive member; also known as
.Ql Va % .
.It Va .OODATE
The list of sources for this target that were deemed out-of-date; also
known as
@ -648,31 +679,41 @@ known as
The file prefix of the target, containing only the file portion, no suffix
or preceding directory components; also known as
.Ql Va * .
The suffix must be one of the known suffixes declared with
.Ic .SUFFIXES
or it will not be recognized.
.It Va .TARGET
The name of the target; also known as
.Ql Va @ .
.El
.Pp
The shorter forms
.Ql Va @ ,
.Ql ( Va \*[Gt] ,
.Ql Va \&! ,
.Ql Va \*[Lt] ,
.Ql Va % ,
.Ql Va \&? ,
.Ql Va \&\*[Lt] ,
.Ql Va \&\*[Gt] ,
.Ql Va * ,
and
.Ql Va *
.Ql Va @ )
are permitted for backward
compatibility with historical makefiles and are not recommended.
The six variables
.Ql Va "@F" ,
.Ql Va "@D" ,
.Ql Va "\*[Lt]F" ,
.Ql Va "\*[Lt]D" ,
.Ql Va "*F" ,
compatibility with historical makefiles and legacy POSIX make and are
not recommended.
.Pp
Variants of these variables with the punctuation followed immediately by
.Ql D
or
.Ql F ,
e.g.
.Ql Va $(@D) ,
are legacy forms equivalent to using the
.Ql :H
and
.Ql Va "*D"
are permitted for compatibility with
.Ql :T
modifiers.
These forms are accepted for compatibility with
.At V
makefiles and are not recommended.
makefiles and POSIX but are not recommended.
.Pp
Four of the local variables may be used in sources on dependency lines
because they expand to the proper value for each target on the line.
@ -682,7 +723,6 @@ These variables are
.Ql Va .ARCHIVE ,
and
.Ql Va .MEMBER .
.El
.Ss Additional built-in variables
In addition,
.Nm
@ -2130,19 +2170,87 @@ system makefile
system makefile directory
.El
.Sh COMPATIBILITY
The basic make syntax is compatible between different versions of make,
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 dependent nodes.
The algorithms used may change again in the future.
.Ss Older versions
An incomplete list of changes in older versions of
.Nm :
.Pp
The way that .for loop variables are substituted changed after
.Nx 5.0
so that they still appear to be variable expansions.
In particular this stops them being treated as syntax, and removes some
obscure problems using them in .if statements.
.Pp
The way that parallel makes are scheduled changed in
.Nx 4.0
so that .ORDER and .WAIT apply recursively to the dependent nodes.
The algorithms used may change again in the future.
.Ss Other make dialects
Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
support most of the features of
.Nm
as described in this manual.
Most notably:
.Bl -bullet -offset indent
.It
The
.Ic .WAIT
and
.Ic .ORDER
declarations and most functionality pertaining to parallelization.
(GNU make supports parallelization but lacks these features needed to
control it effectively.)
.It
Directives, including for loops and conditionals and most of the
forms of include files.
(GNU make has its own incompatible and less powerful syntax for
conditionals.)
.It
All built-in variables that begin with a dot.
.It
Most of the special sources and targets that begin with a dot,
with the notable exception of
.Ic .PHONY ,
.Ic .PRECIOUS ,
and
.Ic .SUFFIXES .
.It
Variable modifiers, except for the
.Dl :old=new
string substitution, which does not portably support globbing with
.Ql %
and historically only works on declared suffixes.
.It
The
.Ic $>
variable even in its short form; most makes support this functionality
but its name varies.
.El
.Pp
Some features are somewhat more portable, such as assignment with
.Ic += ,
.Ic ?= ,
and
.Ic != .
The
.Ic .PATH
functionality is based on an older feature
.Ic VPATH
found in GNU make and many versions of SVR4 make; however,
historically its behavior is too ill-defined (and too buggy) to rely
upon.
.Pp
The
.Ic $@
and
.Ic $<
variables are more or less universally portable, as is the
.Ic $(MAKE)
variable.
Basic use of suffix rules (for files only in the current directory,
not trying to chain transformations together, etc.) is also reasonably
portable.
.Sh SEE ALSO
.Xr mkdep 1
.Sh HISTORY

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $ */
/* $NetBSD: make.c,v 1.91 2014/10/18 08:33:30 snj Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $";
static char rcsid[] = "$NetBSD: make.c,v 1.91 2014/10/18 08:33:30 snj 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.88 2012/11/09 18:53:05 sjg Exp $");
__RCSID("$NetBSD: make.c,v 1.91 2014/10/18 08:33:30 snj Exp $");
#endif
#endif /* not lint */
#endif
@ -563,7 +563,7 @@ MakeHandleUse(void *cgnp, void *pgnp)
* in the comments below.
*
* Results:
* returns 0 if the gnode does not exist, or it's filesystem
* returns 0 if the gnode does not exist, or its filesystem
* time if it does.
*
* Side Effects:

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.92 2013/09/04 15:38:26 sjg Exp $ */
/* $NetBSD: make.h,v 1.95 2014/09/07 20:55:34 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -289,6 +289,7 @@ typedef struct GNode {
#define OP_NOMETA 0x00080000 /* .NOMETA do not create a .meta file */
#define OP_META 0x00100000 /* .META we _do_ want a .meta file */
#define OP_NOMETA_CMP 0x00200000 /* Do not compare commands in .meta file */
#define OP_SUBMAKE 0x00400000 /* Possibly a submake 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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: meta.c,v 1.33 2013/10/01 05:37:17 sjg Exp $ */
/* $NetBSD: meta.c,v 1.38 2015/04/11 05:24:30 sjg Exp $ */
/*
* Implement 'meta' mode.
@ -155,8 +155,8 @@ filemon_open(BuildMon *pbm)
static void
filemon_read(FILE *mfp, int fd)
{
FILE *fp;
char buf[BUFSIZ];
int n;
/* Check if we're not writing to a meta data file.*/
if (mfp == NULL) {
@ -166,17 +166,14 @@ filemon_read(FILE *mfp, int fd)
}
/* rewind */
(void)lseek(fd, (off_t)0, SEEK_SET);
if ((fp = fdopen(fd, "r")) == NULL)
err(1, "Could not read build monitor file '%d'", fd);
fprintf(mfp, "\n-- filemon acquired metadata --\n");
while (fgets(buf, sizeof(buf), fp)) {
fprintf(mfp, "%s", buf);
while ((n = read(fd, buf, sizeof(buf))) > 0) {
fwrite(buf, 1, n, mfp);
}
fflush(mfp);
clearerr(fp);
fclose(fp);
close(fd);
}
#endif
@ -662,17 +659,21 @@ meta_job_child(Job *job)
{
#ifdef USE_FILEMON
BuildMon *pbm;
pid_t pid;
if (job != NULL) {
pbm = &job->bm;
} else {
pbm = &Mybm;
}
pid = getpid();
if (pbm->mfp != NULL && useFilemon) {
if (ioctl(pbm->filemon_fd, FILEMON_SET_PID, &pid) < 0) {
err(1, "Could not set filemon pid!");
if (pbm->mfp != NULL) {
close(fileno(pbm->mfp));
if (useFilemon) {
pid_t pid;
pid = getpid();
if (ioctl(pbm->filemon_fd, FILEMON_SET_PID, &pid) < 0) {
err(1, "Could not set filemon pid!");
}
}
}
#endif
@ -844,9 +845,10 @@ string_match(const void *p, const void *q)
/*
* When running with 'meta' functionality, a target can be out-of-date
* if any of the references in it's meta data file is more recent.
* if any of the references in its meta data file is more recent.
* We have to track the latestdir on a per-process basis.
*/
#define LCWD_VNAME_FMT ".meta.%d.lcwd"
#define LDIR_VNAME_FMT ".meta.%d.ldir"
/*
@ -872,11 +874,14 @@ meta_oodate(GNode *gn, Boolean oodate)
{
static char *tmpdir = NULL;
static char cwd[MAXPATHLEN];
char lcwd_vname[64];
char ldir_vname[64];
char lcwd[MAXPATHLEN];
char latestdir[MAXPATHLEN];
char fname[MAXPATHLEN];
char fname1[MAXPATHLEN];
char fname2[MAXPATHLEN];
char fname3[MAXPATHLEN];
char *p;
char *cp;
char *link_src;
@ -928,6 +933,8 @@ meta_oodate(GNode *gn, Boolean oodate)
err(1, "Could not get current working directory");
cwdlen = strlen(cwd);
}
strlcpy(lcwd, cwd, sizeof(lcwd));
strlcpy(latestdir, cwd, sizeof(latestdir));
if (!tmpdir) {
tmpdir = getTmpdir();
@ -1011,9 +1018,11 @@ meta_oodate(GNode *gn, Boolean oodate)
char *tp;
if (lastpid > 0) {
/* We need to remember this. */
/* We need to remember these. */
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
Var_Set(ldir_vname, latestdir, VAR_GLOBAL, 0);
}
snprintf(lcwd_vname, sizeof(lcwd_vname), LCWD_VNAME_FMT, pid);
snprintf(ldir_vname, sizeof(ldir_vname), LDIR_VNAME_FMT, pid);
lastpid = pid;
ldir = Var_Value(ldir_vname, VAR_GLOBAL, &tp);
@ -1021,15 +1030,22 @@ meta_oodate(GNode *gn, Boolean oodate)
strlcpy(latestdir, ldir, sizeof(latestdir));
if (tp)
free(tp);
} else
strlcpy(latestdir, cwd, sizeof(latestdir));
}
ldir = Var_Value(lcwd_vname, VAR_GLOBAL, &tp);
if (ldir) {
strlcpy(lcwd, ldir, sizeof(lcwd));
if (tp)
free(tp);
}
}
/* Skip past the pid. */
if (strsep(&p, " ") == NULL)
continue;
#ifdef DEBUG_META_MODE
if (DEBUG(META))
fprintf(debug_file, "%s: %d: cwd=%s ldir=%s\n", fname, lineno, cwd, latestdir);
fprintf(debug_file, "%s: %d: %d: %c: cwd=%s lcwd=%s ldir=%s\n",
fname, lineno,
pid, buf[0], cwd, lcwd, latestdir);
#endif
break;
}
@ -1039,6 +1055,7 @@ meta_oodate(GNode *gn, Boolean oodate)
/* Process according to record type. */
switch (buf[0]) {
case 'X': /* eXit */
Var_Delete(lcwd_vname, VAR_GLOBAL);
Var_Delete(ldir_vname, VAR_GLOBAL);
lastpid = 0; /* no need to save ldir_vname */
break;
@ -1050,15 +1067,30 @@ meta_oodate(GNode *gn, Boolean oodate)
child = atoi(p);
if (child > 0) {
snprintf(cldir, sizeof(cldir), LCWD_VNAME_FMT, child);
Var_Set(cldir, lcwd, VAR_GLOBAL, 0);
snprintf(cldir, sizeof(cldir), LDIR_VNAME_FMT, child);
Var_Set(cldir, latestdir, VAR_GLOBAL, 0);
#ifdef DEBUG_META_MODE
if (DEBUG(META))
fprintf(debug_file, "%s: %d: %d: cwd=%s lcwd=%s ldir=%s\n",
fname, lineno,
child, cwd, lcwd, latestdir);
#endif
}
}
break;
case 'C': /* Chdir */
/* Update the latest directory. */
strlcpy(latestdir, p, sizeof(latestdir));
/* Update lcwd and latest directory. */
strlcpy(latestdir, p, sizeof(latestdir));
strlcpy(lcwd, p, sizeof(lcwd));
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
Var_Set(ldir_vname, lcwd, VAR_GLOBAL, 0);
#ifdef DEBUG_META_MODE
if (DEBUG(META))
fprintf(debug_file, "%s: %d: cwd=%s ldir=%s\n", fname, lineno, cwd, lcwd);
#endif
break;
case 'M': /* renaMe */
@ -1207,11 +1239,16 @@ meta_oodate(GNode *gn, Boolean oodate)
snprintf(fname1, sizeof(fname1), "%s/%s", latestdir, p);
sdirs[sdx++] = fname1;
if (strcmp(latestdir, cwd) != 0) {
/* Check vs cwd */
snprintf(fname2, sizeof(fname2), "%s/%s", cwd, p);
if (strcmp(latestdir, lcwd) != 0) {
/* Check vs lcwd */
snprintf(fname2, sizeof(fname2), "%s/%s", lcwd, p);
sdirs[sdx++] = fname2;
}
if (strcmp(lcwd, cwd) != 0) {
/* Check vs cwd */
snprintf(fname3, sizeof(fname3), "%s/%s", cwd, p);
sdirs[sdx++] = fname3;
}
}
sdirs[sdx++] = NULL;
@ -1250,6 +1287,10 @@ meta_oodate(GNode *gn, Boolean oodate)
oodate = TRUE;
}
}
if (buf[0] == 'E') {
/* previous latestdir is no longer relevant */
strlcpy(latestdir, lcwd, sizeof(latestdir));
}
break;
default:
break;

View File

@ -1,3 +1,111 @@
2015-04-16 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20150411
bump version
* own.mk: put AUTO_OBJ in OPTIONS_DEFAULT_NO rather than YES.
it is here mainly for documentation purposes, since
if using auto.obj.mk it is better done via sys.mk
2015-04-01 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20150401
* meta2deps.sh: support @list
* meta2deps.py: updates from Juniper
o add EXCLUDES
o skip bogus input files.
o treat 'M' and 'L' as both an 'R' and a 'W'
2015-03-03 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20150303
* dirdeps.mk: if MK_DIRDEPS_CACHE is yes, use dirdeps-cache
which is built via sub-make so we have a .meta file to tell if
it is out-of-date.
The dirdeps-cache contains the same dependency rules that we
normaly construct on the fly.
This adds a few seconds overhead when the cache is out of date,
but for a large target, the savings can be significant (10-20min).
2014-11-18 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20141118
* meta.stage.mk: add stale_staged
* dirdeps.mk (_DIRDEP_USE_LEVEL): allow this to be tweaked
only useful under very rare conditions such as
FreeBSD's make universe.
* auto.obj.mk: Allow MK_AUTO_OBJ to set MKOBJDIRS=auto
2014-11-11 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20141111
* mkopt.sh: use consistent semantics for _mk_opt and _mk_opts
2014-11-09 Simon J. Gerraty <sjg@bad.crufty.net>
* FILES: include mkopt.sh which allows handling options in shell
scripts in a manner compatible with options.mk
2014-10-12 Simon J. Gerraty <sjg@bad.crufty.net>
* meta.stage.mk: ensure only _STAGED_DIRS under objroot are used
for GENDIRDEPS_FILTER to avoid surprises.
2014-10-10 Simon J. Gerraty <sjg@bad.crufty.net>
* dirdeps.mk (NSkipHostDir): this needs SRCTOP prepended since by
the time it is applied to __depdirs they have.
* dirdeps.mk fix filtering of _machines since M_dep_qual_fixes
expects patterns like *.${MACHINE}
* cython.mk (pyprefix?): use pyprefix to find python bits
since prefix might be something else (where we install our
stuff)
2014-09-11 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20140911
* dirdeps.mk: add bootstrap target to simplify adding support for
new MACHINE.
2014-09-01 Simon J. Gerraty <sjg@bad.crufty.net>
* gendirdeps.mk: Add handling of GENDIRDEPS_FILTER_DIR_VARS and
GENDIRDEPS_FILTER_VARS to make it easier to produce sharable
Makefile.depend files.
2014-08-28 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20140828
* cython.mk: capture logic for building python extension modules
with Cython.
2014-08-08 Simon J. Gerraty <sjg@bad.crufty.net>
* meta.stage.mk (_STAGE_AS_BASENAME_USE): Add StageAs variant
2014-08-02 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20140801
* dep.mk: use explicit MKDEP_MK rather than overload MKDEP to
identify the autodep.mk variant.
* sys.dependfile.mk: delete .MAKE.DEPENDFILE if its
initial value does not match .MAKE.DEPENDFILE_PREFIX
* meta.autodep.mk: if _bootstrap_dirdeps add RELDIR to DIRDEPS
2014-05-22 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20140522

View File

@ -5,6 +5,7 @@ auto.obj.mk
autoconf.mk
autodep.mk
auto.dep.mk
cython.mk
dep.mk
doc.mk
dpadd.mk
@ -20,7 +21,9 @@ libnames.mk
libs.mk
links.mk
man.mk
manifest.mk
mk-files.txt
mkopt.sh
nls.mk
obj.mk
options.mk
@ -49,6 +52,7 @@ sys/SunOS.mk
sys/UnixWare.mk
target-flags.mk
warnings.mk
whats.mk
yacc.mk
dirdeps.mk
gendirdeps.mk

View File

@ -1,6 +1,6 @@
#
# RCSid:
# $Id: auto.dep.mk,v 1.2 2010/04/19 17:37:19 sjg Exp $
# $Id: auto.dep.mk,v 1.3 2014/08/04 05:19:10 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
#
@ -18,7 +18,7 @@
# This module provides automagic dependency generation along the
# lines suggested in the GNU make.info
# set MKDEP=auto.dep and dep.mk will include us
# set MKDEP_MK=auto.dep.mk and dep.mk will include us
# This version differs from autodep.mk, in that
# we use ${.TARGET:T}.d rather than ${.TARGET:T:R}.d

View File

@ -1,4 +1,4 @@
# $Id: auto.obj.mk,v 1.8 2011/08/08 17:35:20 sjg Exp $
# $Id: auto.obj.mk,v 1.10 2015/04/16 16:59:00 sjg Exp $
#
# @(#) Copyright (c) 2004, Simon J. Gerraty
#
@ -34,10 +34,14 @@ Mkdirs= Mkdirs() { \
# if MKOBJDIRS is set to auto (and NOOBJ isn't defined) do some magic...
# This will automatically create objdirs as needed.
# Skip it if we are just doing 'clean'.
.if ${MK_AUTO_OBJ:Uno} == "yes"
MKOBJDIRS= auto
.endif
.if !defined(NOOBJ) && !defined(NO_OBJ) && ${MKOBJDIRS:Uno} == auto
# Use __objdir here so it is easier to tweak without impacting
# the logic.
__objdir?= ${MAKEOBJDIR}
__objdir:= ${__objdir:tA}
.if ${.OBJDIR} != ${__objdir}
# We need to chdir, make the directory if needed
.if !exists(${__objdir}/) && \
@ -46,11 +50,12 @@ __objdir?= ${MAKEOBJDIR}
__objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \
${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \
${Mkdirs}; Mkdirs ${__objdir}
__objdir:= ${__objdir:tA}
.endif
# This causes make to use the specified directory as .OBJDIR
.OBJDIR: ${__objdir}
.if ${.OBJDIR} != ${__objdir} && ${__objdir_made:Uno:M${__objdir}/*} != ""
.error could not use ${__objdir}
.error could not use ${__objdir}: .OBJDIR=${.OBJDIR}
.endif
.endif
.endif

View File

@ -1,6 +1,6 @@
#
# RCSid:
# $Id: autodep.mk,v 1.33 2014/04/05 22:56:54 sjg Exp $
# $Id: autodep.mk,v 1.34 2014/08/04 05:12:27 sjg Exp $
#
# @(#) Copyright (c) 1999-2010, Simon J. Gerraty
#
@ -19,14 +19,9 @@
# The depend target is mainly for backwards compatibility,
# dependencies are normally updated as part of compilation.
# set MKDEP=autodep and dep.mk will include us
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
# different versions of bsd.dep.mk use these
MKDEP=autodep
MKDEPCMD=autodep
DEPENDFILE?= .depend
.for d in ${DEPENDFILE:N.depend}
# bmake only groks .depend

View File

@ -0,0 +1,96 @@
# RCSid:
# $Id: cython.mk,v 1.6 2014/10/15 06:23:51 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
# this is what we build
CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so
CYTHON_MODULE_NAME?= it
CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx
# this is where we save generated src
CYTHON_SAVEGENDIR?= ${.CURDIR}/gen
# pyprefix is where python bits are
# which may not be where we want to put ours (prefix)
.if exists(/usr/pkg/include)
pyprefix?= /usr/pkg
.endif
pyprefix?= /usr/local
PYTHON_VERSION?= 2.7
PYTHON_H?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h
PYVERSION:= ${PYTHON_VERSION:C,\..*,,}
# set this empty if you don't want to handle multiple versions
.if !defined(CYTHON_PYVERSION)
CYTHON_PYVERSION:= ${PYVERSION}
.endif
CFLAGS+= -I${PYTHON_H:H}
CYTHON_GENSRCS= ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,}
SRCS+= ${CYTHON_GENSRCS}
.SUFFIXES: .pyx .c .So
CYTHON?= ${pyprefix}/bin/cython
# if we don't have cython we can use pre-generated srcs
.if ${type ${CYTHON} 2> /dev/null || echo:L:sh:M/*} == ""
.PATH: ${CYTHON_SAVEGENDIR}
.else
.if !empty(CYTHON_PYVERSION)
.for c in ${CYTHON_SRCS}
${c:R}${CYTHON_PYVERSION}.${c:E}: $c
ln -sf ${.ALLSRC:M*pyx} ${.TARGET}
.endfor
.endif
.pyx.c:
${CYTHON} ${CYTHON_FLAGS} -${PYVERSION} -o ${.TARGET} ${.IMPSRC}
save-gen: ${CYTHON_GENSRCS}
mkdir -p ${CYTHON_SAVEGENDIR}
cp -p ${.ALLSRC} ${CYTHON_SAVEGENDIR}
.endif
COMPILE.c?= ${CC} -c ${CFLAGS}
.c.So:
${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
${CYTHON_MODULE}: ${SRCS:S,.c,.So,}
${CC} ${CC_SHARED:U-shared} -o ${.TARGET} ${.ALLSRC:M*.So} ${LDADD}
# conf.host_target() is limited to uname -m rather than uname -p
_HOST_MACHINE!= uname -m
.if ${HOST_TARGET:M*${_HOST_MACHINE}} == ""
PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},}
.endif
MODULE_BINDIR?= ${.CURDIR:H}/${PY_HOST_TARGET:U${HOST_TARGET}}
build-cython-module: ${CYTHON_MODULE}
install-cython-module: ${CYTHON_MODULE}
test -d ${DESTDIR}${MODULE_BINDIR} || \
${INSTALL} -d ${DESTDIR}${MODULE_BINDIR}
${INSTALL} -m 755 ${.ALLSRC} ${DESTDIR}${MODULE_BINDIR}
CLEANFILES+= *.So ${CYTHON_MODULE}

View File

@ -1,4 +1,4 @@
# $Id: dep.mk,v 1.16 2012/11/11 22:37:02 sjg Exp $
# $Id: dep.mk,v 1.17 2014/08/04 05:12:27 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@ -34,21 +34,15 @@ MKDEP ?= ${MKDEP_CMD}
.NOPATH: .depend
.if ${MKDEP} == "auto.dep" && make(depend)
.if ${MKDEP_MK:Uno} == "auto.dep.mk" && make(depend)
# auto.dep.mk does not "do" depend
MK_AUTODEP= no
.endif
.if ${MK_AUTODEP} == yes
.if ${MKDEP:T:S,auto,,} != ${MKDEP:T}
.include <${MKDEP}.mk>
MKDEP_MK ?= autodep.mk
.include <${MKDEP_MK}>
.else
.include <autodep.mk>
.endif
.else
.if ${MKDEP:T:S,auto,,} != ${MKDEP:T}
MKDEP = ${MKDEP_CMD}
.endif
MKDEP_ENV_VARS += CC CXX
.for v in ${MKDEP_ENV_VARS:O:u}
.if !empty($v)

View File

@ -1,4 +1,4 @@
# $Id: dirdeps.mk,v 1.35 2014/05/03 06:27:56 sjg Exp $
# $Id: dirdeps.mk,v 1.49 2015/03/11 21:39:28 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@ -111,7 +111,9 @@
# TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
#
.if ${.MAKE.LEVEL} == 0
# touch this at your peril
_DIRDEP_USE_LEVEL?= 0
.if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL}
# only the first instance is interested in all this
# First off, we want to know what ${MACHINE} to build for.
@ -121,6 +123,12 @@
.if !target(_DIRDEP_USE)
# do some setup we only need once
_CURDIR ?= ${.CURDIR}
_OBJDIR ?= ${.OBJDIR}
now_utc = ${%s:L:gmtime}
.if !defined(start_utc)
start_utc := ${now_utc}
.endif
# make sure these are empty to start with
_DEP_TARGET_SPEC =
@ -201,7 +209,7 @@ _last_dependfile := ${.INCLUDEDFROMFILE:M${.MAKE.DEPENDFILE_PREFIX}*}
.else
_last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]}
.endif
.if !empty(_debug_reldir)
.if ${_debug_reldir:U0}
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _last_dependfile='${_last_dependfile}'
.endif
@ -260,7 +268,7 @@ _DEP_RELDIR := ${DEP_RELDIR}
# things we skip for host tools
SKIP_HOSTDIR ?=
NSkipHostDir = ${SKIP_HOSTDIR:N*.host:S,$,.host,:N.host:${M_ListToSkip}}
NSkipHostDir = ${SKIP_HOSTDIR:N*.host*:S,$,.host*,:N.host*:S,^,${SRCTOP}/,:${M_ListToSkip}}
# things we always skip
# SKIP_DIRDEPS allows for adding entries on command line.
@ -332,8 +340,78 @@ _only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}}
DIRDEPS ?= ${RELDIR}
.endif # target
_debug_reldir := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@}
_debug_search := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@}
# if repeatedly building the same target,
# we can avoid the overhead of re-computing the tree dependencies.
MK_DIRDEPS_CACHE ?= no
BUILD_DIRDEPS_CACHE ?= no
BUILD_DIRDEPS ?= yes
.if !defined(NO_DIRDEPS)
.if ${MK_DIRDEPS_CACHE} == "yes"
# this is where we will cache all our work
DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,^,.,:N.}
# just ensure this exists
build-dirdeps:
M_oneperline = @x@\\${.newline} $$x@
.if ${BUILD_DIRDEPS_CACHE} == "no"
.if !target(dirdeps-cached)
# we do this via sub-make
BUILD_DIRDEPS = no
dirdeps: dirdeps-cached
dirdeps-cached: ${DIRDEPS_CACHE} .MAKE
@echo "${TRACER}Using ${DIRDEPS_CACHE}"
@MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \
dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no
# these should generally do
BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE}
BUILD_DIRDEPS_TARGETS ?= ${.TARGETS}
# we need the .meta file to ensure we update if
# any of the Makefile.depend* changed.
# We do not want to compare the command line though.
${DIRDEPS_CACHE}: .META .NOMETA_CMP
+@{ echo '# Autogenerated - do NOT edit!'; echo; \
echo 'BUILD_DIRDEPS=no'; echo; \
echo '.include <dirdeps.mk>'; \
} > ${.TARGET}.new
+@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \
DIRDEPS="${DIRDEPS}" \
MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \
${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \
3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g' >> ${.TARGET}.new && \
mv ${.TARGET}.new ${.TARGET}
.endif
.elif !target(_count_dirdeps)
# we want to capture the dirdeps count in the cache
.END: _count_dirdeps
_count_dirdeps: .NOMETA
@echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3
.endif
.endif
.elif !target(_count_dirdeps)
beforedirdeps: _count_dirdeps
_count_dirdeps: .NOMETA
@echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"
.endif
.if ${BUILD_DIRDEPS} == "yes"
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
_debug_reldir = 1
.else
_debug_reldir = 0
.endif
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != ""
_debug_search = 1
.else
_debug_search = 0
.endif
# the rest is done repeatedly for every Makefile.depend we read.
# if we are anything but the original dir we care only about the
@ -368,7 +446,8 @@ _machines := ${_machines:O:u}
# we need to tweak _machines
_dm := ${DEP_MACHINE}
# apply the same filtering that we do when qualifying DIRDEPS.
_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@:${M_dep_qual_fixes:ts:}:O:u}
# M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.'
_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,}
DEP_MACHINE := ${_dm}
.endif
@ -388,7 +467,7 @@ _build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@}
.endif
.endif
.if !empty(_debug_reldir)
.if ${_debug_reldir}
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: DIRDEPS='${DIRDEPS}'
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}'
.endif
@ -419,7 +498,7 @@ __hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${
__qual_depdirs += ${__hostdpadd}
.endif
.if !empty(_debug_reldir)
.if ${_debug_reldir}
.info depdirs=${__depdirs}
.info qualified=${__qual_depdirs}
.info unqualified=${__unqual_depdirs}
@ -429,7 +508,8 @@ __qual_depdirs += ${__hostdpadd}
_build_dirs += \
${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \
${__qual_depdirs:N*.host} \
${_machines:@m@${__unqual_depdirs:@d@$d.$m@}@}
${_machines:Mhost*:@m@${__unqual_depdirs:@d@$d.$m@}@:${NSkipHostDir}:N.host} \
${_machines:Nhost*:@m@${__unqual_depdirs:@d@$d.$m@}@}
# qualify everything now
_build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
@ -441,11 +521,17 @@ _build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
# but if we want to count the number of Makefile.depend* read, we do.
.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == ""
.if !empty(_build_dirs)
.if ${BUILD_DIRDEPS_CACHE} == "yes"
x!= { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \
echo 'dirdeps: ${_build_dirs:${M_oneperline}}'; echo; } >&3; echo
x!= { ${_build_dirs:@x@${target($x):?:echo '$x: _DIRDEP_USE';}@} echo; } >&3; echo
.else
# this makes it all happen
dirdeps: ${_build_dirs}
.endif
${_build_dirs}: _DIRDEP_USE
.if !empty(_debug_reldir)
.if ${_debug_reldir}
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: needs: ${_build_dirs}
.endif
@ -454,16 +540,24 @@ ${_build_dirs}: _DIRDEP_USE
# it would be nice to do :N${.TARGET}
.if !empty(__qual_depdirs)
.for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m}
.if !empty(_debug_reldir) || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
.if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q}
.endif
.if ${BUILD_DIRDEPS_CACHE} == "yes"
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$q:${M_oneperline}}'; echo; } >&3; echo
.else
${_this_dir}.$m: ${_build_dirs:M*.$q}
.endif
.endfor
.endif
.if !empty(_debug_reldir)
.if ${_debug_reldir}
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m}
.endif
.if ${BUILD_DIRDEPS_CACHE} == "yes"
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m:${M_oneperline}}'; echo; } >&3; echo
.else
${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
.endif
.endfor
.endif
@ -473,7 +567,7 @@ ${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
.if ${_DIRDEP_CHECKED:M$d} == ""
# once only
_DIRDEP_CHECKED += $d
.if !empty(_debug_search)
.if ${_debug_search}
.info checking $d
.endif
# Note: _build_dirs is fully qualifed so d:R is always the directory
@ -485,14 +579,14 @@ _m := ${.MAKE.DEPENDFILE_PREFERENCE:T:S;${TARGET_SPEC}$;${d:E};:S;${MACHINE};${d
.if !empty(_m)
# M_dep_qual_fixes isn't geared to Makefile.depend
_qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes:ts:}}
.if !empty(_debug_search)
.if ${_debug_search}
.info Looking for ${_qm}
.endif
# we pass _DEP_TARGET_SPEC to tell the next step what we want
_DEP_TARGET_SPEC := ${d:E}
# some makefiles may still look at this
_DEP_MACHINE := ${d:E:C/,.*//}
.if !empty(_debug_reldir) && ${_qm} != ${_m}
.if ${_debug_reldir} && ${_qm} != ${_m}
.info loading ${_m} for ${d:E}
.endif
.include <${_m}>
@ -502,6 +596,7 @@ _DEP_MACHINE := ${d:E:C/,.*//}
.endfor
.endif # -V
.endif # BUILD_DIRDEPS
.elif ${.MAKE.LEVEL} > 42
.error You should have stopped recursing by now.
@ -511,3 +606,37 @@ _DEP_RELDIR := ${DEP_RELDIR}
.-include <.depend>
.endif
# bootstrapping new dependencies made easy?
.if make(bootstrap*) && !target(bootstrap)
.if exists(${.CURDIR}/${.MAKE.DEPENDFILE:T})
# stop here
${.TARGETS:Mboot*}:
.else
# find a Makefile.depend to use as _src
_src != cd ${.CURDIR} && for m in ${.MAKE.DEPENDFILE_PREFERENCE:T:S,${MACHINE},*,}; do test -s $$m || continue; echo $$m; break; done; echo
.if empty(_src)
.error cannot find any of ${.MAKE.DEPENDFILE_PREFERENCE:T}
.endif
_src?= ${.MAKE.DEPENDFILE:T}
bootstrap-this: .NOTMAIN
@echo Bootstrapping ${RELDIR}/${.MAKE.DEPENDFILE:T} from ${_src:T}
(cd ${.CURDIR} && sed 's,${_src:E},${MACHINE},g' ${_src} > ${.MAKE.DEPENDFILE:T})
bootstrap: bootstrap-recurse
bootstrap-recurse: bootstrap-this
_mf := ${.PARSEFILE}
bootstrap-recurse: .NOTMAIN .MAKE
@cd ${SRCTOP} && \
for d in `cd ${RELDIR} && ${.MAKE} -B -f ${"${.MAKEFLAGS:M-n}":?${_src}:${.MAKE.DEPENDFILE:T}} -V DIRDEPS`; do \
test -d $$d || d=$${d%.*}; \
test -d $$d || continue; \
echo "Checking $$d for bootstrap ..."; \
(cd $$d && ${.MAKE} -f ${_mf} bootstrap-recurse); \
done
.endif
.endif

View File

@ -1,4 +1,4 @@
# $Id: gendirdeps.mk,v 1.25 2014/03/14 21:28:37 sjg Exp $
# $Id: gendirdeps.mk,v 1.26 2014/09/05 04:40:52 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@ -93,6 +93,17 @@ _skip_gendirdeps = egrep -v '^(${SKIP_GENDIRDEPS:O:u:ts|})' |
_skip_gendirdeps =
.endif
# Below we will turn _{VAR} into ${VAR} which keeps this simple
# GENDIRDEPS_FILTER_DIR_VARS is a list of dirs to be substiuted for.
# GENDIRDEPS_FILTER_VARS is more general.
# In each case order matters.
.if !empty(GENDIRDEPS_FILTER_DIR_VARS)
GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_DIR_VARS:@v@S,${$v},_{${v}},@}
.endif
.if !empty(GENDIRDEPS_FILTER_VARS)
GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u}
.endif
# this (*should* be set in meta.sys.mk)
# is the script that extracts what we want.
META2DEPS ?= ${.PARSEDIR}/meta2deps.sh

View File

@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
# $Id: install-mk,v 1.100 2014/05/23 01:30:36 sjg Exp $
# $Id: install-mk,v 1.109 2015/04/16 16:59:00 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@ -70,7 +70,7 @@
# sjg@crufty.net
#
MK_VERSION=20140522
MK_VERSION=20150411
OWNER=
GROUP=
MODE=444

View File

@ -1,4 +1,4 @@
# $Id: links.mk,v 1.5 2005/07/11 18:01:05 sjg Exp $
# $Id: links.mk,v 1.6 2014/09/29 17:14:40 sjg Exp $
#
# @(#) Copyright (c) 2005, Simon J. Gerraty
#
@ -22,9 +22,14 @@ SYMLINKS?=
__SYMLINK_SCRIPT= \
${ECHO} "$$t -> $$l"; \
mkdir -p `dirname $$t`; \
rm -f $$t; \
${LN} -s $$l $$t
case `'ls' -l $$t 2> /dev/null` in \
*"> $$l") ;; \
*) \
mkdir -p `dirname $$t`; \
rm -f $$t; \
${LN} -s $$l $$t;; \
esac
__LINK_SCRIPT= \
${ECHO} "$$t -> $$l"; \

View File

@ -0,0 +1,66 @@
# $Id: manifest.mk,v 1.2 2014/10/31 18:06:17 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
# generate mtree style manifest supported by makefs in FreeBSD
# input looks like
# MANIFEST= my.mtree
# for each MANIFEST we have a list of dirs
# ${MANIFEST}.DIRS += bin sbin usr/bin ...
# for each dir we have a ${MANIFEST}.SRCS.$dir
# that provides the absolute path to the contents
# ${MANIFEST}.SRCS.bin += ${OBJTOP}/bin/sh/sh
# ${MANIFEST}.SYMLINKS is a list of src target pairs
# for each file/dir there are a number of attributes
# UID GID MODE FLAGS
# which can be set per dir, per file or we use defaults
# eg.
# MODE.sbin = 550
# MODE.usr/sbin = 550
# MODE.dirs = 555
# means that sbin and usr/sbin get 550 all other dirs get 555
# MODE.usr/bin/passwd = 4555
# MODE.usr/bin.files = 555
# MODE.usr/sbin.files = 500
# means passwd gets 4555 other files in usr/bin get 555 and
# files in usr/sbin get 500
# STORE defaults to basename of src and target directory
# but we can use
# ${MANIFEST}.SRCS.sbin += ${OBJTOP}/bin/sh-static/sh-static
# STORE.sbin/sh-static = sbin/sh
#
# the above is a little overkill but means we can easily adapt to
# different formats
UID.dirs ?= 0
GID.dirs ?= 0
MODE.dirs ?= 775
FLAGS.dirs ?=
UID.files ?= 0
GID.files ?= 0
MODE.files ?= 555
# a is attribute name d is dirname
M_DIR_ATTR = L:@a@$${$$a.$$d:U$${$$a.dirs}}@
# as above and s is set to the name we store f as
M_FILE_ATTR = L:@a@$${$$a.$$s:U$${$$a.$$d.files:U$${$$a.files}}}@
# this produces the body of the manifest
# there should typically be a header prefixed
_GEN_MTREE_MANIFEST_USE: .USE
@(${${.TARGET}.DIRS:O:u:@d@echo '$d type=dir uid=${UID:${M_DIR_ATTR}} gid=${GID:${M_DIR_ATTR}} mode=${MODE:${M_DIR_ATTR}} ${FLAGS:${M_DIR_ATTR}}';@} \
${${.TARGET}.DIRS:O:u:@d@${${.TARGET}.SRCS.$d:O:u:@f@echo '${s::=${STORE.$d/${f:T}:U$d/${f:T}}}$s contents="$f" type=file uid=${UID:${M_FILE_ATTR}} gid=${GID:${M_FILE_ATTR}} mode=${MODE:${M_FILE_ATTR}} ${FLAGS:${M_FILE_ATTR}}';@}@} \
set ${${.TARGET}.SYMLINKS}; while test $$# -ge 2; do echo "$$2 type=link link=$$1"; shift 2; done) > ${.TARGET}

View File

@ -1,4 +1,4 @@
# $Id: meta.autodep.mk,v 1.35 2014/05/09 00:05:46 sjg Exp $
# $Id: meta.autodep.mk,v 1.36 2014/08/02 23:10:29 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
@ -254,6 +254,9 @@ ${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.MET
.endif
.if ${_bootstrap_dirdeps} == "yes"
.if ${BUILD_AT_LEVEL0:Uno} == "no"
DIRDEPS+= ${RELDIR}.${TARGET_SPEC:U${MACHINE}}
.endif
# make sure this is included at least once
.include <dirdeps.mk>
.else

View File

@ -1,4 +1,4 @@
# $Id: meta.stage.mk,v 1.30 2013/04/19 16:32:57 sjg Exp $
# $Id: meta.stage.mk,v 1.34 2014/11/20 22:40:08 sjg Exp $
#
# @(#) Copyright (c) 2011, Simon J. Gerraty
#
@ -35,7 +35,13 @@ _stage_file_basename = $${f\#\#*/}
_stage_target_dirname = $${t%/*}
.endif
_OBJROOT ?= ${OBJROOT:U${OBJTOP:H}}
.if ${_OBJROOT:M*/} != ""
_objroot ?= ${_OBJROOT:tA}/
.else
_objroot ?= ${_OBJROOT:tA}
.endif
# make sure this is global
_STAGED_DIRS ?=
.export _STAGED_DIRS
@ -46,7 +52,7 @@ STAGE_DIR_FILTER = tA:@d@$${_STAGED_DIRS::+=$$d}$$d@
# convert _STAGED_DIRS into suitable filters
GENDIRDEPS_FILTER += Nnot-empty-is-important \
${_STAGED_DIRS:O:u:M${OBJTOP}*:S,${OBJTOP}/,N,} \
${_STAGED_DIRS:O:u:N${OBJTOP}*:S,${_objroot},,:C,^([^/]+)/(.*),N\2.\1,:S,${HOST_TARGET},.host,}
${_STAGED_DIRS:O:u:M${_objroot}*:N${OBJTOP}*:S,${_objroot},,:C,^([^/]+)/(.*),N\2.\1,:S,${HOST_TARGET},.host,}
LN_CP_SCRIPT = LnCp() { \
rm -f $$2 2> /dev/null; \
@ -113,10 +119,14 @@ STAGE_AS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageAs() { \
_STAGE_BASENAME_USE: .USE ${.TARGET:T}
@${STAGE_FILE_SCRIPT}; StageFiles ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T}
_STAGE_AS_BASENAME_USE: .USE ${.TARGET:T}
@${STAGE_AS_SCRIPT}; StageAs ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T} ${STAGE_AS_${.TARGET:T}:U${.TARGET:T}}
.if !empty(STAGE_INCSDIR)
STAGE_TARGETS += stage_incs
STAGE_INCS ?= ${.ALLSRC:N.dirdep}
stage_includes: stage_incs
stage_incs: .dirdep
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS}
@touch $@
@ -129,11 +139,13 @@ STAGE_LIBS ?= ${.ALLSRC:N.dirdep}
stage_libs: .dirdep
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS}
.if !defined(NO_SHLIB_LINKS)
.if !empty(SHLIB_LINKS)
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} \
${SHLIB_LINKS:@t@${STAGE_LIBS:T:M$t.*} $t@}
.elif !empty(SHLIB_LINK) && !empty(SHLIB_NAME)
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK} ${SYMLINKS:T}
.endif
.endif
@touch $@
.endif
@ -212,7 +224,7 @@ stage_as.$s: .dirdep
.endfor
.endif
CLEANFILES += ${STAGE_TARGETS}
CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes
# stage_*links usually needs to follow any others.
.for t in ${STAGE_TARGETS:N*links:O:u}
@ -240,5 +252,26 @@ INSTALL := ${STAGE_INSTALL}
beforeinstall: .dirdep
.endif
.endif
.NOPATH: ${STAGE_FILES}
.if !empty(STAGE_TARGETS)
MK_STALE_STAGED?= no
.if ${MK_STALE_STAGED} == "yes"
all: stale_staged
# get a list of paths that we have just staged
# get a list of paths that we have previously staged to those same dirs
# anything in the 2nd list but not the first is stale - remove it.
stale_staged: staging .NOMETA
@egrep '^[WL] .*${STAGE_OBJTOP}' /dev/null ${.MAKE.META.FILES:M*stage_*} | \
sed "/\.dirdep/d;s,.* '*\(${STAGE_OBJTOP}/[^ '][^ ']*\).*,\1," | \
sort > ${.TARGET}.staged1
@grep -l '${_dirdep}' /dev/null ${_STAGED_DIRS:M${STAGE_OBJTOP}*:O:u:@d@$d/*.dirdep@} | \
sed 's,\.dirdep,,' | sort > ${.TARGET}.staged2
@comm -13 ${.TARGET}.staged1 ${.TARGET}.staged2 > ${.TARGET}.stale
@test ! -s ${.TARGET}.stale || { \
echo "Removing stale staged files..."; \
sed 's,.*,& &.dirdep,' ${.TARGET}.stale | xargs rm -f; }
.endif
.endif
.endif

View File

@ -1,4 +1,4 @@
# $Id: meta.sys.mk,v 1.16 2012/07/03 05:26:00 sjg Exp $
# $Id: meta.sys.mk,v 1.20 2014/08/04 05:12:27 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
@ -106,7 +106,13 @@ _metaError: .NOMETA .NOTMAIN
# Are we, after all, in meta mode?
.if ${.MAKE.MODE:Mmeta*} != ""
MKDEP = meta.autodep
MKDEP_MK = meta.autodep.mk
# if we think we are updating dependencies,
# then filemon had better be present
.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !exists(/dev/filemon)
.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
.endif
.if ${.MAKE.LEVEL} == 0
# make sure dirdeps target exists and do it first
@ -121,19 +127,11 @@ dirdeps:
# tell dirdeps.mk what we want
BUILD_AT_LEVEL0 = no
.endif
.if ${.MAKE.DEPENDFILE:E} == ${MACHINE}
.if ${.TARGETS:Nall} == ""
# it works best if we do everything via sub-makes
BUILD_AT_LEVEL0 ?= no
.endif
BUILD_AT_LEVEL0 ?= yes
.endif
# if we think we are updating dependencies,
# then filemon had better be present
.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !exists(/dev/filemon)
.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
.endif
.endif
.endif
.endif

View File

@ -37,7 +37,7 @@
"""
RCSid:
$Id: meta2deps.py,v 1.17 2014/04/05 22:56:54 sjg Exp $
$Id: meta2deps.py,v 1.18 2015/04/03 18:23:25 sjg Exp $
Copyright (c) 2011-2013, Juniper Networks, Inc.
All rights reserved.
@ -112,7 +112,8 @@ def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
rpath = resolve(path, cwd, last_dir, debug, debug_out)
if rpath:
path = rpath
if (path.find('./') > 0 or
if (path.find('/') < 0 or
path.find('./') > 0 or
path.endswith('/..') or
os.path.islink(path)):
return os.path.realpath(path)
@ -142,7 +143,7 @@ class MetaFile:
host_target = None
srctops = []
objroots = []
excludes = []
seen = {}
obj_deps = []
src_deps = []
@ -179,6 +180,10 @@ def __init__(self, name, conf={}):
This can allow 'bmake' to learn all the dirs within
the tree that depend on 'foo.h'
EXCLUDES
A list of paths to ignore.
ccache(1) can otherwise be trouble.
debug desired debug level
debug_out open file to send debug output to (sys.stderr)
@ -236,11 +241,14 @@ def __init__(self, name, conf={}):
# we want the longest match
self.srctops.sort(reverse=True)
self.objroots.sort(reverse=True)
self.excludes = getv(conf, 'EXCLUDES', [])
if self.debug:
print("host_target=", self.host_target, file=self.debug_out)
print("srctops=", self.srctops, file=self.debug_out)
print("objroots=", self.objroots, file=self.debug_out)
print("excludes=", self.excludes, file=self.debug_out)
self.dirdep_re = re.compile(r'([^/]+)/(.+)')
@ -257,6 +265,7 @@ def __init__(self, name, conf={}):
self.dpdeps = None # we cannot do it?
self.cwd = os.getcwd() # make sure this is initialized
self.last_dir = self.cwd
if name:
self.try_parse()
@ -360,18 +369,18 @@ def parse(self, name=None, file=None):
V 3
C "pid" "cwd"
E "pid" "path"
F "pid" "child"
F "pid" "child"
R "pid" "path"
W "pid" "path"
X "pid" "status"
D "pid" "path"
L "pid" "src" "target"
M "pid" "old" "new"
S "pid" "path"
# Bye bye
D "pid" "path"
L "pid" "src" "target"
M "pid" "old" "new"
S "pid" "path"
# Bye bye
We go to some effort to avoid processing a dependency more than once.
Of the above record types only C,E,F,L,R,V and W are of interest.
We go to some effort to avoid processing a dependency more than once.
Of the above record types only C,E,F,L,R,V and W are of interest.
"""
version = 0 # unknown
@ -379,7 +388,7 @@ def parse(self, name=None, file=None):
self.name = name;
if file:
f = file
cwd = last_dir = self.cwd
cwd = self.last_dir = self.cwd
else:
f = open(self.name, 'r')
skip = True
@ -412,7 +421,7 @@ def parse(self, name=None, file=None):
interesting += 'W'
"""
elif w[0] == 'CWD':
self.cwd = cwd = last_dir = w[1]
self.cwd = cwd = self.last_dir = w[1]
self.seenit(cwd) # ignore this
if self.debug:
print("%s: CWD=%s" % (self.name, cwd), file=self.debug_out)
@ -422,9 +431,9 @@ def parse(self, name=None, file=None):
if pid != last_pid:
if last_pid:
pid_cwd[last_pid] = cwd
pid_last_dir[last_pid] = last_dir
pid_last_dir[last_pid] = self.last_dir
cwd = getv(pid_cwd, pid, self.cwd)
last_dir = getv(pid_last_dir, pid, self.cwd)
self.last_dir = getv(pid_last_dir, pid, self.cwd)
last_pid = pid
# process operations
@ -438,7 +447,7 @@ def parse(self, name=None, file=None):
cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
if cwd.endswith('/.'):
cwd = cwd[0:-2]
last_dir = cwd
self.last_dir = cwd
if self.debug > 1:
print("cwd=", cwd, file=self.debug_out)
continue
@ -449,98 +458,114 @@ def parse(self, name=None, file=None):
continue
# file operations
if w[0] in 'ML':
path = w[2].strip("'")
else:
# these are special, tread src as read and
# target as write
self.parse_path(w[1].strip("'"), cwd, 'R', w)
self.parse_path(w[2].strip("'"), cwd, 'W', w)
continue
elif w[0] in 'ERWS':
path = w[2]
# we are never interested in .dirdep files as dependencies
if path.endswith('.dirdep'):
continue
# we don't want to resolve the last component if it is
# a symlink
path = resolve(path, cwd, last_dir, self.debug, self.debug_out)
if not path:
continue
dir,base = os.path.split(path)
if dir in self.seen:
if self.debug > 2:
print("seen:", dir, file=self.debug_out)
continue
# we can have a path in an objdir which is a link
# to the src dir, we may need to add dependencies for each
rdir = dir
dir = abspath(dir, cwd, last_dir, self.debug, self.debug_out)
if rdir == dir or rdir.find('./') > 0:
rdir = None
# now put path back together
path = '/'.join([dir,base])
if self.debug > 1:
print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
if w[0] in 'SRWL':
if w[0] == 'W' and path.endswith('.dirdep'):
continue
if path in [last_dir, cwd, self.cwd, self.curdir]:
if self.debug > 1:
print("skipping:", path, file=self.debug_out)
continue
if os.path.isdir(path):
if w[0] in 'RW':
last_dir = path;
if self.debug > 1:
print("ldir=", last_dir, file=self.debug_out)
continue
self.parse_path(path, cwd, w[0], w)
if w[0] in 'REWML':
# finally, we get down to it
if dir == self.cwd or dir == self.curdir:
continue
srctop = self.find_top(path, self.srctops)
if srctop:
if self.dpdeps:
self.add(self.file_deps, path.replace(srctop,''), 'file')
self.add(self.src_deps, dir.replace(srctop,''), 'src')
self.seenit(w[2])
self.seenit(dir)
if rdir and not rdir.startswith(srctop):
dir = rdir # for below
rdir = None
else:
continue
objroot = None
for dir in [dir,rdir]:
if not dir:
continue
objroot = self.find_top(dir, self.objroots)
if objroot:
break
if objroot:
ddep = self.find_obj(objroot, dir, path, w[2])
if ddep:
self.add(self.obj_deps, ddep, 'obj')
else:
# don't waste time looking again
self.seenit(w[2])
self.seenit(dir)
if not file:
f.close()
def parse_path(self, path, cwd, op=None, w=[]):
"""look at a path for the op specified"""
if not op:
op = w[0]
# we are never interested in .dirdep files as dependencies
if path.endswith('.dirdep'):
return
for p in self.excludes:
if p and path.startswith(p):
if self.debug > 2:
print >> self.debug_out, "exclude:", p, path
return
# we don't want to resolve the last component if it is
# a symlink
path = resolve(path, cwd, self.last_dir, self.debug, self.debug_out)
if not path:
return
dir,base = os.path.split(path)
if dir in self.seen:
if self.debug > 2:
print("seen:", dir, file=self.debug_out)
return
# we can have a path in an objdir which is a link
# to the src dir, we may need to add dependencies for each
rdir = dir
dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
if rdir == dir or rdir.find('./') > 0:
rdir = None
# now put path back together
path = '/'.join([dir,base])
if self.debug > 1:
print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
if op in 'RWS':
if path in [self.last_dir, cwd, self.cwd, self.curdir]:
if self.debug > 1:
print("skipping:", path, file=self.debug_out)
return
if os.path.isdir(path):
if op in 'RW':
self.last_dir = path;
if self.debug > 1:
print("ldir=", self.last_dir, file=self.debug_out)
return
if op in 'ERW':
# finally, we get down to it
if dir == self.cwd or dir == self.curdir:
return
srctop = self.find_top(path, self.srctops)
if srctop:
if self.dpdeps:
self.add(self.file_deps, path.replace(srctop,''), 'file')
self.add(self.src_deps, dir.replace(srctop,''), 'src')
self.seenit(w[2])
self.seenit(dir)
if rdir and not rdir.startswith(srctop):
dir = rdir # for below
rdir = None
else:
return
objroot = None
for dir in [dir,rdir]:
if not dir:
continue
objroot = self.find_top(dir, self.objroots)
if objroot:
break
if objroot:
ddep = self.find_obj(objroot, dir, path, w[2])
if ddep:
self.add(self.obj_deps, ddep, 'obj')
else:
# don't waste time looking again
self.seenit(w[2])
self.seenit(dir)
def main(argv, klass=MetaFile, xopts='', xoptf=None):
"""Simple driver for class MetaFile.
Usage:
script [options] [key=value ...] "meta" ...
script [options] [key=value ...] "meta" ...
Options and key=value pairs contribute to the
dictionary passed to MetaFile.
-S "SRCTOP"
add "SRCTOP" to the "SRCTOPS" list.
add "SRCTOP" to the "SRCTOPS" list.
-C "CURDIR"
-O "OBJROOT"
add "OBJROOT" to the "OBJROOTS" list.
add "OBJROOT" to the "OBJROOTS" list.
-m "MACHINE"
@ -550,7 +575,7 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
-D "DPDEPS"
-d bumps debug level
-d bumps debug level
"""
import getopt
@ -568,6 +593,7 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
conf = {
'SRCTOPS': [],
'OBJROOTS': [],
'EXCLUDES': [],
}
try:
@ -589,7 +615,7 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
debug = 0
output = True
opts, args = getopt.getopt(argv[1:], 'a:dS:C:O:R:m:D:H:qT:' + xopts)
opts, args = getopt.getopt(argv[1:], 'a:dS:C:O:R:m:D:H:qT:X:' + xopts)
for o, a in opts:
if o == '-a':
conf['MACHINE_ARCH'] = a
@ -615,6 +641,9 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
conf['MACHINE'] = a
elif o == '-T':
conf['TARGET_SPEC'] = a
elif o == '-X':
if a not in conf['EXCLUDES']:
conf['EXCLUDES'].append(a)
elif xoptf:
xoptf(o, a, conf)
@ -649,16 +678,21 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
for k,v in list(conf.items()):
print("%s=%s" % (k,v), file=debug_out)
m = None
for a in args:
if a.endswith('.meta'):
if not os.path.exists(a):
continue
m = klass(a, conf)
elif a.startswith('@'):
# there can actually multiple files per line
for line in open(a[1:]):
for f in line.strip().split():
if not os.path.exists(f):
continue
m = klass(f, conf)
if output:
if output and m:
print(m.dirdeps())
print(m.src_dirdeps('\nsrc:'))

View File

@ -77,7 +77,7 @@
# RCSid:
# $Id: meta2deps.sh,v 1.7 2014/04/05 22:56:54 sjg Exp $
# $Id: meta2deps.sh,v 1.9 2015/04/03 18:23:25 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@ -139,10 +139,15 @@ add_list() {
eval "$name=\"$list\""
}
_excludes_f() {
egrep -v "$EXCLUDES"
}
meta2deps() {
DPDEPS=
SRCTOPS=$SRCTOP
OBJROOTS=
EXCLUDES=
while :
do
case "$1" in
@ -153,6 +158,7 @@ meta2deps() {
-H) HOST_TARGET=$2; shift 2;;
-S) add_list SRCTOPS $2; shift 2;;
-O) add_list OBJROOTS $2; shift 2;;
-X) add_list EXCLUDES '|' $2; shift 2;;
-R) RELDIR=$2; shift 2;;
-T) TARGET_SPEC=$2; shift 2;;
*) break;;
@ -212,8 +218,26 @@ meta2deps() {
seenit=
seensrc=
lpid=
cat /dev/null "$@" |
sed -e 's,^CWD,C C,;/^[CREFL] /!d' -e "s,',,g" |
case "$EXCLUDES" in
"") _excludes=cat;;
*) _excludes=_excludes_f;;
esac
# handle @list files
case "$@" in
*@[!.]*)
for f in "$@"
do
case "$f" in
*.meta) cat $f;;
@*) xargs cat < ${f#@};;
*) cat $f;;
esac
done
;;
*) cat /dev/null "$@";;
esac 2> /dev/null |
sed -e 's,^CWD,C C,;/^[CREFLM] /!d' -e "s,',,g" |
$_excludes |
while read op pid path junk
do
: op=$op pid=$pid path=$path

View File

@ -432,13 +432,27 @@ You should never need to edit ``warnings.mk``, it will include
``warnings-sets.mk`` if it exists and you use that to make any local
customizations.
rst2htm.mk
----------
Logic to simplify generating HTML (and PDF) documents from ReStructuredText.
cython.mk
---------
Logic to build Python C interface modules using Cython_
.. _Cython: http://www.cython.org/
Meta mode
=========
The 20110505 and later versions of ``mk-files`` include a number of
makefile contributed by Juniper Networks, Inc.
These allow the latest version of bmake_ to run in `meta mode`_.
makefiles contributed by Juniper Networks, Inc.
These allow the latest version of bmake_ to run in `meta mode`_
see `dirdeps.mk`_
.. _`dirdeps.mk`: /help/sjg/dirdeps.htm
.. _`meta mode`: bmake-meta-mode.htm
Install
@ -463,5 +477,5 @@ where you unpacked the tar file, you can::
.. _mk.tar.gz: http://www.crufty.net/ftp/pub/sjg/mk.tar.gz
:Author: sjg@crufty.net
:Revision: $Id: mk-files.txt,v 1.15 2011/06/08 07:06:18 sjg Exp $
:Revision: $Id: mk-files.txt,v 1.16 2014/09/05 04:41:16 sjg Exp $
:Copyright: Crufty.NET

94
contrib/bmake/mk/mkopt.sh Executable file
View File

@ -0,0 +1,94 @@
:
# $Id: mkopt.sh,v 1.8 2014/11/15 07:07:18 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
# handle WITH[OUT]_* options in a manner compatible with
# options.mk and bsd.mkopt.mk in recent FreeBSD
# no need to be included more than once
_MKOPT_SH=:
#
# _mk_opt OPT default
#
# Set MK_$OPT
#
# The semantics are simple, if MK_$OPT has no value
# WITHOUT_$OPT results in MK_$OPT=no
# otherwise WITH_$OPT results in MK_$OPT=yes.
# Note WITHOUT_$OPT overrides WITH_$OPT.
#
# For backwards compatability reasons we treat WITH_$OPT=no
# the same as WITHOUT_$OPT.
#
_mk_opt() {
_d=$1
_mo=MK_$2 _wo=WITHOUT_$2 _wi=WITH_$2
eval "_mov=\$$_mo _wov=\$$_wo _wiv=\$$_wi"
case "$_wiv" in
no) _wov=no;;
esac
_v=${_mov:-${_wov:+no}}
_v=${_v:-${_wiv:+yes}}
_v=${_v:-$_d}
_opt_list="$_opt_list $_mo"
case "$_v" in
yes|no) ;; # sane
0|[NnFf]*) _v=no;; # they mean no
1|[YyTt]*) _v=yes;; # they mean yes
*) _v=$_d;; # ignore bogus value
esac
eval "$_mo=$_v"
}
#
# _mk_opts default opt ... [default [opt] ...]
#
# see _mk_opts_defaults for example
#
_mk_opts() {
_d=no
for _o in "$@"
do
case "$_o" in
yes|no) _d=$_o; continue;;
esac
_mk_opt $_d $_o
done
}
_mk_opts_defaults() {
_mk_opts no $__DEFAULT_NO_OPTIONS yes $__DEFAULT_YES_OPTIONS
}
case "/$0" in
*/mkopt*)
_list=no
while :
do
case "$1" in
*=*) eval "$1"; shift;;
--no|no) _list="$_list no"; shift;;
--yes|yes) _list="$_list yes"; shift;;
-DWITH*) eval "${1#-D}=1"; shift;;
[A-Z]*) _list="$_list $1"; shift;;
*) break;;
esac
done
_mk_opts $_list
;;
esac

View File

@ -1,4 +1,4 @@
# $Id: own.mk,v 1.27 2013/07/18 05:46:24 sjg Exp $
# $Id: own.mk,v 1.28 2015/04/16 16:59:00 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@ -89,6 +89,7 @@ OPTIONS_DEFAULT_NO+= DPADD_MK
# process options
OPTIONS_DEFAULT_NO+= \
AUTO_OBJ \
INSTALL_AS_USER \
GPROF \
LIBTOOL \
@ -98,7 +99,6 @@ OPTIONS_DEFAULT_NO+= \
OPTIONS_DEFAULT_YES+= \
ARCHIVE \
AUTODEP \
AUTO_OBJ \
CRYPTO \
DOC \
DPADD_MK \

View File

@ -1,4 +1,4 @@
# $Id: sys.dependfile.mk,v 1.5 2013/03/08 00:59:21 sjg Exp $
# $Id: sys.dependfile.mk,v 1.6 2014/08/02 18:02:06 sjg Exp $
#
# @(#) Copyright (c) 2012, Simon J. Gerraty
#
@ -25,6 +25,12 @@
# All depend file names should start with this
.MAKE.DEPENDFILE_PREFIX ?= Makefile.depend
.if !empty(.MAKE.DEPENDFILE) && \
${.MAKE.DEPENDFILE:M${.MAKE.DEPENDFILE_PREFIX}*} == ""
# let us do our thing below...
.undef .MAKE.DEPENDFILE
.endif
# The order of preference: we will use the first one of these we find.
# It usually makes sense to order from most specific to least.
.MAKE.DEPENDFILE_PREFERENCE ?= \

63
contrib/bmake/mk/whats.mk Normal file
View File

@ -0,0 +1,63 @@
# $Id: whats.mk,v 1.1 2014/08/30 22:40:47 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
.if ${MK_WHATSTRING:Uno} != "no"
what_build_exts?= o
# it can be useful to embed a what(1) string in binaries
# so that the build location can be seen from a core file.
.if defined(PROG) && ${.MAKE.MAKEFILES:M*prog.mk} != ""
what_thing?= ${PROGNAME:U${PROG}}
what_build_thing?= ${PROG}
.elif defined(LIB) && ${.MAKE.MAKEFILES:M*lib.mk} != ""
# probably only makes sense for shared libs
# and the plumbing needed varies depending on *lib.mk
what_thing?= lib${LIB}
.if !empty(SOBJS)
_soe:= ${SOBJS:E:[1]}
what_build_exts= ${_soe}
SOBJS+= ${what_uuid}.${_soe}
.endif
.elif defined(KMOD) && ${.MAKE.MAKEFILES:M*kmod.mk} != ""
what_thing?= ${KMOD}
what_build_thing?= ${KMOD}.ko
.endif
.if !empty(what_thing)
# a unique name that won't conflict with anything
what_uuid = what_${.CURDIR:T:hash}
.if !empty(what_build_thing)
${what_build_thing}: ${what_build_exts:@e@${what_uuid}.$e@}
.endif
OBJS+= ${what_uuid}.o
CLEANFILES+= ${what_uuid}.c
# we do not need to capture this
SUPPRESS_DEPEND+= *${what_uuid}.c
SB?= ${SRCTOP:H}
SB_LOCATION?= ${HOST}:${SB}
what_location:= ${.OBJDIR:S,${SB},${SB_LOCATION},}
# this works with clang and gcc
_what_t= const char __attribute__ ((section(".data")))
_what1:= @(\#)${what_thing:tu} built ${%Y%m%d:L:localtime} by ${USER}
_what2:= @(\#)${what_location}
${what_uuid}.c:
echo '${_what_t} ${what_uuid}1[] = "${_what1}";' > $@ ${.OODATE:MNO_META_CMP}
echo '${_what_t} ${what_uuid}2[] = "${_what2}";' >> $@
.endif
.endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.65 2012/08/30 21:17:05 sjg Exp $ */
/* $NetBSD: nonints.h,v 1.67 2014/09/07 20:55:34 joerg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $ */
/* $NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $";
static char rcsid[] = "$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $");
__RCSID("$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $");
#endif
#endif /* not lint */
#endif
@ -1203,7 +1203,17 @@ ParseDoDependency(char *line)
curTargs = Lst_Init(FALSE);
/*
* First, grind through the targets.
*/
do {
/*
* Here LINE points to the beginning of the next word, and
* LSTART points to the actual beginning of the line.
*/
/* Find the end of the next word. */
for (cp = line; *cp && (ParseIsEscaped(lstart, cp) ||
!(isspace((unsigned char)*cp) ||
*cp == '!' || *cp == ':' || *cp == LPAREN));
@ -1226,6 +1236,10 @@ ParseDoDependency(char *line)
}
}
/*
* If the word is followed by a left parenthesis, it's the
* name of an object file inside an archive (ar file).
*/
if (!ParseIsEscaped(lstart, cp) && *cp == LPAREN) {
/*
* Archives must be handled specially to make sure the OP_ARCHV
@ -1242,13 +1256,16 @@ ParseDoDependency(char *line)
"Error in archive specification: \"%s\"", line);
goto out;
} else {
/* Done with this word; on to the next. */
continue;
}
}
savec = *cp;
if (!*cp) {
/*
* We got to the end of the line while we were still
* looking at targets.
*
* Ending a dependency line without an operator is a Bozo
* no-no. As a heuristic, this is also often triggered by
* undetected conflicts from cvs/rcs merges.
@ -1263,10 +1280,13 @@ ParseDoDependency(char *line)
: "Need an operator");
goto out;
}
/* Insert a null terminator. */
savec = *cp;
*cp = '\0';
/*
* Have a word in line. See if it's a special target and set
* Got the word. See if it's a special target and if so set
* specType to match it.
*/
if (*line == '.' && isupper ((unsigned char)line[1])) {
@ -1405,6 +1425,8 @@ ParseDoDependency(char *line)
(void)Lst_AtEnd(curTargs, line);
}
/* Apply the targets. */
while(!Lst_IsEmpty(curTargs)) {
char *targName = (char *)Lst_DeQueue(curTargs);
@ -1422,7 +1444,9 @@ ParseDoDependency(char *line)
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line);
}
/* Don't need the inserted null terminator any more. */
*cp = savec;
/*
* If it is a special type and not .PATH, it's the only target we
* allow on this line...
@ -1498,12 +1522,21 @@ ParseDoDependency(char *line)
goto out;
}
cp++; /* Advance beyond operator */
/* Advance beyond the operator */
cp++;
/*
* Apply the operator to the target. This is how we remember which
* operator a target was defined with. It fails if the operator
* used isn't consistent across all references.
*/
Lst_ForEach(targets, ParseDoOp, &op);
/*
* Get to the first source
* Onward to the sources.
*
* LINE will now point to the first source word, if any, or the
* end of the string if not.
*/
while (*cp && isspace ((unsigned char)*cp)) {
cp++;
@ -1962,6 +1995,40 @@ Parse_DoVar(char *line, GNode *ctxt)
}
/*
* ParseMaybeSubMake --
* Scan the command string to see if it a possible submake node
* Input:
* cmd the command to scan
* Results:
* TRUE if the command is possibly a submake, FALSE if not.
*/
static Boolean
ParseMaybeSubMake(const char *cmd)
{
size_t i;
static struct {
const char *name;
size_t len;
} vals[] = {
#define MKV(A) { A, sizeof(A) - 1 }
MKV("${MAKE}"),
MKV("${.MAKE}"),
MKV("$(MAKE)"),
MKV("$(.MAKE)"),
MKV("make"),
};
for (i = 0; i < sizeof(vals)/sizeof(vals[0]); i++) {
char *ptr;
if ((ptr = strstr(cmd, vals[i].name)) == NULL)
continue;
if ((ptr == cmd || !isalnum((unsigned char)ptr[-1]))
&& !isalnum((unsigned char)ptr[vals[i].len]))
return TRUE;
}
return FALSE;
}
/*-
* ParseAddCmd --
* Lst_ForEach function to add a command line to all targets
@ -1974,7 +2041,9 @@ Parse_DoVar(char *line, GNode *ctxt)
* Always 0
*
* Side Effects:
* A new element is added to the commands list of the node.
* A new element is added to the commands list of the node,
* and the node can be marked as a submake node if the command is
* determined to be that.
*/
static int
ParseAddCmd(void *gnp, void *cmd)
@ -1988,6 +2057,8 @@ ParseAddCmd(void *gnp, void *cmd)
/* if target already supplied, ignore commands */
if (!(gn->type & OP_HAS_COMMANDS)) {
(void)Lst_AtEnd(gn->commands, cmd);
if (ParseMaybeSubMake(cmd))
gn->type |= OP_SUBMAKE;
ParseMark(gn);
} else {
#ifdef notyet

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $ */
/* $NetBSD: suff.c,v 1.73 2014/09/07 20:55:34 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $";
static char rcsid[] = "$NetBSD: suff.c,v 1.73 2014/09/07 20:55:34 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
__RCSID("$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $");
__RCSID("$NetBSD: suff.c,v 1.73 2014/09/07 20:55:34 joerg Exp $");
#endif
#endif /* not lint */
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $ */
/* $NetBSD: targ.c,v 1.59 2014/09/07 20:55:34 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $";
static char rcsid[] = "$NetBSD: targ.c,v 1.59 2014/09/07 20:55: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.57 2012/06/12 19:21:51 joerg Exp $");
__RCSID("$NetBSD: targ.c,v 1.59 2014/09/07 20:55:34 joerg Exp $");
#endif
#endif /* not lint */
#endif

View File

@ -1,17 +1,18 @@
# $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $
# $Id: Makefile.in,v 1.46 2014/11/06 01:47:57 sjg Exp $
#
# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
# $NetBSD: Makefile,v 1.51 2014/10/20 23:21:11 sjg Exp $
#
# Unit tests for make(1)
# The main targets are:
#
# all: run all the tests
# test: run 'all', capture output and compare to expected results
# test: run 'all', and compare to expected results
# accept: move generated output to expected results
#
# Adding a test case.
# Each feature should get its own set of tests in its own suitably
# named makefile which should be added to SUBFILES to hook it in.
# named makefile (*.mk), with its own set of expected results (*.exp),
# and it should be added to the TESTNAMES list.
#
srcdir= @srcdir@
@ -19,10 +20,11 @@ srcdir= @srcdir@
.MAIN: all
UNIT_TESTS:= ${srcdir}
.PATH: ${UNIT_TESTS}
# Simple sub-makefiles - we run them as a black box
# keep the list sorted.
SUBFILES= \
# Each test is in a sub-makefile.
# Keep the list sorted.
TESTNAMES= \
comment \
cond1 \
error \
@ -42,7 +44,6 @@ SUBFILES= \
modts \
modword \
order \
phony-end \
posix \
qequals \
sunshcmd \
@ -50,23 +51,36 @@ SUBFILES= \
ternary \
unexport \
unexport-env \
varcmd
varcmd \
varmisc \
varshell
all: ${SUBFILES}
# these tests were broken by referting POSIX chanegs
STRICT_POSIX_TESTS = \
escape \
impsrc \
phony-end \
posix1 \
suffixes
# Override make flags for certain tests
flags.doterror=
flags.order=-j1
# the tests are actually done with sub-makes.
.PHONY: ${SUBFILES}
.PRECIOUS: ${SUBFILES}
${SUBFILES}:
-@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
OUTFILES= ${TESTNAMES:S/$/.out/}
all: ${OUTFILES}
CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp
CLEANFILES += obj*.[och] lib*.a # posix1.mk
CLEANFILES += issue* .[ab]* # suffixes.mk
CLEANRECURSIVE += dir dummy # posix1.mk
clean:
rm -f *.out *.fail *.core
.-include <obj.mk>
rm -f ${CLEANFILES}
.if !empty(CLEANRECURSIVE)
rm -rf ${CLEANRECURSIVE}
.endif
TEST_MAKE?= ${.MAKE}
TOOL_SED?= sed
@ -81,22 +95,56 @@ LANG= C
.export LANG LC_ALL
.endif
# The driver.
# some tests need extra post-processing
SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \
-e '/command/s,No such.*,not found,'
# the tests are actually done with sub-makes.
.SUFFIXES: .mk .rawout .out
.mk.rawout:
@echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC}
-@cd ${.OBJDIR} && \
{ ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \
2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp
@mv ${.TARGET}.tmp ${.TARGET}
# We always pretend .MAKE was called 'make'
# and strip ${.CURDIR}/ from the output
# and replace anything after 'stopped in' with unit-tests
# so the results can be compared.
test:
@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
${TOOL_TR} -d '\015' | \
${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
-e '/stopped/s, /.*, unit-tests,' \
-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; }
${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
.rawout.out:
@echo postprocess ${.TARGET}
@${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \
-e 's,${TEST_MAKE:C/\./\\\./g},make,' \
-e '/stopped/s, /.*, unit-tests,' \
-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \
< ${.IMPSRC} > ${.TARGET}.tmp
@echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
@mv ${.TARGET}.tmp ${.TARGET}
# Compare all output files
test: ${OUTFILES} .PHONY
@failed= ; \
for test in ${TESTNAMES}; do \
${TOOL_DIFF} -u ${UNIT_TESTS}/$${test}.exp $${test}.out \
|| failed="$${failed}$${failed:+ }$${test}" ; \
done ; \
if [ -n "$${failed}" ]; then \
echo "Failed tests: $${failed}" ; false ; \
else \
echo "All tests passed" ; \
fi
accept:
mv test.out ${srcdir}/test.exp
@for test in ${TESTNAMES}; do \
cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
|| { echo "Replacing $${test}.exp" ; \
cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
done
.if exists(${TEST_MAKE})
${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE}
.endif
.-include <obj.mk>

View File

@ -0,0 +1,5 @@
comment testing start
this is foo
This is how a comment looks: # comment
comment testing done
exit status 0

View File

@ -0,0 +1,23 @@
make: "cond1.mk" line 75: warning: extra else
make: "cond1.mk" line 85: warning: extra else
2 is prime
A='other' B='unknown' C='clever' o='no,no'
Passed:
var
("var")
(var != var)
var != var
!((var != var) && defined(name))
var == quoted
1 is not prime
2 is prime
3 is prime
4 is not prime
5 is prime
make: warning: String comparison operator should be either == or !=
make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No
OK
exit status 0

View File

@ -1,4 +1,4 @@
# $Id: cond1,v 1.1.1.3 2011/03/06 00:04:58 sjg Exp $
# $Id: cond1.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
# hard code these!
TEST_UNAME_S= NetBSD

View File

@ -0,0 +1,9 @@
At first, I am
happy
and now: sad
.ERROR: Looks like 'sad' is upset.
*** Error code 1
Stop.
make: stopped in unit-tests
exit status 1

View File

@ -1,4 +1,4 @@
# $Id: doterror,v 1.1.1.1 2010/04/08 17:43:00 sjg Exp $
# $Id: doterror.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
.BEGIN:

View File

@ -0,0 +1,30 @@
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
exit status 0

View File

@ -1,4 +1,4 @@
# $NetBSD: dotwait,v 1.1 2006/02/26 22:45:46 apb Exp $
# $NetBSD: dotwait.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE}

View File

@ -0,0 +1,4 @@
make: "error.mk" line 3: just FYI
make: "error.mk" line 4: warning: this could be serious
make: "error.mk" line 5: this is fatal
exit status 1

View File

@ -1,4 +1,4 @@
# $Id: error,v 1.1.1.2 2010/05/24 23:36:03 sjg Exp $
# $Id: error.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
.info just FYI
.warning this could be serious

View File

@ -0,0 +1,104 @@
var-1bs
printf "%s=:%s:\n" VAR1BS 111\\111; printf "%s=:%s:\n" VAR1BSa 111\\aaa; printf "%s=:%s:\n" VAR1BSA 111\\aaa; printf "%s=:%s:\n" VAR1BSda 111\\\$\{a\}; printf "%s=:%s:\n" VAR1BSdA 111\\\$\{A\}; printf "%s=:%s:\n" VAR1BSc 111\#\ backslash\ escapes\ comment\ char,\ so\ this\ is\ part\ of\ the\ value; printf "%s=:%s:\n" VAR1BSsc 111\\\ ;
VAR1BS=:111\111:
VAR1BSa=:111\aaa:
VAR1BSA=:111\aaa:
VAR1BSda=:111\${a}:
VAR1BSdA=:111\${A}:
VAR1BSc=:111# backslash escapes comment char, so this is part of the value:
VAR1BSsc=:111\ :
var-2bs
printf "%s=:%s:\n" VAR2BS 222\\\\222; printf "%s=:%s:\n" VAR2BSa 222\\\\aaa; printf "%s=:%s:\n" VAR2BSA 222\\\\aaa; printf "%s=:%s:\n" VAR2BSda 222\\\\\$\{a\}; printf "%s=:%s:\n" VAR2BSdA 222\\\\\$\{A\}; printf "%s=:%s:\n" VAR2BSc 222\\\\; printf "%s=:%s:\n" VAR2BSsc 222\\\\;
VAR2BS=:222\\222:
VAR2BSa=:222\\aaa:
VAR2BSA=:222\\aaa:
VAR2BSda=:222\\${a}:
VAR2BSdA=:222\\${A}:
VAR2BSc=:222\\:
VAR2BSsc=:222\\:
var-1bsnl
printf "%s=:%s:\n" VAR1BSNL 111\ 111; printf "%s=:%s:\n" VAR1BSNLa 111\ aaa; printf "%s=:%s:\n" VAR1BSNLA 111\ aaa; printf "%s=:%s:\n" VAR1BSNLda 111\ \$\{a\}; printf "%s=:%s:\n" VAR1BSNLdA 111\ \$\{A\}; printf "%s=:%s:\n" VAR1BSNLc 111; printf "%s=:%s:\n" VAR1BSNLsc 111;
VAR1BSNL=:111 111:
VAR1BSNLa=:111 aaa:
VAR1BSNLA=:111 aaa:
VAR1BSNLda=:111 ${a}:
VAR1BSNLdA=:111 ${A}:
VAR1BSNLc=:111:
VAR1BSNLsc=:111:
var-2bsnl
printf "%s=:%s:\n" VAR2BSNL 222\\\\; printf "%s=:%s:\n" VAR2BSNLa 222\\\\; printf "%s=:%s:\n" VAR2BSNLA 222\\\\; printf "%s=:%s:\n" VAR2BSNLda 222\\\\; printf "%s=:%s:\n" VAR2BSNLdA 222\\\\; printf "%s=:%s:\n" VAR2BSNLc 222\\\\; printf "%s=:%s:\n" VAR2BSNLsc 222\\\\;
VAR2BSNL=:222\\:
VAR2BSNLa=:222\\:
VAR2BSNLA=:222\\:
VAR2BSNLda=:222\\:
VAR2BSNLdA=:222\\:
VAR2BSNLc=:222\\:
VAR2BSNLsc=:222\\:
var-3bsnl
printf "%s=:%s:\n" VAR3BSNL 333\\\\\ 333=; printf "%s=:%s:\n" VAR3BSNLa 333\\\\\ aaa=; printf "%s=:%s:\n" VAR3BSNLA 333\\\\\ aaa=; printf "%s=:%s:\n" VAR3BSNLda 333\\\\\ \$\{a\}=; printf "%s=:%s:\n" VAR3BSNLdA 333\\\\\ \$\{A\}=; printf "%s=:%s:\n" VAR3BSNLc 333\\\\; printf "%s=:%s:\n" VAR3BSNLsc 333\\\\;
VAR3BSNL=:333\\ 333=:
VAR3BSNLa=:333\\ aaa=:
VAR3BSNLA=:333\\ aaa=:
VAR3BSNLda=:333\\ ${a}=:
VAR3BSNLdA=:333\\ ${A}=:
VAR3BSNLc=:333\\:
VAR3BSNLsc=:333\\:
var-1bsnl-space
printf "%s=:%s:\n" VAR1BSNL00 first\ line; printf "%s=:%s:\n" VAR1BSNL0 first\ line\ no\ space\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLs first\ line\ one\ space\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLss first\ line\ two\ spaces\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLt first\ line\ one\ tab\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLtt first\ line\ two\ tabs\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLxx first\ line\ many\ spaces\ and\ tabs\ \[\ \ \ \ \]\ on\ second\ line;
VAR1BSNL00=:first line:
VAR1BSNL0=:first line no space on second line:
VAR1BSNLs=:first line one space on second line:
VAR1BSNLss=:first line two spaces on second line:
VAR1BSNLt=:first line one tab on second line:
VAR1BSNLtt=:first line two tabs on second line:
VAR1BSNLxx=:first line many spaces and tabs [ ] on second line:
cmd-1bsnl
echo :'first line\
#second line without space\
third line':
:first line\
#second line without space\
third line:
echo :'first line\
second line spaces should be retained':
:first line\
second line spaces should be retained:
echo :'first line\
second line tab should be elided':
:first line\
second line tab should be elided:
echo :'first line\
only one tab should be elided, second tab remains'
:first line\
only one tab should be elided, second tab remains
cmd-1bsnl-eof
echo :'command ending with backslash-newline'; \
:command ending with backslash-newline
cmd-2bsnl
echo take one\\
take one\
echo take two\\
take two\
echo take three\\
take three\
cmd-3bsnl
echo :'first line\\\
#second line without space\\\
third line':
:first line\\\
#second line without space\\\
third line:
echo :'first line\\\
second line spaces should be retained':
:first line\\\
second line spaces should be retained:
echo :'first line\\\
second line tab should be elided':
:first line\\\
second line tab should be elided:
echo :'first line\\\
only one tab should be elided, second tab remains'
:first line\\\
only one tab should be elided, second tab remains
exit status 0

View File

@ -0,0 +1,246 @@
# $Id: escape.mk,v 1.1.1.2 2014/11/06 01:40:37 sjg Exp $
#
# Test backslash escaping.
# Extracts from the POSIX 2008 specification
# <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html>:
#
# Comments start with a <number-sign> ( '#' ) and continue until an
# unescaped <newline> is reached.
#
# When an escaped <newline> (one preceded by a <backslash>) is found
# anywhere in the makefile except in a command line, an include
# line, or a line immediately preceding an include line, it shall
# be replaced, along with any leading white space on the following
# line, with a single <space>.
#
# When an escaped <newline> is found in a command line in a
# makefile, the command line shall contain the <backslash>, the
# <newline>, and the next line, except that the first character of
# the next line shall not be included if it is a <tab>.
#
# When an escaped <newline> is found in an include line or in a
# line immediately preceding an include line, the behavior is
# unspecified.
#
# Notice that the behaviour of <backslash><backslash> or
# <backslash><anything other than newline> is not mentioned. I think
# this implies that <backslash> should be taken literally everywhere
# except before <newline>.
#
# Our practice, despite what POSIX might say, is that "\#"
# in a variable assignment stores "#" as part of the value.
# The "\" is not taken literally, and the "#" does not begin a comment.
#
# Also, our practice is that an even number of backslashes before a
# newline in a variable assignment simply stores the backslashes as part
# of the value, and treats the newline as though it was not escaped.
# Similarly, ann even number of backslashes before a newline in a
# command simply uses the backslashes as part of the command test, but
# does not escape the newline. This is compatible with GNU make.
all: .PHONY
# We will add dependencies like "all: yet-another-test" later.
# Some variables to be expanded in tests
#
a = aaa
A = ${a}
# Backslash at end of line in a comment\
should continue the comment. \
# This is also tested in comment.mk.
__printvars: .USE .MADE
@echo ${.TARGET}
${.ALLSRC:@v@ printf "%s=:%s:\n" ${v:Q} ${${v}:Q}; @}
# Embedded backslash in variable should be taken literally.
#
VAR1BS = 111\111
VAR1BSa = 111\${a}
VAR1BSA = 111\${A}
VAR1BSda = 111\$${a}
VAR1BSdA = 111\$${A}
VAR1BSc = 111\# backslash escapes comment char, so this is part of the value
VAR1BSsc = 111\ # This is a comment. Value ends with <backslash><space>
all: var-1bs
var-1bs: .PHONY __printvars VAR1BS VAR1BSa VAR1BSA VAR1BSda VAR1BSdA \
VAR1BSc VAR1BSsc
# Double backslash in variable should be taken as two literal backslashes.
#
VAR2BS = 222\\222
VAR2BSa = 222\\${a}
VAR2BSA = 222\\${A}
VAR2BSda = 222\\$${a}
VAR2BSdA = 222\\$${A}
VAR2BSc = 222\\# backslash does not escape comment char, so this is a comment
VAR2BSsc = 222\\ # This is a comment. Value ends with <backslash><backslash>
all: var-2bs
var-2bs: .PHONY __printvars VAR2BS VAR2BSa VAR2BSA VAR2BSda VAR2BSdA \
VAR2BSc VAR2BSsc
# Backslash-newline in a variable setting is replaced by a single space.
#
VAR1BSNL = 111\
111
VAR1BSNLa = 111\
${a}
VAR1BSNLA = 111\
${A}
VAR1BSNLda = 111\
$${a}
VAR1BSNLdA = 111\
$${A}
VAR1BSNLc = 111\
# this should be processed as a comment
VAR1BSNLsc = 111\
# this should be processed as a comment
all: var-1bsnl
var-1bsnl: .PHONY
var-1bsnl: .PHONY __printvars \
VAR1BSNL VAR1BSNLa VAR1BSNLA VAR1BSNLda VAR1BSNLdA \
VAR1BSNLc VAR1BSNLsc
# Double-backslash-newline in a variable setting.
# Both backslashes should be taken literally, and the newline is NOT escaped.
#
# The second lines below each end with '=' so that they will not
# generate syntax errors regardless of whether or not they are
# treated as part of the value.
#
VAR2BSNL = 222\\
222=
VAR2BSNLa = 222\\
${a}=
VAR2BSNLA = 222\\
${A}=
VAR2BSNLda = 222\\
$${a}=
VAR2BSNLdA = 222\\
$${A}=
VAR2BSNLc = 222\\
# this should be processed as a comment
VAR2BSNLsc = 222\\
# this should be processed as a comment
all: var-2bsnl
var-2bsnl: .PHONY __printvars \
VAR2BSNL VAR2BSNLa VAR2BSNLA VAR2BSNLda VAR2BSNLdA \
VAR2BSNLc VAR2BSNLsc
# Triple-backslash-newline in a variable setting.
# First two should be taken literally, and last should escape the newline.
#
# The second lines below each end with '=' so that they will not
# generate syntax errors regardless of whether or not they are
# treated as part of the value.
#
VAR3BSNL = 333\\\
333=
VAR3BSNLa = 333\\\
${a}=
VAR3BSNLA = 333\\\
${A}=
VAR3BSNLda = 333\\\
$${a}=
VAR3BSNLdA = 333\\\
$${A}=
VAR3BSNLc = 333\\\
# this should be processed as a comment
VAR3BSNLsc = 333\\\
# this should be processed as a comment
all: var-3bsnl
var-3bsnl: .PHONY __printvars \
VAR3BSNL VAR3BSNLa VAR3BSNLA VAR3BSNLda VAR3BSNLdA \
VAR3BSNLc VAR3BSNLsc
# Backslash-newline in a variable setting, plus any amount of white space
# on the next line, is replaced by a single space.
#
VAR1BSNL00= first line\
# above line is entirely empty, and this is a comment
VAR1BSNL0= first line\
no space on second line
VAR1BSNLs= first line\
one space on second line
VAR1BSNLss= first line\
two spaces on second line
VAR1BSNLt= first line\
one tab on second line
VAR1BSNLtt= first line\
two tabs on second line
VAR1BSNLxx= first line\
many spaces and tabs [ ] on second line
all: var-1bsnl-space
var-1bsnl-space: .PHONY __printvars \
VAR1BSNL00 VAR1BSNL0 VAR1BSNLs VAR1BSNLss VAR1BSNLt VAR1BSNLtt \
VAR1BSNLxx
# Backslash-newline in a command is retained.
#
# The "#" in "# second line without space" makes it a comment instead
# of a syntax error if the preceding line is parsed incorretly.
# The ":" in "third line':" makes it look like the start of a
# target instead of a syntax error if the first line is parsed incorrectly.
#
all: cmd-1bsnl
cmd-1bsnl: .PHONY
@echo ${.TARGET}
echo :'first line\
#second line without space\
third line':
echo :'first line\
second line spaces should be retained':
echo :'first line\
second line tab should be elided':
echo :'first line\
only one tab should be elided, second tab remains'
# When backslash-newline appears at the end of a command script,
# both the backslash and the newline should be passed to the shell.
# The shell should elide the backslash-newline.
#
all: cmd-1bsnl-eof
cmd-1bsnl-eof:
@echo ${.TARGET}
echo :'command ending with backslash-newline'; \
# above line must be blank
# Double-backslash-newline in a command.
# Both backslashes are retained, but the newline is not escaped.
# XXX: This may differ from POSIX, but matches gmake.
#
# When make passes two backslashes to the shell, the shell will pass one
# backslash to the echo commant.
#
all: cmd-2bsnl
cmd-2bsnl: .PHONY
@echo ${.TARGET}
echo take one\\
# this should be a comment
echo take two\\
echo take three\\
# Triple-backslash-newline in a command is retained.
#
all: cmd-3bsnl
cmd-3bsnl: .PHONY
@echo ${.TARGET}
echo :'first line\\\
#second line without space\\\
third line':
echo :'first line\\\
second line spaces should be retained':
echo :'first line\\\
second line tab should be elided':
echo :'first line\\\
only one tab should be elided, second tab remains'

Some files were not shown because too many files have changed in this diff Show More