From 85cae402fa71ea64ce081f99bf946e8ea4f0cbfc Mon Sep 17 00:00:00 2001
From: John Marino <draco@marino.st>
Date: Thu, 17 Nov 2016 14:46:24 -0600
Subject: [PATCH] Relocate readline and ncurses headers to /usr/include/priv

Having public headers for private libraries can cause confusion for
software that assumes the presence of headers leads to the availability
of the libraries.

Approved by:	dillon
---
 Makefile_upgrade.inc                  |  7 +++++++
 bin/ls/Makefile                       |  1 +
 etc/mtree/BSD.include.dist            |  4 ++++
 games/atc/Makefile                    |  8 +++++---
 games/backgammon/backgammon/Makefile  |  5 ++++-
 games/backgammon/teachgammon/Makefile |  6 ++++--
 games/battlestar/Makefile             |  5 ++++-
 games/bs/Makefile                     |  4 +++-
 games/canfield/canfield/Makefile      |  6 ++++--
 games/colorbars/Makefile              |  2 ++
 games/cribbage/Makefile               |  3 +++
 games/grdc/Makefile                   |  2 ++
 games/hack/Makefile                   | 11 +++++++----
 games/hangman/Makefile                |  2 ++
 games/hunt/hunt/Makefile              |  2 ++
 games/larn/Makefile                   |  7 +++++--
 games/mille/Makefile                  |  7 ++++---
 games/phantasia/Makefile              | 14 +++++++++-----
 games/rain/Makefile                   |  2 ++
 games/robots/Makefile                 |  4 +++-
 games/rogue/Makefile                  |  8 +++++---
 games/sail/Makefile                   |  4 +++-
 games/snake/snake/Makefile            |  6 ++++--
 games/worm/Makefile                   |  4 +++-
 games/worms/Makefile                  |  2 ++
 gnu/lib/libdialog/Makefile            |  2 ++
 gnu/usr.bin/dialog/Makefile           |  2 ++
 gnu/usr.bin/gdb/kgdb/Makefile         |  2 ++
 gnu/usr.bin/gdb/libgdb/Makefile       |  2 ++
 gnu/usr.bin/gdb/libreadline/Makefile  |  1 +
 lib/libedit/libedit/Makefile          |  1 +
 lib/libedit/readline/Makefile         |  2 +-
 lib/libncurses/libncurses/Makefile    |  3 ++-
 lib/libncurses/libpanel/Makefile      |  6 ++++++
 libexec/telnetd/Makefile              |  1 +
 sbin/vinum/Makefile                   |  6 ++++--
 usr.bin/ee/Makefile                   |  2 ++
 usr.bin/ftp/Makefile                  |  2 ++
 usr.bin/less/Makefile                 |  2 ++
 usr.bin/msgs/Makefile                 |  2 ++
 usr.bin/ncal/Makefile                 |  7 ++++---
 usr.bin/systat/Makefile               |  2 ++
 usr.bin/tabs/Makefile                 |  2 ++
 usr.bin/talk/Makefile                 |  4 +++-
 usr.bin/telnet/Makefile               |  1 +
 usr.bin/tic/Makefile                  |  2 ++
 usr.bin/top/Makefile                  |  3 +++
 usr.bin/tput/Makefile                 |  6 ++++--
 usr.bin/tset/Makefile                 |  6 ++++--
 usr.bin/ul/Makefile                   |  2 ++
 usr.bin/vi/Makefile                   |  2 ++
 usr.bin/window/Makefile               |  2 ++
 usr.sbin/tzsetup/Makefile             |  2 ++
 usr.sbin/watch/Makefile               |  2 ++
 54 files changed, 161 insertions(+), 44 deletions(-)

diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc
index dceaecb..ea50aaa 100644
--- a/Makefile_upgrade.inc
+++ b/Makefile_upgrade.inc
@@ -3142,6 +3142,13 @@ TO_REMOVE+=/usr/share/man/man3/ascftime.3.gz
 TO_REMOVE+=/usr/share/man/man3/cfree.3.gz
 TO_REMOVE+=/usr/share/man/man3/cftime.3.gz
 TO_REMOVE+=/usr/share/man/man3/getpw.3.gz
