diff --git a/pkg.build b/pkg.build
index 975c183..dffcff7 100644
--- a/pkg.build
+++ b/pkg.build
@@ -37,12 +37,12 @@ fi;
 if ! is_build_script_done patch; then
 	if [ ${PKG_AUTOGEN:-0} -eq 1 ]; then
 		cd ${PKG_SUBDIR} &&				\
-		install -m 0700 ${_PWD}/config.sub build-aux/ &&\
+		install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub build-aux/ &&\
 				./autogen.sh && cd ${OLDPWD};
 	fi;
 	for PATCH_FNAME in portage/${PKG_SUBDIR}.midipix.patch	\
-			${_PWD}/${PKG_SUBDIR}.local.patch	\
-			${_PWD}/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do
+			${MIDIPIX_BUILD_PWD}/${PKG_SUBDIR}.local.patch	\
+			${MIDIPIX_BUILD_PWD}/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do
 		[ -r ${PATCH_FNAME} ] &&\
 			patch -b -d ${PKG_SUBDIR} -p1 < ${PATCH_FNAME};
 	done; unset PATCH_FNAME;
diff --git a/tcsh-6.19.00.local.patch b/tcsh-6.19.00.local.patch
index 721b614..9e843d4 100644
--- a/tcsh-6.19.00.local.patch
+++ b/tcsh-6.19.00.local.patch
@@ -34,9 +34,39 @@
    * )
      as_fn_error $? "Tcsh can't guess the configuration file name
  for \`${host}' systems.
---- tcsh-6.19.00/config/midipix.orig	2016-05-26 11:54:37.763728719 +0000
-+++ tcsh-6.19.00/config/midipix	2016-05-26 11:56:37.751726056 +0000
-@@ -0,0 +1,90 @@
+--- tcsh-6.19.00/sh.h.orig	2015-05-10 13:29:28.000000000 +0000
++++ tcsh-6.19.00/sh.h	2016-05-26 12:16:19.303699832 +0000
+@@ -333,7 +333,7 @@
+ #endif /* POSIX && !WINNT_NATIVE */
+ #include <limits.h>
+ 
+-#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
++#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__midipix__)
+ # if !defined(pyr) && !defined(stellar)
+ #  include <time.h>
+ #  ifdef _MINIX
+--- tcsh-6.19.00/Makefile.in.orig	2014-07-24 22:52:13.000000000 +0000
++++ tcsh-6.19.00/Makefile.in	2016-05-26 12:43:28.099663682 +0000
+@@ -24,6 +24,7 @@
+ CF=-c
+ 
+ CPPFLAGS=-I. -I$(srcdir)
++CPPFLAGS_FOR_GETHOST=-I. -I$(srcdir)
+ 
+ LFLAGS=
+ # hpux lint
+@@ -449,7 +450,7 @@
+ 
+ gethost:  gethost.c sh.err.h tc.const.h sh.h
+ 	rm -f gethost
+-	${CC_FOR_GETHOST} -o gethost ${CPPFLAGS} ${CFLAGS} $(srcdir)/gethost.c
++	${CC_FOR_GETHOST} -o gethost ${CPPFLAGS_FOR_GETHOST} ${CFLAGS_FOR_GETHOST} $(srcdir)/gethost.c
+ 
+ tc.defs.c:	gethost host.defs
+ 	@rm -f $@.tmp
+--- tcsh-6.19.00/config/midipix.orig	1970-01-01 00:00:00.000000000 +0000
++++ tcsh-6.19.00/config/midipix	2016-05-26 13:04:58.627635040 +0000
+@@ -0,0 +1,138 @@
 +/*
 + * config.h -- configure various defines for tcsh
 + *
@@ -85,7 +115,7 @@
 + *		This may or may not be true.  For example, Apple Unix
 + *		(OREO) has BSDJOBS but not BSDTIMES.
 + */
-+#undef BSDTIMES
++#define BSDTIMES
 +
 +/*
 + * BSDLIMIT	You have BSD-style resource limit stuff (getrlimit/setrlimit)
@@ -109,7 +139,7 @@
 + *
 + *		Note: Linux should work with any SYSVREL < 3.
 + */
-+#define SYSVREL	0
++#define SYSVREL	2
 +
 +/*
 + * YPBUGS	Work around Sun YP bugs that cause expansion of ~username
@@ -117,43 +147,61 @@
 + */
 +#undef YPBUGS
 +
++/*
++ * Get the name space we want.
++ *
++ * The more recent defaults for gcc (e.g. on Red Hat 7.0)
++ * also define _POSIX_C_SOURCE, which throws our code off.
++ */
++
++#define __STRICT_ANSI__
++#ifndef _BSD_SOURCE
++# define _BSD_SOURCE
++#endif
++#ifndef _SVID_SOURCE
++# define _SVID_SOURCE
++#endif
++#ifndef _POSIX_SOURCE
++# define _POSIX_SOURCE
++#endif
++#ifndef _XOPEN_SOURCE
++# define _XOPEN_SOURCE 500
++#endif
++#ifndef _GNU_SOURCE
++# define _GNU_SOURCE
++#endif
++
++/*
++ * Large file support from <features.h>
++ */
++
++#ifndef _LARGEFILE_SOURCE
++# define _LARGEFILE_SOURCE
++#endif
++#ifndef _LARGEFILE64_SOURCE
++# define _LARGEFILE64_SOURCE
++#endif
++#ifndef _FILE_OFFSET_BITS
++# define _FILE_OFFSET_BITS 64
++#endif
++
 +/****************** local defines *********************/
 +#ifndef _PATH_TCSHELL
 +#define _PATH_TCSHELL "/bin/tcsh"
 +#endif
 +#define ECHO_STYLE      BOTH_ECHO
 +
++#if !defined(SYSMALLOC)
++# define SYSMALLOC
++#endif
++#if !defined(NISPLUS)
++# define NISPLUS
++#endif
++#if !defined(POSIX)
++# define POSIX
++#endif
++
 +/* midipix allows paths prepended with double slashes (network paths). */
 +#define HAVE_SLASHSLASH 1
 +
 +#endif /* _h_config */
---- tcsh-6.19.00/sh.h.orig	2015-05-10 13:29:28.000000000 +0000
-+++ tcsh-6.19.00/sh.h	2016-05-26 12:16:19.303699832 +0000
-@@ -333,7 +333,7 @@
- #endif /* POSIX && !WINNT_NATIVE */
- #include <limits.h>
- 
--#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
-+#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__midipix__)
- # if !defined(pyr) && !defined(stellar)
- #  include <time.h>
- #  ifdef _MINIX
---- tcsh-6.19.00/Makefile.in.orig	2014-07-24 22:52:13.000000000 +0000
-+++ tcsh-6.19.00/Makefile.in	2016-05-26 12:43:28.099663682 +0000
-@@ -24,6 +24,7 @@
- CF=-c
- 
- CPPFLAGS=-I. -I$(srcdir)
-+CPPFLAGS_FOR_GETHOST=-I. -I$(srcdir)
- 
- LFLAGS=
- # hpux lint
-@@ -449,7 +450,7 @@
- 
- gethost:  gethost.c sh.err.h tc.const.h sh.h
- 	rm -f gethost
--	${CC_FOR_GETHOST} -o gethost ${CPPFLAGS} ${CFLAGS} $(srcdir)/gethost.c
-+	${CC_FOR_GETHOST} -o gethost ${CPPFLAGS_FOR_GETHOST} ${CFLAGS_FOR_GETHOST} $(srcdir)/gethost.c
- 
- tc.defs.c:	gethost host.defs
- 	@rm -f $@.tmp