aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-03-08 19:21:22 +0100
committerDuncaen <mail@duncano.de>2017-03-08 19:34:12 +0100
commitc7570b8fc168601bcd596624b04d0b17c6d0f508 (patch)
tree2aa2b1869b494af47a7d084064b6fc482b534097
parentd064f905593ebd2a691f0029d733021e8bc03576 (diff)
downloadlobase-c7570b8fc168601bcd596624b04d0b17c6d0f508.tar.gz
mk: add MAKEOBJDIR support
-rw-r--r--Makefile6
-rw-r--r--bin/Makefile7
-rw-r--r--bin/cat/Makefile4
-rw-r--r--bin/chmod/Makefile4
-rw-r--r--bin/cp/Makefile4
-rw-r--r--bin/date/Makefile4
-rw-r--r--bin/dd/Makefile4
-rw-r--r--bin/df/Makefile4
-rw-r--r--bin/domainname/Makefile4
-rw-r--r--bin/echo/Makefile4
-rw-r--r--bin/ed/Makefile4
-rw-r--r--bin/expr/Makefile4
-rw-r--r--bin/hostname/Makefile4
-rw-r--r--bin/kill/Makefile4
-rw-r--r--bin/ln/Makefile4
-rw-r--r--bin/ls/Makefile4
-rw-r--r--bin/md5/Makefile4
-rw-r--r--bin/mkdir/Makefile4
-rw-r--r--bin/mv/Makefile4
-rw-r--r--bin/pax/Makefile4
-rw-r--r--bin/pwd/Makefile4
-rw-r--r--bin/rm/Makefile4
-rw-r--r--bin/rmdir/Makefile4
-rw-r--r--bin/sleep/Makefile4
-rw-r--r--bin/stty/Makefile4
-rw-r--r--bin/sync/Makefile4
-rw-r--r--bin/test/Makefile4
-rw-r--r--lib/Makefile5
-rw-r--r--lib/libopenbsd/Makefile.inc32
-rw-r--r--lib/libopenbsd/crypt/Makefile.inc7
-rw-r--r--lib/libopenbsd/gen/Makefile.inc10
-rw-r--r--lib/libopenbsd/net/Makefile.inc8
-rw-r--r--lib/libopenbsd/stdio/Makefile.inc12
-rw-r--r--lib/libopenbsd/stdlib/Makefile.inc9
-rw-r--r--lib/libopenbsd/string/Makefile.inc18
-rw-r--r--lib/libopenbsd/sys/Makefile.inc16
-rw-r--r--lib/libutil/Makefile5
-rw-r--r--mk/bsd.lib.mk21
-rw-r--r--mk/bsd.own.mk44
-rw-r--r--mk/bsd.prog.mk56
-rw-r--r--mk/bsd.regress.mk2
-rw-r--r--mk/bsd.subdir.mk53
-rw-r--r--regress/Makefile5
-rw-r--r--regress/bin/Makefile6
-rw-r--r--regress/bin/cat/Makefile2
-rw-r--r--regress/bin/chmod/Makefile2
-rw-r--r--regress/bin/ln/Makefile2
-rw-r--r--regress/bin/md5/Makefile2
-rw-r--r--regress/bin/pax/Makefile2
-rw-r--r--regress/bin/test/Makefile2
-rw-r--r--regress/sbin/Makefile5
-rw-r--r--regress/usr.bin/Makefile9
-rw-r--r--regress/usr.bin/basename/Makefile2
-rw-r--r--regress/usr.bin/bc/Makefile2
-rw-r--r--regress/usr.bin/calendar/Makefile2
-rw-r--r--regress/usr.bin/colrm/Makefile2
-rw-r--r--regress/usr.bin/column/Makefile2
-rw-r--r--regress/usr.bin/cut/Makefile2
-rw-r--r--regress/usr.bin/dc/Makefile2
-rw-r--r--regress/usr.bin/diff/Makefile2
-rw-r--r--regress/usr.bin/diff3/Makefile2
-rw-r--r--regress/usr.bin/dirname/Makefile2
-rw-r--r--regress/usr.bin/file/Makefile2
-rw-r--r--regress/usr.bin/fmt/Makefile2
-rw-r--r--regress/usr.bin/fold/Makefile2
-rw-r--r--regress/usr.bin/grep/Makefile2
-rw-r--r--regress/usr.bin/jot/Makefile2
-rw-r--r--regress/usr.bin/tail/Makefile2
-rw-r--r--regress/usr.bin/tsort/Makefile2
-rw-r--r--regress/usr.bin/ul/Makefile2
-rw-r--r--regress/usr.bin/wc/Makefile2
-rw-r--r--regress/usr.bin/xargs/Makefile2
-rw-r--r--regress/usr.sbin/Makefile6
-rw-r--r--sbin/Makefile6
-rw-r--r--sbin/mknod/Makefile4
-rw-r--r--usr.bin/Makefile19
-rw-r--r--usr.bin/apply/Makefile4
-rw-r--r--usr.bin/awk/Makefile5
-rw-r--r--usr.bin/basename/Makefile4
-rw-r--r--usr.bin/bc/Makefile6
-rw-r--r--usr.bin/biff/Makefile4
-rw-r--r--usr.bin/cal/Makefile4
-rw-r--r--usr.bin/calendar/Makefile4
-rw-r--r--usr.bin/cmp/Makefile4
-rw-r--r--usr.bin/col/Makefile4
-rw-r--r--usr.bin/colrm/Makefile4
-rw-r--r--usr.bin/column/Makefile4
-rw-r--r--usr.bin/comm/Makefile4
-rw-r--r--usr.bin/cu/Makefile4
-rw-r--r--usr.bin/cut/Makefile4
-rw-r--r--usr.bin/dc/Makefile5
-rw-r--r--usr.bin/diff/Makefile4
-rw-r--r--usr.bin/diff3/Makefile4
-rw-r--r--usr.bin/dirname/Makefile4
-rw-r--r--usr.bin/du/Makefile4
-rw-r--r--usr.bin/env/Makefile4
-rw-r--r--usr.bin/expand/Makefile4
-rw-r--r--usr.bin/false/Makefile4
-rw-r--r--usr.bin/file/Makefile4
-rw-r--r--usr.bin/fmt/Makefile4
-rw-r--r--usr.bin/fold/Makefile4
-rw-r--r--usr.bin/getopt/Makefile4
-rw-r--r--usr.bin/grep/Makefile4
-rw-r--r--usr.bin/head/Makefile4
-rw-r--r--usr.bin/hexdump/Makefile4
-rw-r--r--usr.bin/id/Makefile4
-rw-r--r--usr.bin/indent/Makefile4
-rw-r--r--usr.bin/join/Makefile4
-rw-r--r--usr.bin/jot/Makefile4
-rw-r--r--usr.bin/lam/Makefile4
-rw-r--r--usr.bin/lndir/Makefile4
-rw-r--r--usr.bin/logger/Makefile4
-rw-r--r--usr.bin/logname/Makefile4
-rw-r--r--usr.bin/look/Makefile4
-rw-r--r--usr.bin/mktemp/Makefile4
-rw-r--r--usr.bin/newsyslog/Makefile4
-rw-r--r--usr.bin/nice/Makefile4
-rw-r--r--usr.bin/nl/Makefile4
-rw-r--r--usr.bin/nohup/Makefile4
-rw-r--r--usr.bin/paste/Makefile4
-rw-r--r--usr.bin/patch/Makefile4
-rw-r--r--usr.bin/printenv/Makefile4
-rw-r--r--usr.bin/printf/Makefile4
-rw-r--r--usr.bin/readlink/Makefile4
-rw-r--r--usr.bin/renice/Makefile4
-rw-r--r--usr.bin/rev/Makefile4
-rw-r--r--usr.bin/rs/Makefile4
-rw-r--r--usr.bin/sdiff/Makefile4
-rw-r--r--usr.bin/sed/Makefile4
-rw-r--r--usr.bin/shar/Makefile4
-rw-r--r--usr.bin/sort/Makefile4
-rw-r--r--usr.bin/split/Makefile6
-rw-r--r--usr.bin/stat/Makefile4
-rw-r--r--usr.bin/tee/Makefile4
-rw-r--r--usr.bin/time/Makefile4
-rw-r--r--usr.bin/touch/Makefile4
-rw-r--r--usr.bin/tr/Makefile4
-rw-r--r--usr.bin/true/Makefile4
-rw-r--r--usr.bin/tsort/Makefile4
-rw-r--r--usr.bin/tty/Makefile4
-rw-r--r--usr.bin/uname/Makefile4
-rw-r--r--usr.bin/unexpand/Makefile4
-rw-r--r--usr.bin/uniq/Makefile4
-rw-r--r--usr.bin/unvis/Makefile4
-rw-r--r--usr.bin/uudecode/Makefile4
-rw-r--r--usr.bin/uuencode/Makefile4
-rw-r--r--usr.bin/vis/Makefile4
-rw-r--r--usr.bin/wc/Makefile4
-rw-r--r--usr.bin/what/Makefile4
-rw-r--r--usr.bin/which/Makefile5
-rw-r--r--usr.bin/xinstall/Makefile4
-rw-r--r--usr.sbin/Makefile6
-rw-r--r--usr.sbin/mtree/Makefile4
-rw-r--r--usr.sbin/rdate/Makefile4
154 files changed, 630 insertions, 214 deletions
diff --git a/Makefile b/Makefile
index 91d24bf..784e1ec 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,7 @@
-export TOPDIR := $(shell pwd)
-
-SUBDIR = lib bin sbin usr.bin usr.sbin
+SUBDIR= lib bin sbin usr.bin usr.sbin
ifeq (clean,$(filter clean,$(MAKECMDGOALS)))
-SUBDIR += regress
+SUBDIR+=regress
endif
all:
diff --git a/bin/Makefile b/bin/Makefile
index bccaa47..039aaca 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -1,3 +1,4 @@
-SUBDIR = cat chmod cp date dd df domainname echo ed expr hostname kill ln ls \
- md5 mkdir mv pax pwd rm rmdir sleep stty sync test
-include bsd.subdir.mk
+TOPDIR?=..
+SUBDIR= cat chmod cp date dd df domainname echo ed expr hostname kill ln ls \
+ md5 mkdir mv pax pwd rm rmdir sleep stty sync test
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/bin/cat/Makefile b/bin/cat/Makefile
index 44a515f..f21f2cb 100644
--- a/bin/cat/Makefile
+++ b/bin/cat/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.4 2017/02/19 00:46:57 jca Exp $
+.TOPDIR?=../..
+
PROG= cat
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/chmod/Makefile b/bin/chmod/Makefile
index e39cc1d..c29e904 100644
--- a/bin/chmod/Makefile
+++ b/bin/chmod/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.7 2001/09/06 18:52:55 mickey Exp $
+.TOPDIR?=../..
+
PROG= chmod
CFLAGS+=-DSUPPORT_DOT
MAN= chmod.1 chgrp.1 chown.8 chflags.1
@@ -15,4 +17,4 @@ LINKS= ${BINDIR}/chmod ${BINDIR}/chgrp \
# ln -sf ../../bin/chmod chflags)
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/cp/Makefile b/bin/cp/Makefile
index d48e19a..78c7fd0 100644
--- a/bin/cp/Makefile
+++ b/bin/cp/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:34:47 deraadt Exp $
+.TOPDIR?=../..
+
PROG= cp
SRCS= cp.c utils.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/date/Makefile b/bin/date/Makefile
index 6edb89a..dbf7a86 100644
--- a/bin/date/Makefile
+++ b/bin/date/Makefile
@@ -1,8 +1,10 @@
# $OpenBSD: Makefile,v 1.4 2011/07/07 21:00:59 deraadt Exp $
+.TOPDIR?=../..
+
PROG= date
SRCS= date.c
DPADD+= ${LIBUTIL}
LDADD+= -lutil
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/dd/Makefile b/bin/dd/Makefile
index 641bdc9..39f54d5 100644
--- a/bin/dd/Makefile
+++ b/bin/dd/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.5 1998/05/29 04:34:20 rahnds Exp $
+.TOPDIR?=../..
+
PROG= dd
SRCS= args.c conv.c conv_tab.c dd.c misc.c position.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/df/Makefile b/bin/df/Makefile
index 1fb1a80..87277b2 100644
--- a/bin/df/Makefile
+++ b/bin/df/Makefile
@@ -1,8 +1,10 @@
# $OpenBSD: Makefile,v 1.8 2003/05/26 18:02:32 ian Exp $
+.TOPDIR?=../..
+
PROG= df
SRCS= df.c
LDADD= -lutil
DPADD= ${LIBUTIL}
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/domainname/Makefile b/bin/domainname/Makefile
index 90ac043..d2f1423 100644
--- a/bin/domainname/Makefile
+++ b/bin/domainname/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:34:59 deraadt Exp $
+.TOPDIR?=../..
+
PROG= domainname
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/echo/Makefile b/bin/echo/Makefile
index 5fbe97f..7cdf2d0 100644
--- a/bin/echo/Makefile
+++ b/bin/echo/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:02 deraadt Exp $
+.TOPDIR?=../..
+
PROG= echo
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/ed/Makefile b/bin/ed/Makefile
index 9e2439b..ee0aa09 100644
--- a/bin/ed/Makefile
+++ b/bin/ed/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.11 2014/05/24 01:35:55 daniel Exp $
+.TOPDIR?=../..
+
PROG= ed
CFLAGS+=-DBACKWARDS
SRCS= buf.c glbl.c io.c main.c re.c sub.c undo.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/expr/Makefile b/bin/expr/Makefile
index d4d2cdc..247c84c 100644
--- a/bin/expr/Makefile
+++ b/bin/expr/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:07 deraadt Exp $
+.TOPDIR?=../..
+
PROG= expr
SRCS= expr.c
CPPFLAGS+=-D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/hostname/Makefile b/bin/hostname/Makefile
index 7e88e0a..590ec3d 100644
--- a/bin/hostname/Makefile
+++ b/bin/hostname/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:09 deraadt Exp $
+.TOPDIR?=../..
+
PROG= hostname
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/kill/Makefile b/bin/kill/Makefile
index 9ba86c4..d82111f 100644
--- a/bin/kill/Makefile
+++ b/bin/kill/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:12 deraadt Exp $
+.TOPDIR?=../..
+
PROG= kill
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/ln/Makefile b/bin/ln/Makefile
index 0f47498..eaca950 100644
--- a/bin/ln/Makefile
+++ b/bin/ln/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:15 deraadt Exp $
+.TOPDIR?=../..
+
PROG= ln
MAN= ln.1 symlink.7
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/ls/Makefile b/bin/ls/Makefile
index 1e9c9aa..22d62a6 100644
--- a/bin/ls/Makefile
+++ b/bin/ls/Makefile
@@ -1,9 +1,11 @@
# $OpenBSD: Makefile,v 1.8 2015/12/01 18:36:13 schwarze Exp $
+.TOPDIR?=../..
+
PROG= ls
SRCS= cmp.c ls.c main.c print.c util.c utf8.c
DPADD= ${LIBUTIL}
LDADD= -lutil
CPPFLAGS+=-D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/md5/Makefile b/bin/md5/Makefile
index 3d3ad4c..4d18929 100644
--- a/bin/md5/Makefile
+++ b/bin/md5/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.15 2016/03/30 06:38:40 jmc Exp $
+.TOPDIR?=../..
+
PROG= md5
SRCS= crc.c md5.c
MAN= cksum.1 md5.1
@@ -11,4 +13,4 @@ LINKS= ${BINDIR}/md5 ${BINDIR}/sha1 \
CPPFLAGS+= -I${.CURDIR} -D_GNU_SOURCE
COPTS+= -Wall -Wconversion -Wmissing-prototypes
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/mkdir/Makefile b/bin/mkdir/Makefile
index 3c4a949..aaf388a 100644
--- a/bin/mkdir/Makefile
+++ b/bin/mkdir/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:20 deraadt Exp $
+.TOPDIR?=../..
+
PROG= mkdir
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/mv/Makefile b/bin/mv/Makefile
index b2f6c1e..5dbc460 100644
--- a/bin/mv/Makefile
+++ b/bin/mv/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.5 2016/02/01 22:38:01 gsoares Exp $
+.TOPDIR?=../..
+
PROG= mv
SRCS= mv.c cp.c rm.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/pax/Makefile b/bin/pax/Makefile
index 14a7c93..ec57f81 100644
--- a/bin/pax/Makefile
+++ b/bin/pax/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.11 2014/01/08 04:58:36 guenther Exp $
+.TOPDIR?=../..
+
PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
@@ -7,4 +9,4 @@ SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
MAN= pax.1 tar.1 cpio.1
LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/pwd/Makefile b/bin/pwd/Makefile
index 8eefafa..9e6053c 100644
--- a/bin/pwd/Makefile
+++ b/bin/pwd/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:35 deraadt Exp $
+.TOPDIR?=../..
+
PROG= pwd
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/rm/Makefile b/bin/rm/Makefile
index b8d7114..b68441e 100644
--- a/bin/rm/Makefile
+++ b/bin/rm/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:40 deraadt Exp $
+.TOPDIR?=../..
+
PROG= rm
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/rmdir/Makefile b/bin/rmdir/Makefile
index 09dacee..8951858 100644
--- a/bin/rmdir/Makefile
+++ b/bin/rmdir/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:45 deraadt Exp $
+.TOPDIR?=../..
+
PROG= rmdir
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/sleep/Makefile b/bin/sleep/Makefile
index 111bd19..2ca10c5 100644
--- a/bin/sleep/Makefile
+++ b/bin/sleep/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:48 deraadt Exp $
+.TOPDIR?=../..
+
PROG= sleep
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/stty/Makefile b/bin/stty/Makefile
index e617aa3..12efe50 100644
--- a/bin/stty/Makefile
+++ b/bin/stty/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:50 deraadt Exp $
+.TOPDIR?=../..
+
PROG= stty
SRCS= cchar.c gfmt.c key.c modes.c print.c stty.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/sync/Makefile b/bin/sync/Makefile
index 6c258e2..e08167e 100644
--- a/bin/sync/Makefile
+++ b/bin/sync/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:35:53 deraadt Exp $
+.TOPDIR?=../..
+
PROG= sync
MAN= sync.8
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/bin/test/Makefile b/bin/test/Makefile
index 4e1ddc8..fdffa1f 100644
--- a/bin/test/Makefile
+++ b/bin/test/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.5 2016/03/30 06:38:40 jmc Exp $
+.TOPDIR?=../..
+
PROG= test
SRCS= test.c
LINKS= ${BINDIR}/test ${BINDIR}/[
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/lib/Makefile b/lib/Makefile
index 021466b..4ea9f4c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,2 +1,3 @@
-SUBDIR = libopenbsd libutil
-include bsd.subdir.mk
+TOPDIR?=..
+SUBDIR= libopenbsd libutil
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/lib/libopenbsd/Makefile.inc b/lib/libopenbsd/Makefile.inc
new file mode 100644
index 0000000..c4b6a38
--- /dev/null
+++ b/lib/libopenbsd/Makefile.inc
@@ -0,0 +1,32 @@
+# $OpenBSD: Makefile.inc,v 1.29 2016/05/07 19:05:21 guenther Exp $
+#
+# This file contains make rules used to build libc
+#
+
+ifndef LIBCSRCDIR
+all:
+ @echo "need to define LIBCSRCDIR" >&2; exit 1
+endif
+
+CFLAGS+=-I${LIBCSRCDIR}/include -I${LIBCSRCDIR}/hidden -D__LIBC__ \
+ -Werror-implicit-function-declaration -include namespace.h
+
+#.if ${COMPILER_VERSION:L} != "gcc3"
+CFLAGS+=-Werror=deprecated-declarations
+#.endif
+
+# Include link-time warnings about unsafe API uses (ie. strcpy)
+CFLAGS+=-DAPIWARN
+
+include ${LIBCSRCDIR}/gen/Makefile.inc
+include ${LIBCSRCDIR}/crypt/Makefile.inc
+include ${LIBCSRCDIR}/hash/Makefile.inc
+include ${LIBCSRCDIR}/net/Makefile.inc
+
+include ${LIBCSRCDIR}/regex/Makefile.inc
+include ${LIBCSRCDIR}/stdio/Makefile.inc
+include ${LIBCSRCDIR}/stdlib/Makefile.inc
+include ${LIBCSRCDIR}/string/Makefile.inc
+include ${LIBCSRCDIR}/sys/Makefile.inc
+
+${OBJS} ${GOBJS} ${POBJS} ${SOBJS} ${DOBJS}: ${LIBCSRCDIR}/include/namespace.h
diff --git a/lib/libopenbsd/crypt/Makefile.inc b/lib/libopenbsd/crypt/Makefile.inc
new file mode 100644
index 0000000..0a433f9
--- /dev/null
+++ b/lib/libopenbsd/crypt/Makefile.inc
@@ -0,0 +1,7 @@
+# $OpenBSD: Makefile.inc,v 1.27 2016/03/30 06:38:41 jmc Exp $
+
+VPATH+= ${LIBCSRCDIR}/arch/${MACHINE_CPU}/crypt ${LIBCSRCDIR}/crypt
+
+SRCS+= arc4random.c arc4random_uniform.c blowfish.c
+
+MAN+= blowfish.3 arc4random.3
diff --git a/lib/libopenbsd/gen/Makefile.inc b/lib/libopenbsd/gen/Makefile.inc
new file mode 100644
index 0000000..42e979d
--- /dev/null
+++ b/lib/libopenbsd/gen/Makefile.inc
@@ -0,0 +1,10 @@
+# $OpenBSD: Makefile.inc,v 1.29 2016/03/30 06:38:41 jmc Exp $
+
+# stdio sources
+VPATH+= ${LIBCSRCDIR}/gen
+
+SRCS+= basename.c dirname.c errc.c fts.c getmntinfo.c setmode.c unvis.c \
+ verrc.c vis.c vwarnc.c warnc.c
+
+
+MAN+= basename.3 dirname.3 fts.3 getmntinfo.3 setmode.3 unvis.3 vis.3
diff --git a/lib/libopenbsd/net/Makefile.inc b/lib/libopenbsd/net/Makefile.inc
new file mode 100644
index 0000000..92ecca5
--- /dev/null
+++ b/lib/libopenbsd/net/Makefile.inc
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile.inc,v 1.59 2016/03/30 06:38:41 jmc Exp $
+
+# net sources
+VPATH+= ${LIBCSRCDIR}/net
+
+CFLAGS+=-DRESOLVSORT
+
+SRCS+= base64.c
diff --git a/lib/libopenbsd/stdio/Makefile.inc b/lib/libopenbsd/stdio/Makefile.inc
new file mode 100644
index 0000000..d7024fa
--- /dev/null
+++ b/lib/libopenbsd/stdio/Makefile.inc
@@ -0,0 +1,12 @@
+# $OpenBSD: Makefile.inc,v 1.29 2016/03/30 06:38:41 jmc Exp $
+
+# stdio sources
+VPATH+= ${LIBCSRCDIR}/stdio
+
+SRCS+= fgetwln.c
+
+ifneq ($(HAVE_FGETLN),1)
+SRCS+= fgetln.c
+endif
+
+MAN+= fgetwln.3
diff --git a/lib/libopenbsd/stdlib/Makefile.inc b/lib/libopenbsd/stdlib/Makefile.inc
new file mode 100644
index 0000000..e49c320
--- /dev/null
+++ b/lib/libopenbsd/stdlib/Makefile.inc
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile.inc,v 1.61 2016/08/14 23:18:03 guenther Exp $
+
+# stdlib sources
+VPATH+= ${LIBCSRCDIR}/stdlib
+
+ifneq ($(HAVE_REALLOCARRAY),1)
+SRCS+= reallocarray.c
+MAN+= malloc.3
+endif
diff --git a/lib/libopenbsd/string/Makefile.inc b/lib/libopenbsd/string/Makefile.inc
new file mode 100644
index 0000000..2c845d7
--- /dev/null
+++ b/lib/libopenbsd/string/Makefile.inc
@@ -0,0 +1,18 @@
+# $OpenBSD: Makefile.inc,v 1.38 2016/03/30 06:38:41 jmc Exp $
+
+# string sources
+VPATH+= ${LIBCSRCDIR}/string
+
+ifneq ($(HAVE_EXPLICIT_BZERO),1)
+SRCS+= explicit_bzero.c
+endif
+
+ifneq ($(HAVE_STRLCAT),1)
+SRCS+= strlcat.c
+endif
+
+ifneq ($(HAVE_STRLCPY),1)
+SRCS+= strlcpy.c
+endif
+
+MAN+= strlcpy.3
diff --git a/lib/libopenbsd/sys/Makefile.inc b/lib/libopenbsd/sys/Makefile.inc
new file mode 100644
index 0000000..d18ff08
--- /dev/null
+++ b/lib/libopenbsd/sys/Makefile.inc
@@ -0,0 +1,16 @@
+# $OpenBSD: Makefile.inc,v 1.146 2016/07/04 18:01:44 guenther Exp $
+# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
+# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
+
+# sys sources
+VPATH+= ${LIBCSRCDIR}/sys
+
+ifneq ($(HAVE_GETFSSTAT),1)
+SRCS+= getfsstat.c
+SRCS+= statfs.c
+endif
+
+ifneq ($(HAVE_GETDTABLECOUNT),1)
+SRCS+= getdtablecount.c
+MAN+= getdtablecount.2
+endif
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 8e8cd34..25fb4b3 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -1,6 +1,9 @@
# $OpenBSD: Makefile,v 1.39 2016/03/30 06:38:43 jmc Exp $
# $NetBSD: Makefile,v 1.8 1996/05/16 07:03:28 thorpej Exp $
+.TOPDIR?=../..
+.CURDIR?=.
+
LIB= util
CPPFLAGS+=-D_GNU_SOURCE
@@ -29,4 +32,4 @@ includes:
eval "$$j"; \
done
-include bsd.lib.mk
+include ${.TOPDIR}/mk/bsd.lib.mk
diff --git a/mk/bsd.lib.mk b/mk/bsd.lib.mk
index 2343c61..b72d0e1 100644
--- a/mk/bsd.lib.mk
+++ b/mk/bsd.lib.mk
@@ -1,14 +1,14 @@
+include ${.TOPDIR}/mk/bsd.own.mk
+
STATICLIB = lib$(LIB).a
-LIBDIR=/lib
-BINOWN=root
-BINGRP=root
-LIBOWN=$(BINOWN)
-LIBGRP=$(BINGRP)
-.CURDIR = .
+#.CURDIR = .
+#_objdir = ${.CURDIR}/obj
+#VPATH+= $(__objdir)
+
+CPPFLAGS+= -I$(.TOPDIR)/include -include compat.h \
+ -I$(.TOPDIR) -include config.h
-CPPFLAGS += -I$(TOPDIR)/lib/libopenbsd -include openbsd.h -I$(TOPDIR)/include \
- -I$(TOPDIR) -include config.h
LDFLAGS += $(LDADD)
CFILES = $(filter %.c,$(SRCS))
@@ -68,8 +68,7 @@ realinstall: beforeinstall
.PHONY: all clean cleandir install libinstall
ifndef NOMAN
-include bsd.man.mk
+include ${.TOPDIR}/mk/bsd.man.mk
endif
-include bsd.subdir.mk
-include config.mk
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/mk/bsd.own.mk b/mk/bsd.own.mk
new file mode 100644
index 0000000..467c4a0
--- /dev/null
+++ b/mk/bsd.own.mk
@@ -0,0 +1,44 @@
+#.SUFFIXES:
+#.CURDIR = $(shell pwd)
+#.OBJDIR ?= ${.CURDIR}/obj
+#
+#MAKETARGET = $(MAKE) --no-print-directory -C $@ -f ${.CURDIR}/Makefile \
+# .CURDIR=${.CURDIR} .OBJDIR=${.OBJDIR} $(MAKECMDGOALS)
+#
+#.DEFAULT_GOAL :=
+#
+#${.OBJDIR}: ;
+# +@[ -d "$@" ] || mkdir -p "$@"
+# +@$(MAKETARGET)
+#
+#.PHONY: ${.OBJDIR}
+#
+#Makefile : ;
+#
+#% :: ${.OBJDIR} ; @:
+
+include ${.TOPDIR}/config.mk
+
+.CURDIR ?= $(dir $(firstword $(MAKEFILE_LIST)))
+VPATH+= ${.CURDIR}
+
+BINOWN?= root
+BINGRP?= root
+BINMODE?= 555
+NONBINMODE?= 444
+DIRMODE?= 755
+
+SHAREDIR?= /usr/share
+SHAREGRP?= root
+SHAREOWN?= root
+SHAREMODE?= ${NONBINMODE}
+
+MANDIR?= /usr/share/man/man
+MANGRP?= root
+MANOWN?= root
+MANMODE?= ${NONBINMODE}
+
+LIBDIR?= /usr/lib
+LIBOWN?= $(BINOWN)
+LIBGRP?= $(BINGRP)
+LIBMODE?= ${NONBINMODE}
diff --git a/mk/bsd.prog.mk b/mk/bsd.prog.mk
index 67321e7..099c84a 100644
--- a/mk/bsd.prog.mk
+++ b/mk/bsd.prog.mk
@@ -1,27 +1,31 @@
-include config.mk
+include ${.TOPDIR}/mk/bsd.own.mk
-.CURDIR = .
-CLEANFILES += $(PROG) *.o
+CPPFLAGS+= -I${.TOPDIR}/include -include compat.h
+CPPFLAGS+= -I${.TOPDIR} -include config.h
-CPPFLAGS += -I$(TOPDIR)/lib/libopenbsd -include openbsd.h -I$(TOPDIR) -include config.h
+ifdef MAKEOBJDIR
+LIBPATHS+= ${MAKEOBJDIR}/lib
+endif
+LIBPATHS+= ${.TOPDIR}/obj/lib ${.TOPDIR}/lib
+
+_find_lib= $(firstword $(wildcard $(LIBPATHS:%=%/$(1))))
-LIBC ?= $(TOPDIR)/lib/libopenbsd/libopenbsd.a
-LIBUTIL ?= $(TOPDIR)/lib/libutil/libutil.a
+LIBC?= $(call _find_lib,libopenbsd/libopenbsd.a)
+LIBUTIL?= $(call _find_lib,libutil/libutil.a)
ifeq (-lutil,$(filter -lutil,$(LDADD)))
- LDFLAGS+= -L$(TOPDIR)/lib/libutil
+LDFLAGS+= -L$(dir $(LIBUTIL))
endif
-LDFLAGS += -L$(TOPDIR)/lib/libopenbsd $(LDADD) -lopenbsd
+
+LDFLAGS+= -L$(dir $(LIBC)) $(LDADD) -lopenbsd
CFILES = $(filter %.c,$(SRCS))
YFILES = $(filter %.y,$(SRCS))
LFILES = $(filter %.l,$(SRCS))
-OBJS = $(YFILES:.y=.o) $(LFILES:.l=.o) $(CFILES:.c=.o)
-
-ifneq (,$(findstring $(.DEFAULT_GOAL),install beforeinstall afterinstall))
- .DEFAULT_GOAL :=
-endif
+OBJS += $(YFILES:.y=.o)
+OBJS += $(LFILES:.l=.o)
+OBJS += $(CFILES:.c=.o)
.DEFAULT_GOAL :=
@@ -33,20 +37,33 @@ else
$(PROG) : % : %.o
endif
-y.tab.h y.tab.c:
- $(YACC) -d $(YFILES)
+y.tab.h y.tab.c: $(YFILES)
+ $(YACC) -d $^
%.o: %.y y.tab.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c y.tab.c -o $@
%.o: %.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(PROG):
$(CC) $^ -o $@ $(LDFLAGS)
clean:
- rm -f $(CLEANFILES) y.tab.h y.tab.c
+ifdef SRCS
+ rm -f $(OBJS)
+else
+ rm -f $(PROG).o
+endif
+ifdef PROG
+ rm -f $(PROG)
+endif
+ifdef YFILES
+ rm -f y.tab.h y.tab.c
+endif
+ifdef CLEANFILES
+ rm -f $(CLEANFILES)
+endif
install: proginstall install_links
@@ -72,3 +89,8 @@ ifneq (,$(LINKS))
endif
.PHONY: all clean install proginstall
+
+-include ${.TOPDIR}/mk/bsd.obj.mk
+-include ${.TOPDIR}/mk/bsd.dep.mk
+include ${.TOPDIR}/mk/bsd.subdir.mk
+-include ${.TOPDIR}/mk/bsd.sys.mk
diff --git a/mk/bsd.regress.mk b/mk/bsd.regress.mk
index 3a26d63..4c976ca 100644
--- a/mk/bsd.regress.mk
+++ b/mk/bsd.regress.mk
@@ -20,4 +20,4 @@ endif
.PHONY: all clean regress depend
.SUFFIXES:
-include config.mk
+include ${.TOPDIR}/config.mk
diff --git a/mk/bsd.subdir.mk b/mk/bsd.subdir.mk
index d484731..f19ebcf 100644
--- a/mk/bsd.subdir.mk
+++ b/mk/bsd.subdir.mk
@@ -1,24 +1,49 @@
-SUBDIR_MFLAGS = -I$(TOPDIR) -I$(TOPDIR)/mk
+MAKEOBJDIR?= obj
+
+.TOPDIR?= ..
+.OBJDIR?= ${MAKEOBJDIR}
+.SRCDIR?= .
+.CURDIR?= .
+.RELDIR:= $(.SRCDIR:.%=$(.TOPDIR)/../%)
+
+SUBDIR_MFLAGS= --no-print-directory \
+ -I$(.NEXTTOP)/mk \
+ -C ${.OBJDIR}/$$nextdir \
+ -f ${.RELDIR}/$$nextdir/Makefile \
+ .OBJDIR=. \
+ .TOPDIR=${.TOPDIR}/.. \
+ .CURDIR=${.RELDIR}/$$nextdir \
+ .SRCDIR=${.SRCDIR}/$$nextdir \
+ MAKEOBJDIR=${.TOPDIR}/${MAKEOBJDIR} \
+ _THISDIR_=$$nextdir
+
+
+
SUBDIR_TARGETS = all install clean cleandir includes depend regress obj tags manlint
-SKIPDIR ?=
$(SUBDIR_TARGETS): _SUBDIRUSE
+define __SUBDIRUSE
+for nextdir in $(SUBDIR); do \
+ b=; for s in $(SKIPDIR); do \
+ [ "$$s" = "$$nextdir" ] && b=1 && break; \
+ done; \
+ [ -n "$$b" ] && echo "($$nextdir skipped)" && continue; \
+ echo "===> $${_THISDIR_:+$${_THISDIR_}/}$$nextdir"; \
+ mkdir -p "${.OBJDIR}/$$nextdir" \
+ && $(MAKE) $(SUBDIR_MFLAGS) $(MAKECMDGOALS) || exit 1; \
+done
+endef
+
_SUBDIRUSE:
-ifneq (,$(SUBDIR))
- @for d in $(SUBDIR); do \
- skip=; for s in $(SKIPDIR); do \
- [ "$$s" = "$$d" ] && skip=1; \
- done; \
- [ -n "$$_THISDIR_" ] && n="$$_THISDIR_/$$d" || n=$$d; \
- [ "$$skip" ] && echo "($$n skipped)" && continue; \
- echo "===> $$n"; \
- $(MAKE) $(SUBDIR_MFLAGS) -C $$d _THISDIR_=$$n $(MAKECMDGOALS) || exit 1; \
- done
+ifneq ($(SUBDIR),)
+ @$(__SUBDIRUSE)
$(SUBDIR):
- @echo "===> $@"; \
- $(MAKE) $(SUBDIR_MFLAGS) -C $@ all || exit 1
+ @nextdir="$@"; \
+ echo "===> $$nextdir"; \
+ mkdir -p "${.OBJDIR}/$$nextdir" \
+ && $(MAKE) $(SUBDIR_MFLAGS) all || exit 1
endif
.PHONY: _SUBDIRUSE $(SUBDIR_TARGETS) $(SUBDIR)
diff --git a/regress/Makefile b/regress/Makefile
index 491a431..272eea6 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -1,2 +1,3 @@
-SUBDIR = bin sbin usr.bin usr.sbin
-include bsd.subdir.mk
+TOPDIR?=..
+SUBDIR= bin sbin usr.bin usr.sbin
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/regress/bin/Makefile b/regress/bin/Makefile
index 0a62629..6d6f37b 100644
--- a/regress/bin/Makefile
+++ b/regress/bin/Makefile
@@ -1,3 +1,3 @@
-SUBDIR = cat chmod ln md5 pax test
-SKIPDIR =
-include bsd.subdir.mk
+TOPDIR?=../..
+SUBDIR= cat chmod ln md5 pax test
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/regress/bin/cat/Makefile b/regress/bin/cat/Makefile
index c7b0b67..4c047f5 100644
--- a/regress/bin/cat/Makefile
+++ b/regress/bin/cat/Makefile
@@ -8,4 +8,4 @@ cat_be:
cat_se:
cat -se ${.CURDIR}/cat_se.in | cmp -s ${.CURDIR}/cat_se.out /dev/stdin
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/bin/chmod/Makefile b/regress/bin/chmod/Makefile
index 60b9dd9..9180e26 100644
--- a/regress/bin/chmod/Makefile
+++ b/regress/bin/chmod/Makefile
@@ -487,4 +487,4 @@ clean:
.POSIX:
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/bin/ln/Makefile b/regress/bin/ln/Makefile
index 2e1891d..d23c3f5 100644
--- a/regress/bin/ln/Makefile
+++ b/regress/bin/ln/Makefile
@@ -15,4 +15,4 @@ recursive: links
links/source: links
@echo "Hello, world!" > ${.OBJDIR}/links/source
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/bin/md5/Makefile b/regress/bin/md5/Makefile
index 341cfb9..3676f00 100644
--- a/regress/bin/md5/Makefile
+++ b/regress/bin/md5/Makefile
@@ -47,4 +47,4 @@ md5_multiple_files:
.PHONY: ${REGRESS_TARGETS}
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/bin/pax/Makefile b/regress/bin/pax/Makefile
index a7c121a..d9d7c47 100644
--- a/regress/bin/pax/Makefile
+++ b/regress/bin/pax/Makefile
@@ -8,4 +8,4 @@ $(REGRESS_TARGETS):
.PHONY: ${REGRESS_TARGETS}
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/bin/test/Makefile b/regress/bin/test/Makefile
index fa62c4d..d7df48d 100644
--- a/regress/bin/test/Makefile
+++ b/regress/bin/test/Makefile
@@ -5,4 +5,4 @@ REGRESS_TARGETS= run_test
run_test:
$(SHELL) $(.CURDIR)/TEST.sh >/dev/null
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/sbin/Makefile b/regress/sbin/Makefile
index b0b29da..ee47b11 100644
--- a/regress/sbin/Makefile
+++ b/regress/sbin/Makefile
@@ -1,3 +1,2 @@
-SUBDIR =
-SKIPDIR =
-include bsd.subdir.mk
+TOPDIR?=../..
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/regress/usr.bin/Makefile b/regress/usr.bin/Makefile
index 24cae46..e91f055 100644
--- a/regress/usr.bin/Makefile
+++ b/regress/usr.bin/Makefile
@@ -1,4 +1,5 @@
-SUBDIR = basename bc calendar colrm column cut dc diff diff3 dirname file \
- fmt fold grep jot tail tsort ul wc xargs
-SKIPDIR = grep bc calendar diff3 cut jot
-include bsd.subdir.mk
+TOPDIR?=../..
+SUBDIR= basename bc calendar colrm column cut dc diff diff3 dirname file \
+ fmt fold grep jot tail tsort ul wc xargs
+SKIPDIR=grep bc calendar diff3 cut jot
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/regress/usr.bin/basename/Makefile b/regress/usr.bin/basename/Makefile
index 4b719dc..6ab0207 100644
--- a/regress/usr.bin/basename/Makefile
+++ b/regress/usr.bin/basename/Makefile
@@ -4,4 +4,4 @@
regress:
@$(SHELL) ${.CURDIR}/basename.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/bc/Makefile b/regress/usr.bin/bc/Makefile
index 3da192f..1217dab 100644
--- a/regress/usr.bin/bc/Makefile
+++ b/regress/usr.bin/bc/Makefile
@@ -47,4 +47,4 @@ t19test: t19
clean:
rm -f *.log t19
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/calendar/Makefile b/regress/usr.bin/calendar/Makefile
index 6a539a8..de18337 100644
--- a/regress/usr.bin/calendar/Makefile
+++ b/regress/usr.bin/calendar/Makefile
@@ -10,4 +10,4 @@ $(REGRESS_TARGETS):
.PHONY: ${REGRESS_TARGETS}
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/colrm/Makefile b/regress/usr.bin/colrm/Makefile
index bc1b2ce..437178b 100644
--- a/regress/usr.bin/colrm/Makefile
+++ b/regress/usr.bin/colrm/Makefile
@@ -5,4 +5,4 @@ REGRESS_TARGETS = colrm
colrm:
$(SHELL) ${.CURDIR}/colrm.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/column/Makefile b/regress/usr.bin/column/Makefile
index 6b65018..f230be5 100644
--- a/regress/usr.bin/column/Makefile
+++ b/regress/usr.bin/column/Makefile
@@ -3,4 +3,4 @@
regress:
@$(SHELL) ${.CURDIR}/column.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/cut/Makefile b/regress/usr.bin/cut/Makefile
index a508692..af5d7c6 100644
--- a/regress/usr.bin/cut/Makefile
+++ b/regress/usr.bin/cut/Makefile
@@ -5,4 +5,4 @@ REGRESS_TARGETS = cut
cut:
$(SHELL) ${.CURDIR}/cut.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/dc/Makefile b/regress/usr.bin/dc/Makefile
index 0b61c00..203a03e 100644
--- a/regress/usr.bin/dc/Makefile
+++ b/regress/usr.bin/dc/Makefile
@@ -50,4 +50,4 @@ all: clean ${REGRESS_TARGET}
clean:
rm -f *.log
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/diff/Makefile b/regress/usr.bin/diff/Makefile
index 66e676a..e9be7b3 100644
--- a/regress/usr.bin/diff/Makefile
+++ b/regress/usr.bin/diff/Makefile
@@ -67,4 +67,4 @@ t14.1 t15.1:
clean:
rm -f *.copy *.patch *.orig
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/diff3/Makefile b/regress/usr.bin/diff3/Makefile
index aed1eb7..aafc3c3 100644
--- a/regress/usr.bin/diff3/Makefile
+++ b/regress/usr.bin/diff3/Makefile
@@ -6,4 +6,4 @@ REGRESS_TARGETS+=t1
t1:
merge -p /etc/motd /etc/motd /etc/motd | diff /etc/motd -
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/dirname/Makefile b/regress/usr.bin/dirname/Makefile
index 49c37fa..6158c6d 100644
--- a/regress/usr.bin/dirname/Makefile
+++ b/regress/usr.bin/dirname/Makefile
@@ -4,4 +4,4 @@
regress:
@$(SHELL) ${.CURDIR}/dirname.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/file/Makefile b/regress/usr.bin/file/Makefile
index 957021d..31930ee 100644
--- a/regress/usr.bin/file/Makefile
+++ b/regress/usr.bin/file/Makefile
@@ -22,4 +22,4 @@ all: ${REGRESS_TARGET}
clean:
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/fmt/Makefile b/regress/usr.bin/fmt/Makefile
index c0352df..9353e93 100644
--- a/regress/usr.bin/fmt/Makefile
+++ b/regress/usr.bin/fmt/Makefile
@@ -3,4 +3,4 @@
regress:
@$(SHELL) ${.CURDIR}/fmt.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/fold/Makefile b/regress/usr.bin/fold/Makefile
index e386ec4..a583f75 100644
--- a/regress/usr.bin/fold/Makefile
+++ b/regress/usr.bin/fold/Makefile
@@ -3,4 +3,4 @@
regress:
@$(SHELL) ${.CURDIR}/fold.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/grep/Makefile b/regress/usr.bin/grep/Makefile
index 3e337d9..e831e41 100644
--- a/regress/usr.bin/grep/Makefile
+++ b/regress/usr.bin/grep/Makefile
@@ -106,4 +106,4 @@ t26:
.PHONY: t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20
.PHONY: t21 t22 t23 t24 t25 t26
-include ../../../bsd.regress.mk
+include ../../../${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/jot/Makefile b/regress/usr.bin/jot/Makefile
index 333dbab..5af3e1b 100644
--- a/regress/usr.bin/jot/Makefile
+++ b/regress/usr.bin/jot/Makefile
@@ -10,4 +10,4 @@ regress:
clean:
rm -f test.*.out
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/tail/Makefile b/regress/usr.bin/tail/Makefile
index 4031e3a..f3574de 100644
--- a/regress/usr.bin/tail/Makefile
+++ b/regress/usr.bin/tail/Makefile
@@ -12,4 +12,4 @@ $(REGRESS_ROOT_TARGETS):
$(REGRESS_TARGETS):
$(SHELL) $@.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/tsort/Makefile b/regress/usr.bin/tsort/Makefile
index ebe53f9..a3accfc 100644
--- a/regress/usr.bin/tsort/Makefile
+++ b/regress/usr.bin/tsort/Makefile
@@ -51,4 +51,4 @@ pairs4:
.PHONY: t1 t2 t7
CLEANFILES+=t1.out t2.out t3.out t4.out t5.out t6.out pairs3 pairs4
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/ul/Makefile b/regress/usr.bin/ul/Makefile
index 49b0ea9..bfb4587 100644
--- a/regress/usr.bin/ul/Makefile
+++ b/regress/usr.bin/ul/Makefile
@@ -5,4 +5,4 @@ REGRESS_TARGETS = ul
ul:
$(SHELL) ${.CURDIR}/ul.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/wc/Makefile b/regress/usr.bin/wc/Makefile
index 531ff6c..0a2bedc 100644
--- a/regress/usr.bin/wc/Makefile
+++ b/regress/usr.bin/wc/Makefile
@@ -5,4 +5,4 @@ REGRESS_TARGETS = wc
wc:
$(SHELL) ${.CURDIR}/wc.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.bin/xargs/Makefile b/regress/usr.bin/xargs/Makefile
index 70bac9d..86aa669 100644
--- a/regress/usr.bin/xargs/Makefile
+++ b/regress/usr.bin/xargs/Makefile
@@ -5,4 +5,4 @@ PROG= showargs
run-regress-showargs:
@$(SHELL) ${.CURDIR}/xargs-L.sh
-include bsd.regress.mk
+include ${.TOPDIR}/mk/bsd.regress.mk
diff --git a/regress/usr.sbin/Makefile b/regress/usr.sbin/Makefile
index b0b29da..224f5ec 100644
--- a/regress/usr.sbin/Makefile
+++ b/regress/usr.sbin/Makefile
@@ -1,3 +1,3 @@
-SUBDIR =
-SKIPDIR =
-include bsd.subdir.mk
+TOPDIR?=../..
+SUBDIR=
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/sbin/Makefile b/sbin/Makefile
index e11b749..843d01d 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -1,3 +1,3 @@
-SUBDIR = mknod
-
-include bsd.subdir.mk
+TOPDIR?=..
+SUBDIR= mknod
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/sbin/mknod/Makefile b/sbin/mknod/Makefile
index 5a8aaf7..111e469 100644
--- a/sbin/mknod/Makefile
+++ b/sbin/mknod/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.5 2001/08/21 17:55:47 millert Exp $
+.TOPDIR?=../..
+
PROG= mknod
MAN= mknod.8 mkfifo.1
LINKS= ${BINDIR}/mknod ${BINDIR}/mkfifo
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index 465341c..09a6f38 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -1,9 +1,10 @@
-# dc before bc because it depends on dc.o
-SUBDIR = apply awk basename dc bc biff cal calendar cmp colrm col column comm \
- cut dirname du diff3 diff env expand false file fmt fold getopt grep head \
- hexdump id indent join jot lam lndir logger logname look mktemp nice \
- nl nohup paste patch printenv printf readlink renice rev rs sed shar \
- sort split stat tee time touch tr true tsort tty uname unexpand uniq unvis \
- uudecode uuencode vis wc what which xinstall hexdump cu newsyslog sdiff
-SKIPDIR = file cu
-include bsd.subdir.mk
+TOPDIR?=..
+SUBDIR= apply awk basename bc biff cal calendar cmp colrm col column comm \
+ cut dc dirname du diff3 diff env expand false file fmt fold getopt \
+ grep head hexdump id indent join jot lam lndir logger logname look \
+ mktemp nice nl nohup paste patch printenv printf readlink renice rev \
+ rs sed shar sort split stat tee time touch tr true tsort tty uname \
+ unexpand uniq unvis uudecode uuencode vis wc what which xinstall \
+ hexdump cu newsyslog sdiff
+SKIPDIR=file cu
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/usr.bin/apply/Makefile b/usr.bin/apply/Makefile
index 4e89cc8..75dd8c3 100644
--- a/usr.bin/apply/Makefile
+++ b/usr.bin/apply/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:16 deraadt Exp $
+.TOPDIR?=../..
+
PROG= apply
CPPFLAGS+=-D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile
index 04b3586..ca0a97a 100644
--- a/usr.bin/awk/Makefile
+++ b/usr.bin/awk/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.14 2013/08/18 22:06:44 miod Exp $
+.TOPDIR?=../..
+
PROG= awk
SRCS= ytab.c lex.c b.c main.c parse.c proctab.c tran.c lib.c run.c
LDADD= -lm
@@ -9,6 +11,7 @@ CFLAGS+=-I. -I${.CURDIR} -DHAS_ISBLANK -DNDEBUG
HOSTCFLAGS+=-I. -I${.CURDIR} -DHAS_ISBLANK -DNDEBUG
CPPFLAGS+=-D_GNU_SOURCE
+# XXX: replace with make depends
lex.o b.o main.o tran.o run.o parse.o lib.o : ytab.h
ytab.c: awkgram.y
@@ -24,4 +27,4 @@ proctab.c: maketab
maketab: ytab.h maketab.c
${HOSTCC} ${HOSTCFLAGS} ${.CURDIR}/maketab.c -o $@
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/basename/Makefile b/usr.bin/basename/Makefile
index 91d006d..c90866b 100644
--- a/usr.bin/basename/Makefile
+++ b/usr.bin/basename/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.5 2001/07/05 22:06:33 pjanzen Exp $
+.TOPDIR?=../..
+
PROG= basename
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/bc/Makefile b/usr.bin/bc/Makefile
index aceaccc..797fdbb 100644
--- a/usr.bin/bc/Makefile
+++ b/usr.bin/bc/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.8 2015/10/10 19:28:54 deraadt Exp $
+.TOPDIR?=../..
+
PROG= bc
SRCS= bc.y scan.l tty.c dc.c bcode.c inout.c mem.c stack.c
CPPFLAGS+= -I. -I${.CURDIR}
@@ -8,12 +10,14 @@ YFLAGS+=
LDADD+= -ledit -lcurses -lcrypto
DPADD+= ${LIBEDIT} ${LIBCURSES} ${LIBCRYPTO}
+# XXX: include add %/obj by default?
VPATH+= ${.CURDIR}/../dc
beforeinstall:
install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/bc.library \
${DESTDIR}/usr/share/misc
+# XXX: replace with make depends
scan.o : y.tab.h
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/biff/Makefile b/usr.bin/biff/Makefile
index 1530448..6550a8d 100644
--- a/usr.bin/biff/Makefile
+++ b/usr.bin/biff/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:28 deraadt Exp $
+.TOPDIR?=../..
+
PROG= biff
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/cal/Makefile b/usr.bin/cal/Makefile
index 609cf02..a7e25e9 100644
--- a/usr.bin/cal/Makefile
+++ b/usr.bin/cal/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:29 deraadt Exp $
+.TOPDIR?=../..
+
PROG= cal
CPPFLAGS+=-D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/calendar/Makefile b/usr.bin/calendar/Makefile
index 9ac4186..4294f37 100644
--- a/usr.bin/calendar/Makefile
+++ b/usr.bin/calendar/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.10 2015/10/23 10:33:52 tedu Exp $
+.TOPDIR?=../..
+
PROG= calendar
SRCS= calendar.c io.c day.c pesach.c ostern.c paskha.c
INTER= de_DE.UTF-8 hr_HR.UTF-8 ru_RU.UTF-8 fr_FR.UTF-8
@@ -16,4 +18,4 @@ beforeinstall:
# ${DESTDIR}/usr/share/calendar/${lang};
#.endfor
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/cmp/Makefile b/usr.bin/cmp/Makefile
index 1b19f3d..826552a 100644
--- a/usr.bin/cmp/Makefile
+++ b/usr.bin/cmp/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:41 deraadt Exp $
+.TOPDIR?=../..
+
PROG= cmp
SRCS= cmp.c misc.c regular.c special.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/col/Makefile b/usr.bin/col/Makefile
index ed29176..c9f7b06 100644
--- a/usr.bin/col/Makefile
+++ b/usr.bin/col/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:42 deraadt Exp $
+.TOPDIR?=../..
+
PROG= col
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/colrm/Makefile b/usr.bin/colrm/Makefile
index 1131c1f..7adaadd 100644
--- a/usr.bin/colrm/Makefile
+++ b/usr.bin/colrm/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:45 deraadt Exp $
+.TOPDIR?=../..
+
PROG= colrm
CPPFLAGS+=-D_GNU_SOURCE -D_XOPEN_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/column/Makefile b/usr.bin/column/Makefile
index 72007ac..a64d2bd 100644
--- a/usr.bin/column/Makefile
+++ b/usr.bin/column/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:46 deraadt Exp $
+.TOPDIR?=../..
+
PROG= column
CPPFLAGS+=-D_GNU_SOURCE -D_XOPEN_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/comm/Makefile b/usr.bin/comm/Makefile
index ff1a514..b75796d 100644
--- a/usr.bin/comm/Makefile
+++ b/usr.bin/comm/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:47 deraadt Exp $
+.TOPDIR?=../..
+
PROG= comm
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/cu/Makefile b/usr.bin/cu/Makefile
index e6cb91c..1c0c767 100644
--- a/usr.bin/cu/Makefile
+++ b/usr.bin/cu/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 2012/07/10 11:42:02 nicm Exp $
+.TOPDIR?=../..
+
PROG= cu
SRCS= cu.c command.c error.c input.c xmodem.c
@@ -8,4 +10,4 @@ CDIAGFLAGS+= -Wall -W -Wno-unused-parameter
LDADD= -levent
DPADD= ${LIBEVENT}
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/cut/Makefile b/usr.bin/cut/Makefile
index 1af3fa4..d5af90e 100644
--- a/usr.bin/cut/Makefile
+++ b/usr.bin/cut/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:51 deraadt Exp $
+.TOPDIR?=../..
+
PROG= cut
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/dc/Makefile b/usr.bin/dc/Makefile
index 47480b7..d9de8d1 100644
--- a/usr.bin/dc/Makefile
+++ b/usr.bin/dc/Makefile
@@ -1,10 +1,11 @@
# $OpenBSD: Makefile,v 1.3 2015/10/10 19:28:54 deraadt Exp $
+.TOPDIR?=../..
+
PROG= dc
SRCS= main.c dc.c bcode.c inout.c mem.c stack.c
-CPPFLAGS+=-D_GNU_SOURCE
COPTS+= -Wall
LDADD= -lcrypto
DPADD= ${LIBCRYPTO}
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/diff/Makefile b/usr.bin/diff/Makefile
index bab507a..69a1504 100644
--- a/usr.bin/diff/Makefile
+++ b/usr.bin/diff/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.3 2007/05/29 18:24:56 ray Exp $
+.TOPDIR?=../..
+
PROG= diff
SRCS= diff.c diffdir.c diffreg.c xmalloc.c
COPTS+= -Wall
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/diff3/Makefile b/usr.bin/diff3/Makefile
index aeaffe7..84846de 100644
--- a/usr.bin/diff3/Makefile
+++ b/usr.bin/diff3/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 2003/07/22 00:11:30 millert Exp $
+.TOPDIR?=../..
+
PROG= diff3prog
MAN= diff3.1
BINDIR= /usr/libexec
@@ -8,4 +10,4 @@ beforeinstall:
install ${INSTALL_COPY}c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${.CURDIR}/diff3.ksh ${DESTDIR}/usr/bin/diff3
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/dirname/Makefile b/usr.bin/dirname/Makefile
index 67fd7ee..c999716 100644
--- a/usr.bin/dirname/Makefile
+++ b/usr.bin/dirname/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.4 2001/07/05 22:06:24 pjanzen Exp $
+.TOPDIR?=../..
+
PROG= dirname
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/du/Makefile b/usr.bin/du/Makefile
index 5a2cc67..c42fa4a 100644
--- a/usr.bin/du/Makefile
+++ b/usr.bin/du/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.4 2004/06/14 18:21:31 otto Exp $
+.TOPDIR?=../..
+
PROG= du
DPADD= ${LIBUTIL}
LDADD= -lutil
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/env/Makefile b/usr.bin/env/Makefile
index 9d359d2..63d49dc 100644
--- a/usr.bin/env/Makefile
+++ b/usr.bin/env/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:56 deraadt Exp $
+.TOPDIR?=../..
+
PROG= env
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/expand/Makefile b/usr.bin/expand/Makefile
index 3d322de..3ef868e 100644
--- a/usr.bin/expand/Makefile
+++ b/usr.bin/expand/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.4 2016/03/30 06:38:45 jmc Exp $
+.TOPDIR?=../..
+
PROG= expand
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/false/Makefile b/usr.bin/false/Makefile
index 86d1658..9e780fe 100644
--- a/usr.bin/false/Makefile
+++ b/usr.bin/false/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.5 2015/11/11 19:05:28 deraadt Exp $
+.TOPDIR?=../..
+
MAN= false.1
PROG= false
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/file/Makefile b/usr.bin/file/Makefile
index df7ec08..5352ceb 100644
--- a/usr.bin/file/Makefile
+++ b/usr.bin/file/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.16 2015/10/04 07:25:59 nicm Exp $
+.TOPDIR?=../..
+
PROG= file
SRCS= file.c magic-dump.c magic-load.c magic-test.c magic-common.c \
text.c xmalloc.c
@@ -39,4 +41,4 @@ afterinstall:
all: file magic
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/fmt/Makefile b/usr.bin/fmt/Makefile
index 5a88935..8049568 100644
--- a/usr.bin/fmt/Makefile
+++ b/usr.bin/fmt/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.4 1998/04/25 23:08:26 millert Exp $
+.TOPDIR?=../..
+
PROG= fmt
SRCS= fmt.c
CPPFLAGS+=-D_XOPEN_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/fold/Makefile b/usr.bin/fold/Makefile
index 98069b7..564d539 100644
--- a/usr.bin/fold/Makefile
+++ b/usr.bin/fold/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:49:05 deraadt Exp $
+.TOPDIR?=../..
+
PROG= fold
CPPFLAGS+=-D_XOPEN_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/getopt/Makefile b/usr.bin/getopt/Makefile
index 2e76643..6d3ccc5 100644
--- a/usr.bin/getopt/Makefile
+++ b/usr.bin/getopt/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:33:44 deraadt Exp $
+.TOPDIR?=../..
+
PROG = getopt
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/grep/Makefile b/usr.bin/grep/Makefile
index 35804be..80bc345 100644
--- a/usr.bin/grep/Makefile
+++ b/usr.bin/grep/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.7 2016/03/30 06:38:46 jmc Exp $
+.TOPDIR?=../..
+
PROG= grep
SRCS= binary.c file.c grep.c mmfile.c queue.c util.c
LINKS= ${BINDIR}/grep ${BINDIR}/egrep \
@@ -13,4 +15,4 @@ CFLAGS+= -Wall
LDADD= -lz
DPADD= ${LIBZ}
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/head/Makefile b/usr.bin/head/Makefile
index a3309a3..c9696d2 100644
--- a/usr.bin/head/Makefile
+++ b/usr.bin/head/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:34:14 deraadt Exp $
+.TOPDIR?=../..
+
PROG= head
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/hexdump/Makefile b/usr.bin/hexdump/Makefile
index c8cd52c..8094357 100644
--- a/usr.bin/hexdump/Makefile
+++ b/usr.bin/hexdump/Makefile
@@ -1,8 +1,10 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:34:16 deraadt Exp $
+.TOPDIR?=../..
+
PROG= hexdump
SRCS= conv.c display.c hexdump.c hexsyntax.c odsyntax.c parse.c
MAN= hexdump.1 od.1
LINKS= ${BINDIR}/hexdump ${BINDIR}/od
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/id/Makefile b/usr.bin/id/Makefile
index 7ba426e..b902934 100644
--- a/usr.bin/id/Makefile
+++ b/usr.bin/id/Makefile
@@ -1,9 +1,11 @@
# $OpenBSD: Makefile,v 1.5 2013/09/06 19:48:46 okan Exp $
+.TOPDIR?=../..
+
PROG= id
MAN= id.1 groups.1 whoami.1
LINKS= ${BINDIR}/id ${BINDIR}/groups \
${BINDIR}/id ${BINDIR}/whoami
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/indent/Makefile b/usr.bin/indent/Makefile
index 38fe702..7a1eff1 100644
--- a/usr.bin/indent/Makefile
+++ b/usr.bin/indent/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:34:27 deraadt Exp $
+.TOPDIR?=../..
+
PROG= indent
SRCS= indent.c io.c lexi.c parse.c pr_comment.c args.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/join/Makefile b/usr.bin/join/Makefile
index d9aeaca..15c6692 100644
--- a/usr.bin/join/Makefile
+++ b/usr.bin/join/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 2003/12/12 10:38:44 otto Exp $
+.TOPDIR?=../..
+
PROG= join
CFLAGS+= -Wall
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/jot/Makefile b/usr.bin/jot/Makefile
index 59972aa..c76027c 100644
--- a/usr.bin/jot/Makefile
+++ b/usr.bin/jot/Makefile
@@ -1,8 +1,10 @@
# $OpenBSD: Makefile,v 1.5 2016/01/10 01:15:52 tb Exp $
+.TOPDIR?=../..
+
PROG= jot
CFLAGS+= -Wall
LDADD+= -lm
DPADD+= ${LIBM}
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/lam/Makefile b/usr.bin/lam/Makefile
index 9bba788..b1d2df7 100644
--- a/usr.bin/lam/Makefile
+++ b/usr.bin/lam/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:49:24 deraadt Exp $
+.TOPDIR?=../..
+
PROG= lam
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/lndir/Makefile b/usr.bin/lndir/Makefile
index 3603df4..62c0824 100644
--- a/usr.bin/lndir/Makefile
+++ b/usr.bin/lndir/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.1 1996/08/19 05:47:25 downsj Exp $
+.TOPDIR?=../..
+
PROG= lndir
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/logger/Makefile b/usr.bin/logger/Makefile
index 9cdc220..bb79513 100644
--- a/usr.bin/logger/Makefile
+++ b/usr.bin/logger/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:49:37 deraadt Exp $
+.TOPDIR?=../..
+
PROG= logger
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/logname/Makefile b/usr.bin/logname/Makefile
index 7ef7be9..1d5e236 100644
--- a/usr.bin/logname/Makefile
+++ b/usr.bin/logname/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:49:42 deraadt Exp $
+.TOPDIR?=../..
+
PROG= logname
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/look/Makefile b/usr.bin/look/Makefile
index 6c9c0eb..1260be4 100644
--- a/usr.bin/look/Makefile
+++ b/usr.bin/look/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:49:44 deraadt Exp $
+.TOPDIR?=../..
+
PROG= look
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/mktemp/Makefile b/usr.bin/mktemp/Makefile
index cf2d784..1e9dc53 100644
--- a/usr.bin/mktemp/Makefile
+++ b/usr.bin/mktemp/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.1 1996/11/21 07:59:31 millert Exp $
+.TOPDIR?=../..
+
PROG= mktemp
CPPFLAGS+=-D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/newsyslog/Makefile b/usr.bin/newsyslog/Makefile
index 5793a90..3de4e08 100644
--- a/usr.bin/newsyslog/Makefile
+++ b/usr.bin/newsyslog/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.7 2016/06/01 16:57:48 tedu Exp $
+.TOPDIR?=../..
+
PROG= newsyslog
CPPFLAGS+=-D_GNU_SOURCE
@@ -7,4 +9,4 @@ BINOWN= root
MAN= newsyslog.8
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/nice/Makefile b/usr.bin/nice/Makefile
index 80c0fce..e7fab34 100644
--- a/usr.bin/nice/Makefile
+++ b/usr.bin/nice/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:50:19 deraadt Exp $
+.TOPDIR?=../..
+
PROG= nice
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/nl/Makefile b/usr.bin/nl/Makefile
index 0df4e37..596607c 100644
--- a/usr.bin/nl/Makefile
+++ b/usr.bin/nl/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.1 2013/09/08 18:59:07 jca Exp $
# $NetBSD: Makefile,v 1.4 2011/08/16 12:00:46 christos Exp $
+.TOPDIR?=../..
+
PROG= nl
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/nohup/Makefile b/usr.bin/nohup/Makefile
index 6232294..b79966d 100644
--- a/usr.bin/nohup/Makefile
+++ b/usr.bin/nohup/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:50:24 deraadt Exp $
+.TOPDIR?=../..
+
PROG= nohup
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/paste/Makefile b/usr.bin/paste/Makefile
index 73944cc..ecfa9d1 100644
--- a/usr.bin/paste/Makefile
+++ b/usr.bin/paste/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:37:49 deraadt Exp $
+.TOPDIR?=../..
+
PROG= paste
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/patch/Makefile b/usr.bin/patch/Makefile
index b775718..e1c436d 100644
--- a/usr.bin/patch/Makefile
+++ b/usr.bin/patch/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.5 2015/10/16 07:33:47 tobias Exp $
+.TOPDIR?=../..
+
PROG= patch
SRCS= patch.c pch.c inp.c util.c backupfile.c mkpath.c ed.c
CPPFLAGS+=-D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/printenv/Makefile b/usr.bin/printenv/Makefile
index 1f083d4..ba63a83 100644
--- a/usr.bin/printenv/Makefile
+++ b/usr.bin/printenv/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:37:56 deraadt Exp $
+.TOPDIR?=../..
+
PROG= printenv
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/printf/Makefile b/usr.bin/printf/Makefile
index d88abe4..9425323 100644
--- a/usr.bin/printf/Makefile
+++ b/usr.bin/printf/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:37:58 deraadt Exp $
+.TOPDIR?=../..
+
PROG= printf
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/readlink/Makefile b/usr.bin/readlink/Makefile
index c8defa3..3539b3b 100644
--- a/usr.bin/readlink/Makefile
+++ b/usr.bin/readlink/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 1997/08/18 20:30:59 kstailey Exp $
+.TOPDIR?=../..
+
PROG= readlink
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/renice/Makefile b/usr.bin/renice/Makefile
index e063a6f..7cf20fd 100644
--- a/usr.bin/renice/Makefile
+++ b/usr.bin/renice/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:38:26 deraadt Exp $
+.TOPDIR?=../..
+
PROG= renice
MAN= renice.8
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/rev/Makefile b/usr.bin/rev/Makefile
index c54ae03..13d5cb9 100644
--- a/usr.bin/rev/Makefile
+++ b/usr.bin/rev/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:50:34 deraadt Exp $
+.TOPDIR?=../..
+
PROG= rev
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/rs/Makefile b/usr.bin/rs/Makefile
index 937a567..ebec6e3 100644
--- a/usr.bin/rs/Makefile
+++ b/usr.bin/rs/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.3 2015/12/03 12:23:15 schwarze Exp $
+.TOPDIR?=../..
+
PROG= rs
SRCS= rs.c utf8.c
CPPFLAGS+=-D_GNU_SOURCE -D_XOPEN_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/sdiff/Makefile b/usr.bin/sdiff/Makefile
index a7a9854..02f6042 100644
--- a/usr.bin/sdiff/Makefile
+++ b/usr.bin/sdiff/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.4 2006/02/20 08:38:18 otto Exp $
+.TOPDIR?=../..
+
PROG=sdiff
SRCS=common.c edit.c sdiff.c
COPTS+=-Wall -W
@@ -7,4 +9,4 @@ COPTS+=-Wall -W
LDADD+= -lutil
DPADD+= ${LIBUTIL}
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/sed/Makefile b/usr.bin/sed/Makefile
index f6f562f..bc5d6bf 100644
--- a/usr.bin/sed/Makefile
+++ b/usr.bin/sed/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.4 2010/01/04 17:50:39 deraadt Exp $
+.TOPDIR?=../..
+
PROG= sed
SRCS= compile.c main.c misc.c process.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/shar/Makefile b/usr.bin/shar/Makefile
index a2e6b34..b0a32e0 100644
--- a/usr.bin/shar/Makefile
+++ b/usr.bin/shar/Makefile
@@ -1,9 +1,11 @@
# $OpenBSD: Makefile,v 1.5 1997/09/21 11:50:44 deraadt Exp $
+.TOPDIR?=../..
+
MAN= shar.1
#beforeinstall:
# ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
# ${.CURDIR}/shar.sh ${DESTDIR}/usr/bin/shar
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/sort/Makefile b/usr.bin/sort/Makefile
index 1ecf07e..e815c18 100644
--- a/usr.bin/sort/Makefile
+++ b/usr.bin/sort/Makefile
@@ -1,8 +1,10 @@
# $OpenBSD: Makefile,v 1.6 2015/03/17 17:45:13 millert Exp $
+.TOPDIR?=../..
+
PROG= sort
SRCS= bwstring.c coll.c file.c mem.c radixsort.c sort.c vsort.c
CPPFLAGS+=-D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/split/Makefile b/usr.bin/split/Makefile
index 4a431da..3712f50 100644
--- a/usr.bin/split/Makefile
+++ b/usr.bin/split/Makefile
@@ -1,5 +1,7 @@
-# $OpenBSD: Makefile,v 1.3 1997/09/21 11:50:59 deraadt Exp $
+## $OpenBSD: Makefile,v 1.3 1997/09/21 11:50:59 deraadt Exp $
+
+.TOPDIR?=../..
PROG= split
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/stat/Makefile b/usr.bin/stat/Makefile
index d8fb6f2..a3d1d07 100644
--- a/usr.bin/stat/Makefile
+++ b/usr.bin/stat/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.2 2005/04/03 18:30:55 deraadt Exp $
# $NetBSD: Makefile,v 1.7 2003/07/25 03:21:17 atatat Exp $
+.TOPDIR?=../..
+
PROG= stat
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/tee/Makefile b/usr.bin/tee/Makefile
index 6f648f2..8a8d6a3 100644
--- a/usr.bin/tee/Makefile
+++ b/usr.bin/tee/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:09 deraadt Exp $
+.TOPDIR?=../..
+
PROG= tee
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/time/Makefile b/usr.bin/time/Makefile
index b177256..50c96d9 100644
--- a/usr.bin/time/Makefile
+++ b/usr.bin/time/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:14 deraadt Exp $
+.TOPDIR?=../..
+
PROG= time
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/touch/Makefile b/usr.bin/touch/Makefile
index 52b68fb..a410b62 100644
--- a/usr.bin/touch/Makefile
+++ b/usr.bin/touch/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:19 deraadt Exp $
+.TOPDIR?=../..
+
PROG= touch
CPPFLAGS+=-D_XOPEN_SOURCE -D_GNU_SOURCE
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/tr/Makefile b/usr.bin/tr/Makefile
index 715c39c..2e11412 100644
--- a/usr.bin/tr/Makefile
+++ b/usr.bin/tr/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:22 deraadt Exp $
+.TOPDIR?=../..
+
PROG= tr
SRCS= str.c tr.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/true/Makefile b/usr.bin/true/Makefile
index bec5f2a..ffd1754 100644
--- a/usr.bin/true/Makefile
+++ b/usr.bin/true/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.5 2015/11/11 19:05:28 deraadt Exp $
+.TOPDIR?=../..
+
MAN= true.1
PROG= true
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/tsort/Makefile b/usr.bin/tsort/Makefile
index dc9a3f7..dfd639c 100644
--- a/usr.bin/tsort/Makefile
+++ b/usr.bin/tsort/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.6 2014/05/12 19:11:20 espie Exp $
+.TOPDIR?=../..
+
PROG = tsort
SRCS = tsort.c
@@ -8,4 +10,4 @@ DPADD += ${LIBUTIL}
LDADD += -L$(TOPDIR)/lib/libutil -lutil
CPPFLAGS+=-I$(TOPDIR)/lib/libutil
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/tty/Makefile b/usr.bin/tty/Makefile
index 2c65e2a..9c7c381 100644
--- a/usr.bin/tty/Makefile
+++ b/usr.bin/tty/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:27 deraadt Exp $
+.TOPDIR?=../..
+
PROG= tty
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/uname/Makefile b/usr.bin/uname/Makefile
index 697fe78..4d2313c 100644
--- a/usr.bin/uname/Makefile
+++ b/usr.bin/uname/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.2 1996/06/26 05:42:06 deraadt Exp $
+.TOPDIR?=../..
+
PROG= uname
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/unexpand/Makefile b/usr.bin/unexpand/Makefile
index f6ed1e5..28ea670 100644
--- a/usr.bin/unexpand/Makefile
+++ b/usr.bin/unexpand/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:30 deraadt Exp $
+.TOPDIR?=../..
+
PROG= unexpand
NOMAN= noman
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/uniq/Makefile b/usr.bin/uniq/Makefile
index 9cc4ba0..20836dc 100644
--- a/usr.bin/uniq/Makefile
+++ b/usr.bin/uniq/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.4 2006/04/07 05:10:02 ray Exp $
+.TOPDIR?=../..
+
PROG= uniq
COPTS+= -Wall -W
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/unvis/Makefile b/usr.bin/unvis/Makefile
index 24fa5cc..f835dc2 100644
--- a/usr.bin/unvis/Makefile
+++ b/usr.bin/unvis/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:36 deraadt Exp $
+.TOPDIR?=../..
+
PROG= unvis
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/uudecode/Makefile b/usr.bin/uudecode/Makefile
index eaf5c27..e44b448 100644
--- a/usr.bin/uudecode/Makefile
+++ b/usr.bin/uudecode/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.4 2004/04/09 22:54:02 millert Exp $
+.TOPDIR?=../..
+
PROG= uudecode
LINKS= ${BINDIR}/uudecode ${BINDIR}/b64decode
NOMAN= noman
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/uuencode/Makefile b/usr.bin/uuencode/Makefile
index b83721a..e78401e 100644
--- a/usr.bin/uuencode/Makefile
+++ b/usr.bin/uuencode/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.7 2016/03/30 06:38:46 jmc Exp $
+.TOPDIR?=../..
+
PROG= uuencode
MAN= uuencode.1 uuencode.5
LINKS= ${BINDIR}/uuencode ${BINDIR}/b64encode
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/vis/Makefile b/usr.bin/vis/Makefile
index e5339fd..358a207 100644
--- a/usr.bin/vis/Makefile
+++ b/usr.bin/vis/Makefile
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:50 deraadt Exp $
+.TOPDIR?=../..
+
PROG= vis
SRCS= vis.c foldit.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/wc/Makefile b/usr.bin/wc/Makefile
index 106448b..4470fc4 100644
--- a/usr.bin/wc/Makefile
+++ b/usr.bin/wc/Makefile
@@ -1,7 +1,9 @@
# $OpenBSD: Makefile,v 1.3 2005/10/19 21:49:02 espie Exp $
+.TOPDIR?=../..
+
PROG= wc
DPADD= ${LIBUTIL}
LDADD= -lutil
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/what/Makefile b/usr.bin/what/Makefile
index 033654a..6e3e5b0 100644
--- a/usr.bin/what/Makefile
+++ b/usr.bin/what/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:58 deraadt Exp $
+.TOPDIR?=../..
+
PROG= what
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/which/Makefile b/usr.bin/which/Makefile
index 12c499f..2d06b92 100644
--- a/usr.bin/which/Makefile
+++ b/usr.bin/which/Makefile
@@ -1,9 +1,12 @@
# $OpenBSD: Makefile,v 1.9 2016/05/26 21:24:16 millert Exp $
+.TOPDIR?=../..
+
PROG= which
MAN= which.1 whereis.1
LINKS= ${BINDIR}/which ${BINDIR}/whereis
+# XXX: put the updated man page in the objdir?
check_path_in_man:
@echo "Checking path expansion in whereis.1"; \
stdpath=`printf 'include paths.h\n_PATH_STDPATH\n' | \
@@ -16,4 +19,4 @@ check_path_in_man:
all: check_path_in_man
CLEANFILES = check_path_in_man
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile
index a4c7ef8..eb135ee 100644
--- a/usr.bin/xinstall/Makefile
+++ b/usr.bin/xinstall/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.7 2011/11/08 10:37:10 guenther Exp $
+.TOPDIR?=../..
+
PROG= xinstall
SRCS= xinstall.c
MAN= install.1
@@ -9,4 +11,4 @@ MAN= install.1
# -o ${BINOWN} -g ${BINGRP} \
# -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}/install
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 25fba62..e1feaaa 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -1,3 +1,3 @@
-SUBDIR = mtree rdate
-
-include bsd.subdir.mk
+TOPDIR?=..
+SUBDIR= mtree rdate
+include ${.TOPDIR}/mk/bsd.subdir.mk
diff --git a/usr.sbin/mtree/Makefile b/usr.sbin/mtree/Makefile
index ce05689..0a146f9 100644
--- a/usr.sbin/mtree/Makefile
+++ b/usr.sbin/mtree/Makefile
@@ -1,8 +1,10 @@
# $OpenBSD: Makefile,v 1.9 2013/04/15 06:25:18 deraadt Exp $
+.TOPDIR?=../..
+
PROG= mtree
#CFLAGS+=-DDEBUG
MAN= mtree.8
SRCS= compare.c crc.c create.c misc.c mtree.c spec.c verify.c
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk
diff --git a/usr.sbin/rdate/Makefile b/usr.sbin/rdate/Makefile
index af7ea29..a1b0ca7 100644
--- a/usr.sbin/rdate/Makefile
+++ b/usr.sbin/rdate/Makefile
@@ -1,5 +1,7 @@
# $OpenBSD: Makefile,v 1.7 2003/11/20 23:23:09 avsm Exp $
+.TOPDIR?=../..
+
PROG= rdate
SRCS= rdate.c rfc868time.c ntp.c ntpleaps.c
CFLAGS+=-Wall
@@ -8,4 +10,4 @@ LDADD+= -lutil
MAN= rdate.8
-include bsd.prog.mk
+include ${.TOPDIR}/mk/bsd.prog.mk