+TO_REMOVE+=/usr/include/readline
+TO_REMOVE+=/usr/include/curses.h
+TO_REMOVE+=/usr/include/ncurses.h
+TO_REMOVE+=/usr/include/ncurses_dll.h
+TO_REMOVE+=/usr/include/termcap.h
+TO_REMOVE+=/usr/include/term.h
+TO_REMOVE+=/usr/include/unctrl.h
 
 .if !defined(WANT_INSTALLER)
 TO_REMOVE+=/usr/sbin/dfuibe_installer
diff --git a/bin/ls/Makefile b/bin/ls/Makefile
index ea60958..9523e18 100644
--- a/bin/ls/Makefile
+++ b/bin/ls/Makefile
@@ -6,6 +6,7 @@ SRCS=	cmp.c ls.c print.c util.c
 
 DPADD=	${LIBUTIL} ${LIBNCURSES}
 LDADD=	-lutil -lprivate_ncurses
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 CFLAGS+= -DCOLORLS
diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist
index c0ad072..d47d617 100644
--- a/etc/mtree/BSD.include.dist
+++ b/etc/mtree/BSD.include.dist
@@ -398,8 +398,12 @@
     pcap
     ..
     priv
+        ncurses
+        ..
         openssl
         ..
+        readline
+        ..
     ..
     protocols
     ..
diff --git a/games/atc/Makefile b/games/atc/Makefile
index 5a9f5c1..b703dd1 100644
--- a/games/atc/Makefile
+++ b/games/atc/Makefile
@@ -8,10 +8,12 @@ SRCS=	extern.c grammar.y graphics.c input.c lex.l list.c log.c \
 MAN=	atc.6
 DPADD=	${LIBL} ${LIBM} ${LIBNCURSES}
 LDADD=	-ll -lm -lprivate_ncurses
-LDFLAGS+=      ${PRIVATELIB_LDFLAGS}
-FILES=  Game_List Killer crossover default easy game_2
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
+LDFLAGS+=	${PRIVATELIB_LDFLAGS}
+FILES=		Game_List Killer crossover default easy game_2
 FILESDIR=	${SHAREDIR}/games/atc
-HIDEGAME=hidegame
+HIDEGAME=	hidegame
 
 .PATH: ${.CURDIR}/games
 
diff --git a/games/backgammon/backgammon/Makefile b/games/backgammon/backgammon/Makefile
index 58a03a9..85d4dd1 100644
--- a/games/backgammon/backgammon/Makefile
+++ b/games/backgammon/backgammon/Makefile
@@ -8,9 +8,12 @@ SRCS=	allow.c board.c check.c extra.c fancy.c init.c main.c move.c \
 MAN=	backgammon.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
+HIDEGAME=	hidegame
+
 .PATH:	${.CURDIR}/../common_source
-HIDEGAME=hidegame
 
 # XXX: mismatches between types for static init
 init.o:	init.c
diff --git a/games/backgammon/teachgammon/Makefile b/games/backgammon/teachgammon/Makefile
index f8459b8..4160aa9 100644
--- a/games/backgammon/teachgammon/Makefile
+++ b/games/backgammon/teachgammon/Makefile
@@ -1,14 +1,16 @@
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
 
 PROG=	teachgammon
+NOMAN=	noman
 CFLAGS+=-DTEACHGAMMON_TEXT -I${.CURDIR}/../common_source
 SRCS=	allow.c board.c check.c data.c fancy.c init.c odds.c one.c save.c \
 	subs.c table.c teach.c ttext1.c ttext2.c tutor.c
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
-NOMAN=	noman
+HIDEGAME=	hidegame
 
 .PATH:	${.CURDIR}/../common_source
 
diff --git a/games/battlestar/Makefile b/games/battlestar/Makefile
index 63e9015..6db28a4 100644
--- a/games/battlestar/Makefile
+++ b/games/battlestar/Makefile
@@ -9,8 +9,11 @@ SRCS=	battlestar.c command1.c command2.c command3.c command4.c \
 MAN=	battlestar.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
