Index: build
==================================================================
--- build
+++ build
@@ -184,23 +184,37 @@
 function postconfigure() {
 	:
 }
 
 function configure_gcc() {
+	local glibcdir linuxheadersdir
+	local dynlinker
+	local gcc_default_headers
+
 	glibcdir="/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest"
 	glibcdir="$(readlink -f "${glibcdir}")"
+
+	linuxheadersdir="/opt/appfs/core.appfs.rkeene.org/linux-headers/platform/latest"
+	linuxheadersdir="$(readlink -f "${linuxheadersdir}")"
 
 	dynlinker="$(ls "${glibcdir}"/lib/ld-linux*.so.* | tail -n 1)"
 
 	if [ ! -f "${dynlinker}" ]; then
 		die 'glibc directory is not available (appfs running/working?)'
 	fi
 
-	CC="${CC:-gcc} -nostdinc -I${glibcdir}/include"
+	gcc_default_headers="$(echo '' | ${CPP:-cpp} -v 2>&1 | sed '/^End of search list/,$ d;0,/search starts here:$/ d' | grep '/gcc/' | sed 's@^ *@-I@' | tr $'\n' ' ')"
+
+	CC="${CC:-gcc} -nostdinc ${gcc_default_headers} -I${glibcdir}/include"
+
+	if ! echo " ${require[*]} " | grep ' linux-headers[/@: ]' >/dev/null; then
+		CC="${CC} -I${linuxheadersdir}/include"
+	fi
+
 	BUILD_CC="${CC}"
 	HOST_CC="${CC}"
-	LDFLAGS="${LDFLAGS} -Wl,--rpath,${glibcdir}/lib -Wl,--dynamic-linker,${dynlinker}"
+	LDFLAGS="${LDFLAGS} -L${glibcdir}/lib -Wl,--rpath,${glibcdir}/lib -Wl,--dynamic-linker,${dynlinker}"
 	PKG_CONFIG_LIBDIR="${glibcdir}/lib/pkgconfig"
 	export CC BUILD_CC HOST_CC LDFLAGS PKG_CONFIG_LIBDIR
 }
 
 function configure() {