summaryrefslogtreecommitdiffstats
path: root/contrib/bmake
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2013-02-01 22:55:27 +0000
committersjg <sjg@FreeBSD.org>2013-02-01 22:55:27 +0000
commitf817112dff6d3bf2855772b5112bf05748266394 (patch)
tree203f81f05d53b13df9fb85ffa3d26ac6a5f93a55 /contrib/bmake
parent6a1efe1ad9984c8085ef28facb9d7f1cc2f01b6a (diff)
parent69db492ce55c9787def3ba14dca33e52909dd5ca (diff)
downloadFreeBSD-src-f817112dff6d3bf2855772b5112bf05748266394.zip
FreeBSD-src-f817112dff6d3bf2855772b5112bf05748266394.tar.gz
Merge bmake-20130123
Approved by: marcel (mentor)
Diffstat (limited to 'contrib/bmake')
-rw-r--r--contrib/bmake/ChangeLog32
-rw-r--r--contrib/bmake/FILES64
-rw-r--r--contrib/bmake/Makefile221
-rw-r--r--contrib/bmake/Makefile.config.in16
-rw-r--r--contrib/bmake/Makefile.in190
-rw-r--r--contrib/bmake/bmake.170
-rw-r--r--contrib/bmake/bmake.cat141
-rwxr-xr-xcontrib/bmake/boot-strap267
-rw-r--r--contrib/bmake/bsd.after-import.mk30
-rw-r--r--contrib/bmake/compat.c7
-rwxr-xr-xcontrib/bmake/configure28
-rw-r--r--contrib/bmake/configure.in12
-rw-r--r--contrib/bmake/job.c38
-rw-r--r--contrib/bmake/main.c218
-rwxr-xr-xcontrib/bmake/make-bootstrap.sh.in2
-rw-r--r--contrib/bmake/make.170
-rw-r--r--contrib/bmake/makefile.in14
-rw-r--r--contrib/bmake/meta.c26
-rw-r--r--contrib/bmake/mk/ChangeLog644
-rw-r--r--contrib/bmake/mk/FILES60
-rw-r--r--contrib/bmake/mk/README401
-rw-r--r--contrib/bmake/mk/auto.dep.mk64
-rw-r--r--contrib/bmake/mk/auto.obj.mk56
-rw-r--r--contrib/bmake/mk/autoconf.mk78
-rw-r--r--contrib/bmake/mk/autodep.mk216
-rw-r--r--contrib/bmake/mk/dep.mk133
-rw-r--r--contrib/bmake/mk/dirdeps.mk414
-rw-r--r--contrib/bmake/mk/doc.mk63
-rw-r--r--contrib/bmake/mk/dpadd.mk196
-rw-r--r--contrib/bmake/mk/final.mk14
-rw-r--r--contrib/bmake/mk/gendirdeps.mk301
-rw-r--r--contrib/bmake/mk/host-target.mk31
-rw-r--r--contrib/bmake/mk/host.libnames.mk29
-rw-r--r--contrib/bmake/mk/inc.mk35
-rw-r--r--contrib/bmake/mk/init.mk44
-rw-r--r--contrib/bmake/mk/install-mk185
-rw-r--r--contrib/bmake/mk/install-new.mk53
-rw-r--r--contrib/bmake/mk/java.mk97
-rw-r--r--contrib/bmake/mk/lib.mk605
-rw-r--r--contrib/bmake/mk/libnames.mk22
-rw-r--r--contrib/bmake/mk/libs.mk54
-rw-r--r--contrib/bmake/mk/links.mk75
-rw-r--r--contrib/bmake/mk/man.mk137
-rw-r--r--contrib/bmake/mk/meta.autodep.mk262
-rw-r--r--contrib/bmake/mk/meta.stage.mk212
-rw-r--r--contrib/bmake/mk/meta.subdir.mk79
-rw-r--r--contrib/bmake/mk/meta.sys.mk139
-rwxr-xr-xcontrib/bmake/mk/meta2deps.py614
-rwxr-xr-xcontrib/bmake/mk/meta2deps.sh307
-rw-r--r--contrib/bmake/mk/mk-files.txt467
-rw-r--r--contrib/bmake/mk/nls.mk48
-rw-r--r--contrib/bmake/mk/obj.mk113
-rw-r--r--contrib/bmake/mk/options.mk58
-rw-r--r--contrib/bmake/mk/own.mk244
-rw-r--r--contrib/bmake/mk/prlist.mk36
-rw-r--r--contrib/bmake/mk/prog.mk219
-rw-r--r--contrib/bmake/mk/progs.mk87
-rw-r--r--contrib/bmake/mk/rst2htm.mk43
-rw-r--r--contrib/bmake/mk/scripts.mk52
-rw-r--r--contrib/bmake/mk/srctop.mk66
-rw-r--r--contrib/bmake/mk/subdir.mk99
-rw-r--r--contrib/bmake/mk/sys.clean-env.mk119
-rw-r--r--contrib/bmake/mk/sys.dependfile.mk47
-rw-r--r--contrib/bmake/mk/sys.mk199
-rw-r--r--contrib/bmake/mk/sys/AIX.mk197
-rw-r--r--contrib/bmake/mk/sys/Darwin.mk220
-rw-r--r--contrib/bmake/mk/sys/Generic.mk208
-rw-r--r--contrib/bmake/mk/sys/HP-UX.mk237
-rw-r--r--contrib/bmake/mk/sys/IRIX.mk199
-rw-r--r--contrib/bmake/mk/sys/Linux.mk200
-rw-r--r--contrib/bmake/mk/sys/NetBSD.mk234
-rw-r--r--contrib/bmake/mk/sys/OSF1.mk211
-rw-r--r--contrib/bmake/mk/sys/OpenBSD.mk209
-rw-r--r--contrib/bmake/mk/sys/SunOS.mk232
-rw-r--r--contrib/bmake/mk/sys/UnixWare.mk254
-rw-r--r--contrib/bmake/mk/target-flags.mk62
-rw-r--r--contrib/bmake/mk/warnings.mk148
-rw-r--r--contrib/bmake/mk/yacc.mk57
-rw-r--r--contrib/bmake/realpath.c77
-rw-r--r--contrib/bmake/unit-tests/Makefile.in4
-rw-r--r--contrib/bmake/var.c16
81 files changed, 10963 insertions, 665 deletions
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index b17fcb5..9d54c18 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,35 @@
+2013-01-27 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Merge with NetBSD make, pick up
+ o make.1: more info on how shell commands are handled.
+ o job.c,main.c: detect write errors to job pipes.
+
+2013-01-25 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (MAKE_VERSION): 20130123
+ Merge with NetBSD make, pick up
+ o meta.c: if script uses .OODATE and meta_oodate() decides
+ rebuild is needed, .OODATE will be empty - set it to .ALLSRC.
+ o var.c: in debug output indicate which variabale modifiers
+ apply to.
+ o remove Check_Cwd logic the makefiles have been fixed.
+
+2012-12-12 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * makefile.in: add a simple makefile for folk who insist on
+ ./configure; make; make install
+ it just runs boot-strap
+ * include mk/* to accommodate the above
+ * boot-strap: re-work to accommodate the above
+ mksrc defaults to $Mydir/mk
+ allow op={configure,build,install,clean,all}
+ add options to facilitate install
+ * Makefile.config.in: just the bits set by configure
+ * Makefile: bump version to 20121212
+ abandon Makefile.in (NetBSD Makefile)
+ leverage mk/* instead
+ * configure.in: ensure srcdir is absolute
+
2012-11-11 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile.in (MAKE_VERSION): 20121111
diff --git a/contrib/bmake/FILES b/contrib/bmake/FILES
index e7c7861..b75cf1c 100644
--- a/contrib/bmake/FILES
+++ b/contrib/bmake/FILES
@@ -4,7 +4,9 @@ bmake.cat1
boot-strap
bsd.after-import.mk
os.sh
-Makefile.in
+makefile.in
+Makefile
+Makefile.config.in
PSD.doc/Makefile
PSD.doc/tutorial.ms
README
@@ -120,3 +122,63 @@ unit-tests/test.exp
unit-tests/unexport
unit-tests/unexport-env
unit-tests/varcmd
+mk/ChangeLog
+mk/FILES
+mk/README
+mk/auto.obj.mk
+mk/autoconf.mk
+mk/autodep.mk
+mk/auto.dep.mk
+mk/dep.mk
+mk/doc.mk
+mk/dpadd.mk
+mk/final.mk
+mk/host-target.mk
+mk/host.libnames.mk
+mk/inc.mk
+mk/init.mk
+mk/install-mk
+mk/java.mk
+mk/lib.mk
+mk/libnames.mk
+mk/libs.mk
+mk/links.mk
+mk/man.mk
+mk/mk-files.txt
+mk/nls.mk
+mk/obj.mk
+mk/options.mk
+mk/own.mk
+mk/prlist.mk
+mk/prog.mk
+mk/progs.mk
+mk/rst2htm.mk
+mk/scripts.mk
+mk/srctop.mk
+mk/subdir.mk
+mk/sys.mk
+mk/sys.clean-env.mk
+mk/sys.dependfile.mk
+mk/sys/AIX.mk
+mk/sys/Darwin.mk
+mk/sys/Generic.mk
+mk/sys/HP-UX.mk
+mk/sys/IRIX.mk
+mk/sys/Linux.mk
+mk/sys/NetBSD.mk
+mk/sys/OSF1.mk
+mk/sys/OpenBSD.mk
+mk/sys/SunOS.mk
+mk/sys/UnixWare.mk
+mk/target-flags.mk
+mk/warnings.mk
+mk/yacc.mk
+mk/dirdeps.mk
+mk/gendirdeps.mk
+mk/install-new.mk
+mk/meta2deps.py
+mk/meta2deps.sh
+mk/meta.sys.mk
+mk/meta.autodep.mk
+mk/meta.stage.mk
+mk/meta.subdir.mk
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
new file mode 100644
index 0000000..3607326
--- /dev/null
+++ b/contrib/bmake/Makefile
@@ -0,0 +1,221 @@
+# $Id: Makefile,v 1.5 2013/01/28 19:31:58 sjg Exp $
+
+# Base version on src date
+MAKE_VERSION= 20130123
+
+PROG= bmake
+
+SRCS= \
+ arch.c \
+ buf.c \
+ compat.c \
+ cond.c \
+ dir.c \
+ for.c \
+ hash.c \
+ job.c \
+ main.c \
+ make.c \
+ make_malloc.c \
+ meta.c \
+ parse.c \
+ str.c \
+ strlist.c \
+ suff.c \
+ targ.c \
+ trace.c \
+ util.c \
+ var.c
+
+# from lst.lib/
+SRCS+= \
+ lstAppend.c \
+ lstAtEnd.c \
+ lstAtFront.c \
+ lstClose.c \
+ lstConcat.c \
+ lstDatum.c \
+ lstDeQueue.c \
+ lstDestroy.c \
+ lstDupl.c \
+ lstEnQueue.c \
+ lstFind.c \
+ lstFindFrom.c \
+ lstFirst.c \
+ lstForEach.c \
+ lstForEachFrom.c \
+ lstInit.c \
+ lstInsert.c \
+ lstIsAtEnd.c \
+ lstIsEmpty.c \
+ lstLast.c \
+ lstMember.c \
+ lstNext.c \
+ lstOpen.c \
+ lstPrev.c \
+ lstRemove.c \
+ lstReplace.c \
+ lstSucc.c
+
+# this file gets generated by configure
+.-include "Makefile.config"
+
+.if !empty(LIBOBJS)
+SRCS+= ${LIBOBJS:T:.o=.c}
+.endif
+
+# just in case
+prefix?= /usr
+srcdir?= ${.CURDIR}
+
+DEFAULT_SYS_PATH?= .../share/mk:${prefix}/share/mk
+
+CPPFLAGS+= -DUSE_META
+CFLAGS+= ${CPPFLAGS}
+CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
+CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
+CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
+COPTS.main.c+= "-DMAKE_VERSION=\"${MAKE_VERSION}\""
+
+# meta mode can be useful even without filemon
+FILEMON_H ?= /usr/include/dev/filemon/filemon.h
+.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
+COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
+.endif
+
+.PATH: ${srcdir}
+.PATH: ${srcdir}/lst.lib
+
+.if make(obj) || make(clean)
+SUBDIR+= unit-tests
+.endif
+
+# start-delete1 for bsd.after-import.mk
+# we skip a lot of this when building as part of FreeBSD etc.
+
+# list of OS's which are derrived from BSD4.4
+BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly
+# we are...
+OS!= uname -s
+# are we 4.4BSD ?
+isBSD44:=${BSD44_LIST:M${OS}}
+
+.if ${isBSD44} == ""
+MANTARGET= cat
+INSTALL?=${srcdir}/install-sh
+.if (${MACHINE} == "sun386")
+# even I don't have one of these anymore :-)
+CFLAGS+= -DPORTAR
+.elif (${MACHINE} != "sunos")
+SRCS+= sigcompat.c
+CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
+.endif
+.else
+MANTARGET?= man
+.endif
+
+# turn this on by default - ignored if we are root
+WITH_INSTALL_AS_USER=
+
+# supress with -DWITHOUT_*
+OPTIONS_DEFAULT_YES+= \
+ AUTOCONF_MK \
+ INSTALL_MK \
+ PROG_LINK
+
+OPTIONS_DEFAULT_NO+= \
+ PROG_VERSION
+
+# process options now
+.include <own.mk>
+
+.if ${MK_PROG_VERSION} == "yes"
+PROG_NAME= ${PROG}-${MAKE_VERSION}
+.if ${MK_PROG_LINK} == "yes"
+SYMLINKS+= ${PROG}-${MAKE_VERSION} ${BINDIR}/${PROG}
+.endif
+.endif
+
+EXTRACT_MAN=no
+# end-delete1
+
+MAN= ${PROG}.1
+MAN1= ${MAN}
+
+.if (${PROG} != "make")
+CLEANFILES+= my.history
+.if make(${MAN}) || !exists(${srcdir}/${MAN})
+my.history: ${MAKEFILE}
+ @(echo ".Nm"; \
+ echo "is derived from NetBSD"; \
+ echo ".Xr make 1 ."; \
+ echo "It uses autoconf to facilitate portability to other platforms."; \
+ echo ".Pp") > $@
+
+.NOPATH: ${MAN}
+${MAN}: make.1 my.history
+ @echo making $@
+ @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
+ -e '/^.Sh HISTORY/rmy.history' \
+ -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
+
+all beforeinstall: ${MAN}
+_mfromdir=.
+.endif
+.endif
+
+MANTARGET?= cat
+MANDEST?= ${MANDIR}/${MANTARGET}1
+
+.if ${MANTARGET} == "cat"
+_mfromdir=${srcdir}
+.endif
+
+.include <prog.mk>
+
+CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
+COPTS.var.c += -Wno-cast-qual
+COPTS.job.c += -Wno-format-nonliteral
+COPTS.parse.c += -Wno-format-nonliteral
+COPTS.var.c += -Wno-format-nonliteral
+
+# Force these
+SHAREDIR= ${prefix}/share
+BINDIR= ${prefix}/bin
+MANDIR= ${SHAREDIR}/man
+
+.if !exists(.depend)
+${OBJS}: config.h
+.endif
+.if ${MK_AUTOCONF_MK} == "yes"
+.include <autoconf.mk>
+.endif
+
+# make sure that MAKE_VERSION gets updated.
+main.o: ${SRCS} ${MAKEFILE}
+
+# start-delete2 for bsd.after-import.mk
+SHARE_MK?=${SHAREDIR}/mk
+MKSRC=${srcdir}/mk
+INSTALL?=${srcdir}/install-sh
+
+.if ${MK_INSTALL_MK} == "yes"
+install: install-mk
+.endif
+
+beforeinstall:
+ test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
+ test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}
+
+install-mk:
+.if exists(${MKSRC}/install-mk)
+ test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK}
+ sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK}
+.else
+ @echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
+.endif
+# end-delete2
+
+# A simple unit-test driver to help catch regressions
+accept test:
+ cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
diff --git a/contrib/bmake/Makefile.config.in b/contrib/bmake/Makefile.config.in
new file mode 100644
index 0000000..16ea66e
--- /dev/null
+++ b/contrib/bmake/Makefile.config.in
@@ -0,0 +1,16 @@
+# things set by configure
+
+prefix= @prefix@
+srcdir= @srcdir@
+CC?= @CC@
+MACHINE= @machine@
+MACHINE_ARCH= @machine_arch@
+DEFAULT_SYS_PATH= @default_sys_path@
+
+CPPFLAGS+= @CPPFLAGS@
+CFLAGS+= ${CPPFLAGS} @DEFS@
+LDFLAGS= @LDFLAGS@
+LIBOBJS= @LIBOBJS@
+LDADD= @LIBS@
+USE_META= @use_meta@
+FILEMON_H= @filemon_h@
diff --git a/contrib/bmake/Makefile.in b/contrib/bmake/Makefile.in
deleted file mode 100644
index 7936d3b..0000000
--- a/contrib/bmake/Makefile.in
+++ /dev/null
@@ -1,190 +0,0 @@
-# $NetBSD: Makefile,v 1.56 2012/05/30 21:54:23 sjg Exp $
-# @(#)Makefile 5.2 (Berkeley) 12/28/90
-
-# $Id: Makefile.in,v 1.178 2012/11/15 16:48:59 sjg Exp $
-
-PROG= bmake
-SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
- make.c parse.c str.c suff.c targ.c trace.c var.c util.c
-SRCS+= strlist.c
-SRCS+= make_malloc.c
-SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
- lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \
- lstFind.c lstFindFrom.c lstFirst.c lstForEach.c lstForEachFrom.c \
- lstInit.c lstInsert.c lstIsAtEnd.c lstIsEmpty.c lstLast.c \
- lstMember.c lstNext.c lstOpen.c lstRemove.c lstReplace.c lstSucc.c
-SRCS += lstPrev.c
-
-# you can use this Makefile if you have an earlier version of bmake.
-prefix= @prefix@
-srcdir= @srcdir@
-CC?= @CC@
-
-# Base version on src date
-MAKE_VERSION= 20121111
-MACHINE=@machine@
-MACHINE_ARCH=@machine_arch@
-DEFAULT_SYS_PATH = @default_sys_path@
-
-CPPFLAGS+= @CPPFLAGS@
-CFLAGS+= ${CPPFLAGS}
-CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
-CFLAGS+= -I. -I${srcdir} @DEFS@ ${XDEFS} -DMAKE_NATIVE
-CFLAGS+= ${CFLAGS_${.TARGET:T}}
-CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
-COPTS.main.c+= "-DMAKE_VERSION=\"${MAKE_VERSION}\""
-LDFLAGS= @LDFLAGS@
-LIBOBJS= @LIBOBJS@
-LDADD= @LIBS@
-
-.if !empty(LIBOBJS)
-SRCS+= ${LIBOBJS:T:.o=.c}
-.endif
-
-USE_META = @use_meta@
-.if ${USE_META} != "no"
-SRCS+= meta.c
-CPPFLAGS+= -DUSE_META
-FILEMON_H ?= @filemon_h@
-.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
-COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
-.endif
-.endif
-
-.PATH: ${srcdir}
-.PATH: ${srcdir}/lst.lib
-
-OS!= uname -s
-ARCH!= uname -p 2>/dev/null || uname -m
-
-# list of OS's which are derrived from BSD4.4
-isBSD44= NetBSD FreeBSD OpenBSD DragonFly
-
-.if ${OS} == "NetBSD"
-# Don't set these for anyone else since we don't know what the effect may be.
-# On FreeBSD WARNS=2 sets a bunch of -W flags that make does not handle.
-WFORMAT= 1
-WARNS=4
-.NOPATH: bmake.cat1
-.if make(install) && exists(${DESTDIR}/usr/share/doc)
-SUBDIR= PSD.doc
-.endif
-.endif
-
-.if defined(.PARSEDIR)
-# we cannot rely on anything but bmake to parse this correctly.
-.if empty(isBSD44:M${OS})
-MANTARGET=cat
-INSTALL?=${srcdir}/install-sh
-.if (${MACHINE} == "sun386")
-# even I don't have one of these anymore :-)
-CFLAGS+= -DPORTAR
-.elif (${MACHINE} != "sunos")
-SRCS+= sigcompat.c
-CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
-.endif
-.endif
-
-.if make(obj) || make(clean)
-SUBDIR+= unit-tests
-.endif
-.endif
-
-# many systems use gcc these days
-CC_IS_GCC=@GCC@
-.if ${CC_IS_GCC} == "yes"
-# problem with gcc3
-CFLAGS_var.o+= -Wno-cast-qual
-.endif
-
-CFLAGS_main.o+= "-D@force_machine@MACHINE=\"${MACHINE}\"" "-DMACHINE_ARCH=\"${MACHINE_ARCH}\""
-
-EXTRACT_MAN=no
-
-MAN=${PROG}.1
-.if (${PROG} != "make")
-my.history: ${MAKEFILE}
- @(echo ".Nm"; \
- echo "is derived from NetBSD"; \
- echo ".Xr make 1 ."; \
- echo "It uses autoconf to facilitate portability to other platforms."; \
- echo ".Pp") > $@
-
-${MAN}: make.1 my.history
- @echo making ${PROG}.1
- @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
- -e '/^.Sh HISTORY/rmy.history' \
- -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
-
-.endif
-
-.if !empty(isBSD44:M${OS})
-.if "${OS}" != "NetBSD"
-MAN1=${MAN}
-.endif
-MANTARGET?=man
-.endif
-
-MANTARGET?= cat
-MANDEST?= ${MANDIR}/${MANTARGET}1
-
-.if ${MANTARGET} == "cat"
-_mfromdir=${srcdir}
-.endif
-
-.if exists(${srcdir}/../Makefile.inc)
-.include "${srcdir}/../Makefile.inc"
-.endif
-.-include <bsd.prog.mk>
-# sigh, FreeBSD at least includes bsd.subdir.mk via bsd.obj.mk
-# so the inclusion below, results in complaints about re-defined
-# targets. For NetBSD though we need to explicitly include it.
-.if defined(.PARSEDIR)
-.if defined(SUBDIR) && !target(${SUBDIR:[1]})
-.-include <bsd.subdir.mk>
-.endif
-.endif
-
-CPPFLAGS+= -DMAKE_NATIVE
-COPTS.var.c += -Wno-cast-qual
-COPTS.job.c += -Wno-format-nonliteral
-COPTS.parse.c += -Wno-format-nonliteral
-COPTS.var.c += -Wno-format-nonliteral
-
-# Force these
-BINDIR= ${prefix}/bin
-MANDIR= ${prefix}/man
-
-arch.o: config.h
-# make sure that MAKE_VERSION gets updated.
-main.o: ${SRCS} ${MAKEFILE}
-
-MK?=${prefix}/share/mk
-MKSRC?=@mksrc@
-INSTALL?=${srcdir}/install-sh
-
-beforeinstall:
- test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
- test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}
-
-# latest version of *.mk includes an installer.
-# you should not need to set USE_OS
-install-mk:
-.if exists(${MKSRC}/install-mk)
- test -d ${DESTDIR}${MK} || ${INSTALL} -m 775 -d ${DESTDIR}${MK}
- ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${MK} ${USE_OS}
-.else
- @echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
-.endif
-
-.ifdef TOOLDIR
-# this is a native netbsd build,
-# use libutil rather than the local emalloc etc.
-CPPFLAGS+= -DUSE_EMALLOC
-LDADD+=-lutil
-DPADD+=${LIBUTIL}
-.endif
-
-# A simple unit-test driver to help catch regressions
-accept test:
- cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
diff --git a/contrib/bmake/bmake.1 b/contrib/bmake/bmake.1
index d7ed08a..82cec21 100644
--- a/contrib/bmake/bmake.1
+++ b/contrib/bmake/bmake.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.209 2012/10/08 15:09:48 christos Exp $
+.\" $NetBSD: make.1,v 1.210 2013/01/27 18:52:01 sjg 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 October 8, 2012
+.Dd January 23, 2013
.Dt MAKE 1
.Os
.Sh NAME
@@ -468,6 +468,50 @@ except that the effect can be limited to a single line of a script.
A
.Ql Ic \-
causes any non-zero exit status of the command line to be ignored.
+.Pp
+When
+.Nm
+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
+.Nm
+will attempt direct execution.
+.Pp
+Since
+.Nm
+will
+.Xr chdir 2
+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.
@@ -2027,28 +2071,6 @@ 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
-Unlike other
-.Nm
-programs, this implementation by default executes all commands for a given
-target using a single shell invocation.
-This is done for both efficiency and to simplify error handling in remote
-command invocations.
-Typically this is transparent to the user, unless the target commands change
-the current working directory using
-.Dq cd
-or
-.Dq chdir .
-To be compatible with Makefiles that do this, one can use
-.Fl B
-to disable this behavior.
-.Pp
-In compatibility 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
-.Nm
-will attempt direct execution.
.Sh SEE ALSO
.Xr mkdep 1
.Sh HISTORY
diff --git a/contrib/bmake/bmake.cat1 b/contrib/bmake/bmake.cat1
index 2d54ee2..7800726 100644
--- a/contrib/bmake/bmake.cat1
+++ b/contrib/bmake/bmake.cat1
@@ -284,6 +284,32 @@ SSHHEELLLL CCOOMMMMAANNDDSS
line of a script. A `--' 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.
+
+ 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:
+
+
+ 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`
+
VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Variables in make are much like variables in the shell, and, by tradi-
tion, consist of all upper-case letters.
@@ -1293,19 +1319,6 @@ CCOOMMPPAATTIIBBIILLIITTYY
stops them being treated as syntax, and removes some obscure problems
using them in .if statements.
- Unlike other bbmmaakkee programs, this implementation by default executes all
- commands for a given target using a single shell invocation. This is
- done for both efficiency and to simplify error handling in remote command
- invocations. Typically this is transparent to the user, unless the tar-
- get commands change the current working directory using ``cd'' or
- ``chdir''. To be compatible with Makefiles that do this, one can use --BB
- to disable this behavior.
-
- In compatibility 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 execu-
- tion.
-
SSEEEE AALLSSOO
mkdep(1)
@@ -1327,4 +1340,4 @@ BBUUGGSS
There is no way of escaping a space character in a filename.
-NetBSD 5.1 October 8, 2012 NetBSD 5.1
+NetBSD 5.1 January 23, 2013 NetBSD 5.1
diff --git a/contrib/bmake/boot-strap b/contrib/bmake/boot-strap
index 660b766..7eff5f6 100755
--- a/contrib/bmake/boot-strap
+++ b/contrib/bmake/boot-strap
@@ -3,23 +3,52 @@
# boot-strap
#
# SYNOPSIS:
-# boot-strap [--"configure_arg" ... ][-s "srcdir"][-m "mksrc"]\\
-# ["prefix" ["bmakesrc" ["mksrc"]]]
+# boot-strap ["options"]
+# boot-strap --prefix=/opt --install
+# boot-strap --prefix=$HOME --install-host-target -DWITH_PROG_VERSION
+# boot-strap ["options"] op=build
+# boot-strap ["options"] op=install
#
# DESCRIPTION:
# This script is used to configure/build bmake it builds for
-# each OS in a subdir to keep the src clean.
-# On successful completion it echos commands to put the new
-# bmake binary into the /configs tree (if it exists)
-# (http://www.crufty.net/FreeWare/configs.html), $prefix/bin
-# and a suitable ~/*bin directory.
+# each host-target in a different subdir to keep the src clean.
+# There is no requirement for an existing make(1).
#
+# On successful completion if no '--install' flag is given,
+# it echos a command to do installation.
+#
+# The variable "op" defaults to 'all', and is affected by
+# '--install' flag as above.
+# Other values include:
+#
+# configure
+# Just run 'configure'
+#
+# build
+# If 'configure' has not been done, do it, then
+# run the build script, and finally 'test'.
+#
+# install
+# If 'build' has not been done, do it, 'test' then
+# install.
+#
+# clean
+# attempt to clean up
+#
+# test
+# run the unit-tests. Done automatically after 'build'
+# and before 'install'.
+#
+# The above are leveraged by a trivial makefile for the benefit
+# of those that have './configure; make; make install' baked
+# into them.
+#
# Options:
#
# -c "rc"
# Pick up settings from "rc".
# We look for '.bmake-boot-strap.rc' before processing
-# options.
+# options (unless SKIP_RC is set in environment).
#
# --share "share_dir"
# Where to put man pages and mk files.
@@ -28,9 +57,28 @@
#
# --mksrc "mksrc"
# Indicate where the mk files can be found.
-# Default is ./mk or ../mk, set to 'none' to force
-# building without "mksrc" but in that case a sys.mk
-# needs to exist in the default syspath ($share_dir/mk)
+# Default is $Mydir/mk
+#
+# --install
+# If build and test work, run bmake install.
+# BINDIR=$prefix/bin
+# SHAREDIR=$prefix/share
+#
+# --install-host-target
+# As for '--install' but BINDIR=$prefix/$HOST_TARGET/bin
+# This is useful when $prefix/ is shared by multiple
+# machines.
+#
+# Flags relevant when installing:
+#
+# -DWITHOUT_INSTALL_MK
+# Skip installing mk files.
+# By default they will be installed to $prefix/share/mk
+#
+# -DWITH_PROG_VERSION
+# Install 'bmake' as 'bmake-$MAKE_VERSION'
+# A symlink will be made as 'bmake' unless
+# -DWITHOUT_PROG_LINK is set.
#
# Possibly useful configure_args:
#
@@ -63,7 +111,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: boot-strap,v 1.39 2012/03/26 17:08:22 sjg Exp $
+# $Id: boot-strap,v 1.42 2013/01/25 20:20:33 sjg Exp $
#
# @(#) Copyright (c) 2001 Simon J. Gerraty
#
@@ -85,11 +133,10 @@ case "$Mydir" in
*) Mydir=`cd "$Mydir" && 'pwd'`;;
esac
-
Usage() {
[ "$1" ] && echo "ERROR: $@" >&2
echo "Usage:" >&2
- echo "$0 [--<configure_arg> ...][-s <srcdir>][-m <mksrc>][<prefix> [[<srcdir>] [<mksrc>]]]" >&2
+ echo "$0 [--<configure_arg> ...][<prefix>][--install]" >&2
exit 1
}
@@ -110,28 +157,55 @@ source_rc() {
done
}
+cmd_args="$@"
+
+# --install[-host-target] will set this
+INSTALL_PREFIX=
+# other things we pass to install step
+INSTALL_ARGS=
CONFIGURE_ARGS=
MAKESYSPATH=
# pick a useful default prefix (for me at least ;-)
for prefix in /opt/$HOST_TARGET "$HOME/$HOST_TARGET" /usr/pkg /usr/local ""
do
- [ -d "${prefix:-.}" ] && break
+ [ -d "${prefix:-.}" ] || continue
+ case "$prefix" in
+ */$HOST_TARGET)
+ p=`dirname $prefix`
+ if [ -d $p/share ]; then
+ INSTALL_BIN=$HOST_TARGET/bin
+ prefix=$p
+ fi
+ ;;
+ esac
+ echo "NOTE: default prefix=$prefix ${INSTALL_BIN:+INSTALL_BIN=$INSTALL_BIN}"
+ break
done
-srcdir=
-mksrc=
+srcdir=$Mydir
+mksrc=$Mydir/mk
objdir=
quiet=:
-source_rc .bmake-boot-strap.rc . "$Mydir/.." "$HOME"
+${SKIP_RC:+:} source_rc .bmake-boot-strap.rc . "$Mydir/.." "$HOME"
get_optarg() {
expr "x$1" : "x[^=]*=\\(.*\\)"
}
+here=`'pwd'`
+if [ $here = $Mydir ]; then
+ # avoid polution
+ OBJROOT=../
+fi
+
+op=all
+BMAKE=
+
while :
do
case "$1" in
--) shift; break;;
+ --help) sed -n -e "1d;/RCSid/,\$d" -e '/^#\.[a-z]/d' -e '/^#/s,^# *,,p' $0; exit 0;;
--prefix) prefix="$2"; shift;;
--prefix=*) prefix=`get_optarg "$1"`;;
--src=*) srcdir=`get_optarg "$1"`;;
@@ -144,6 +218,13 @@ do
--with-default-sys-path)
CONFIGURE_ARGS="$1 $2"
MAKESYSPATH="$2"; shift;;
+ --install) INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix};;
+ --install-host-target)
+ INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix}
+ INSTALL_BIN=$HOST_TARGET/bin;;
+ --install-destdir=*) INSTALL_DESTDIR=`get_optarg "$1"`;;
+ --install-prefix=*) INSTALL_PREFIX=`get_optarg "$1"`;;
+ -DWITH*) INSTALL_ARGS="$INSTALL_ARGS $1";;
-s|--src) srcdir="$2"; shift;;
-m|--mksrc) mksrc="$2"; shift;;
-o|--objdir) objdir="$2"; shift;;
@@ -261,7 +342,7 @@ none|-) # we don't want it
esac
# Ok, get to work...
-objdir="${objdir:-$OS}"
+objdir="${objdir:-$OBJROOT$HOST_TARGET}"
[ -d "$objdir" ] || mkdir -p "$objdir"
[ -d "$objdir" ] || mkdir "$objdir"
cd "$objdir" || exit 1
@@ -301,88 +382,80 @@ if [ "$mksrc" ]; then
export CFLAGS_MF CFLAGS_MD
fi
-$srcdir/configure $CONFIGURE_ARGS || exit 1
-chmod 755 make-bootstrap.sh || exit 1
-./make-bootstrap.sh || exit 1
-if [ -z "$MAKESYSPATH" ]; then
- add_path "${share_dir:-...}/mk" MAKESYSPATH
- case "$HOST_TARGET" in
- netbsd*) add_path /usr/share/mk MAKESYSPATH;;
- esac
-fi
-if [ -s "${mksrc:-/dev/null}/install-mk" ]; then
- sh "${mksrc}/install-mk" "$objdir/mk"
- case "$MAKESYSPATH" in
- .../mk*) ;;
- *) MAKESYSPATH=".../mk:${MAKESYSPATH}";;
- esac
-fi
+# this makes it easy to run the bmake we just built
+# the :tA dance is needed because 'pwd' and even /bin/pwd
+# may not give the same result as realpath().
+Bmake() {
+ (
+ cd $Mydir &&
+ MAKESYSPATH=$mksrc SRCTOP=$Mydir OBJTOP=$objdir \
+ MAKEOBJDIR='${.CURDIR:S,${SRCTOP:tA},${OBJTOP:tA},}' \
+ ${BMAKE:-$objdir/bmake} -f $Mydir/Makefile "$@"
+ )
+}
+
# make sure test below uses the same diff that configure did
TOOL_DIFF=`type diff | sed 's,[()],,g;s,^[^/][^/]*,,;q'`
-export MAKESYSPATH TOOL_DIFF
-if [ "$mksrc" ]; then
- $objdir/bmake test || exit 1
-else
- # assume nothing
- $objdir/bmake -r -m / test || exit 1
-fi
-# If -q given, we don't want all the install instructions
-$quiet exit 0
-
-make_version=`./bmake -r -m / -f ./Makefile -V MAKE_VERSION | ( read one two; echo $one )`
-bmake_version=bmake-$make_version
-
-if [ -s /usr/share/tmac/andoc.tmac ]; then
- # this should be ok
- man_subdir=man1
- man_src=$srcdir/bmake.1
-else
- # guess not
- man_subdir=cat1
- man_src=$srcdir/bmake.cat1
-fi
+export TOOL_DIFF
-install_prefix() {
- (
- bin_dir=
- share_dir=
- man_dir=
- mk_dir=
- while :
- do
- case "$1" in
- *=*) eval "$1"; shift;;
- *) break;;
- esac
- done
- bin_dir=${bin_dir:-$1/bin}
- share_dir=${share_dir:-`ShareDir "$1"`}
- man_dir=${man_dir:-$share_dir/man}
- mk_dir=${mk_dir:-$share_dir/mk}
- echo
- echo Commands to install into $1/
- echo
- echo mkdir -p $bin_dir
- echo cp $objdir/bmake $bin_dir/$bmake_version
- echo rm -f $bin_dir/bmake
- echo ln -s $bmake_version $bin_dir/bmake
- echo mkdir -p $man_dir/$man_subdir
- echo cp $man_src $man_dir/$man_subdir/bmake.1
- if [ "$mksrc" ]; then
- ev=`env | grep '_MK='`
- echo $ev sh $mksrc/install-mk $mk_dir
+op_configure() {
+ $srcdir/configure $CONFIGURE_ARGS || exit 1
+}
+
+op_build() {
+ [ -s make-bootstrap.sh ] || op_configure
+ chmod 755 make-bootstrap.sh || exit 1
+ ./make-bootstrap.sh || exit 1
+ case "$op" in
+ build) op_test;;
+ esac
+}
+
+op_test() {
+ [ -x bmake ] || op_build
+ Bmake test || exit 1
+}
+
+op_clean() {
+ if [ -x bmake ]; then
+ ln bmake bmake$$
+ BMAKE=$objdir/bmake$$ Bmake clean
+ rm -f bmake$$
+ elif [ $objdir != $srcdir ]; then
+ rm -rf *
fi
- )
}
-case "$prefix/" in
-"$HOME"/*) ;;
-*) CONFIGS=${CONFIGS:-/configs}
- [ -d $CONFIGS ] &&
- install_prefix mksrc= "$CONFIGS/$OS/$OSMAJOR.X/$MACHINE_ARCH$prefix"
- # I like to keep a copy here...
- install_prefix share_dir="$HOME/share" "$HOME/$HOST_TARGET"
- ;;
-esac
+op_install() {
+ op_test
+ case "$INSTALL_PREFIX,$INSTALL_BIN,$prefix" in
+ ,$HOST_TARGET/bin,*/$HOST_TARGET)
+ INSTALL_PREFIX=`dirname $prefix`
+ ;;
+ esac
+ INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix}
+ Bmake install prefix=$INSTALL_PREFIX BINDIR=$INSTALL_PREFIX/${INSTALL_BIN:-bin} ${INSTALL_DESTDIR:+DESTDIR=$INSTALL_DESTDIR} $INSTALL_ARGS || exit 1
+}
+
+op_all() {
+ rm -f make-bootstrap.sh bmake *.o
+ if [ -n "$INSTALL_PREFIX" ]; then
+ op_install
+ else
+ op_test
+ MAKE_VERSION=`sed -n '/^MAKE_VERSION/ { s,.*= *,,;p; }' $srcdir/Makefile`
+ echo You can install by running:
+ echo
+ echo $0 $cmd_args op=install
+ echo
+ echo "Use --install-prefix=/something to install somewhere other than $prefix"
+ echo "Use --install-destdir=/somewhere to set DESTDIR during install"
+ echo "Use --install-host-target to use INSTALL_BIN=$HOST_TARGET/bin"
+ echo "Use -DWITH_PROG_VERSION to install as bmake-$MAKE_VERSION"
+ echo "Use -DWITHOUT_PROG_LINK to supress bmake -> bmake-$MAKE_VERSION symlink"
+ echo "Use -DWITHOUT_INSTALL_MK to skip installing files to $prefix/share/mk"
+ fi
+}
-install_prefix "$prefix"
+op_$op
+exit 0
diff --git a/contrib/bmake/bsd.after-import.mk b/contrib/bmake/bsd.after-import.mk
index 6cd442a..85bd2c1 100644
--- a/contrib/bmake/bsd.after-import.mk
+++ b/contrib/bmake/bsd.after-import.mk
@@ -1,4 +1,4 @@
-# $Id: bsd.after-import.mk,v 1.9 2012/09/20 00:30:15 sjg Exp $
+# $Id: bsd.after-import.mk,v 1.11 2012/12/29 19:32:25 sjg Exp $
# This makefile is for use when integrating bmake into a BSD build
# system. Use this makefile after importing bmake.
@@ -48,36 +48,36 @@ DEFAULT_SYS_PATH= .../share/mk:/usr/share/mk
BOOTSTRAP_ARGS = \
--with-default-sys-path='${DEFAULT_SYS_PATH}' \
--prefix /usr \
- --share /usr/share \
- --mksrc none
+ --share /usr/share
+
# run boot-strap with minimal influence
bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE}
- HOME=/ ${BMAKE_SRC}/boot-strap ${BOOTSTRAP_ARGS} ${BOOTSTRAP_XTRAS}
+ HOME=/ ${BMAKE_SRC}/boot-strap -o ${HOST_OS} ${BOOTSTRAP_ARGS} ${BOOTSTRAP_XTRAS}
touch ${.TARGET}
# Makefiles need a little more tweaking than say config.h
MAKEFILE_SED = sed -e '/^MACHINE/d' \
-e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \
-e 's,^.-include,.sinclude,' \
+ -e '/^\..*include *</ { s,<,<bsd.,;/autoconf/d; }' \
-e 's,${SRCTOP},$${SRCTOP},g'
# These are the simple files we want to capture
-configured_files= config.h unit-tests/Makefile
+configured_files= config.h Makefile.config unit-tests/Makefile
after-import: bootstrap ${MAKEFILE}
-.for f in ${configured_files:N*Makefile}
+.for f in ${configured_files:M*.[ch]}
@echo Capturing $f
@mkdir -p ${${.CURDIR}/$f:L:H}
- @cmp -s ${.CURDIR}/$f ${HOST_OS}/$f || \
- cp ${HOST_OS}/$f ${.CURDIR}/$f
+ @(echo '/* $$${HOST_OS}$$ */'; cat ${HOST_OS}/$f) > ${.CURDIR}/$f
.endfor
-.for f in ${configured_files:M*Makefile}
+.for f in ${configured_files:M*Makefile*}
@echo Capturing $f
@mkdir -p ${${.CURDIR}/$f:L:H}
@(echo '# This is a generated file, do NOT edit!'; \
echo '# See ${_this:S,${SRCTOP}/,,}'; \
- echo '#'; echo '# $$${OS}$$'; echo; \
+ echo '#'; echo '# $$${HOST_OS}$$'; echo; \
echo 'SRCTOP?= $${.CURDIR:${${.CURDIR}/$f:L:H:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \
${MAKEFILE_SED} ${HOST_OS}/$f ) > ${.CURDIR}/$f
.endfor
@@ -87,18 +87,22 @@ _makefile: bootstrap ${MAKEFILE}
@echo Generating ${.CURDIR}/Makefile
@(echo '# This is a generated file, do NOT edit!'; \
echo '# See ${_this:S,${SRCTOP}/,,}'; \
- echo '#'; echo '# $$${OS}$$'; \
+ echo '#'; echo '# $$${HOST_OS}$$'; \
echo; echo '.sinclude "Makefile.inc"'; \
echo; echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \
echo; echo '# look here first for config.h'; \
echo 'CFLAGS+= -I$${.CURDIR}'; echo; \
- ${MAKEFILE_SED} ${HOST_OS}/Makefile; \
+ echo '# for after-import'; \
+ echo 'CLEANDIRS+= ${HOST_OS}'; \
+ echo 'CLEANFILES+= bootstrap'; echo; \
+ ${MAKEFILE_SED} \
+ ${1 2:L:@n@-e '/start-delete$n/,/end-delete$n/d'@} \
+ ${BMAKE_SRC}/Makefile; \
echo; echo '# override some simple things'; \
echo 'BINDIR= /usr/bin'; \
echo 'MANDIR= ${MANDIR:U/usr/share/man}'; \
echo; echo '# make sure we get this'; \
echo 'CFLAGS+= $${COPTS.$${.IMPSRC:T}}'; \
- echo 'CLEANFILES+= bootstrap'; \
echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \
echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \
echo ) > ${.TARGET}
diff --git a/contrib/bmake/compat.c b/contrib/bmake/compat.c
index 4cc699e..8f931cb 100644
--- a/contrib/bmake/compat.c
+++ b/contrib/bmake/compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg Exp $ */
+/* $NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg 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.90 2012/10/07 19:17:31 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg 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.90 2012/10/07 19:17:31 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -377,7 +377,6 @@ again:
Fatal("Could not fork");
}
if (cpid == 0) {
- Check_Cwd(av);
Var_ExportVars();
#ifdef USE_META
if (useMeta) {
diff --git a/contrib/bmake/configure b/contrib/bmake/configure
index ee479f1..f79b26f 100755
--- a/contrib/bmake/configure
+++ b/contrib/bmake/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64 for bmake 20120620.
+# Generated by GNU Autoconf 2.64 for bmake 20121212.
#
# Report bugs to <sjg@NetBSD.org>.
#
@@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bmake'
PACKAGE_TARNAME='bmake'
-PACKAGE_VERSION='20120620'
-PACKAGE_STRING='bmake 20120620'
+PACKAGE_VERSION='20121212'
+PACKAGE_STRING='bmake 20121212'
PACKAGE_BUGREPORT='sjg@NetBSD.org'
PACKAGE_URL=''
@@ -1220,7 +1220,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures bmake 20120620 to adapt to many kinds of systems.
+\`configure' configures bmake 20121212 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1281,7 +1281,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of bmake 20120620:";;
+ short | recursive ) echo "Configuration of bmake 20121212:";;
esac
cat <<\_ACEOF
@@ -1386,7 +1386,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-bmake configure 20120620
+bmake configure 20121212
generated by GNU Autoconf 2.64
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -1907,7 +1907,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by bmake $as_me 20120620, which was
+It was created by bmake $as_me 20121212, which was
generated by GNU Autoconf 2.64. Invocation command line was
$ $0 $@
@@ -2257,6 +2257,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers config.h"
+case "$srcdir" in
+/*) ;;
+*) srcdir=`cd $srcdir && pwd`;;
+esac
+
# Check whether --with-defshell was given.
if test "${with_defshell+set}" = set; then :
@@ -5861,7 +5866,7 @@ fi
-ac_config_files="$ac_config_files Makefile make-bootstrap.sh unit-tests/Makefile"
+ac_config_files="$ac_config_files makefile Makefile.config make-bootstrap.sh unit-tests/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -6369,7 +6374,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by bmake $as_me 20120620, which was
+This file was extended by bmake $as_me 20121212, which was
generated by GNU Autoconf 2.64. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6429,7 +6434,7 @@ Report bugs to <sjg@NetBSD.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-bmake config.status 20120620
+bmake config.status 20121212
configured by $0, generated by GNU Autoconf 2.64,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -6544,7 +6549,8 @@ for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
- "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "makefile") CONFIG_FILES="$CONFIG_FILES makefile" ;;
+ "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
"make-bootstrap.sh") CONFIG_FILES="$CONFIG_FILES make-bootstrap.sh" ;;
"unit-tests/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/Makefile" ;;
diff --git a/contrib/bmake/configure.in b/contrib/bmake/configure.in
index 156034b9..0caafdf 100644
--- a/contrib/bmake/configure.in
+++ b/contrib/bmake/configure.in
@@ -1,12 +1,18 @@
dnl
dnl RCSid:
-dnl $Id: configure.in,v 1.45 2012/06/20 22:43:41 sjg Exp $
+dnl $Id: configure.in,v 1.46 2012/12/28 21:28:18 sjg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
-AC_INIT([bmake], [20120620], [sjg@NetBSD.org])
+AC_INIT([bmake], [20121212], [sjg@NetBSD.org])
AC_CONFIG_HEADER(config.h)
+dnl make srcdir absolute
+case "$srcdir" in
+/*) ;;
+*) srcdir=`cd $srcdir && pwd`;;
+esac
+
dnl
AC_ARG_WITH(defshell,
[ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
@@ -357,7 +363,7 @@ AC_SUBST(GCC)
AC_SUBST(diff_u)
AC_SUBST(use_meta)
AC_SUBST(filemon_h)
-AC_OUTPUT(Makefile make-bootstrap.sh unit-tests/Makefile)
+AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile)
cat <<EOF
diff --git a/contrib/bmake/job.c b/contrib/bmake/job.c
index 99e05d5..3049e60 100644
--- a/contrib/bmake/job.c
+++ b/contrib/bmake/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $ */
+/* $NetBSD: job.c,v 1.165 2013/01/26 15:52:59 christos 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.163 2012/07/03 21:03:40 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.165 2013/01/26 15:52:59 christos 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.163 2012/07/03 21:03:40 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.165 2013/01/26 15:52:59 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -490,7 +490,8 @@ JobCondPassSig(int signo)
static void
JobChildSig(int signo MAKE_ATTR_UNUSED)
{
- write(childExitJob.outPipe, CHILD_EXIT, 1);
+ while (write(childExitJob.outPipe, CHILD_EXIT, 1) == -1 && errno == EAGAIN)
+ continue;
}
@@ -517,7 +518,9 @@ JobContinueSig(int signo MAKE_ATTR_UNUSED)
* Defer sending to SIGCONT to our stopped children until we return
* from the signal handler.
*/
- write(childExitJob.outPipe, DO_JOB_RESUME, 1);
+ while (write(childExitJob.outPipe, DO_JOB_RESUME, 1) == -1 &&
+ errno == EAGAIN)
+ continue;
}
/*-
@@ -688,7 +691,6 @@ JobPrintCommand(void *cmdp, void *jobp)
char *escCmd = NULL; /* Command with quotes/backticks escaped */
char *cmd = (char *)cmdp;
Job *job = (Job *)jobp;
- char *cp, *tmp;
int i, j;
noSpecials = NoExecute(job->node);
@@ -860,11 +862,6 @@ JobPrintCommand(void *cmdp, void *jobp)
job->flags |= JOB_TRACED;
}
- if ((cp = Check_Cwd_Cmd(cmd)) != NULL) {
- DBPRINTF("test -d %s && ", cp);
- DBPRINTF("cd %s\n", cp);
- }
-
DBPRINTF(cmdTemplate, cmd);
free(cmdStart);
if (escCmd)
@@ -884,10 +881,6 @@ JobPrintCommand(void *cmdp, void *jobp)
if (shutUp && commandShell->hasEchoCtl) {
DBPRINTF("%s\n", commandShell->echoOn);
}
- if (cp != NULL) {
- DBPRINTF("test -d %s && ", cp);
- DBPRINTF("cd %s\n", Var_Value(".OBJDIR", VAR_GLOBAL, &tmp));
- }
return 0;
}
@@ -1185,7 +1178,8 @@ Job_Touch(GNode *gn, Boolean silent)
*/
if (read(streamID, &c, 1) == 1) {
(void)lseek(streamID, (off_t)0, SEEK_SET);
- (void)write(streamID, &c, 1);
+ while (write(streamID, &c, 1) == -1 && errno == EAGAIN)
+ continue;
}
(void)close(streamID);
@@ -2074,7 +2068,8 @@ Job_CatchOutput(void)
if (nready < 0 || readyfd(&childExitJob)) {
char token = 0;
nready -= 1;
- (void)read(childExitJob.inPipe, &token, 1);
+ while (read(childExitJob.inPipe, &token, 1) == -1 && errno == EAGAIN)
+ continue;
if (token == DO_JOB_RESUME[0])
/* Complete relay requested from our SIGCONT handler */
JobRestartJobs();
@@ -2805,7 +2800,8 @@ JobTokenAdd(void)
if (DEBUG(JOB))
fprintf(debug_file, "(%d) aborting %d, deposit token %c\n",
getpid(), aborting, JOB_TOKENS[aborting]);
- write(tokenWaitJob.outPipe, &tok, 1);
+ while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
+ continue;
}
/*-
@@ -2918,13 +2914,15 @@ Job_TokenWithdraw(void)
while (read(tokenWaitJob.inPipe, &tok1, 1) == 1)
continue;
/* And put the stopper back */
- write(tokenWaitJob.outPipe, &tok, 1);
+ while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
+ continue;
Fatal("A failure has been detected in another branch of the parallel make");
}
if (count == 1 && jobTokensRunning == 0)
/* We didn't want the token really */
- write(tokenWaitJob.outPipe, &tok, 1);
+ while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
+ continue;
jobTokensRunning++;
if (DEBUG(JOB))
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index 0b177bb..f4bd721 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $ */
+/* $NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos 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.203 2012/08/31 07:00:36 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -176,9 +176,6 @@ Boolean varNoExportEnv; /* -X flag */
Boolean doing_depend; /* Set while reading .depend */
static Boolean jobsRunning; /* TRUE if the jobs might be running */
static const char * tracefile;
-#ifndef NO_CHECK_MAKE_CHDIR
-static char * Check_Cwd_av(int, char **, int);
-#endif
static void MainParseArgs(int, char **);
static int ReadMakefile(const void *, const void *);
static void usage(void) MAKE_ATTR_DEAD;
@@ -1204,10 +1201,6 @@ main(int argc, char **argv)
Main_ExportMAKEFLAGS(TRUE); /* initial export */
-#ifndef NO_CHECK_MAKE_CHDIR
- Check_Cwd_av(0, NULL, 0); /* initialize it */
-#endif
-
/*
* For compatibility, look at the directories in the VPATH variable
* and add them to the search path, if the variable is defined. The
@@ -1423,208 +1416,6 @@ found:
}
-/*
- * If MAKEOBJDIRPREFIX is in use, make ends up not in .CURDIR
- * in situations that would not arrise with ./obj (links or not).
- * This tends to break things like:
- *
- * build:
- * ${MAKE} includes
- *
- * This function spots when ${.MAKE:T} or ${.MAKE} is a command (as
- * opposed to an argument) in a command line and if so returns
- * ${.CURDIR} so caller can chdir() so that the assumptions made by
- * the Makefile hold true.
- *
- * If ${.MAKE} does not contain any '/', then ${.MAKE:T} is skipped.
- *
- * The chdir() only happens in the child process, and does nothing if
- * MAKEOBJDIRPREFIX and MAKEOBJDIR are not in the environment so it
- * should not break anything. Also if NOCHECKMAKECHDIR is set we
- * do nothing - to ensure historic semantics can be retained.
- */
-#ifdef NO_CHECK_MAKE_CHDIR
-char *
-Check_Cwd_Cmd(cmd)
- char *cmd;
-{
- return 0;
-}
-
-void
-Check_Cwd(argv)
- char **argv;
-{
- return;
-}
-
-#else
-
-static int Check_Cwd_Off = 0;
-
-static char *
-Check_Cwd_av(int ac, char **av, int copy)
-{
- static char *make[4];
- static char *cur_dir = NULL;
- char **mp;
- char *cp;
- int is_cmd, next_cmd;
- int i;
- int n;
-
- if (Check_Cwd_Off) {
- if (DEBUG(CWD))
- fprintf(debug_file, "check_cwd: check is off.\n");
- return NULL;
- }
-
- if (make[0] == NULL) {
- if (Var_Exists("NOCHECKMAKECHDIR", VAR_GLOBAL)) {
- Check_Cwd_Off = 1;
- if (DEBUG(CWD))
- fprintf(debug_file, "check_cwd: turning check off.\n");
- return NULL;
- }
-
- make[1] = Var_Value(".MAKE", VAR_GLOBAL, &cp);
- if ((make[0] = strrchr(make[1], '/')) == NULL) {
- make[0] = make[1];
- make[1] = NULL;
- } else
- ++make[0];
- make[2] = NULL;
- cur_dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp);
- }
- if (ac == 0 || av == NULL) {
- if (DEBUG(CWD))
- fprintf(debug_file, "check_cwd: empty command.\n");
- return NULL; /* initialization only */
- }
-
- if (getenv("MAKEOBJDIR") == NULL &&
- getenv("MAKEOBJDIRPREFIX") == NULL) {
- if (DEBUG(CWD))
- fprintf(debug_file, "check_cwd: no obj dirs.\n");
- return NULL;
- }
-
-
- next_cmd = 1;
- for (i = 0; i < ac; ++i) {
- is_cmd = next_cmd;
-
- n = strlen(av[i]);
- cp = &(av[i])[n - 1];
- if (strspn(av[i], "|&;") == (size_t)n) {
- next_cmd = 1;
- continue;
- } else if (*cp == ';' || *cp == '&' || *cp == '|' || *cp == ')') {
- next_cmd = 1;
- if (copy) {
- do {
- *cp-- = '\0';
- } while (*cp == ';' || *cp == '&' || *cp == '|' ||
- *cp == ')' || *cp == '}') ;
- } else {
- /*
- * XXX this should not happen.
- */
- fprintf(stderr, "%s: WARNING: raw arg ends in shell meta '%s'\n",
- progname, av[i]);
- }
- } else
- next_cmd = 0;
-
- cp = av[i];
- if (*cp == ';' || *cp == '&' || *cp == '|')
- is_cmd = 1;
-
- if (DEBUG(CWD))
- fprintf(debug_file, "av[%d] == %s '%s'",
- i, (is_cmd) ? "cmd" : "arg", av[i]);
- if (is_cmd != 0) {
- if (*cp == '(' || *cp == '{' ||
- *cp == ';' || *cp == '&' || *cp == '|') {
- do {
- ++cp;
- } while (*cp == '(' || *cp == '{' ||
- *cp == ';' || *cp == '&' || *cp == '|');
- if (*cp == '\0') {
- next_cmd = 1;
- continue;
- }
- }
- if (strcmp(cp, "cd") == 0 || strcmp(cp, "chdir") == 0) {
- if (DEBUG(CWD))
- fprintf(debug_file, " == cd, done.\n");
- return NULL;
- }
- for (mp = make; *mp != NULL; ++mp) {
- n = strlen(*mp);
- if (strcmp(cp, *mp) == 0) {
- if (DEBUG(CWD))
- fprintf(debug_file, " %s == '%s', chdir(%s)\n",
- cp, *mp, cur_dir);
- return cur_dir;
- }
- }
- }
- if (DEBUG(CWD))
- fprintf(debug_file, "\n");
- }
- return NULL;
-}
-
-char *
-Check_Cwd_Cmd(const char *cmd)
-{
- char *cp, *bp;
- char **av;
- int ac;
-
- if (Check_Cwd_Off)
- return NULL;
-
- if (cmd) {
- av = brk_string(cmd, &ac, TRUE, &bp);
- if (DEBUG(CWD))
- fprintf(debug_file, "splitting: '%s' -> %d words\n",
- cmd, ac);
- } else {
- ac = 0;
- av = NULL;
- bp = NULL;
- }
- cp = Check_Cwd_av(ac, av, 1);
- if (bp)
- free(bp);
- if (av)
- free(av);
- return cp;
-}
-
-void
-Check_Cwd(const char **argv)
-{
- char *cp;
- int ac;
-
- if (Check_Cwd_Off)
- return;
-
- for (ac = 0; argv[ac] != NULL; ++ac)
- /* NOTHING */;
- if (ac == 3 && *argv[1] == '-') {
- cp = Check_Cwd_Cmd(argv[2]);
- } else {
- cp = Check_Cwd_av(ac, UNCONST(argv), 0);
- }
- if (cp) {
- chdir(cp);
- }
-}
-#endif /* NO_CHECK_MAKE_CHDIR */
/*-
* Cmd_Exec --
@@ -1952,7 +1743,8 @@ execError(const char *af, const char *av)
IOADD(")\n");
#ifdef USE_IOVEC
- (void)writev(2, iov, 8);
+ while (writev(2, iov, 8) == -1 && errno == EAGAIN)
+ continue;
#endif
}
diff --git a/contrib/bmake/make-bootstrap.sh.in b/contrib/bmake/make-bootstrap.sh.in
index d9ff9ff..70d7e2b 100755
--- a/contrib/bmake/make-bootstrap.sh.in
+++ b/contrib/bmake/make-bootstrap.sh.in
@@ -13,7 +13,7 @@ esac
CC="@CC@"
CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS}"
-MAKE_VERSION=`sed -n '/^MAKE_VERSION=/s,.*=[^0-9]*,,p' Makefile`
+MAKE_VERSION=`sed -n '/^MAKE_VERSION=/s,.*=[^0-9]*,,p' $srcdir/Makefile`
MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \
-D@force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" \
diff --git a/contrib/bmake/make.1 b/contrib/bmake/make.1
index 702e478..198410c 100644
--- a/contrib/bmake/make.1
+++ b/contrib/bmake/make.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.209 2012/10/08 15:09:48 christos Exp $
+.\" $NetBSD: make.1,v 1.210 2013/01/27 18:52:01 sjg 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 October 8, 2012
+.Dd January 23, 2013
.Dt MAKE 1
.Os
.Sh NAME
@@ -468,6 +468,50 @@ except that the effect can be limited to a single line of a script.
A
.Ql Ic \-
causes any non-zero exit status of the command line to be ignored.
+.Pp
+When
+.Nm
+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
+.Nm
+will attempt direct execution.
+.Pp
+Since
+.Nm
+will
+.Xr chdir 2
+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.
@@ -2027,28 +2071,6 @@ The way that .for loop variables are substituted changed after
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
-Unlike other
-.Nm
-programs, this implementation by default executes all commands for a given
-target using a single shell invocation.
-This is done for both efficiency and to simplify error handling in remote
-command invocations.
-Typically this is transparent to the user, unless the target commands change
-the current working directory using
-.Dq cd
-or
-.Dq chdir .
-To be compatible with Makefiles that do this, one can use
-.Fl B
-to disable this behavior.
-.Pp
-In compatibility 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
-.Nm
-will attempt direct execution.
.Sh SEE ALSO
.Xr mkdep 1
.Sh HISTORY
diff --git a/contrib/bmake/makefile.in b/contrib/bmake/makefile.in
new file mode 100644
index 0000000..03b980a
--- /dev/null
+++ b/contrib/bmake/makefile.in
@@ -0,0 +1,14 @@
+# $Id: makefile.in,v 1.1 2012/12/28 21:28:19 sjg Exp $
+
+# a simple makefile for those who don't like anything beyond:
+# ./configure; make; make install
+
+prefix= @prefix@
+srcdir= @srcdir@
+
+all: build
+
+build clean install test:
+ ${srcdir}/boot-strap --prefix=${prefix} -o . op=$@
+
+
diff --git a/contrib/bmake/meta.c b/contrib/bmake/meta.c
index 77af4e8..d6110d9 100644
--- a/contrib/bmake/meta.c
+++ b/contrib/bmake/meta.c
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.25 2012/06/27 17:22:58 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.26 2013/01/19 04:23:37 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -843,7 +843,7 @@ meta_oodate(GNode *gn, Boolean oodate)
static size_t cwdlen = 0;
static size_t tmplen = 0;
FILE *fp;
- Boolean ignoreOODATE = FALSE;
+ Boolean needOODATE = FALSE;
Lst missingFiles;
if (oodate)
@@ -1197,15 +1197,15 @@ meta_oodate(GNode *gn, Boolean oodate)
} else {
char *cmd = (char *)Lst_Datum(ln);
- if (!ignoreOODATE) {
+ if (!needOODATE) {
if (strstr(cmd, "$?"))
- ignoreOODATE = TRUE;
+ needOODATE = TRUE;
else if ((cp = strstr(cmd, ".OODATE"))) {
/* check for $[{(].OODATE[)}] */
if (cp > cmd + 2 && cp[-2] == '$')
- ignoreOODATE = TRUE;
+ needOODATE = TRUE;
}
- if (ignoreOODATE && DEBUG(META))
+ if (needOODATE && DEBUG(META))
fprintf(debug_file, "%s: %d: cannot compare commands using .OODATE\n", fname, lineno);
}
cmd = Var_Subst(NULL, cmd, gn, TRUE);
@@ -1235,7 +1235,7 @@ meta_oodate(GNode *gn, Boolean oodate)
if (buf[x - 1] == '\n')
buf[x - 1] = '\0';
}
- if (!ignoreOODATE &&
+ if (!needOODATE &&
!(gn->type & OP_NOMETA_CMP) &&
strcmp(p, cmd) != 0) {
if (DEBUG(META))
@@ -1279,14 +1279,16 @@ meta_oodate(GNode *gn, Boolean oodate)
oodate = TRUE;
}
}
- if (oodate && ignoreOODATE) {
+ if (oodate && needOODATE) {
/*
- * Target uses .OODATE, so we need to re-compute it.
- * We need to clean up what Make_DoAllVar() did.
+ * Target uses .OODATE which is empty; or we wouldn't be here.
+ * We have decided it is oodate, so .OODATE needs to be set.
+ * All we can sanely do is set it to .ALLSRC.
*/
- Var_Delete(ALLSRC, gn);
Var_Delete(OODATE, gn);
- gn->flags &= ~DONE_ALLSRC;
+ Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn, 0);
+ if (cp)
+ free(cp);
}
return oodate;
}
diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog
new file mode 100644
index 0000000..fee1c90
--- /dev/null
+++ b/contrib/bmake/mk/ChangeLog
@@ -0,0 +1,644 @@
+2013-01-23 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20130123
+ * meta.stage.mk: add stage_links (hard links).
+ if doing hard links, we add dest to link as well.
+ Default the stage dir for [sym]links to STAGE_OBJTOP since
+ these are typically specified as absolute paths.
+ Add -m "mode" flag to StageFiles and StageAs.
+
+2012-11-11 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20121111
+ * autoconf.mk: avoid meta mode seeing changed commands for config.status
+ * meta.autodep.mk: pass resolved MAKESYSPATH to gendirdeps
+ in case we were found via .../mk
+ * sys.clean-env.mk: move it from examples, we and others use it
+ "as is".
+ * FILES: add srctop.mk and options.mk
+ * own.mk: convert to using options.mk
+ which is modeled after FreeBSD's handling of MK_*
+ but more flexible.
+ This allows MK_* for boolean knobs to not be confused
+ with MK* which can be commands.
+
+ * examples/sys.clean-env.mk: add WITH[OUT]_ to
+ MAKE_ENV_SAVE_PREFIX_LIST.
+ Mention that HOME=/var/empty might be a good idea.
+
+2012-11-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * sys.dependfile.mk: if not depend file exists, $MACHINE
+ specific ones are supported but not the default,
+ check if any exist and follow suit.
+
+2012-11-06 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20121106
+
+2012-11-05 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * import latest dirdeps.mk and meta2deps.py from Juniper.
+ * progs.mk: add MAN and CXXFLAGS to PROG_VARS
+ also add PROGS_TARGETS and pass on PROG_CXX if it seems
+ appropriate.
+
+2012-11-04 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.stage.mk: update CLEANFILES
+ remove redundant cp of .dirdep from STAGE_AS_SCRIPT.
+ * progs.mk: Add LDADD to PROG_VARS
+
+2012-10-12 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.stage.mk (STAGE_DIR_FILTER): track dirs we stage to in
+ _STAGED_DIRS so that these can be turned into filters for
+ GENDIRDEPS_FILTER.
+
+2012-10-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20121010
+ * meta.stage.mk (STAGE_DIRDEP_SCRIPT): check that an existing
+ target.dirdep matches .dirdep
+
+2012-08-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20120808
+ * import latest meta2deps.py from Juniper.
+
+2012-07-11 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20120711
+ * dep.mk: add explicit dependencies on SRCS after applying
+ SRCS_DEP_FILTER
+ * meta.autodep.mk: add explicit dependencies on SRCS after
+ applying SRCS_DEP_FILTER
+ * meta.autodep.mk: ensure GENDIRDEPS_FILTER is exported if needed.
+
+2012-06-26 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20120626
+ * meta.sys.mk: ignore PYTHON if it does not exist
+ compare ${.MAKE.DEPENDFILE:E} against ${MACHINE} is more reliable.
+ * meta.stage.mk: examine .MAKE.DEPENDFILE_PREFERENCE for any
+ entries ending in .${MACHINE} to decide if qualified _dirdep is
+ needed.
+ * gendirdeps.mk: only produce unqualified deps if no
+ .MAKE.DEPENDFILE_PREFERENCE ends in .${MACHINE}
+ * meta.subdir.mk: apply SUBDIREPS_FILTER
+
+2012-04-20 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20120420
+ * add sys.dependfile.mk so we can experiment with
+ .MAKE.DEPENDFILE_PREFERENCE
+ * meta.autodep.mk: _DEPENDFILE is precious!
+
+2012-03-15 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20120315
+ * install-new.mk: avoid being interrupted
+
+2012-02-26 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * man.mk: MAN might have multiple values so be careful with exists().
+
+2012-01-19 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20120112
+ * fix examples/sys.clean-env.mk so that MAKEOBJDIR is handled
+ as: MAKEOBJDIR='${.CURDIR:S,${SRCTOP},${OBJTOP},}'
+
+2011-12-03 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20111201
+ * import dirdeps.mk from Juniper sjg@
+ o more consistent handling of DEP_MACHINE, especially when
+ dealing with an odd Makefile.depend, when normally using
+ Makefile.depend.${MACHINE}
+
+2011-11-22 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20111122
+ * meta.autodep.mk: add some debug output, be more crisp about
+ updating. Use ${.ALLTARGETS:M*.o} as a clue for .depend
+
+2011-11-13 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20111111
+ it's too cool to miss
+ * import meta* updates from Juniper sjg@
+ o dirdeps.mk set DEP_MACHINE for Makefile.depend (when we are
+ normally using Makefile.depend.${MACHINE}), handy for
+ read-only manually maintained dependencies.
+ o meta2deps.py add a clear 'ERROR:' token if an exception is raised.
+ o gendirdeps.mk if ERROR: from meta2deps.py do not update
+ anything.
+
+2011-10-30 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-new.mk separate the cmp and copy logic to its own function.
+
+2011-10-28 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20111028
+ * sys.mk: include auto.obj.mk if MKOBJDIRS is set to auto
+ * subdir.mk: ensure _SUBDIRUSE is provided
+ * meta.autodep.mk: remove dependency of gendirdeps.mk on auto.obj.mk
+ * meta.subdir.mk: always allow for Makefile.depend
+
+2011-10-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20111010
+ o minor tweak to *dirdeps.mk from Juniper sjg@
+
+2011-10-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20111001
+ o add meta2deps.py from Juniper sjg@
+ o tweak gendirdeps.mk to work with meta2deps.py when not
+ cross-building
+ * autoconf.mk: add autoconf-input as a hook for regenerating
+ AUTOCONF_INPUTS (configure).
+
+2011-08-24 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.autodep.mk: if we do not have OBJS, .depend isn't a useful
+ trigger for updating Makefile.depend*
+
+2011-08-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20110808
+ * obj.mk: minor cleanup
+ * auto.obj.mk: improve description of Mkdirs and honor NO_OBJ too.
+
+2011-08-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * auto.obj.mk (.OBJDIR): throw an error if we cannot use the
+ specified dir.
+
+2011-06-28 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.autodep.mk: if XMAKE_META_FILE is set
+ the makefile uses a foreign make, and so dependencies
+ can only be gathered from a clean tree build.
+
+2011-06-24 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20110622
+ * meta.autodep.mk: improve bootstraping
+
+2011-06-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * yacc.mk: handle the corner case of .c being removed
+ while .h remains.
+
+2011-06-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * yacc.mk: do .y.h and .y.c separately
+
+2011-06-04 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20110606
+ * don't store SRC_DIRDEPS in Makefile.depend* by default
+ not everyone needs it.
+
+2011-05-04 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20110505
+ first release including meta mode makefiles
+
+2011-05-02 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.stage.mk: add STAGE_AS_SETS and stage_as
+ for things that need to be staged with different names.
+
+2011-05-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.stage.mk: add notion of STAGE_SETS
+ so a makefile can stage to multiple dirs
+
+2011-04-03 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * rst2htm.mk: convert rst to s5 (slides) or plain html depending
+ on target name.
+
+2011-03-30 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20110330
+
+2011-03-29 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * sys.mk (_DEBUG_MAKE_FLAGS): use indirection so that DEBUG_MAKE_FLAGS0
+ can be used to debug level 0 only and DEBUG_MAKE_FLAGS for the rest.
+ * sys.mk: re-define M_whence in terms of M_type.
+ M_type is useful for checking if something is a builtin.
+
+2011-03-16 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.stage.mk: add stage_symlinks and leverage StageLinks for
+ stage_libs
+
+2011-03-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * dirdeps.mk: correct value for _depdir_files depends on
+ .MAKE.DEPENDFILE
+ Add our copyright - just to make it clear we have frobbed this
+ quite a bit.
+ DEP_MACHINE needs to be set to MACHINE each time, if using only
+ Makefile.depend (cf. Makefile.depend.${MACHINE})
+
+ * meta.stage.mk: meta mode version of staging
+
+ * init.mk, final.mk: include local.*.mk to simplify customization
+
+2011-03-03 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * auto.obj.mk: just because we are doing mk destroy, we should
+ still set .OBJDIR correctly if it exists.
+
+ * install-mk (mksrc): do not exclude meta.sys.mk
+
+2011-03-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * host-target.mk: set/export _HOST_ARCH etc separately,
+ catch junk resulting from uname -p, so we can find sys/Linux.mk
+ correctly.
+
+2011-02-18 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.sys.mk: throw an error if /dev/filemon is missing and we
+ expected to be updating Makefile.depend*
+
+2011-02-14 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20110214
+ * meta.subdir.mk: add support for -DBOOTSTRAP_DEPENDFILES
+
+2010-09-25 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * meta.sys.mk: not valid for older bmake
+
+2010-09-24 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100919
+ include dirdeps.mk et al from Juniper Networks,
+ for meta mode - requires filemon(9).
+ * sys.mk, subdir.mk: Add hooks for meta mode.
+ we do this as meta.sys.mk, meta.autodep.mk and meta.subdir.mk
+ to make turning it on/off simple.
+
+2010-06-16 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100616
+ * fix typo in sys.mk
+
+2010-06-12 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100612
+ * lib.mk: remove duplicate addition to SOBJS
+
+2010-06-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * sys.mk: Add a means of selectively turning on debug flags.
+ Eg. DEBUG_MAKE_FLAGS=-dv DEBUG_MAKE_DIRS="*lib/sjg"
+ will act as if we did make -dv if .CURDIR ends in lib/sjg
+ DEBUG_MAKE_SYS_DIRS does the same thing, but we set the flags at
+ the start of sys.mk rather than the end.
+ This only makes sense for leaf dirs, so we check that
+ .MAKE.LEVEL > 0
+
+2010-06-09 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100608
+ * sys.mk: include sys.env.mk later so it can use M_ListToSkip et al.
+ * examples/sys.clean-env.mk: require MAKE_VERIONS >= 20100606
+ also make it easier for folk to tweak
+
+2010-06-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100606
+ do not install examples/*
+ * FILES: add examples/sys.clean-env.mk
+ * examples/sys.clean-env.mk: use .export-env to handle MAKEOBJDIR
+ this requires bmake-20100606 or later to work.
+
+2010-05-13 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * sys.mk (M_tA): better simulate the result of :tA if not available.
+
+2010-05-04 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * sys.mk: canonicalize MAKE_VERSION
+ old versions reported bmake-<src-date> build-<build-date>
+ whereas we only care about <src-date>
+
+2010-04-25 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk: just warn about FORCE_{BSD,SYS}_MK being ignored
+ * lib.mk: we only build the shared lib if SHLIB_FULLVERSION
+ is !empty
+
+2010-04-22 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * dpadd.mk: use LDADD_* if defined.
+
+2010-04-21 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100420
+ * sys/NetBSD.mk: add MACHINE_CPU to keep netbsd makefiles happy
+ * autoconf.mk allow AUTO_AUTOCONF
+
+2010-04-19 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * obj.mk: add objwarn to keep freebsd makefiles happy
+ * auto.obj.mk: ensure Mkdirs is available.
+ * FILES: add auto.dep.mk - a simpler version of autodep.mk
+ * dep.mk: auto.dep.mk does not do 'make depend' so ignore it if
+ asked to do that.
+ fix/simplify the tests for when to run mkdep.
+ * auto.dep.mk: add some explaination of how/what we do.
+ * autodep.mk: skip the .OPTIONAL frobbing of .depend
+ bmake's FROM_DEPEND flag makes it redundant.
+
+2010-04-13 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100404
+ * subdir.mk: protect from multiple inclusion using _SUBDIRUSE.
+ * obj.mk: protect from multiple inclusion even as bsd.obj.mk
+ Also create a target _SUBDIRUSE so that we can be used without
+ subdir.mk
+
+2010-04-12 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * dep.mk: use <> when .including so can override.
+
+2010-01-11 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * lib.mk (SHLIB_LINKS): ensure a string comparison.
+
+2010-01-04 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20100102
+ * own.mk: ensure PRINTOBJDIR works
+ * autoconf.mk: pass on CONFIGURE_ARGS
+ * init.mk: handle COPTS.${.IMPSRC:T} etc.
+ * lib.mk: allow sys.mk to control SHLIB_FULLVERSION
+ fix handling of symlinks for darwin
+ * libnames.mk: add DSHLIBEXT for libs which only exist as shared.
+ * man.mk: suppress chown when not root.
+ * rst2htm.mk: allow srcs from multiple locations.
+ * sys.mk: M_whence, stop after 1st line of output.
+ * sys/Darwin.mk: Use .dylib for DSHLIBEXT and HOST_LIBEXT
+ * sys/SunOS.mk: we need to export PATH
+
+2009-12-23 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ include rst2htm.mk
+
+2009-12-17 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * sys.mk,libnames.mk add .-include <local.*>
+ this allows local customization without the need to edit the
+ distributed files.
+
+2009-12-14 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * dpadd.mk (__dpadd_libdirs): order -L's to avoid picking up
+ older versions already installed.
+
+2009-12-13 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * stage.mk (.stage-install): generalize lib.mk's .libinstall
+ * rules.mk rules for generic Makefile.
+ * inc.mk install for includes.
+
+2009-12-11 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * sys/NetBSD.mk (MAKE_VERSION): some of our *.mk want to check
+ this, so provide it if using native make.
+
+2009-12-10 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * FILES: move all the platform *.sys.mk files to sys/*.mk
+ * Rename Generic.sys.mk to sys.mk - we always want it.
+
+2009-11-17 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ * host-target.mk: only export the expensive stuff
+ * Generic.sys.mk (sys_mk): for SunOS we need to look for
+ ${HOST_OS}.${HOST_OSMAJOR} too!
+
+2009-11-07 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ * lib.mk: if sys.mk doesn't give us an lorder, don't use it.
+ based on patch from Greg Olszewski.
+ * Generic.sys.mk: if we have nothing to work with
+ set LORDER etc only if we can find it.
+
+2009-09-08 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ * man.mk: cleanman: remove CLEANMAN if defined.
+
+2009-09-04 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * SunOS.5.sys.mk (CC): Use ?= like the other *sys.mk
+
+2009-07-17 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ include auto.obj.mk
+
+
+2009-03-26 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * prog.mk,lib.mk: ensure test of USE_DPADD_MK doesn't fail.
+
+2008-11-11 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ man.mk: ensure we generate *.cat1 etc in .
+
+2008-07-16 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ add prlist.mk
+
+2007-11-25 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * Generic.sys.mk: Allow os specific sys.mk to be in a
+ subdir of ${.PARSEDIR}
+
+2007-11-22 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ * general cleanup
+ * dpadd.mk introduce DPMAGIC_LIBS_*
+
+2007-04-30 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+
+ * libs.mk, progs.mk, autodep.mk: allow for per lib/prog
+ depend files and ensure clean is called for each lib/prog.
+
+2007-03-27 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * autodep.mk (.depend): delete lines that do not start with
+ space and do not contain ':'
+
+2007-02-16 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * autodep.mk (.depend): gcc may wrap lines if pathnames are long
+ so make sure the transform for .OPTIONAL copes.
+
+2007-02-03 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+
+ * own.mk: make sure RM and LN are defined.
+
+ * obj.mk: fix a typo, and objlink target.
+
+2006-12-30 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version
+ * added libs.mk - analagous to progs.mk
+ make both of them always inlcude {lib,prog}.mk
+
+2006-12-28 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * progs.mk: add a means of building multiple apps in one dir.
+
+2006-11-26 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20061126
+
+ * warnings.mk: detect invalid WARNINGS_SET
+
+ * warnings.mk: use ${.TARGET:T:R}.o when looking for target
+ specific warnings.
+
+ * For .cc sources, turn off warnings that g++ vomits on.
+
+2006-11-08 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * own.mk: if __initialized__ target doesn't exist and we are
+ FreeBSD we got here directly from sys.mk
+
+2006-11-06 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20061106
+ add scripts.mk
+
+2006-03-18 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20060318
+
+ * autodep.mk: avoid := when modifying OBJS into __dependsrcs
+
+2006-03-02 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20060302
+ * autodep.mk: use -MF et al to help gcc+ccache DTRT.
+
+2006-03-01 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20060301
+ * autodep.mk (.depend):
+ if MAKE_VERSION is newer than 20050530 we can make .END depend on
+ .depend and make .depend depend on __depsrcs that exist.
+ * dpadd.mk: add SRC_PATHADD
+
+2005-11-04 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20051104
+ * prog.mk: remove all the LIBC?= junk, use
+ .-include libnames.mk instead (none by default).
+ also if USE_DPADD_MK is set, include that.
+
+2005-10-09 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20051001
+ Add UnixWare.sys.mk from Klaus Heinz.
+
+2005-04-05 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk: always install *.sys.mk and if need be symlink one
+ to sys.mk
+
+2005-03-22 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * subdir.mk, own.mk: use .MAKE rather than MAKE
+
+2004-02-15 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * own.mk: don't use NetBSD's _SRC_TOP_ it can
+ cause confusion. Also don't take just 'mk' as a
+ srctop indicator.
+
+2004-02-14 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * warnings.mk: overhauled, now very powerful.
+
+2004-02-03 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * Generic.sys.mk: need to use ${.PARSEDIR} with exists().
+
+2004-02-01 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): bump version to 20040201
+ * extract HOST_TARGET stuff to host-target.mk so own.mk and
+ Generic.sys.mk can share.
+ * fix typo in autodep.mk _SUBDIRUSE not _SUBDIR.
+
+2003-09-30 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): 20030930
+ * rename generic.sys.mk to Generic.sys.mk
+ so that it does not get installed (unless being used as sys.mk)
+ * set OS and ROOT_GROUP for those that we know the value.
+ for others (eg. Generic.sys.mk) wrap the != in an .ifndef so
+ we don't do it again for each sub-make.
+
+2003-09-28 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk (MK_VERSION): 20030928
+ Add some extra *.sys.mk from bootstrap-pkgsrc
+ some of these likely still need work.
+ Make everything default to root:wheel ownership,
+ sys.mk can set ROOT_GROUP accordingly.
+
+2003-08-07 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk: if FORCE_BSD_MK={cp,ln} use the ones in SYS_MK_DIR
+ not the portable ones.
+
+2003-07-31 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk: add ability to use cp -f when updating
+ destination .mk files. Also now possible to play games with
+ FORCE_SYS_MK=ln etc on *BSD machines to link /usr/share/mk/sys.mk
+ into dest - not recommended unless you seriously want to.
+
+2003-07-28 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * own.mk (IMPFLAGS): add support for COPTS.${IMPSRC:T} etc
+ for semi-compatability with NetBSD.
+
+2003-07-23 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * install-mk: add a version indicator
+
+2003-07-22 Simon J. Gerraty <sjg@void.crufty.net>
+
+ * prog.mk: don't try and use ${LIBCRT0} if its /dev/null
+
+ * install-mk: Allow FORCE_SYS_MK to come from env
+
+
+
diff --git a/contrib/bmake/mk/FILES b/contrib/bmake/mk/FILES
new file mode 100644
index 0000000..7a2bf29
--- /dev/null
+++ b/contrib/bmake/mk/FILES
@@ -0,0 +1,60 @@
+ChangeLog
+FILES
+README
+auto.obj.mk
+autoconf.mk
+autodep.mk
+auto.dep.mk
+dep.mk
+doc.mk
+dpadd.mk
+final.mk
+host-target.mk
+host.libnames.mk
+inc.mk
+init.mk
+install-mk
+java.mk
+lib.mk
+libnames.mk
+libs.mk
+links.mk
+man.mk
+mk-files.txt
+nls.mk
+obj.mk
+options.mk
+own.mk
+prlist.mk
+prog.mk
+progs.mk
+rst2htm.mk
+scripts.mk
+srctop.mk
+subdir.mk
+sys.mk
+sys.clean-env.mk
+sys.dependfile.mk
+sys/AIX.mk
+sys/Darwin.mk
+sys/Generic.mk
+sys/HP-UX.mk
+sys/IRIX.mk
+sys/Linux.mk
+sys/NetBSD.mk
+sys/OSF1.mk
+sys/OpenBSD.mk
+sys/SunOS.mk
+sys/UnixWare.mk
+target-flags.mk
+warnings.mk
+yacc.mk
+dirdeps.mk
+gendirdeps.mk
+install-new.mk
+meta2deps.py
+meta2deps.sh
+meta.sys.mk
+meta.autodep.mk
+meta.stage.mk
+meta.subdir.mk
diff --git a/contrib/bmake/mk/README b/contrib/bmake/mk/README
new file mode 100644
index 0000000..3d79b6a
--- /dev/null
+++ b/contrib/bmake/mk/README
@@ -0,0 +1,401 @@
+# $Id: README,v 1.1 1997/03/11 07:27:15 sjg Exp $
+
+This directory contains some macro's derrived from the NetBSD bsd.*.mk
+macros. They have the same names but without the bsd., separate macro
+files are needed to ensure we can make them do what we want for
+builing things outside of /usr/src. Nearly all the comments below
+apply.
+
+# $NetBSD: bsd.README,v 1.18 1997/01/13 00:54:23 mark Exp $
+# @(#)bsd.README 5.1 (Berkeley) 5/11/90
+
+This is the README file for the new make "include" files for the BSD
+source tree. The files are installed in /usr/share/mk, and are, by
+convention, named with the suffix ".mk".
+
+Note, this file is not intended to replace reading through the .mk
+files for anything tricky.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+RANDOM THINGS WORTH KNOWING:
+
+The files are simply C-style #include files, and pretty much behave like
+you'd expect. The syntax is slightly different in that a single '.' is
+used instead of the hash mark, i.e. ".include <bsd.prog.mk>".
+
+One difference that will save you lots of debugging time is that inclusion
+of the file is normally done at the *end* of the Makefile. The reason for
+this is because .mk files often modify variables and behavior based on the
+values of variables set in the Makefile. To make this work, remember that
+the FIRST target found is the target that is used, i.e. if the Makefile has:
+
+ a:
+ echo a
+ a:
+ echo a number two
+
+the command "make a" will echo "a". To make things confusing, the SECOND
+variable assignment is the overriding one, i.e. if the Makefile has:
+
+ a= foo
+ a= bar
+
+ b:
+ echo ${a}
+
+the command "make b" will echo "bar". This is for compatibility with the
+way the V7 make behaved.
+
+It's fairly difficult to make the BSD .mk files work when you're building
+multiple programs in a single directory. It's a lot easier split up the
+programs than to deal with the problem. Most of the agony comes from making
+the "obj" directory stuff work right, not because we switch to a new version
+of make. So, don't get mad at us, figure out a better way to handle multiple
+architectures so we can quit using the symbolic link stuff. (Imake doesn't
+count.)
+
+The file .depend in the source directory is expected to contain dependencies
+for the source files. This file is read automatically by make after reading
+the Makefile.
+
+The variable DESTDIR works as before. It's not set anywhere but will change
+the tree where the file gets installed.
+
+The profiled libraries are no longer built in a different directory than
+the regular libraries. A new suffix, ".po", is used to denote a profiled
+object.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+The include file <sys.mk> has the default rules for all makes, in the BSD
+environment or otherwise. You probably don't want to touch this file.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+The include file <bsd.man.mk> handles installing manual pages and their
+links.
+
+It has a single target:
+
+ maninstall:
+ Install the manual pages and their links.
+
+It sets/uses the following variables:
+
+MANDIR Base path for manual installation.
+
+MANGRP Manual group.
+
+MANOWN Manual owner.
+
+MANMODE Manual mode.
+
+MANSUBDIR Subdirectory under the manual page section, i.e. "/vax"
+ or "/tahoe" for machine specific manual pages.
+
+MAN The manual pages to be installed (use a .1 - .9 suffix).
+
+MLINKS List of manual page links (using a .1 - .9 suffix). The
+ linked-to file must come first, the linked file second,
+ and there may be multiple pairs. The files are soft-linked.
+
+The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
+it exists.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+The include file <bsd.own.mk> contains source tree configuration parameters,
+such as the owners, groups, etc. for both manual pages and binaries, and
+a few global "feature configuration" parameters.
+
+It has no targets.
+
+To get system-specific configuration parameters, bsd.own.mk will try to
+include the file specified by the "MAKECONF" variable. If MAKECONF is not
+set, or no such file exists, the system make configuration file, /etc/mk.conf
+is included. These files may define any of the variables described below.
+
+bsd.own.mk sets the following variables, if they are not already defined
+(defaults are in brackets):
+
+BSDSRCDIR The real path to the system sources, so that 'make obj'
+ will work correctly. [/usr/src]
+
+BSDOBJDIR The real path to the system 'obj' tree, so that 'make obj'
+ will work correctly. [/usr/obj]
+
+BINGRP Binary group. [bin]
+
+BINOWN Binary owner. [bin]
+
+BINMODE Binary mode. [555]
+
+NONBINMODE Mode for non-executable files. [444]
+
+MANDIR Base path for manual installation. [/usr/share/man/cat]
+
+MANGRP Manual group. [bin]
+
+MANOWN Manual owner. [bin]
+
+MANMODE Manual mode. [${NONBINMODE}]
+
+LIBDIR Base path for library installation. [/usr/lib]
+
+LINTLIBDIR Base path for lint(1) library installation. [/usr/libdata/lint]
+
+LIBGRP Library group. [${BINGRP}]
+
+LIBOWN Library owner. [${BINOWN}]
+
+LIBMODE Library mode. [${NONBINMODE}]
+
+DOCDIR Base path for system documentation (e.g. PSD, USD, etc.)
+ installation. [/usr/share/doc]
+
+DOCGRP Documentation group. [bin]
+
+DOCOWN Documentation owner. [bin]
+
+DOCMODE Documentation mode. [${NONBINMODE}]
+
+NLSDIR Base path for National Language Support files installation.
+ [/usr/share/nls]
+
+NLSGRP National Language Support files group. [bin]
+
+NLSOWN National Language Support files owner. [bin]
+
+NLSMODE National Language Support files mode. [${NONBINMODE}]
+
+STRIP The flag passed to the install program to cause the binary
+ to be stripped. This is to be used when building your
+ own install script so that the entire system can be made
+ stripped/not-stripped using a single knob. [-s]
+
+COPY The flag passed to the install program to cause the binary
+ to be copied rather than moved. This is to be used when
+ building our own install script so that the entire system
+ can either be installed with copies, or with moves using
+ a single knob. [-c]
+
+Additionally, the following variables may be set by bsd.own.mk or in a
+make configuration file to modify the behaviour of the system build
+process (default values are in brackets along with comments, if set by
+bsd.own.mk):
+
+EXPORTABLE_SYSTEM
+ Do not build /usr/src/domestic, even if it is present.
+
+SKEY Compile in support for S/key authentication. [yes, set
+ unconditionally]
+
+KERBEROS Compile in support for Kerberos 4 authentication.
+
+KERBEROS5 Compile in support for Kerberos 5 authentication.
+
+MANZ Compress manual pages at installation time.
+
+SYS_INCLUDE Copy or symlink kernel include files into /usr/include.
+ Possible values are "symlinks" or "copies" (which is
+ the same as the variable being unset).
+
+NOPROFILE Do not build profiled versions of system libraries
+
+NOPIC Do not build PIC versions of system libraries, and
+ do not build shared libraries. [set if ${MACHINE_ARCH}
+ is "mips", "vax", "alpha" or "arm32", unset otherwise.]
+
+NOLINT Do not build lint libraries. [set, set unconditionally]
+
+bsd.own.mk is generally useful when building your own Makefiles so that
+they use the same default owners etc. as the rest of the tree.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+The include file <bsd.prog.mk> handles building programs from one or
+more source files, along with their manual pages. It has a limited number
+of suffixes, consistent with the current needs of the BSD tree.
+
+It has eight targets:
+
+ all:
+ build the program and its manual page
+ clean:
+ remove the program, any object files and the files a.out,
+ Errs, errs, mklog, and core.
+ cleandir:
+ remove all of the files removed by the target clean, as
+ well as .depend, tags, and any manual pages.
+ depend:
+ make the dependencies for the source files, and store
+ them in the file .depend.
+ includes:
+ install any header files.
+ install:
+ install the program and its manual pages; if the Makefile
+ does not itself define the target install, the targets
+ beforeinstall and afterinstall may also be used to cause
+ actions immediately before and after the install target
+ is executed.
+ lint:
+ run lint on the source files
+ tags:
+ create a tags file for the source files.
+
+It sets/uses the following variables:
+
+BINGRP Binary group.
+
+BINOWN Binary owner.
+
+BINMODE Binary mode.
+
+CLEANFILES Additional files to remove for the clean and cleandir targets.
+
+COPTS Additional flags to the compiler when creating C objects.
+
+HIDEGAME If HIDEGAME is defined, the binary is installed in
+ /usr/games/hide, and a symbolic link is created to
+ /usr/games/dm.
+
+LDADD Additional loader objects. Usually used for libraries.
+ For example, to load with the compatibility and utility
+ libraries, use:
+
+ LDADD+=-lutil -lcompat
+
+LDFLAGS Additional loader flags.
+
+LINKS The list of binary links; should be full pathnames, the
+ linked-to file coming first, followed by the linked
+ file. The files are hard-linked. For example, to link
+ /bin/test and /bin/[, use:
+
+ LINKS= ${DESTDIR}/bin/test ${DESTDIR}/bin/[
+
+MAN Manual pages (should end in .1 - .9). If no MAN variable is
+ defined, "MAN=${PROG}.1" is assumed.
+
+PROG The name of the program to build. If not supplied, nothing
+ is built.
+
+SRCS List of source files to build the program. If PROG is not
+ defined, it's assumed to be ${PROG}.c.
+
+DPADD Additional dependencies for the program. Usually used for
+ libraries. For example, to depend on the compatibility and
+ utility libraries use:
+
+ DPADD+=${LIBCOMPAT} ${LIBUTIL}
+
+ The following libraries are predefined for DPADD:
+
+ LIBC /lib/libc.a
+ LIBCOMPAT /usr/lib/libcompat.a
+ LIBCRYPT /usr/lib/libcrypt.a
+ LIBCURSES /usr/lib/libcurses.a
+ LIBDBM /usr/lib/libdbm.a
+ LIBDES /usr/lib/libdes.a
+ LIBL /usr/lib/libl.a
+ LIBKDB /usr/lib/libkdb.a
+ LIBKRB /usr/lib/libkrb.a
+ LIBKVM /usr/lib/libkvm.a
+ LIBM /usr/lib/libm.a
+ LIBMP /usr/lib/libmp.a
+ LIBPC /usr/lib/libpc.a
+ LIBPLOT /usr/lib/libplot.a
+ LIBRPC /usr/lib/sunrpc.a
+ LIBTERM /usr/lib/libterm.a
+ LIBUTIL /usr/lib/libutil.a
+
+SHAREDSTRINGS If defined, a new .c.o rule is used that results in shared
+ strings, using xstr(1). Note that this will not work with
+ parallel makes.
+
+STRIP The flag passed to the install program to cause the binary
+ to be stripped.
+
+SUBDIR A list of subdirectories that should be built as well.
+ Each of the targets will execute the same target in the
+ subdirectories.
+
+The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
+if it exists, as well as the include file <bsd.man.mk>.
+
+Some simple examples:
+
+To build foo from foo.c with a manual page foo.1, use:
+
+ PROG= foo
+
+ .include <bsd.prog.mk>
+
+To build foo from foo.c with a manual page foo.2, add the line:
+
+ MAN= foo.2
+
+If foo does not have a manual page at all, add the line:
+
+ NOMAN= noman
+
+If foo has multiple source files, add the line:
+
+ SRCS= a.c b.c c.c d.c
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+The include file <bsd.subdir.mk> contains the default targets for building
+subdirectories. It has the same eight targets as <bsd.prog.mk>: all,
+clean, cleandir, depend, includes, install, lint, and tags. For all of
+the directories listed in the variable SUBDIRS, the specified directory
+will be visited and the target made. There is also a default target which
+allows the command "make subdir" where subdir is any directory listed in
+the variable SUBDIRS.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+The include file <bsd.sys.mk> is used by <bsd.prog.mk> and
+<bsd.lib.mk>. It contains overrides that are used when building
+the NetBSD source tree. For instance, if "PARALLEL" is defined by
+the program/library Makefile, it includes a set of rules for lex and
+yacc that allow multiple lex and yacc targets to be built in parallel.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+The include file <bsd.lib.mk> has support for building libraries. It has
+the same eight targets as <bsd.prog.mk>: all, clean, cleandir, depend,
+includes, install, lint, and tags. It has a limited number of suffixes,
+consistent with the current needs of the BSD tree.
+
+It sets/uses the following variables:
+
+LIB The name of the library to build.
+
+LIBDIR Target directory for libraries.
+
+LINTLIBDIR Target directory for lint libraries.
+
+LIBGRP Library group.
+
+LIBOWN Library owner.
+
+LIBMODE Library mode.
+
+LDADD Additional loader objects.
+
+MAN The manual pages to be installed (use a .1 - .9 suffix).
+
+SRCS List of source files to build the library. Suffix types
+ .s, .c, and .f are supported. Note, .s files are preferred
+ to .c files of the same name. (This is not the default for
+ versions of make.)
+
+The include file <bsd.lib.mk> includes the file named "../Makefile.inc"
+if it exists, as well as the include file <bsd.man.mk>.
+
+It has rules for building profiled objects; profiled libraries are
+built by default.
+
+Libraries are ranlib'd when made.
diff --git a/contrib/bmake/mk/auto.dep.mk b/contrib/bmake/mk/auto.dep.mk
new file mode 100644
index 0000000..bb2d4c1
--- /dev/null
+++ b/contrib/bmake/mk/auto.dep.mk
@@ -0,0 +1,64 @@
+#
+# RCSid:
+# $Id: auto.dep.mk,v 1.2 2010/04/19 17:37:19 sjg Exp $
+#
+# @(#) Copyright (c) 2010, 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 module provides automagic dependency generation along the
+# lines suggested in the GNU make.info
+
+# set MKDEP=auto.dep 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
+# this makes it simpler to get the args to -MF and -MT right
+# and ensure we can simply include all the .d files.
+#
+# However suffix rules do not work with something like .o.d so we
+# don't even try to handle 'make depend' gracefully.
+# dep.mk will handle that itself.
+#
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+# this what bmake > 20100401 will look for
+.MAKE.DEPENDFILE ?= .depend
+
+# set this to -MMD to ignore /usr/include
+# actually it ignores <> so may not be a great idea
+CFLAGS_MD ?= -MD
+# -MF etc not available on all gcc versions.
+CFLAGS_MF ?= -MF ${.TARGET:T}.d -MT ${.TARGET:T}
+CFLAGS += ${CFLAGS_MD} ${CFLAGS_MF}
+CXXFLAGS += ${CFLAGS_MD} ${CFLAGS_MF}
+
+CLEANFILES += .depend ${.MAKE.DEPENDFILE} *.d
+
+# skip generating dependfile for misc targets
+.if ${.TARGETS:Uall:M*all} != ""
+.END: ${.MAKE.DEPENDFILE}
+.endif
+
+# doing 'make depend' isn't a big win with this model
+.if !target(depend)
+depend: ${.MAKE.DEPENDFILE}
+.endif
+
+# this is trivial
+${.MAKE.DEPENDFILE}: ${OBJS} ${POBJS} ${SOBJS}
+ -@for f in ${.ALLSRC:M*o:T:O:u:%=%.d}; do \
+ echo ".-include \"$$f\""; \
+ done > $@
+
+.endif
diff --git a/contrib/bmake/mk/auto.obj.mk b/contrib/bmake/mk/auto.obj.mk
new file mode 100644
index 0000000..adccd4b
--- /dev/null
+++ b/contrib/bmake/mk/auto.obj.mk
@@ -0,0 +1,56 @@
+# $Id: auto.obj.mk,v 1.8 2011/08/08 17:35:20 sjg Exp $
+#
+# @(#) Copyright (c) 2004, 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
+#
+
+ECHO_TRACE ?= echo
+
+.ifndef Mkdirs
+# A race condition in some versions of mkdir, means that it can bail
+# if another process made a dir that mkdir expected to.
+# We repeat the mkdir -p a number of times to try and work around this.
+# We stop looping as soon as the dir exists.
+# If we get to the end of the loop, a plain mkdir will issue an error.
+Mkdirs= Mkdirs() { \
+ for d in $$*; do \
+ for i in 1 2 3 4 5 6; do \
+ mkdir -p $$d; \
+ test -d $$d && return 0; \
+ done > /dev/null 2>&1; \
+ mkdir $$d || exit $$?; \
+ done; }
+.endif
+
+# 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 !defined(NOOBJ) && !defined(NO_OBJ) && ${MKOBJDIRS:Uno} == auto
+# Use __objdir here so it is easier to tweak without impacting
+# the logic.
+__objdir?= ${MAKEOBJDIR}
+.if ${.OBJDIR} != ${__objdir}
+# We need to chdir, make the directory if needed
+.if !exists(${__objdir}/) && \
+ (${.TARGETS} == "" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} != "")
+# This will actually make it...
+__objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \
+ ${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \
+ ${Mkdirs}; Mkdirs ${__objdir}
+.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}
+.endif
+.endif
+.endif
diff --git a/contrib/bmake/mk/autoconf.mk b/contrib/bmake/mk/autoconf.mk
new file mode 100644
index 0000000..573a715
--- /dev/null
+++ b/contrib/bmake/mk/autoconf.mk
@@ -0,0 +1,78 @@
+# $Id: autoconf.mk,v 1.8 2012/11/19 05:37:48 sjg Exp $
+#
+# @(#) Copyright (c) 1996-2009, 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
+#
+
+.NOPATH: config.h config.status
+
+.if !target(config.h)
+config.h: ${.CURDIR}/config.h.in config.status
+ ./config.status
+.endif
+
+.if !target(config.status)
+# avoid the targets behaving differently
+.if exists(${.OBJDIR}/config.status)
+config.status: config.recheck
+.else
+config.status: config.gen
+.endif
+
+config.recheck: config.h.in ${.CURDIR}/configure
+ ./config.status --recheck
+ @touch $@
+
+config.gen: config.h.in ${.CURDIR}/configure
+ CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS}
+ @touch $@ config.recheck
+
+CLEANFILES+= config.recheck config.gen config.status *.meta
+.endif
+
+# avoid things blowing up if these are not here...
+# this is not quite per the autoconf manual,
+# and is extremely convoluted - but all utterly necessary!
+
+.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes"
+AUTOCONF ?= autoconf
+AUTOHEADER ?= autoheader
+
+# expand it to a full path
+AUTOCONF := ${AUTOCONF:${M_whence}}
+
+.if exists(${AUTOCONF})
+
+.PRECIOUS: configure config.h.in config.status
+
+ACLOCAL =
+ACCONFIG =
+
+.if exists(${.CURDIR}/aclocal.m4)
+ACLOCAL += aclocal.m4
+.endif
+# use of acconfig.h is deprecated!
+.if exists(${.CURDIR}/acconfig.h)
+ACCONFIG += acconfig.h
+.endif
+
+config.h.in: ${.CURDIR}/configure.in ${ACCONFIG}
+ (cd ${.CURDIR} && ${AUTOHEADER})
+
+configure: ${.CURDIR}/configure.in ${ACLOCAL}
+ (cd ${.CURDIR} && ${AUTOCONF})
+
+AUTOCONF_INPUTS += configure
+autoconf-input: ${AUTOCONF_INPUTS}
+
+.endif
+.endif
diff --git a/contrib/bmake/mk/autodep.mk b/contrib/bmake/mk/autodep.mk
new file mode 100644
index 0000000..744770f
--- /dev/null
+++ b/contrib/bmake/mk/autodep.mk
@@ -0,0 +1,216 @@
+#
+# RCSid:
+# $Id: autodep.mk,v 1.32 2010/04/19 17:37:56 sjg Exp $
+#
+# @(#) Copyright (c) 1999-2010, 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 module provides automagic dependency generation along the
+# lines suggested in the GNU make.info
+# The depend target is mainly for backwards compatability,
+# 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
+.-include "$d"
+.endfor
+
+# it does nothing if SRCS is not defined or is empty
+.if defined(SRCS) && !empty(SRCS)
+DEPSRCS?=${SRCS}
+__depsrcs=${DEPSRCS:M*.c}
+__depsrcs+=${DEPSRCS:M*.y}
+__depsrcs+=${DEPSRCS:M*.l}
+__depsrcs+=${DEPSRCS:M*.s}
+__depsrcs+=${DEPSRCS:M*.S}
+__depsrcs+=${DEPSRCS:M*.cc}
+__depsrcs+=${DEPSRCS:M*.cpp}
+__depsrcs+=${DEPSRCS:M*.C}
+__depsrcs+=${DEPSRCS:M*.cxx}
+__depsrcs+=${DEPSRCS:M*.pc}
+
+.for s in ${__depsrcs}
+${s:T:R}.d: $s
+.endfor
+
+__depsrcs:=${__depsrcs:T:R:S/$/.d/g}
+# we also need to handle makefiles where the .d's from __depsrcs
+# don't match those from OBJS
+# we avoid using := here, since the modifier applied to OBJS
+# can cause trouble if there are any undefined vars in OBJS.
+__dependsrcsx?= ${__depsrcs} ${OBJS:S/.o/.d/}
+__dependsrcs= ${__dependsrcsx:O:u}
+
+# clean up any .c files we may have generated
+#__gensrcs:= ${DEPSRCS:M*.y} ${DEPSRCS:M*.l}
+#CLEANFILES+= ${__gensrcs:T:R:S/$/.c/g}
+
+# set this to -MMD to ignore /usr/include
+# actually it ignores <> so may not be a great idea
+CFLAGS_MD?=-MD
+# -MF etc not available on all gcc versions.
+# we "fix" the .o later
+CFLAGS_MF?=-MF ${.TARGET:T:R}.d -MT ${.TARGET:T:R}.o
+CFLAGS+= ${CFLAGS_MD} ${CFLAGS_MF}
+RM?= rm
+
+# watch out for people who don't use CPPFLAGS
+CPPFLAGS_MD=${CFLAGS:M-[IUD]*} ${CPPFLAGS}
+CXXFLAGS_MD=${CXXFLAGS:M-[IUD]*} ${CPPFLAGS}
+
+# just in case these need to be different
+CC_MD?=${CC}
+CXX_MD?=${CXX}
+
+# so we can do an explicit make depend, but not otherwise
+.if make(depend)
+.SUFFIXES: .d
+
+.if empty(CFLAGS_MD)
+.y.d:
+ @echo updating dependencies for $<
+ @${YACC} ${YFLAGS} $<
+ @${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} y.tab.c | sed '/:/s/^/$@ /' > $@" || { ${RM} -f y.tab.c $@; false; }
+ @${RM} -f y.tab.c
+
+.l.d:
+ @echo updating dependencies for $<
+ ${LEX} ${LFLAGS} $<
+ @${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} lex.yy.c | sed '/:/s/^/$@ /' > $@" || { ${RM} -f lex.yy.c $@; false; }
+ @${RM} -f lex.yy.c
+
+.c.d:
+ @echo updating dependencies for $<
+ @${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
+
+.s.d .S.d:
+ @echo updating dependencies for $<
+ @${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} ${AINC} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
+
+.cc.d .cpp.d .C.d .cxx.d:
+ @echo updating dependencies for $<
+ @${SHELL} -ec "${CXX_MD} -M ${CXXFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
+.else
+.y.d:
+ ${YACC} ${YFLAGS} $<
+ ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} y.tab.c > $@ || { ${RM} -f y.tab.c $@; false; }
+ ${RM} -f y.tab.c
+
+.l.d:
+ ${LEX} ${LFLAGS} $<
+ ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} lex.yy.c > $@ || { ${RM} -f lex.yy.c $@; false; }
+ ${RM} -f lex.yy.c
+
+.c.d:
+ ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} $< > $@ || { ${RM} -f $@; false; }
+
+.s.d .S.d:
+ ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} ${AINC} $< > $@ || { ${RM} -f $@; false; }
+
+.cc.d .cpp.d .C.d .cxx.d:
+ ${CXX_MD} ${CFLAGS_MD:S/D//} ${CXXFLAGS_MD} $< > $@ || { ${RM} -f $@; false; }
+.endif
+
+.if !target(depend)
+depend: beforedepend ${DEPENDFILE} afterdepend _SUBDIRUSE
+
+${DEPENDFILE}: ${DEPSRCS} ${__dependsrcs}
+.NOPATH: ${__dependsrcs}
+.OPTIONAL: ${__dependsrcs}
+.endif
+.endif # make(depend)
+
+.if empty(CFLAGS_MD)
+# make sure the .d's are generated/updated
+${PROG} ${_LIBS}: ${DEPENDFILE}
+.endif
+
+.ORDER: beforedepend ${DEPENDFILE} afterdepend
+
+.if ${.OBJDIR} != ${.CURDIR}
+__depfiles= *.d
+.else
+__depfiles= ${__dependsrcs}
+.endif
+
+DEPCLEANFILES= ${DEPENDFILE} ${__depfiles} y.tab.d *.tmp.d
+
+cleandir: cleanautodepend
+cleanautodepend:
+ ${RM} -f ${DEPCLEANFILES}
+
+CLEANFILES+= ${DEPCLEANFILES}
+
+.if defined(__dependsrcs) && !empty(__dependsrcs)
+.if make(depend) || !(make(clean*) || make(destroy*) || make(obj) || make(*install) || make(install-*))
+# this ensures we do the right thing if only building a shared or
+# profiled lib
+OBJ_EXTENSIONS?=.o .po .so .So
+MDLIB_SED= -e '/:/s,^\([^\.:]*\)\.[psS]*o,${OBJ_EXTENSIONS:S,^,\1,},'
+.ifdef NOMD_SED
+.ifdef LIB
+MD_SED=sed ${MDLIB_SED}
+.else
+MD_SED=cat
+.endif
+.else
+# arrange to put some variable names into ${DEPENDFILE}
+.ifdef LIB
+MD_SED=sed ${MDLIB_SED}
+.else
+MD_SED=sed
+.endif
+SUBST_DEPVARS+= SB TOP BACKING SRC SRCDIR BASE BASEDIR
+.for v in ${SUBST_DEPVARS}
+.if defined(${v}) && !empty(${v})
+MD_SED+= -e 's,${$v},$${$v},'
+.endif
+.endfor
+.endif
+.if (${MD_SED} == "sed")
+MD_SED=cat
+.endif
+
+# this will be done whenever make finishes successfully
+.if ${MAKE_VERSION:U0:[1]:C/.*-//} < 20050530
+.END:
+.else
+.END: ${DEPENDFILE}
+# we do not want to trigger building .d's just use them if they exist
+${DEPENDFILE}: ${__dependsrcs:@d@${exists($d):?$d:}@}
+.endif
+ -@${MD_SED} ${__depfiles} > ${DEPENDFILE}.new 2> /dev/null && \
+ test -s ${DEPENDFILE}.new && mv ${DEPENDFILE}.new ${DEPENDFILE}; \
+ ${RM} -f ${DEPENDFILE}.new
+.endif
+.endif
+.else
+depend: beforedepend afterdepend _SUBDIRUSE
+.endif
+
+.if !target(beforedepend)
+beforedepend:
+.endif
+.if !target(afterdepend)
+afterdepend:
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/dep.mk b/contrib/bmake/mk/dep.mk
new file mode 100644
index 0000000..b754500
--- /dev/null
+++ b/contrib/bmake/mk/dep.mk
@@ -0,0 +1,133 @@
+# $Id: dep.mk,v 1.16 2012/11/11 22:37:02 sjg Exp $
+
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+# handle Proc*C as well...
+.if defined(SRCS)
+.if !empty(SRCS:M*.pc)
+.include <proc.mk>
+.endif
+
+# it would be nice to be able to query .SUFFIXES
+OBJ_EXTENSIONS+= .o .po .lo .So
+
+# explicit dependencies help short-circuit .SUFFIX searches
+SRCS_DEP_FILTER+= N*.[hly]
+.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}}
+.for e in ${OBJ_EXTENSIONS:O:u}
+.if !target(${s:T:R}$e)
+${s:T:R}$e: $s
+.endif
+.endfor
+.endfor
+.endif
+
+.if exists(/usr/bin/mkdep)
+MKDEP_CMD?= mkdep
+.elif exists(/usr/local/share/bin/mkdeps.sh)
+MKDEP_CMD?= /usr/local/share/bin/mkdeps.sh -N
+.endif
+MKDEP_CMD?= mkdep
+
+MKDEP ?= ${MKDEP_CMD}
+
+.NOPATH: .depend
+
+.if ${MKDEP} == "auto.dep" && 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>
+.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)
+MKDEP_ENV += $v='${$v}'
+.endif
+.endfor
+
+_MKDEP = ${MKDEP_ENV} ${MKDEP}
+
+# some of the rules involve .h sources, so remove them from mkdep line
+.if !target(depend)
+depend: beforedepend .depend _SUBDIRUSE afterdepend
+
+.if defined(SRCS)
+# libs can have too many SRCS for a single command line
+# so do them one at a time.
+.depend: ${SRCS} ${.PARSEDIR}/${.PASEFILE}
+ @rm -f .depend
+.ifdef LIB
+ @files="${.ALLSRC:M*.[sS]}"; \
+ set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$f; done
+ @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
+ set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
+ @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
+ set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
+.else
+ @files="${.ALLSRC:M*.[Ss]}"; \
+ case "$$files" in *.[Ss]*) \
+ echo ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files; \
+ ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files;; \
+ esac
+ @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
+ case "$$files" in *.c*) \
+ echo ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
+ ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
+ esac
+ @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
+ case "$$files" in *.[Cc]*) \
+ echo ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
+ ${_MKDEP} -a ${MKDEPFLAGS} \
+ ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
+ esac
+.endif
+.else
+.depend:
+.endif
+.if !target(beforedepend)
+beforedepend:
+.endif
+.if !target(afterdepend)
+afterdepend:
+.endif
+.endif
+.endif
+
+.if !target(tags)
+.if defined(SRCS)
+tags: ${SRCS} _SUBDIRUSE
+ -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
+ sed "s;\${.CURDIR}/;;" > tags
+.else
+tags:
+.endif
+.endif
+
+.if defined(SRCS)
+cleandir: cleandepend
+.if !target(cleandepend)
+cleandepend:
+ rm -f .depend ${.CURDIR}/tags
+.endif
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/dirdeps.mk b/contrib/bmake/mk/dirdeps.mk
new file mode 100644
index 0000000..9f051e9
--- /dev/null
+++ b/contrib/bmake/mk/dirdeps.mk
@@ -0,0 +1,414 @@
+# $Id: dirdeps.mk,v 1.23 2012/11/06 05:44:03 sjg Exp $
+
+# Copyright (c) 2010-2012, Juniper Networks, Inc.
+#
+# 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+# OWNER 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.
+
+# Much of the complexity here is for supporting cross-building.
+# If a tree does not support that, simply using plain Makefile.depend
+# should provide sufficient clue.
+# Otherwise the recommendation is to use Makefile.depend.${MACHINE}
+# as expected below.
+
+# Note: this file gets multiply included.
+# This is what we do with DIRDEPS
+
+# DIRDEPS:
+# This is a list of directories - relative to SRCTOP, it is only
+# of interest to .MAKE.LEVEL 0.
+# In some cases the entry may be qualified with a .<machine>
+# suffix, for example to force building something for the pseudo
+# machines "host" or "common" regardless of current ${MACHINE}.
+# All unqualified entries end up being qualified with .${MACHINE}
+# and _DIRDEPS_USE below, uses the suffix to set MACHINE
+# correctly when visiting each entry.
+#
+# Each entry is also converted into a set of paths to look for
+# Makefile.depend.<machine> to learn the dependencies of each.
+# Each Makefile.depend.<machine> sets DEP_RELDIR to be the
+# the RELDIR (path relative to SRCTOP) for its directory, and
+# DEP_MACHINE to its suffix (<machine>), further since
+# each Makefile.depend.<machine> includes dirdeps.mk, this
+# processing is recursive and results in .MAKE.LEVEL 0 learning the
+# dependencies of the tree wrt the initial directory (_DEP_RELDIR).
+#
+# BUILD_AT_LEVEL0
+# Indicates whether .MAKE.LEVEL 0 builds anything:
+# if "no" sub-makes are used to build everything,
+# if "yes" sub-makes are only used to build for other machines.
+#
+# TARGET_SPEC_VARS
+# All the description above (and below) assumes <machine> is the
+# only data needed to control the build.
+# This is not always the case. So in addition to setting
+# MACHINE in the build environment we set TARGET_SPEC which is
+# composed of the values of TARGET_SPEC_VARS separated by
+# commas. The default is just MACHINE.
+#
+# If more that MACHINE is needed then sys.mk needs to decompose
+# TARGET_SPEC and set the relevant variables accordingly.
+# It is important that MACHINE be included in TARGET_SPEC_VARS
+# since if there is more the value passed as MACHINE will infact
+# be the TARGET_SPEC.
+# Note: TARGET_SPEC cannot contain any '.'s so the target
+# tripple used by compiler folk won't work (directly anyway).
+#
+# For example:
+#
+# # variables other than MACHINE might be optional
+# TARGET_SPEC_VARS = MACHINE TARGET_OS
+# .if ${TARGET_SPEC:Uno:M*,*} != ""
+# _tspec := ${TARGET_SPEC:S/,/ /g}
+# MACHINE := ${_tspec:[1]}
+# TARGET_OS := ${_tspec:[2]}
+# # etc.
+# .for v in ${TARGET_SPEC_VARS:O:u}
+# .if empty($v)
+# .undef $v
+# .endif
+# .endfor
+# .endif
+#
+
+.if ${.MAKE.LEVEL} == 0
+# only the first instance is interested in all this
+
+# First off, we want to know what ${MACHINE} to build for.
+# This can be complicated if we are using a mixture of ${MACHINE} specific
+# and non-specific Makefile.depend*
+
+.if !target(_DIRDEP_USE)
+# do some setup we only need once
+_CURDIR ?= ${.CURDIR}
+
+# If TARGET_SPEC_VARS is other than just MACHINE
+# it should be set by sys.mk or similar by now.
+# TARGET_SPEC must not contain any '.'s.
+TARGET_SPEC_VARS ?= MACHINE
+TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
+
+.if !defined(.MAKE.DEPENDFILE_PREFERENCE)
+# this makes the logic below neater?
+.MAKE.DEPENDFILE_PREFERENCE = ${_CURDIR}/${.MAKE.DEPENDFILE:T}
+.if ${.MAKE.DEPENDFILE:E} == "${TARGET_SPEC}"
+.if ${TARGET_SPEC} != ${MACHINE}
+.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}.$${MACHINE}
+.endif
+.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}
+.endif
+.endif
+
+_default_dependfile := ${.MAKE.DEPENDFILE_PREFERENCE:[1]:T}
+_machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:M*.${TARGET_SPEC}} \
+ ${.MAKE.DEPENDFILE_PREFERENCE:M*.${MACHINE}}
+
+# for machine specific dependfiles we require ${MACHINE} to be at the end
+# also for the sake of sanity we require a common prefix
+.if !defined(.MAKE.DEPENDFILE_PREFIX)
+.if !empty(_machine_dependfiles)
+.MAKE.DEPENDFILE_PREFIX := ${_machine_dependfiles:[1]:T:R}
+.else
+.MAKE.DEPENDFILE_PREFIX := ${_default_dependfile:T}
+.endif
+.endif
+
+
+# this is how we identify non-machine specific dependfiles
+N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N${TARGET_SPEC}:N${MACHINE}:${M_ListToSkip}}
+
+.endif # !target(_DIRDEP_USE)
+
+_last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]}
+
+# Note: if a makefile is read many times, the above
+# will not work, so we also test for DEP_MACHINE==depend below.
+.if empty(_last_dependfile)
+# we haven't included one yet
+DEP_MACHINE ?= ${TARGET_MACHINE:U${TARGET_SPEC}}
+# else it should be correctly set by ${.MAKE.DEPENDFILE}
+.elif ${_last_dependfile:E:${N_notmachine}} == "" || ${DEP_MACHINE:Uno:${N_notmachine}} == ""
+# don't rely on manually maintained files to be correct
+DEP_MACHINE := ${_DEP_MACHINE:U${TARGET_SPEC}}
+.else
+# just in case
+DEP_MACHINE ?= ${_last_dependfile:E}
+.endif
+
+# pickup customizations
+# as below you can use !target(_DIRDEP_USE) to protect things
+# which should only be done once.
+.-include "local.dirdeps.mk"
+
+# the first time we are included the _DIRDEP_USE target will not be defined
+# we can use this as a clue to do initialization and other one time things.
+.if !target(_DIRDEP_USE)
+# make sure this target exists
+dirdeps:
+
+# We normally expect to be included by Makefile.depend.*
+# which sets the DEP_* macros below.
+DEP_RELDIR ?= ${RELDIR}
+
+# this can cause lots of output!
+# set to a set of glob expressions that might match RELDIR
+DEBUG_DIRDEPS ?= no
+
+# remember the initial value of DEP_RELDIR - we test for it below.
+_DEP_RELDIR := ${DEP_RELDIR}
+
+# things we skip for host tools
+SKIP_HOSTDIR ?=
+
+NSkipHostDir = ${SKIP_HOSTDIR:N*.host:S,$,.host,:N.host:${M_ListToSkip}}
+NSkipHostDep = ${SKIP_HOSTDIR:R:@d@*/$d*.host@:${M_ListToSkip}}
+
+# things we always skip
+# SKIP_DIRDEPS allows for adding entries on command line.
+SKIP_DIR += .host *.WAIT ${SKIP_DIRDEPS}
+
+.ifdef HOSTPROG
+SKIP_DIR += ${SKIP_HOSTDIR}
+.endif
+
+NSkipDir = ${SKIP_DIR:${M_ListToSkip}}
+
+.if defined(NO_DIRDEPS) || defined(NODIRDEPS)
+# confine ourselves to the original dir
+DIRDEPS_FILTER += M${_DEP_RELDIR}*
+.endif
+
+# we supress SUBDIR when visiting the leaves
+# we assume sys.mk will set MACHINE_ARCH
+_DIRDEP_USE: .USE .MAKE
+ @for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \
+ test -s ${.TARGET:R}/$$m || continue; \
+ echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \
+ TARGET_SPEC=${.TARGET:E} \
+ MACHINE=${.TARGET:E} MACHINE_ARCH= NO_SUBDIR=1 \
+ ${.MAKE} -C ${.TARGET:R} || exit 1; \
+ break; \
+ done
+
+.ifdef ALL_MACHINES
+# this is how you limit it to only the machines we have been built for
+# previously.
+.if empty(ONLY_MACHINE_LIST)
+.if !empty(ALL_MACHINE_LIST)
+# ALL_MACHINE_LIST is the list of all legal machines - ignore anything else
+_machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo
+.else
+_machine_list != 'ls' -1 ${_CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.* 2> /dev/null; echo
+.endif
+_only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u}
+.else
+_only_machines := ${ONLY_MACHINE_LIST}
+.endif
+
+.if empty(_only_machines)
+# we must be boot-strapping
+_only_machines := ${TARGET_MACHINE:U${ALL_MACHINE_LIST:U${DEP_MACHINE}}}
+.endif
+
+.else # ! ALL_MACHINES
+# if ONLY_MACHINE_LIST is set, we are limited to that
+# if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST
+# otherwise DEP_MACHINE is it - so DEP_MACHINE will match.
+_only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}}
+.endif
+
+.if !empty(NOT_MACHINE_LIST)
+_only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}}
+.endif
+
+# make sure we have a starting place?
+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}@}
+
+# the rest is done repeatedly for every Makefile.depend we read.
+# if we are anything but the original dir we care only about the
+# machine type we were included for..
+
+.if ${DEP_RELDIR} == "."
+_this_dir := ${SRCTOP}
+.else
+_this_dir := ${SRCTOP}/${DEP_RELDIR}
+.endif
+
+# on rare occasions, there can be a need for extra help
+_dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc
+.-include "${_dep_hack}"
+
+.if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_MACHINE} != ${TARGET_SPEC}
+# this should be all
+_machines := ${DEP_MACHINE}
+.else
+# this is the machine list we actually use below
+_machines := ${_only_machines}
+
+.if defined(HOSTPROG) || ${DEP_MACHINE} == "host"
+# we need to build this guy's dependencies for host as well.
+_machines += host
+.endif
+
+_machines := ${_machines:O:u}
+.endif
+
+# reset these each time through
+_build_dirs =
+_depdir_files =
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# pickup other machines for this dir if necessary
+.if ${BUILD_AT_LEVEL0:Uyes} == "no"
+_build_dirs += ${_machines:@m@${_CURDIR}.$m@}
+.else
+_build_dirs += ${_machines:N${DEP_MACHINE}:@m@${_CURDIR}.$m@}
+.if ${DEP_MACHINE} == ${TARGET_SPEC}
+# pickup local dependencies now
+.-include <.depend>
+.endif
+.endif
+.endif
+
+.if !empty(_debug_reldir)
+.info ${DEP_RELDIR}.${DEP_MACHINE}: _last_dependfile='${_last_dependfile}'
+.info ${DEP_RELDIR}.${DEP_MACHINE}: DIRDEPS='${DIRDEPS}'
+.info ${DEP_RELDIR}.${DEP_MACHINE}: _machines='${_machines}'
+.endif
+
+.if !empty(DIRDEPS)
+
+# this is what we start with
+__depdirs := ${DIRDEPS:${NSkipDir}:${DIRDEPS_FILTER:ts:}:O:u:@d@${SRCTOP}/$d@}
+
+# some entries may be qualified with .<machine>
+# the :M*/*/*.* just tries to limit the dirs we check to likely ones.
+# the ${d:E:M*/*} ensures we don't consider junos/usr.sbin/mgd
+__qual_depdirs := ${__depdirs:M*/*/*.*:@d@${exists($d):?:${"${d:E:M*/*}":?:${exists(${d:R}):?$d:}}}@}
+__unqual_depdirs := ${__depdirs:${__qual_depdirs:Uno:${M_ListToSkip}}}
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# if it was called out - we likely need it.
+__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@}
+__qual_depdirs += ${__hostdpadd}
+.endif
+
+.if !empty(_debug_reldir)
+.info depdirs=${__depdirs}
+.info qualified=${__qual_depdirs}
+.info unqualified=${__unqual_depdirs}
+.endif
+
+# _build_dirs is what we will feed to _DIRDEP_USE
+_build_dirs += \
+ ${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \
+ ${__qual_depdirs:N*.host} \
+ ${_machines:@m@${__unqual_depdirs:@d@$d.$m@}@}
+
+_build_dirs := ${_build_dirs:O:u}
+
+# this is where we will pick up more dependencies from
+# the inner inline loops look complex, but save a significant
+# amount of memory compared to a .for loop.
+_depdir_files =
+.for d in ${_build_dirs}
+.if exists($d)
+# easy, we're building for ${MACHINE}
+_depdir_files += ${.MAKE.DEPENDFILE_PREFERENCE:T:@m@${exists($d/$m):?$d/$m:}@:[1]}
+.elif exists(${d:R}) && ${d:R:T} == ${d:T:R}
+# a little more complex - building for another machine
+# we will ensure the file is qualified with a machine
+# so that if necessary _DEP_MACHINE can be set below
+_depdir_files += ${.MAKE.DEPENDFILE_PREFERENCE:T:S,.${TARGET_SPEC}$,.${d:E},:S,.${MACHINE}$,.${d:E},:@m@${exists(${d:R}/$m):?${d:R}/$m:}@:[1]:@m@${"${m:M*.${d:E}}":?$m:$m.${d:E}}@}
+.endif
+.endfor
+
+# clean up
+_depdir_files := ${_depdir_files:O:u}
+
+.endif # empty DIRDEPS
+
+# Normally if doing make -V something,
+# we do not want to waste time chasing DIRDEPS
+# 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)
+# this makes it all happen
+dirdeps: ${_build_dirs}
+${_build_dirs}: _DIRDEP_USE
+
+.if !empty(_debug_reldir)
+.info ${DEP_RELDIR}.${DEP_MACHINE}: ${_build_dirs}
+.endif
+
+.for m in ${_machines}
+# it would be nice to do :N${.TARGET}
+.if !empty(__qual_depdirs)
+.for q in ${__qual_depdirs:E:O:u:N$m}
+.if !empty(_debug_reldir) || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
+.info ${DEP_RELDIR}.$m: ${_build_dirs:M*.$q}
+.endif
+${_this_dir}.$m: ${_build_dirs:M*.$q}
+.endfor
+.endif
+.if !empty(_debug_reldir)
+.info ${DEP_RELDIR}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
+.endif
+${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
+.endfor
+
+.endif
+
+.for d in ${_depdir_files}
+.if ${.MAKE.MAKEFILES:M${d}} == ""
+.if !empty(_debug_search)
+.info Looking for $d
+.endif
+.if exists($d)
+.include <$d>
+.elif exists(${d:R})
+# an unqualified file exists, we qualified it above so we can set _DEP_MACHINE
+# it might be manually maintained and shared by all machine types
+# tell it the machine we are interested in.
+_DEP_MACHINE := ${d:E}
+.if !empty(_debug_reldir)
+.info loading ${d:R} for ${_DEP_MACHINE}
+.endif
+# pretend we read $d, so we don't come by here again.
+.MAKE.MAKEFILES += $d
+.include <${d:R}>
+.endif
+.endif
+.endfor
+.endif # -V
+
+.elif ${.MAKE.LEVEL} > 42
+.error You should have stopped recursing by now.
+.else
+_DEP_RELDIR := ${DEP_RELDIR}
+# pickup local dependencies
+.-include <.depend>
+.endif
+
diff --git a/contrib/bmake/mk/doc.mk b/contrib/bmake/mk/doc.mk
new file mode 100644
index 0000000..d496c42
--- /dev/null
+++ b/contrib/bmake/mk/doc.mk
@@ -0,0 +1,63 @@
+# $Id: doc.mk,v 1.4 2012/11/11 22:37:02 sjg Exp $
+
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+BIB?= bib
+EQN?= eqn
+GREMLIN?= grn
+GRIND?= vgrind -f
+INDXBIB?= indxbib
+PIC?= pic
+REFER?= refer
+ROFF?= groff -M/usr/share/tmac ${MACROS} ${PAGES}
+SOELIM?= soelim
+TBL?= tbl
+
+.PATH: ${.CURDIR}
+
+.if !target(all)
+.MAIN: all
+all: paper.ps
+.endif
+
+.if !target(paper.ps)
+paper.ps: ${SRCS}
+ ${ROFF} ${SRCS} > ${.TARGET}
+.endif
+
+.if !target(print)
+print: paper.ps
+ lpr -P${PRINTER} paper.ps
+.endif
+
+.if !target(manpages)
+manpages:
+.endif
+
+.if !target(obj)
+obj:
+.endif
+
+clean cleandir:
+ rm -f paper.* [eE]rrs mklog ${CLEANFILES}
+
+.if ${MK_DOC} == "no"
+install:
+.else
+FILES?= ${SRCS}
+install:
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \
+ Makefile ${FILES} ${EXTRA} ${DESTDIR}${BINDIR}/${DIR}
+.endif
+
+spell: ${SRCS}
+ spell ${SRCS} | sort | comm -23 - spell.ok > paper.spell
+
+BINDIR?= /usr/share/doc
+BINGRP?= bin
+BINOWN?= bin
+BINMODE?= 444
+
+.include <own.mk>
+.endif
diff --git a/contrib/bmake/mk/dpadd.mk b/contrib/bmake/mk/dpadd.mk
new file mode 100644
index 0000000..a940b61
--- /dev/null
+++ b/contrib/bmake/mk/dpadd.mk
@@ -0,0 +1,196 @@
+# $Id: dpadd.mk,v 1.18 2011/11/10 05:13:37 sjg Exp $
+#
+# @(#) Copyright (c) 2004, 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 !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+# sometimes we play games with .CURDIR etc
+# _* hold the original values of .*
+_OBJDIR?= ${.OBJDIR}
+_CURDIR?= ${.CURDIR}
+
+# DPLIBS helps us ensure we keep DPADD and LDADD in sync
+DPLIBS+= ${DPLIBS_LAST}
+DPADD+= ${DPLIBS}
+.for __lib in ${DPLIBS:T:R}
+LDADD+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
+.endfor
+
+# DPADD can contain things other than libs
+__dpadd_libs = ${DPADD:M*/lib*}
+
+# some libs have dependencies...
+# DPLIBS_* allows bsd.libnames.mk to flag libs which must be included
+# in DPADD for a given library.
+.for __lib in ${__dpadd_libs:@d@${DPLIBS_${d:T:R}}@}
+.if "${DPADD:M${__lib}}" == ""
+DPADD+= ${__lib}
+LDADD+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
+.endif
+.endfor
+# Last of all... for libc and libgcc
+DPADD+= ${DPADD_LAST}
+
+# Convert DPADD into -I and -L options and add them to CPPFLAGS and LDADD
+# For the -I's convert the path to a relative one. For separate objdirs
+# the DPADD paths will be to the obj tree so we need to subst anyway.
+
+# If USE_PROFILE is yes, then check for profiled versions of libs
+# and use them.
+
+USE_PROFILE?=no
+.if defined(LIBDL) && exists(${LIBDL})
+.if defined(PROG) && (make(${PROG}_p) || ${USE_PROFILE} == yes) && \
+ defined(LDFLAGS) && ${LDFLAGS:M-export-dynamic}
+# building profiled version of a prog that needs dlopen to work
+DPLIBS+= ${LIBDL}
+.endif
+.endif
+
+.if defined(LIBDMALLOC) && exists(${LIBDMALLOC})
+.if defined(USE_DMALLOC) && ${USE_DMALLOC} != no
+.if !defined(NO_DMALLOC)
+CPPFLAGS+= -DUSE_DMALLOC
+.endif
+DPLIBS+= ${LIBDMALLOC}
+.endif
+.endif
+
+# Order -L's to seach ours first.
+# Avoids picking up old versions already installed.
+__dpadd_libdirs := ${__dpadd_libs:R:H:S/^/-L/g:O:u:N-L}
+LDADD += ${__dpadd_libdirs:M-L${OBJTOP}/*}
+LDADD += ${__dpadd_libdirs:N-L${OBJTOP}/*}
+
+.if ${.CURDIR} == ${SRCTOP}
+RELDIR=.
+RELTOP=.
+.else
+RELDIR?= ${.CURDIR:S,${SRCTOP}/,,}
+.if ${RELDIR} == ${.CURDIR}
+RELDIR?= ${.OBJDIR:S,${OBJTOP}/,,}
+.endif
+RELTOP?= ${RELDIR:C,[^/]+,..,g}
+.endif
+RELOBJTOP?= ${OBJTOP}
+RELSRCTOP?= ${SRCTOP}
+
+.if !make(dpadd)
+.ifdef LIB
+# Each lib is its own src_lib, we want to include it in SRC_LIBS
+# so that the correct INCLUDES_* will be picked up automatically.
+SRC_LIBS+= ${_OBJDIR}/lib${LIB}.a
+.endif
+.endif
+
+#
+# This little bit of magic, assumes that SRC_libfoo will be
+# set if it cannot be correctly derrived from ${LIBFOO}
+# Note that SRC_libfoo and INCLUDES_libfoo should be named for the
+# actual libary name not the variable name that might refer to it.
+# 99% of the time the two are the same, but the DPADD logic
+# only has the libary name available, so stick to that.
+#
+
+SRC_LIBS?=
+__dpadd_libs += ${SRC_LIBS}
+DPMAGIC_LIBS += ${__dpadd_libs} \
+ ${__dpadd_libs:@d@${DPMAGIC_LIBS_${d:T:R}}@}
+
+.for __lib in ${DPMAGIC_LIBS:O:u}
+#
+# if SRC_libfoo is not set, then we assume that the srcdir corresponding
+# to where we found the library is correct.
+#
+SRC_${__lib:T:R} ?= ${__lib:H:S,${OBJTOP},${RELSRCTOP},}
+#
+# This is a no-brainer but just to be complete...
+#
+OBJ_${__lib:T:R} ?= ${__lib:H:S,${OBJTOP},${RELOBJTOP},}
+#
+# If INCLUDES_libfoo is not set, then we'll use ${SRC_libfoo}/h if it exists,
+# else just ${SRC_libfoo}.
+#
+INCLUDES_${__lib:T:R}?= -I${exists(${SRC_${__lib:T:R}}/h):?${SRC_${__lib:T:R}}/h:${SRC_${__lib:T:R}}}
+
+.endfor
+
+# Now for the bits we actually need
+__dpadd_incs=
+.for __lib in ${__dpadd_libs:u}
+.if (make(${PROG}_p) || defined(NEED_GPROF)) && exists(${__lib:R}_p.a)
+__ldadd=-l${__lib:T:R:S,lib,,}
+LDADD := ${LDADD:S,^${__ldadd}$,${__ldadd}_p,g}
+.endif
+
+#
+# Some libs generate headers, so we potentially need both
+# the src dir and the obj dir.
+# If ${INCLUDES_libfoo} contains a word ending in /h, we assume that either
+# 1. it does not generate headers or
+# 2. INCLUDES_libfoo will have been set correctly
+# XXX it gets ugly avoiding duplicates...
+# use :? to ensure .for does not prevent correct evaluation
+#
+# We take care of duplicate suppression later.
+__dpadd_incs += ${"${INCLUDES_${__lib:T:R}:M*/h}":? :-I${OBJ_${__lib:T:R}}}
+__dpadd_incs += ${INCLUDES_${__lib:T:R}}
+.endfor
+
+#
+# eliminate any duplicates - but don't mess with the order
+# force evaluation now - to avoid giving make a headache
+#
+.for t in CFLAGS CXXFLAGS
+# avoid duplicates
+__$t_incs:=${$t:M-I*:O:u}
+.for i in ${__dpadd_incs}
+.if "${__$t_incs:M$i}" == ""
+$t+= $i
+__$t_incs+= $i
+.endif
+.endfor
+.endfor
+
+# This target is used to gather a list of
+# dir: ${DPADD}
+# entries
+.if make(*dpadd*)
+# allow overrides
+.-include "dpadd++.mk"
+
+.if !target(dpadd)
+dpadd: .NOTMAIN
+.if defined(DPADD) && ${DPADD} != ""
+ @echo "${RELDIR}: ${DPADD:S,${OBJTOP}/,,}"
+.endif
+.endif
+.endif
+
+.ifdef SRC_PATHADD
+# We don't want to assume that we need to .PATH every element of
+# SRC_LIBS, but the Makefile cannot do
+# .PATH: ${SRC_libfoo}
+# since the value of SRC_libfoo must be available at the time .PATH:
+# is read - and we only just worked it out.
+# Further, they can't wait until after include of {lib,prog}.mk as
+# the .PATH is needed before then.
+# So we let the Makefile do
+# SRC_PATHADD+= ${SRC_libfoo}
+# and we defer the .PATH: until now so that SRC_libfoo will be available.
+.PATH: ${SRC_PATHADD}
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/final.mk b/contrib/bmake/mk/final.mk
new file mode 100644
index 0000000..5f41189
--- /dev/null
+++ b/contrib/bmake/mk/final.mk
@@ -0,0 +1,14 @@
+# $Id: final.mk,v 1.5 2011/03/11 05:22:38 sjg Exp $
+
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+# provide a hook for folk who want to do scary stuff
+.-include "${.CURDIR}/../Makefile-final.inc"
+
+.if !empty(STAGE)
+.-include <stage.mk>
+.endif
+
+.-include <local.final.mk>
+.endif
diff --git a/contrib/bmake/mk/gendirdeps.mk b/contrib/bmake/mk/gendirdeps.mk
new file mode 100644
index 0000000..890f495
--- /dev/null
+++ b/contrib/bmake/mk/gendirdeps.mk
@@ -0,0 +1,301 @@
+# $Id: gendirdeps.mk,v 1.10 2012/06/30 00:37:50 sjg Exp $
+
+# Copyright (c) 2010, Juniper Networks, Inc.
+#
+# 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+# OWNER 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.
+
+#
+# This makefile [re]generates ${.MAKE.DEPENDFILE}
+#
+
+.include <install-new.mk>
+
+# Assumptions:
+# RELDIR is the relative path from ${SRCTOP} to ${_CURDIR}
+# (SRCTOP is ${SB}/src)
+# _CURDIR is the absolute version of ${.CURDIR}
+# _OBJDIR is the absolute version of ${.OBJDIR}
+# _objroot is realpath of ${_OBJTOP} without ${MACHINE}
+# this may be different from _OBJROOT if $SB/obj is a
+# symlink to another filesystem.
+# _objroot must be a prefix match for _objtop
+
+.MAIN: all
+
+# keep this simple
+.MAKE.MODE = compat
+
+all:
+
+_CURDIR ?= ${.CURDIR}
+_OBJDIR ?= ${.OBJDIR}
+_OBJTOP ?= ${OBJTOP}
+_OBJROOT ?= ${OBJROOT:U${_OBJTOP}}
+_objroot ?= ${_OBJROOT:tA}
+
+_this = ${.PARSEDIR}/${.PARSEFILE}
+
+# remember what to make
+_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T}
+
+# We do _not_ want to read our own output!
+.MAKE.DEPENDFILE = /dev/null
+
+# caller should have set this
+META_FILES ?= ${.MAKE.META.FILES}
+
+.if !empty(META_FILES)
+
+.if ${.MAKE.LEVEL} > 0 && !empty(GENDIRDEPS_FILTER)
+# so we can compare below
+.-include <${_DEPENDFILE}>
+# yes, I mean :U with no value
+_DIRDEPS := ${DIRDEPS:U:O:u}
+.endif
+
+META_FILES := ${META_FILES:T:O:u}
+.export META_FILES
+
+# pickup customizations
+.-include "local.gendirdeps.mk"
+
+# these are actually prefixes that we'll skip
+# they should all be absolute paths
+SKIP_GENDIRDEPS ?=
+.if !empty(SKIP_GENDIRDEPS)
+_skip_gendirdeps = egrep -v '^(${SKIP_GENDIRDEPS:O:u:ts|})' |
+.else
+_skip_gendirdeps =
+.endif
+
+# this (*should* be set in meta.sys.mk)
+# is the script that extracts what we want.
+META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
+META2DEPS := ${META2DEPS}
+
+.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" && ${DEBUG_GENDIRDEPS:Uno:Mmeta2d*} != ""
+_time = time
+_sh_x = sh -x
+_py_d = -ddd
+.else
+_time =
+_sh_x =
+_py_d =
+.endif
+
+.if ${META2DEPS:E} == "py"
+# we can afford to do this all the time.
+DPDEPS ?= no
+META2DEPS_CMD = ${_time} ${PYTHON} ${META2DEPS} ${_py_d} \
+ -R ${RELDIR} -H ${HOST_TARGET} -O ${M2D_OBJROOT}
+.if ${DPDEPS:tl} != "no"
+META2DEPS_CMD += -D ${DPDEPS}
+.endif
+.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == ""
+# meta2deps.py only groks objroot
+# so we need to give it what it expects
+M2D_OBJROOT = ${OBJTOP}/
+# and tell it not to add machine qualifiers
+META2DEPS_ARGS += MACHINE=none
+.else
+.if defined(SB_OBJROOT)
+M2D_OBJROOT ?= ${SB_OBJROOT}
+.else
+M2D_OBJROOT = ${OBJTOP}/
+.endif
+.endif
+.if defined(SB_BACKING_SB)
+META2DEPS_CMD += -S ${SB_BACKING_SB}/src -O ${SB_BACKING_SB}/${SB_OBJPREFIX}
+.endif
+META2DEPS_FILTER = sed 's,^src:,${SRCTOP}/,;s,^\([^/]\),${OBJTOP}/\1,' |
+.elif ${META2DEPS:E} == "sh"
+META2DEPS_CMD = ${_time} ${_sh_x} ${META2DEPS} \
+ OBJTOP=${_objtop} SB_OBJROOT=${_objroot}
+.else
+META2DEPS_CMD ?= ${META2DEPS}
+.endif
+
+# we are only interested in the dirs
+# sepecifically those we read something from.
+# we canonicalize them to keep things simple
+# if we are using a split-fs sandbox, it gets a little messier.
+_objtop := ${_OBJTOP:tA}
+dir_list != cd ${_OBJDIR} && \
+ ${META2DEPS_CMD} MACHINE=${MACHINE} \
+ SRCTOP=${SRCTOP} RELDIR=${RELDIR} CURDIR=${_CURDIR} \
+ ${META2DEPS_ARGS} \
+ ${META_FILES:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
+ sed 's,//*$$,,;s,\.${HOST_TARGET}$$,.host,'
+
+.if ${dir_list:M*ERROR\:*} != ""
+.warning ${dir_list:tW:C,.*(ERROR),\1,}
+.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,}
+# we are not going to update anything
+.else
+
+.if !empty(DPADD)
+_nonlibs := ${DPADD:T:Nlib*:N*include}
+.if !empty(_nonlibs)
+dir_list += ${_nonlibs:@x@${DPADD:M*/$x}@:H:tA}
+.endif
+.endif
+
+# DIRDEPS represent things that had to have been built first
+# so they should all be undir OBJTOP.
+# Note that ${_OBJTOP}/bsd/include/machine will get reported
+# to us as $SRCTOP/bsd/sys/$MACHINE_ARCH/include meaning we
+# will want to visit bsd/include
+# so we add
+# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:}
+# to GENDIRDEPS_DIR_LIST_XTRAS
+dirdep_list = \
+ ${dir_list:M${_objtop}*/*:C,${_objtop}[^/]*/,,} \
+ ${GENDIRDEPS_DIR_LIST_XTRAS}
+
+# anything we use from an object dir other than ours
+# needs to be qualified with its .<machine> suffix
+# (we used the pseudo machine "host" for the HOST_TARGET).
+qualdir_list = \
+ ${dir_list:M${_objroot}*/*/*:N${SRCTOP}*:N${_objtop}*:C,${_objroot}([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
+
+.if ${_OBJROOT} != ${_objroot}
+dirdep_list += \
+ ${dir_list:M${_OBJTOP}*/*:C,${_OBJTOP}[^/]*/,,}
+
+qualdir_list += \
+ ${dir_list:M${_OBJROOT}*/*/*:N${SRCTOP}*:N${_OBJTOP}*:C,${_OBJROOT}([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
+.endif
+
+dirdep_list := ${dirdep_list:O:u}
+qualdir_list := ${qualdir_list:O:u}
+
+DIRDEPS = \
+ ${dirdep_list:N${RELDIR}:N${RELDIR}/*} \
+ ${qualdir_list:N${RELDIR}.*:N${RELDIR}/*}
+
+# We only consider things below $RELDIR/ if they have a makefile.
+# This is the same test that _DIRDEPS_USE applies.
+# We have do a double test with dirdep_list as it _may_ contain
+# qualified dirs - if we got anything from a stage dir.
+# qualdir_list we know are all qualified.
+# It would be nice do peform this check for all of DIRDEPS,
+# but we cannot assume that all of the tree is present,
+# in fact we can only assume that RELDIR is.
+DIRDEPS += \
+ ${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/$d/$m):?$d:${exists(${SRCTOP}/${d:R}/$m):?$d:}}@}@} \
+ ${qualdir_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/${d:R}/$m):?$d:}@}@}
+
+DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:ts:}:O:u}
+
+.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
+.info ${RELDIR}: dir_list='${dir_list}'
+.info ${RELDIR}: dirdep_list='${dirdep_list}'
+.info ${RELDIR}: qualdir_list='${qualdir_list}'
+.info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}'
+.info ${RELDIR}: GENDIRDEPS_FILTER='${GENDIRDEPS_FILTER}'
+.info ${RELDIR}: FORCE_DPADD='${DPADD}'
+.info ${RELDIR}: DIRDEPS='${DIRDEPS}'
+.endif
+
+# SRC_DIRDEPS is for checkout logic
+src_dirdep_list = \
+ ${dir_list:M${SRCTOP}/*:S,${SRCTOP}/,,}
+
+SRC_DIRDEPS = \
+ ${src_dirdep_list:N${RELDIR}:N${RELDIR}/*:C,(/h)/.*,,}
+
+SRC_DIRDEPS := ${SRC_DIRDEPS:${GENDIRDEPS_SRC_FILTER:UN/*:ts:}:O:u}
+
+# if you want to capture SRC_DIRDEPS in .MAKE.DEPENDFILE put
+# SRC_DIRDEPS_FILE = ${_DEPENDFILE}
+# in local.gendirdeps.mk
+.if ${SRC_DIRDEPS_FILE:Uno:tl} != "no"
+ECHO_SRC_DIRDEPS = echo 'SRC_DIRDEPS = \'; echo '${SRC_DIRDEPS:@d@ $d \\${.newline}@}'; echo;
+
+.if ${SRC_DIRDEPS_FILE:T} == ${_DEPENDFILE:T}
+_include_src_dirdeps = ${ECHO_SRC_DIRDEPS}
+.else
+all: ${SRC_DIRDEPS_FILE}
+.if !target(${SRC_DIRDEPS_FILE})
+${SRC_DIRDEPS_FILE}: ${META_FILES} ${_this} ${META2DEPS}
+ @(${ECHO_SRC_DIRDEPS}) > $@
+.endif
+.endif
+.endif
+_include_src_dirdeps ?=
+
+all: ${_DEPENDFILE}
+
+# if this is going to exist it would be there by now
+.if !exists(.depend)
+CAT_DEPEND = /dev/null
+.endif
+CAT_DEPEND ?= .depend
+
+.if !empty(_DIRDEPS) && ${DIRDEPS} != ${_DIRDEPS}
+# we may have changed a filter
+.PHONY: ${_DEPENDFILE}
+.endif
+
+# 'cat .depend' should suffice, but if we are mixing build modes
+# .depend may contain things we don't want.
+# The sed command at the end of the stream, allows for the filters
+# to output _{VAR} tokens which we will turn into proper ${VAR} references.
+${_DEPENDFILE}: ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS}
+ @(echo '# Autogenerated - do NOT edit!'; echo; \
+ echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
+ echo 'DEP_MACHINE := $${.PARSEFILE:E}'; echo; \
+ echo 'DIRDEPS = \'; \
+ echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
+ ${_include_src_dirdeps} \
+ echo '.include <dirdeps.mk>'; \
+ echo; \
+ echo '.if $${DEP_RELDIR} == $${_DEP_RELDIR}'; \
+ echo '# local dependencies - needed for -jN in clean tree'; \
+ [ -s ${CAT_DEPEND} ] && { grep : ${CAT_DEPEND} | grep -v '[/\\]'; }; \
+ echo '.endif' ) | sed 's,_\([{(]\),$$\1,g' > $@.new${.MAKE.PID}
+ @${InstallNew}; InstallNew -s $@.new${.MAKE.PID}
+
+.endif # meta2deps failed
+.elif !empty(SUBDIR)
+
+DIRDEPS := ${SUBDIR:S,^,${RELDIR}/,:O:u}
+
+all: ${_DEPENDFILE}
+
+${_DEPENDFILE}: ${MAKEFILE} ${_this}
+ @(echo '# Autogenerated - do NOT edit!'; echo; \
+ echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
+ echo 'DEP_MACHINE := $${.PARSEFILE:E}'; echo; \
+ echo 'DIRDEPS = \'; \
+ echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
+ echo '.include <dirdeps.mk>'; \
+ echo ) | sed 's,_\([{(]\),$$\1,g' > $@.new
+ @${InstallNew}; InstallNew $@.new
+
+.else
+
+# nothing to do
+all ${_DEPENDFILE}:
+
+.endif
+${_DEPENDFILE}: .PRECIOUS
diff --git a/contrib/bmake/mk/host-target.mk b/contrib/bmake/mk/host-target.mk
new file mode 100644
index 0000000..c6d4562
--- /dev/null
+++ b/contrib/bmake/mk/host-target.mk
@@ -0,0 +1,31 @@
+# RCSid:
+# $Id: host-target.mk,v 1.6 2011/03/02 05:05:21 sjg Exp $
+
+# Host platform information; may be overridden
+.if !defined(_HOST_OSNAME)
+_HOST_OSNAME != uname -s
+.export _HOST_OSNAME
+.endif
+.if !defined(_HOST_OSREL)
+_HOST_OSREL != uname -r
+.export _HOST_OSREL
+.endif
+.if !defined(_HOST_ARCH)
+_HOST_ARCH != uname -p 2>/dev/null || uname -m
+# uname -p may produce garbage on linux
+.if ${_HOST_ARCH:[\#]} > 1
+_HOST_ARCH != uname -m
+.endif
+.export _HOST_ARCH
+.endif
+
+HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//}
+HOST_OSTYPE := ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
+HOST_OS := ${_HOST_OSNAME}
+host_os := ${_HOST_OSNAME:tl}
+HOST_TARGET := ${host_os}${HOST_OSMAJOR}-${_HOST_ARCH}
+
+# tr is insanely non-portable, accommodate the lowest common denominator
+TR ?= tr
+toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
+toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
diff --git a/contrib/bmake/mk/host.libnames.mk b/contrib/bmake/mk/host.libnames.mk
new file mode 100644
index 0000000..c0a13d7
--- /dev/null
+++ b/contrib/bmake/mk/host.libnames.mk
@@ -0,0 +1,29 @@
+# $Id: host.libnames.mk,v 1.4 2010/01/11 23:01:31 sjg Exp $
+#
+# @(#) Copyright (c) 2007-2009, 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
+#
+
+
+DLIBEXT ?= .a
+DSHLIBEXT ?= ${DLIBEXT}
+HOST_LIBEXT ?= ${DSHLIBEXT}
+HOST_LIBDIRS ?= /usr/lib /lib
+HOST_LIBS ?=
+
+.for x in ${HOST_LIBS:O:u}
+.for d in ${HOST_LIBDIRS}
+.if exists($d/lib$x${HOST_LIBEXT})
+LIB${x:tu} ?= $d/lib$x${HOST_LIBEXT}
+.endif
+.endfor
+.endfor
diff --git a/contrib/bmake/mk/inc.mk b/contrib/bmake/mk/inc.mk
new file mode 100644
index 0000000..5d57f52
--- /dev/null
+++ b/contrib/bmake/mk/inc.mk
@@ -0,0 +1,35 @@
+# $Id: inc.mk,v 1.3 2011/03/11 05:23:05 sjg Exp $
+#
+# @(#) Copyright (c) 2008, 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
+#
+
+.include <init.mk>
+
+includes: ${INCS}
+
+.if !empty(LIBOWN)
+INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
+.endif
+INCMODE ?= 444
+INC_COPY ?= -C
+INCSDIR ?= ${INCDIR}
+
+realinstall: incinstall
+.if !target(incinstall)
+incinstall:
+.if !empty(INCS)
+ [ -d ${DESTDIR}${INCSDIR} ] || \
+ ${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}${INCSDIR}
+ ${INSTALL} ${INC_COPY} ${INC_INSTALL_OWN} -m ${INCMODE} ${INCS} ${DESTDIR}${INCSDIR}
+.endif
+.endif
diff --git a/contrib/bmake/mk/init.mk b/contrib/bmake/mk/init.mk
new file mode 100644
index 0000000..ed63fe6
--- /dev/null
+++ b/contrib/bmake/mk/init.mk
@@ -0,0 +1,44 @@
+# $Id: init.mk,v 1.8 2012/11/11 22:37:02 sjg Exp $
+#
+# @(#) Copyright (c) 2002, 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 !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+.if ${MAKE_VERSION:U0} > 20100408
+_this_mk_dir := ${.PARSEDIR:tA}
+.else
+_this_mk_dir := ${.PARSEDIR}
+.endif
+
+.-include <local.init.mk>
+.-include "${.CURDIR:H}/Makefile.inc"
+.include <own.mk>
+
+.MAIN: all
+
+.if !empty(WARNINGS_SET) || !empty(WARNINGS_SET_${MACHINE_ARCH})
+.include <warnings.mk>
+.endif
+
+COPTS += ${COPTS.${.IMPSRC:T}}
+CPPFLAGS += ${CPPFLAGS.${.IMPSRC:T}}
+CPUFLAGS += ${CPUFLAGS.${.IMPSRC:T}}
+
+.if ${.MAKE.LEVEL:U1} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
+# this tells lib.mk and prog.mk to not actually build anything
+_SKIP_BUILD = not building at level 0
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk
new file mode 100644
index 0000000..7dea1fc
--- /dev/null
+++ b/contrib/bmake/mk/install-mk
@@ -0,0 +1,185 @@
+:
+# NAME:
+# install-mk - install mk files
+#
+# SYNOPSIS:
+# install-mk [options] [var=val] [dest]
+#
+# DESCRIPTION:
+# This tool installs mk files in a semi-intelligent manner into
+# "dest".
+#
+# Options:
+#
+# -n just say what we want to do, but don't touch anything.
+#
+# -f use -f when copying sys,mk.
+#
+# -v be verbose
+#
+# -q be quiet
+#
+# -m "mode"
+# Use "mode" for installed files (444).
+#
+# -o "owner"
+# Use "owner" for installed files.
+#
+# -g "group"
+# Use "group" for installed files.
+#
+# var=val
+# Set "var" to "val". See below.
+#
+# All our *.mk files are copied to "dest" with appropriate
+# ownership and permissions.
+#
+# By default if a sys.mk can be found in a standard location
+# (that bmake will find) then no sys.mk will be put in "dest".
+#
+# SKIP_SYS_MK:
+# If set, we will avoid installing our 'sys.mk'
+# This is probably a bad idea.
+#
+# SKIP_BSD_MK:
+# If set, we will skip making bsd.*.mk links to *.mk
+#
+# sys.mk:
+#
+# By default (and provided we are not installing to the system
+# mk dir - '/usr/share/mk') we install our own 'sys.mk' which
+# includes a sys specific file, or a generic one.
+#
+#
+# AUTHOR:
+# Simon J. Gerraty <sjg@crufty.net>
+
+# RCSid:
+# $Id: install-mk,v 1.83 2013/01/24 01:02:23 sjg Exp $
+#
+# @(#) Copyright (c) 1994 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
+#
+
+MK_VERSION=20130123
+OWNER=
+GROUP=
+MODE=444
+BINMODE=555
+ECHO=:
+SKIP=
+cp_f=-f
+
+while :
+do
+ case "$1" in
+ *=*) eval "$1"; shift;;
+ +f) cp_f=; shift;;
+ -f) cp_f=-f; shift;;
+ -m) MODE=$2; shift 2;;
+ -o) OWNER=$2; shift 2;;
+ -g) GROUP=$2; shift 2;;
+ -v) ECHO=echo; shift;;
+ -q) ECHO=:; shift;;
+ -n) ECHO=echo SKIP=:; shift;;
+ --) shift; break;;
+ *) break;;
+ esac
+done
+
+case $# in
+0) echo "$0 [options] <destination> [<os>]"
+ echo "eg."
+ echo "$0 -o bin -g bin -m 444 /usr/local/share/mk"
+ exit 1
+ ;;
+esac
+dest=$1
+os=${2:-`uname`}
+osrel=${3:-`uname -r`}
+
+Do() {
+ $ECHO "$@"
+ $SKIP "$@"
+}
+
+Error() {
+ echo "ERROR: $@" >&2
+ exit 1
+}
+
+Warning() {
+ echo "WARNING: $@" >&2
+}
+
+[ "$FORCE_SYS_MK" ] && Warning "ignoring: FORCE_{BSD,SYS}_MK (no longer supported)"
+
+SYS_MK_DIR=${SYS_MK_DIR:-/usr/share/mk}
+SYS_MK=${SYS_MK:-$SYS_MK_DIR/sys.mk}
+
+realpath() {
+ [ -d $1 ] && cd $1 && 'pwd' && return
+ echo $1
+}
+
+if [ -s $SYS_MK -a -d $dest ]; then
+ # if this is a BSD system we don't want to touch $SYS_MK
+ dest=`realpath $dest`
+ sys_mk_dir=`realpath $SYS_MK_DIR`
+ if [ $dest = $sys_mk_dir ]; then
+ case "$os" in
+ *BSD*) SKIP_SYS_MK=:
+ SKIP_BSD_MK=:
+ ;;
+ *) # could be fake?
+ if [ ! -d $dest/sys -a ! -s $dest/Generic.sys.mk ]; then
+ SKIP_SYS_MK=: # play safe
+ SKIP_BSD_MK=:
+ fi
+ ;;
+ esac
+ fi
+fi
+
+[ -d $dest/sys ] || Do mkdir -p $dest/sys
+[ -d $dest/sys ] || Do mkdir $dest/sys || exit 1
+[ -z "$SKIP" ] && dest=`realpath $dest`
+
+cd `dirname $0`
+mksrc=`'pwd'`
+if [ $mksrc = $dest ]; then
+ SKIP_MKFILES=:
+else
+ # we do not install the examples
+ mk_files=`grep '^[a-z].*\.mk' FILES | egrep -v '(examples/|^sys\.mk|sys/)'`
+ mk_scripts=`egrep '^[a-z].*\.(sh|py)' FILES | egrep -v '/'`
+ sys_mk_files=`grep 'sys/.*\.mk' FILES`
+ SKIP_MKFILES=
+ [ -z "$SKIP_SYS_MK" ] && mk_files="sys.mk $mk_files"
+fi
+$SKIP_MKFILES Do cp $cp_f $mk_files $dest
+$SKIP_MKFILES Do cp $cp_f $sys_mk_files $dest/sys
+$SKIP_MKFILES Do cp $cp_f $mk_scripts $dest
+$SKIP cd $dest
+$SKIP_MKFILES Do chmod $MODE $mk_files $sys_mk_files
+$SKIP_MKFILES Do chmod $BINMODE $mk_scripts
+[ "$GROUP" ] && $SKIP_MKFILES Do chgrp $GROUP $mk_files $sys_mk_files
+[ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files
+# if this is a BSD system the bsd.*.mk should exist and be used.
+if [ -z "$SKIP_BSD_MK" ]; then
+ for f in dep doc init lib links man nls obj own prog subdir
+ do
+ b=bsd.$f.mk
+ [ -s $b ] || Do ln -s $f.mk $b
+ done
+fi
+exit 0
diff --git a/contrib/bmake/mk/install-new.mk b/contrib/bmake/mk/install-new.mk
new file mode 100644
index 0000000..ddfff20
--- /dev/null
+++ b/contrib/bmake/mk/install-new.mk
@@ -0,0 +1,53 @@
+# $Id: install-new.mk,v 1.3 2012/03/24 18:25:49 sjg Exp $
+#
+# @(#) Copyright (c) 2009, 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 !defined(InstallNew)
+
+# copy if src and target are different making a backup if desired
+CmpCp= CmpCp() { \
+ src=$$1 target=$$2 _bak=$$3; \
+ if ! test -s $$target || ! cmp -s $$target $$src; then \
+ trap "" 1 2 3 15; \
+ if test -s $$target; then \
+ if test "x$$_bak" != x; then \
+ rm -f $$target$$_bak; \
+ mv $$target $$target$$_bak; \
+ else \
+ rm -f $$target; \
+ fi; \
+ fi; \
+ cp $$src $$target; \
+ fi; }
+
+# If the .new file is different, we want it.
+# Note: this function will work as is for *.new$RANDOM"
+InstallNew= ${CmpCp}; InstallNew() { \
+ _t=-e; _bak=; \
+ while :; do \
+ case "$$1" in \
+ -?) _t=$$1; shift;; \
+ --bak) _bak=$$2; shift 2;; \
+ *) break;; \
+ esac; \
+ done; \
+ for new in "$$@"; do \
+ if test $$_t $$new; then \
+ target=`expr $$new : '\(.*\).new'`; \
+ CmpCp $$new $$target $$_bak; \
+ fi; \
+ rm -f $$new; \
+ done; :; }
+
+.endif
diff --git a/contrib/bmake/mk/java.mk b/contrib/bmake/mk/java.mk
new file mode 100644
index 0000000..ef4a5ea
--- /dev/null
+++ b/contrib/bmake/mk/java.mk
@@ -0,0 +1,97 @@
+#
+# RCSid:
+# $Id: java.mk,v 1.14 2007/11/22 08:16:25 sjg Exp $
+
+# @(#) Copyright (c) 1998-2001, 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 !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+.include <init.mk>
+
+CLASSPATH?=.
+
+.if defined(PROG)
+SRCS?= ${PROG:.class=.java}
+.endif
+.if !defined(SRCS) || empty(SRCS)
+SRCS!=cd ${.CURDIR} && echo *.java
+.endif
+.SUFFIXES: .class .java
+
+CLEANFILES+= *.class
+
+JAVAC?= javac
+JAVADOC?= javadoc
+
+.if !target(docs)
+docs:
+ ${JAVADOC} ${JAVADOC_FLAGS} ${SRCS}
+.endif
+
+.if defined(JAVADESTDIR) && !empty(JAVADESTDIR)
+JAVASRCDIR?=${JAVADESTDIR:H}/src
+__classdest:=${JAVADESTDIR}${.CURDIR:S,${JAVASRCDIR},,}/
+CLASSPATH:=${CLASSPATH}:${JAVADESTDIR}
+JAVAC_FLAGS+= -d ${JAVADESTDIR}
+.else
+__classdest=
+.endif
+
+JAVAC_FLAGS+= ${JAVAC_DBG}
+
+.if defined(MAKE_VERSION) && !defined(NO_CLASSES_COOKIE)
+# java works best by compiling a bunch of classes at once.
+# this lot does that but needs a recent netbsd make or
+# or its portable cousin bmake.
+.for __s in ${SRCS}
+__c:= ${__classdest}${__s:.java=.class}
+.if !target(${__c})
+# We need to do something to force __c's parent to be made.
+${__c}: ${__s}
+ @rm -f ${.TARGET}
+.endif
+SRCS_${__c}=${__s}
+__classes:= ${__classes} ${__c}
+.endfor
+__classes_cookie=${__classdest}.classes.done
+CLEANFILES+= ${__classes} ${__classes_cookie}
+
+${__classes_cookie}: ${__classes}
+ CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE:@c@${SRCS_$c}@}
+ @touch ${.TARGET}
+
+all: ${__classes_cookie}
+
+.else
+# this will work with other BSD make's
+.for __s in ${SRCS}
+__c:= ${__classdest}${__s:.java=.class}
+${__c}: ${__s}
+ CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE}
+.endfor
+
+all: ${SRCS:%.java=${__classdest}%.class}
+
+.endif
+
+.if !target(cleanjava)
+cleanjava:
+ rm -f [Ee]rrs mklog core *.core ${PROG} ${CLEANFILES}
+
+clean: cleanjava
+cleandir: cleanjava
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/lib.mk b/contrib/bmake/mk/lib.mk
new file mode 100644
index 0000000..24f9527
--- /dev/null
+++ b/contrib/bmake/mk/lib.mk
@@ -0,0 +1,605 @@
+# $Id: lib.mk,v 1.48 2012/11/12 04:08:18 sjg Exp $
+
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+.include <init.mk>
+
+.if ${OBJECT_FMT} == "ELF"
+NEED_SOLINKS?= yes
+.endif
+
+.if exists(${.CURDIR}/shlib_version)
+SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
+SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
+.endif
+
+print-shlib-major:
+.if defined(SHLIB_MAJOR) && ${MK_PIC} != "no"
+ @echo ${SHLIB_MAJOR}
+.else
+ @false
+.endif
+
+print-shlib-minor:
+.if defined(SHLIB_MINOR) && ${MK_PIC} != "no"
+ @echo ${SHLIB_MINOR}
+.else
+ @false
+.endif
+
+print-shlib-teeny:
+.if defined(SHLIB_TEENY) && ${MK_PIC} != "no"
+ @echo ${SHLIB_TEENY}
+.else
+ @false
+.endif
+
+SHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.}
+SHLIB_FULLVERSION := ${SHLIB_FULLVERSION}
+
+# add additional suffixes not exported.
+# .po is used for profiling object files.
+# .so is used for PIC object files.
+.SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
+.SUFFIXES: .sh .m4 .m
+
+CFLAGS+= ${COPTS}
+
+# Derrived from NetBSD-1.6
+
+# Set PICFLAGS to cc flags for producing position-independent code,
+# if not already set. Includes -DPIC, if required.
+
+# Data-driven table using make variables to control how shared libraries
+# are built for different platforms and object formats.
+# OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
+# SHLIB_SOVERSION: version number to be compiled into a shared library
+# via -soname. Usualy ${SHLIB_MAJOR} on ELF.
+# NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
+# [.${SHLIB_TEENY}]]
+# SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
+# with ELF, also set shared-lib version for ld.so.
+# SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
+# SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
+# FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
+# CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
+# CPICFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
+# CAPICFLAGS flags for {$CC} to compiling .[Ss] files
+# (usually just ${CPPPICFLAGS} ${CPICFLAGS})
+# APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
+
+.if ${TARGET_OSNAME} == "NetBSD"
+.if ${MACHINE_ARCH} == "alpha"
+ # Alpha-specific shared library flags
+FPICFLAGS ?= -fPIC
+CPICFLAGS ?= -fPIC -DPIC
+CPPPICFLAGS?= -DPIC
+CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
+APICFLAGS ?=
+.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
+ # mips-specific shared library flags
+
+# On mips, all libs are compiled with ABIcalls, not just sharedlibs.
+MKPICLIB= no
+
+# so turn shlib PIC flags on for ${AS}.
+AINC+=-DABICALLS
+AFLAGS+= -fPIC
+AS+= -KPIC
+
+.elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF"
+# On the VAX, all object are PIC by default, not just sharedlibs.
+MKPICLIB= no
+
+.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
+ ${OBJECT_FMT} == "ELF"
+# If you use -fPIC you need to define BIGPIC to turn on 32-bit
+# relocations in asm code
+FPICFLAGS ?= -fPIC
+CPICFLAGS ?= -fPIC -DPIC
+CPPPICFLAGS?= -DPIC -DBIGPIC
+CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
+APICFLAGS ?= -KPIC
+
+.else
+
+# Platform-independent flags for NetBSD a.out shared libraries
+SHLIB_SOVERSION=${SHLIB_FULLVERSION}
+SHLIB_SHFLAGS=
+FPICFLAGS ?= -fPIC
+CPICFLAGS?= -fPIC -DPIC
+CPPPICFLAGS?= -DPIC
+CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
+APICFLAGS?= -k
+
+.endif
+
+# Platform-independent linker flags for ELF shared libraries
+.if ${OBJECT_FMT} == "ELF"
+SHLIB_SOVERSION= ${SHLIB_MAJOR}
+SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION}
+SHLIB_LDSTARTFILE?= /usr/lib/crtbeginS.o
+SHLIB_LDENDFILE?= /usr/lib/crtendS.o
+.endif
+
+# for compatability with the following
+CC_PIC?= ${CPICFLAGS}
+LD_shared=${SHLIB_SHFLAGS}
+
+.endif # NetBSD
+
+.if ${TARGET_OSNAME} == "FreeBSD"
+.if ${OBJECT_FMT} == "ELF"
+SHLIB_SOVERSION= ${SHLIB_MAJOR}
+SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION}
+.else
+SHLIB_SHFLAGS= -assert pure-text
+.endif
+SHLIB_LDSTARTFILE=
+SHLIB_LDENDFILE=
+CC_PIC?= -fpic
+LD_shared=${SHLIB_SHFLAGS}
+
+.endif # FreeBSD
+
+MKPICLIB?= yes
+
+# sys.mk can override these
+CC_PG?=-pg
+CC_PIC?=-DPIC
+
+LD_X?=-X
+LD_x?=-x
+LD_r?=-r
+
+# Non BSD machines will be using bmake.
+.if ${TARGET_OSNAME} == "SunOS"
+LD_shared=-assert pure-text
+.if ${OBJECT_FMT} == "ELF" || ${MACHINE} == "solaris"
+# Solaris
+LD_shared=-h lib${LIB}.so.${SHLIB_MAJOR} -G
+.endif
+.elif ${TARGET_OSNAME} == "HP-UX"
+LD_shared=-b
+LD_so=sl
+DLLIB=
+# HPsUX lorder does not grok anything but .o
+LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
+LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
+.elif ${TARGET_OSNAME} == "OSF1"
+LD_shared= -msym -shared -expect_unresolved '*'
+LD_solib= -all lib${LIB}_pic.a
+DLLIB=
+# lorder does not grok anything but .o
+LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
+LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
+AR_cq= -cqs
+.elif ${TARGET_OSNAME} == "FreeBSD"
+LD_solib= lib${LIB}_pic.a
+.elif ${TARGET_OSNAME} == "Linux"
+# this is ambiguous of course
+LD_shared=-shared -h lib${LIB}.so.${SHLIB_MAJOR}
+LD_solib= --whole-archive lib${LIB}_pic.a
+# Linux uses GNU ld, which is a multi-pass linker
+# so we don't need to use lorder or tsort
+LD_objs = ${OBJS}
+LD_pobjs = ${POBJS}
+LD_sobjs = ${SOBJS}
+.elif ${TARGET_OSNAME} == "Darwin"
+SHLIB_LD = ${CC}
+SHLIB_INSTALL_VERSION ?= ${SHLIB_MAJOR}
+SHLIB_COMPATABILITY_VERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR:U0}
+SHLIB_COMPATABILITY ?= \
+ -compatibility_version ${SHLIB_COMPATABILITY_VERSION} \
+ -current_version ${SHLIB_FULLVERSION}
+LD_shared = -dynamiclib \
+ -flat_namespace -undefined suppress \
+ -install_name ${LIBDIR}/lib${LIB}.${SHLIB_INSTALL_VERSION}.${LD_solink} \
+ ${SHLIB_COMPATABILITY}
+SHLIB_LINKS =
+.for v in ${SHLIB_COMPATABILITY_VERSION} ${SHLIB_INSTALL_VERSION}
+.if "$v" != "${SHLIB_FULLVERSION}"
+SHLIB_LINKS += lib${LIB}.$v.${LD_solink}
+.endif
+.endfor
+.if ${MK_LINKLIB} != "no"
+SHLIB_LINKS += lib${LIB}.${LD_solink}
+.endif
+
+LD_so = ${SHLIB_FULLVERSION}.dylib
+LD_sobjs = ${SOBJS:O:u}
+LD_solib = ${LD_sobjs}
+SOLIB = ${LD_sobjs}
+LD_solink = dylib
+.if ${MACHINE_ARCH} == "i386"
+PICFLAG ?= -fPIC
+.else
+PICFLAG ?= -fPIC -fno-common
+.endif
+RANLIB = :
+.endif
+
+SHLIB_LD ?= ${LD}
+
+.if !empty(SHLIB_MAJOR)
+.if ${NEED_SOLINKS} && empty(SHLIB_LINKS)
+.if ${MK_LINKLIB} != "no"
+SHLIB_LINKS = lib${LIB}.${LD_solink}
+.endif
+.if "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
+SHLIB_LINKS += lib${LIB}.${LD_solink}.${SHLIB_MAJOR}
+.endif
+.endif
+.endif
+
+LIBTOOL?=libtool
+LD_shared ?= -Bshareable -Bforcearchive
+LD_so ?= so.${SHLIB_FULLVERSION}
+LD_solink ?= so
+.if empty(LORDER)
+LD_objs ?= ${OBJS}
+LD_pobjs ?= ${POBJS}
+LD_sobjs ?= ${SOBJS}
+.else
+LD_objs ?= `${LORDER} ${OBJS} | ${TSORT}`
+LD_sobjs ?= `${LORDER} ${SOBJS} | ${TSORT}`
+LD_pobjs ?= `${LORDER} ${POBJS} | ${TSORT}`
+.endif
+LD_solib ?= ${LD_sobjs}
+AR_cq ?= cq
+.if exists(/netbsd) && exists(${DESTDIR}/usr/lib/libdl.so)
+DLLIB ?= -ldl
+.endif
+
+# some libs have lots of objects, and scanning all .o, .po and .So meta files
+# is a waste of time, this tells meta.autodep.mk to just pick one
+# (typically .So)
+# yes, 42 is a random number.
+.if ${MK_META_MODE} == "yes" && ${SRCS:Uno:[\#]} > 42
+OPTIMIZE_OBJECT_META_FILES ?= yes
+.endif
+
+
+.if ${MK_LIBTOOL} == "yes"
+# because libtool is so facist about naming the object files,
+# we cannot (yet) build profiled libs
+MK_PROFILE=no
+_LIBS=lib${LIB}.a
+.if exists(${.CURDIR}/shlib_version)
+SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
+.endif
+.else
+# for the normal .a we do not want to strip symbols
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+
+# for the normal .a we do not want to strip symbols
+.cc.o .C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+
+.S.o .s.o:
+ @echo ${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
+ @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
+
+.if (${LD_X} == "")
+.c.po:
+ ${COMPILE.c} ${CC_PG} ${.IMPSRC} -o ${.TARGET}
+
+.cc.po .C.po:
+ ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
+
+.S.so .s.so:
+ ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
+.else
+.c.po:
+ @echo ${COMPILE.c} ${CC_PG} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.c} ${CC_PG} ${.IMPSRC} -o ${.TARGET}.o
+ @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+ @rm -f ${.TARGET}.o
+
+.cc.po .C.po:
+ @echo ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
+ @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+ @rm -f ${.TARGET}.o
+
+.S.so .s.so:
+ @echo ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
+ @${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+ @rm -f ${.TARGET}.o
+.endif
+
+.if (${LD_x} == "")
+.c.so:
+ ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
+
+.cc.so .C.so:
+ ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
+
+.S.po .s.po:
+ ${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
+.else
+
+.c.so:
+ @echo ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
+ @${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+ @rm -f ${.TARGET}.o
+
+.cc.so .C.so:
+ @echo ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
+ @${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+ @rm -f ${.TARGET}.o
+
+.S.po .s.po:
+ @echo ${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
+ @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+ @rm -f ${.TARGET}.o
+
+.endif
+.endif
+
+.c.ln:
+ ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
+
+.if ${MK_LIBTOOL} != "yes"
+
+.if !defined(PICFLAG)
+PICFLAG=-fpic
+.endif
+
+_LIBS=
+
+.if ${MK_ARCHIVE} != "no"
+_LIBS += lib${LIB}.a
+.endif
+
+.if ${MK_PROFILE} != "no"
+_LIBS+=lib${LIB}_p.a
+POBJS+=${OBJS:.o=.po}
+.endif
+
+.if ${MK_PIC} != "no"
+.if ${MK_PICLIB} == "no"
+SOLIB ?= lib${LIB}.a
+.else
+SOLIB=lib${LIB}_pic.a
+_LIBS+=${SOLIB}
+.endif
+.if !empty(SHLIB_FULLVERSION)
+_LIBS+=lib${LIB}.${LD_so}
+.endif
+.endif
+
+.if ${MK_LINT} != "no"
+_LIBS+=llib-l${LIB}.ln
+.endif
+
+# here is where you can define what LIB* are
+.-include <libnames.mk>
+.if ${MK_DPADD_MK} == "yes"
+# lots of cool magic, but might not suit everyone.
+.include <dpadd.mk>
+.endif
+
+.if !defined(_SKIP_BUILD)
+all: prebuild .WAIT ${_LIBS}
+# a hook for things that must be done early
+prebuild:
+.if !defined(.PARSEDIR)
+# no-op is the best we can do if not bmake.
+.WAIT:
+.endif
+.endif
+all: _SUBDIRUSE
+
+.for s in ${SRCS:N*.h:M*/*}
+${.o .so .po .lo:L:@o@${s:T:R}$o@}: $s
+.endfor
+
+OBJS+= ${SRCS:T:N*.h:R:S/$/.o/g}
+.NOPATH: ${OBJS}
+
+.if ${MK_LIBTOOL} == "yes"
+.if ${MK_PIC} == "no"
+LT_STATIC=-static
+.else
+LT_STATIC=
+.endif
+SHLIB_AGE?=0
+
+# .lo's are created as a side effect
+.s.o .S.o .c.o:
+ ${LIBTOOL} --mode=compile ${CC} ${LT_STATIC} ${CFLAGS} ${CPPFLAGS} ${IMPFLAGS} -c ${.IMPSRC}
+
+# can't really do profiled libs with libtool - its too facist about
+# naming the output...
+lib${LIB}.a:: ${OBJS}
+ @rm -f ${.TARGET}
+ ${LIBTOOL} --mode=link ${CC} ${LT_STATIC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} -rpath ${SHLIBDIR}:/usr/lib -version-info ${SHLIB_MAJOR}:${SHLIB_MINOR}:${SHLIB_AGE}
+ @ln .libs/${.TARGET} .
+
+lib${LIB}.${LD_so}:: lib${LIB}.a
+ @[ -s ${.TARGET}.${SHLIB_AGE} ] || { ln -s .libs/lib${LIB}.${LD_so}* . 2>/dev/null; : }
+ @[ -s ${.TARGET} ] || ln -s ${.TARGET}.${SHLIB_AGE} ${.TARGET}
+
+.else # MK_LIBTOOL=yes
+
+lib${LIB}.a:: ${OBJS}
+ @echo building standard ${LIB} library
+ @rm -f ${.TARGET}
+ @${AR} ${AR_cq} ${.TARGET} ${LD_objs}
+ ${RANLIB} ${.TARGET}
+
+POBJS+= ${OBJS:.o=.po}
+.NOPATH: ${POBJS}
+lib${LIB}_p.a:: ${POBJS}
+ @echo building profiled ${LIB} library
+ @rm -f ${.TARGET}
+ @${AR} ${AR_cq} ${.TARGET} ${LD_pobjs}
+ ${RANLIB} ${.TARGET}
+
+SOBJS+= ${OBJS:.o=.so}
+.NOPATH: ${SOBJS}
+lib${LIB}_pic.a:: ${SOBJS}
+ @echo building shared object ${LIB} library
+ @rm -f ${.TARGET}
+ @${AR} ${AR_cq} ${.TARGET} ${LD_sobjs}
+ ${RANLIB} ${.TARGET}
+
+#SHLIB_LDADD?= ${LDADD}
+
+# bound to be non-portable...
+# this is known to work for NetBSD 1.6 and FreeBSD 4.2
+lib${LIB}.${LD_so}: ${SOLIB} ${DPADD}
+ @echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
+ @rm -f ${.TARGET}
+.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD"
+.if ${OBJECT_FMT} == "ELF"
+ ${SHLIB_LD} -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
+ ${SHLIB_LDSTARTFILE} \
+ --whole-archive ${SOLIB} --no-whole-archive ${SHLIB_LDADD} \
+ ${SHLIB_LDENDFILE}
+.else
+ ${SHLIB_LD} ${LD_x} ${LD_shared} \
+ -o ${.TARGET} ${SOLIB} ${SHLIB_LDADD}
+.endif
+.else
+ ${SHLIB_LD} -o ${.TARGET} ${LD_shared} ${LD_solib} ${DLLIB} ${SHLIB_LDADD}
+.endif
+.endif
+.if !empty(SHLIB_LINKS)
+ rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s ${.TARGET} $x;@}
+.endif
+
+LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
+.NOPATH: ${LOBJS}
+LLIBS?= -lc
+llib-l${LIB}.ln: ${LOBJS}
+ @echo building llib-l${LIB}.ln
+ @rm -f llib-l${LIB}.ln
+ @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
+
+.if !target(clean)
+cleanlib: .PHONY
+ rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
+ rm -f lib${LIB}.a ${OBJS}
+ rm -f lib${LIB}_p.a ${POBJS}
+ rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
+ rm -f llib-l${LIB}.ln ${LOBJS}
+.if !empty(SHLIB_LINKS)
+ rm -f ${SHLIB_LINKS}
+.endif
+
+clean: _SUBDIRUSE cleanlib
+cleandir: _SUBDIRUSE cleanlib
+.else
+cleandir: _SUBDIRUSE clean
+.endif
+
+.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep)
+afterdepend: .depend
+ @(TMP=/tmp/_depend$$$$; \
+ sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
+ < .depend > $$TMP; \
+ mv $$TMP .depend)
+.endif
+
+.if !target(install)
+.if !target(beforeinstall)
+beforeinstall:
+.endif
+
+.if !empty(LIBOWN)
+LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
+.endif
+
+.include <links.mk>
+
+.if !target(realinstall)
+realinstall: libinstall
+.endif
+.if !target(libinstall)
+libinstall:
+ [ -d ${DESTDIR}/${LIBDIR} ] || \
+ ${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR}
+.if ${MK_ARCHIVE} != "no"
+ ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 lib${LIB}.a \
+ ${DESTDIR}${LIBDIR}
+ ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}.a
+ chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
+.endif
+.if ${MK_PROFILE} != "no"
+ ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \
+ lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
+ chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
+.endif
+.if ${MK_PIC} != "no"
+.if ${MK_PICLIB} != "no"
+ ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \
+ lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
+ ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
+ chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
+.endif
+.if !empty(SHLIB_MAJOR)
+ ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
+ lib${LIB}.${LD_so} ${DESTDIR}${LIBDIR}
+.if !empty(SHLIB_LINKS)
+ (cd ${DESTDIR}${LIBDIR} && { rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s lib${LIB}.${LD_so} $x;@} })
+.endif
+.endif
+.endif
+.if ${MK_LINT} != "no" && ${MK_LINKLIB} != "no" && !empty(LOBJS)
+ ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
+ llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
+.endif
+.if defined(LINKS) && !empty(LINKS)
+ @set ${LINKS}; ${_LINKS_SCRIPT}
+.endif
+.endif
+
+install: maninstall _SUBDIRUSE
+maninstall: afterinstall
+afterinstall: realinstall
+realinstall: beforeinstall
+.endif
+
+.if ${MK_MAN} != "no"
+.include <man.mk>
+.endif
+
+.if ${MK_NLS} != "no"
+.include <nls.mk>
+.endif
+
+.include <obj.mk>
+.include <inc.mk>
+.include <dep.mk>
+.include <subdir.mk>
+.endif
+
+# during building we usually need/want to install libs somewhere central
+# note that we do NOT ch{own,grp} as that would likely fail at this point.
+# otherwise it is the same as realinstall
+# Note that we don't need this when using dpadd.mk
+.libinstall: ${_LIBS}
+ test -d ${DESTDIR}${LIBDIR} || ${INSTALL} -d -m775 ${DESTDIR}${LIBDIR}
+.for _lib in ${_LIBS:M*.a}
+ ${INSTALL} ${COPY} -m 644 ${_lib} ${DESTDIR}${LIBDIR}
+ ${RANLIB} ${DESTDIR}${LIBDIR}/${_lib}
+.endfor
+.for _lib in ${_LIBS:M*.${LD_solink}*:O:u}
+ ${INSTALL} ${COPY} -m ${LIBMODE} ${_lib} ${DESTDIR}${LIBDIR}
+.if !empty(SHLIB_LINKS)
+ (cd ${DESTDIR}${LIBDIR} && { ${SHLIB_LINKS:O:u:@x@ln -sf ${_lib} $x;@}; })
+.endif
+.endfor
+ @touch ${.TARGET}
+
+.include <final.mk>
+.endif
diff --git a/contrib/bmake/mk/libnames.mk b/contrib/bmake/mk/libnames.mk
new file mode 100644
index 0000000..60e12eb
--- /dev/null
+++ b/contrib/bmake/mk/libnames.mk
@@ -0,0 +1,22 @@
+# $Id: libnames.mk,v 1.7 2009/12/25 07:34:03 sjg Exp $
+#
+# @(#) Copyright (c) 2007-2009, 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
+#
+
+DLIBEXT ?= .a
+DSHLIBEXT ?= .so
+
+.-include "local.libnames.mk"
+.-include "sjg.libnames.mk"
+.-include "fwall.libnames.mk"
+.-include "host.libnames.mk"
diff --git a/contrib/bmake/mk/libs.mk b/contrib/bmake/mk/libs.mk
new file mode 100644
index 0000000..05b4506
--- /dev/null
+++ b/contrib/bmake/mk/libs.mk
@@ -0,0 +1,54 @@
+# $Id: libs.mk,v 1.2 2007/04/30 17:39:27 sjg Exp $
+#
+# @(#) Copyright (c) 2006, 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
+#
+
+.MAIN: all
+
+.if defined(LIBS)
+
+.ifndef LIB
+.for t in ${LIBS:R:T:S,^lib,,}
+.if make(lib$t)
+LIB?= $t
+lib$t: all
+.endif
+.endfor
+.endif
+
+.if defined(LIB)
+# just one of many
+.for v in DPADD SRCS CFLAGS ${LIB_VARS}
+$v += ${${v}_lib${LIB}}
+.endfor
+# ensure that we don't clobber each other's dependencies
+DEPENDFILE?= .depend.${LIB}
+# lib.mk will do the rest
+.else
+all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
+.endif
+.endif
+
+# handle being called [bsd.]libs.mk
+.include <${.PARSEFILE:S,libs,lib,}>
+
+.ifndef LIB
+.for t in ${LIBS:R:T:S,^lib,,}
+lib$t.a: ${SRCS} ${DPADD} ${SRCS_lib$t} ${DPADD_lib$t}
+ (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t)
+
+clean: $t.clean
+$t.clean:
+ (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t ${@:E})
+.endfor
+.endif
diff --git a/contrib/bmake/mk/links.mk b/contrib/bmake/mk/links.mk
new file mode 100644
index 0000000..4ec8a01
--- /dev/null
+++ b/contrib/bmake/mk/links.mk
@@ -0,0 +1,75 @@
+# $Id: links.mk,v 1.5 2005/07/11 18:01:05 sjg Exp $
+#
+# @(#) Copyright (c) 2005, 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
+#
+
+# some platforms need something special
+LN?= ln
+ECHO?= echo
+
+LINKS?=
+SYMLINKS?=
+
+__SYMLINK_SCRIPT= \
+ ${ECHO} "$$t -> $$l"; \
+ mkdir -p `dirname $$t`; \
+ rm -f $$t; \
+ ${LN} -s $$l $$t
+
+__LINK_SCRIPT= \
+ ${ECHO} "$$t -> $$l"; \
+ mkdir -p `dirname $$t`; \
+ rm -f $$t; \
+ ${LN} $$l $$t
+
+_SYMLINKS_SCRIPT= \
+ while test $$\# -ge 2; do \
+ l=$$1; shift; \
+ t=${DESTDIR}$$1; shift; \
+ ${__SYMLINK_SCRIPT}; \
+ done; :;
+
+_LINKS_SCRIPT= \
+ while test $$\# -ge 2; do \
+ l=${DESTDIR}$$1; shift; \
+ t=${DESTDIR}$$1; shift; \
+ ${__LINK_SCRIPT}; \
+ done; :;
+
+_SYMLINKS_USE: .USE
+ @set ${$@_SYMLINKS:U${SYMLINKS}}; ${_SYMLINKS_SCRIPT}
+
+_LINKS_USE: .USE
+ @set ${$@_LINKS:U${LINKS}}; ${_LINKS_SCRIPT}
+
+
+# sometimes we want to ensure DESTDIR is ignored
+_BUILD_SYMLINKS_SCRIPT= \
+ while test $$\# -ge 2; do \
+ l=$$1; shift; \
+ t=$$1; shift; \
+ ${__SYMLINK_SCRIPT}; \
+ done; :;
+
+_BUILD_LINKS_SCRIPT= \
+ while test $$\# -ge 2; do \
+ l=$$1; shift; \
+ t=$$1; shift; \
+ ${__LINK_SCRIPT}; \
+ done; :;
+
+_BUILD_SYMLINKS_USE: .USE
+ @set ${$@_SYMLINKS:U${SYMLINKS}}; ${_BUILD_SYMLINKS_SCRIPT}
+
+_BUILD_LINKS_USE: .USE
+ @set ${$@_LINKS:U${LINKS}}; ${_BUILD_LINKS_SCRIPT}
diff --git a/contrib/bmake/mk/man.mk b/contrib/bmake/mk/man.mk
new file mode 100644
index 0000000..391b08a
--- /dev/null
+++ b/contrib/bmake/mk/man.mk
@@ -0,0 +1,137 @@
+# $Id: man.mk,v 1.20 2012/12/13 01:51:01 sjg Exp $
+
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+.include <init.mk>
+
+# unlike bsd.man.mk we handle 3 approaches
+# 1. install unformated nroff (default)
+# 2. install formatted pages
+# 3. install formatted pages but with extension of .0
+# sadly we cannot rely on a shell that supports ${foo#...} and ${foo%...}
+# so we have to use sed(1).
+
+# set MANTARGET=cat for formatted pages
+MANTARGET?= man
+# set this to .0 for same behavior as bsd.man.mk
+MCATEXT?=
+
+NROFF?= nroff
+MANDIR?= /usr/share/man
+MANDOC?= man
+
+.SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 \
+ .cat7 .cat8 .cat9
+
+.9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3.cat3 .2.cat2 .1.cat1:
+ @echo "${NROFF} -${MANDOC} ${.IMPSRC} > ${.TARGET:T}"
+ @${NROFF} -${MANDOC} ${.IMPSRC} > ${.TARGET:T} || ( rm -f ${.TARGET:T} ; false )
+
+.if defined(MAN) && !empty(MAN)
+
+# we use cmt2doc.pl to extract manpages from source
+# this is triggered by the setting of EXTRACT_MAN or MAN being set but
+# not existsing.
+
+.if !exists(${MAN:[1]}) && !target(${MAN:[1]})
+.if defined(EXTRACT_MAN) && ${EXTRACT_MAN} == "no"
+MAN=
+.else
+.if exists(/usr/local/share/bin/cmt2doc.pl)
+CMT2DOC?= cmt2doc.pl
+CMT2DOC_OPTS?= ${CMT2DOC_ORGOPT} -pmS${.TARGET:E}
+.endif
+.ifdef CMT2DOC
+.c.8 .c.5 .c.3 .c.4 .c.1 \
+ .cc.8 .cc.5 .cc.3 .cc.4 .cc.1 \
+ .h.8 .h.5 .h.3 .h.4 .h.1 \
+ .sh.8 .sh.5 .sh.3 .sh.4 .sh.1 \
+ .pl.8 .pl.5 .pl.3 .pl.4 .pl.1:
+ @echo "${CMT2DOC} ${.IMPSRC} > ${.TARGET:T}"
+ @${CMT2DOC} ${CMT2DOC_OPTS} ${.IMPSRC} > ${.TARGET:T} || ( rm -f ${.TARGET:T} ; false )
+.else
+MAN=
+.endif
+.endif
+.endif
+
+_mandir=${DESTDIR}${MANDIR}/${MANTARGET}`echo $$page | sed -e 's/.*\.cat/./' -e 's/.*\.//'`
+.if ${MANTARGET} == "cat"
+_mfromdir?=.
+MANALL= ${MAN:S/.1$/.cat1/g:S/.2$/.cat2/g:S/.3$/.cat3/g:S/.4$/.cat4/g:S/.5$/.cat5/g:S/.6$/.cat6/g:S/.7$/.cat7/g:S/.8$/.cat8/g:S/.9$/.cat9/g}
+.if ${MCATEXT} == ""
+_minstpage=`echo $$page | sed 's/\.cat/./'`
+.else
+_minstpage=`echo $$page | sed 's/\.cat.*//'`${MCATEXT}
+.endif
+.endif
+.if target(${MAN:[1]})
+_mfromdir?=.
+.endif
+_mfromdir?=${.CURDIR}
+MANALL?= ${MAN}
+_minstpage?=$${page}
+.endif
+
+.if !empty(MANOWN)
+MAN_INSTALL_OWN ?= -o ${MANOWN} -g ${MANGRP}
+MAN_CHOWN ?= chown
+.else
+MAN_CHOWN = :
+.endif
+
+MINSTALL= ${INSTALL} ${COPY} ${MAN_INSTALL_OWN} -m ${MANMODE}
+.if defined(MANZ)
+# chown and chmod are done afterward automatically
+MCOMPRESS= gzip -cf
+MCOMPRESSSUFFIX= .gz
+.endif
+
+maninstall:
+.if defined(MANALL) && !empty(MANALL)
+ @for page in ${MANALL:T}; do \
+ test -s ${_mfromdir}/$$page || continue; \
+ dir=${_mandir}; \
+ test -d $$dir || ${INSTALL} -d ${MAN_INSTALL_OWN} -m 775 $$dir; \
+ instpage=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \
+ if [ X"${MCOMPRESS}" = X ]; then \
+ echo ${MINSTALL} ${_mfromdir}/$$page $$instpage; \
+ ${MINSTALL} ${_mfromdir}/$$page $$instpage; \
+ else \
+ rm -f $$instpage; \
+ echo ${MCOMPRESS} ${_mfromdir}/$$page \> $$instpage; \
+ ${MCOMPRESS} ${_mfromdir}/$$page > $$instpage; \
+ ${MAN_CHOWN} ${MANOWN}:${MANGRP} $$instpage; \
+ chmod ${MANMODE} $$instpage; \
+ fi \
+ done
+.if defined(MLINKS) && !empty(MLINKS)
+ @set ${MLINKS}; \
+ while test $$# -ge 2; do \
+ page=$$1; \
+ shift; \
+ dir=${_mandir}; \
+ l=${_minstpage}${MCOMPRESSSUFFIX}; \
+ page=$$1; \
+ shift; \
+ dir=${_mandir}; \
+ t=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \
+ echo $$t -\> $$l; \
+ rm -f $$t; \
+ ln -s $$l $$t; \
+ done
+.endif
+.endif
+
+.if defined(MANALL) && !empty(MANALL)
+manall: ${MANALL}
+all: manall
+.endif
+
+.if defined(CLEANMAN) && !empty(CLEANMAN)
+cleandir: cleanman
+cleanman:
+ rm -f ${CLEANMAN}
+.endif
+.endif
diff --git a/contrib/bmake/mk/meta.autodep.mk b/contrib/bmake/mk/meta.autodep.mk
new file mode 100644
index 0000000..c29c26e
--- /dev/null
+++ b/contrib/bmake/mk/meta.autodep.mk
@@ -0,0 +1,262 @@
+# $Id: meta.autodep.mk,v 1.32 2012/11/13 00:44:26 sjg Exp $
+
+#
+# @(#) Copyright (c) 2010, 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 ?= ${.PARSEFILE}
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
+
+.-include "local.autodep.mk"
+
+.if defined(SRCS)
+# it would be nice to be able to query .SUFFIXES
+OBJ_EXTENSIONS+= .o .po .lo .So
+
+# explicit dependencies help short-circuit .SUFFIX searches
+SRCS_DEP_FILTER+= N*.[hly]
+.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}}
+.for e in ${OBJ_EXTENSIONS:O:u}
+.if !target(${s:T:R}$e)
+${s:T:R}$e: $s
+.endif
+.endfor
+.endfor
+.endif
+
+.if make(gendirdeps)
+# you are supposed to know what you are doing!
+UPDATE_DEPENDFILE = yes
+.elif !empty(.TARGETS) && !make(all)
+# do not update the *depend* files
+# unless we are building the entire directory or the default target.
+# NO means don't update .depend - or Makefile.depend*
+# no means update .depend but not Makefile.depend*
+UPDATE_DEPENDFILE = NO
+.elif ${.MAKEFLAGS:M-k} != ""
+# it is a bad idea to update anything
+UPDATE_DEPENDFILE = NO
+.endif
+
+_CURDIR ?= ${.CURDIR}
+_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T}
+
+.if ${.MAKE.LEVEL} == 0
+.if ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
+UPDATE_DEPENDFILE = NO
+.endif
+.endif
+.if !exists(${_DEPENDFILE})
+_bootstrap_dirdeps = yes
+.endif
+_bootstrap_dirdeps ?= no
+UPDATE_DEPENDFILE ?= yes
+
+.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.info ${_DEPENDFILE:S,${SRCTOP}/,,} update=${UPDATE_DEPENDFILE}
+.endif
+
+.if !empty(XMAKE_META_FILE)
+.if exists(${.OBJDIR}/${XMAKE_META_FILE})
+# we cannot get accurate dependencies from an update build
+UPDATE_DEPENDFILE = NO
+.else
+META_XTRAS += ${XMAKE_META_FILE}
+.endif
+.endif
+
+.if ${_bootstrap_dirdeps} == "yes" || exists(${_DEPENDFILE})
+# if it isn't supposed to be touched by us the Makefile should have
+# UPDATE_DEPENDFILE = no
+WANT_UPDATE_DEPENDFILE ?= yes
+.endif
+
+.if ${WANT_UPDATE_DEPENDFILE:Uno:tl} != "no"
+.if ${.MAKE.MODE:Mmeta*} == "" || ${.MAKE.MODE:M*read*} != ""
+UPDATE_DEPENDFILE = no
+.endif
+
+.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.info ${_DEPENDFILE:S,${SRCTOP}/,,} update=${UPDATE_DEPENDFILE}
+.endif
+
+.if ${UPDATE_DEPENDFILE:tl} == "yes"
+# sometimes we want .meta files generated to aid debugging/error detection
+# but do not want to consider them for dependencies
+# for example the result of running configure
+# just make sure this is not empty
+META_FILE_FILTER ?= N.meta
+
+.if !empty(DPADD)
+# if we have any non-libs in DPADD,
+# they probably need to be paid attention to
+.if !empty(DPLIBS)
+FORCE_DPADD = ${DPADD:${DPLIBS:${M_ListToSkip}}:${DPADD_LAST:${M_ListToSkip}}}
+.else
+_nonlibs := ${DPADD:T:Nlib*:N*include}
+.if !empty(_nonlibs)
+FORCE_DPADD += ${_nonlibs:@x@${DPADD:M*/$x}@}
+.endif
+.endif
+.endif
+
+.if !make(gendirdeps)
+.END: gendirdeps
+.endif
+
+# if we don't have OBJS, then .depend isn't useful
+.if !target(.depend) && (!empty(OBJS) || ${.ALLTARGETS:M*.o} != "")
+# some makefiles and/or targets contain
+# circular dependencies if you dig too deep
+# (as meta mode is apt to do)
+# so we provide a means of supressing them.
+# the input to the loop below is target: dependency
+# with just one dependency per line.
+# Also some targets are not really local, or use random names.
+# Use local.autodep.mk to provide local additions!
+SUPPRESS_DEPEND += \
+ ${SB:S,/,_,g}* \
+ *:y.tab.c \
+ *.c:*.c \
+ *.h:*.h
+
+.NOPATH: .depend
+# we use ${.MAKE.META.CREATED} to trigger an update but
+# we process using ${.MAKE.META.FILES}
+# the double $$ defers initial evaluation
+# if necessary, we fake .po dependencies, just so the result
+# in Makefile.depend* is stable
+# The current objdir may be refered to in various ways
+OBJDIR_REFS += ${.OBJDIR} ${.OBJDIR:tA} ${_OBJDIR} ${RELOBJTOP}/${RELDIR}
+_depend = .depend
+# it would be nice to be able to get .SUFFIXES as ${.SUFFIXES}
+# we actually only care about the .SUFFIXES of files that might be
+# generated by tools like yacc.
+DEPEND_SUFFIXES += .c .h .cpp .hpp .cxx .hxx .cc .hh
+.depend: .NOMETA $${.MAKE.META.CREATED} ${_this}
+ @echo "Updating $@: ${.OODATE:T:[1..8]}"
+ @egrep -i '^R .*\.(${DEPEND_SUFFIXES:tl:O:u:S,^.,,:ts|})$$' /dev/null ${.MAKE.META.FILES:T:O:u:${META_FILE_FILTER:ts:}:M*o.meta} | \
+ sed -e 's, \./, ,${OBJDIR_REFS:O:u:@d@;s, $d/, ,@};/\//d' \
+ -e 's,^\([^/][^/]*\).meta...[0-9]* ,\1: ,' | \
+ sort -u | \
+ while read t d; do \
+ case "$$d:" in $$t) continue;; esac; \
+ case "$$t$$d" in ${SUPPRESS_DEPEND:U.:O:u:ts|}) continue;; esac; \
+ echo $$t $$d; \
+ done > $@.${.MAKE.PID}
+ @case "${.MAKE.META.FILES:T:M*.po.*}" in \
+ *.po.*) mv $@.${.MAKE.PID} $@;; \
+ *) { cat $@.${.MAKE.PID}; \
+ sed 's,\.So:,.o:,;s,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \
+ rm -f $@.${.MAKE.PID};; \
+ esac
+.else
+# make sure this exists
+.depend:
+# do _not_ assume that .depend is in any fit state for us to use
+CAT_DEPEND = /dev/null
+.if ${.MAKE.LEVEL} > 0
+.export CAT_DEPEND
+.endif
+_depend =
+.endif
+
+.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.info ${_DEPENDFILE:S,${SRCTOP}/,,} _depend=${_depend}
+.endif
+
+gendirdeps: ${_DEPENDFILE}
+
+.if !target(${_DEPENDFILE})
+.if ${_bootstrap_dirdeps} == "yes"
+# We are boot-strapping a new directory
+# Use DPADD to seed DIRDEPS
+.if !empty(DPADD)
+# anything which matches ${_OBJROOT}* but not ${_OBJTOP}*
+# needs to be qualified in DIRDEPS
+# The pseudo machine "host" is used for HOST_TARGET
+DIRDEPS = \
+ ${DPADD:M${_OBJTOP}*:H:C,${_OBJTOP}[^/]*/,,:N.:O:u} \
+ ${DPADD:M${_OBJROOT}*:N${_OBJTOP}*:H:S,${_OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
+
+.endif
+.endif
+
+_gendirdeps_mutex =
+.if defined(NEED_GENDIRDEPS_MUTEX)
+# If a src dir gets built with multiple object dirs,
+# we need a mutex. Obviously, this is best avoided.
+# Note if .MAKE.DEPENDFILE is common for all ${MACHINE}
+# you either need to mutex, or ensure only one machine builds at a time!
+# lockf is an example of a suitable tool
+LOCKF ?= /usr/bin/lockf
+.if exists(${LOCKF})
+GENDIRDEPS_MUTEXER ?= ${LOCKF} -k
+.endif
+.if empty(GENDIRDEPS_MUTEXER)
+.error NEED_GENDIRDEPS_MUTEX defined, but GENDIRDEPS_MUTEXER not set
+.else
+_gendirdeps_mutex = ${GENDIRDEPS_MUTEXER} ${GENDIRDEPS_MUTEX:U${_CURDIR}/Makefile}
+.endif
+.endif
+
+# If we have META_XTRAS we most likely did not create them
+# but we need to behave as if we did.
+# Avoid adding glob patterns to .MAKE.META.CREATED though.
+.MAKE.META.CREATED += ${META_XTRAS:N*\**:O:u}
+
+.if make(gendirdeps)
+META_FILES = *.meta
+.elif ${OPTIMIZE_OBJECT_META_FILES:Uno:tl} == "no"
+META_FILES = ${.MAKE.META.FILES:T:N.depend*:O:u}
+.else
+# if we have 1000's of .o.meta, .So.meta etc we need only look at one set
+# it is left as an exercise for the reader to work out what this does
+META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \
+ ${.MAKE.META.FILES:T:M*.${.MAKE.META.FILES:M*o.meta:R:E:O:u:[1]}.meta:O:u}
+.endif
+
+.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.info ${_DEPENDFILE:S,${SRCTOP}/,,}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} xtras=${META_XTRAS}
+.endif
+
+.if ${.MAKE.LEVEL} > 0 && !empty(GENDIRDEPS_FILTER)
+.export GENDIRDEPS_FILTER
+.endif
+
+# we might have .../ in MAKESYSPATH
+_makesyspath:= ${_PARSEDIR}
+${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.META.CREATED}
+ @echo Checking $@: ${.OODATE:T:[1..8]}
+ @(cd . && \
+ SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS:O:u}' \
+ DPADD='${FORCE_DPADD:O:u}' ${_gendirdeps_mutex} \
+ MAKESYSPATH=${_makesyspath} \
+ ${.MAKE} -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE} \
+ META_FILES='${META_XTRAS:T:O:u} ${META_FILES:T:O:u:${META_FILE_FILTER:ts:}}')
+ @test -s $@ && touch $@; :
+.endif
+
+.endif
+.endif
+
+.if ${_bootstrap_dirdeps} == "yes"
+# make sure this is included at least once
+.include <dirdeps.mk>
+.else
+${_DEPENDFILE}: .PRECIOUS
+.endif
+
+CLEANFILES += *.meta filemon.* *.db
+.endif
diff --git a/contrib/bmake/mk/meta.stage.mk b/contrib/bmake/mk/meta.stage.mk
new file mode 100644
index 0000000..cf62db4
--- /dev/null
+++ b/contrib/bmake/mk/meta.stage.mk
@@ -0,0 +1,212 @@
+# $Id: meta.stage.mk,v 1.17 2013/01/24 01:02:23 sjg Exp $
+#
+# @(#) Copyright (c) 2011, 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 !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != ""
+# this is generally safer anyway
+_dirdep = ${RELDIR}.${MACHINE}
+.else
+_dirdep = ${RELDIR}
+.endif
+
+# this allows us to trace dependencies back to their src dir
+.dirdep:
+ @echo '${_dirdep}' > $@
+
+.if defined(NO_POSIX_SHELL) || ${type printf:L:sh:Mbuiltin} == ""
+_stage_file_basename = `basename $$f`
+_stage_target_dirname = `dirname $$t`
+.else
+_stage_file_basename = $${f\#\#*/}
+_stage_target_dirname = $${t%/*}
+.endif
+
+_objroot ?= ${_OBJROOT:tA}
+# make sure this is global
+_STAGED_DIRS ?=
+.export _STAGED_DIRS
+# add each dir we stage to to _STAGED_DIRS
+# and make sure we have absolute paths so that bmake
+# will match against .MAKE.META.BAILIWICK
+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,}
+
+# it is an error for more than one src dir to try and stage
+# the same file
+STAGE_DIRDEP_SCRIPT = StageDirdep() { \
+ t=$$1; \
+ if [ -s $$t.dirdep ]; then \
+ cmp -s .dirdep $$t.dirdep && return; \
+ echo "ERROR: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \
+ exit 1; \
+ fi; \
+ ln .dirdep $$t.dirdep 2> /dev/null || \
+ cp .dirdep $$t.dirdep; }
+
+# common logic for staging files
+# this all relies on RELDIR being set to a subdir of SRCTOP
+# we use ln(1) if we can, else cp(1)
+STAGE_FILE_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageFiles() { \
+ case "$$1" in -m) mode=$$2; shift 2;; *) mode=;; esac; \
+ dest=$$1; shift; \
+ mkdir -p $$dest; \
+ [ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \
+ for f in "$$@"; do \
+ case "$$f" in */*) t=$$dest/${_stage_file_basename};; *) t=$$dest/$$f;; esac; \
+ StageDirdep $$t; \
+ rm -f $$t; \
+ { ln $$f $$t 2> /dev/null || \
+ cp -p $$f $$t; }; \
+ $${mode:+chmod $$mode $$t}; \
+ done; :; }
+
+STAGE_LINKS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageLinks() { \
+ case "$$1" in --) shift;; -*) ldest= lnf=$$1; shift;; /*) ldest=$$1/;; esac; \
+ dest=$$1; shift; \
+ mkdir -p $$dest; \
+ [ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \
+ while test $$\# -ge 2; do \
+ l=$$ldest$$1; shift; \
+ t=$$dest/$$1; \
+ case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \
+ shift; \
+ StageDirdep $$t; \
+ rm -f $$t 2>/dev/null; \
+ ln $$lnf $$l $$t; \
+ done; :; }
+
+STAGE_AS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageAs() { \
+ case "$$1" in -m) mode=$$2; shift 2;; *) mode=;; esac; \
+ dest=$$1; shift; \
+ mkdir -p $$dest; \
+ [ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \
+ while test $$\# -ge 2; do \
+ s=$$1; shift; \
+ t=$$dest/$$1; \
+ case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \
+ shift; \
+ StageDirdep $$t; \
+ rm -f $$t; \
+ { ln $$s $$t 2> /dev/null || \
+ cp -p $$s $$t; }; \
+ $${mode:+chmod $$mode $$t}; \
+ done; :; }
+
+# this is simple, a list of the "staged" files depends on this,
+_STAGE_BASENAME_USE: .USE ${.TARGET:T}
+ @${STAGE_FILE_SCRIPT}; StageFiles ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T}
+
+.if !empty(STAGE_INCSDIR)
+CLEANFILES += stage_incs
+
+STAGE_INCS ?= ${.ALLSRC:N.dirdep}
+
+stage_incs: .dirdep
+ @${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS}
+ @touch $@
+.endif
+
+.if !empty(STAGE_LIBDIR)
+CLEANFILES += stage_libs
+
+STAGE_LIBS ?= ${.ALLSRC:N.dirdep}
+
+stage_libs: .dirdep
+ @${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS}
+.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
+ @touch $@
+.endif
+
+.if !empty(STAGE_DIR)
+STAGE_SETS += _default
+STAGE_DIR._default = ${STAGE_DIR}
+STAGE_LINKS_DIR._default = ${STAGE_LINKS_DIR:U${STAGE_OBJTOP}}
+STAGE_SYMLINKS_DIR._default = ${STAGE_SYMLINKS_DIR:U${STAGE_OBJTOP}}
+STAGE_FILES._default = ${STAGE_FILES}
+STAGE_LINKS._default = ${STAGE_LINKS}
+STAGE_SYMLINKS._default = ${STAGE_SYMLINKS}
+STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*}
+STAGE_SYMLINKS ?= ${.ALLSRC:T:N.dirdep:Nstage_*}
+.endif
+
+.if !empty(STAGE_SETS)
+
+CLEANFILES += ${STAGE_SETS:@s@stage*$s@}
+
+# some makefiles need to populate multiple directories
+.for s in ${STAGE_SETS:O:u}
+STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep}
+STAGE_SYMLINKS.$s ?= ${.ALLSRC:N.dirdep}
+STAGE_LINKS_DIR.$s ?= ${STAGE_OBJTOP}
+STAGE_SYMLINKS_DIR.$s ?= ${STAGE_OBJTOP}
+
+.if $s != "_default"
+stage_files: stage_files.$s
+stage_files.$s: .dirdep
+.else
+stage_files: .dirdep
+.endif
+ @${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s}
+ @touch $@
+
+.if $s != "_default"
+stage_links: stage_links.$s
+stage_links.$s: .dirdep
+.else
+stage_links: .dirdep
+.endif
+ @${STAGE_LINKS_SCRIPT}; StageLinks ${STAGE_LINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_LINKS.$s}
+ @touch $@
+
+.if $s != "_default"
+stage_symlinks: stage_symlinks.$s
+stage_symlinks.$s: .dirdep
+.else
+stage_symlinks: .dirdep
+.endif
+ @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_SYMLINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_SYMLINKS.$s}
+ @touch $@
+
+.endfor
+.endif
+
+.if !empty(STAGE_AS_SETS)
+CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@}
+
+# sometimes things need to be renamed as they are staged
+# each ${file} will be staged as ${STAGE_AS_${file:T}}
+# one could achieve the same with SYMLINKS
+.for s in ${STAGE_AS_SETS:O:u}
+STAGE_AS.$s ?= ${.ALLSRC:N.dirdep}
+
+stage_as: stage_as.$s
+stage_as.$s: .dirdep
+ @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:T}:U${f:T}}@}
+ @touch $@
+
+.endfor
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/meta.subdir.mk b/contrib/bmake/mk/meta.subdir.mk
new file mode 100644
index 0000000..2b739ee
--- /dev/null
+++ b/contrib/bmake/mk/meta.subdir.mk
@@ -0,0 +1,79 @@
+# $Id: meta.subdir.mk,v 1.10 2012/07/03 05:26:46 sjg Exp $
+
+#
+# @(#) Copyright (c) 2010, 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 !defined(NO_SUBDIR) && !empty(SUBDIR)
+.if make(destroy*) || make(clean*)
+.MAKE.MODE = compat
+.if !commands(destroy)
+.-include <bsd.obj.mk>
+.endif
+.elif ${.MAKE.LEVEL} == 0
+
+.MAIN: all
+
+.if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps)
+# start with this
+DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@}
+
+.if make(gendirdeps)
+.include <meta.autodep.mk>
+.else
+# this is the cunning bit
+# actually it is probably a bit risky
+# since we may pickup subdirs which are not relevant
+# the alternative is a walk through the tree though
+# which is difficult without a sub-make.
+
+.if defined(BOOTSTRAP_DEPENDFILES)
+_find_name = ${.MAKE.MAKEFILE_PREFERENCE:@m@-o -name $m@:S,^-o,,1}
+DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@}
+.elif ${.MAKE.DEPENDFILE:E} == ${MACHINE} && defined(ALL_MACHINES)
+# we want to find Makefile.depend.* ie for all machines
+# and turn the dirs into dir.<machine>
+_find_name = -name '${.MAKE.DEPENDFILE:T:R}*'
+DIRDEPS = ${_subdeps:O:u:${NIgnoreFiles}:@d@${RELDIR}/${d:H}.${d:E}@:S,.${MACHINE}$,,:S,.depend$,,}
+.else
+# much simpler
+_find_name = -name ${.MAKE.DEPENDFILE:T}
+.if ${.MAKE.DEPENDFILE:E} == ${MACHINE}
+_find_name += -o -name ${.MAKE.DEPENDFILE:T:R}
+.endif
+DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@}
+.endif
+
+_subdeps != cd ${.CURDIR} && \
+ find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \
+ -name .svn -prune 2> /dev/null; echo
+
+.if empty(_subdeps)
+DIRDEPS =
+.else
+# clean up if needed
+DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIREPS_FILTER:Uu}}
+.endif
+# we just dealt with it, if we leave it defined,
+# dirdeps.mk will compute some interesting combinations.
+.undef ALL_MACHINES
+
+DEP_RELDIR = ${RELDIR}
+.include <dirdeps.mk>
+.endif
+.endif
+.else
+all: .PHONY
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/meta.sys.mk b/contrib/bmake/mk/meta.sys.mk
new file mode 100644
index 0000000..1707a66
--- /dev/null
+++ b/contrib/bmake/mk/meta.sys.mk
@@ -0,0 +1,139 @@
+# $Id: meta.sys.mk,v 1.16 2012/07/03 05:26:00 sjg Exp $
+
+#
+# @(#) Copyright (c) 2010, 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
+#
+
+# include this if you want to enable meta mode
+# for maximum benefit, requires filemon(4) driver.
+
+.if ${MAKE_VERSION:U0} > 20100901
+.if !target(.ERROR)
+
+
+META_MODE += meta verbose
+.MAKE.MODE ?= ${META_MODE}
+
+.if ${.MAKE.LEVEL} == 0
+_make_mode := ${.MAKE.MODE} ${META_MODE}
+.if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != ""
+# tell everyone we are not updating Makefile.depend*
+UPDATE_DEPENDFILE = NO
+.export UPDATE_DEPENDFILE
+.endif
+.if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon)
+# we should not get upset
+META_MODE += nofilemon
+.export META_MODE
+.endif
+.endif
+
+.if !defined(NO_SILENT)
+.if ${MAKE_VERSION} > 20110818
+# only be silent when we have a .meta file
+META_MODE += silent=yes
+.else
+.SILENT:
+.endif
+.endif
+
+# make defaults .MAKE.DEPENDFILE to .depend
+# that won't work for us.
+.if ${.MAKE.DEPENDFILE} == ".depend"
+.undef .MAKE.DEPENDFILE
+.endif
+
+# if you don't cross build for multiple MACHINEs concurrently, then
+# .MAKE.DEPENDFILE = Makefile.depend
+# probably makes sense - you can set that in local.sys.mk
+.MAKE.DEPENDFILE ?= Makefile.depend.${MACHINE}
+
+# we use the pseudo machine "host" for the build host.
+# this should be taken care of before we get here
+.if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub}
+MACHINE = host
+.endif
+
+.if ${.MAKE.LEVEL} == 0
+# it can be handy to know which MACHINE kicked off the build
+# for example, if using Makefild.depend for multiple machines,
+# allowing only MACHINE0 to update can keep things simple.
+MACHINE0 := ${MACHINE}
+
+.if defined(PYTHON) && exists(${PYTHON})
+# we prefer the python version of this - it is much faster
+META2DEPS ?= ${.PARSEDIR}/meta2deps.py
+.else
+META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
+.endif
+META2DEPS := ${META2DEPS}
+.export META2DEPS
+.endif
+
+MAKE_PRINT_VAR_ON_ERROR += \
+ .ERROR_TARGET \
+ .ERROR_META_FILE \
+ .MAKE.LEVEL \
+ MAKEFILE \
+ .MAKE.MODE
+
+.if !defined(SB) && defined(SRCTOP)
+SB = ${SRCTOP:H}
+.endif
+ERROR_LOGDIR ?= ${SB}/error
+meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
+
+# we are not interested in make telling us a failure happened elsewhere
+.ERROR: _metaError
+_metaError: .NOMETA .NOTMAIN
+ -@[ "${.ERROR_META_FILE}" ] && { \
+ grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
+ mkdir -p ${meta_error_log:H}; \
+ cp ${.ERROR_META_FILE} ${meta_error_log}; \
+ echo "ERROR: log ${meta_error_log}" >&2; }; :
+
+.endif
+
+# Are we, after all, in meta mode?
+.if ${.MAKE.MODE:Mmeta*} != ""
+MKDEP = meta.autodep
+
+.if ${.MAKE.LEVEL} == 0
+# make sure dirdeps target exists and do it first
+all: dirdeps .WAIT
+dirdeps:
+.NOPATH: dirdeps
+
+.if defined(ALL_MACHINES)
+# the first .MAIN: is what counts
+# by default dirdeps is all we want at level0
+.MAIN: dirdeps
+# tell dirdeps.mk what we want
+BUILD_AT_LEVEL0 = no
+.endif
+
+.if ${.MAKE.DEPENDFILE:E} == ${MACHINE}
+# 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
diff --git a/contrib/bmake/mk/meta2deps.py b/contrib/bmake/mk/meta2deps.py
new file mode 100755
index 0000000..cb6d321
--- /dev/null
+++ b/contrib/bmake/mk/meta2deps.py
@@ -0,0 +1,614 @@
+#!/usr/bin/env python
+
+"""
+This script parses each "meta" file and extracts the
+information needed to deduce build and src dependencies.
+
+It works much the same as the original shell script, but is
+*much* more efficient.
+
+The parsing work is handled by the class MetaFile.
+We only pay attention to a subset of the information in the
+"meta" files. Specifically:
+
+'CWD' to initialize our notion.
+
+'C' to track chdir(2) on a per process basis
+
+'R' files read are what we really care about.
+ directories read, provide a clue to resolving
+ subsequent relative paths. That is if we cannot find
+ them relative to 'cwd', we check relative to the last
+ dir read.
+
+'W' files opened for write or read-write,
+ for filemon V3 and earlier.
+
+'E' files executed.
+
+'L' files linked
+
+'V' the filemon version, this record is used as a clue
+ that we have reached the interesting bit.
+
+"""
+
+"""
+RCSid:
+ $Id: meta2deps.py,v 1.7 2012/11/06 05:44:03 sjg Exp $
+
+ Copyright (c) 2011, Juniper Networks, Inc.
+
+ 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.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ OWNER 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.
+
+"""
+
+import os, re, sys
+
+def getv(dict, key, d=None):
+ """Lookup key in dict and return value or the supplied default."""
+ if key in dict:
+ return dict[key]
+ return d
+
+def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
+ """
+ Return an absolute path, resolving via cwd or last_dir if needed.
+ """
+ if path.endswith('/.'):
+ path = path[0:-2]
+ if path[0] == '/':
+ return path
+ if path == '.':
+ return cwd
+ if path.startswith('./'):
+ return cwd + path[1:]
+ if last_dir == cwd:
+ last_dir = None
+ for d in [last_dir, cwd]:
+ if not d:
+ continue
+ p = '/'.join([d,path])
+ if debug > 2:
+ print >> debug_out, "looking for:", p,
+ if not os.path.exists(p):
+ if debug > 2:
+ print >> debug_out, "nope"
+ p = None
+ continue
+ if debug > 2:
+ print >> debug_out, "found:", p
+ return p
+ return None
+
+def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
+ """
+ Return an absolute path, resolving via cwd or last_dir if needed.
+ this gets called a lot, so we try to avoid calling realpath
+ until we know we have something.
+ """
+ path = resolve(path, cwd, last_dir, debug, debug_out)
+ if path and (path.find('./') > 0 or
+ path.endswith('/..') or
+ os.path.islink(path)):
+ return os.path.realpath(path)
+ return path
+
+def sort_unique(list, cmp=None, key=None, reverse=False):
+ list.sort(cmp, key, reverse)
+ nl = []
+ le = None
+ for e in list:
+ if e == le:
+ continue
+ nl.append(e)
+ return nl
+
+class MetaFile:
+ """class to parse meta files generated by bmake."""
+
+ conf = None
+ dirdep_re = None
+ host_target = None
+ srctops = []
+ objroots = []
+
+ seen = {}
+ obj_deps = []
+ src_deps = []
+ file_deps = []
+
+ def __init__(self, name, conf={}):
+ """if name is set we will parse it now.
+ conf can have the follwing keys:
+
+ SRCTOPS list of tops of the src tree(s).
+
+ CURDIR the src directory 'bmake' was run from.
+
+ RELDIR the relative path from SRCTOP to CURDIR
+
+ MACHINE the machine we built for.
+ set to 'none' if we are not cross-building.
+
+ HOST_TARGET
+ when we build for the psuedo machine 'host'
+ the object tree uses HOST_TARGET rather than MACHINE.
+
+ OBJROOTS a list of the common prefix for all obj dirs it might
+ end in '/' or '-'.
+
+ DPDEPS names an optional file to which per file dependencies
+ will be appended.
+ For example if 'some/path/foo.h' is read from SRCTOP
+ then 'DPDEPS_some/path/foo.h +=' "RELDIR" is output.
+ This can allow 'bmake' to learn all the dirs within
+ the tree that depend on 'foo.h'
+
+ debug desired debug level
+
+ debug_out open file to send debug output to (sys.stderr)
+
+ """
+
+ self.name = name
+ self.debug = getv(conf, 'debug', 0)
+ self.debug_out = getv(conf, 'debug_out', sys.stderr)
+
+ if not self.conf:
+ # some of the steps below we want to do only once
+ self.conf = conf
+ self.host_target = getv(conf, 'HOST_TARGET')
+ for srctop in getv(conf, 'SRCTOPS', []):
+ if srctop[-1] != '/':
+ srctop += '/'
+ if not srctop in self.srctops:
+ self.srctops.append(srctop)
+ _srctop = os.path.realpath(srctop)
+ if _srctop[-1] != '/':
+ _srctop += '/'
+ if not _srctop in self.srctops:
+ self.srctops.append(_srctop)
+
+ for objroot in getv(conf, 'OBJROOTS', []):
+ if not objroot in self.objroots:
+ self.objroots.append(objroot)
+ _objroot = os.path.realpath(objroot)
+ if objroot[-1] == '/':
+ _objroot += '/'
+ if not _objroot in self.objroots:
+ self.objroots.append(_objroot)
+
+ if self.debug:
+ print >> self.debug_out, "host_target=", self.host_target
+ print >> self.debug_out, "srctops=", self.srctops
+ print >> self.debug_out, "objroots=", self.objroots
+
+ self.dirdep_re = re.compile(r'([^/]+)/(.+)')
+
+ self.curdir = getv(conf, 'CURDIR')
+ self.machine = getv(conf, 'MACHINE', '')
+ self.reldir = getv(conf, 'RELDIR')
+ self.dpdeps = getv(conf, 'DPDEPS')
+ if self.dpdeps and not self.reldir:
+ if self.debug:
+ print >> self.debug_out, "need reldir:",
+ if self.curdir:
+ srctop = self.find_top(self.curdir, self.srctops)
+ if srctop:
+ self.reldir = self.curdir.replace(srctop,'')
+ if self.debug:
+ print >> self.debug_out, self.reldir
+ if not self.reldir:
+ self.dpdeps = None # we cannot do it?
+
+ if name:
+ self.parse()
+
+ def reset(self):
+ """reset state if we are being passed meta files from multiple directories."""
+ self.seen = {}
+ self.obj_deps = []
+ self.src_deps = []
+ self.file_deps = []
+
+ def dirdeps(self, sep='\n'):
+ """return DIRDEPS"""
+ return sep.strip() + sep.join(self.obj_deps)
+
+ def src_dirdeps(self, sep='\n'):
+ """return SRC_DIRDEPS"""
+ return sep.strip() + sep.join(self.src_deps)
+
+ def file_depends(self, out=None):
+ """Append DPDEPS_${file} += ${RELDIR}
+ for each file we saw, to the output file."""
+ if not self.reldir:
+ return None
+ for f in sort_unique(self.file_deps):
+ print >> out, 'DPDEPS_%s += %s' % (f, self.reldir)
+
+ def seenit(self, dir):
+ """rememer that we have seen dir."""
+ self.seen[dir] = 1
+
+ def add(self, list, data, clue=''):
+ """add data to list if it isn't already there."""
+ if data not in list:
+ list.append(data)
+ if self.debug:
+ print >> self.debug_out, "%s: %sAdd: %s" % (self.name, clue, data)
+
+ def find_top(self, path, list):
+ """the logical tree may be split accross multiple trees"""
+ for top in list:
+ if path.startswith(top):
+ if self.debug > 2:
+ print >> self.debug_out, "found in", top
+ return top
+ return None
+
+ def find_obj(self, objroot, dir, path, input):
+ """return path within objroot, taking care of .dirdep files"""
+ ddep = None
+ for ddepf in [path + '.dirdep', dir + '/.dirdep']:
+ if not ddep and os.path.exists(ddepf):
+ ddep = open(ddepf, 'rb').readline().strip('# \n')
+ if self.debug > 1:
+ print >> self.debug_out, "found %s: %s\n" % (ddepf, ddep)
+ if ddep.endswith(self.machine):
+ ddep = ddep[0:-(1+len(self.machine))]
+
+ if not ddep:
+ # no .dirdeps, so remember that we've seen the raw input
+ self.seenit(input)
+ self.seenit(dir)
+ if self.machine == 'none':
+ if dir.startswith(objroot):
+ return dir.replace(objroot,'')
+ return None
+ m = self.dirdep_re.match(dir.replace(objroot,''))
+ if m:
+ ddep = m.group(2)
+ dmachine = m.group(1)
+ if dmachine != self.machine:
+ if not (self.machine == 'host' and
+ dmachine == self.host_target):
+ if self.debug > 2:
+ print >> self.debug_out, "adding .%s to %s" % (dmachine, ddep)
+ ddep += '.' + dmachine
+
+ return ddep
+
+ def parse(self, name=None, file=None):
+ """A meta file looks like:
+
+ # Meta data file "path"
+ CMD "command-line"
+ CWD "cwd"
+ TARGET "target"
+ -- command output --
+ -- filemon acquired metadata --
+ # buildmon version 3
+ V 3
+ C "pid" "cwd"
+ E "pid" "path"
+ 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
+
+ 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
+ if name:
+ self.name = name;
+ if file:
+ f = file
+ cwd = last_dir = self.cwd
+ else:
+ f = open(self.name, 'rb')
+ skip = True
+ pid_cwd = {}
+ pid_last_dir = {}
+ last_pid = 0
+
+ if self.curdir:
+ self.seenit(self.curdir) # we ignore this
+
+ interesting = 'CEFLRV'
+ for line in f:
+ # ignore anything we don't care about
+ if not line[0] in interesting:
+ continue
+ if self.debug > 2:
+ print >> self.debug_out, "input:", line,
+ w = line.split()
+
+ if skip:
+ if w[0] == 'V':
+ skip = False
+ version = int(w[1])
+ """
+ if version < 4:
+ # we cannot ignore 'W' records
+ # as they may be 'rw'
+ interesting += 'W'
+ """
+ elif w[0] == 'CWD':
+ self.cwd = cwd = last_dir = w[1]
+ self.seenit(cwd) # ignore this
+ if self.debug:
+ print >> self.debug_out, "%s: CWD=%s" % (self.name, cwd)
+ continue
+
+ pid = int(w[1])
+ if pid != last_pid:
+ if last_pid:
+ pid_cwd[last_pid] = cwd
+ pid_last_dir[last_pid] = last_dir
+ cwd = getv(pid_cwd, pid, self.cwd)
+ last_dir = getv(pid_last_dir, pid, self.cwd)
+ last_pid = pid
+
+ # process operations
+ if w[0] == 'F':
+ npid = int(w[2])
+ pid_cwd[npid] = cwd
+ pid_last_dir[npid] = cwd
+ last_pid = npid
+ continue
+ elif w[0] == 'C':
+ cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
+ if cwd.endswith('/.'):
+ cwd = cwd[0:-2]
+ last_dir = cwd
+ if self.debug > 1:
+ print >> self.debug_out, "cwd=", cwd
+ continue
+
+ if w[2] in self.seen:
+ if self.debug > 2:
+ print >> self.debug_out, "seen:", w[2]
+ continue
+ # file operations
+ if w[0] in 'ML':
+ path = w[2].strip("'")
+ else:
+ 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 >> self.debug_out, "seen:", dir
+ 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 >> self.debug_out, "raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path)
+ 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 >> self.debug_out, "skipping:", path
+ continue
+ if os.path.isdir(path):
+ if w[0] in 'RW':
+ last_dir = path;
+ if self.debug > 1:
+ print >> self.debug_out, "ldir=", last_dir
+ continue
+
+ 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 main(argv, klass=MetaFile, xopts='', xoptf=None):
+ """Simple driver for class MetaFile.
+
+ Usage:
+ 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.
+
+ -C "CURDIR"
+
+ -O "OBJROOT"
+ add "OBJROOT" to the "OBJROOTS" list.
+
+ -m "MACHINE"
+
+ -H "HOST_TARGET"
+
+ -D "DPDEPS"
+
+ -d bumps debug level
+
+ """
+ import getopt
+
+ # import Psyco if we can
+ # it can speed things up quite a bit
+ have_psyco = 0
+ try:
+ import psyco
+ psyco.full()
+ have_psyco = 1
+ except:
+ pass
+
+ conf = {
+ 'SRCTOPS': [],
+ 'OBJROOTS': [],
+ }
+
+ try:
+ machine = os.environ['MACHINE']
+ if machine:
+ conf['MACHINE'] = machine
+ srctop = os.environ['SB_SRC']
+ if srctop:
+ conf['SRCTOPS'].append(srctop)
+ objroot = os.environ['SB_OBJROOT']
+ if objroot:
+ conf['OBJROOTS'].append(objroot)
+ except:
+ pass
+
+ debug = 0
+ output = True
+
+ opts, args = getopt.getopt(argv[1:], 'dS:C:O:R:m:D:H:q' + xopts)
+ for o, a in opts:
+ if o == '-d':
+ debug += 1
+ elif o == '-q':
+ output = False
+ elif o == '-H':
+ conf['HOST_TARGET'] = a
+ elif o == '-S':
+ if a not in conf['SRCTOPS']:
+ conf['SRCTOPS'].append(a)
+ elif o == '-C':
+ conf['CURDIR'] = a
+ elif o == '-O':
+ if a not in conf['OBJROOTS']:
+ conf['OBJROOTS'].append(a)
+ elif o == '-R':
+ conf['RELDIR'] = a
+ elif o == '-D':
+ conf['DPDEPS'] = a
+ elif o == '-m':
+ conf['MACHINE'] = a
+ elif xoptf:
+ xoptf(o, a, conf)
+
+ conf['debug'] = debug
+
+ # get any var=val assignments
+ eaten = []
+ for a in args:
+ if a.find('=') > 0:
+ k,v = a.split('=')
+ if k in ['SRCTOP','OBJROOT','SRCTOPS','OBJROOTS']:
+ if k == 'SRCTOP':
+ k = 'SRCTOPS'
+ elif k == 'OBJROOT':
+ k = 'OBJROOTS'
+ if v not in conf[k]:
+ conf[k].append(v)
+ else:
+ conf[k] = v
+ eaten.append(a)
+ continue
+ break
+
+ for a in eaten:
+ args.remove(a)
+
+ debug_out = getv(conf, 'debug_out', sys.stderr)
+
+ if debug:
+ print >> debug_out, "config:"
+ print >> debug_out, "psyco=", have_psyco
+ for k,v in conf.items():
+ print >> debug_out, "%s=%s" % (k,v)
+
+ for a in args:
+ m = klass(a, conf)
+
+ if output:
+ print m.dirdeps()
+
+ print m.src_dirdeps('\nsrc:')
+
+ dpdeps = getv(conf, 'DPDEPS')
+ if dpdeps:
+ m.file_depends(open(dpdeps, 'wb'))
+
+ return m
+
+if __name__ == '__main__':
+ try:
+ main(sys.argv)
+ except:
+ # yes, this goes to stdout
+ print "ERROR: ", sys.exc_info()[1]
+ raise
+
diff --git a/contrib/bmake/mk/meta2deps.sh b/contrib/bmake/mk/meta2deps.sh
new file mode 100755
index 0000000..e7ddd82
--- /dev/null
+++ b/contrib/bmake/mk/meta2deps.sh
@@ -0,0 +1,307 @@
+#!/bin/sh
+
+# NAME:
+# meta2deps.sh - extract useful info from .meta files
+#
+# SYNOPSIS:
+# meta2deps.sh SB="SB" "meta" ...
+#
+# DESCRIPTION:
+# This script looks each "meta" file and extracts the
+# information needed to deduce build and src dependencies.
+#
+# To do this, we extract the 'CWD' record as well as all the
+# syscall traces which describe 'R'ead, 'C'hdir and 'E'xec
+# syscalls.
+#
+# The typical meta file looks like::
+#.nf
+#
+# # Meta data file "path"
+# CMD "command-line"
+# CWD "cwd"
+# TARGET "target"
+# -- command output --
+# -- filemon acquired metadata --
+# # buildmon version 2
+# V 2
+# E "pid" "path"
+# R "pid" "path"
+# C "pid" "cwd"
+# R "pid" "path"
+# X "pid" "status"
+#.fi
+#
+# The fact that all the syscall entry lines start with a single
+# character make these files quite easy to process using sed(1).
+#
+# To simplify the logic the 'CWD' line is made to look like a
+# normal 'C'hdir entry, and "cwd" is remembered so that it can
+# be prefixed to any "path" which is not absolute.
+#
+# If the "path" being read ends in '.srcrel' it is the content
+# of (actually the first line of) that file that we are
+# interested in.
+#
+# Any "path" which lies outside of the sandbox "SB" is generally
+# not of interest and is ignored.
+#
+# The output, is a set of absolute paths with "SB" like:
+#.nf
+#
+# $SB/obj-i386/junos/gnu/lib/csu
+# $SB/obj-i386/junos/gnu/lib/libgcc
+# $SB/obj-i386/bsd/include
+# $SB/obj-i386/bsd/lib/csu/i386-elf
+# $SB/obj-i386/bsd/lib/libc
+# $SB/src/bsd/include
+# $SB/src/bsd/sys/i386/include
+# $SB/src/bsd/sys/sys
+# $SB/src/pan-release/rtsock
+# $SB/src/pfe-shared/include/jnx
+#.fi
+#
+# Which can then be further processed by 'gendirdeps.mk'
+#
+# If we are passed 'DPDEPS='"dpdeps", then for each src file
+# outside of "CURDIR" we read, we output a line like:
+#.nf
+#
+# DPDEPS_$path += $RELDIR
+#.fi
+#
+# with "$path" geting turned into reldir's, so that we can end
+# up with a list of all the directories which depend on each src
+# file in another directory. This can allow for efficient yet
+# complete testing of changes.
+
+
+# RCSid:
+# $Id: meta2deps.sh,v 1.4 2012/11/07 06:55:21 sjg Exp $
+
+# Copyright (c) 2010, Juniper Networks, Inc.
+#
+# 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+# OWNER 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.
+
+meta2src() {
+ cat /dev/null "$@" |
+ sed -n '/^R .*\.[chyl]$/s,^..[0-9]* ,,p' |
+ sort -u
+}
+
+meta2dirs() {
+ cat /dev/null "$@" |
+ sed -n '/^R .*\/.*\.[a-z0-9][^\/]*$/s,^..[0-9]* \(.*\)/[^/]*$,\1,p' |
+ sort -u
+}
+
+meta2deps() {
+ DPDEPS=
+ while :
+ do
+ case "$1" in
+ *=*) eval export "$1"; shift;;
+ *) break;;
+ esac
+ done
+
+ [ -z "$RELDIR" ] && unset DPDEPS
+ tf=/tmp/m2d$$-$USER
+ rm -f $tf.*
+ trap 'rm -f $tf.*; trap 0' 0
+
+ > $tf.dirdep
+ > $tf.qual
+ > $tf.srcdep
+ > $tf.srcrel
+ > $tf.dpdeps
+
+ seenit=
+ seensrc=
+ lpid=
+ cat /dev/null "$@" |
+ sed -e 's,^CWD,C C,;/^[CREFL] /!d' -e "s,',,g" |
+ while read op pid path junk
+ do
+ : op=$op pid=$pid path=$path
+ # we track cwd and ldir (of interest) per pid
+ # CWD is bmake's cwd
+ case "$lpid,$pid" in
+ ,C) CWD=$path cwd=$path ldir=$path
+ if [ -z "$SB" ]; then
+ SB=`echo $CWD | sed 's,/obj.*,,'`
+ fi
+ SRCTOP=${SRCTOP:-$SB/src}
+ continue
+ ;;
+ $pid,$pid) ;;
+ *)
+ case "$lpid" in
+ "") ;;
+ *) eval ldir_$lpid=$ldir cwd_$lpid=$cwd;;
+ esac
+ eval ldir=\${ldir_$pid:-$CWD} cwd=\${cwd_$pid:-$CWD}
+ lpid=$pid
+ ;;
+ esac
+
+ case "$op,$path" in
+ *.dirdep) continue;;
+ W,*srcrel) continue;;
+ C,*)
+ case "$path" in
+ /*) cwd=$path;;
+ *) cwd=`cd $cwd/$path 2> /dev/null && /bin/pwd`;;
+ esac
+ # watch out for temp dirs that no longer exist
+ test -d ${cwd:-/dev/null/no/such} || cwd=$CWD
+ continue
+ ;;
+ F,*) eval cwd_$path=$cwd ldir_$path=$ldir
+ continue
+ ;;
+ *) dir=${path%/*}
+ case "$path" in
+ $SB/*|${SB_BACKING_SB:-$SB}/*) ;;
+ $SB_OBJROOT*) ;;
+ /*/stage/*) ;;
+ /*) continue;;
+ *) for path in $ldir/$path $cwd/$path
+ do
+ test -e $path && break
+ done
+ dir=${path%/*}
+ ;;
+ esac
+ ;;
+ esac
+ # avoid repeating ourselves...
+ case "$DPDEPS,$seensrc," in
+ ,*)
+ case ",$seenit," in
+ *,$dir,*) continue;;
+ esac
+ ;;
+ *,$path,*) continue;;
+ esac
+ # canonicalize if needed
+ case "/$dir/" in
+ */../*|*/./*)
+ rdir=$dir
+ dir=`cd $dir 2> /dev/null && /bin/pwd`
+ seen="$rdir,$dir"
+ ;;
+ *) seen=$dir;;
+ esac
+ case "$dir" in
+ ${CURDIR:-.}|${CURDIR:-.}/*|"") continue;;
+ $SRCTOP/*|${SB_BACKING_SB:-$SB}/src/*)
+ # avoid repeating ourselves...
+ case "$DPDEPS,$seensrc," in
+ ,*)
+ case ",$seenit," in
+ *,$dir,*) continue;;
+ esac
+ ;;
+ esac
+ ;;
+ *)
+ case ",$seenit," in
+ *,$dir,*) continue;;
+ esac
+ ;;
+ esac
+ if [ -d $path ]; then
+ case "$path" in
+ */..) ldir=${dir%/*};;
+ *) ldir=$path;;
+ esac
+ continue
+ fi
+ [ -f $path ] || continue
+ case "$dir" in
+ $CWD) continue;; # ignore
+ $SRCTOP/*|${SB_BACKING_SB:-$SB}/src/*)
+ seenit="$seenit,$seen"
+ echo $dir >> $tf.srcdep
+ case "$DPDEPS,$reldir,$seensrc," in
+ ,*) ;;
+ *) seensrc="$seensrc,$path"
+ echo "DPDEPS_$dir/${path##*/} += $RELDIR" >> $tf.dpdeps
+ ;;
+ esac
+ continue
+ ;;
+ esac
+ # if there is a .dirdep we cannot skip
+ # just because we've seen the dir before.
+ if [ -s $path.dirdep ]; then
+ # this file contains:
+ # '# ${RELDIR}.<machine>'
+ echo $path.dirdep >> $tf.qual
+ continue
+ elif [ -s $dir.dirdep ]; then
+ echo $dir.dirdep >> $tf.qual
+ seenit="$seenit,$seen"
+ continue
+ fi
+ seenit="$seenit,$seen"
+ case "$dir" in
+ $SB/*|${SB_OBJROOT:-$SB/}*|${SB_BACKING_SB:-$SB}/*)
+ echo $dir;;
+ esac
+ done > $tf.dirdep
+ _nl=echo
+ for f in $tf.dirdep $tf.qual $tf.srcdep
+ do
+ [ -s $f ] || continue
+ case $f in
+ *qual) # a list of .dirdep files
+ # we can prefix everthing with $OBJTOP to
+ # tell gendirdeps.mk that these are
+ # DIRDEP entries, since they are already
+ # qualified with .<machine> as needed.
+ # We strip .$MACHINE though
+ xargs cat < $f | sort -u |
+ sed "s,^# ,,;s,^,$OBJTOP/,;s,\.$MACHINE\$,,"
+ ;;
+ *) sort -u $f;;
+ esac
+ _nl=:
+ done
+ if [ -s $tf.dpdeps ]; then
+ case "$DPDEPS" in
+ */*) ;;
+ *) echo > $DPDEPS;; # the echo is needed!
+ esac
+ sort -u $tf.dpdeps |
+ sed "s,${SRCTOP}/,,;s,${SB_BACKING_SB:-$SB}/src/,," >> $DPDEPS
+ fi
+ # ensure we produce _something_ else egrep -v gets upset
+ $_nl
+}
+
+case /$0 in
+*/meta2dep*) meta2deps "$@";;
+*/meta2dirs*) meta2dirs "$@";;
+*/meta2src*) meta2src "$@";;
+esac
diff --git a/contrib/bmake/mk/mk-files.txt b/contrib/bmake/mk/mk-files.txt
new file mode 100644
index 0000000..7882641
--- /dev/null
+++ b/contrib/bmake/mk/mk-files.txt
@@ -0,0 +1,467 @@
+mk-files
+********
+
+The term ``mk-files`` refers to a collection of ``*.mk`` files.
+
+You need bmake_ or a *recent* NetBSD_ make.
+If in doubt use bmake_.
+
+Introduction
+============
+
+Many years ago, when building large software projects, I used GNU make
+(or my own patched version of it), and had developed a set of macros
+to simplify developing complex build trees.
+
+Since the early 90's my main development machines, run BSD
+(NetBSD_ to be precise), and the BSD source tree is good example of a
+large software project. It quickly became clear that
+``/usr/share/mk/*.mk`` were a great model, but were quite tightly
+linked to building the BSD tree.
+
+Much as I liked using NetBSD, my customers were more likely to be
+using SunOS, HP-UX etc, so I started on bmake_ and a portable collection
+of mk-files (mk.tar.gz_). NetBSD provided much of the original structure.
+
+Since then I've added a lot of features to NetBSD's make and hence to
+bmake which is kept closely in sync. The mk-files however have
+diverged quite a bit, though ideas are still picked up from NetBSD.
+
+Basics
+------
+
+The BSD build model is very simple. A directory produces one
+component, which is generally either a library or a program.
+Library makefiles include ``lib.mk`` and programs include ``prog.mk``
+and they *do the right thing*.
+
+A simple library makefile might look like::
+
+ LIB = sig
+
+ SRCS = \
+ sigaction.c \
+ sigcompat.c \
+ sighdl.c
+
+ .include <lib.mk>
+
+a simple program makefile::
+
+ PROG = cat
+
+ SRCS = cat.c
+
+ .include <prog.mk>
+
+in such cases even the ``SRCS`` line is unnecessary as ``prog.mk``
+will default it to ``${PROG}.c``.
+
+It is the sensible use of defaults and the plethora of macro modifiers
+provided by bmake_ that allow simple makefiles such as the above
+*just work* on many different systems.
+
+
+mk-files
+========
+
+This section provides a brief description of some of the ``*.mk``
+files.
+
+sys.mk
+------
+
+When bmake starts, it looks for ``sys.mk`` and reads it before doing
+anything else. Thus, this is the place to setup the environment for
+everyone else.
+
+In this distribution, sys.mk avoids doing anything platform dependent.
+It is quite short, and includes a number of other files (which may or
+may not exists)
+
+sys.env.mk
+ If it exists, is expected to do things like conditioning the
+ environment. Since it will only be included by the initial
+ instance of bmake, it should ``.export`` anything that
+ sub-makes might need.
+
+examples/sys.clean-env.mk
+ An example of how to clean the environment.
+ See the file for all the details::
+
+ .if ${MAKE_VERSION} >= 20100606 && ${.MAKE.LEVEL} == 0
+ # we save any env var that starts with these
+ MAKE_SAVE_ENV_PREFIX += SB MK MAKE MACHINE NEED_ CCACHE DISTCC USE_ SSH
+ MAKE_SAVE_ENV_VARS += \
+ PATH HOME USER LOGNAME \
+ SRCTOP OBJTOP OBJROOT \
+ ${_env_vars}
+
+ _env_vars != env | egrep '^(${MAKE_SAVE_ENV_PREFIX:ts|})' | sed 's,=.*,,'; echo
+ _export_list =
+ .for v in ${MAKE_SAVE_ENV_VARS:O:u}
+ .if !empty($v)
+ _export_list += $v
+ $v := ${$v}
+ .endif
+ .endfor
+ # now clobber the environment
+ .unexport-env
+
+ # list of vars that we handle specially below
+ _tricky_env_vars = MAKEOBJDIR
+ # export our selection - sans tricky ones
+ .export ${_export_list:${_tricky_env_vars:${M_ListToSkip}}}
+
+ # this next bit may need tweaking
+ .if defined(MAKEOBJDIR)
+ srctop := ${SRCTOP:U${SB_SRC:U${SB}/src}}
+ objroot := ${OBJROOT:U${SB_OBJROOT:U${SB}/${SB_OBJPREFIX}}}
+ # we'll take care of MACHINE below
+ objtop := ${OBJTOP:U${objroot}${MACHINE}}
+ .if !empty(objtop)
+ # we would normally want something like (/bin/sh):
+ # MAKEOBJDIR="\${.CURDIR:S,${SRCTOP},${OBJROOT}\${MACHINE},}"
+ # the $$ below is how we achieve the same result here.
+ # since everything saved from the environment above
+ # has run through := we need to compensate for ${MACHINE}
+ MAKEOBJDIR = $${.CURDIR:S,${srctop},${objtop:S,${MACHINE},\${MACHINE},},}
+
+ # export these as-is, and do not track...
+ .export-env ${_tricky_env_vars}
+ # now evaluate for ourselves
+ .for v in ${_tricky_env_vars}
+ $v := ${$v}
+ .endfor
+
+ .endif
+ .endif
+ .endif
+
+
+host-target.mk
+ Is used to set macros like ``HOST_TARGET``, ``HOST_OS`` and
+ ``host_os`` which are used to find the next step.
+
+sys/\*.mk
+ Platform specific additions, such as ``Darwin.mk`` or ``SunOS.mk``
+ set things like ``HOST_LIBEXT = .dylib`` for Darwin or
+ ``SHLIB_FULLVERSION = ${SHLIB_MAJOR}`` for SunOS 5.
+ If there is no OS specific file, ``sys/Generic.mk`` is used.
+
+local.sys.mk
+ Any ``local.*.mk`` file is not part of the distribution.
+ This provides a hook for sites to do extra setup without
+ having to edit the distributed files.
+
+
+The above arrangement makes it easy for the mk files to be part of a
+src tree on an NFS volume and to allow building on multiple platforms.
+
+lib.mk
+------
+
+This file is used to build a number of different libraries from the
+same SRCS.
+
+lib${LIB}.a
+ An archive lib of ``.o`` files, this is the default
+
+lib${LIB}_p.a
+ A profiled lib of ``.po`` files.
+ Still an archive lib, but all the objects are built with
+ profiling in mind - hence the different extension.
+ It is skipped if ``MKPROFILE`` is "no".
+
+lib${LIB}_pic.a
+ An archive of ``.so`` objects compiled for relocation.
+ On NetBSD this is the input to ``lib${LIB}.${LD_so}``, it is
+ skipped if ``MKPICLIB`` is "no".
+
+lib${LIB}.${LD_so}
+ A shared library. The value of ``LD_so`` is very platform
+ specific. For example::
+
+ # SunOS 5 and most other ELF systems
+ libsslfd.so.1
+
+ # Darwin
+ libsslfd.1.dylib
+
+ This library will only be built if ``SHLIB_MAJOR`` has
+ a value, and ``MKPIC`` is not set to "no".
+
+There is a lot of platform specific tweaking in ``lib.mk``, largely the
+result of the original distributions trying to avoid interfering with
+the system's ``sys.mk``.
+
+libnames.mk
+-----------
+
+This is included by both ``prog.mk`` and ``lib.mk`` and tries to
+include ``*.libnames.mk`` of which:
+
+local.libnames.mk
+ does not exist unless you create it. It is a handy way for you
+ to customize without touching the distributed files.
+ For example, on a test machine I needed to build openssl but
+ not install it, so put the following in ``local.libnames.mk``::
+
+ .if ${host_os} == "sunos"
+ LIBCRYPTO = ${OBJTOP}/openssl/lib/crypto/libcrypto${DLIBEXT}
+ LIBSSL = ${OBJTOP}/openssl/lib/ssl/libssl${DLIBEXT}
+ INCLUDES_libcrypto = -I${OBJ_libcrypto}
+ .endif
+
+ The makefile created an openssl dir in ``${OBJ_libcrypto}`` to
+ gather all the headers. dpadd.mk_ did the rest.
+
+sjg.libnames.mk
+ not part of the mk-files distribution.
+
+host.libnames.mk
+ contains logic to find any libs named in ``HOST_LIBS`` in
+ ``HOST_LIBDIRS``.
+
+Each file above gets an opportunity to define things like::
+
+ LIBSSLFD ?= ${OBJTOP}/ssl/lib/sslfd/libsslfd${DLIBEXT}
+ INCLUDES_libsslfd = -I${SRC_libsslfd}/h -I${OBJ_libslfd}
+
+these are used by dpadd.mk_ and will be explained below.
+
+dpadd.mk
+--------
+
+This file looks like line noise, and is best considered read-only.
+However it provides some very useful functionality, which simplifies the build.
+
+Makefiles can use the LIB* macros defined via libnames.mk_ or anywhere
+else in various ways::
+
+ # indicate that we need to include headers from LIBCRYPTO
+ # this would result in ${INCLUDES_libcrypto} being added to CFLAGS.
+ SRC_LIBS += ${LIBCRYPTO}
+
+ # indicate that libsslfd must be built already.
+ # it also has the same effect as SRC_LIBS
+ DPADD += ${LIBSSLFD}
+
+ # indicate that not only must libsslfd be built,
+ # but that we need to link with it.
+ # this is almost exactly equivalent to
+ # DPADD += ${LIBSSLFD}
+ # LDADD += -L${LIBSSLFD:H} -lsslfd
+ # and mostly serves to ensure that DPADD and LDADD are in sync.
+ DPLIBS += ${LIBSSLFD}
+
+Any library (referenced by its full path) in any of the above, is
+added to ``DPMAGIC_LIBS`` with the following results, for each lib *foo*.
+
+SRC_libfoo
+ Is set to indicate where the src for libfoo is.
+ By default it is derived from ``LIBFOO`` by replacing
+ ``${OBJTOP}`` with ``${SRCTOP}``.
+
+OBJ_libfoo
+ Not very exciting, is just the dir where libfoo lives.
+
+INCLUDES_libfoo
+ What to add to ``CFLAGS`` to find the public headers.
+ The default varies. If ``${SRC_libfoo}/h`` exists, it is assumed
+ to be the home of all public headers and thus the default is
+ ``-I${SRC_libfoo}/h``
+
+ Otherwise we make no assumptions and the default is
+ ``-I${SRC_libfoo} -I${OBJ_libfoo}``
+
+LDADD_libfoo
+ This only applies to libs reference via ``DPLIBS``.
+ The default is ``-lfoo``, ``LDADD_*`` provides a hook to
+ instantiate other linker flags at the appropriate point
+ without losing the benfits of ``DPLIBS``.
+
+prog.mk
+-------
+
+Compiles the specified SRCS and links them and the nominated libraries
+into a program. Prog makefiles usually need to list the libraries
+that need to be linked. We prefer use of ``DPLIBS`` but the more
+traditional ``DPADD`` and ``LDADD`` work just as well.
+That is::
+
+ DPLIBS += ${LIBCRYPTO}
+
+is equivalent to::
+
+ DPADD += ${LIBCRYPTO}
+ LDADD += -lcrypto
+
+obj.mk
+------
+
+One of the cool aspects of BSD make, is its support for separating
+object files from the src tree. This is also the source of much
+confusion to some.
+
+Traditionally one had to do a separate ``make obj`` pass through the
+tree. If ``MKOBJDIRS`` is "auto", we include auto.obj.mk_.
+
+auto.obj.mk
+-----------
+
+This leverages the ``.OBJDIR`` target introduced some years ago to
+NetBSD make, to automatically create the desired object dir.
+
+subdir.mk
+---------
+
+This is the traditional means of walking the tree. A makefile sets
+``SUBDIR`` to the list of sub-dirs to visit.
+
+If ``SUBDIR_MUST_EXIST`` is set, missing directories cause an error,
+otherwise a warning is issued. If you don't even want the warning,
+set ``MISSING_DIR=continue``.
+
+Traditionally, ``subdir.mk`` prints clue as it visits each subdir::
+
+ ===> ssl
+ ===> ssl/lib
+ ===> ssl/lib/sslfd
+
+you can suppress that - or enhance it by setting ``ECHO_DIR``::
+
+ # suppress subdir noise
+ ECHO_DIR=:
+ # print time stamps
+ ECHO_DIR=echo @ `date "+%s [%Y-%m-%d %T] "`
+
+links.mk
+--------
+
+Provides rules for processing lists of ``LINKS`` and ``SYMLINKS``.
+Each is expected to be a list of ``link`` and ``target`` pairs
+(``link`` -> ``target``).
+
+The logic is generally in a ``_*_SCRIPT`` which is referenced in a
+``_*_USE`` (``.USE``) target.
+
+The ``_BUILD_*`` forms are identical, but do not use ``${DESTDIR}``
+and so are useful for creating symlinks during the build phase.
+For example::
+
+ SYMLINKS += ${.CURDIR}/${MACHINE_ARCH}/include machine
+ header_links: _BUILD_SYMLINKS_USE
+
+ md.o: header_links
+
+would create a symlink called ``machine`` in ``${.OBJDIR}`` pointing to
+``${.CURDIR}/${MACHINE_ARCH}/include`` before compiling ``md.o``
+
+
+autoconf.mk
+-----------
+
+Deals with running (or generating) GNU autoconf ``configure`` scripts.
+
+dep.mk
+------
+
+Deals with collecting dependencies. Another useful feature of BSD
+make is the separation of this sort of information into a ``.depend``
+file. ``MKDEP`` needs to point to a suitable tool (like mkdeps.sh_)
+
+If ``USE_AUTODEP_MK`` is "yes" includes autodep.mk_
+
+autodep.mk
+----------
+
+Leverages the ``-MD`` feature of recent GCC to collect dependency
+information as a side effect of compilation. With this GCC puts
+dependency info into a ``.d`` file.
+
+Unfortunately GCC bases the name of the ``.d`` file on the name of the
+input rather than the output file, which causes problems when the same
+source is compiled different ways. The latest GCC supports ``-MF`` to
+name the ``.d`` file and ``-MT`` to control the name to put as the
+dependent.
+
+Recent bmake allows dependencies for the ``.END`` target (run at the
+end if everything was successful), and ``autodep.mk`` uses this to
+post process the ``.d`` files into ``.depend``.
+
+auto.dep.mk
+-----------
+
+A much simpler implementation than autodep.mk_ it uses
+``-MF ${.TARGET:T}.d``
+to avoid possible conflicts during parallel builds.
+This precludes the use of suffix rules to drive ``make depend``, so
+dep.mk_ handles that if specifically requested.
+
+own.mk
+------
+
+Normally included by ``init.mk`` (included by ``lib.mk`` and
+``prog.mk`` etc), sets macros for default ownership etc.
+
+It includes ``${MAKECONF}`` if it is defined and exists.
+
+man.mk
+------
+
+Deals with man pages.
+
+warnings.mk
+-----------
+
+This provides a means of fine grained control over warnings on a per
+``${MACHINE}`` or even file basis.
+
+A makefile sets ``WARNINGS_SET`` to name a list of warnings
+and individual ``W_*`` macros can be used to tweak them.
+For example::
+
+ WARNINGS_SET = HIGH
+ W_unused_sparc = -Wno-unused
+
+would add all the warnings in ``${HIGH_WARNINGS}`` to CFLAGS, but
+on sparc, ``-Wno-unused`` would replace ``-Wunused``.
+
+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.
+
+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`_.
+
+.. _`meta mode`: bmake-meta-mode.htm
+
+Install
+=======
+
+You can use the content of mk.tar.gz_ without installing at all.
+
+The script ``install-mk`` takes care of copying ``*.mk`` into a
+destination directory, and unless told not to, create ``bsd.*.mk`` links
+for ``lib.mk`` etc.
+
+If you just want to create the ``bsd.*.mk`` links in the directory
+where you unpacked the tar file, you can::
+
+ ./mk/install-mk ./mk
+
+------
+
+.. _bmake: bmake.htm
+.. _NetBSD: http://www.netbsd.org/
+.. _mkdeps.sh: http://www.crufty.net/ftp/pub/sjg/mkdeps.sh
+.. _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 $
+:Copyright: Crufty.NET
diff --git a/contrib/bmake/mk/nls.mk b/contrib/bmake/mk/nls.mk
new file mode 100644
index 0000000..e302c8d
--- /dev/null
+++ b/contrib/bmake/mk/nls.mk
@@ -0,0 +1,48 @@
+# $NetBSD: bsd.nls.mk,v 1.3 1996/10/18 02:34:45 thorpej Exp $
+
+.if !target(.MAIN)
+.if exists(${.CURDIR}/../Makefile.inc)
+.include "${.CURDIR}/../Makefile.inc"
+.endif
+
+.MAIN: all
+.endif
+
+.SUFFIXES: .cat .msg
+
+.msg.cat:
+ @rm -f ${.TARGET}
+ gencat ${.TARGET} ${.IMPSRC}
+
+.if defined(NLS) && !empty(NLS)
+NLSALL= ${NLS:.msg=.cat}
+.NOPATH: ${NLSALL}
+.endif
+
+.if !defined(NLSNAME)
+.if defined(PROG)
+NLSNAME=${PROG}
+.else
+NLSNAME=lib${LIB}
+.endif
+.endif
+
+nlsinstall:
+.if defined(NLSALL)
+ @for msg in ${NLSALL}; do \
+ NLSLANG=`basename $$msg .cat`; \
+ dir=${DESTDIR}${NLSDIR}/$${NLSLANG}; \
+ ${INSTALL} -d $$dir; \
+ ${INSTALL} ${COPY} -o ${NLSOWN} -g ${NLSGRP} -m ${NLSMODE} $$msg $$dir/${NLSNAME}.cat; \
+ done
+.endif
+
+.if defined(NLSALL)
+all: ${NLSALL}
+
+install: nlsinstall
+
+cleandir: cleannls
+cleannls:
+ rm -f ${NLSALL}
+.endif
diff --git a/contrib/bmake/mk/obj.mk b/contrib/bmake/mk/obj.mk
new file mode 100644
index 0000000..b936379
--- /dev/null
+++ b/contrib/bmake/mk/obj.mk
@@ -0,0 +1,113 @@
+# $Id: obj.mk,v 1.15 2012/11/11 22:37:02 sjg Exp $
+#
+# @(#) Copyright (c) 1999-2010, 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 !target(__${.PARSEFILE:S,bsd.,,}__)
+__${.PARSEFILE:S,bsd.,,}__:
+
+.include <init.mk>
+
+ECHO_TRACE ?= echo
+
+.if ${MK_OBJDIRS} == "no"
+obj:
+objlink:
+objwarn:
+.else
+
+# this has to match how make behaves
+.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
+.if defined(MAKEOBJDIRPREFIX)
+__objdir:= ${MAKEOBJDIRPREFIX}${.CURDIR}
+.else
+__objdir:= ${MAKEOBJDIR}
+.endif
+.else
+__objdir= ${__objlink}
+.endif
+
+.if defined(OBJMACHINE)
+__objlink= obj.${MACHINE}
+.else
+__objlink= obj
+.endif
+
+.if ${MK_AUTO_OBJ} == "yes"
+.-include "auto.obj.mk"
+.endif
+
+.NOPATH: ${__objdir}
+.PHONY: obj
+
+obj: _SUBDIRUSE
+ @if test ! -d ${__objdir}/.; then \
+ mkdir -p ${__objdir}; \
+ if test ! -d ${__objdir}; then \
+ mkdir ${__objdir}; exit 1; \
+ fi; \
+ ${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \
+ fi
+
+.if !target(_SUBDIRUSE)
+# this just allows us to be included by ourselves
+_SUBDIRUSE:
+.endif
+
+# so we can interact with freebsd makefiles
+.if !target(objwarn)
+objwarn:
+.if ${.OBJDIR} == ${.CURDIR}
+ @echo "Warning Object directory is ${.CURDIR}"
+.elif ${.OBJDIR} != ${__objdir}
+ @echo "Warning Object directory is ${.OBJDIR} vs. ${__objdir}"
+.endif
+.endif
+
+.if !target(objlink)
+objlink:
+.if ${__objdir:T} != ${__objlink}
+ @if test -d ${__objdir}/.; then \
+ ${RM} -f ${.CURDIR}/${__objlink}; \
+ ${LN} -s ${__objdir} ${.CURDIR}/${__objlink}; \
+ echo "${__objlink} -> ${__objdir}"; \
+ else \
+ echo "No ${__objdir} to link to - do a 'make obj'"; \
+ fi
+.endif
+.endif
+.endif
+
+_CURDIR?= ${.CURDIR}
+_OBJDIR?= ${.OBJDIR}
+
+.if !target(print-objdir)
+print-objdir:
+ @echo ${_OBJDIR}
+.endif
+
+.if !target(whereobj)
+whereobj:
+ @echo ${_OBJDIR}
+.endif
+
+.if !target(destroy)
+.if ${.CURDIR} != ${.OBJDIR}
+destroy:
+ (cd ${_CURDIR} && rm -rf ${_OBJDIR})
+.else
+destroy: clean
+.endif
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/options.mk b/contrib/bmake/mk/options.mk
new file mode 100644
index 0000000..7d1bf67
--- /dev/null
+++ b/contrib/bmake/mk/options.mk
@@ -0,0 +1,58 @@
+# $Id: options.mk,v 1.6 2013/01/28 19:28:52 sjg Exp $
+#
+# @(#) Copyright (c) 2012, 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
+#
+
+# Inspired by FreeBSD bsd.own.mk, but intentionally simpler.
+
+# Options are normally listed in either OPTIONS_DEFAULT_{YES,NO}
+# We convert these to ${OPTION}/{yes,no} in OPTIONS_DEFAULT_VALUES.
+# We add the OPTIONS_DEFAULT_NO first so they take precedence.
+# This allows override of an OPTIONS_DEFAULT_YES by adding it to
+# OPTIONS_DEFAULT_NO or adding ${OPTION}/no to OPTIONS_DEFAULT_VALUES.
+# An OPTIONS_DEFAULT_NO option can only be overridden by putting
+# ${OPTION}/yes in OPTIONS_DEFAULT_VALUES.
+# A makefile may set NO_* (or NO*) to indicate it cannot do something.
+# User sets WITH_* and WITHOUT_* to indicate what they want.
+# We set MK_* which is then all we need care about.
+OPTIONS_DEFAULT_VALUES += \
+ ${OPTIONS_DEFAULT_NO:O:u:S,$,/no,} \
+ ${OPTIONS_DEFAULT_YES:O:u:S,$,/yes,}
+
+.for o in ${OPTIONS_DEFAULT_VALUES:M*/*}
+.if ${o:T:tl} == "no"
+.if defined(WITH_${o:H}) && !defined(NO_${o:H}) && !defined(NO${o:H})
+MK_${o:H} ?= yes
+.else
+MK_${o:H} ?= no
+.endif
+.else
+.if defined(WITHOUT_${o:H}) || defined(NO_${o:H}) || defined(NO${o:H})
+MK_${o:H} ?= no
+.else
+MK_${o:H} ?= yes
+.endif
+.endif
+.endfor
+
+# OPTIONS_DEFAULT_DEPENDENT += FOO_UTILS/FOO
+# if neither WITH[OUT]_FOO_UTILS is set, use value of MK_FOO
+.for o in ${OPTIONS_DEFAULT_DEPENDENT:M*/*:O:u}
+.if defined(WITH_${o:H}) && !defined(NO_${o:H}) && !defined(NO${o:H})
+MK_${o:H} ?= yes
+.elif defined(WITHOUT_${o:H}) || defined(NO_${o:H}) || defined(NO${o:H})
+MK_${o:H} ?= no
+.else
+MK_${o:H} ?= ${MK_${o:T}}
+.endif
+.endfor
diff --git a/contrib/bmake/mk/own.mk b/contrib/bmake/mk/own.mk
new file mode 100644
index 0000000..85ea66b
--- /dev/null
+++ b/contrib/bmake/mk/own.mk
@@ -0,0 +1,244 @@
+# $Id: own.mk,v 1.26 2012/12/11 23:40:19 sjg Exp $
+
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+.if !target(__init.mk__)
+.include "init.mk"
+.endif
+
+.ifndef NOMAKECONF
+MAKECONF?= /etc/mk.conf
+.-include "${MAKECONF}"
+.endif
+
+.include <host-target.mk>
+
+TARGET_OSNAME?= ${_HOST_OSNAME}
+TARGET_OSREL?= ${_HOST_OSREL}
+TARGET_OSTYPE?= ${HOST_OSTYPE}
+TARGET_HOST?= ${HOST_TARGET}
+
+# these may or may not exist
+.-include "${TARGET_HOST}.mk"
+.-include "config.mk"
+
+RM?= rm
+LN?= ln
+INSTALL?= install
+
+prefix?= /usr
+.if exists(${prefix}/lib)
+libprefix?= ${prefix}
+.else
+libprefix?= /usr
+.endif
+
+# FreeBSD at least does not set this
+MACHINE_ARCH?=${MACHINE}
+# we need to make sure these are defined too in case sys.mk fails to.
+COMPILE.s?= ${CC} ${AFLAGS} -c
+LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
+LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+CXXFLAGS?= ${CFLAGS}
+COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
+LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.f?= ${FC} ${FFLAGS} -c
+LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+LEX.l?= ${LEX} ${LFLAGS}
+COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+YACC.y?= ${YACC} ${YFLAGS}
+
+# for suffix rules
+IMPFLAGS?= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}}
+.for s in .c .cc
+COMPILE.$s += ${IMPFLAGS}
+LINK.$s += ${IMPFLAGS}
+.endfor
+
+PRINT.VAR.MAKE = MAKESYSPATH=${MAKESYSPATH:U${.PARSEDIR}} ${.MAKE}
+.if empty(.MAKEFLAGS:M-V*)
+.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
+PRINTOBJDIR= ${PRINT.VAR.MAKE} -r -V .OBJDIR -f /dev/null xxx
+.else
+PRINTOBJDIR= ${PRINT.VAR.MAKE} -V .OBJDIR
+.endif
+.else
+PRINTOBJDIR= echo # prevent infinite recursion
+.endif
+
+# we really like to have SRCTOP and OBJTOP defined...
+.if !defined(SRCTOP) || !defined(OBJTOP)
+.-include "srctop.mk"
+.endif
+
+.if !defined(SRCTOP) || !defined(OBJTOP)
+# dpadd.mk is rather pointless without these
+OPTIONS_DEFAULT_NO+= DPADD_MK
+.endif
+
+# process options
+OPTIONS_DEFAULT_NO+= \
+ INSTALL_AS_USER \
+ LIBTOOL \
+ LINT \
+ META_MODE \
+
+OPTIONS_DEFAULT_YES+= \
+ ARCHIVE \
+ AUTODEP \
+ AUTO_OBJ \
+ CRYPTO \
+ DOC \
+ DPADD_MK \
+ GDB \
+ KERBEROS \
+ LINKLIB \
+ MAN \
+ NLS \
+ OBJ \
+ PIC \
+ SHARE \
+ SKEY \
+ YP \
+
+OPTIONS_DEFAULT_DEPENDENT+= \
+ CATPAGES/MAN \
+ OBJDIRS/OBJ \
+ PICINSTALL/LINKLIB \
+ PICLIB/PIC \
+ PROFILE/LINKLIB \
+
+.include <options.mk>
+
+.if ${MK_INSTALL_AS_USER} == "yes"
+# We ignore this if user is root.
+_uid!= id -u
+.if ${_uid} != 0
+.if !defined(USERGRP)
+USERGRP!= id -g
+.export USERGRP
+.endif
+.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
+$xOWN= ${USER}
+$xGRP= ${USERGRP}
+.endfor
+.endif
+.endif
+
+# override this in sys.mk
+ROOT_GROUP?= wheel
+BINGRP?= ${ROOT_GROUP}
+BINOWN?= root
+BINMODE?= 555
+NONBINMODE?= 444
+
+# Define MANZ to have the man pages compressed (gzip)
+#MANZ= 1
+
+MANTARGET?= cat
+MANDIR?= ${prefix}/share/man/${MANTARGET}
+MANGRP?= ${BINGRP}
+MANOWN?= ${BINOWN}
+MANMODE?= ${NONBINMODE}
+
+LIBDIR?= ${libprefix}/lib
+SHLIBDIR?= ${libprefix}/lib
+.if ${USE_SHLIBDIR:Uno} == "yes"
+_LIBSODIR?= ${SHLIBDIR}
+.else
+_LIBSODIR?= ${LIBDIR}
+.endif
+# this is where ld.*so lives
+SHLINKDIR?= /usr/libexec
+LINTLIBDIR?= ${libprefix}/libdata/lint
+LIBGRP?= ${BINGRP}
+LIBOWN?= ${BINOWN}
+LIBMODE?= ${NONBINMODE}
+
+DOCDIR?= ${prefix}/share/doc
+DOCGRP?= ${BINGRP}
+DOCOWN?= ${BINOWN}
+DOCMODE?= ${NONBINMODE}
+
+NLSDIR?= ${prefix}/share/nls
+NLSGRP?= ${BINGRP}
+NLSOWN?= ${BINOWN}
+NLSMODE?= ${NONBINMODE}
+
+KMODDIR?= ${prefix}/lkm
+KMODGRP?= ${BINGRP}
+KMODOWN?= ${BINOWN}
+KMODMODE?= ${NONBINMODE}
+
+COPY?= -c
+STRIP_FLAG?= -s
+
+.if ${TARGET_OSNAME} == "NetBSD"
+.if exists(/usr/libexec/ld.elf_so)
+OBJECT_FMT=ELF
+.endif
+OBJECT_FMT?=a.out
+.endif
+# sys.mk should set something appropriate if need be.
+OBJECT_FMT?=ELF
+
+.if (${_HOST_OSNAME} == "FreeBSD")
+CFLAGS+= ${CPPFLAGS}
+.endif
+
+# allow for per target flags
+# apply the :T:R first, so the more specific :T can override if needed
+CPPFLAGS += ${CPPFLAGS_${.TARGET:T:R}} ${CPPFLAGS_${.TARGET:T}}
+CFLAGS += ${CFLAGS_${.TARGET:T:R}} ${CFLAGS_${.TARGET:T}}
+
+# Define SYS_INCLUDE to indicate whether you want symbolic links to the system
+# source (``symlinks''), or a separate copy (``copies''); (latter useful
+# in environments where it's not possible to keep /sys publicly readable)
+#SYS_INCLUDE= symlinks
+
+# don't try to generate PIC versions of libraries on machines
+# which don't support PIC.
+.if (${MACHINE_ARCH} == "vax") || \
+ ((${MACHINE_ARCH} == "mips") && defined(STATIC_TOOLCHAIN)) || \
+ ((${MACHINE_ARCH} == "alpha") && defined(ECOFF_TOOLCHAIN))
+MK_PIC=no
+.endif
+
+# No lint, for now.
+NOLINT=
+
+
+.if ${MK_LINKLIB} == "no"
+MK_PICINSTALL= no
+MK_PROFILE= no
+.endif
+
+.if ${MK_MAN} == "no"
+MK_CATPAGES= no
+.endif
+
+.if ${MK_OBJ} == "no"
+MK_OBJDIRS= no
+MK_AUTO_OBJ= no
+.endif
+
+.if ${MK_SHARE} == "no"
+MK_CATPAGES= no
+MK_DOC= no
+MK_INFO= no
+MK_MAN= no
+MK_NLS= no
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/prlist.mk b/contrib/bmake/mk/prlist.mk
new file mode 100644
index 0000000..09d7dfd
--- /dev/null
+++ b/contrib/bmake/mk/prlist.mk
@@ -0,0 +1,36 @@
+# $Id: prlist.mk,v 1.3 2008/07/17 16:24:57 sjg Exp $
+#
+# @(#) Copyright (c) 2006, 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 !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+# this needs to be included after all the lists it will process
+# are defined - which is why it is a separate file.
+# Usage looks like:
+# MAKEFLAGS= ${.MAKE} -f ${MAKEFILE} prlist.SOMETHING_HUGE | xargs whatever
+#
+.if make(prlist.*)
+.for t in ${.TARGETS:Mprlist.*:E}
+.if empty($t)
+prlist.$t:
+.else
+prlist.$t: ${$t:O:u:S,^,prlist-,}
+${$t:O:u:S,^,prlist-,}: .PHONY
+ @echo "${.TARGET:S,prlist-,,}"
+.endif
+.endfor
+.endif
+
+.endif
diff --git a/contrib/bmake/mk/prog.mk b/contrib/bmake/mk/prog.mk
new file mode 100644
index 0000000..99fd7e8
--- /dev/null
+++ b/contrib/bmake/mk/prog.mk
@@ -0,0 +1,219 @@
+# $Id: prog.mk,v 1.24 2012/12/13 23:04:14 sjg Exp $
+
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
+.include <init.mk>
+
+# FreeBSD at least expects MAN8 etc.
+.if defined(MAN) && !empty(MAN)
+_sect:=${MAN:E}
+MAN${_sect}=${MAN}
+.endif
+
+.SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
+
+CFLAGS+= ${COPTS}
+
+.if ${TARGET_OSNAME} == "NetBSD"
+.if ${MACHINE_ARCH} == "sparc64"
+CFLAGS+= -mcmodel=medlow
+.endif
+
+# ELF platforms depend on crtbegin.o and crtend.o
+.if ${OBJECT_FMT} == "ELF"
+.ifndef LIBCRTBEGIN
+LIBCRTBEGIN= ${DESTDIR}/usr/lib/crtbegin.o
+.MADE: ${LIBCRTBEGIN}
+.endif
+.ifndef LIBCRTEND
+LIBCRTEND= ${DESTDIR}/usr/lib/crtend.o
+.MADE: ${LIBCRTEND}
+.endif
+_SHLINKER= ${SHLINKDIR}/ld.elf_so
+.else
+LIBCRTBEGIN?=
+LIBCRTEND?=
+_SHLINKER= ${SHLINKDIR}/ld.so
+.endif
+
+.ifndef LIBCRT0
+LIBCRT0= ${DESTDIR}/usr/lib/crt0.o
+.MADE: ${LIBCRT0}
+.endif
+.endif # NetBSD
+
+# here is where you can define what LIB* are
+.-include <libnames.mk>
+.if ${MK_DPADD_MK} == "yes"
+# lots of cool magic, but might not suit everyone.
+.include <dpadd.mk>
+.endif
+
+.if defined(SHAREDSTRINGS)
+CLEANFILES+=strings
+.c.o:
+ ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
+ @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
+ @rm -f x.c
+
+.cc.o:
+ ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
+ @mv -f x.c x.cc
+ @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
+ @rm -f x.cc
+
+.C.o:
+ ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
+ @mv -f x.c x.C
+ @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
+ @rm -f x.C
+.endif
+
+
+.if defined(PROG)
+SRCS?= ${PROG}.c
+.for s in ${SRCS:N*.h:N*.sh:M*/*}
+${.o .po .lo:L:@o@${s:T:R}$o@}: $s
+.endfor
+.if !empty(SRCS:N*.h:N*.sh)
+OBJS+= ${SRCS:T:N*.h:N*.sh:R:S/$/.o/g}
+LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
+.endif
+
+.if defined(OBJS) && !empty(OBJS)
+.NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
+
+# this is known to work for NetBSD 1.6 and FreeBSD 4.2
+.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD"
+_PROGLDOPTS=
+.if ${SHLINKDIR} != "/usr/libexec" # XXX: change or remove if ld.so moves
+_PROGLDOPTS+= -Wl,-dynamic-linker=${_SHLINKER}
+.endif
+.if defined(LIBDIR) && ${SHLIBDIR} != ${LIBDIR}
+_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
+ -L${DESTDIR}${SHLIBDIR}
+.endif
+_PROGLDOPTS+= -Wl,-rpath,${SHLIBDIR}:/usr/lib
+
+.if defined(PROG_CXX)
+_CCLINK= ${CXX}
+_SUPCXX= -lstdc++ -lm
+.endif
+.endif # NetBSD
+
+_CCLINK?= ${CC}
+
+.if defined(DESTDIR) && exists(${LIBCRT0}) && ${LIBCRT0} != "/dev/null"
+
+${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
+ ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} -L${DESTDIR}/usr/lib ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
+
+.else
+
+${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
+ ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
+
+.endif # defined(DESTDIR)
+.endif # defined(OBJS) && !empty(OBJS)
+
+.if !defined(MAN)
+MAN= ${PROG}.1
+.endif # !defined(MAN)
+.endif # defined(PROG)
+
+.if !defined(_SKIP_BUILD)
+all: ${PROG}
+.endif
+all: _SUBDIRUSE
+
+.if !target(clean)
+cleanprog:
+ rm -f a.out [Ee]rrs mklog core *.core \
+ ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
+
+clean: _SUBDIRUSE cleanprog
+cleandir: _SUBDIRUSE cleanprog
+.else
+cleandir: _SUBDIRUSE clean
+.endif
+
+.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep)
+afterdepend: .depend
+ @(TMP=/tmp/_depend$$$$; \
+ sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
+ < .depend > $$TMP; \
+ mv $$TMP .depend)
+.endif
+
+.if !target(install)
+.if !target(beforeinstall)
+beforeinstall:
+.endif
+.if !target(afterinstall)
+afterinstall:
+.endif
+
+.if !empty(BINOWN)
+PROG_INSTALL_OWN ?= -o ${BINOWN} -g ${BINGRP}
+.endif
+
+.if !target(realinstall)
+realinstall: proginstall
+.endif
+.if !target(proginstall)
+proginstall:
+.if defined(PROG)
+ [ -d ${DESTDIR}${BINDIR} ] || \
+ ${INSTALL} -d ${PROG_INSTALL_OWN} -m 775 ${DESTDIR}${BINDIR}
+ ${INSTALL} ${COPY} ${STRIP_FLAG} ${PROG_INSTALL_OWN} -m ${BINMODE} \
+ ${PROG} ${DESTDIR}${BINDIR}/${PROG_NAME}
+.endif
+.if defined(HIDEGAME)
+ (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG})
+.endif
+.endif
+
+.include <links.mk>
+
+install: maninstall install_links _SUBDIRUSE
+
+install_links:
+.if !empty(SYMLINKS)
+ @set ${SYMLINKS}; ${_SYMLINKS_SCRIPT}
+.endif
+.if !empty(LINKS)
+ @set ${LINKS}; ${_LINKS_SCRIPT}
+.endif
+
+maninstall: afterinstall
+afterinstall: realinstall
+realinstall: beforeinstall
+.endif
+
+.if !target(lint)
+lint: ${LOBJS}
+.if defined(LOBJS) && !empty(LOBJS)
+ @${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
+.endif
+.endif
+
+.NOPATH: ${PROG}
+.if defined(OBJS) && !empty(OBJS)
+.NOPATH: ${OBJS}
+.endif
+
+.if ${MK_MAN} != "no"
+.include <man.mk>
+.endif
+
+.if ${MK_NLS} != "no"
+.include <nls.mk>
+.endif
+
+.include <obj.mk>
+.include <dep.mk>
+.include <subdir.mk>
+.include <final.mk>
+
+.endif
diff --git a/contrib/bmake/mk/progs.mk b/contrib/bmake/mk/progs.mk
new file mode 100644
index 0000000..0fd2312
--- /dev/null
+++ b/contrib/bmake/mk/progs.mk
@@ -0,0 +1,87 @@
+# $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $
+#
+# @(#) Copyright (c) 2006, 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
+#
+
+.MAIN: all
+
+.if defined(PROGS)
+
+# In meta mode, we can capture dependenices for _one_ of the progs.
+# if makefile doesn't nominate one, we use the first.
+.ifndef UPDATE_DEPENDFILE_PROG
+UPDATE_DEPENDFILE_PROG = ${PROGS:[1]}
+.export UPDATE_DEPENDFILE_PROG
+.endif
+
+.ifndef PROG
+# They may have asked us to build just one
+.for t in ${PROGS}
+.if make($t)
+PROG ?= $t
+.endif
+.endfor
+.endif
+
+.if defined(PROG)
+# just one of many
+PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS
+.for v in ${PROG_VARS:O:u}
+$v += ${${v}_${PROG}:U${${v}.${PROG}}}
+.endfor
+
+# for meta mode, there can be only one!
+.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno}
+UPDATE_DEPENDFILE ?= yes
+.endif
+UPDATE_DEPENDFILE ?= NO
+
+# ensure that we don't clobber each other's dependencies
+DEPENDFILE?= .depend.${PROG}
+# prog.mk will do the rest
+.else
+all: ${PROGS}
+
+# We cannot capture dependencies for meta mode here
+UPDATE_DEPENDFILE = NO
+# nor can we safely run in parallel.
+.NOTPARALLEL:
+.endif
+.endif
+
+# handle being called [bsd.]progs.mk
+.include <${.PARSEFILE:S,progs,prog,}>
+
+.ifndef PROG
+PROGS_TARGETS += clean
+
+.for p in ${PROGS}
+.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
+# bsd.prog.mk may need to know this
+x.$p= PROG_CXX=$p
+.endif
+
+$p ${p}_p: .PHONY .MAKE
+ (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p})
+
+.for t in ${PROGS_TARGETS:O:u}
+$p.$t: .PHONY .MAKE
+ (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E})
+.endfor
+.endfor
+
+.for t in ${PROGS_TARGETS:O:u}
+$t: ${PROGS:%=%.$t}
+.endfor
+
+.endif
diff --git a/contrib/bmake/mk/rst2htm.mk b/contrib/bmake/mk/rst2htm.mk
new file mode 100644
index 0000000..8bd66da
--- /dev/null
+++ b/contrib/bmake/mk/rst2htm.mk
@@ -0,0 +1,43 @@
+# $Id: rst2htm.mk,v 1.8 2011/04/03 21:39:25 sjg Exp $
+#
+# @(#) Copyright (c) 2009, 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
+#
+
+# convert reStructuredText to HTML, using rst2html.py from
+# docutils - http://docutils.sourceforge.net/
+
+.if empty(TXTSRCS)
+TXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo
+.endif
+RSTSRCS ?= ${TXTSRCS}
+HTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm}
+RST2HTML ?= rst2html.py
+RST2S5 ?= rst2s5.py
+# the following will run RST2S5 if the target name contains the word 'slides'
+# otherwise it uses RST2HTML
+RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5} ${RST2S5_FLAGS}:${RST2HTML} ${RST2HTML_FLAGS}}
+
+RST_SUFFIXES ?= .rst .txt
+
+CLEANFILES += ${HTMFILES}
+
+html: ${HTMFILES}
+
+.SUFFIXES: ${RST_SUFFIXES} .htm
+
+${RST_SUFFIXES:@s@$s.htm@}:
+ ${RST2HTM} ${.IMPSRC} ${.TARGET}
+
+.for s in ${RSTSRCS:O:u}
+${s:R:T}.htm: $s
+.endfor
diff --git a/contrib/bmake/mk/scripts.mk b/contrib/bmake/mk/scripts.mk
new file mode 100644
index 0000000..efd65f9
--- /dev/null
+++ b/contrib/bmake/mk/scripts.mk
@@ -0,0 +1,52 @@
+# $Id: scripts.mk,v 1.2 2006/11/09 01:55:18 sjg Exp $
+
+.include <init.mk>
+
+.if defined(SCRIPTS)
+
+all: ${SCRIPTS}
+
+.PHONY: scriptsinstall
+install: scriptsinstall
+
+.if !target(scriptsinstall)
+SCRIPTSDIR?= ${BINDIR}
+SCRIPTSOWN?= ${BINOWN}
+SCRIPTSGRP?= ${BINGRP}
+SCRIPTSMODE?= ${BINMODE}
+
+# how we get script name from src
+SCRIPTSNAME_MOD?=T:R
+
+script_targets= ${SCRIPTS:@s@${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}@}
+
+scriptsinstall:: ${script_targets}
+
+.PRECIOUS: ${script_targets}
+.if !defined(UPDATE)
+.PHONY: ${script_targets}
+.endif
+
+INSTALL_FLAGS?= ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} \
+ -o ${OWN_${.TARGET:T}:U${SCRIPTSOWN}} \
+ -g ${GRP_${.TARGET:T}:U${SCRIPTSGRP}} \
+ -m ${MODE_${.TARGET:T}:U${SCRIPTSMODE}}
+
+__SCRIPTINSTALL_USE: .USE
+ ${INSTALL} ${INSTALL_FLAGS_${.TARGET:T}:U${INSTALL_FLAGS}} \
+ ${.ALLSRC} ${.TARGET}
+
+.for s in ${SCRIPTS}
+.if !defined(BUILD) && !make(all) && !make(${s})
+${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}: .MADE
+.endif
+${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}: ${s} __SCRIPTINSTALL_USE
+.endfor
+.endif
+
+.endif
+
+.if !target(scriptsinstall)
+scriptsinstall::
+.endif
+
diff --git a/contrib/bmake/mk/srctop.mk b/contrib/bmake/mk/srctop.mk
new file mode 100644
index 0000000..fab090c
--- /dev/null
+++ b/contrib/bmake/mk/srctop.mk
@@ -0,0 +1,66 @@
+# $Id: srctop.mk,v 1.3 2012/11/11 23:20:18 sjg Exp $
+#
+# @(#) Copyright (c) 2012, 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 !defined(SRCTOP)
+# if using mk(1) SB will be set.
+.ifdef SB
+.if ${.CURDIR:S,${SB},,} != ${.CURDIR}
+# we are actually within SB
+.ifdef SB_SRC
+SRCTOP:= ${SB_SRC}
+.elif exists(${SB}/src)
+SRCTOP:= ${SB}/src
+.else
+SRCTOP:= ${SB}
+.endif
+.endif
+.endif
+
+.if !defined(SRCTOP)
+.for rd in share/mk build/mk mk
+.if ${_this_mk_dir:M*${rd}} != ""
+.if ${.CURDIR:S,${_this_mk_dir:${rd:C,[^/]+,H,g:S,/, ,g:ts:}},,} != ${.CURDIR}
+SRCTOP:= ${_this_mk_dir:${rd:C,[^/]+,H,g:S,/, ,g:ts:}}
+.endif
+.endif
+.endfor
+.endif
+
+.if !defined(SRCTOP)
+_SRCTOP_TEST_?= [ -f ../.sandbox-env -o -d share/mk ]
+# Linux at least has a bug where attempting to check an automounter
+# directory will hang. So avoid looking above /a/b
+SRCTOP!= cd ${.CURDIR}; while :; do \
+ here=`pwd`; \
+ ${_SRCTOP_TEST_} && { echo $$here; break; }; \
+ case $$here in /*/*/*) cd ..;; *) echo ""; break;; esac; \
+ done
+.endif
+.if defined(SRCTOP) && exists(${SRCTOP}/.)
+.export SRCTOP
+.endif
+.endif
+
+.if !defined(OBJTOP) && !empty(SRCTOP)
+.if defined(MAKEOBJDIRPREFIX) && exists(${MAKEOBJDIRPREFIX}${SRCTOP})
+OBJTOP= ${MAKEOBJDIRPREFIX}${SRCTOP}
+.elif (exists(${SRCTOP}/Makefile) || exists(${SRCTOP}/makefile))
+OBJTOP!= cd ${SRCTOP} && ${PRINTOBJDIR}
+.endif
+.if empty(OBJTOP)
+OBJTOP= ${SRCTOP}
+.endif
+.export OBJTOP
+.endif
diff --git a/contrib/bmake/mk/subdir.mk b/contrib/bmake/mk/subdir.mk
new file mode 100644
index 0000000..313b7d7
--- /dev/null
+++ b/contrib/bmake/mk/subdir.mk
@@ -0,0 +1,99 @@
+# $Id: subdir.mk,v 1.14 2012/11/12 04:34:33 sjg Exp $
+# skip missing directories...
+
+# $NetBSD: bsd.subdir.mk,v 1.11 1996/04/04 02:05:06 jtc Exp $
+# @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
+
+.if ${.MAKE.LEVEL} == 0 && ${.MAKE.MODE:Uno:Mmeta*} != ""
+.include <meta.subdir.mk>
+# keep everyone happy
+_SUBDIRUSE:
+.elif !commands(_SUBDIRUSE) && !defined(NO_SUBDIR) && !defined(NOSUBDIR)
+.if exists(${.CURDIR}/Makefile.inc)
+.include "Makefile.inc"
+.endif
+.if !target(.MAIN)
+.MAIN: all
+.endif
+
+ECHO_DIR ?= echo
+.ifdef SUBDIR_MUST_EXIST
+MISSING_DIR=echo "Missing ===> ${.CURDIR}/$${entry}"; exit 1
+.else
+MISSING_DIR=echo "Skipping ===> ${.CURDIR}/$${entry}"; continue
+.endif
+
+_SUBDIRUSE: .USE
+.if defined(SUBDIR)
+ @Exists() { test -f $$1; }; \
+ for entry in ${SUBDIR}; do \
+ (set -e; \
+ if Exists ${.CURDIR}/$${entry}.${MACHINE}/[mM]akefile; then \
+ _newdir_="$${entry}.${MACHINE}"; \
+ elif Exists ${.CURDIR}/$${entry}/[mM]akefile; then \
+ _newdir_="$${entry}"; \
+ else \
+ ${MISSING_DIR}; \
+ fi; \
+ if test X"${_THISDIR_}" = X""; then \
+ _nextdir_="$${_newdir_}"; \
+ else \
+ _nextdir_="$${_THISDIR_}/$${_newdir_}"; \
+ fi; \
+ ${ECHO_DIR} "===> $${_nextdir_}"; \
+ cd ${.CURDIR}/$${_newdir_}; \
+ ${.MAKE} _THISDIR_="$${_nextdir_}" \
+ ${.TARGET:S/realinstall/install/:S/.depend/depend/}) || exit 1; \
+ done
+
+${SUBDIR}::
+ @set -e; if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
+ _newdir_=${.TARGET}.${MACHINE}; \
+ else \
+ _newdir_=${.TARGET}; \
+ fi; \
+ ${ECHO_DIR} "===> $${_newdir_}"; \
+ cd ${.CURDIR}/$${_newdir_}; \
+ ${.MAKE} _THISDIR_="$${_newdir_}" all
+.endif
+
+.if !target(install)
+.if !target(beforeinstall)
+beforeinstall:
+.endif
+.if !target(afterinstall)
+afterinstall:
+.endif
+install: maninstall
+maninstall: afterinstall
+afterinstall: realinstall
+realinstall: beforeinstall _SUBDIRUSE
+.endif
+
+.if defined(SRCS)
+etags: ${SRCS}
+ -cd ${.CURDIR}; etags `echo ${.ALLSRC:N*.h} | sed 's;${.CURDIR}/;;'`
+.endif
+
+SUBDIR_TARGETS += \
+ all \
+ clean \
+ cleandir \
+ includes \
+ depend \
+ lint \
+ obj \
+ tags \
+ etags
+
+.for t in ${SUBDIR_TARGETS:O:u}
+$t: _SUBDIRUSE
+.endfor
+
+.include <own.mk>
+.if make(destroy*)
+.include <obj.mk>
+.endif
+.endif
+# make sure this exists
+all:
diff --git a/contrib/bmake/mk/sys.clean-env.mk b/contrib/bmake/mk/sys.clean-env.mk
new file mode 100644
index 0000000..b1867c3
--- /dev/null
+++ b/contrib/bmake/mk/sys.clean-env.mk
@@ -0,0 +1,119 @@
+# $Id: sys.clean-env.mk,v 1.20 2012/11/12 06:56:04 sjg Exp $
+#
+# @(#) Copyright (c) 2009, 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 makefile would normally be included by sys.env.mk
+
+# The variables used by this makefile include:
+#
+# MAKE_ENV_SAVE_VAR_LIST
+# The actuall list of variables from the environment that will be
+# preserved.
+# MAKE_ENV_SAVE_PREFIX_LIST
+# A list of prefixes to match against the environment - the results
+# are added to MAKE_ENV_SAVE_VAR_LIST after being filtered by...
+# MAKE_ENV_SAVE_EXCLUDE_LIST
+# A list of words or patterns which is turned into a list of :N
+# modifiers.
+
+.if ${.MAKE.LEVEL} == 0 && ${MAKE_VERSION} >= 20100606
+# We save any env var that starts with the words in MAKE_ENV_SAVE_PREFIX_LIST.
+# This gets expanded to an egrep expression like '^(A|B|C...)'
+# and added to MAKE_ENV_SAVE_VAR_LIST below.
+# If any of these end up being too greedy, MAKE_ENV_SAVE_EXCLUDE_LIST
+# can be used to filter.
+MAKE_ENV_SAVE_PREFIX_LIST += \
+ CCACHE \
+ CVS \
+ DEBUG \
+ DISTCC \
+ HOST \
+ MACHINE \
+ MAKE \
+ MK \
+ NEED_ \
+ SB_ \
+ SSH \
+ SVN \
+ USE_ \
+ WITH_ \
+ WITHOUT_ \
+
+
+# This could be a list of vars or patterns to explicitly exclude.
+MAKE_ENV_SAVE_EXCLUDE_LIST ?= _
+
+# This is the actual list that we will save
+# HOME is probably something worth clobbering eg.
+# HOME=/var/empty
+MAKE_ENV_SAVE_VAR_LIST += \
+ HOME \
+ LOGNAME \
+ OBJROOT \
+ OBJTOP \
+ PATH \
+ SB \
+ SRCTOP \
+ USER \
+ ${_env_vars:${MAKE_ENV_SAVE_EXCLUDE_LIST:${M_ListToSkip}}}
+
+_env_vars != env | egrep '^(${MAKE_ENV_SAVE_PREFIX_LIST:ts|})' | sed 's,=.*,,'; echo
+
+_export_list =
+.for v in ${MAKE_ENV_SAVE_VAR_LIST:O:u}
+.if defined($v)
+_export_list += $v
+# Save current value
+$v := ${$v}
+.endif
+.endfor
+
+# Now, clobber the environment
+.unexport-env
+
+# This is a list of vars that we handle specially below
+_tricky_env_vars = MAKEOBJDIR OBJTOP
+# Export our selection - sans tricky ones
+.export ${_export_list:${_tricky_env_vars:${M_ListToSkip}}}
+
+# This next bit may need tweaking
+# if you don't happen to like the way I set it.
+.if defined(MAKEOBJDIR)
+# We are going to set this to the equivalent of the shell's
+# MAKEOBJDIR='${.CURDIR:S,${SRCTOP},${OBJTOP},}'
+_srctop := ${SRCTOP:U${SB_SRC:U${SB}/src}}
+_objroot := ${OBJROOT:U${SB_OBJROOT:U${SB}/${SB_OBJPREFIX}}}
+_objtop := ${OBJTOP:U${_objroot}${MACHINE}}
+# Take care of ${MACHINE}
+.if ${MACHINE} == "host" || ${OBJTOP} == ${HOST_OBJTOP:Uno}
+OBJTOP = ${_objtop:S,${HOST_TARGET}$,\${MACHINE},}
+.else
+OBJTOP = ${_objtop:S,${MACHINE}$,\${MACHINE},}
+.endif
+# Export like this
+MAKEOBJDIR = $${.CURDIR:S,${_srctop},$${OBJTOP},}
+#.info ${MAKE_SAVE_ENV_VARS _srctop _objroot _objtop OBJTOP MAKEOBJDIR:L:@v@${.newline}$v=${$v}@}
+
+# Export these as-is, and do not track...
+# otherwise the environment will be ruined when we evaluate them below.
+.export-env ${_tricky_env_vars}
+
+# Now evaluate for ourselves
+.for v in ${_tricky_env_vars}
+$v := ${$v}
+.endfor
+#.info ${_tricky_env_vars:@v@${.newline}$v=${$v}@}
+
+.endif # MAKEOBJDIR
+.endif # level 0
diff --git a/contrib/bmake/mk/sys.dependfile.mk b/contrib/bmake/mk/sys.dependfile.mk
new file mode 100644
index 0000000..752a46f
--- /dev/null
+++ b/contrib/bmake/mk/sys.dependfile.mk
@@ -0,0 +1,47 @@
+# $Id: sys.dependfile.mk,v 1.4 2012/11/08 18:31:42 sjg Exp $
+#
+# @(#) Copyright (c) 2012, 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 only makes sense in meta mode.
+# This allows a mixture of auto generated as well as manually edited
+# dependency files, which can be differentiated by their names.
+# As per dirdeps.mk we only require:
+# 1. a common prefix
+# 2. that machine specific files end in .${MACHINE}
+#
+# The .MAKE.DEPENDFILE_PREFERENCE below is an example.
+
+# All depend file names should start with this
+.MAKE.DEPENDFILE_PREFIX ?= Makefile.depend
+
+# The order of preference: we will use the first one of these we find
+# otherwise the 1st entry will be used by default.
+.MAKE.DEPENDFILE_PREFERENCE ?= \
+ ${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
+ ${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}
+
+_e := ${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}
+.if !empty(_e)
+.MAKE.DEPENDFILE := ${_e:[1]}
+.elif ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}} != "" && ${.MAKE.DEPENDFILE_PREFERENCE:[1]:E} != ${MACHINE}
+# MACHINE specific depend files are supported, but *not* default.
+# If any already exist, we should follow suit.
+_aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE}
+# MACHINE must be the last entry in _aml ;-)
+_e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@}
+.if !empty(_e)
+.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]}
+.endif
+.endif
+.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:[1]}
diff --git a/contrib/bmake/mk/sys.mk b/contrib/bmake/mk/sys.mk
new file mode 100644
index 0000000..30eca9b
--- /dev/null
+++ b/contrib/bmake/mk/sys.mk
@@ -0,0 +1,199 @@
+# $Id: sys.mk,v 1.35 2012/11/12 06:27:51 sjg Exp $
+#
+# @(#) Copyright (c) 2003-2009, 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
+#
+
+# Avoid putting anything platform specific in here.
+
+# We use the following paradigm for preventing multiple inclusion.
+# It relies on the fact that conditionals and dependencies are resolved
+# at the time they are read.
+#
+# _this ?= ${.PARSEFILE}
+# .if !target(__${_this}__)
+# __${_this}__:
+#
+.if ${MAKE_VERSION:U0} > 20100408
+_this = ${.PARSEDIR:tA}/${.PARSEFILE}
+.else
+_this = ${.PARSEDIR}/${.PARSEFILE}
+.endif
+
+# Sometimes we want to turn on debugging in just one or two places
+# if .CURDIR is matched by any entry in DEBUG_MAKE_SYS_DIRS we
+# will apply DEBUG_MAKE_FLAGS now.
+# if an entry in DEBUG_MAKE_DIRS matches, we at the end of sys.mk
+# eg. DEBUG_MAKE_FLAGS=-dv DEBUG_MAKE_SYS_DIRS="*lib/sjg"
+# use DEBUG_MAKE_FLAGS0 to apply only to .MAKE.LEVEL 0
+#
+.if ${.MAKE.LEVEL:U1} == 0
+# we use indirection, to simplify the tests below, and incase
+# DEBUG_* were given on our command line.
+_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS0}
+_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS0:U${DEBUG_MAKE_SYS_DIRS}}
+_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS0:U${DEBUG_MAKE_DIRS}}
+.else
+_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS}
+_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS}
+_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS}
+.endif
+
+.if !empty(_DEBUG_MAKE_FLAGS)
+.if ${_DEBUG_MAKE_SYS_DIRS:Uno:@x@${.CURDIR:M$x}@} != ""
+.MAKEFLAGS: ${_DEBUG_MAKE_FLAGS}
+.endif
+.endif
+
+# if this is an ancient version of bmake
+MAKE_VERSION ?= 0
+.if ${MAKE_VERSION:M*make-*}
+# turn it into what we want - just the date
+MAKE_VERSION := ${MAKE_VERSION:[1]:C,.*-,,}
+.endif
+
+# some useful modifiers
+
+# A useful trick for testing multiple :M's against something
+# :L says to use the variable's name as its value - ie. literal
+# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
+M_ListToMatch = L:@m@$${V:M$$m}@
+# match against our initial targets (see above)
+M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
+
+# turn a list into a set of :N modifiers
+# NskipFoo = ${Foo:${M_ListToSkip}}
+M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
+
+# type should be a builtin in any sh since about 1980,
+# AUTOCONF := ${autoconf:L:${M_whence}}
+M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
+M_whence = ${M_type}:M/*
+
+# convert a path to a valid shell variable
+M_P2V = tu:C,[./-],_,g
+
+# convert path to absolute
+.if ${MAKE_VERSION:U0} > 20100408
+M_tA = tA
+.else
+M_tA = C,.*,('cd' & \&\& 'pwd') 2> /dev/null || echo &,:sh
+.endif
+
+# absoulte path to what we are reading.
+_PARSEDIR = ${.PARSEDIR:${M_tA}}
+
+# we expect a recent bmake
+.if !defined(_TARGETS)
+# some things we do only once
+_TARGETS := ${.TARGETS}
+.-include <sys.env.mk>
+.endif
+
+# we need HOST_TARGET etc below.
+.include <host-target.mk>
+
+# find the OS specifics
+.if defined(SYS_OS_MK)
+.include <${SYS_OS_MK}>
+.else
+_sys_mk =
+.for x in ${HOST_OSTYPE} ${HOST_TARGET} ${HOST_OS} ${MACHINE} Generic
+.if empty(_sys_mk)
+.-include <sys/$x.mk>
+_sys_mk := ${.MAKE.MAKEFILES:M*/$x.mk}
+.if !empty(_sys_mk)
+_sys_mk := sys/${_sys_mk:T}
+.endif
+.endif
+.if empty(_sys_mk)
+# might be an old style
+.-include <$x.sys.mk>
+_sys_mk := ${.MAKE.MAKEFILES:M*/$x.sys.mk:T}
+.endif
+.endfor
+
+SYS_OS_MK := ${_sys_mk}
+.export SYS_OS_MK
+.endif
+
+# allow customization without editing.
+.-include <local.sys.mk>
+
+# if you want objdirs make them automatic
+.if ${MKOBJDIRS:Uno} == "auto"
+.include <auto.obj.mk>
+.endif
+
+.if !empty(SRCTOP)
+.if ${.CURDIR} == ${SRCTOP}
+RELDIR = .
+.elif ${.CURDIR:M${SRCTOP}/*}
+RELDIR := ${.CURDIR:S,${SRCTOP}/,,}
+.endif
+.endif
+
+MACHINE_ARCH.host ?= ${_HOST_ARCH}
+MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
+.if empty(MACHINE_ARCH)
+MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
+.endif
+
+.ifndef ROOT_GROUP
+ROOT_GROUP != sed -n /:0:/s/:.*//p /etc/group
+.export ROOT_GROUP
+.endif
+
+unix ?= We run ${_HOST_OSNAME}.
+
+# A race condition in mkdir, means that it can bail if another
+# process made a dir that mkdir expected to.
+# We repeat the mkdir -p a number of times to try and work around this.
+# We stop looping as soon as the dir exists.
+# If we get to the end of the loop, a plain mkdir will issue an error.
+Mkdirs= Mkdirs() { \
+ for d in $$*; do \
+ for i in 1 2 3 4 5 6; do \
+ mkdir -p $$d; \
+ test -d $$d && return 0; \
+ done; \
+ mkdir $$d || exit $$?; \
+ done; }
+
+# this often helps with debugging
+.SUFFIXES: .cpp-out
+
+.c.cpp-out:
+ @${COMPILE.c:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
+
+.cc.cpp-out:
+ @${COMPILE.cc:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
+
+# we don't include own.mk but user can expect -DWITH_META_MODE to work
+.if defined(WITHOUT_META_MODE)
+USE_META= no
+.elif defined(WITH_META_MODE)
+USE_META= yes
+.endif
+.if ${USE_META:Uno} == "yes"
+.-include <meta.sys.mk>
+.endif
+# make sure we have a harmless value
+.MAKE.MODE ?= normal
+
+# if .CURDIR is matched by any entry in DEBUG_MAKE_DIRS we
+# will apply DEBUG_MAKE_FLAGS, now.
+.if !empty(_DEBUG_MAKE_FLAGS)
+.if ${_DEBUG_MAKE_DIRS:Uno:@x@${.CURDIR:M$x}@} != ""
+.MAKEFLAGS: ${_DEBUG_MAKE_FLAGS}
+.endif
+.endif
diff --git a/contrib/bmake/mk/sys/AIX.mk b/contrib/bmake/mk/sys/AIX.mk
new file mode 100644
index 0000000..18adfa6
--- /dev/null
+++ b/contrib/bmake/mk/sys/AIX.mk
@@ -0,0 +1,197 @@
+# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
+# @(#)sys.mk 5.11 (Berkeley) 3/13/91
+
+OS= AIX
+unix= We run ${OS}.
+ROOT_GROUP= system
+
+# This needs a lot of work yet...
+
+NOPIC=no # no shared libs?
+
+.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+
+.LIBS: .a
+
+AR= ar
+ARFLAGS= rl
+RANLIB= ranlib
+
+AS= as
+AFLAGS=
+COMPILE.s= ${AS} ${AFLAGS}
+LINK.s= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c
+LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+.if exists(/usr/local/bin/gcc)
+CC= gcc
+DBG= -O -g
+STATIC?= -static
+.else
+CC= cc
+DBG= -g
+STATIC=
+.endif
+CFLAGS= ${DBG}
+COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX= g++
+CXXFLAGS= ${CFLAGS}
+COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP= cpp
+.if defined(DESTDIR)
+CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include
+.endif
+
+MK_DEP= mkdeps.sh -N
+FC= f77
+FFLAGS= -O
+RFLAGS=
+COMPILE.f= ${FC} ${FFLAGS} -c
+LINK.f= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+LEX= lex
+LFLAGS=
+LEX.l= ${LEX} ${LFLAGS}
+
+LD= ld
+LDFLAGS=
+
+LINT= lint
+LINTFLAGS= -chapbx
+
+MAKE= bmake
+
+PC= pc
+PFLAGS=
+COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL= sh
+
+YACC= yacc
+YFLAGS= -d
+YACC.y= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++
+.cc:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} -o ${.TARGET} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/Darwin.mk b/contrib/bmake/mk/sys/Darwin.mk
new file mode 100644
index 0000000..d05e32a
--- /dev/null
+++ b/contrib/bmake/mk/sys/Darwin.mk
@@ -0,0 +1,220 @@
+# $NetBSD: Darwin.sys.mk,v 1.3 2003/02/16 09:44:41 grant Exp $
+# @(#)sys.mk 8.2 (Berkeley) 3/21/94
+
+OS= Darwin
+unix?= We run ${OS}.
+
+.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .sh .m4 .dylib
+
+.LIBS: .a .dylib
+
+SHLIBEXT = .dylib
+HOST_LIBEXT = .dylib
+DSHLIBEXT = .dylib
+
+AR?= ar
+ARFLAGS?= rl
+RANLIB =
+
+AS?= as
+AFLAGS?=
+COMPILE.s?= ${AS} ${AFLAGS}
+LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c
+LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+.if exists(/usr/bin/gcc)
+CC?= gcc -pipe
+.else
+CC?= cc -pipe
+.endif
+DBG?= -O2
+CFLAGS?= ${DBG}
+COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+.if exists(/usr/bin/g++)
+CXX?= g++
+.else
+CXX?= c++
+.endif
+CXXFLAGS?= ${CFLAGS}
+COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+OBJC?= ${CC}
+OBJCFLAGS?= ${CFLAGS}
+COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
+LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP?= cpp
+NOLINT= 1
+CPPFLAGS?=
+
+MK_DEP?= mkdeps.sh -N
+
+FC?= f77
+FFLAGS?= -O
+RFLAGS?=
+COMPILE.f?= ${FC} ${FFLAGS} -c
+LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+INSTALL?= install
+
+LEX?= lex
+LFLAGS?=
+LEX.l?= ${LEX} ${LFLAGS}
+
+LD?= ld
+LDFLAGS?=
+
+SHLIB_TEENY = 0
+SHLIB_MINOR = 0
+
+MKPICLIB = no
+LIBEXT = .dylib
+
+LINT?= lint
+LINTFLAGS?= -chapbx
+
+LORDER?= lorder
+
+MAKE?= bmake
+
+NM?= nm
+
+PC?= pc
+PFLAGS?=
+COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL?= sh
+
+SIZE?= size
+
+TSORT?= tsort -q
+
+YACC?= bison -y
+YFLAGS?= -d
+YACC.y?= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++
+.cc:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} -o ${.TARGET} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/Generic.mk b/contrib/bmake/mk/sys/Generic.mk
new file mode 100644
index 0000000..179da97
--- /dev/null
+++ b/contrib/bmake/mk/sys/Generic.mk
@@ -0,0 +1,208 @@
+# $Id: Generic.mk,v 1.11 2010/09/24 05:59:53 sjg Exp $
+#
+
+# some reasonable defaults
+.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .sh .m4
+
+.LIBS: .a
+
+tools = \
+ ar \
+ lorder \
+ ranlib \
+ tsort
+
+.for t in ${tools}
+${t:tu} := ${t:${M_whence}}
+.endfor
+
+# need to make sure this is set
+MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
+.if empty(MACHINE_ARCH)
+MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
+.endif
+
+.if !empty(TSORT)
+TSORT += -q
+.endif
+
+ARFLAGS?= rl
+
+AS?= as
+AFLAGS?=
+.if ${MACHINE_ARCH} == "sparc64"
+AFLAGS+= -Wa,-Av9a
+.endif
+COMPILE.s?= ${CC} ${AFLAGS} -c
+LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
+LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CC?= cc
+DBG?= -O2
+CFLAGS?= ${DBG}
+COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX?= c++
+CXXFLAGS?= ${CFLAGS}
+COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+OBJC?= ${CC}
+OBJCFLAGS?= ${CFLAGS}
+COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
+LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP?= cpp
+CPPFLAGS?=
+
+FC?= f77
+FFLAGS?= -O
+RFLAGS?=
+COMPILE.f?= ${FC} ${FFLAGS} -c
+LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+INSTALL?= install
+
+LEX?= lex
+LFLAGS?=
+LEX.l?= ${LEX} ${LFLAGS}
+
+LD?= ld
+LDFLAGS?=
+
+LINT?= lint
+LINTFLAGS?= -chapbxzF
+
+MAKE?= ${.MAKE}
+
+NM?= nm
+
+PC?= pc
+PFLAGS?=
+COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL?= sh
+
+SIZE?= size
+
+YACC?= yacc
+YFLAGS?=
+YACC.y?= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.c.ln:
+ ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
+
+# C++
+.cc .cpp .cxx .C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o .cpp.o .cxx.o .C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a .cpp.a .cxx.a .C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
+
diff --git a/contrib/bmake/mk/sys/HP-UX.mk b/contrib/bmake/mk/sys/HP-UX.mk
new file mode 100644
index 0000000..f6e3e2c
--- /dev/null
+++ b/contrib/bmake/mk/sys/HP-UX.mk
@@ -0,0 +1,237 @@
+# $Id: HP-UX.mk,v 1.9 2003/09/30 16:42:23 sjg Exp $
+# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
+# @(#)sys.mk 5.11 (Berkeley) 3/13/91
+
+OS= HP-UX
+ROOT_GROUP= root
+unix?= We run ${OS}.
+
+# HP-UX's cc does not provide any clues as to wether this is 9.x or 10.x
+# nor does sys/param.h, so we'll use the existence of /hp-ux
+.if exists("/hp-ux")
+OSMAJOR?=9
+.endif
+OSMAJOR?=10
+__HPUX_VERSION?=${OSMAJOR}
+
+.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+
+LIBMODE= 755
+LIBCRT0= /lib/crt0.o
+
+.LIBS: .a
+
+# +b<path> is needed to stop the binaries from insisting on having
+# the build tree available :-)
+# +s tells the dynamic loader to use SHLIB_PATH if set
+LD_bpath?=-Wl,+b/lib:/usr/lib:/usr/local/lib
+LD_spath?=-Wl,+s
+LDADD+= ${LD_bpath} ${LD_spath}
+
+.if exists(/usr/lib/end.o)
+LDADD+= /usr/lib/end.o
+.endif
+
+AR= ar
+ARFLAGS= rl
+RANLIB= :
+
+AFLAGS=
+COMPILE.s= ${AS} ${AFLAGS}
+LINK.s= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c
+LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+.if exists(/usr/local/bin/gcc)
+PIPE?= -pipe
+CC?= gcc ${PIPE}
+AS= gas
+DBG?= -O -g
+STATIC?= -static
+.if defined(DESTDIR)
+CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include
+.endif
+.else
+# HP's bundled compiler knows not -g or -O
+AS= as
+CC= cc
+.if exists(/opt/ansic/bin/cc)
+CCMODE?=-Ae +ESlit
+PICFLAG?= +z
+LD_x=
+DBG?=-g -O
+.endif
+DBG?=
+STATIC?= -Wl,-a,archive
+.endif
+.if (${__HPUX_VERSION} == "10")
+CCSOURCE_FLAGS?= -D_HPUX_SOURCE
+.else
+CCSOURCE_FLAGS?= -D_HPUX_SOURCE -D_INCLUDE_POSIX_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_XOPEN_SOURCE_EXTENDED
+.endif
+CFLAGS= ${DBG}
+CFLAGS+= ${CCMODE} -D__hpux__ -D__HPUX_VERSION=${__HPUX_VERSION} ${CCSOURCE_FLAGS}
+COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX= g++
+CXXFLAGS= ${CFLAGS}
+COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP= cpp
+
+MK_DEP= mkdeps.sh -N
+FC= f77
+FFLAGS= -O
+RFLAGS=
+COMPILE.f= ${FC} ${FFLAGS} -c
+LINK.f= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+LEX= lex
+LFLAGS=
+LEX.l= ${LEX} ${LFLAGS}
+
+LD= ld
+LDFLAGS=
+
+LINT= lint
+LINTFLAGS= -chapbx
+
+MAKE= bmake
+
+PC= pc
+PFLAGS=
+COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+# HP's sh sucks
+ENV=
+SHELL= /bin/ksh
+
+.if exists(/usr/local/bin/bison)
+YACC= bison -y
+.else
+YACC= yacc
+.endif
+YFLAGS= -d
+YACC.y= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++
+.cc:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} -o ${.TARGET} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/IRIX.mk b/contrib/bmake/mk/sys/IRIX.mk
new file mode 100644
index 0000000..783e405
--- /dev/null
+++ b/contrib/bmake/mk/sys/IRIX.mk
@@ -0,0 +1,199 @@
+# $NetBSD: IRIX.sys.mk,v 1.2 2002/12/24 23:03:27 jschauma Exp $
+# @(#)sys.mk 8.2 (Berkeley) 3/21/94
+
+.if ${.PARSEFILE} == "sys.mk"
+.ifndef ROOT_GROUP
+OS!= uname -s
+ROOT_GROUP!= sed -n /:0:/s/:.*//p /etc/group
+.MAKEOVERRIDES+= OS ROOT_GROUP
+.endif
+unix?= We run ${OS}.
+.endif
+
+.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .sh .m4
+
+.LIBS: .a
+
+AR?= ar
+ARFLAGS?= rl
+RANLIB?= ranlib
+
+AS?= as
+AFLAGS?=
+COMPILE.s?= ${CC} ${AFLAGS} -c
+LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
+LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CC?= cc
+NOGCCERROR?= # defined
+DBG?= -O2
+CFLAGS?= ${DBG}
+COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX?= CC
+CXXFLAGS?= ${CFLAGS}
+COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+OBJC?= ${CC}
+OBJCFLAGS?= ${CFLAGS}
+COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
+LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP?= CC
+CPPFLAGS?=
+
+FC?= f77
+FFLAGS?= -O
+RFLAGS?=
+COMPILE.f?= ${FC} ${FFLAGS} -c
+LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+INSTALL?= ${PREFIX}/bin/install-sh
+
+LEX?= lex
+LFLAGS?=
+LEX.l?= ${LEX} ${LFLAGS}
+
+LD?= ld
+LDFLAGS?=
+
+LINT?= lint
+LINTFLAGS?= -chapbxzF
+
+LORDER?= lorder
+
+MAKE?= make
+
+NM?= nm
+
+PC?= pc
+PFLAGS?=
+COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL?= sh
+
+SIZE?= size
+
+TSORT?= tsort -q
+
+YACC?= yacc
+YFLAGS?=
+YACC.y?= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.c.ln:
+ ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
+
+# C++
+.cc .cpp .cxx .C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o .cpp.o .cxx.o .C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a .cpp.a .cxx.a .C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/Linux.mk b/contrib/bmake/mk/sys/Linux.mk
new file mode 100644
index 0000000..862cde6
--- /dev/null
+++ b/contrib/bmake/mk/sys/Linux.mk
@@ -0,0 +1,200 @@
+# $Id: Linux.mk,v 1.7 2011/03/02 05:05:21 sjg Exp $
+# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
+# @(#)sys.mk 5.11 (Berkeley) 3/13/91
+
+OS?= Linux
+unix?= We run ${OS}.
+
+ROOT_GROUP= root
+
+# would be better to work out where it is...
+LIBCRT0= /dev/null
+
+NEED_SOLINKS=yes
+
+.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+
+.LIBS: .a
+
+AR= ar
+ARFLAGS= rl
+RANLIB= ranlib
+
+AS= as
+AFLAGS=
+COMPILE.s= ${AS} ${AFLAGS}
+LINK.s= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c
+LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+.if exists(/usr/local/bin/gcc)
+CC= gcc -pipe
+DBG= -O -g
+STATIC?= -static
+.else
+CC= cc -pipe
+DBG= -g
+STATIC= -Bstatic
+.endif
+CFLAGS= ${DBG}
+COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX= g++
+CXXFLAGS= ${CFLAGS}
+COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP= cpp
+.if defined(DESTDIR)
+CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include
+.endif
+
+MK_DEP= mkdeps.sh -N
+FC= f77
+FFLAGS= -O
+RFLAGS=
+COMPILE.f= ${FC} ${FFLAGS} -c
+LINK.f= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+LEX= lex
+LFLAGS=
+LEX.l= ${LEX} ${LFLAGS}
+
+LD= ld
+LDFLAGS=
+
+LINT= lint
+LINTFLAGS= -chapbx
+
+MAKE= bmake
+
+PC= pc
+PFLAGS=
+COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL= sh
+
+YACC= yacc
+YFLAGS= -d
+YACC.y= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++
+.cc:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} -o ${.TARGET} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/NetBSD.mk b/contrib/bmake/mk/sys/NetBSD.mk
new file mode 100644
index 0000000..4bc7da1
--- /dev/null
+++ b/contrib/bmake/mk/sys/NetBSD.mk
@@ -0,0 +1,234 @@
+# $NetBSD: sys.mk,v 1.66.2.1 2002/06/05 03:31:01 lukem Exp $
+# @(#)sys.mk 8.2 (Berkeley) 3/21/94
+
+OS= NetBSD
+unix?= We run ${OS}.
+
+.if !defined(MAKE_VERSION)
+# we are running native make
+# which defined MAKE_VERSION between 20010609 and 20090324
+# so we can make a rough guess
+.if defined(.MAKE.LEVEL)
+MAKE_VERSION = 20090908
+.elif defined(.MAKE.MAKEFILES)
+# introduced 20071008
+MAKE_VERSION = 20090324
+.else
+# this just before when MAKE_VERSION was introduced
+MAKE_VERSION = 20010606
+.endif
+.endif
+
+.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .sh .m4
+
+.LIBS: .a
+
+AR?= ar
+ARFLAGS?= rl
+RANLIB?= ranlib
+
+AS?= as
+AFLAGS?=
+COMPILE.s?= ${CC} ${AFLAGS} -c
+LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
+LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CC?= cc
+
+# need to make sure this is set
+MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
+.if empty(MACHINE_ARCH)
+MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
+.endif
+
+#
+# CPU model, derived from MACHINE_ARCH
+#
+MACHINE_CPU= ${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/m68000/m68k/:S/armeb/arm/}
+
+.if ${MACHINE_CPU} == "alpha" || \
+ ${MACHINE_CPU} == "arm" || \
+ ${MACHINE_CPU} == "i386" || \
+ ${MACHINE_CPU} == "m68k" || \
+ ${MACHINE_CPU} == "mips" || \
+ ${MACHINE_CPU} == "powerpc" || \
+ ${MACHINE_CPU} == "sparc" || \
+ ${MACHINE_CPU} == "vax"
+DBG?= -O2
+.elif ${MACHINE_ARCH} == "x86_64"
+DBG?=
+.elif ${MACHINE_ARCH} == "sparc64"
+DBG?= -O -ffixed-g4 #Hack for embedany memory model compatibility
+.else
+DBG?= -O
+.endif
+CFLAGS?= ${DBG}
+COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX?= c++
+CXXFLAGS?= ${CFLAGS}
+COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+OBJC?= ${CC}
+OBJCFLAGS?= ${CFLAGS}
+COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
+LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP?= cpp
+CPPFLAGS?=
+
+FC?= f77
+FFLAGS?= -O
+RFLAGS?=
+COMPILE.f?= ${FC} ${FFLAGS} -c
+LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+INSTALL?= install
+
+LEX?= lex
+LFLAGS?=
+LEX.l?= ${LEX} ${LFLAGS}
+
+LD?= ld
+LDFLAGS?=
+
+LINT?= lint
+LINTFLAGS?= -chapbxzF
+
+LORDER?= lorder
+
+MAKE?= make
+
+NM?= nm
+
+PC?= pc
+PFLAGS?=
+COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL?= sh
+
+SIZE?= size
+
+TSORT?= tsort -q
+
+YACC?= yacc
+YFLAGS?=
+YACC.y?= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.c.ln:
+ ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
+
+# C++
+.cc .cpp .cxx .C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o .cpp.o .cxx.o .C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a .cpp.a .cxx.a .C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/OSF1.mk b/contrib/bmake/mk/sys/OSF1.mk
new file mode 100644
index 0000000..a8d729a
--- /dev/null
+++ b/contrib/bmake/mk/sys/OSF1.mk
@@ -0,0 +1,211 @@
+# $Id: OSF1.mk,v 1.6 2003/09/30 16:42:23 sjg Exp $
+# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
+# @(#)sys.mk 5.11 (Berkeley) 3/13/91
+
+OS?= OSF1
+unix?= We run ${OS}.
+ROOT_GROUP= system
+
+# can't fine one anywhere, so just stop the dependency
+LIBCRT0= /dev/null
+
+PATH=/usr/sbin:/usr/bin:/usr/ucb:/opt/gnu/bin:/usr/ccs/bin
+
+.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+
+.LIBS: .a
+
+# no -X
+LD_X=
+LD_x= -x
+LD_r= -r
+AR= ar
+ARFLAGS= rl
+RANLIB= ranlib
+
+AS= as
+AS_STDIN= -
+AFLAGS=
+COMPILE.s= ${AS} ${AFLAGS}
+LINK.s= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c
+LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+.if exists(/opt/gnu/bin/gcc) || exists(/usr/local/bin/gcc)
+CC?= gcc
+.else
+CC?= cc -std
+.endif
+.if (${CC:T} == "gcc")
+DBG= -O -g
+STATIC= -static
+DBG= -g
+STATIC= -non_shared
+.endif
+
+CFLAGS= ${DBG}
+COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX= g++
+CXXFLAGS= ${CFLAGS}
+COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP= /usr/ccs/lib/cpp
+.if defined(DESTDIR)
+CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include
+.endif
+
+MK_DEP= mkdeps.sh -N
+FC= f77
+FFLAGS= -O
+RFLAGS=
+COMPILE.f= ${FC} ${FFLAGS} -c
+LINK.f= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+LEX= lex
+LFLAGS=
+LEX.l= ${LEX} ${LFLAGS}
+
+LD= ld
+LDFLAGS=
+
+LINT= lint
+LINTFLAGS= -chapbx
+
+MAKE= bmake
+
+PC= pc
+PFLAGS=
+COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL= sh
+
+.if exists(/usr/local/bin/bison) || exists(/opt/gnu/bin/bison)
+YACC= bison -y
+.else
+YACC= yacc
+.endif
+YFLAGS= -d
+YACC.y= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++
+.cc:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/OpenBSD.mk b/contrib/bmake/mk/sys/OpenBSD.mk
new file mode 100644
index 0000000..ed496f1
--- /dev/null
+++ b/contrib/bmake/mk/sys/OpenBSD.mk
@@ -0,0 +1,209 @@
+# $NetBSD: OpenBSD.sys.mk,v 1.1 2002/11/17 09:18:00 cjep Exp $
+# @(#)sys.mk 8.2 (Berkeley) 3/21/94
+
+OS= OpenBSD
+unix?= We run ${OS}.
+
+.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .sh .m4
+
+.LIBS: .a
+
+# need to make sure this is set
+MACHINE_ARCH.${MACHINE} ?= ${MACHINE}
+.if empty(MACHINE_ARCH)
+MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
+.endif
+
+AR?= ar
+ARFLAGS?= rl
+RANLIB?= ranlib
+
+AS?= as
+AFLAGS?=
+.if ${MACHINE_ARCH} == "sparc64"
+AFLAGS+= -Wa,-Av9a
+.endif
+COMPILE.s?= ${CC} ${AFLAGS} -c
+LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
+LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CC?= cc
+.if ${MACHINE_ARCH} == "alpha" || \
+ ${MACHINE_ARCH} == "i386" || \
+ ${MACHINE_ARCH} == "m68k" || \
+ ${MACHINE_ARCH} == "sparc" || \
+ ${MACHINE_ARCH} == "vax"
+DBG?= -O2
+.else
+DBG?= -O
+.endif
+CFLAGS?= ${DBG}
+COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX?= c++
+CXXFLAGS?= ${CFLAGS}
+COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+OBJC?= ${CC}
+OBJCFLAGS?= ${CFLAGS}
+COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
+LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP?= cpp
+CPPFLAGS?=
+
+FC?= f77
+FFLAGS?= -O
+RFLAGS?=
+COMPILE.f?= ${FC} ${FFLAGS} -c
+LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+INSTALL?= install
+
+LEX?= lex
+LFLAGS?=
+LEX.l?= ${LEX} ${LFLAGS}
+
+LD?= ld
+LDFLAGS?=
+
+LINT?= lint
+LINTFLAGS?= -chapbxzF
+
+LORDER?= lorder
+
+MAKE?= make
+
+NM?= nm
+
+PC?= pc
+PFLAGS?=
+COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL?= sh
+
+SIZE?= size
+
+TSORT?= tsort -q
+
+YACC?= yacc
+YFLAGS?=
+YACC.y?= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.c.ln:
+ ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
+
+# C++
+.cc .cpp .cxx .C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o .cpp.o .cxx.o .C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a .cpp.a .cxx.a .C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/SunOS.mk b/contrib/bmake/mk/sys/SunOS.mk
new file mode 100644
index 0000000..f164aa2
--- /dev/null
+++ b/contrib/bmake/mk/sys/SunOS.mk
@@ -0,0 +1,232 @@
+# $Id: SunOS.mk,v 1.5 2010/01/11 23:02:05 sjg Exp $
+
+.if ${.PARSEFILE} == "sys.mk"
+.include <host-target.mk>
+
+OS?= SunOS.${HOST_OSMAJOR}
+unix?= We run ${OS}.
+.endif
+
+.if ${HOST_OSMAJOR} > 4
+ROOT_GROUP= root
+
+SHLIB_FULLVERSION = ${SHLIB_MAJOR}
+
+# supress the dependency
+LIBCRT0= /dev/null
+
+.ifndef CC
+# the PATH below may find an ancient gcc
+CC := ${gcc:L:${M_whence}}
+.export CC
+.endif
+
+# the stuff in /usr/xpg4/bin is usually more sane.
+PATH=/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/ucb:/usr/sfw/bin:/opt/gnu/bin:/usr/ccs/bin:/usr/local/bin
+.export PATH
+
+DSHLIBEXT = .so
+HOST_LIBDIRS = /usr/lib /lib /usr/sfw/lib
+
+# no -X
+LD_X=
+LD_x=
+RANLIB= :
+CPP= /usr/ccs/lib/cpp
+.else
+ROOT_GROUP= wheel
+RANLIB= ranlib
+CPP= cpp
+.endif
+
+# the rest is common
+
+.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+
+.LIBS: .a
+
+AR= ar
+ARFLAGS= rl
+
+AS= as
+AS_STDIN= -
+AFLAGS=
+COMPILE.s= ${AS} ${AFLAGS}
+LINK.s= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c
+LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+.if exists(/opt/gnu/bin/gcc) || exists(/usr/local/bin/gcc)
+CC ?= gcc -pipe
+DBG= -O -g
+STATIC= -static
+.else
+CC ?= cc
+DBG= -g
+STATIC= -Bstatic
+.endif
+CFLAGS= ${DBG}
+COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CXX= g++
+CXXFLAGS= ${CFLAGS}
+COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+.if defined(DESTDIR)
+CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include
+.endif
+
+MK_DEP= mkdeps.sh -N
+FC= f77
+FFLAGS= -O
+RFLAGS=
+COMPILE.f= ${FC} ${FFLAGS} -c
+LINK.f= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+LEX= lex
+LFLAGS=
+LEX.l= ${LEX} ${LFLAGS}
+
+LD= ld
+LDFLAGS=
+
+LINT= lint
+LINTFLAGS= -chapbx
+
+MAKE= bmake
+
+PC= pc
+PFLAGS=
+COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL= sh
+
+.if exists(/usr/local/bin/bison) || exists(/opt/gnu/bin/bison)
+YACC= bison -y
+.else
+YACC= yacc
+.endif
+YFLAGS= -d
+YACC.y= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++
+.cc:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/sys/UnixWare.mk b/contrib/bmake/mk/sys/UnixWare.mk
new file mode 100644
index 0000000..f21895b
--- /dev/null
+++ b/contrib/bmake/mk/sys/UnixWare.mk
@@ -0,0 +1,254 @@
+# $Id: UnixWare.mk,v 1.1 2005/10/09 22:56:40 sjg Exp $
+# based on "Id: SunOS.5.sys.mk,v 1.6 2003/09/30 16:42:23 sjg Exp "
+# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
+# @(#)sys.mk 5.11 (Berkeley) 3/13/91
+
+OS?= UnixWare
+unix?= We run ${OS}.
+ROOT_GROUP= root
+
+# can't fine one anywhere, so just stop the dependency
+LIBCRT0= /dev/null
+
+PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/ccs/lib:/usr/ucb:/usr/local/bin
+
+.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+
+.LIBS: .a
+
+# no -X
+LD_X=
+LD_x=
+AR?= ar
+ARFLAGS?= rl
+RANLIB?= :
+
+AS?= as
+AS_STDIN?= -
+AFLAGS?=
+COMPILE.s?= ${AS} ${AFLAGS}
+LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c
+LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+# at least gcc 2.95 on UnixWare has no internal macro to identify the system
+.if exists(/usr/local/bin/gcc)
+CC?= gcc -pipe -DUNIXWARE
+DBG?= -O -g
+STATIC?= -static
+.else
+CC?= cc
+DBG?= -g
+STATIC?= -Bstatic # XXX: don't know about UDK compilers
+.endif
+CFLAGS?= ${DBG}
+COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+.if exists(/usr/local/bin/g++)
+CXX?= g++ -DUNIXWARE
+.else
+CXX?= c++ # XXX: don't know about UDK compilers
+.endif
+CXXFLAGS?= ${CFLAGS}
+COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+CPP?= /usr/ccs/lib/cpp
+.if defined(DESTDIR)
+CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include
+.endif
+
+MK_DEP?= mkdeps.sh -N
+.if exists(/usr/local/bin/g77)
+FC?= g77
+.else
+FC?= f77 # XXX: don't know about UDK compilers
+.endif
+FFLAGS?= -O
+RFLAGS?=
+COMPILE.f?= ${FC} ${FFLAGS} -c
+LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+
+INSTALL?= /usr/ucb/install # BSD install
+
+LEX?= lex
+LFLAGS?=
+LEX.l?= ${LEX} ${LFLAGS}
+
+LD?= ld
+LDFLAGS?=
+
+LIBC?= ${DESTDIR}/usr/ccs/lib/libc.a
+LIBCOMPAT?=
+LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a
+LIBCURSES?= ${DESTDIR}/usr/ccs/lib/libcurses.a
+LIBDBM?=
+LIBDES?=
+LIBEDIT?=
+LIBGCC?=
+LIBKDB?=
+LIBKRB?=
+LIBKVM?=
+LIBL?= ${DESTDIR}/usr/ccs/lib/libl.a
+LIBM?= ${DESTDIR}/usr/ccs/lib/libm.a
+LIBMP?=
+LIBPC?=
+LIBPCAP?=
+LIBPLOT?=
+LIBRESOLV?=
+LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a
+LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a
+LIBTERMCAP?= ${DESTDIR}/usr/ccs/lib/libtermcap.a
+LIBUTIL?=
+LIBWRAP?=
+LIBY?= ${DESTDIR}/usr/ccs/lib/liby.a
+LIBZ?=
+
+LINT?= lint
+LINTFLAGS?= -pF
+
+LORDER?= lorder
+
+MAKE?= bmake
+
+NM?= nm
+
+PC?= pc # XXX: UDK probably does not have pc
+PFLAGS?=
+COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+
+SHELL?= sh
+
+SIZE?= size
+
+TSORT?= tsort
+
+.if exists(/usr/local/bin/bison)
+YACC?= bison -y
+.else
+YACC?= yacc
+.endif
+YFLAGS?= -d
+YACC.y?= ${YACC} ${YFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++
+.cc:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.cc.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.cc.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.C:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.C.o:
+ ${COMPILE.cc} ${.IMPSRC}
+.C.a:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
diff --git a/contrib/bmake/mk/target-flags.mk b/contrib/bmake/mk/target-flags.mk
new file mode 100644
index 0000000..f8932b2
--- /dev/null
+++ b/contrib/bmake/mk/target-flags.mk
@@ -0,0 +1,62 @@
+# NAME:
+# target-flags.mk - target specific flags
+#
+# DESCRIPTION:
+# Include this macro file after all others in a makefile and
+# follow it with any target specfic flag settings.
+# For each such variable v in TARGET_FLAG_VARS we set:
+#.nf
+#
+# _$v := ${$v}
+# $v = ${${v}_${.TARGET:T}:U${_$v}}
+#.fi
+#
+# This allows one to do things like:
+#.nf
+#
+# TARGET_FLAG_VARS= CFLAGS
+# .include <target-flags.mk>
+# CFLAGS_fu.o = ${_CFLAGS:N-Wall}
+#.fi
+#
+# To turn off -Wall for just the target fu.o
+# Actually CFLAGS is the default value for TARGET_FLAG_VARS.
+#
+# BUGS:
+# One must be careful to avoid creating circular references in
+# variables. The original version of this macro file did
+# elaborate things with CFLAGS. The current, simpler
+# implementation is ultimately more flexible.
+#
+# It is important that target-flags.mk is included after other
+# macro files and that target specific flags that may reference
+# _$v are set after that.
+#
+# Only works with a make(1) that does nested evaluation correctly.
+
+
+
+# RCSid:
+# $Id: target-flags.mk,v 1.8 2002/05/08 06:01:00 sjg Exp $
+#
+# @(#) Copyright (c) 1998-2002, 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
+#
+
+TARGET_FLAG_VARS?= CFLAGS
+.for v in ${TARGET_FLAG_VARS}
+.ifndef _$v
+_$v := ${$v}
+$v = ${${v}_${.TARGET:T}:U${_$v}}
+.endif
+.endfor
+
diff --git a/contrib/bmake/mk/warnings.mk b/contrib/bmake/mk/warnings.mk
new file mode 100644
index 0000000..9143e42
--- /dev/null
+++ b/contrib/bmake/mk/warnings.mk
@@ -0,0 +1,148 @@
+# RCSid:
+# $Id: warnings.mk,v 1.7 2009/12/11 17:06:03 sjg Exp $
+#
+# @(#) Copyright (c) 2002, 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
+#
+
+.ifndef _w_cflags
+
+# Any number of warnings sets can be added.
+.-include "warnings-sets.mk"
+
+# Modest defaults - put more elaborate sets in warnings-sets.mk
+# -Wunused etc are here so you can set
+# W_unused=-Wno-unused etc.
+MIN_WARNINGS?= -Wall \
+ -Wformat \
+ -Wimplicit \
+ -Wunused \
+ -Wuninitialized
+
+LOW_WARNINGS?= ${MIN_WARNINGS} -W -Wstrict-prototypes -Wmissing-prototypes
+
+MEDIUM_WARNINGS?= ${LOW_WARNINGS} -Werror
+
+HIGH_WARNINGS?= ${MEDIUM_WARNINGS} \
+ -Wcast-align \
+ -Wcast-qual \
+ -Wparentheses \
+ -Wpointer-arith \
+ -Wmissing-declarations \
+ -Wreturn-type \
+ -Wswitch \
+ -Wwrite-strings
+
+# The two step default makes it easier to test build with different defaults.
+DEFAULT_WARNINGS_SET?= MIN
+WARNINGS_SET?= ${DEFAULT_WARNINGS_SET}
+
+# If you add sets, besure to list them (you don't have to touch this list).
+ALL_WARNINGS_SETS+= MIN LOW MEDIUM HIGH
+
+.if empty(${WARNINGS_SET}_WARNINGS)
+.if ${MAKE_VERSION:U0:[1]:C/.*-//} >= 20050530
+.BEGIN: _empty_warnings
+_empty_warnings: .PHONY
+.else
+.BEGIN:
+.endif
+ @echo "ERROR: Invalid: WARNINGS_SET=${WARNINGS_SET}"
+ @echo "ERROR: Try one of: ${ALL_WARNINGS_SETS:O:u}"; exit 1
+
+.endif
+
+# Without -O or if we've set -O0 somewhere - to make debugging more effective,
+# we need to turn off -Wuninitialized as otherwise we get a warning that
+# -Werror turns into an error. To be safe, set W_uninitialized blank.
+_w_cflags:= ${CFLAGS} ${CPPFLAGS}
+.if ${_w_cflags:M-O*} == "" || ${_w_cflags:M-O0} != ""
+W_uninitialized=
+.endif
+
+.if ${MAKE_VERSION:U0:[1]:C/.*-//} <= 20040118
+# This version uses .for loops to avoid a double free bug in old bmake's
+# but the .for loops are sensitive to when this file is read.
+
+# first, make a list of all the warning flags - doesn't matter if
+# its redundant - we'll sort -u
+_all_sets= ${WARNINGS_SET_${MACHINE_ARCH}} ${WARNINGS_SET} ${ALL_WARNINGS_SETS}
+_all_warnings= ${WARNINGS} ${_all_sets:O:u:@s@${$s_WARNINGS}@}
+
+# we want to set W_* for each warning so they are easy to turn off.
+# :O:u does a sort -u
+# using :C allows us to handle -f* -w* etc as well as -W*
+.for w in ${_all_warnings:O:u}
+${w:C/-(.)/\1_/} ?= $w
+.endfor
+
+# Allow for per-target warnings
+# Warning: the WARNINGS+= line below,
+# may make your brain hurt - trust me; it works --sjg
+# the idea is that you can set WARNINGS_SET[_${MACHINE_ARCH}]=HIGH
+# and use one of
+# W_format_mips_foo.o=
+# W_format_foo.o=
+# to turn off -Wformat for foo.o (on mips only in the first case), or
+# W_format_foo.o=-Wformat=2
+# for stricter checking.
+#
+# NOTE: that we force the target extension to be .o
+#
+.for w in ${WARNINGS_SET_${MACHINE_ARCH}:U${WARNINGS_SET}:@s@${$s_WARNINGS}@:O:u}
+WARNINGS+= ${${w:C/-(.)/\1_/}_${MACHINE_ARCH}_${.TARGET:T:R}.o:U${${w:C/-(.)/\1_/}_${.TARGET:T:R}.o:U${${w:C/-(.)/\1_/}_${MACHINE_ARCH}:U${${w:C/-(.)/\1_/}}}}}
+.endfor
+
+.else
+
+# .for loops have the [dis]advantage of being evaluated when read,
+# so adding to WARNINGS_SET[_${MACHINE_ARCH}] after this file is
+# read has no effect.
+# Replacing the above .for loops with the WARNINGS+= below solves that
+# but tiggers a double free bug in bmake-20040118 and earlier.
+# Don't try and read this too fast!
+#
+# The first :@ "loop" handles multiple sets in WARNINGS_SET
+#
+# In the second :@ "loop", the ::?= noise sets W_foo?=-Wfoo etc
+# which makes it easy to turn off override individual flags
+# (see W_uninitialized above).
+#
+# The last bit expands to ${W_foo_${.TARGET:T}:U${W_foo}}
+# which is the bit we ultimately want. It allows W_* to be set on a
+# per target basis.
+#
+# NOTE: that we force the target extension to be .o
+#
+WARNINGS+= ${WARNINGS_SET_${MACHINE_ARCH}:U${WARNINGS_SET}:@s@${$s_WARNINGS}@:O:u:@w@${${w:C/-(.)/\1_/}::?=$w} ${${w:C/-(.)/\1_/}_${MACHINE_ARCH}_${.TARGET:T:R}.o:U${${w:C/-(.)/\1_/}_${.TARGET:T:R}.o:U${${w:C/-(.)/\1_/}_${MACHINE_ARCH}:U${${w:C/-(.)/\1_/}}}}}@}
+
+.endif
+
+.ifndef NO_CFLAGS_WARNINGS
+# Just ${WARNINGS} should do, but this is more flexible?
+CFLAGS+= ${WARNINGS_${.TARGET:T:R}.o:U${WARNINGS}}
+.endif
+
+# it is rather silly that g++ blows up on some warning flags
+NO_CXX_WARNINGS+= \
+ missing-declarations \
+ missing-prototypes \
+ nested-externs \
+ strict-prototypes
+
+.for s in ${SRCS:M*.cc}
+.for w in ${NO_CXX_WARNINGS}
+W_$w_${s:T:R}.o=
+.endfor
+.endfor
+
+.endif # _w_cflags
diff --git a/contrib/bmake/mk/yacc.mk b/contrib/bmake/mk/yacc.mk
new file mode 100644
index 0000000..910b004
--- /dev/null
+++ b/contrib/bmake/mk/yacc.mk
@@ -0,0 +1,57 @@
+# $Id: yacc.mk,v 1.6 2011/06/10 22:45:46 sjg Exp $
+
+#
+# @(#) Copyright (c) 1999-2011, 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 file contains rules to DTRT when SRCS contains foo.y or foo.c
+# when only a foo.y exists.
+
+YACC?= yacc
+YFLAGS?= -v -t
+RM?= rm
+
+YACC.y?= ${YACC} ${YFLAGS}
+
+.if ${YACC.y:M-d} == "" || defined(NO_RENAME_Y_TAB_H)
+
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET}
+ ${RM} -f y.tab.[!h]
+
+.else
+
+# the touch of the .c is to ensure it is newer than .h (paranoia)
+.y.h:
+ ${YACC.y} ${.IMPSRC}
+ [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET:T:R}.c
+ [ ! -s y.tab.h ] || cmp -s y.tab.h ${.TARGET:T:R}.h \
+ || mv y.tab.h ${.TARGET:T:R}.h
+ touch ${.TARGET:T:R}.c
+ ${RM} -f y.tab.*
+
+# Normally the .y.h rule does the work - to avoid races.
+# If for any reason the .c is lost but the .h remains,
+# regenerate the .c
+.y.c: ${.TARGET:T:R}.h
+ [ -s ${.TARGET} ] || { \
+ ${YACC.y} ${.IMPSRC} && \
+ { [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET}; \
+ ${RM} y.tab.*; }; }
+.endif
+
+beforedepend: ${SRCS:T:M*.y:S/.y/.c/g}
+
+CLEANFILES+= ${SRCS:T:M*.y:S/.y/.[ch]/g}
+CLEANFILES+= y.tab.[ch]
diff --git a/contrib/bmake/realpath.c b/contrib/bmake/realpath.c
index 1ef2cd8..fbf0335 100644
--- a/contrib/bmake/realpath.c
+++ b/contrib/bmake/realpath.c
@@ -1,5 +1,5 @@
-/* $Id: realpath.c,v 1.2 2010/04/21 17:47:49 sjg Exp $ */
-/* from: $NetBSD: getcwd.c,v 1.45 2007/10/26 19:48:14 christos Exp $ */
+/* $Id: realpath.c,v 1.3 2013/01/25 17:06:09 sjg Exp $ */
+/* from: $NetBSD: getcwd.c,v 1.53 2012/06/21 23:29:23 enami Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
@@ -52,24 +52,40 @@
# include <unistd.h>
#endif
+#ifndef __restrict
+# define __restrict /* restrict */
+#endif
+
/*
- * char *realpath(const char *path, char resolved[MAXPATHLEN]);
+ * char *realpath(const char *path, char *resolved);
*
* 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)
+realpath(const char * __restrict path, char * __restrict resolved)
{
struct stat sb;
- int idx = 0, n, nlnk = 0;
+ int idx = 0, nlnk = 0;
const char *q;
- char *p, wbuf[2][MAXPATHLEN];
+ char *p, wbuf[2][MAXPATHLEN], *fres;
size_t len;
+ ssize_t n;
+
+ /* POSIX sez we must test for this */
+ if (path == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (resolved == NULL) {
+ fres = resolved = malloc(MAXPATHLEN);
+ if (resolved == NULL)
+ return NULL;
+ } else
+ fres = NULL;
- if (!path || !resolved || path == resolved)
- return (NULL);
/*
* Build real path one by one with paying an attention to .,
@@ -82,10 +98,10 @@ realpath(const char *path, char *resolved)
*/
p = resolved;
- if (*path == 0) {
- *p = 0;
+ if (*path == '\0') {
+ *p = '\0';
errno = ENOENT;
- return (NULL);
+ goto out;
}
/* If relative path, start from current working directory. */
@@ -93,8 +109,8 @@ realpath(const char *path, char *resolved)
/* check for resolved pointer to appease coverity */
if (resolved && getcwd(resolved, MAXPATHLEN) == NULL) {
p[0] = '.';
- p[1] = 0;
- return (NULL);
+ p[1] = '\0';
+ goto out;
}
len = strlen(resolved);
if (len > 1)
@@ -106,18 +122,18 @@ loop:
while (*path == '/')
path++;
- if (*path == 0) {
+ if (*path == '\0') {
if (p == resolved)
*p++ = '/';
- *p = 0;
- return (resolved);
+ *p = '\0';
+ return resolved;
}
/* Find the end of this component. */
q = path;
do
q++;
- while (*q != '/' && *q != 0);
+ while (*q != '/' && *q != '\0');
/* Test . or .. */
if (path[0] == '.') {
@@ -129,7 +145,7 @@ loop:
/* Trim the last component. */
if (p != resolved)
while (*--p != '/')
- ;
+ continue;
path = q;
goto loop;
}
@@ -140,39 +156,39 @@ loop:
errno = ENAMETOOLONG;
if (p == resolved)
*p++ = '/';
- *p = 0;
- return (NULL);
+ *p = '\0';
+ goto out;
}
p[0] = '/';
memcpy(&p[1], path,
/* LINTED We know q > path. */
q - path);
- p[1 + q - path] = 0;
+ 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 (lstat(resolved, &sb) == -1)
+ goto out;
+
if (S_ISLNK(sb.st_mode)) {
if (nlnk++ >= MAXSYMLINKS) {
errno = ELOOP;
- return (NULL);
+ goto out;
}
n = readlink(resolved, wbuf[idx], sizeof(wbuf[0]) - 1);
if (n < 0)
- return (NULL);
+ goto out;
if (n == 0) {
errno = ENOENT;
- return (NULL);
+ goto out;
}
/* Append unresolved path to link target and switch to it. */
if (n + (len = strlen(q)) + 1 > sizeof(wbuf[0])) {
errno = ENAMETOOLONG;
- return (NULL);
+ goto out;
}
memcpy(&wbuf[idx][n], q, len + 1);
path = wbuf[idx];
@@ -185,12 +201,15 @@ loop:
}
if (*q == '/' && !S_ISDIR(sb.st_mode)) {
errno = ENOTDIR;
- return (NULL);
+ goto out;
}
/* Advance both resolved and unresolved path. */
p += 1 + q - path;
path = q;
goto loop;
+out:
+ free(fres);
+ return NULL;
}
#endif
diff --git a/contrib/bmake/unit-tests/Makefile.in b/contrib/bmake/unit-tests/Makefile.in
index e5bf9b2..a64a074 100644
--- a/contrib/bmake/unit-tests/Makefile.in
+++ b/contrib/bmake/unit-tests/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.39 2012/11/09 19:16:10 sjg Exp $
+# $Id: Makefile.in,v 1.40 2012/12/28 21:28:19 sjg Exp $
#
# $NetBSD: Makefile,v 1.35 2012/11/09 19:08:28 sjg Exp $
#
@@ -64,7 +64,7 @@ ${SUBFILES}:
clean:
rm -f *.out *.fail *.core
-.-include <bsd.obj.mk>
+.-include <obj.mk>
TEST_MAKE?= ${.MAKE}
TOOL_SED?= sed
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c
index e958a36..2e73d5b 100644
--- a/contrib/bmake/var.c
+++ b/contrib/bmake/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $ */
+/* $NetBSD: var.c,v 1.172 2012/11/15 16:42:26 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.172 2012/11/15 16:42:26 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $");
+__RCSID("$NetBSD: var.c,v 1.172 2012/11/15 16:42:26 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -2567,7 +2567,8 @@ ApplyModifiers(char *nstr, const char *tstr,
}
apply_mods:
if (DEBUG(VAR)) {
- fprintf(debug_file, "Applying :%c to \"%s\"\n", *tstr, nstr);
+ fprintf(debug_file, "Applying[%s] :%c to \"%s\"\n", v->name,
+ *tstr, nstr);
}
newStr = var_Error;
switch ((modifier = *tstr)) {
@@ -3167,8 +3168,8 @@ ApplyModifiers(char *nstr, const char *tstr,
free(cp2);
}
if (DEBUG(VAR))
- fprintf(debug_file, "Pattern for [%s] is [%s]\n", nstr,
- pattern);
+ fprintf(debug_file, "Pattern[%s] for [%s] is [%s]\n",
+ v->name, nstr, pattern);
if (*tstr == 'M') {
newStr = VarModify(ctxt, &parsestate, nstr, VarMatch,
pattern);
@@ -3523,7 +3524,8 @@ ApplyModifiers(char *nstr, const char *tstr,
}
}
if (DEBUG(VAR)) {
- fprintf(debug_file, "Result of :%c is \"%s\"\n", modifier, newStr);
+ fprintf(debug_file, "Result[%s] of :%c is \"%s\"\n",
+ v->name, modifier, newStr);
}
if (newStr != nstr) {
OpenPOWER on IntegriCloud