-HIDEGAME=hidegame
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
+HIDEGAME=	hidegame
+
 beforeinstall:
 .if !exists(${DESTDIR}/var/games/battlestar.log)
 	${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
diff --git a/games/bs/Makefile b/games/bs/Makefile
index 7818479..b496415 100644
--- a/games/bs/Makefile
+++ b/games/bs/Makefile
@@ -4,7 +4,9 @@ PROG=	bs
 MAN=	bs.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
+HIDEGAME=	hidegame
 
 .include <bsd.prog.mk>
diff --git a/games/canfield/canfield/Makefile b/games/canfield/canfield/Makefile
index cdc64e5..d573111 100644
--- a/games/canfield/canfield/Makefile
+++ b/games/canfield/canfield/Makefile
@@ -3,11 +3,13 @@
 
 PROG=	canfield
 MAN=	canfield.6
+MLINKS=	canfield.6 cfscores.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
-MLINKS=	canfield.6 cfscores.6
+HIDEGAME=	hidegame
 
 beforeinstall:
 .if !exists(${DESTDIR}/var/games/cfscores)
diff --git a/games/colorbars/Makefile b/games/colorbars/Makefile
index 09f7601..5204fe9 100644
--- a/games/colorbars/Makefile
+++ b/games/colorbars/Makefile
@@ -4,6 +4,8 @@ PROG=  colorbars
 MAN=   colorbars.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/games/cribbage/Makefile b/games/cribbage/Makefile
index 5e9105d..0579fe0 100644
--- a/games/cribbage/Makefile
+++ b/games/cribbage/Makefile
@@ -4,7 +4,10 @@
 PROG=	cribbage
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
+
 SRCS=	extern.c crib.c cards.c instr.c io.c score.c support.c
 FILES=	cribbage.n
 FILESNAME_cribbage.n=	cribbage.instr
diff --git a/games/grdc/Makefile b/games/grdc/Makefile
index e090390..1593f2a 100644
--- a/games/grdc/Makefile
+++ b/games/grdc/Makefile
@@ -4,6 +4,8 @@ PROG=	grdc
 MAN=	grdc.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/games/hack/Makefile b/games/hack/Makefile
index 1f7bc4b..4e5d28a 100644
--- a/games/hack/Makefile
+++ b/games/hack/Makefile
@@ -17,14 +17,17 @@ SRCS=	alloc.c hack.Decl.c hack.apply.c hack.bones.c hack.c hack.cmd.c \
 MAN=	hack.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+= 	-I${.CURDIR} -I.
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-CFLAGS+= -I${.CURDIR} -I.
-FILES=	rumors help hh data
+
+FILES=		rumors help hh data
 FILESMODE_rumors=	440
 FILESGRP=	${BINGRP}
 FILESDIR=	/var/games/hackdir
-HIDEGAME=hidegame
-CLEANFILES=hack.onames.h makedefs.nx makedefs.no
+HIDEGAME=	hidegame
+CLEANFILES=	hack.onames.h makedefs.nx makedefs.no
 NO_STRICT_ALIASING=
 
 build-tools: makedefs.nx
diff --git a/games/hangman/Makefile b/games/hangman/Makefile
index 108fdf6..a27ea45 100644
--- a/games/hangman/Makefile
+++ b/games/hangman/Makefile
@@ -6,6 +6,8 @@ SRCS=	endgame.c extern.c getguess.c getsym.c getword.c main.c playgame.c \
 MAN=	hangman.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/games/hunt/hunt/Makefile b/games/hunt/hunt/Makefile
index 14467ad..8d7a23e 100644
--- a/games/hunt/hunt/Makefile
+++ b/games/hunt/hunt/Makefile
@@ -6,6 +6,8 @@ SRCS=	connect.c hunt.c otto.c playit.c display.c list.c
 MAN=	hunt.6
 LDADD=	-lprivate_ncurses
 DPADD=	${LIBNCURSES}
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 CFLAGS+=-I${.CURDIR}/../huntd
diff --git a/games/larn/Makefile b/games/larn/Makefile
index e279328..3c2cfaa 100644
--- a/games/larn/Makefile
+++ b/games/larn/Makefile
@@ -50,10 +50,13 @@ SRCS=	main.c object.c create.c tok.c display.c global.c data.c io.c \
 	signal.c moreobj.c movem.c regen.c fortune.c savelev.c
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-FILES=	larnmaze larnopts larn.help
+
+FILES=		larnmaze larnopts larn.help
 FILESDIR=	${SHAREDIR}/games/larn
-HIDEGAME=hidegame
+HIDEGAME=	hidegame
 
 .PATH: ${.CURDIR}/datfiles
 
diff --git a/games/mille/Makefile b/games/mille/Makefile
index 53ca455..807e281 100644
--- a/games/mille/Makefile
+++ b/games/mille/Makefile
@@ -2,13 +2,14 @@
 # $FreeBSD: src/games/mille/Makefile,v 1.2.14.1 2001/04/25 09:28:58 ru Exp $
 
 PROG=	mille
+MAN=	mille.6
 SRCS=	comp.c end.c extern.c init.c mille.c misc.c move.c print.c \
 	roll.c save.c types.c varpush.c
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-MAN=	mille.6
-HIDEGAME=hidegame
+HIDEGAME=	hidegame
 
 .include <bsd.prog.mk>
-
diff --git a/games/phantasia/Makefile b/games/phantasia/Makefile
index e485433..dbf4400 100644
--- a/games/phantasia/Makefile
+++ b/games/phantasia/Makefile
@@ -2,15 +2,19 @@
 # $FreeBSD: src/games/phantasia/Makefile,v 1.16.2.2 2002/08/07 16:31:42 ru Exp $
 
 PROG=	phantasia
+MAN=	phantasia.6
 SRCS=	main.c fight.c io.c interplayer.c gamesupport.c misc.c phantglobs.c
 DPADD=	${LIBM} ${LIBNCURSES}
 LDADD=	-lm -lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-NXLDLIBS= -lm
-DATAFILES=characs gold lastdead mess monsters motd scoreboard void
-HIDEGAME=hidegame
-MAN=	phantasia.6
-CLEANFILES=${DATAFILES} cross-phantglobs.no map setup.nx setup.no stamp.setuprun
+
+NXLDLIBS=	-lm
+DATAFILES=	characs gold lastdead mess monsters motd scoreboard void
+HIDEGAME=	hidegame
+CLEANFILES=	${DATAFILES} cross-phantglobs.no map setup.nx setup.no \
+		stamp.setuprun
 
 all: stamp.setuprun
 
diff --git a/games/rain/Makefile b/games/rain/Makefile
index a0f2b9e..00e5e33 100644
--- a/games/rain/Makefile
+++ b/games/rain/Makefile
@@ -5,6 +5,8 @@ PROG=	rain
 MAN=	rain.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/games/robots/Makefile b/games/robots/Makefile
index 29546ff..b86e8e0 100644
--- a/games/robots/Makefile
+++ b/games/robots/Makefile
@@ -8,8 +8,10 @@ SRCS=	extern.c init_field.c main.c make_level.c move.c move_robs.c \
 MAN=	robots.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
+HIDEGAME=	hidegame
 
 beforeinstall:
 .if !exists(${DESTDIR}/var/games/robots_roll)
diff --git a/games/rogue/Makefile b/games/rogue/Makefile
index 26b9f3b..d0ae40d 100644
--- a/games/rogue/Makefile
+++ b/games/rogue/Makefile
@@ -2,15 +2,17 @@
 # $FreeBSD: src/games/rogue/Makefile,v 1.4.2.5 2002/08/07 16:31:42 ru Exp $
 
 PROG=	rogue
-CFLAGS+=-DUNIX
+MAN=	rogue.6
 SRCS=	hit.c init.c inventory.c level.c machdep.c main.c \
 	message.c monster.c move.c object.c pack.c play.c random.c ring.c \
 	room.c save.c score.c spec_hit.c throw.c trap.c use.c zap.c
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-DUNIX
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
-MAN=	rogue.6
+HIDEGAME=	hidegame
 
 beforeinstall:
 .if !exists(${DESTDIR}/var/games/rogue.scores)
diff --git a/games/sail/Makefile b/games/sail/Makefile
index 6669634..dc7ed2f 100644
--- a/games/sail/Makefile
+++ b/games/sail/Makefile
@@ -8,8 +8,10 @@ SRCS=	main.c pl_main.c pl_1.c pl_2.c pl_3.c pl_4.c pl_5.c pl_6.c pl_7.c \
 MAN=	sail.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
+HIDEGAME=	hidegame
 
 beforeinstall:
 .if !exists(${DESTDIR}/var/games/saillog)
diff --git a/games/snake/snake/Makefile b/games/snake/snake/Makefile
index 0cee869..99cf7c1 100644
--- a/games/snake/snake/Makefile
+++ b/games/snake/snake/Makefile
@@ -4,11 +4,13 @@
 PROG=	snake
 SRCS=	snake.c
 MAN=	snake.6
+MLINKS=	snake.6 snscore.6
 DPADD=	${LIBM} ${LIBNCURSES}
 LDADD=	-lm -lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
-MLINKS=	snake.6 snscore.6
+HIDEGAME=	hidegame
 
 beforeinstall:
 .if !exists(${DESTDIR}/var/games/snakerawscores)
diff --git a/games/worm/Makefile b/games/worm/Makefile
index ff0596a..7fb5ff8 100644
--- a/games/worm/Makefile
+++ b/games/worm/Makefile
@@ -5,7 +5,9 @@ PROG=	worm
 MAN=	worm.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-HIDEGAME=hidegame
+HIDEGAME=	hidegame
 
 .include <bsd.prog.mk>
diff --git a/games/worms/Makefile b/games/worms/Makefile
index a323e45..3efbaec 100644
--- a/games/worms/Makefile
+++ b/games/worms/Makefile
@@ -5,6 +5,8 @@ PROG=	worms
 MAN=	worms.6
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/gnu/lib/libdialog/Makefile b/gnu/lib/libdialog/Makefile
index f3e4f99..f6bbc2c 100644
--- a/gnu/lib/libdialog/Makefile
+++ b/gnu/lib/libdialog/Makefile
@@ -14,4 +14,6 @@ SRCS=	argv.c arrows.c buildlist.c buttons.c \
 	ui_getc.c util.c version.c yesno.c
 WARNS?=	3
 
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
+
 .include <bsd.lib.mk>
diff --git a/gnu/usr.bin/dialog/Makefile b/gnu/usr.bin/dialog/Makefile
index 703ebcb..19dba72 100644
--- a/gnu/usr.bin/dialog/Makefile
+++ b/gnu/usr.bin/dialog/Makefile
@@ -4,6 +4,8 @@ PROG=	dialog
 
 DPADD=	$(LIBDIALOG) ${LIBM} $(LIBNCURSESW)
 LDADD=	-ldialog -lm -lprivate_ncursesw
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/gnu/usr.bin/gdb/kgdb/Makefile b/gnu/usr.bin/gdb/kgdb/Makefile
index c259039..f744711 100644
--- a/gnu/usr.bin/gdb/kgdb/Makefile
+++ b/gnu/usr.bin/gdb/kgdb/Makefile
@@ -17,6 +17,8 @@ LDADD+= -L../libiberty -liberty
 LDADD+= -L../libdecnumber -ldecnumber
 LDADD+= -L../libgnu -lgnu
 LDADD+= -lprivate_ncurses -lm -lz -lkvm -llzma
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 WARNS?=	2
diff --git a/gnu/usr.bin/gdb/libgdb/Makefile b/gnu/usr.bin/gdb/libgdb/Makefile
index 857d222..e6b06e1 100644
--- a/gnu/usr.bin/gdb/libgdb/Makefile
+++ b/gnu/usr.bin/gdb/libgdb/Makefile
@@ -175,6 +175,8 @@ DPADD=	${LIBKVM} ${LIBNCURSES} ${LIBM}
 DPADD+=	../libbfd/libbfd.a ../libopcodes/libopcodes.a ../libiberty/libiberty.a
 LDADD=	-lprivate_ncurses -lm
 LDADD+=	-L../libbfd -lbfd -L../libopcodes -lopcodes -L../libiberty -liberty
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include "Makefile.${TARGET_ARCH}"
diff --git a/gnu/usr.bin/gdb/libreadline/Makefile b/gnu/usr.bin/gdb/libreadline/Makefile
index 319351e..28636ff 100644
--- a/gnu/usr.bin/gdb/libreadline/Makefile
+++ b/gnu/usr.bin/gdb/libreadline/Makefile
@@ -6,6 +6,7 @@ INTERNALLIB=	YES
 .PATH:		${BASEDIR}/readline
 CFLAGS+=	-I${.CURDIR} -I${.OBJDIR} -I${BASEDIR}
 CFLAGS+=	-DHAVE_CONFIG_H
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 
 SRCS+=		readline.c \
 		vi_mode.c \
diff --git a/lib/libedit/libedit/Makefile b/lib/libedit/libedit/Makefile
index 95dcd6b..12fd3e7 100644
--- a/lib/libedit/libedit/Makefile
+++ b/lib/libedit/libedit/Makefile
@@ -10,6 +10,7 @@ SRCDIR= 	${BASEDIR}/src
 .PATH:		${SRCDIR}
 
 CFLAGS+=	-I${SRCDIR} -I${.CURDIR} -I${.OBJDIR}
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 
 DPADD=		${LIBNCURSES}
 LDADD=		-lprivate_ncurses
diff --git a/lib/libedit/readline/Makefile b/lib/libedit/readline/Makefile
index ae6e42d..8c4e7a9 100644
--- a/lib/libedit/readline/Makefile
+++ b/lib/libedit/readline/Makefile
@@ -8,6 +8,6 @@ CONTRIBDIR=	${BASEDIR}/src
 .PATH:		${CONTRIBDIR}/editline
 
 INCS=		readline.h tilde.h history.h
-INCSDIR=	/usr/include/readline
+INCSDIR=	${INCLUDEDIR}/priv/readline
 
 .include <bsd.prog.mk>
diff --git a/lib/libncurses/libncurses/Makefile b/lib/libncurses/libncurses/Makefile
index 4c7398a..9af80b1 100644
--- a/lib/libncurses/libncurses/Makefile
+++ b/lib/libncurses/libncurses/Makefile
@@ -245,7 +245,8 @@ NCDYN=		libprivate_ncurses${LIB_SUFFIX}.so
 
 .if defined(ENABLE_WIDEC)
 INCS=		${HEADERS} ${SRCHDRS}
-INCSLINKS=	curses.h ${INCLUDEDIR}/ncurses.h
+INCSDIR=	${INCLUDEDIR}/priv/ncurses
+INCSLINKS=	curses.h ${INCLUDEDIR}/priv/ncurses/ncurses.h
 
 SRCS+=	charable.c \
 	lib_add_wch.c \
diff --git a/lib/libncurses/libpanel/Makefile b/lib/libncurses/libpanel/Makefile
index 325e611..a9b73a6 100644
--- a/lib/libncurses/libpanel/Makefile
+++ b/lib/libncurses/libpanel/Makefile
@@ -28,6 +28,12 @@ ${SRCS:M*.c}: curses.h
 
 INCS=	panel.h
 
+.if defined(ENABLE_WIDEC)	# for term.h
+CFLAGS+=	-I${.OBJDIR}/../libncursesw
+.else
+CFLAGS+=	-I${.OBJDIR}/../libncurses
+.endif
+
 CLEANFILES=	ncurses_def.h curses.h curses.h.new
 
 .include <bsd.lib.mk>
diff --git a/libexec/telnetd/Makefile b/libexec/telnetd/Makefile
index c7cb96c..d1675af 100644
--- a/libexec/telnetd/Makefile
+++ b/libexec/telnetd/Makefile
@@ -23,6 +23,7 @@ LIBTELNET=	${.OBJDIR}/../../lib/libtelnet/libtelnet.a
 DPADD=		${LIBUTIL} ${LIBNCURSES} ${LIBTELNET}
 LDADD=		-lutil -lprivate_ncurses ${LIBTELNET}
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 
 .if !defined(NO_CRYPT)
 SRCS+=		authenc.c
diff --git a/sbin/vinum/Makefile b/sbin/vinum/Makefile
index 9e6de2d..acac4cb 100644
--- a/sbin/vinum/Makefile
+++ b/sbin/vinum/Makefile
@@ -6,8 +6,10 @@ MAN=	vinum.8
 WARNS?=	2
 
 CFLAGS+=	-I${.CURDIR}/../../lib/libedit -I${.CURDIR}/../../sys
-DPADD=	${LIBEDIT} ${LIBNCURSES} ${LIBDEVSTAT}
-LDADD=	-lprivate_edit -lprivate_ncurses -ldevstat
+DPADD=		${LIBEDIT} ${LIBNCURSES} ${LIBDEVSTAT}
+LDADD=		-lprivate_edit -lprivate_ncurses -ldevstat
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/ee/Makefile b/usr.bin/ee/Makefile
index b29627c..bb90b1d 100644
--- a/usr.bin/ee/Makefile
+++ b/usr.bin/ee/Makefile
@@ -10,6 +10,8 @@ LINKS=	${BINDIR}/ee ${BINDIR}/ree ${BINDIR}/ee ${BINDIR}/edit
 MLINKS=	ee.1 ree.1 ee.1 edit.1
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 WARNS?=	2
diff --git a/usr.bin/ftp/Makefile b/usr.bin/ftp/Makefile
index ad410eb..b6fbcd8 100644
--- a/usr.bin/ftp/Makefile
+++ b/usr.bin/ftp/Makefile
@@ -18,6 +18,8 @@ CFLAGS+=-I${.CURDIR} -I${.OBJDIR} -I${CONTRIBDIR} \
 	-D__dead=__dead2 -DUSE_GLOB_H
 LDADD=	-lprivate_edit -lprivate_ncurses -lutil
 DPADD=	${LIBEDIT} ${LIBNCURSES} ${LIBUTIL}
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .if !defined(NO_CRYPT)
diff --git a/usr.bin/less/Makefile b/usr.bin/less/Makefile
index 118035d..3fbf6ea 100644
--- a/usr.bin/less/Makefile
+++ b/usr.bin/less/Makefile
@@ -10,6 +10,8 @@ SRCS=	main.c screen.c brac.c ch.c charset.c cmdbuf.c \
 CFLAGS+=	-I${.CURDIR} -DSYSDIR=\"/etc\"
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 SCRIPTS= lesspipe.sh
diff --git a/usr.bin/msgs/Makefile b/usr.bin/msgs/Makefile
index bf3435c..59315b9 100644
--- a/usr.bin/msgs/Makefile
+++ b/usr.bin/msgs/Makefile
@@ -4,6 +4,8 @@
 PROG=	msgs
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/ncal/Makefile b/usr.bin/ncal/Makefile
index 7b7ec5f..2f49aec 100644
--- a/usr.bin/ncal/Makefile
+++ b/usr.bin/ncal/Makefile
@@ -1,12 +1,13 @@
 # $FreeBSD: src/usr.bin/ncal/Makefile,v 1.2 1999/08/28 01:04:25 peter Exp $
 
 PROG= ncal
+LINKS=		${BINDIR}/ncal ${BINDIR}/cal
+MLINKS=		ncal.1 cal.1
 
 DPADD+=		${LIBCALENDAR} ${LIBNCURSES}
 LDADD+=		-lcalendar -lprivate_ncurses
-LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
-LINKS=		${BINDIR}/ncal ${BINDIR}/cal
-MLINKS=		ncal.1 cal.1
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
+LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile
index 11a0534..e27f482 100644
--- a/usr.bin/systat/Makefile
+++ b/usr.bin/systat/Makefile
@@ -17,6 +17,8 @@ BINMODE=2555
 
 DPADD+=	${LIBUTIL}
 LDADD+=	-lutil
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 CFLAGS+= -I${.CURDIR}/../../usr.bin/who -DSUPPORT_UTMP -DSUPPORT_UTMPX
diff --git a/usr.bin/tabs/Makefile b/usr.bin/tabs/Makefile
index b89a795..5997d5d 100644
--- a/usr.bin/tabs/Makefile
+++ b/usr.bin/tabs/Makefile
@@ -3,6 +3,8 @@
 PROG=	tabs
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/talk/Makefile b/usr.bin/talk/Makefile
index 9173a32..331c049 100644
--- a/usr.bin/talk/Makefile
+++ b/usr.bin/talk/Makefile
@@ -4,8 +4,10 @@
 PROG=	talk
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
-LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 SRCS=	ctl.c ctl_transact.c display.c get_addrs.c get_iface.c get_names.c \
 	init_disp.c invite.c io.c look_up.c msgs.c talk.c
 
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
+LDFLAGS+=	${PRIVATELIB_LDFLAGS}
+
 .include <bsd.prog.mk>
diff --git a/usr.bin/telnet/Makefile b/usr.bin/telnet/Makefile
index 9827d80..19cd6ec 100644
--- a/usr.bin/telnet/Makefile
+++ b/usr.bin/telnet/Makefile
@@ -18,6 +18,7 @@ CFLAGS+=	-DINET6
 
 DPADD=		${LIBNCURSES} ${LIBTELNET}
 LDADD=		-lprivate_ncurses ${LIBTELNET}
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 CFLAGS+=	-DIPSEC
diff --git a/usr.bin/tic/Makefile b/usr.bin/tic/Makefile
index 6bc5e73..5da1a3d 100644
--- a/usr.bin/tic/Makefile
+++ b/usr.bin/tic/Makefile
@@ -26,11 +26,13 @@ LDADD=		-lncurses
 .  else
 DPADD=		${LIBNCURSES}
 LDADD=		-lprivate_ncurses
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_BLDFLAGS}
 .  endif
 .else
 DPADD=		${LIBNCURSES}
 LDADD=		-lprivate_ncurses
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 .endif
 
