diff --git a/.gitignore b/.gitignore
index 751b1d0..5953a19 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 build.log
+*.sw[op]
diff --git a/000.fetch_git.build b/000.fetch_git.build
index d66f195..27c0282 100644
--- a/000.fetch_git.build
+++ b/000.fetch_git.build
@@ -1,8 +1,12 @@
-# Git clone what we need.
-fetch_git cbb-gcc-${PKG_GCC_VERSION}	${GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION};
-fetch_git lazy				${GITROOT}/lazy;
-fetch_git mmglue			${GITROOT}/mmglue;
-fetch_git portage			${GITROOT}/ports/portage;
-fetch_git psxstub			${GITROOT}/psxstub;
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
+if ! is_build_script_done fetch; then
+	# Git clone what we need.
+	fetch_git lazy				${GITROOT}/lazy;
+	fetch_git portage			${GITROOT}/ports/portage;
+	set_build_script_done fetch finish;
+fi;
 
 # vim:filetype=sh
diff --git a/003.psxstub.build b/003.psxstub.build
deleted file mode 100644
index 535c008..0000000
--- a/003.psxstub.build
+++ /dev/null
@@ -1,10 +0,0 @@
-if is_build_script_done finished; then
-        exit 212;
-elif [ "x${TARGET}" = "xi686-nt32-midipix" ]\
-|| [ "x${TARGET}" = "xx86_64-nt64-midipix" ]; then
-	cd psxstub;
-	make ${MAKEFLAGS} DESTDIR=${PREFIX_LVL} TARGET=${TARGET} install;
-	set_build_script_done finished;
-fi;
-
-# vim:filetype=sh
diff --git a/003.psxstub.build b/003.psxstub.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/003.psxstub.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/003.psxstub.vars b/003.psxstub.vars
new file mode 100644
index 0000000..4683b7a
--- /dev/null
+++ b/003.psxstub.vars
@@ -0,0 +1,16 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
+pkg_psxstub_finish() {
+	if ! is_build_script_done install; then
+		if [ "x${TARGET}" = "xi686-nt32-midipix" ]\
+		|| [ "x${TARGET}" = "xx86_64-nt64-midipix" ]; then
+			cd psxstub;
+			make ${MAKEFLAGS} DESTDIR=${PREFIX_LVL} TARGET=${TARGET} install;
+			set_build_script_done install finish;
+		fi;
+	fi;
+};
+
+# vim:filetype=sh
diff --git a/004.musl.no-complex.build b/004.musl.no-complex.build
index 6e7a82b..59c5eff 120000
--- a/004.musl.no-complex.build
+++ b/004.musl.no-complex.build
@@ -1 +1 @@
-006.musl.build
\ No newline at end of file
+006.musl.full.build
\ No newline at end of file
diff --git a/006.musl.build b/006.musl.build
deleted file mode 100644
index d34f5b0..0000000
--- a/006.musl.build
+++ /dev/null
@@ -1,46 +0,0 @@
-export lz_arch=${ARCH} lz_cflags_debug=-O2 lz_target=${TARGET};
-
-if is_build_script_done finished; then
-        exit 212;
-elif [ "x${3}" = "xno-complex" ]; then
-	# Musl: build (no-complex)
-	_install=install_no_complex;
-	set_build_dir musl-${PKG_MUSL_VERSION}-${3} cross;
-	fetch http://www.musl-libc.org/releases/musl-${PKG_MUSL_VERSION}.tar.gz	\
-		${PKG_MUSL_SHA256SUM};
-	if ! is_build_script_done extracted; then
-		rm_if_exists musl-${PKG_MUSL_VERSION};
-		tar -xf musl-${PKG_MUSL_VERSION}.tar.gz;
-		cp -R mmglue/* musl-${PKG_MUSL_VERSION}/;
-		set_build_script_done extracted -configured;
-	fi;
-elif [ "x${3}" = "xnative" ]; then
-	# Musl: build (full)
-	_install=install;
-	set_build_dir musl-${PKG_MUSL_VERSION} ${3};
-else
-	# Musl: build (full)
-	_install=install;
-	set_build_dir musl-${PKG_MUSL_VERSION} cross;
-fi;
-if ! is_build_script_done configured; then
-	rm_if_exists -m -c ${BUILD_DIR};
-	../lazy/lazy				\
-		-a ${ARCH}			\
-		-c gcc				\
-		-f ${PREFIX_LVL}		\
-		-n musl				\
-		-p ../musl-${PKG_MUSL_VERSION}	\
-		-t ${lz_target}			\
-		-x config;
-	set_build_script_done configured -built;
-else
-	cd ${BUILD_DIR};
-fi;
-if ! is_build_script_done built; then
-	./lazy	-e ${_install}			\
-		-x build;
-	set_build_script_done built finished;
-fi;
-
-# vim:filetype=sh
diff --git a/006.musl.full.build b/006.musl.full.build
new file mode 100644
index 0000000..0b97e62
--- /dev/null
+++ b/006.musl.full.build
@@ -0,0 +1,60 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
+# Order: no-complex, native
+
+export lz_arch=${ARCH} lz_cflags_debug=-O2 lz_target=${TARGET};
+
+if [ "x${3}" = "xno-complex" ]; then
+	# Musl: build (no-complex)
+	_install=install_no_complex;
+	set_build_dir musl-${PKG_MUSL_VERSION}-${3} cross;
+	if ! is_build_script_done fetch; then
+		rm_if_exists musl-${PKG_MUSL_VERSION}.tar.gz;
+		fetch http://www.musl-libc.org/releases/musl-${PKG_MUSL_VERSION}.tar.gz	\
+			${PKG_MUSL_SHA256SUM};
+		rm_if_exists mmglue;
+		fetch_git mmglue ${GITROOT}/mmglue;
+		set_build_script_done fetch -extract;
+	fi;
+	if ! is_build_script_done extract; then
+		rm_if_exists musl-${PKG_MUSL_VERSION};
+		tar -xf musl-${PKG_MUSL_VERSION}.tar.gz;
+		cp -R mmglue/* musl-${PKG_MUSL_VERSION}/;
+		set_build_script_done extract -configure;
+	fi;
+elif [ "x${3}" = "xnative" ]; then
+	# Musl: build (full)
+	_install=install;
+	set_build_dir musl-${PKG_MUSL_VERSION} ${3};
+elif [ "x${3}" = "xfull" ]; then
+	# Musl: build (full)
+	_install=install;
+	set_build_dir musl-${PKG_MUSL_VERSION} cross;
+fi;
+if ! is_build_script_done configure; then
+	rm_if_exists -m -c ${BUILD_DIR};
+	../lazy/lazy				\
+		-a ${ARCH}			\
+		-c gcc				\
+		-f ${PREFIX_LVL}		\
+		-n musl				\
+		-p ../musl-${PKG_MUSL_VERSION}	\
+		-t ${lz_target}			\
+		-x config;
+	set_build_script_done configure clean -build;
+else
+	cd ${BUILD_DIR};
+fi;
+if ! is_build_script_done clean; then
+	make ${MAKEFLAGS} clean;
+	set_build_script_done clean -build;
+fi;
+if ! is_build_script_done build; then
+	./lazy	-e ${_install}			\
+		-x build;
+	set_build_script_done build finish;
+fi;
+
+# vim:filetype=sh
diff --git a/007.gcc.full.build b/007.gcc.full.build
index 73eccbb..3af5c15 100644
--- a/007.gcc.full.build
+++ b/007.gcc.full.build
@@ -1,43 +1,51 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
 # Order: stage1, runtime, full, native
 
-if is_build_script_done finished; then
-        exit 212;
-elif [ "x${3}" = "xruntime" ]\
+if [ "x${3}" = "xruntime" ]\
 ||   [ "x${3}" = "xfull" ]; then
 	set_build_dir cbb-gcc-${PKG_GCC_VERSION} cross;
 	cd ${BUILD_DIR};
 	if [ "x${3}" = "xruntime" ]; then
 		# GCC, compiler runtime.
-		if ! is_build_script_done built; then
+		if ! is_build_script_done build; then
 			make ${MAKEFLAGS} all-target-libgcc;
-			set_build_script_done built -installed;
+			set_build_script_done build -install;
 		fi;
-		if ! is_build_script_done installed; then
+		if ! is_build_script_done install; then
 			make ${MAKEFLAGS} install-target-libgcc;
-			set_build_script_done installed finished;
+			set_build_script_done install finish;
 		fi;
 	elif [ "x${3}" = "xfull" ]; then
 		# GCC, everything else.
-		if ! is_build_script_done built1; then
+		if ! is_build_script_done build1; then
 			make ${MAKEFLAGS} all-target-libstdc++-v3;
-			set_build_script_done built1 -installed1;
+			set_build_script_done build1 -install1;
 		fi;
-		if ! is_build_script_done installed1; then
+		if ! is_build_script_done install1; then
 			make ${MAKEFLAGS} install-target-libstdc++-v3;
-			set_build_script_done installed1 -built2;
+			set_build_script_done install1 -build2;
 		fi;
-		if ! is_build_script_done built2; then
+		if ! is_build_script_done build2; then
 			make ${MAKEFLAGS};
-			set_build_script_done built2 -installed2;
+			set_build_script_done build2 -install2;
 		fi;
-		if ! is_build_script_done installed2; then
+		if ! is_build_script_done install2; then
 			make ${MAKEFLAGS} install;
-			set_build_script_done installed2 finished;
+			set_build_script_done install2 finish;
 		fi;
 	fi;
 else
 	if [ "x${3}" = "xstage1" ]; then
 		# GCC, stage1.
+		if ! is_build_script_done fetch; then
+			rm_if_exists cbb-gcc-${PKG_GCC_VERSION};
+			fetch_git cbb-gcc-${PKG_GCC_VERSION}		\
+			${GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION};
+			set_build_script_done fetch -configure;
+		fi;
 		set_build_dir cbb-gcc-${PKG_GCC_VERSION} cross;
 		export	cbb_ldflags_for_target=--sysroot=${PREFIX_LVL}	\
 			cbb_sysroot_for_libgcc=${PREFIX_LVL}		\
@@ -56,10 +64,10 @@ else
 	fi;
 	GCCFLAGS="${CFLAGS:+${CFLAGS} }--include $(readlink -f ${WORKDIR}/cbb-gcc-${PKG_GCC_VERSION}/libc/cbb-musl-pe.h)";
 	set_env_vars "${GCCFLAGS}" CFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD CXXFLAGS CXXFLAGS_FOR_BUILD;
-	set_env_vars "${CFLAGS_FOR_BUILD}" cbb_cflags_for_stage1 cbb_cflags_for_stage2 cbb_cflags_for_stage3 cbb_cflags_for_stage4;
 	set_env_vars "${GCCTARGET_FLAGS}" CFLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LIBCFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET;
+	set_env_vars "${CFLAGS_FOR_BUILD}" cbb_cflags_for_stage1 cbb_cflags_for_stage2 cbb_cflags_for_stage3 cbb_cflags_for_stage4;
 	export CFLAGS CXXFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD CXXFLAGS_FOR_BUILD CFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LIBCFLAGS_FOR_TARGET;
-	if ! is_build_script_done configured; then
+	if ! is_build_script_done configure; then
 		if [ "x${3}" = "xstage1" ]; then
 			mkdir -p ${PREFIX_LVL}/include;
 			[ \! -d ${PREFIX_LVL}/usr ] &&			\
@@ -104,28 +112,32 @@ else
 			--target=${TARGET}			\
 			--with-fpmath=sse			\
 			${_configure_args};
-		set_build_script_done configured -built;
+		set_build_script_done configure clean -build;
 	else
 		cd ${BUILD_DIR};
 	fi;
-	if ! is_build_script_done built; then
+	if ! is_build_script_done clean; then
+		make ${MAKEFLAGS} clean;
+		set_build_script_done clean -build;
+	fi;
+	if ! is_build_script_done build; then
 		if [ "x${3}" = "xstage1" ]; then
 			make ${MAKEFLAGS} all-gcc;
 		elif [ "x${3}" = "xnative" ]; then
-			make -j18 all-gcc;
-			make -j18 all-target-libgcc;
-			make -j18 all-target-libstdc++-v3;
-			make -j18 all;
+			make ${MAKEFLAGS} all-gcc;
+			make ${MAKEFLAGS} all-target-libgcc;
+			make ${MAKEFLAGS} all-target-libstdc++-v3;
+			make ${MAKEFLAGS} all;
 		fi;
-		set_build_script_done built -installed;
+		set_build_script_done build -install;
 	fi;
-	if ! is_build_script_done installed; then
+	if ! is_build_script_done install; then
 		if [ "x${3}" = "xstage1" ]; then
 			make ${MAKEFLAGS} install-gcc;
 		elif [ "x${3}" = "xnative" ]; then
-			make -j18 DESTDIR=${PREFIX_LVL} install;
+			make ${MAKEFLAGS} DESTDIR=${PREFIX_LVL} install;
 		fi;
-		set_build_script_done installed finished;
+		set_build_script_done install finish;
 	fi;
 fi;
 
diff --git a/100.perk.build b/100.perk.build
index dd9d9c8..cded5a9 100644
--- a/100.perk.build
+++ b/100.perk.build
@@ -1,39 +1,51 @@
-if is_build_script_done finished; then
-        exit 212;
-else
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
+if ! is_build_script_done fetch; then
+	rm_if_exists perk;
 	fetch_git perk ${GITROOT}/perk;
-	set_build_dir ${2} native;
+	set_build_script_done fetch -configure1;
 fi;
-if ! is_build_script_done configured1; then
+set_build_dir ${2} native;
+if ! is_build_script_done configure1; then
 	rm_if_exists -m -c ${BUILD_DIR};
 	../perk/configure;
-	set_build_script_done configured1 -built1;
+	set_build_script_done configure1 clean1 -build1;
 else
 	cd ${BUILD_DIR};
 fi;
-if ! is_build_script_done built1; then
+if ! is_build_script_done clean1; then
+	make ${MAKEFLAGS} clean;
+	set_build_script_done clean1 -build1;
+fi;
+if ! is_build_script_done build1; then
 	make;
-	set_build_script_done built1 -installed1;
+	set_build_script_done build1 -install1;
 fi;
-if ! is_build_script_done installed1; then
+if ! is_build_script_done install1; then
 	make DESTDIR=${PREFIX} install;
-	set_build_script_done installed1 -configured2;
+	set_build_script_done install1 -configure2;
 fi;
 set_build_dir ${2} cross;
-if ! is_build_script_done configured2; then
+if ! is_build_script_done configure2; then
 	rm_if_exists -m -c ../${BUILD_DIR};
 	../perk/configure --target=${TARGET};
-	set_build_script_done configured2 -built2;
+	set_build_script_done configure2 clean2 -build2;
 else
 	cd ../${BUILD_DIR};
 fi;
-if ! is_build_script_done built2; then
+if ! is_build_script_done clean2; then
+	make ${MAKEFLAGS} clean;
+	set_build_script_done clean2 -build2;
+fi;
+if ! is_build_script_done build2; then
 	make;
-	set_build_script_done built2 -installed2;
+	set_build_script_done build2 -install2;
 fi;
-if ! is_build_script_done installed2; then
+if ! is_build_script_done install2; then
 	make DESTDIR=${PREFIX_LVL} install;
-	set_build_script_done installed2 finished;
+	set_build_script_done install2 finish;
 fi;
 
 # vim:filetype=sh
diff --git a/104.libelf.vars b/104.libelf.vars
index 786e691..4b65413 100644
--- a/104.libelf.vars
+++ b/104.libelf.vars
@@ -1,5 +1,9 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
 pkg_libelf_install_post() {
-	if ! is_build_script_done installed2; then
+	if ! is_build_script_done install2; then
 		rm -f lib/libelf.def;
 		echo EXPORTS > lib/libelf.def;
 		perk -e lib/libelf.so >> lib/libelf.def;
@@ -8,7 +12,7 @@ pkg_libelf_install_post() {
 			--dllname libelf.so		\
 			--input-def lib/libelf.def;
 		cp lib/libelf.lib.a ${PREFIX}/lib;
-		set_build_script_done installed2 -finished;
+		set_build_script_done install2 -finish;
 	fi;
 };
 
diff --git a/106.musl.native.build b/106.musl.native.build
index 6e7a82b..59c5eff 120000
--- a/106.musl.native.build
+++ b/106.musl.native.build
@@ -1 +1 @@
-006.musl.build
\ No newline at end of file
+006.musl.full.build
\ No newline at end of file
diff --git a/200.psxtypes.vars b/200.psxtypes.vars
index 493d9c1..b58a094 100644
--- a/200.psxtypes.vars
+++ b/200.psxtypes.vars
@@ -1,7 +1,11 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
 pkg_psxtypes_finish() {
 	if ! is_build_script_done installed; then
 		make -C ${PKG_SUBDIR} ${MAKEFLAGS} DESTDIR=${PREFIX_LVL};
-		set_build_script_done installed finished;
+		set_build_script_done installed finish;
 	fi;
 };
 
diff --git a/300.bzip2.build b/300.bzip2.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/300.bzip2.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/300.coreutils.build b/300.coreutils.build
deleted file mode 120000
index 52bb82e..0000000
--- a/300.coreutils.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/301.coreutils.build b/301.coreutils.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/301.coreutils.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/301.diffutils.build b/301.diffutils.build
deleted file mode 120000
index 52bb82e..0000000
--- a/301.diffutils.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/302.diffutils.build b/302.diffutils.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/302.diffutils.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/302.findutils.build b/302.findutils.build
deleted file mode 120000
index 52bb82e..0000000
--- a/302.findutils.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/302.patch.build b/302.patch.build
deleted file mode 120000
index 52bb82e..0000000
--- a/302.patch.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/303.findutils.build b/303.findutils.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/303.findutils.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/303.gawk.build b/303.gawk.build
deleted file mode 120000
index 52bb82e..0000000
--- a/303.gawk.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/304.bash.build b/304.bash.build
deleted file mode 120000
index 52bb82e..0000000
--- a/304.bash.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/304.bash.vars b/304.bash.vars
deleted file mode 100644
index b1333b3..0000000
--- a/304.bash.vars
+++ /dev/null
@@ -1,45 +0,0 @@
-PKG_BASH_PATCHES_EXTRA_MANIFEST="
-bash43-001 ecb3dff2648667513e31554b3ad054ccd89fce38e33367c9459ac3a285153742
-bash43-002 eee7cd7062ab29a9e4f02924d9c367264dcb8b162703f74ff6eb8f175a91502b
-bash43-003 000e6eac50cd9053ce0630db01239dcdead04a2c2c351c47e2b51dac1ac1087d
-bash43-004 5ea0a42c6506720d26e6d3c5c358e9a0d49f6f189d69a8ed34d5935964821338
-bash43-005 1ac83044032b9f5f11aeca8a344ae3c524ec2156185d3adbb8ad3e7a165aa3fa
-bash43-006 a0648ee72d15e4a90c8b77a5c6b19f8d89e28c1bc881657d22fe26825f040213
-bash43-007 1113e321c59cf6a8648a36245bbe4217cf8acf948d71e67886dad7d486f8f3a3
-bash43-008 9941a98a4987192cc5ce3d45afe879983cad2f0bec96d441a4edd9033767f95e
-bash43-009 c0226d6728946b2f53cdebf090bcd1c01627f01fee03295768605caa80bb40a5
-bash43-010 ce05799c0137314c70c7b6ea0477c90e1ac1d52e113344be8e32fa5a55c9f0b7
-bash43-011 7c63402cdbc004a210f6c1c527b63b13d8bb9ec9c5a43d5c464a9010ff6f7f3b
-bash43-012 3e1379030b35fbcf314e9e7954538cf4b43be1507142b29efae39eef997b8c12
-bash43-013 bfa8ca5336ab1f5ef988434a4bdedf71604aa8a3659636afa2ce7c7446c42c79
-bash43-014 5a4d6fa2365b6eb725a9d4966248b5edf7630a4aeb3fa8d526b877972658ac13
-bash43-015 13293e8a24e003a44d7fe928c6b1e07b444511bed2d9406407e006df28355e8d
-bash43-016 92d60bcf49f61bd7f1ccb9602bead6f2c9946d79dea0e5ec0589bb3bfa5e0773
-bash43-017 1267c25c6b5ba57042a7bb6c569a6de02ffd0d29530489a16666c3b8a23e7780
-bash43-018 7aa8b40a9e973931719d8cc72284a8fb3292b71b522db57a5a79052f021a3d58
-bash43-019 a7a91475228015d676cafa86d2d7aa9c5d2139aa51485b6bbdebfdfbcf0d2d23
-bash43-020 ca5e86d87f178128641fe91f2f094875b8c1eb2de9e0d2e9154f5d5cc0336c98
-bash43-021 41439f06883e6bd11c591d9d5e9ae08afbc2abd4b935e1d244b08100076520a9
-bash43-022 fd4d47bb95c65863f634c4706c65e1e3bae4ee8460c72045c0a0618689061a88
-bash43-023 9ac250c7397a8f53dbc84dfe790d2a418fbf1fe090bcece39b4a5c84a2d300d4
-bash43-024 3b505882a0a6090667d75824fc919524cd44cc3bd89dd08b7c4e622d3f960f6c
-bash43-025 1e5186f5c4a619bb134a1177d9e9de879f3bb85d9c5726832b03a762a2499251
-bash43-026 2ecc12201b3ba4273b63af4e9aad2305168cf9babf6d11152796db08724c214d
-bash43-027 1eb76ad28561d27f7403ff3c76a36e932928a4b58a01b868d663c165f076dabe
-bash43-028 e8b0dbed4724fa7b9bd8ff77d12c7f03da0fbfc5f8251ef5cb8511eb082b469d
-bash43-029 4cc4a397fe6bc63ecb97d030a4e44258ef2d4e076d0e90c77782968cc43d6292
-bash43-030 85434f8a2f379d0c49a3ff6d9ffa12c8b157188dd739e556d638217d2a58385b
-bash43-031 cd529f59dd0f2fdd49d619fe34691da6f0affedf87cc37cd460a9f3fe812a61d
-bash43-032 889357d29a6005b2c3308ca5b6286cb223b5e9c083219e5db3156282dd554f4a
-bash43-033 fb2a7787a13fbe027a7335aca6eb3c21cdbd813e9edc221274b6a9d8692eaa16
-bash43-034 f1694f04f110defe1330a851cc2768e7e57ddd2dfdb0e3e350ca0e3c214ff889
-bash43-035 370d85e51780036f2386dc18c5efe996eba8e652fc1973f0f4f2ab55a993c1e3
-bash43-036 ac5f82445b36efdb543dbfae64afed63f586d7574b833e9aa9cd5170bc5fd27c
-bash43-037 33f170dd7400ab3418d749c55c6391b1d161ef2de7aced1873451b3a3fca5813
-bash43-038 adbeaa500ca7a82535f0e88d673661963f8a5fcdc7ad63445e68bf5b49786367
-bash43-039 ab94dced2215541097691f60c3eb323cc28ef2549463e6a5334bbcc1e61e74ec
-bash43-040 84bb396b9262992ca5424feab6ed3ec39f193ef5c76dfe4a62b551bd8dd9d76b
-bash43-041 4ec432966e4198524a7e0cd685fe222e96043769c9613e66742ac475db132c1a
-bash43-042 ac219322db2791da87a496ee6e8e5544846494bdaaea2626270c2f73c1044919";
-
-# vim:filetype=sh
diff --git a/304.gawk.build b/304.gawk.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/304.gawk.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/305.gzip.build b/305.gzip.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/305.gzip.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/305.gzip.vars b/305.gzip.vars
new file mode 100644
index 0000000..0e23442
--- /dev/null
+++ b/305.gzip.vars
@@ -0,0 +1,11 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
+pkg_gzip_install() {
+	tar -cpf - gunzip gzip zcat |\
+		tar -C ${PREFIX_LVL}/bin -xpf -;
+	set_build_script_done install1 -finish;
+};
+
+# vim:filetype=sh
diff --git a/305.make.build b/305.make.build
deleted file mode 120000
index 52bb82e..0000000
--- a/305.make.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/306.grep.build b/306.grep.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/306.grep.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/306.libz.build b/306.libz.build
deleted file mode 100644
index a1678bf..0000000
--- a/306.libz.build
+++ /dev/null
@@ -1,42 +0,0 @@
-parse_with_pkg_name ${2} libz gzip;
-if is_build_script_done finished; then
-        exit 212;
-else
-	fetch ${PKG_URL} ${PKG_SHA256SUM};
-fi;
-if ! is_build_script_done extracted; then
-	rm_if_exists ${PKG_FNAME%%.tar*};
-	tar -axf ${PKG_FNAME};
-	set_build_script_done extracted -configured;
-fi;
-if ! is_build_script_done configured; then
-	set_build_dir ${PKG_FNAME%%-*} native;
-	rm_if_exists -c -m ${BUILD_DIR};
-	cp ../portage/config.cache .;
-	../${PKG_SUBDIR}/configure		\
-		--host=${HOST_NATIVE}		\
-		--prefix=			\
-		--target=${TARGET};
-	set_build_script_done configured -built;
-else
-	cd ${BUILD_DIR};
-fi;
-if ! is_build_script_done built; then
-	if [ "x${2}" = "xlibz" ]; then
-		make -j18;
-	elif [ "x${2}" = "xgzip" ]; then
-		make clean;
-		make;
-	fi;
-	set_build_script_done built -installed;
-fi;
-if ! is_build_script_done installed; then
-	if [ "x${2}" = "xlibz" ]; then
-		make -j18 DESTDIR=${PREFIX_LVL} install;
-	elif [ "x${2}" = "xgzip" ]; then
-		cp gunzip gzip zcat ${PREFIX_LVL}/bin;
-	fi;
-	set_build_script_done installed finished;
-fi;
-
-# vim:filetype=sh
diff --git a/307.gzip.build b/307.gzip.build
deleted file mode 120000
index bee571a..0000000
--- a/307.gzip.build
+++ /dev/null
@@ -1 +0,0 @@
-306.libz.build
\ No newline at end of file
diff --git a/307.libz.build b/307.libz.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/307.libz.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/308.grep.build b/308.grep.build
deleted file mode 120000
index 52bb82e..0000000
--- a/308.grep.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/308.make.build b/308.make.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/308.make.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/309.patch.build b/309.patch.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/309.patch.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/309.sed.build b/309.sed.build
deleted file mode 120000
index 52bb82e..0000000
--- a/309.sed.build
+++ /dev/null
@@ -1 +0,0 @@
-pkg.build
\ No newline at end of file
diff --git a/310.tar.build b/310.tar.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/310.tar.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/311.sed.build b/311.sed.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/311.sed.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/312.xz.build b/312.xz.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/312.xz.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/313.which.build b/313.which.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/313.which.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/340.popt.build b/340.popt.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/340.popt.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/341.rsync.build b/341.rsync.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/341.rsync.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/350.ncurses.build b/350.ncurses.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/350.ncurses.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/351.bash.build b/351.bash.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/351.bash.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/351.bash.vars b/351.bash.vars
new file mode 100644
index 0000000..8ab081a
--- /dev/null
+++ b/351.bash.vars
@@ -0,0 +1,49 @@
+#
+# . ./build.vars and set -o errexit are assumed.
+#
+
+PKG_BASH_PATCHES_EXTRA_MANIFEST="
+bash43-001 ecb3dff2648667513e31554b3ad054ccd89fce38e33367c9459ac3a285153742
+bash43-002 eee7cd7062ab29a9e4f02924d9c367264dcb8b162703f74ff6eb8f175a91502b
+bash43-003 000e6eac50cd9053ce0630db01239dcdead04a2c2c351c47e2b51dac1ac1087d
+bash43-004 5ea0a42c6506720d26e6d3c5c358e9a0d49f6f189d69a8ed34d5935964821338
+bash43-005 1ac83044032b9f5f11aeca8a344ae3c524ec2156185d3adbb8ad3e7a165aa3fa
+bash43-006 a0648ee72d15e4a90c8b77a5c6b19f8d89e28c1bc881657d22fe26825f040213
+bash43-007 1113e321c59cf6a8648a36245bbe4217cf8acf948d71e67886dad7d486f8f3a3
+bash43-008 9941a98a4987192cc5ce3d45afe879983cad2f0bec96d441a4edd9033767f95e
+bash43-009 c0226d6728946b2f53cdebf090bcd1c01627f01fee03295768605caa80bb40a5
+bash43-010 ce05799c0137314c70c7b6ea0477c90e1ac1d52e113344be8e32fa5a55c9f0b7
+bash43-011 7c63402cdbc004a210f6c1c527b63b13d8bb9ec9c5a43d5c464a9010ff6f7f3b
+bash43-012 3e1379030b35fbcf314e9e7954538cf4b43be1507142b29efae39eef997b8c12
+bash43-013 bfa8ca5336ab1f5ef988434a4bdedf71604aa8a3659636afa2ce7c7446c42c79
+bash43-014 5a4d6fa2365b6eb725a9d4966248b5edf7630a4aeb3fa8d526b877972658ac13
+bash43-015 13293e8a24e003a44d7fe928c6b1e07b444511bed2d9406407e006df28355e8d
+bash43-016 92d60bcf49f61bd7f1ccb9602bead6f2c9946d79dea0e5ec0589bb3bfa5e0773
+bash43-017 1267c25c6b5ba57042a7bb6c569a6de02ffd0d29530489a16666c3b8a23e7780
+bash43-018 7aa8b40a9e973931719d8cc72284a8fb3292b71b522db57a5a79052f021a3d58
+bash43-019 a7a91475228015d676cafa86d2d7aa9c5d2139aa51485b6bbdebfdfbcf0d2d23
+bash43-020 ca5e86d87f178128641fe91f2f094875b8c1eb2de9e0d2e9154f5d5cc0336c98
+bash43-021 41439f06883e6bd11c591d9d5e9ae08afbc2abd4b935e1d244b08100076520a9
+bash43-022 fd4d47bb95c65863f634c4706c65e1e3bae4ee8460c72045c0a0618689061a88
+bash43-023 9ac250c7397a8f53dbc84dfe790d2a418fbf1fe090bcece39b4a5c84a2d300d4
+bash43-024 3b505882a0a6090667d75824fc919524cd44cc3bd89dd08b7c4e622d3f960f6c
+bash43-025 1e5186f5c4a619bb134a1177d9e9de879f3bb85d9c5726832b03a762a2499251
+bash43-026 2ecc12201b3ba4273b63af4e9aad2305168cf9babf6d11152796db08724c214d
+bash43-027 1eb76ad28561d27f7403ff3c76a36e932928a4b58a01b868d663c165f076dabe
+bash43-028 e8b0dbed4724fa7b9bd8ff77d12c7f03da0fbfc5f8251ef5cb8511eb082b469d
+bash43-029 4cc4a397fe6bc63ecb97d030a4e44258ef2d4e076d0e90c77782968cc43d6292
+bash43-030 85434f8a2f379d0c49a3ff6d9ffa12c8b157188dd739e556d638217d2a58385b
+bash43-031 cd529f59dd0f2fdd49d619fe34691da6f0affedf87cc37cd460a9f3fe812a61d
+bash43-032 889357d29a6005b2c3308ca5b6286cb223b5e9c083219e5db3156282dd554f4a
+bash43-033 fb2a7787a13fbe027a7335aca6eb3c21cdbd813e9edc221274b6a9d8692eaa16
+bash43-034 f1694f04f110defe1330a851cc2768e7e57ddd2dfdb0e3e350ca0e3c214ff889
+bash43-035 370d85e51780036f2386dc18c5efe996eba8e652fc1973f0f4f2ab55a993c1e3
+bash43-036 ac5f82445b36efdb543dbfae64afed63f586d7574b833e9aa9cd5170bc5fd27c
+bash43-037 33f170dd7400ab3418d749c55c6391b1d161ef2de7aced1873451b3a3fca5813
+bash43-038 adbeaa500ca7a82535f0e88d673661963f8a5fcdc7ad63445e68bf5b49786367
+bash43-039 ab94dced2215541097691f60c3eb323cc28ef2549463e6a5334bbcc1e61e74ec
+bash43-040 84bb396b9262992ca5424feab6ed3ec39f193ef5c76dfe4a62b551bd8dd9d76b
+bash43-041 4ec432966e4198524a7e0cd685fe222e96043769c9613e66742ac475db132c1a
+bash43-042 ac219322db2791da87a496ee6e8e5544846494bdaaea2626270c2f73c1044919";
+
+# vim:filetype=sh
diff --git a/352.dash.build b/352.dash.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/352.dash.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/353.less.build b/353.less.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/353.less.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/354.util_linux.build b/354.util_linux.build
new file mode 120000
index 0000000..52bb82e
--- /dev/null
+++ b/354.util_linux.build
@@ -0,0 +1 @@
+pkg.build
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index de0c557..3d40165 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2016 lalbornoz
+Copyright (c) 2016 Lucio Andrés Illanes Albornoz <l.illanes@gmx.de>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/build.sh b/build.sh
index eb21970..4f0dbfc 100755
--- a/build.sh
+++ b/build.sh
@@ -1,73 +1,82 @@
 #!/bin/sh
-
+#
 {
-#clear_env_with_except HOME PATH SHELL TERM USER;
-unset AR ARFLAGS CC CFLAGS CXX CXXFLAGS LD LDFLAGS;
-. ./build.vars; . ./build.subr;
+. ./build.subr;
+parse_args_into_vars "${0}" build-scripts,build-steps,help,tarball "${@}";
+[ -n "${ARG_HELP}" ] && { exec cat build.usage; } || . ./build.vars;
+clear_env_with_except HOME PATH SHELL TERM USER;
 check_path_vars PREFIX PREFIX_NATIVE WORKDIR;
-check_prereqs git make openssl sed sort tar tr wget;
-set_env_vars "" LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS \
-LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL;
+check_prereqs git make mktemp openssl sed sort tar tr wget;
 log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE:=$(date %Y-%m-%d-%H-%M-%S)}.";
-#trap
-(set -o errexit; mkdir -p ${PREFIX} ${WORKDIR});
+log_env_vars ${LOG_ENV_VARS};
+(mkdir -p ${PREFIX} ${PREFIX_NATIVE} ${PREFIX_TARGET} ${WORKDIR};
 BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
 for BUILD_LVL in 0 1 2 3; do
 	for BUILD_SCRIPT_FNAME in ${BUILD_LVL}[0-9][0-9].*.build; do
-		if [ -n "${DEBUG_SCRIPT}" ]\
-		&& [ "x${DEBUG_SCRIPT}" != "x${BUILD_SCRIPT_FNAME}" ]; then
+		if [ -n "${ARG_BUILD_SCRIPTS}" ]\
+		&& [ "${ARG_BUILD_SCRIPTS}" != "ALL" ]\
+		&& ! match_list "${ARG_BUILD_SCRIPTS}"	\
+				, "${BUILD_SCRIPT_FNAME}"; then
+			log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (--build-scripts policy.)";
 			continue;
 		elif [ ! -f ${BUILD_SCRIPT_FNAME} ]; then
+			log_msg info "Build script \`${BUILD_SCRIPT_FNAME}' non-existent or not a file.";
 			continue;
 		else
 			unset BUILD_SCRIPT_RC; : $((BUILD_NBUILT+=1));
-			log_msg info "Invoking build script \`${BUILD_SCRIPT_FNAME}'";
-			(set -o errexit -- $(split . ${BUILD_SCRIPT_FNAME%.build});	\
-			 SCRIPT_FNAME=${BUILD_SCRIPT_FNAME}; _pwd=$(pwd);		\
+			if [ "x${ARG_BUILD_SCRIPTS}" != "xALL" ]\
+			&& is_build_script_done finish "${BUILD_SCRIPT_FNAME%.build}"; then
+				log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (already built.)";
+					: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue;
+			fi;
+			log_msg info "Invoking build script${ARG_BUILD_SCRIPTS:+ (forcibly)} \`${BUILD_SCRIPT_FNAME}'${ARG_BUILD_STEPS:+ at build step(s) ${ARG_BUILD_STEPS}}.";
+			(set -o errexit -- $(split . ${BUILD_SCRIPT_FNAME%%.build*});	\
+			 SCRIPT_FNAME=${BUILD_SCRIPT_FNAME};				\
+			 SCRIPT_NAME=${SCRIPT_FNAME%%.build*};				\
 			 export CFLAGS="$(eval echo \${CFLAGS_LVL${BUILD_LVL}})";	\
 			 export PREFIX_LVL="$(eval echo \${PREFIX_LVL${BUILD_LVL}})";	\
-			 cd ${WORKDIR}; . ${_pwd}/build.subr;				\
-			 [ -f ${_pwd}/${SCRIPT_FNAME%.build}.vars ] &&			\
-			 	. ${_pwd}/${SCRIPT_FNAME%.build}.vars;			\
-			 . ${_pwd}/${BUILD_SCRIPT_FNAME});
+			 _PWD=$(pwd); cd ${WORKDIR};					\
+			 for SCRIPT_SOURCE in build.subr ${SCRIPT_NAME}.vars		\
+					${BUILD_SCRIPT_FNAME}; do			\
+			 	[ -r ${_PWD}/${SCRIPT_SOURCE} ] &&			\
+					 . ${_PWD}/${SCRIPT_SOURCE};			\
+			 done);
 			case ${BUILD_SCRIPT_RC:=${?}} in
 			0) log_msg succ "Finished build script \`${BUILD_SCRIPT_FNAME}'.";
 				: $((BUILD_NFINI+=1)); continue; ;;
-			212) log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (already built.)";
-				: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue; ;;
 			*) log_msg fail "Build failed in build script \`${BUILD_SCRIPT_FNAME}' (last return code ${BUILD_SCRIPT_RC}.).";
 				: $((BUILD_NFAIL+=1)); break; ;;
 			esac;
 		fi;
 	done;
-	if [ ${BUILD_SCRIPT_RC:-0} != 0 ]; then
+	if [ ${BUILD_SCRIPT_RC:-0} -ne 0 ]; then
 		break;
 	fi;
 done;
 log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
 if [ $(( ${BUILD_NFINI} + ${BUILD_NSKIP} )) -ge 0 ]\
-&& [ ${BUILD_NFAIL} -eq 0 ]; then
+&& [ ${BUILD_NFAIL} -eq 0 ]\
+&& [ ${ARG_TARBALL:-0} -eq 1 ]; then
 	log_msg info "Building distribution tarball.";
 	(cd ${PREFIX};
 	DISTRIB_FNAME=midipix.${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE}.tar.bz2;
-	rm_if_exists -m ${PREFIX_NATIVE##*/}/lib.bak; rm_if_exists ${DISTRIB_FNAME};
-	tar -C ${PREFIX_NATIVE##*/}/lib -cpf - . |\
-	tar -C ${PREFIX_NATIVE##*/}/lib.bak -xpf -;
+	PREFIX_BASENAME=${PREFIX_NATIVE##*/}; WORKDIR_BASENAME=${WORKDIR##*/};
+	rm_if_exists -m ${PREFIX_BASENAME}/lib.bak; rm_if_exists ${DISTRIB_FNAME};
+	tar -C ${PREFIX_BASENAME}/lib -cpf - . | tar -C ${PREFIX_BASENAME}/lib.bak -xpf -;
 	(cd native/lib &&
 	 find . -maxdepth 1 -type l				\
-		-exec sh -c 'dest=$(readlink -- "$0") && rm -- "$0" && ln -- "$dest" "$0"' {} \;);
-	wait;
-	find .	-maxdepth 2 -type d				\
-		-not -path .					\
-		-not -path ./${WORKDIR##*/}			\
-		-not -path ./${WORKDIR##*/}/\*			\
-		-not -path ./${PREFIX_NATIVE##*/}		\
-		-not -path ./${PREFIX_NATIVE##*/}/lib.bak	|\
-	tar -T - -cpf - | bzip2 -9c - > ${DISTRIB_FNAME}
-	rm -rf ${PREFIX_NATIVE##*/}/lib;
-	mv ${PREFIX_NATIVE##*/}/lib.bak ${PREFIX_NATIVE##*/}/lib); wait;
+	 	-exec sh -c 'dest=$(readlink -- "$0") && rm -- "$0" && ln -- "$dest" "$0"' {} \;);
+	 wait;
+	 find .	-maxdepth 2 -type d				\
+	 	-not -path .					\
+	 	-not -path ./${WORKDIR_BASENAME}		\
+	 	-not -path ./${WORKDIR_BASENAME}/\*		\
+	 	-not -path ./${PREFIX_BASENAME}			\
+	 	-not -path ./${PREFIX_BASENAME}/lib.bak		|\
+	 tar -T - -cpf - | bzip2 -9c - > ${DISTRIB_FNAME}
+	 rm -rf ${PREFIX_BASENAME}/lib;
+	 mv ${PREFIX_BASENAME}/lib.bak ${PREFIX_BASENAME}/lib); wait;
 fi;
-exit ${BUILD_SCRIPT_RC};
-} 2>&1 | tee build.log;
+exit ${BUILD_SCRIPT_RC})} 2>&1 | tee build.log;
 
 # vim:filetype=sh
diff --git a/build.subr b/build.subr
index 4788283..fc6ee40 100644
--- a/build.subr
+++ b/build.subr
@@ -1,86 +1,149 @@
 #
 # . ./build.vars and set -o errexit are assumed.
+# See warning at the top of build.vars.
 #
 
-TIMESTAMP_FMT="${TIMESTAMP_FMT:-"%Y/%m/%d %H:%M:%S"}";
+date() { command date +"${1:-${TIMESTAMP_FMT}}"; };
+fetch_git() { [ -d ${1} ] && (cd ${1} && git pull origin main) || git clone ${3} ${2} ${1}; };
+get_basename() { set -- $(get_name_without_slash ${1}); echo "${1##*/}"; };
+get_var() { eval echo \${${1}}; }; # XXX
+set_var() { eval ${1}=\"${2}\"; }; # XXX
+get_name_without_slash() { while [ "x${1%/}" != "x${1}" ]; do set -- ${1%/}; done; echo ${1}; };
+get_postfix_lrg() { echo "${1##*${2}}"; };
+get_prefix_lrg() { echo "${1%%${2}*}"; };
+get_postfix() { echo "${1#*${2}}"; };
+get_prefix() { echo "${1%${2}*}"; };
+match_any() { [ "x${1#*${2}*}" != "x${1}" ]; };
+match_start() { [ "x${1#${2}}" != "x${1}" ]; };
+push_IFS() { _IFS="${IFS}"; IFS="${1}"; };
+pop_IFS() { IFS="${_IFS}"; unset _IFS; };
+set_build_dir() { BUILD_DIR=${1}-${2}-${TARGET}; };
+split() { push_IFS "${1}"; set -- ${2}; pop_IFS; echo "${*}"; };
+unsplit() { push_IFS "${1}"; shift; set -- "${@}"; echo "${*}"; pop_IFS; };
 
+
+rm_if_exists() {
+	set_flag_vars_from_args "$@"; shift ${_nshift:-0};
+	[ -d ${1} ] && rm -rf ${1}; [ -f ${1} ] && rm -f ${1};
+	[ ${_arg_m:-0} -eq 1 ] && mkdir ${1};
+	[ ${_arg_c:-0} -eq 1 ] && cd ${1};
+	unset_flag_vars_from_args;
+};
+
+set_flag_vars_from_args() {
+	unset _flag_vars _nshift;
+	while [ ${#} -gt 1 ]; do
+		if [ "x${1%[a-z]}" = "x-" ]; then
+			set_var _arg_${1#-} 1;
+			_flag_vars="${_flag_vars:+${_flag_vars} }_arg_${1#-}";
+			: $((_nshift+=1));
+		fi; shift;
+	done;
+};
+unset_flag_vars_from_args() {
+	set -- ${_flag_vars}; while [ ${#} -gt 0 ]; do
+		unset ${1}; shift; done; unset _flag_vars _nshift;
+};
+
+set_env_vars() {
+	_val_new="${1}"; shift;
+	while [ ${#} -gt 1 ]; do
+		[ -z "${_val_new}" ] && unset ${1} ||\
+			export "${1}=${_val_new}"; shift;
+	done; unset _val_new;
+};
+
+
+# Download GNU bash-style patch sets into ${2}-patches-extra and
+# apply them to ${2} in the correct order.
 apply_patches() {
-	(rm_if_exists -m -c ${2};
+	(rm_if_exists -m -c ${2}-patches-extra;
 	wget -c -nd -np -r -R \*.htm\* -R \*.sig ${1};
-	for _patch_fname in			\
+	for _patch_fname in		\
 			$(find . -type f -not -iname \*.sig | sort); do
-		patch -d ../${PKG_SUBDIR} -p0	\
+		patch -b -d ../${2} -p0	\
 			< ${_patch_fname};
 	done; unset _patch_fname);
 };
 
+# Check whether all supplied arguments contain non-empty valid values.
 check_path_vars() {
-	while [ $# -gt 0 ]; do
-		if [ -z "${_val:=$(eval echo \${${1}})}" ]; then
-			log_msg fail "Error: variable \`${1}' is empty or unset.";
-			exit 1;
-		elif [ "x${_val#* }" != "x${_val}" ]; then
-			log_msg fail "Error: variable \`${1}' contains one or more whitespace characters.";
-			exit 1;
+	while [ ${#} -gt 0 ]; do
+		unset _val;
+		if [ -z "${_val:=$(get_var "${1}")}" ]; then
+			log_msg failexit "Error: variable \`${1}' is empty or unset.";
+		elif match_any "${_val}" " "; then
+			log_msg failexit "Error: variable \`${1}' contains one or more whitespace characters.";
 		else
 			shift;
 		fi;
 	done; unset _val;
 };
 
+# Check whether all supplied command names resolve.
 check_prereqs() {
-	for _cmd in "$@"; do
-		if ! command -v ${_cmd} >/dev/null; then
-			log_msg fail "Error: missing prerequisite command \`${_cmd}.";
-			exit 1;
-		fi;
-	done; unset _cmd;
+	while [ ${#} -gt 0 ]; do
+		if ! command -v ${1} >/dev/null; then
+			log_msg failexit "Error: missing prerequisite command \`${1}'.";
+		fi; shift;
+	done;
 };
 
-date() {
-	command date +"${1:-${TIMESTAMP_FMT}}";
+# Clear the environment by unsetting each exported variable except
+# for those named by the caller. 
+clear_env_with_except() {
+	_vfilter="${*}"; _unset_cmds="$(mktemp -q)";
+	export | while read _vspec; do
+		set -- ${_vspec}; shift;
+		if ! match_list "${_vfilter}" " "	\
+				$(get_prefix_lrg ${1} =); then
+			echo unset $(get_prefix_lrg ${1} =) >> ${_unset_cmds};
+		fi;
+	done; . "${_unset_cmds}"; rm -f "${_unset_cmds}" 2>/dev/null;
+	unset _vfilter _vspec;
 };
 
 fetch() {
-	wget --no-check-certificate -N ${1};
-	if [ $# -eq 2 ] && ! compare_hash ${1##*/} ${2}; then
-		log_msg fail "Error: hash mismatch for URL \`${1##*/}'.";
-		exit 1;
-	fi;
-};
-
-fetch_git() {
-	if [ -d ${1} ]; then
-		(cd ${1} && git pull origin main);
-	else
-		git clone ${2} ${1};
+	wget ${WGET_ARGS} ${1};
+	if [ ${#} -eq 2 ]; then
+		set -- $(get_basename ${1}) "$(compare_hash $(get_basename ${1}) ${2})" ${2};
+		if [ -n "${2}" ]; then
+			log_msg failexit "Error: hash mismatch for URL \`${1}' (is: ${2}, should be: ${3}.)";
+		fi;
 	fi;
 };
 
 compare_hash() {
-	_hash_cmp=${2}; set -- $(openssl dgst -sha256 ${1});
-	shift $((${#}-1)); set -- ${1} ${_hash_cmp}; unset _hash_cmp;
-	[ "x${1}" = "x${2}" ];
+	# Push the output of dgst(1SSL) and the caller-supplied hash
+	# value to compare the former with on the pseudo-stack and
+	# shift off# all but the last two positional parameters.
+	# This corresponds to the hash output and caller-supplied
+	# hash values.
+	set -- $(openssl dgst -sha256 ${1}) ${2}; shift $((${#}-2));
+	[ "x${1}" = "x${2}" ] || echo "${1}";
 };
 compare_hash_manifest() {
-	while [ $# -gt 0 ]; do
+	while [ ${#} -gt 0 ]; do
 		if ! compare_hash ${1} ${2}; then
-			log_msg fail "Error: hash mismatch for patch file \`${1}'.";
-			exit 1;
-		else
-			shift;
-		fi;
+			log_msg failexit "Error: hash mismatch for patch file \`${1}'.";
+		fi; shift;
 	done; return 0;
 };
 
 is_build_script_done() {
-	_script_fname=${SCRIPT_FNAME##*/};
-	if [ -f ${WORKDIR}/.${_script_fname%.build}.${1} ]; then
-		unset script_fname;
-		return 0;
+	if [ -n "${ARG_BUILD_STEPS}" ]; then
+		if [ "${ARG_BUILD_STEPS}" = "finish" ]\
+		|| [ -z "${ARG_BUILD_STEPS#ALL}" ]; then
+			return 1;	# Build
+		elif ! match_list ${ARG_BUILD_STEPS} , ${1}; then
+			return 0;	# Skip
+		else
+			return 1;	# Build
+		fi;
+	elif [ -f ${WORKDIR}/.${2:-$(get_basename ${SCRIPT_FNAME%.build})}.${1} ]; then
+		return 0;		# Skip
 	else
-		unset script_fname;
-		return 1;
+		return 1;		# Build
 	fi;
 };
 set_build_script_done() {
@@ -97,9 +160,25 @@ set_build_script_done() {
 	unset _script_fname _done_fname;
 };
 
+log_env_vars() {
+	log_msg info "Variables for this build:";
+	while [ ${_nvar:=0} -lt ${#} ]; do
+		_arg="$(eval echo \${${_nvar}})"; _arg="${_arg%%=*}";
+		if [ ${#_arg} -gt ${_arg_len_max:=0} ]; then
+			_arg_len_max=${#_arg};
+		fi; : $((_nvar+=1));
+	done; unset _nvar _arg;
+	while [ ${#} -gt 0 ]; do
+		log_msg info "$(printf				\
+			"%${_arg_len_max}.${_arg_len_max}s=%s"	\
+			"${1%%=*}" "$(get_var ${1#*=})")";
+		shift;
+	done; unset _arg_len_max;
+};
 log_msg() {
 	_lvl=${1}; shift;
 	case ${_lvl} in
+		failexit) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
 		fail) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
 		info) printf "\033[${LOG_MSG_INFO_COLOUR}m"; ;;
 		succ) printf "\033[${LOG_MSG_SUCC_COLOUR}m"; ;;
@@ -108,8 +187,38 @@ log_msg() {
 		printf "==> %s %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}" "$*";
 	else
 		printf "==> %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}";
-	fi;
-	unset _lvl;
+	fi; [ ${_lvl} = failexit ] && exit 1 || unset _lvl;
+};
+
+match_list() {
+	_cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS;
+	while [ ${#} -gt 0 ]; do
+		if [ "x${1}" = "x${_cmp}" ]; then
+			unset _cmp; return 0;
+		fi; shift;
+	done; unset _cmp; return 1;
+};
+
+parse_args_into_vars() {
+	_arg0="${1}"; _args_valid="${2}"; shift 2;
+	while [ $# -gt 0 ]; do
+		case "${1}" in
+		--*)	_aname="${1#--}";
+			if ! match_list "${_args_valid}" , "${_aname%%=*}"; then
+				log_msg failexit "Unknown parameter --${_aname%%=*} specified.";
+			elif match_start "${_aname}" "*="; then
+				_aval="$(get_postfix "${_aname}" =)";
+				_aname="$(get_prefix_lrg "${_aname}" =)";
+			else
+				_aval=1;
+			fi;
+			set_var $(echo arg_${_aname} | tr a-z- A-Z_) "${_aval}";
+			shift; ;;
+		*=*)	set_var "$(get_prefix_lrg "${1}" =)"\
+				"$(get_postfix "${1}" =)"; shift; ;;
+		*)	log_msg failexit "Invalid or unknown command line argument \`${1}'."; ;;
+		esac;
+	done; unset _arg0 _args_valid _aname _aval;
 };
 
 parse_with_pkg_name() {
@@ -117,14 +226,9 @@ parse_with_pkg_name() {
 	while [ $# -ge 0 ]; do
 		if [ "x${PKG_NAME}" = "x${1}" ]; then
 			_pkg_NAME=$(echo "${PKG_NAME}" | tr a-z A-Z);
-			for _vname in							\
-					build_type configure_args configure_extra_args	\
-					no_config_cache no_destdir no_libtool_midipix	\
-					patches_extra_url prefix prefix_extra sha256sum	\
-					url version					\
-					CC CFLAGS LDFLAGS; do
+			for _vname in ${PKG_VARS}; do
 				_vNAME=$(echo "${_vname}" | tr a-z A-Z);
-				if [ -n "${_vval:=$(eval echo \${PKG_${_pkg_NAME}_${_vNAME}})}" ]; then
+				if [ -n "${_vval:=$(get_var PKG_${_pkg_NAME}_${_vNAME})}" ]; then
 					export PKG_${_vNAME}="${_vval}";
 					if [ "x${_vname#[A-Z]}" != "x${_vname}" ]; then
 						export ${_vname}="${_vval}";
@@ -136,47 +240,12 @@ parse_with_pkg_name() {
 			if [ -z "${PKG_URL}" ]; then
 				return 1;
 			else
-				PKG_FNAME=${PKG_URL##*/};
-				PKG_SUBDIR=${PKG_FNAME%%.tar*};
+				[ -z "${PKG_FNAME}" ] && PKG_FNAME=${PKG_URL##*/};
+				[ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR=${PKG_FNAME%%.tar*};
 				return 0;
 			fi;
 		fi; shift;
 	done; return 1;
 };
 
-rm_if_exists() {
-	while [ $# -gt 1 ]; do [ "x${1%[a-z]}" = "x-" ] &&\
-		eval _${1#-}flag=1; shift; done;
-	_dir=${1};
-	if [ -d ${1} ]; then
-		rm -rf ${1} || return 1;
-	fi;
-	if [ ${_mflag:-0} -eq 1 ]; then
-		unset _mflag; mkdir ${1} || return 2;
-	fi;
-	if [ ${_cflag:-0} -eq 1 ]; then
-		unset _cflag; cd ${1} || return 3;
-	fi;
-};
-
-set_build_dir() {
-	BUILD_DIR=${1}-${2}-${TARGET};
-};
-
-set_env_vars() {
-	_val=${1}; shift;
-	while [ $# -ge 1 ]; do
-		if [ -z "${_val}" ]; then
-			unset ${1};
-		else
-			export "${1}=${_val}";
-		fi; shift;
-	done; unset _val;
-};
-
-split() {
-	_IFS="${IFS}"; IFS="${1}"; set -- ${2};
-	IFS="${_IFS}"; echo "${*}"; unset _IFS;
-};
-
 # vim:filetype=sh
diff --git a/build.usage b/build.usage
new file mode 100644
index 0000000..19ac8bc
--- /dev/null
+++ b/build.usage
@@ -0,0 +1,22 @@
+usage: ./build.sh
+	[--build-scripts=ALL|fname[,fname...]] [--build-steps=ALL|step[,step...]]
+	[--help] [--tarball] [VAR=VAL...]
+	 --build-scripts=...	Only invoke all or the specified build script(s).
+	 --build-steps=...	Forcibly invoke build scripts at all or only the
+				specified build steps. Currently defined build steps
+				are: fetch extract patch configure clean build install
+				configure1 configure2 build1 build2 install1 install2
+				install3 finish.
+	 --help			Show this screen.
+	 --tarball		Produce a distribution tarball containing $PREFIX
+				sans $WORKDIR at the end of a build with zero failures.
+
+	Packages that are built by pkg.build will apply local patches in $WORKDIR
+	named ${PKG_SUBDIR}.local.patch.
+
+	Examples:
+	./build.sh GITROOT_HEAD=... --build-scripts=204.psxscl.build --build-steps=ALL PKG_PSXSCL_CFLAGS=-DPSX_INTERNAL_STRACE
+	Build psxscl from the internal repository with strace enabled.
+
+	./build.sh GITROOT_HEAD=... --build-scripts=ALL --build-steps=ALL
+	Forcibly rebuild everything.
diff --git a/build.vars b/build.vars
index 2c6fca1..838354d 100644
--- a/build.vars
+++ b/build.vars
@@ -16,28 +16,57 @@
 : ${GITROOT:=git://midipix.org};
 : ${GITROOT_HEAD:=git://midipix.org};
 : ${HOST_NATIVE:=x86_64-nt64-midipix};
+: ${LOG_ENV_VARS:="HOME PATH SHELL USER CFLAGS_LVL0 CFLAGS_LVL1 CFLAGS_LVL2 CFLAGS_LVL3 GITROOT GITROOT_HEAD PREFIX PREFIX_NATIVE PREFIX_TARGET PREFIX_LVL0 PREFIX_LVL1 PREFIX_LVL2 PREFIX_LVL3 WORKDIR MAKEFLAGS"};
 : ${LOG_MSG_FAIL_COLOUR:=91};
 : ${LOG_MSG_INFO_COLOUR:=93};
 : ${LOG_MSG_SUCC_COLOUR:=92};
 : ${PREFIX:=${HOME}/midipix};
 : ${PREFIX_NATIVE:=${PREFIX}/native};
 : ${TARGET:=x86_64-nt64-midipix};
+: ${PKG_VARS:="build_dir build_type configure_args configure_args_extra git_args_extra makeflags_build_extra no_clean no_config_cache no_configure no_destdir no_libtool_midipix no_patch_local patches_extra_url prefix prefix_extra unset_vars_build sha256sum subdir url url_type version AR CC CFLAGS LD LDFLAGS PREFIX RANLIB"};
 : ${PREFIX_TARGET:=${PREFIX}/${TARGET}};
 : ${PREFIX_LVL0:=${PREFIX_TARGET}};
 : ${PREFIX_LVL1:=${PREFIX_NATIVE}};
 : ${PREFIX_LVL2:=${PREFIX_NATIVE}};
 : ${PREFIX_LVL3:=${PREFIX_NATIVE}};
 : ${WORKDIR:=${PREFIX}/tmp};
-MAKEFLAGS="-j8${MAKEFLAGS:+ ${MAKEFLAGS}}";
+: ${MAKEFLAGS:="-j8${MAKEFLAGS:+ ${MAKEFLAGS}}"};
 export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
-TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
+: ${TIMESTAMP_FMT:="%Y/%m/%d %H:%M:%S"};
+: ${WGET_ARGS:="-N --no-check-certificate"};
 
-: ${PKG_BASH_CONFIGURE_EXTRA_ARGS:=--without-bash-malloc};
+: ${PKG_LVL0_CONFIGURE_ARGS:="-C --host=${HOST_NATIVE} --prefix= --target=${TARGET}"};
+: ${PKG_LVL1_CONFIGURE_ARGS="--host=${HOST_NATIVE} --target=${TARGET}"};
+: ${PKG_LVL2_BUILD_TYPE:=cross};
+: ${PKG_LVL2_CONFIGURE_ARGS:="--prefix=${PREFIX_LVL2} --host=${HOST_NATIVE}"};
+: ${PKG_LVL2_NO_CONFIG_CACHE:=1};
+: ${PKG_LVL2_NO_DESTDIR:=1};
+: ${PKG_LVL2_NO_EXTRACT:=1};
+: ${PKG_LVL2_URL_TYPE:=git};
+: ${PKG_LVL2_UNSET_VAR_BUILD:="CC LD CFLAGS LDFLAGS PREFIX"};
+: ${PKG_LVL2_CFLAGS_PATH:=-I${PREFIX_LVL2}/include};
+: ${PKG_LVL2_LDFLAGS_PATH:=-L${PREFIX_LVL2}/include};
+: ${PKG_LVL3_CONFIGURE_ARGS:="-C --host=${HOST_NATIVE} --prefix= --target=${TARGET}"};
+
+: ${PKG_BZIP2_AR:=${HOST_NATIVE}-ar};
+: ${PKG_BZIP2_CC:=${HOST_NATIVE}-gcc};
+: ${PKG_BZIP2_RANLIB:=${HOST_NATIVE}-ranlib};
+: ${PKG_BZIP2_MAKEFLAGS_BUILD_EXTRA:=-f Makefile-libbz2_so};
+: ${PKG_BZIP2_NO_CLEAN:=1};
+: ${PKG_BZIP2_NO_CONFIGURE:=1};
+: ${PKG_BZIP2_NO_DESTDIR:=1};
+: ${PKG_BZIP2_PREFIX:=${PREFIX_LVL3}};
+: ${PKG_BZIP2_SHA256SUM:=a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd};
+: ${PKG_BZIP2_VERSION:=1.0.6};
+: ${PKG_BZIP2_BUILD_DIR=bzip2-${PKG_BZIP2_VERSION}};
+: ${PKG_BZIP2_URL:=http://www.bzip.org/1.0.6/bzip2-${PKG_BZIP2_VERSION}.tar.gz};
+: ${PKG_BASH_CONFIGURE_ARGS_EXTRA:=--without-bash-malloc};
+: ${PKG_BASH_LDFLAGS:=-L${PREFIX_LVL3}/lib};
 : ${PKG_BASH_SHA256SUM:=afc687a28e0e24dc21b988fa159ff9dbcf6b7caa92ade8645cc6d5605cd024d4};
 : ${PKG_BASH_VERSION:=4.3};
 : ${PKG_BASH_PATCHES_EXTRA_URL:=https://ftp.gnu.org/gnu/bash/bash-${PKG_BASH_VERSION}-patches/};
 : ${PKG_BASH_URL:=https://ftp.gnu.org/gnu/bash/bash-${PKG_BASH_VERSION}.tar.gz};
-: ${PKG_BINUTILS_CONFIGURE_EXTRA_ARGS:=--with-libelf=${PREFIX_NATIVE} --with-gmp=${PREFIX_NATIVE} --with-mpc=${PREFIX_NATIVE} --with-mpfr=${PREFIX_NATIVE} --with-sysroot=/};
+: ${PKG_BINUTILS_CONFIGURE_ARGS_EXTRA:=--with-libelf=${PREFIX_NATIVE} --with-gmp=${PREFIX_NATIVE} --with-mpc=${PREFIX_NATIVE} --with-mpfr=${PREFIX_NATIVE} --with-sysroot=/};
 : ${PKG_BINUTILS_SHA256SUM:=250d3b2925c6b211fb16173b0b25bc091c58829fbcad3eb849645e0af52cf7fa};
 : ${PKG_BINUTILS_VERSION:=2.24.51};
 : ${PKG_BINUTILS_URL:=ftp://sourceware.org/pub/binutils/snapshots/binutils-${PKG_BINUTILS_VERSION}.tar.bz2};
@@ -52,6 +81,8 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
 : ${PKG_COREUTILS_SHA256SUM:=ec43ca5bcfc62242accb46b7f121f6b684ee21ecd7d075059bf650ff9e37b82d};
 : ${PKG_COREUTILS_VERSION:=8.23};
 : ${PKG_COREUTILS_URL:=https://ftp.gnu.org/gnu/coreutils/coreutils-${PKG_COREUTILS_VERSION}.tar.xz};
+: ${PKG_DASH_VERSION:=0.5.8};
+: ${PKG_DASH_URL:=http://gondor.apana.org.au/~herbert/dash/files/dash-${PKG_DASH_VERSION}.tar.gz};
 : ${PKG_DIFFUTILS_SHA256SUM:=a25e89a8ab65fded1731e4186be1bb25cda967834b6df973599cdcd5abdfc19c};
 : ${PKG_DIFFUTILS_VERSION:=3.3};
 : ${PKG_DIFFUTILS_URL:=https://ftp.gnu.org/gnu/diffutils/diffutils-${PKG_DIFFUTILS_VERSION}.tar.xz};
@@ -63,7 +94,13 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
 : ${PKG_GAWK_VERSION:=4.1.3};
 : ${PKG_GAWK_URL:=https://ftp.gnu.org/gnu/gawk/gawk-${PKG_GAWK_VERSION}.tar.xz};
 : ${PKG_GCC_VERSION:=4.6.4};
-: ${PKG_GMP_CONFIGURE_EXTRA_ARGS:=--disable-assembly};
+: ${PKG_GIT_SUBDIR:=git};
+: ${PKG_GIT_BUILD_DIR=${PKG_GIT_SUBDIR}};
+: ${PKG_GIT_GIT_ARGS_EXTRA:=--branch v2.7.1};
+: ${PKG_GIT_NO_CONFIGURE:=1};
+: ${PKG_GIT_URL:=https://github.com/git/git.git};
+: ${PKG_GIT_URL_TYPE:=git};
+: ${PKG_GMP_CONFIGURE_ARGS_EXTRA:=--disable-assembly};
 : ${PKG_GMP_PREFIX_EXTRA:=${PREFIX_TARGET}};
 : ${PKG_GMP_SHA256SUM:=752079520b4690531171d0f4532e40f08600215feefede70b24fabdc6f1ab160};
 : ${PKG_GMP_VERSION:=5.1.3};
@@ -72,11 +109,16 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
 : ${PKG_GREP_VERSION:=2.22};
 : ${PKG_GREP_URL:=https://ftp.gnu.org/gnu/grep/grep-${PKG_GREP_VERSION}.tar.xz};
 : ${PKG_GZIP_CC:=${HOST_NATIVE}-gcc};
-: ${PKG_GZIP_CFLAGS:="-g3 -O0 -I${PREFIX_NATIVE}/include"};
+: ${PKG_GZIP_CFLAGS:=-g3 -O0 -I${PREFIX_NATIVE}/include};
 : ${PKG_GZIP_LDFLAGS:=--sysroot=${PREFIX_NATIVE}};
+: ${PKG_GZIP_PKG_CONFIGURE_ARGS:=--host=${HOST_NATIVE} --prefix= --target=${TARGET}};
 : ${PKG_GZIP_SHA256SUM:=1ca41818a23c9c59ef1d5e1d00c0d5eaa2285d931c0fb059637d7c0cc02ad967};
 : ${PKG_GZIP_VERSION:=1.2.4};
 : ${PKG_GZIP_URL:=https://ftp.gnu.org/gnu/gzip/gzip-${PKG_GZIP_VERSION}.tar.gz};
+: ${PKG_LESS_LDFLAGS:=-L${PREFIX_LVL3}/lib};
+: ${PKG_LESS_SHA256SUM:=3fa38f2cf5e9e040bb44fffaa6c76a84506e379e47f5a04686ab78102090dda5};
+: ${PKG_LESS_VERSION:=481};
+: ${PKG_LESS_URL:=http://www.greenwoodsoftware.com/less/less-${PKG_LESS_VERSION}.tar.gz};
 : ${PKG_LIBELF_CC:=${HOST_NATIVE}-gcc};
 : ${PKG_LIBELF_NO_DESTDIR:=1};
 : ${PKG_LIBELF_NO_LIBTOOL_MIDIPIX:=1};
@@ -84,18 +126,19 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
 : ${PKG_LIBELF_SHA256SUM:=591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d};
 : ${PKG_LIBELF_VERSION:=0.8.13};
 : ${PKG_LIBELF_URL:=http://www.mr511.de/software/libelf-${PKG_LIBELF_VERSION}.tar.gz};
+: ${PKG_LIBZ_CONFIGURE_ARGS:=--host=${HOST_NATIVE} --prefix= --target=${TARGET}};
 : ${PKG_LIBZ_SHA256SUM:=33e65f22ec3d3e3f87436e53f82eb114054cd3aa373dc0480625dd92806fd9a0};
 : ${PKG_LIBZ_VERSION:=1.2.8.2015.05.20};
 : ${PKG_LIBZ_URL:=https://sortix.org/libz/release/libz-${PKG_LIBZ_VERSION}.tar.gz};
 : ${PKG_MAKE_SHA256SUM:=f3e69023771e23908f5d5592954d8271d3d6af09693cecfd29cee6fde8550dc8};
 : ${PKG_MAKE_VERSION:=3.81};
 : ${PKG_MAKE_URL:=https://ftp.gnu.org/gnu/make/make-${PKG_MAKE_VERSION}.tar.bz2};
-: ${PKG_MPC_CONFIGURE_EXTRA_ARGS:=--with-gmp=${PREFIX_NATIVE} --with-mpfr=${PREFIX_NATIVE}};
+: ${PKG_MPC_CONFIGURE_ARGS_EXTRA:=--with-gmp=${PREFIX_NATIVE} --with-mpfr=${PREFIX_NATIVE}};
 : ${PKG_MPC_PREFIX_EXTRA:=${PREFIX_TARGET}};
 : ${PKG_MPC_SHA256SUM:=ed5a815cfea525dc778df0cb37468b9c1b554aaf30d9328b1431ca705b7400ff};
 : ${PKG_MPC_VERSION:=1.0.1};
 : ${PKG_MPC_URL:=ftp://ftp.gnu.org/gnu/mpc/mpc-${PKG_MPC_VERSION}.tar.gz};
-: ${PKG_MPFR_CONFIGURE_EXTRA_ARGS:=--with-gmp=${PREFIX_NATIVE}};
+: ${PKG_MPFR_CONFIGURE_ARGS_EXTRA:=--with-gmp=${PREFIX_NATIVE}};
 : ${PKG_MPFR_PREFIX_EXTRA:=${PREFIX_TARGET}};
 : ${PKG_MPFR_SHA256SUM:=79c73f60af010a30a5c27a955a1d2d01ba095b72537dab0ecaad57f5a7bb1b6b};
 : ${PKG_MPFR_VERSION:=3.1.2};
@@ -103,12 +146,35 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
 : ${PKG_MUSL_SHA256SUM:=720b83c7e276b4b679c0bffe9509340d5f81fd601508e607e708177df0d31c0e};
 : ${PKG_MUSL_VERSION:=1.1.12};
 : ${PKG_MUSL_URL:=http://www.musl-libc.org/releases/musl-${PKG_MUSL_VERSION}.tar.gz};
+: ${PKG_NCURSES_SHA256SUM=f551c24b30ce8bfb6e96d9f59b42fbea30fa3a6123384172f9e7284bcf647260};
+: ${PKG_NCURSES_VERSION=6.0};
+: ${PKG_NCURSES_URL:=https://ftp.gnu.org/gnu/ncurses/ncurses-${PKG_NCURSES_VERSION}.tar.gz};
 : ${PKG_PATCH_SHA256SUM:=59c29f56faa0a924827e6a60c6accd6e2900eae5c6aaa922268c717f06a62048};
 : ${PKG_PATCH_VERSION:=2.7};
 : ${PKG_PATCH_URL:=https://ftp.gnu.org/gnu/patch/patch-${PKG_PATCH_VERSION}.tar.gz};
+: ${PKG_POPT_SHA256SUM:=e728ed296fe9f069a0e005003c3d6b2dde3d9cad453422a10d6558616d304cc8};
+: ${PKG_POPT_VERSION:=1.16};
+: ${PKG_POPT_URL:=http://rpm5.org/files/popt/popt-${PKG_POPT_VERSION}.tar.gz};
+: ${PKG_RSYNC_CFLAGS=-I${PREFIX_LVL3}/include};
+: ${PKG_RSYNC_CONFIGURE_ARGS_EXTRA=--with-included-zlib};
+: ${PKG_RSYNC_LDFLAGS=-L${PREFIX_LVL3}/lib};
+: ${PKG_RSYNC_VERSION:=3.1.2};
+: ${PKG_RSYNC_URL:=https://download.samba.org/pub/rsync/src/rsync-${PKG_RSYNC_VERSION}.tar.gz};
+: ${PKG_TAR_SHA256SUM:=6a6b65bac00a127a508533c604d5bf1a3d40f82707d56f20cefd38a05e8237de};
+: ${PKG_TAR_VERSION:=1.28};
+: ${PKG_TAR_URL:=https://ftp.gnu.org/gnu/tar/tar-${PKG_TAR_VERSION}.tar.gz};
 : ${PKG_SED_SHA256SUM:=f048d1838da284c8bc9753e4506b85a1e0cc1ea8999d36f6995bcb9460cddbd7};
 : ${PKG_SED_VERSION:=4.2.2};
 : ${PKG_SED_URL:=https://ftp.gnu.org/gnu/sed/sed-${PKG_SED_VERSION}.tar.bz2};
+: ${PKG_UTIL_LINUX_CONFIGURE_ARGS_EXTRA:=--disable-agetty --disable-wall --disable-write};
+: ${PKG_UTIL_LINUX_SHA256SUM:=133c14f625d40e90e73e9d200faf3f2ce87937b99f923c84e5504ac0badc71d6};
+: ${PKG_UTIL_LINUX_VERSION:=2.27.1};
+: ${PKG_UTIL_LINUX_URL:=https://www.kernel.org/pub/linux/utils/util-linux/v2.27/util-linux-${PKG_UTIL_LINUX_VERSION}.tar.gz};
+: ${PKG_WHICH_SHA256SUM:=f4a245b94124b377d8b49646bf421f9155d36aa7614b6ebf83705d3ffc76eaad};
+: ${PKG_WHICH_VERSION:=2.21};
+: ${PKG_WHICH_URL:=https://ftp.gnu.org/gnu/which/which-${PKG_WHICH_VERSION}.tar.gz};
+: ${PKG_XZ_VERSION:=5.2.2};
+: ${PKG_XZ_URL:=http://tukaani.org/xz/xz-${PKG_XZ_VERSION}.tar.gz};
 
 : ${PKG_DALIST_URL:=${GITROOT_HEAD}/dalist};
 : ${PKG_NTAPI_URL:=${GITROOT_HEAD}/ntapi};
@@ -116,6 +182,8 @@ TIMESTAMP_FMT="%Y/%m/%d %H:%M:%S";
 : ${PKG_NTCTTY_URL:=${GITROOT_HEAD}/ntctty};
 : ${PKG_PEMAGINE_URL:=${GITROOT_HEAD}/pemagine};
 : ${PKG_PSXSCL_URL:=${GITROOT_HEAD}/psxscl};
+: ${PKG_PSXSTUB_URL:=${GITROOT}/psxstub};
+: ${PKG_PSXSTUB_URL_TYPE:=git};
 : ${PKG_PSXTYPES_URL:=${GITROOT_HEAD}/psxtypes};
 
 # vim:filetype=sh
diff --git a/ncurses-6.0.local.patch b/ncurses-6.0.local.patch
new file mode 100644
index 0000000..2927fba
--- /dev/null
+++ b/ncurses-6.0.local.patch
@@ -0,0 +1,21 @@
+--- ncurses-6.0/config.sub.orig	2015-05-02 13:52:04.000000000 +0200
++++ ncurses-6.0/config.sub	2016-02-12 13:01:38.765370000 +0100
+@@ -807,6 +807,9 @@
+ 	microblaze*)
+ 		basic_machine=microblaze-xilinx
+ 		;;
++	midipix)
++		os=-midipix
++		;;
+ 	mingw64)
+ 		basic_machine=x86_64-pc
+ 		os=-mingw64
+@@ -1387,7 +1390,7 @@
+ 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ 	      | -chorusos* | -chorusrdb* | -cegcc* \
+ 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+-	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
++	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
+ 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
diff --git a/ntapi.local.patch b/ntapi.local.patch
new file mode 100644
index 0000000..d69de09
--- /dev/null
+++ b/ntapi.local.patch
@@ -0,0 +1,67 @@
+diff --git a/include/ntapi/nt_mount.h b/include/ntapi/nt_mount.h
+index 8a7258a..cf2deac 100644
+--- a/include/ntapi/nt_mount.h
++++ b/include/ntapi/nt_mount.h
+@@ -10,6 +10,10 @@
+ #define __DEVICE_PATH_PREFIX_LEN	(8 * sizeof(wchar16_t))
+ #define __DEVICE_PATH_PREFIX_HASH	(0xDA6FA40B)
+ 
++/* {'\\','D','e','v','i','c','e','\\',M','u','p','\\'} */
++#define __DEVICE_MUP_PATH_PREFIX_LEN	(12 * sizeof(wchar16_t))
++#define __DEVICE_MUP_PATH_PREFIX_HASH	(0x0CEBB5F6)
++
+ /* {'\\','?','?','\\','V','o','l','u','m','e','{'} */
+ #define __VOLUME_PATH_PREFIX_LEN	(11 * sizeof(wchar16_t))
+ #define __VOLUME_PATH_PREFIX_HASH	(0xFEBA8529)
+diff --git a/src/fs/ntapi_tt_statfs.c b/src/fs/ntapi_tt_statfs.c
+index 114cc8e..8bc43e2 100644
+--- a/src/fs/ntapi_tt_statfs.c
++++ b/src/fs/ntapi_tt_statfs.c
+@@ -23,7 +23,7 @@ int32_t __stdcall __ntapi_tt_statfs(
+ 	nt_oa			oa;
+ 	nt_iosb			iosb;
+ 	nt_unicode_string *	sdev;
+-	uint32_t		hash;
++	uint32_t		hash,hash_mup;
+ 	wchar16_t *		wch;
+ 	wchar16_t *		wch_mark;
+ 	uint32_t		offset;
+@@ -156,6 +156,14 @@ int32_t __stdcall __ntapi_tt_statfs(
+ 	if (hash != __DEVICE_PATH_PREFIX_HASH)
+ 		return NT_STATUS_INVALID_HANDLE;
+ 
++	hash_mup = __ntapi->tt_buffer_crc32(
++			0,
++			sdev->buffer,
++			__DEVICE_MUP_PATH_PREFIX_LEN);
++
++	if (hash_mup == __DEVICE_MUP_PATH_PREFIX_HASH)
++		sdev->buffer[__DEVICE_MUP_PATH_PREFIX_LEN - 1] = 0;
++
+ 	wch_mark = sdev->buffer + __DEVICE_PATH_PREFIX_LEN/sizeof(wchar16_t);
+ 	wch = wch_mark;
+ 	while (*wch != '\\') wch++;
+@@ -190,6 +198,9 @@ int32_t __stdcall __ntapi_tt_statfs(
+ 	statfs->nt_control_flags = 0;
+ 	statfs->nt_padding = 0;
+ 
++	if (hash_mup == __DEVICE_MUP_PATH_PREFIX_HASH)
++		return NT_STATUS_SUCCESS;
++
+ 	if (!(flags & NT_STATFS_VOLUME_GUID)) {
+ 		statfs->nt_drive_letter = 0;
+ 		pguid = (uint64_t *)&(statfs->nt_volume_guid);
+diff --git a/src/fs/ntapi_tt_open_physical_parent_directory.c b/src/fs/ntapi_tt_open_physical_parent_directory.c
+index 68d282b..742607d 100644
+--- a/src/fs/ntapi_tt_open_physical_parent_directory.c
++++ b/src/fs/ntapi_tt_open_physical_parent_directory.c
+@@ -37,6 +37,9 @@ int32_t __stdcall __ntapi_tt_open_physical_parent_directory(
+ 		return NT_STATUS_BAD_FILE_TYPE;
+ 
+ 	wch = path->buffer + (path->strlen / sizeof(uint16_t));
++	if ((&wch[-1] >= path->buffer) && (wch[-1] == '\\') &&
++			(&wch[-2] >= path->buffer))
++		wch = &wch[-1];
+ 	while ((--wch >= path->buffer) && (*wch != '\\'));
+ 
+ 	if (wch == path->buffer )
diff --git a/pkg.build b/pkg.build
index 39dc8d6..997da3d 100644
--- a/pkg.build
+++ b/pkg.build
@@ -1,86 +1,137 @@
-# Order for build level 2 (runtime:) psxtypes pemagine dalist ntapi psxscl ntcon ntctty
+#
+# . ./build.vars and set -o errexit are assumed.
+#
 
-parse_with_pkg_name ${2}				\
-	bash binutils binutils_host coreutils dalist	\
-	diffutils findutils gawk gmp grep libelf make	\
-	mpc mpfr ntapi ntcon ntctty patch pemagine	\
-	psxscl psxtypes sed;
-if is_build_script_done finished; then
-        exit 212;
-else
-	case "${SCRIPT_FNAME%[0-9][0-9]*}" in
-	1)	_configure_args="--host=${HOST_NATIVE} --prefix=${PKG_PREFIX:-/} --target=${TARGET}";
-		PKG_NO_CONFIG_CACHE=1; ;;
-	2)
-		_configure_args="--prefix=${PREFIX_LVL} --host=${HOST_NATIVE}";
-		PKG_BUILD_TYPE=cross; PKG_URL_TYPE=git;
-		PKG_NO_CONFIG_CACHE=${PKG_NO_DESTDIR:=${PKG_NO_EXTRACT:=${PKG_NO_PATCH:=1}}};
-		export CFLAGS_PATH=-I${PREFIX_LVL}/include;
-		export LDFLAGS_PATH=-L${PREFIX_LVL}/lib; ;;
-	*)	_configure_args=${PKG_CONFIGURE_ARGS:--C --host=${HOST_NATIVE} --prefix= --target=${TARGET}}; ;;
-	esac;
+# Order for build level 2 (runtime:) psxtypes pemagine dalist ntapi psxscl ntcon ntctty
+parse_with_pkg_name ${2}					\
+	bash binutils binutils_host bzip2 coreutils		\
+	dalist dash diffutils findutils gawk gmp		\
+	grep gzip less libelf libz make mpc mpfr ncurses	\
+	ntapi ntcon ntctty patch pemagine popt psxscl		\
+	psxstub	psxtypes rsync sed tar util_linux which xz;
+case "${SCRIPT_FNAME%[0-9][0-9]*}" in
+1)	_configure_args="--host=${HOST_NATIVE} --prefix=${PKG_PREFIX:-/} --target=${TARGET}";
+	PKG_NO_CONFIG_CACHE=1; ;;
+2)
+	_configure_args="--prefix=${PREFIX_LVL} --host=${HOST_NATIVE}";
+	PKG_BUILD_TYPE=cross; PKG_URL_TYPE=git;
+	PKG_NO_CONFIG_CACHE=${PKG_NO_DESTDIR:=${PKG_NO_EXTRACT:=1}};
+	PKG_UNSET_VARS_BUILD="CC LD CFLAGS LDFLAGS PREFIX";
+	export CFLAGS_PATH=-I${PREFIX_LVL}/include;
+	export LDFLAGS_PATH=-L${PREFIX_LVL}/lib;
+	;;
+*)	_configure_args=${PKG_CONFIGURE_ARGS:--C --host=${HOST_NATIVE} --prefix= --target=${TARGET}}; ;;
+esac;
+if ! is_build_script_done fetch; then
 	if [ "x${PKG_URL_TYPE:-wget}" = "xwget" ]; then
+		rm_if_exists $(get_basename ${PKG_URL});
 		fetch ${PKG_URL} ${PKG_SHA256SUM};
 	else
-		fetch_git ${PKG_SUBDIR} ${PKG_URL};
+		rm_if_exists ${PKG_SUBDIR};
+		fetch_git ${PKG_SUBDIR} ${PKG_URL} "${PKG_GIT_ARGS_EXTRA}";
+		PKG_NO_EXTRACT=1;
 	fi;
-	set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native};
+	set_build_script_done fetch -extract;
+else
+	[ "x${PKG_URL_TYPE:-wget}" = "xwget" ] || PKG_NO_EXTRACT=1;
 fi;
 if command -v pkg_${PKG_NAME}_finish >/dev/null; then
 	pkg_${PKG_NAME}_finish; exit 0;
 elif [ ${PKG_NO_EXTRACT:-0} -eq 0 ] &&\
-! is_build_script_done extracted; then
+! is_build_script_done extract; then
 	rm_if_exists ${PKG_SUBDIR};
 	tar -axf ${PKG_FNAME};
-	set_build_script_done extracted -patched;
+	set_build_script_done extract -build_dir;
 fi;
-if [ ${PKG_NO_PATCH:-0} -eq 0 ] &&\
-! is_build_script_done patched; then
+if [ -n "${PKG_BUILD_DIR}" ]; then
+	BUILD_DIR=${PKG_BUILD_DIR};
+else
+	set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native};
+fi;
+if ! is_build_script_done build_dir; then
+	[ ${PKG_SUBDIR} != ${BUILD_DIR} ] &&\
+		rm_if_exists -m ${BUILD_DIR};
+	set_build_script_done build_dir -patch;
+fi;
+if ! is_build_script_done patch; then
+	[ -f portage/${PKG_SUBDIR}.midipix.patch ] &&		\
+		patch -b -d ${PKG_SUBDIR} -p1			\
+			< portage/${PKG_SUBDIR}.midipix.patch;
+	[ ${PKG_NO_PATCH_LOCAL:-0} -eq 0 ] &&			\
+	[ -f ${_PWD}/${PKG_SUBDIR}.local.patch ] &&		\
+		patch -b -d ${PKG_SUBDIR} -p1			\
+			< ${_PWD}/${PKG_SUBDIR}.local.patch;
 	if [ -n "${PKG_PATCHES_EXTRA_URL}" ]; then
-		apply_patches ${PKG_PATCHES_EXTRA_URL} ${PKG_SUBDIR}-patches-extra;
+		apply_patches ${PKG_PATCHES_EXTRA_URL} ${PKG_SUBDIR};
 		if [ -n "${PKG_PATCHES_EXTRA_MANIFEST}" ]; then
 			compare_hash_manifest ${PKG_PATCHES_EXTRA_MANIFEST};
 		fi;
 	fi;
-	patch -d ${PKG_SUBDIR} -p1			\
-		< portage/${PKG_SUBDIR}.midipix.patch;
 	[ ${PKG_NO_CONFIG_CACHE:-0} -eq 0 ] &&\
-		cp portage/config.cache ${PKG_SUBDIR}/;
-	[ ${PKG_NO_LIBTOOL_MIDIPIX:-0} -eq 0 ] &&	\
+		cp portage/config.cache ${BUILD_DIR}/;
+	[ ${PKG_NO_LIBTOOL_MIDIPIX:-0} -eq 0 ] &&		\
 		cp portage/libtool.midipix ${PKG_SUBDIR}/;
-	set_build_script_done patched -configured;
+	set_build_script_done patch -configure;
 fi;
-if ! is_build_script_done configured; then
-	rm_if_exists -m -c ${BUILD_DIR};
-	../${PKG_SUBDIR}/configure			\
-		${_configure_args}			\
-		${PKG_CONFIGURE_EXTRA_ARGS};
-	set_build_script_done configured -built;
+cd ${BUILD_DIR};
+if [ ${PKG_NO_CONFIGURE:-0} -eq 0 ]\
+&& ! is_build_script_done configure; then
+	../${PKG_SUBDIR}/configure				\
+		${_configure_args}				\
+		${PKG_CONFIGURE_ARGS_EXTRA};
+	set_build_script_done configure clean -build;
 else
-	cd ${BUILD_DIR};
+	set_build_script_done clean;
 fi;
-if ! is_build_script_done built; then
-	make ${MAKEFLAGS};
-	set_build_script_done built -installed1;
+if [ ${PKG_NO_CLEAN:-0} -eq 0 ]\
+&& ! is_build_script_done clean; then
+	make ${MAKEFLAGS} clean;
+	set_build_script_done clean -build;
+fi;
+if ! is_build_script_done build; then
+	if [ -n "${PKG_UNSET_VARS_BUILD}" ]; then
+		unset ${PKG_UNSET_VARS_BUILD}
+	fi;
+	make	${PKG_MAKEFLAGS_BUILD_EXTRA:+${PKG_MAKEFLAGS_BUILD_EXTRA}}\
+		${MAKEFLAGS}					\
+		${AR:+AR=${AR}}					\
+		${CC:+CC=${CC}} ${CFLAGS:+"CFLAGS=${CFLAGS}"}	\
+		${LD:+LD=${LD}} ${LDFLAGS:+"LDFLAGS=${LDFLAGS}"}\
+		${RANLIB:+RANLIB=${RANLIB}};
+	set_build_script_done build -install1;
 fi;
-if ! is_build_script_done installed1; then
-	if [ ${PKG_NO_DESTDIR:-0} -eq 0 ]; then
-		make ${MAKEFLAGS} DESTDIR=${PREFIX_LVL} install;
+if ! is_build_script_done install1; then
+	if command -v pkg_${PKG_NAME}_install >/dev/null; then
+		pkg_${PKG_NAME}_install;
+	elif [ ${PKG_NO_DESTDIR:-0} -eq 0 ]; then
+		make	${PKG_MAKEFLAGS_INSTALL_EXTRA:+${PKG_MAKEFLAGS_BUILD_EXTRA}}\
+			${MAKEFLAGS}					\
+			${AR:+AR=${AR}}					\
+			${CC:+CC=${CC}} ${CFLAGS:+"CFLAGS=${CFLAGS}"}	\
+			${LD:+LD=${LD}} ${LDFLAGS:+"LDFLAGS=${LDFLAGS}"}\
+			${RANLIB:+RANLIB=${RANLIB}}			\
+			DESTDIR=${PREFIX_LVL} install;
 	else
-		make ${MAKEFLAGS} install;
+		make	${PKG_MAKEFLAGS_INSTALL_EXTRA:+${PKG_MAKEFLAGS_BUILD_EXTRA}}\
+			${MAKEFLAGS}					\
+			${AR:+AR=${AR}}					\
+			${CC:+CC=${CC}} ${CFLAGS:+"CFLAGS=${CFLAGS}"}	\
+			${LD:+LD=${LD}} ${LDFLAGS:+"LDFLAGS=${LDFLAGS}"}\
+			${PREFIX:+PREFIX=${PREFIX}}			\
+			${RANLIB:+RANLIB=${RANLIB}} install;
 	fi;
-	set_build_script_done installed1 -installed2 -finished;
+	set_build_script_done install1 -install2 -finish;
 fi;
-if ! is_build_script_done installed2; then
-	[ -n "${PKG_PREFIX_EXTRA}" ] &&\
+if [ -n "${PKG_PREFIX_EXTRA}" ]\
+&& ! is_build_script_done install2; then
 		make DESTDIR=${PKG_PREFIX_EXTRA} install;
-	set_build_script_done installed2 -installed3 -finished;
+	set_build_script_done install2 -install3 -finish;
 fi;
-if ! is_build_script_done installed3; then
-	command -v pkg_${PKG_NAME}_install_post		\
-		>/dev/null && pkg_${PKG_NAME}_install_post;
-	set_build_script_done installed3 -finished;
+if command -v pkg_${PKG_NAME}_install_post >/dev/null\
+&& ! is_build_script_done install3; then
+	pkg_${PKG_NAME}_install_post;
+	set_build_script_done install3 -finish;
 fi;
-set_build_script_done finished;
+set_build_script_done finish;
 
 # vim:filetype=sh
diff --git a/popt-1.16.local.patch b/popt-1.16.local.patch
new file mode 100644
index 0000000..8ccca2c
--- /dev/null
+++ b/popt-1.16.local.patch
@@ -0,0 +1,21 @@
+--- popt-1.16/config.sub.orig	2010-04-26 14:16:44.000000000 +0200
++++ popt-1.16/config.sub	2016-02-12 15:51:37.738535300 +0100
+@@ -735,6 +735,9 @@
+         microblaze)
+ 		basic_machine=microblaze-xilinx
+ 		;;
++	midipix)
++		os=-midipix
++		;;
+ 	mingw32)
+ 		basic_machine=i386-pc
+ 		os=-mingw32
+@@ -1294,7 +1297,7 @@
+ 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ 	      | -chorusos* | -chorusrdb* | -cegcc* \
+ 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+-	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++	      | -midipix* | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ 	      | -uxpv* | -beos* | -mpeix* | -udk* \
+ 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
diff --git a/psxscl.local.patch b/psxscl.local.patch
new file mode 100644
index 0000000..72a40bd
--- /dev/null
+++ b/psxscl.local.patch
@@ -0,0 +1,150 @@
+diff --git a/src/init/psx_init_cwd.c b/src/init/psx_init_cwd.c
+index 924b1b8..02846ba 100644
+--- a/src/init/psx_init_cwd.c
++++ b/src/init/psx_init_cwd.c
+@@ -17,7 +17,7 @@
+ #ifndef __PSX_DEFAULT_ROOT_DIRECTORY
+ #define __PSX_DEFAULT_ROOT_DIRECTORY { \
+ 				'\\','?','?','\\', \
+-				'C',':','\\','m','i','d','i','p','i','x'}
++				'Z',':','\\'}
+ #endif
+ 
+ int32_t __psx_init_cwd(void)
+diff --git a/src/iofn/psx_iofn_fsdir.c b/src/iofn/psx_iofn_fsdir.c
+index 53b3380..8bdd7d8 100644
+--- a/src/iofn/psx_iofn_fsdir.c
++++ b/src/iofn/psx_iofn_fsdir.c
+@@ -52,10 +52,34 @@ static int32_t __fastcall __psx_iofn_fsdir_open_next(
+ 		path.buffer++;
+ 	}
+ 
++	/* XXX */
++	uint32_t		status;
++	static char		name_buffer[1024];
++	nt_unicode_string *	dev_name,full_path;
++	
++	iosb.info = 0;
++	if ((status = __ntapi->zw_query_object(
++			path_info->hat,NT_OBJECT_NAME_INFORMATION,
++			name_buffer,sizeof(name_buffer),(uint32_t *)&iosb.info)))
++		return status;
++	else {
++		dev_name = (nt_unicode_string *)name_buffer;
++		if ((dev_name->strlen > 2) && 
++			(dev_name->buffer[(dev_name->strlen - 1) / 2] != '\\')) {
++			dev_name->buffer[dev_name->strlen / 2] = '\\';
++			dev_name->strlen += 2;
++		}
++		__ntapi->tt_generic_memcpy(&dev_name->buffer[dev_name->strlen / 2],
++			path.buffer,path.strlen);
++		dev_name->strlen += path.strlen;
++		full_path.maxlen = (full_path.strlen = dev_name->strlen) + 2;
++		full_path.buffer = dev_name->buffer;
++	}
++
+ 	/* oa */
+ 	oa.len = sizeof(nt_oa);
+-	oa.root_dir = path_info->hat;
+-	oa.obj_name = &path;
++	oa.root_dir = 0;
++	oa.obj_name = &full_path;
+ 	oa.obj_attr = path_info->ntobjattr;
+ 	oa.sec_desc = 0;
+ 	oa.sec_qos  = 0;
+@@ -73,6 +97,45 @@ static int32_t __fastcall __psx_iofn_fsdir_open_next(
+ 		0,0);
+ }
+ 
++static int32_t __stdcall __psx_iofn_fsdir_open_parent_directory(
++	void **		hparent,
++	void *		hdir,
++	uintptr_t *	buffer,
++	uint32_t	buffer_size,
++	uint32_t	desired_access,
++	uint32_t	open_options,
++	int32_t *	type)
++{
++	uint32_t			status;
++	nt_io_status_block		iosb;
++	nt_file_internal_information	fii_hdir,fii_hroot;
++	struct __psx_tlca *		tlca;
++
++	tlca = __tlca_self();
++	status = __ntapi->zw_query_information_file(
++			hdir,&iosb,&fii_hdir,sizeof(fii_hdir),
++			NT_FILE_INTERNAL_INFORMATION);
++	if (status)
++		return status;
++	status = __ntapi->zw_query_information_file(
++			tlca->ctx->root.hfile,&iosb,&fii_hroot,sizeof(fii_hroot),
++			NT_FILE_INTERNAL_INFORMATION);
++	if (status)
++		return status;
++	if (fii_hdir.index_number.quad == fii_hroot.index_number.quad) {
++		*hparent = hdir;
++		*type = PSX_FD_OS_FS_ROOT;
++		status = NT_STATUS_SUCCESS;
++	} else
++		status = __ntapi->tt_open_physical_parent_directory(
++			hparent,hdir,
++			buffer,
++			buffer_size,
++			desired_access,
++			open_options,type);
++	return status;
++}
++
+ int32_t	__stdcall __psx_iofn_fsdir_getvents(
+ 	void *			hfile,
+ 	void *			hevent,
+@@ -133,6 +196,6 @@ void __fastcall __psx_iofn_fsdir_init(struct __iovtbl * iovtbl)
+ 	iovtbl->getdents		= __ntapi->zw_query_directory_file;
+ 	iovtbl->getvents		= __psx_iofn_fsdir_getvents;
+ 
+-	iovtbl->open_logical_parent  = __ntapi->tt_open_logical_parent_directory;
+-	iovtbl->open_physical_parent = __ntapi->tt_open_physical_parent_directory;
++	iovtbl->open_logical_parent  = __psx_iofn_fsdir_open_parent_directory;
++	iovtbl->open_physical_parent = __psx_iofn_fsdir_open_parent_directory;
+ }
+diff --git a/src/path/psx_path_parse.c b/src/path/psx_path_parse.c
+index ff4d933..08431b6 100644
+--- a/src/path/psx_path_parse.c
++++ b/src/path/psx_path_parse.c
+@@ -48,8 +48,8 @@ int32_t __fastcall __psx_parse_normalized_path_utf8(
+ 			ch,
+ 			++(path_info->depth));
+ 
+-		if (*(++ch)=='/') {
+-			ch++;
++		if (ch[1]=='/') {
++			ch+=2;
+ 		}
+ 	}
+ 
+diff --git a/src/path/psx_path_resolve.c b/src/path/psx_path_resolve.c
+index 2bd615c..705e646 100644
+--- a/src/path/psx_path_resolve.c
++++ b/src/path/psx_path_resolve.c
+@@ -260,7 +260,7 @@ static int __fastcall __path_swap_at(
+ 	int32_t			status;
+ 
+ 	/* swap */
+-	if (path_info->pathflags & PSX_PATH_CLOSE_AT)
++	if ((path_info->pathflags & PSX_PATH_CLOSE_AT) && (path_info->hat != path_info->hfile))
+ 		if ((status = __iovtbl[path_info->fdtypeat].close(path_info->hat)))
+ 			return status;
+
+diff --git a/src/process/_execve.c b/src/process/_execve.c
+index a623d2a..80dd4a9 100644
+--- a/src/process/_execve.c
++++ b/src/process/_execve.c
+@@ -232,7 +232,7 @@ intptr_t __sys_execve(const unsigned char * path, const char ** argv, const char
+ 			NT_SECTION_QUERY|NT_SECTION_MAP_EXECUTE,
+ 			&oa,&ssize,
+ 			NT_PAGE_EXECUTE,
+-			NT_SEC_IMAGE,
++			NT_SEC_RESERVE,
+ 			image->info.hfile)))
+ 		return __execve_return(tlca,0,target,-ENOEXEC);
+ 
diff --git a/rsync-3.1.2.local.patch b/rsync-3.1.2.local.patch
new file mode 100644
index 0000000..aa6c8c5
--- /dev/null
+++ b/rsync-3.1.2.local.patch
@@ -0,0 +1,21 @@
+--- rsync-3.1.2/config.sub.orig	2013-05-20 00:01:07.000000000 +0200
++++ rsync-3.1.2/config.sub	2016-02-12 15:43:21.581825700 +0100
+@@ -789,6 +789,9 @@
+ 	microblaze*)
+ 		basic_machine=microblaze-xilinx
+ 		;;
++	midipix)
++		os=-midipix
++		;;
+ 	mingw64)
+ 		basic_machine=x86_64-pc
+ 		os=-mingw64
+@@ -1365,7 +1368,7 @@
+ 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ 	      | -chorusos* | -chorusrdb* | -cegcc* \
+ 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+-	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
++	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ 	      | -uxpv* | -beos* | -mpeix* | -udk* \
+ 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
diff --git a/util-linux-2.27.1.local.patch b/util-linux-2.27.1.local.patch
new file mode 100644
index 0000000..7c26291
--- /dev/null
+++ b/util-linux-2.27.1.local.patch
@@ -0,0 +1,21 @@
+--- util-linux-2.27.1/config/config.sub.orig	2015-01-07 13:05:37.000000000 +0100
++++ util-linux-2.27.1/config/config.sub	2016-02-12 12:36:20.953559000 +0100
+@@ -804,6 +804,9 @@
+ 	microblaze*)
+ 		basic_machine=microblaze-xilinx
+ 		;;
++	midipix)
++		os=-midipix
++		;;
+ 	mingw64)
+ 		basic_machine=x86_64-pc
+ 		os=-mingw64
+@@ -1384,7 +1387,7 @@
+ 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ 	      | -chorusos* | -chorusrdb* | -cegcc* \
+ 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+-	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
++	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
+ 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
diff --git a/xz-5.2.2.local.patch b/xz-5.2.2.local.patch
new file mode 100644
index 0000000..0002af0
--- /dev/null
+++ b/xz-5.2.2.local.patch
@@ -0,0 +1,21 @@
+--- xz-5.2.2/build-aux/config.sub.orig	2015-09-29 13:03:41.000000000 +0200
++++ xz-5.2.2/build-aux/config.sub	2016-02-12 15:49:34.036215100 +0100
+@@ -804,6 +804,9 @@
+ 	microblaze*)
+ 		basic_machine=microblaze-xilinx
+ 		;;
++	midipix)
++		os=-midipix
++		;;
+ 	mingw64)
+ 		basic_machine=x86_64-pc
+ 		os=-mingw64
+@@ -1384,7 +1387,7 @@
+ 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ 	      | -chorusos* | -chorusrdb* | -cegcc* \
+ 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+-	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
++	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
+ 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \