summaryrefslogtreecommitdiff
path: root/devel/bmake/files
diff options
context:
space:
mode:
authorjoerg <joerg>2010-04-20 13:32:27 +0000
committerjoerg <joerg>2010-04-20 13:32:27 +0000
commitee050f037514ab596ac478252aa13f0865dfd8c3 (patch)
tree89b1f8582ca03e9c5ce6ce55ed83ed159ba6337e /devel/bmake/files
parent2b6c679daef05b831209c18a2dd1b98d7a5b0037 (diff)
downloadpkgsrc-ee050f037514ab596ac478252aa13f0865dfd8c3.tar.gz
Import bmake-20100414:
- Resolve argv[0] with realpath if needed - Add :tA to realpath(3)ify variables - Support for .info, .warning, .error, .ERROR - Unit tests for .ERROR / .error; never make .ERROR the default target - Fix for .ALLSRC being populated twice - Support for .MAKE_MODE, .MAKE.MAKEFILE_PREFERENCE, .MAKE_DEPENDFILE - Haiku support - Improved diagnostics for .for with multiple variables - Rewrite bootstrap to not use make - Fix for -m .../ - Add support for .unexport - Catch typoes in .el*if etc - Fix parsing of :S;...;...; applied to .for loop iterators appearing in dependency lines
Diffstat (limited to 'devel/bmake/files')
-rw-r--r--devel/bmake/files/make-bootstrap.sh.in68
-rw-r--r--devel/bmake/files/realpath.c196
-rw-r--r--devel/bmake/files/unit-tests/doterror20
-rw-r--r--devel/bmake/files/unit-tests/error6
-rw-r--r--devel/bmake/files/unit-tests/forsubst10
-rw-r--r--devel/bmake/files/unit-tests/unexport8
-rw-r--r--devel/bmake/files/unit-tests/unexport-env14
7 files changed, 322 insertions, 0 deletions
diff --git a/devel/bmake/files/make-bootstrap.sh.in b/devel/bmake/files/make-bootstrap.sh.in
new file mode 100644
index 00000000000..64cb9e4d308
--- /dev/null
+++ b/devel/bmake/files/make-bootstrap.sh.in
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+set -e
+
+srcdir=@srcdir@
+
+DEFAULT_SYS_PATH="@default_sys_path@"
+
+CC="@CC@"
+CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS} \
+ -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\""
+
+MAKE_VERSION=`sed -n '/^MAKE_VERSION=/s,.*=[^0-9]*,,p' Makefile`
+
+MDEFS="-D@force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" -DMAKE_VERSION=\"$MAKE_VERSION\""
+
+LDFLAGS="@LDFLAGS@"
+LIBS="@LIBS@"
+
+do_compile2() {
+ obj="$1"; shift
+ src="$1"; shift
+ echo ${CC} -c ${CFLAGS} "$@" -o "$obj" "$src"
+ ${CC} -c ${CFLAGS} "$@" -o "$obj" "$src"
+}
+
+do_compile() {
+ obj="$1"; shift
+ src=`basename "$obj" .o`.c
+
+ for d in "$srcdir" "$srcdir/lst.lib"
+ do
+ test -s "$d/$src" || continue
+
+ do_compile2 "$obj" "$d/$src" "$@" || exit 1
+ return
+ done
+ echo "Unknown object file '$1'" >&2
+ exit 1
+}
+
+do_link() {
+ output="$1"; shift
+ echo ${CC} ${LDFLAGS} -o "$output" "$@" ${LIBS}
+ ${CC} ${LDFLAGS} -o "$output" "$@" ${LIBS}
+}
+
+BASE_OBJECTS="arch.o buf.o compat.o cond.o dir.o for.o getopt hash.o \
+job.o make.o make_malloc.o parse.o sigcompat.o str.o strlist.o \
+suff.o targ.o trace.o var.o util.o"
+
+LST_OBJECTS="lstAppend.o lstDupl.o lstInit.o lstOpen.o \
+lstAtEnd.o lstEnQueue.o lstInsert.o lstAtFront.o lstIsAtEnd.o \
+lstClose.o lstFind.o lstIsEmpty.o lstRemove.o lstConcat.o \
+lstFindFrom.o lstLast.o lstReplace.o lstFirst.o lstDatum.o \
+lstForEach.o lstMember.o lstSucc.o lstDeQueue.o lstForEachFrom.o \
+lstDestroy.o lstNext.o lstPrev.o"
+
+LIB_OBJECTS="@LIBOBJS@"
+
+do_compile main.o ${MDEFS}
+
+for o in ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS}
+do
+ do_compile "$o"
+done
+
+do_link bmake main.o ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS}
diff --git a/devel/bmake/files/realpath.c b/devel/bmake/files/realpath.c
new file mode 100644
index 00000000000..9783fefb260
--- /dev/null
+++ b/devel/bmake/files/realpath.c
@@ -0,0 +1,196 @@
+/* $Id: realpath.c,v 1.1.1.1 2010/04/20 13:32:27 joerg Exp $ */
+/* from: $NetBSD: realpath.c,v 1.1.1.1 2010/04/20 13:32:27 joerg Exp $ */
+
+/*
+ * Copyright (c) 1989, 1991, 1993, 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#ifndef HAVE_REALPATHx
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+/*
+ * char *realpath(const char *path, char resolved[MAXPATHLEN]);
+ *
+ * Find the real name of path, by removing all ".", ".." and symlink
+ * components. Returns (resolved) on success, or (NULL) on failure,
+ * in which case the path which caused trouble is left in (resolved).
+ */
+char *
+realpath(const char *path, char *resolved)
+{
+ struct stat sb;
+ int idx = 0, n, nlnk = 0;
+ const char *q;
+ char *p, wbuf[2][MAXPATHLEN];
+ size_t len;
+
+ if (!path || !resolved || path == resolved)
+ return (NULL);
+
+ /*
+ * Build real path one by one with paying an attention to .,
+ * .. and symbolic link.
+ */
+
+ /*
+ * `p' is where we'll put a new component with prepending
+ * a delimiter.
+ */
+ p = resolved;
+
+ if (*path == 0) {
+ *p = 0;
+ errno = ENOENT;
+ return (NULL);
+ }
+
+ /* If relative path, start from current working directory. */
+ if (*path != '/') {
+ /* check for resolved pointer to appease coverity */
+ if (resolved && getcwd(resolved, MAXPATHLEN) == NULL) {
+ p[0] = '.';
+ p[1] = 0;
+ return (NULL);
+ }
+ len = strlen(resolved);
+ if (len > 1)
+ p += len;
+ }
+
+loop:
+ /* Skip any slash. */
+ while (*path == '/')
+ path++;
+
+ if (*path == 0) {
+ if (p == resolved)
+ *p++ = '/';
+ *p = 0;
+ return (resolved);
+ }
+
+ /* Find the end of this component. */
+ q = path;
+ do
+ q++;
+ while (*q != '/' && *q != 0);
+
+ /* Test . or .. */
+ if (path[0] == '.') {
+ if (q - path == 1) {
+ path = q;
+ goto loop;
+ }
+ if (path[1] == '.' && q - path == 2) {
+ /* Trim the last component. */
+ if (p != resolved)
+ while (*--p != '/')
+ ;
+ path = q;
+ goto loop;
+ }
+ }
+
+ /* Append this component. */
+ if (p - resolved + 1 + q - path + 1 > MAXPATHLEN) {
+ errno = ENAMETOOLONG;
+ if (p == resolved)
+ *p++ = '/';
+ *p = 0;
+ return (NULL);
+ }
+ p[0] = '/';
+ memcpy(&p[1], path,
+ /* LINTED We know q > path. */
+ q - path);
+ p[1 + q - path] = 0;
+
+ /*
+ * If this component is a symlink, toss it and prepend link
+ * target to unresolved path.
+ */
+ if (lstat(resolved, &sb) == -1) {
+ return (NULL);
+ }
+ if (S_ISLNK(sb.st_mode)) {
+ if (nlnk++ >= MAXSYMLINKS) {
+ errno = ELOOP;
+ return (NULL);
+ }
+ n = readlink(resolved, wbuf[idx], sizeof(wbuf[0]) - 1);
+ if (n < 0)
+ return (NULL);
+ if (n == 0) {
+ errno = ENOENT;
+ return (NULL);
+ }
+
+ /* Append unresolved path to link target and switch to it. */
+ if (n + (len = strlen(q)) + 1 > sizeof(wbuf[0])) {
+ errno = ENAMETOOLONG;
+ return (NULL);
+ }
+ memcpy(&wbuf[idx][n], q, len + 1);
+ path = wbuf[idx];
+ idx ^= 1;
+
+ /* If absolute symlink, start from root. */
+ if (*path == '/')
+ p = resolved;
+ goto loop;
+ }
+ if (*q == '/' && !S_ISDIR(sb.st_mode)) {
+ errno = ENOTDIR;
+ return (NULL);
+ }
+
+ /* Advance both resolved and unresolved path. */
+ p += 1 + q - path;
+ path = q;
+ goto loop;
+}
+#endif
diff --git a/devel/bmake/files/unit-tests/doterror b/devel/bmake/files/unit-tests/doterror
new file mode 100644
index 00000000000..edc30e568b5
--- /dev/null
+++ b/devel/bmake/files/unit-tests/doterror
@@ -0,0 +1,20 @@
+# $Id: doterror,v 1.1.1.1 2010/04/20 13:32:42 joerg Exp $
+
+
+.BEGIN:
+ @echo At first, I am
+
+.END:
+ @echo not reached
+
+.ERROR:
+ @echo "$@: Looks like '${.ERROR_TARGET}' is upset."
+
+all: happy sad
+
+happy:
+ @echo $@
+
+sad:
+ @echo and now: $@; exit 1
+
diff --git a/devel/bmake/files/unit-tests/error b/devel/bmake/files/unit-tests/error
new file mode 100644
index 00000000000..364c35ad104
--- /dev/null
+++ b/devel/bmake/files/unit-tests/error
@@ -0,0 +1,6 @@
+# $Id: error,v 1.1.1.1 2010/04/20 13:32:42 joerg Exp $
+
+.info just FYI
+.warning this could be serious
+.error this is fatal
+
diff --git a/devel/bmake/files/unit-tests/forsubst b/devel/bmake/files/unit-tests/forsubst
new file mode 100644
index 00000000000..3e2ab3b3de3
--- /dev/null
+++ b/devel/bmake/files/unit-tests/forsubst
@@ -0,0 +1,10 @@
+# $Id: forsubst,v 1.1.1.1 2010/04/20 13:32:42 joerg Exp $
+
+all: for-subst
+
+here := ${.PARSEDIR}
+# this should not run foul of the parser
+.for file in ${.PARSEFILE}
+for-subst: ${file:S;^;${here}/;g}
+ @echo ".for with :S;... OK"
+.endfor
diff --git a/devel/bmake/files/unit-tests/unexport b/devel/bmake/files/unit-tests/unexport
new file mode 100644
index 00000000000..1a88d6dcbda
--- /dev/null
+++ b/devel/bmake/files/unit-tests/unexport
@@ -0,0 +1,8 @@
+# $Id: unexport,v 1.1.1.1 2010/04/20 13:32:42 joerg Exp $
+
+# pick up a bunch of exported vars
+.include "export"
+
+.unexport UT_ZOO UT_FOO
+
+UT_TEST = unexport
diff --git a/devel/bmake/files/unit-tests/unexport-env b/devel/bmake/files/unit-tests/unexport-env
new file mode 100644
index 00000000000..90062455959
--- /dev/null
+++ b/devel/bmake/files/unit-tests/unexport-env
@@ -0,0 +1,14 @@
+# $Id: unexport-env,v 1.1.1.1 2010/04/20 13:32:42 joerg Exp $
+
+# pick up a bunch of exported vars
+.include "export"
+
+# an example of setting up a minimal environment.
+PATH = /bin:/usr/bin:/sbin:/usr/sbin
+
+# now clobber the environment to just PATH and UT_TEST
+UT_TEST = unexport-env
+
+# this removes everything
+.unexport-env
+.export PATH UT_TEST