diff --git a/usr.bin/top/Makefile b/usr.bin/top/Makefile
index c911b62..fa22250 100644
--- a/usr.bin/top/Makefile
+++ b/usr.bin/top/Makefile
@@ -19,7 +19,10 @@ SRCS=	commands.c getopt.c screen.c username.c version.c \
 
 DPADD=  ${LIBNCURSES} ${LIBM} ${LIBKVM} ${LIBKINFO}
 LDADD=  -lprivate_ncurses -lm -lkvm -lkinfo
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
+
 BINGRP= kmem
 BINMODE=2555
 
diff --git a/usr.bin/tput/Makefile b/usr.bin/tput/Makefile
index 6d44be4..6259f06 100644
--- a/usr.bin/tput/Makefile
+++ b/usr.bin/tput/Makefile
@@ -2,10 +2,12 @@
 # $FreeBSD: src/usr.bin/tput/Makefile,v 1.3.6.1 2001/04/25 14:04:33 ru Exp $
 
 PROG=	tput
+MLINKS=	tput.1 clear.1
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-SCRIPTS=clear.sh
-MLINKS=	tput.1 clear.1
+SCRIPTS=	clear.sh
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/tset/Makefile b/usr.bin/tset/Makefile
index 9b04309..352fe1a 100644
--- a/usr.bin/tset/Makefile
+++ b/usr.bin/tset/Makefile
@@ -1,12 +1,14 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/9/93
 
 PROG=	tset
