--- svn-3468/linuxboot/Makefile	2012-05-16 12:27:54.017239188 +0300
+++ work/linuxboot/Makefile	2012-05-21 13:50:59.996148246 +0300
@@ -200,7 +200,11 @@
 	cp $< $@
 	[ -e $@ ] && touch $@
 
-$(slang)/src/objs/libslang.a: stage1/lib/libdl.so $(slang)/configure
+$(slang)/.stamp-slang-patch: misc/slang.patch
+	cd $(slang) && patch -b -p1 < $(cwd)/$<
+	touch $@
+
+$(slang)/src/objs/libslang.a: $(slang)/.stamp-slang-patch stage1/lib/libdl.so $(slang)/configure
 	rm -f $@
 	cd $(slang)						\
 	&& CC="$(CC) $(fakelib_cflags)" ./configure		\
@@ -312,10 +316,15 @@
 	sed -ie "s| gcc -E | $(CC) -E |" $(glibc)/locale/gen-translit.pl
 	touch $@
 
+$(glibc)/.stamp-glibc-i686-patch: misc/glibc-i686.patch
+	cd $(glibc) && patch -b -p1 < $(cwd)/$<
+	touch $@
+
 ## glibc
 # Configure switches cheerfully stolen from LFS project
 # (http://www.linuxfromscratch.org/lfs/view/development/chapter05/glibc.html).
 build-$(glibc)/libc.so: $(linux)/arch/x86/boot/bzImage	\
+			$(glibc)/.stamp-glibc-i686-patch \
 			$(glibc)/.stamp-glibc-gen-translit.pl-patch
 	mkdir -p build-$(glibc)
 	cd build-$(glibc) && CC="$(CC)" CFLAGS="-O2 -U_FORTIFY_SOURCE -fno-stack-protector $(CFLAGS)"	\
@@ -360,6 +369,7 @@
 # FIXME: Should include -nostdinc here
 fakelib_cflags=-isystem $(cwd)/fakeinclude -L$(cwd)/fakelib	\
 	-L$(cwd)/stage1/lib -L$(cwd)/stage1/usr/lib		\
+        -L$(cwd)/build-$(glibc)/math                            \
 	-Wl,-rpath-link,$(cwd)/stage1/lib
 
 # Create empty config file to silence ldconfig warnings
@@ -484,7 +494,7 @@
 				stage1/lib/libdl.so
 	cd $(parted)							\
 	&& CC="$(CC)" CXX="$(CXX)"						\
-		CFLAGS="$(fakelib_cflags) -I$(cwd)/$(e2fsprogs)/lib"	\
+		CFLAGS="$(fakelib_cflags) -I$(cwd)/$(e2fsprogs)/lib -ldl"	\
 		./configure --disable-nls --without-readline		\
 		--build=i586-linux --disable-Werror			\
 	&& $(MAKE)
@@ -800,7 +810,7 @@
 ## libusb
 $(libusb)/.libs/libusb-0.1.so.4.4.4:
 	cd $(libusb)						\
-	&& CC="$(CC)" CXX="$(CXX)" ./configure --disable-static		\
+	&& CC="$(CC)" CXX="$(CXX)" CPPFLAGS="$(fakelib_cflags)" ./configure --disable-static		\
 	                        --build=i586-linux		\
 	                        --disable-dependency-tracking	\
 	&&  $(MAKE)
@@ -1037,7 +1047,7 @@
 #	:pserver:anoncvs@sources.redhat.com:/cvs/glibc)
 $(call download_rule, $(glibc), tar.bz2, http://ftp.gnu.org/gnu/glibc/)
 $(call download_rule, $(kbd), tar.gz,			\
-	http://www.all.kernel.org/pub/linux/utils/kbd/)
+	http://ftp.altlinux.com/pub/people/legion/kbd/)
 $(call download_rule, $(libusb), tar.gz,	\
 	http://downloads.sourceforge.net/libusb/)
 $(call download_rule, $(linux), tar.bz2,		\
@@ -1067,10 +1077,10 @@
 $(call download_rule, $(syslinux), tar.gz, \
         http://ftp.all.kernel.org/pub/linux/utils/boot/syslinux/)
 $(call download_rule, $(usbutils), tar.bz2,	\
-	http://mirror.anl.gov/pub/linux/utils/usb/usbutils/)
+	http://ftp.sunet.se/pub/Linux/kernel.org/linux/utils/usb/usbutils/)
 $(call download_rule, $(wireless_tools), tar.gz,	\
 	http://pcmcia-cs.sourceforge.net/ftp/contrib/)
-$(call download_rule, $(zlib), tar.gz, http://www.zlib.net/)
+$(call download_rule, $(zlib), tar.gz, http://downloads.sourceforge.net/project/libpng/zlib/1.2.5/)
 
 symlink_targets=$(addprefix symlink-,$(packages))		\
 	symlink-build-$(glibc) symlink-build-$(dosemu)		\