+MLINKS=	tset.1 reset.1
+LINKS=	${BINDIR}/tset ${BINDIR}/reset
 SRCS=	map.c misc.c set.c term.c tset.c wrterm.c
 
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
-LINKS=	${BINDIR}/tset ${BINDIR}/reset
-MLINKS=	tset.1 reset.1
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/ul/Makefile b/usr.bin/ul/Makefile
index be86591..1113406 100644
--- a/usr.bin/ul/Makefile
+++ b/usr.bin/ul/Makefile
@@ -5,6 +5,8 @@ PROG=	ul
 
 DPADD=	${LIBNCURSES}
 LDADD=	-lprivate_ncurses
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/vi/Makefile b/usr.bin/vi/Makefile
index 68ede24..be76ccc 100644
--- a/usr.bin/vi/Makefile
+++ b/usr.bin/vi/Makefile
@@ -38,6 +38,8 @@ LDADD=		-lutil
 
 DPADD+=		${LIBNCURSESW}
 LDADD+=		-lprivate_ncursesw
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 CLEANFILES+=${EX}
diff --git a/usr.bin/window/Makefile b/usr.bin/window/Makefile
index 5250d79..be60ffe 100644
--- a/usr.bin/window/Makefile
+++ b/usr.bin/window/Makefile
@@ -18,6 +18,8 @@ SRCS=	char.c cmd.c cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c cmd7.c \
 
 DPADD=	${LIBNCURSES} ${LIBUTIL}
 LDADD=	-lprivate_ncurses -lutil
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/tzsetup/Makefile b/usr.sbin/tzsetup/Makefile
index 5a9ca89..dcb878b 100644
--- a/usr.sbin/tzsetup/Makefile
+++ b/usr.sbin/tzsetup/Makefile
@@ -5,6 +5,8 @@ MAN=	tzsetup.8
 
 DPADD=	${LIBDIALOG} ${LIBM} ${LIBNCURSESW}
 LDADD=	-ldialog -lm -lprivate_ncursesw
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/watch/Makefile b/usr.sbin/watch/Makefile
index d222b04..1e5185a 100644
--- a/usr.sbin/watch/Makefile
+++ b/usr.sbin/watch/Makefile
@@ -5,6 +5,8 @@ MAN=	watch.8
 
 LDADD=	-lprivate_ncurses
 DPADD=	${LIBNCURSES}
+
+CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
 .include <bsd.prog.mk>
-- 
2.10.1

