Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
+++ HelenOS.config	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -0,0 +1,24 @@
+## General configuration directives
+
+# Platform
+@ "amd64" AMD64/Intel EM64T (PC)
+@ "ia32" Intel IA-32 (PC)
+@ "ia64" Intel IA-64 (Ski)
+@ "mips32msim" MIPS 32-bit (MSIM)
+@ "mips32sim" MIPS 32-bit (Simics)
+@ "mips32gbe" MIPS 32-bit (GXEmul big endian)
+@ "mips32gle" MIPS 32-bit (GXEmul little endian)
+@ "mips32sgi" MIPS 32-bit (Sgi Indy)
+@ "ppc32" PowerPC 32-bit (iMac G4)
+@ "ppc64" PowerPC 64-bit (iMac G5)
+@ "sparc64" Sun UltraSPARC 64-bit
+@ "xen32" Xen 32-bit (PC)
+! PLATFORM (choice)
+
+# Compiler
+@ "cross" Cross-compiler
+@ "native" Native
+! COMPILER (choice)
+
+# Debug build
+! CONFIG_DEBUG (y/n)
Index: Makefile
===================================================================
--- Makefile	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
+++ Makefile	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -0,0 +1,152 @@
+#
+# Copyright (C) 2006 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+## Include configuration
+#
+
+-include Makefile.config
+
+## Setup platform configuration
+#
+
+ifeq ($(PLATFORM),amd64)
+	KARCH = amd64
+	MACHINE = opteron
+	UARCH = amd64
+	BARCH = amd64
+endif
+
+ifeq ($(PLATFORM),ia32)
+	KARCH = ia32
+	UARCH = ia32
+	BARCH = ia32
+endif
+
+ifeq ($(PLATFORM),ia64)
+	KARCH = ia64
+	UARCH = ia64
+	BARCH = ia64
+endif
+
+ifeq ($(PLATFORM),mips32msim)
+	KARCH = mips32
+	MACHINE = msim
+	UARCH = mips32
+	BARCH = mips32
+	IMAGE = binary
+endif
+
+ifeq ($(PLATFORM),mips32sim)
+	KARCH = mips32
+	MACHINE = simics
+	UARCH = mips32
+	BARCH = mips32
+	IMAGE = ecoff
+endif
+
+ifeq ($(PLATFORM),mips32gbe)
+	KARCH = mips32
+	MACHINE = bgxemul
+	UARCH = mips32eb
+	BARCH = mips32
+	IMAGE = ecoff
+endif
+
+ifeq ($(PLATFORM),mips32gle)
+	KARCH = mips32
+	MACHINE = lgxemul
+	UARCH = mips32
+	BARCH = mips32
+	IMAGE = ecoff
+endif
+
+ifeq ($(PLATFORM),mips32sgi)
+	KARCH = mips32
+	MACHINE = indy
+	UARCH = mips32eb
+	BARCH = mips32
+	IMAGE = ecoff
+endif
+
+ifeq ($(PLATFORM),ppc32)
+	KARCH = ppc32
+	UARCH = ppc32
+	BARCH = ppc32
+endif
+
+ifeq ($(PLATFORM),ppc64)
+	KARCH = ppc64
+	UARCH = ppc64
+	BARCH = ppc64
+endif
+
+ifeq ($(PLATFORM),sparc64)
+	KARCH = sparc64
+	UARCH = sparc64
+	BARCH = sparc64
+endif
+
+ifeq ($(PLATFORM),xen32)
+	KARCH = xen32
+	UARCH = ia32
+	BARCH = xen32
+endif
+
+.PHONY: all build config distclean clean
+
+all:
+	tools/config.py HelenOS.config default
+	$(MAKE) -C . build
+
+build:
+ifneq ($(MACHINE),)
+	$(MAKE) -C kernel ARCH=$(KARCH) COMPILER=$(COMPILER) CONFIG_DEBUG=$(CONFIG_DEBUG) MACHINE=$(MACHINE)
+else
+	$(MAKE) -C kernel ARCH=$(KARCH) COMPILER=$(COMPILER) CONFIG_DEBUG=$(CONFIG_DEBUG)
+endif
+	$(MAKE) -C uspace ARCH=$(UARCH) COMPILER=$(COMPILER) CONFIG_DEBUG=$(CONFIG_DEBUG)
+ifneq ($(IMAGE),)
+	$(MAKE) -C boot ARCH=$(BARCH) COMPILER=$(COMPILER) CONFIG_DEBUG=$(CONFIG_DEBUG) IMAGE=$(IMAGE)
+else
+	$(MAKE) -C boot ARCH=$(BARCH) COMPILER=$(COMPILER) CONFIG_DEBUG=$(CONFIG_DEBUG)
+endif
+
+config:
+	-rm Makefile.depend HelenOS.config
+	tools/config.py
+
+distclean:
+	-rm Makefile.config
+	-$(MAKE) -C kernel distclean
+	-$(MAKE) -C uspace distclean
+	-$(MAKE) -C boot distclean
+
+clean:
+	-$(MAKE) -C kernel clean
+	-$(MAKE) -C uspace clean
+	-$(MAKE) -C boot clean
Index: boot/Makefile
===================================================================
--- boot/Makefile	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/Makefile	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -30,7 +30,8 @@
 #
 
+-include ../version
 -include Makefile.config
 
-## Common flags
+## Paths
 #
 
@@ -38,15 +39,4 @@
 KERNELDIR = $(BASE)/kernel
 USPACEDIR = $(BASE)/uspace
-
-## Setup arch configuration
-#
-
--include arch/$(ARCH)/Makefile.inc
-
-ifeq ($(ARCH),xen32)
-	UARCH = ia32
-else
-	UARCH = $(ARCH)
-endif
 
 ifeq ($(CONFIG_DEBUG),y)
@@ -58,34 +48,18 @@
 endif
 
-.PHONY: all build config distclean arch_distclean clean kernel uspace clean_kernel clean_uspace distclean_kernel distclean_uspace
+.PHONY: all build config distclean clean generic_clean
 
 all:
-	tools/config.py default
-	$(MAKE) -C . build $(ARCH)
+	../tools/config.py boot.config default $(ARCH) $(COMPILER) $(CONFIG_DEBUG) $(IMAGE)
+	$(MAKE) -C . build
+
+-include arch/$(ARCH)/Makefile.inc
 
 config:
-	tools/config.py
+	../tools/config.py boot.config
 
-distclean: clean arch_distclean
+distclean: clean
 	-rm Makefile.config
 
-kernel:
-	$(MAKE) -C $(KERNELDIR) NARCH=$(ARCH)
-
-uspace:
-	$(MAKE) -C $(USPACEDIR) NARCH=$(UARCH)
-
-clean_kernel:
-	$(MAKE) -C $(KERNELDIR) clean ARCH=$(ARCH)
-
-clean_uspace:
-	$(MAKE) -C $(USPACEDIR) clean ARCH=$(UARCH)
-
-clean_boot_gen:
+generic_clean:
 	-rm generic/*.o genarch/*.o
-
-distclean_kernel:
-	$(MAKE) -C $(KERNELDIR) distclean ARCH=$(ARCH)
-
-distclean_uspace:
-	$(MAKE) -C $(USPACEDIR) distclean ARCH=$(UARCH)
Index: boot/arch/amd64/Makefile.inc
===================================================================
--- boot/arch/amd64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/amd64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,25 +27,28 @@
 #
 
-build: image.iso
+TASKS = \
+	$(USPACEDIR)/init/init \
+	$(USPACEDIR)/ns/ns \
+	$(USPACEDIR)/pci/pci \
+	$(USPACEDIR)/fb/fb \
+	$(USPACEDIR)/kbd/kbd \
+	$(USPACEDIR)/console/console \
+	$(USPACEDIR)/tetris/tetris \
+	$(USPACEDIR)/ipcc/ipcc \
+	$(USPACEDIR)/klog/klog
 
-image.iso: kernel uspace
+build: $(BASE)/image.iso
+
+$(BASE)/image.iso: arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(TASKS)
 	mkdir -p arch/$(ARCH)/iso/boot/grub
 	cp arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/iso/boot/grub/
 	cp arch/$(ARCH)/grub/menu.lst arch/$(ARCH)/iso/boot/grub/
 	cp $(KERNELDIR)/kernel.bin arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/init/init arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/ns/ns arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/pci/pci arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/fb/fb arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/kbd/kbd arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/console/console arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/tetris/tetris arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/ipcc/ipcc arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/klog/klog arch/$(ARCH)/iso/boot/
-	mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o image.iso arch/$(ARCH)/iso/
+	for task in $(TASKS) ; do \
+		cp $$task arch/$(ARCH)/iso/boot/ ; \
+	done
+	mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $(BASE)/image.iso arch/$(ARCH)/iso/
 
-clean: clean_kernel clean_uspace
+clean:
 	-rm -fr arch/$(ARCH)/iso
-	-rm -f image.iso
-
-arch_distclean: distclean_kernel distclean_uspace
+	-rm -f $(BASE)/image.iso
Index: boot/arch/ia32/Makefile.inc
===================================================================
--- boot/arch/ia32/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/ia32/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,25 +27,28 @@
 #
 
-build: image.iso
+TASKS = \
+	$(USPACEDIR)/init/init \
+	$(USPACEDIR)/ns/ns \
+	$(USPACEDIR)/pci/pci \
+	$(USPACEDIR)/fb/fb \
+	$(USPACEDIR)/kbd/kbd \
+	$(USPACEDIR)/console/console \
+	$(USPACEDIR)/tetris/tetris \
+	$(USPACEDIR)/ipcc/ipcc \
+	$(USPACEDIR)/klog/klog
 
-image.iso: kernel uspace
+build: $(BASE)/image.iso
+
+$(BASE)/image.iso: arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(TASKS)
 	mkdir -p arch/$(ARCH)/iso/boot/grub
 	cp arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/iso/boot/grub/
 	cp arch/$(ARCH)/grub/menu.lst arch/$(ARCH)/iso/boot/grub/
 	cp $(KERNELDIR)/kernel.bin arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/init/init arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/ns/ns arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/pci/pci arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/fb/fb arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/kbd/kbd arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/console/console arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/tetris/tetris arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/ipcc/ipcc arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/klog/klog arch/$(ARCH)/iso/boot/
-	mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o image.iso arch/$(ARCH)/iso/
+	for task in $(TASKS) ; do \
+		cp $$task arch/$(ARCH)/iso/boot/ ; \
+	done
+	mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $(BASE)/image.iso arch/$(ARCH)/iso/
 
-clean: clean_kernel clean_uspace
+clean:
 	-rm -fr arch/$(ARCH)/iso
-	-rm -f image.iso
-
-arch_distclean: distclean_kernel distclean_uspace
+	-rm -f $(BASE)/image.iso
Index: boot/arch/ia64/Makefile.inc
===================================================================
--- boot/arch/ia64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/ia64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,17 +27,15 @@
 #
 
-VMAXLMA_SRC=$(KERNELDIR)/contrib/arch/ia64/vmaxlma.c
+VMAXLMA_SRC = tools/ia64/vmaxlma.c
 
-build: kernel.bin
+build: $(BASE)/kernel.bin
 
-kernel.bin: kernel uspace vmaxlma
-	cp $(KERNELDIR)/kernel.bin .
-	./vmaxlma kernel.bin
+$(BASE)/kernel.bin: $(KERNELDIR)/kernel.bin vmaxlma
+	cp $(KERNELDIR)/kernel.bin $(BASE)/kernel.bin
+	./vmaxlma $(BASE)/kernel.bin
 
 vmaxlma: $(VMAXLMA_SRC)
-	gcc $(VMAXLMA_SRC) -o $@
+	$(CC) $(VMAXLMA_SRC) -o $@
 
-clean: clean_kernel clean_uspace
-	-rm -f kernel.bin vmaxlma
-
-arch_distclean: distclean_kernel distclean_uspace
+clean:
+	-rm -f $(BASE)/kernel.bin vmaxlma
Index: boot/arch/mips32/Makefile.inc
===================================================================
--- boot/arch/mips32/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/mips32/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,13 +27,16 @@
 #
 
-build: image.boot
+build: $(BASE)/image.boot
 
-image.boot: kernel uspace
-	make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(CONFIG_IMAGE)
-	cp arch/$(ARCH)/loader/image.boot image.boot
+$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot
+	cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot
 
-clean: clean_boot_gen clean_kernel clean_uspace
-	make -C arch/$(ARCH)/loader clean
-	-rm -f image.boot
+depend:
+	-rm arch/$(ARCH)/loader/image.boot
 
-arch_distclean: distclean_kernel distclean_uspace
+arch/$(ARCH)/loader/image.boot:
+	make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE)
+
+clean:
+	make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(IMAGE)
+	-rm -f $(BASE)/image.boot
Index: boot/arch/ppc32/Makefile.inc
===================================================================
--- boot/arch/ppc32/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/ppc32/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,13 +27,16 @@
 #
 
-build: image.boot
+build: $(BASE)/image.boot
 
-image.boot: kernel uspace
+$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot
+	cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot
+
+depend:
+	-rm arch/$(ARCH)/loader/image.boot
+
+arch/$(ARCH)/loader/image.boot:
 	make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)"
-	cp arch/$(ARCH)/loader/image.boot image.boot
 
-clean: clean_boot_gen clean_kernel clean_uspace
-	make -C arch/$(ARCH)/loader clean KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-	-rm -f image.boot
-
-arch_distclean: distclean_kernel distclean_uspace
+clean: generic_clean
+	make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)"
+	-rm -f $(BASE)/image.boot
Index: boot/arch/ppc64/Makefile.inc
===================================================================
--- boot/arch/ppc64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/ppc64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,13 +27,16 @@
 #
 
-build: image.boot
+build: $(BASE)/image.boot
 
-image.boot: kernel uspace
+$(BASE)/image.boot: depend arch/$(ARCH)/loader/image.boot
+	cp arch/$(ARCH)/loader/image.boot $(BASE)/image.boot
+
+depend:
+	-rm arch/$(ARCH)/loader/image.boot
+
+arch/$(ARCH)/loader/image.boot:
 	make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-	cp arch/$(ARCH)/loader/image.boot image.boot
 
-clean: clean_boot_gen clean_kernel clean_uspace
-	make -C arch/$(ARCH)/loader clean KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
-	-rm -f image.boot
-
-arch_distclean: distclean_kernel distclean_uspace
+clean: generic_clean
+	make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
+	-rm -f $(BASE)/image.boot
Index: boot/arch/sparc64/Makefile.inc
===================================================================
--- boot/arch/sparc64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/sparc64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -29,8 +29,7 @@
 TMP=distroot
 
-build: image.iso
+build: $(BASE)/image.iso
 
-image.iso: kernel
-	make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(CONFIG_IMAGE)
+$(BASE)/image.iso: depend arch/$(ARCH)/loader/image.boot
 	mkdir -p $(TMP)/boot
 	mkdir -p $(TMP)/HelenOS
@@ -38,10 +37,14 @@
 	cp arch/$(ARCH)/silo/README arch/$(ARCH)/silo/COPYING arch/$(ARCH)/silo/silo.conf $(TMP)/boot
 	cp arch/$(ARCH)/loader/image.boot $(TMP)/HelenOS/image.boot
-	mkisofs -f -G $(TMP)/boot/isofs.b -B ... -r -o image.iso $(TMP)/
+	mkisofs -f -G $(TMP)/boot/isofs.b -B ... -r -o $(BASE)/image.iso $(TMP)/
 
-clean: clean_boot_gen clean_kernel
-	 make -C arch/$(ARCH)/loader clean
+depend:
+	-rm arch/$(ARCH)/loader/image.boot
+
+arch/$(ARCH)/loader/image.boot:
+	make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
+
+clean: generic_clean
+	make -C arch/$(ARCH)/loader clean COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
 	-rm -fr $(TMP)
-	-rm -f image.iso
-
-arch_distclean: distclean_kernel
+	-rm -f $(BASE)/image.iso
Index: boot/arch/xen32/Makefile.inc
===================================================================
--- boot/arch/xen32/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/arch/xen32/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,7 +27,18 @@
 #
 
-build: image.iso
+TASKS = \
+	$(USPACEDIR)/init/init \
+	$(USPACEDIR)/ns/ns \
+	$(USPACEDIR)/pci/pci \
+	$(USPACEDIR)/fb/fb \
+	$(USPACEDIR)/kbd/kbd \
+	$(USPACEDIR)/console/console \
+	$(USPACEDIR)/tetris/tetris \
+	$(USPACEDIR)/ipcc/ipcc \
+	$(USPACEDIR)/klog/klog
 
-image.iso: kernel uspace
+build: $(BASE)/image.iso
+
+$(BASE)/image.iso: arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/grub/menu.lst arch/$(ARCH)/grub/xen.gz $(KERNELDIR)/kernel.bin $(TASKS)
 	mkdir -p arch/$(ARCH)/iso/boot/grub
 	cp arch/$(ARCH)/grub/stage2_eltorito arch/$(ARCH)/iso/boot/grub/
@@ -35,18 +46,10 @@
 	cp arch/$(ARCH)/grub/xen.gz arch/$(ARCH)/iso/boot/
 	cp $(KERNELDIR)/kernel.bin arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/init/init arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/ns/ns arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/pci/pci arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/fb/fb arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/kbd/kbd arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/console/console arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/tetris/tetris arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/ipcc/ipcc arch/$(ARCH)/iso/boot/
-	cp $(USPACEDIR)/klog/klog arch/$(ARCH)/iso/boot/
-	mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o image.iso arch/$(ARCH)/iso/
+	for task in $(TASKS) ; do \
+		cp $$task arch/$(ARCH)/iso/boot/ ; \
+	done
+	mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $(BASE)/image.iso arch/$(ARCH)/iso/
 
-clean: clean_kernel clean_uspace
+clean:
 	-rm -fr arch/$(ARCH)/iso
-	-rm -f image.iso
-
-arch_distclean: distclean_kernel distclean_uspace
+	-rm -f $(BASE)/image.iso
Index: boot/boot.config
===================================================================
--- boot/boot.config	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ boot/boot.config	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -12,21 +12,8 @@
 ! ARCH (choice)
 
-# PPC32 Compiler
+# Compiler
 @ "cross" Cross-compiler
 @ "native" Native
-! [ARCH=ppc32] PPC32_COMPILER (choice)
-% [ARCH=ppc32] SAVEAS PPC32_COMPILER COMPILER
-
-# PPC64 Compiler
-@ "cross" Cross-compiler
-@ "native" Native
-! [ARCH=ppc64] PPC64_COMPILER (choice)
-% [ARCH=ppc64] SAVEAS PPC64_COMPILER COMPILER
-
-# MIPS32 Compiler
-@ "cross" Cross-compiler
-@ "native" Native
-! [ARCH=mips32] MIPS32_COMPILER (choice)
-% [ARCH=mips32] SAVEAS MIPS32_COMPILER COMPILER
+! COMPILER (choice)
 
 # Debug bootloader
@@ -39,3 +26,3 @@
 @ "binary" Binary image (MSIM)
 @ "ecoff" Ecoff image (GXEmul)
-! [ARCH=mips32] CONFIG_IMAGE (choice)
+! [ARCH=mips32] IMAGE (choice)
Index: ot/tools/config.py
===================================================================
--- boot/tools/config.py	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ 	(revision )
@@ -1,494 +1,0 @@
-#!/usr/bin/env python
-"""
-Boot configuration script
-"""
-import sys
-import os
-import re
-import commands
-
-INPUT = 'boot.config'
-OUTPUT = 'Makefile.config'
-TMPOUTPUT = 'Makefile.config.tmp'
-
-class DefaultDialog:
-    "Wrapper dialog that tries to return default values"
-    def __init__(self, dlg):
-        self.dlg = dlg
-
-    def set_title(self,text):
-        self.dlg.set_title(text)
-        
-    def yesno(self, text, default=None):
-        if default is not None:
-            return default
-        return self.dlg.yesno(text, default)
-    def noyes(self, text, default=None):
-        if default is not None:
-            return default
-        return self.dlg.noyes(text, default)
-    
-    def choice(self, text, choices, defopt=None):
-        if defopt is not None:
-            return choices[defopt][0]
-        return self.dlg.choice(text, choices, defopt)
-
-class NoDialog:
-    def __init__(self):
-        self.printed = None
-        self.title = 'HelenOS Configuration'
-
-    def print_title(self):
-        if not self.printed:
-            sys.stdout.write("\n*** %s ***\n" % self.title)
-            self.printed = True
-
-    def set_title(self, text):
-        self.title = text
-        self.printed = False
-    
-    def noyes(self, text, default=None):
-        if not default:
-            default = 'n'
-        return self.yesno(text, default)
-    
-    def yesno(self, text, default=None):
-        self.print_title()
-        
-        if default != 'n':
-            default = 'y'
-        while 1:
-            sys.stdout.write("%s (y/n)[%s]: " % (text,default))
-            inp = sys.stdin.readline()
-            if not inp:
-                raise EOFError
-            inp = inp.strip().lower()
-            if not inp:
-                return default
-            if inp == 'y':
-                return 'y'
-            elif inp == 'n':
-                return 'n'
-
-    def _print_choice(self, text, choices, defopt):
-        sys.stdout.write('%s:\n' % text)
-        for i,(text,descr) in enumerate(choices):
-            sys.stdout.write('\t%2d. %s\n' % (i, descr))
-        if defopt is not None:
-            sys.stdout.write('Enter choice number[%d]: ' % defopt)
-        else:
-            sys.stdout.write('Enter choice number: ')
-
-    def menu(self, text, choices, button, defopt=None):
-        self.title = 'Main menu'
-        menu = []
-        for key, descr in choices:
-            txt = key + (45-len(key))*' ' + ': ' + descr
-            menu.append((key, txt))
-            
-        return self.choice(text, [button] + menu)
-        
-    def choice(self, text, choices, defopt=None):
-        self.print_title()
-        while 1:
-            self._print_choice(text, choices, defopt)
-            inp = sys.stdin.readline()
-            if not inp:
-                raise EOFError
-            if not inp.strip():
-                if defopt is not None:
-                    return choices[defopt][0]
-                continue
-            try:
-                number = int(inp.strip())
-            except ValueError:
-                continue
-            if number < 0 or number >= len(choices):
-                continue
-            return choices[number][0]
-
-
-def eof_checker(fnc):
-    def wrapper(self, *args, **kw):
-        try:
-            return fnc(self, *args, **kw)
-        except EOFError:
-            return getattr(self.bckdialog,fnc.func_name)(*args, **kw)
-    return wrapper
-
-class Dialog(NoDialog):
-    def __init__(self):
-        NoDialog.__init__(self)
-        self.dlgcmd = os.environ.get('DIALOG','dialog')
-        self.title = ''
-        self.backtitle = 'HelenOS Kernel Configuration'
-        
-        if os.system('%s --print-maxsize >/dev/null 2>&1' % self.dlgcmd) != 0:
-            raise NotImplementedError
-        
-        self.bckdialog = NoDialog()
-
-    def set_title(self,text):
-        self.title = text
-        self.bckdialog.set_title(text)
-        
-    def calldlg(self,*args,**kw):
-        "Wrapper for calling 'dialog' program"
-        indesc, outdesc = os.pipe()
-        pid = os.fork()
-        if not pid:
-            os.close(2)
-            os.dup(outdesc)
-            os.close(indesc)
-            
-            dlgargs = [self.dlgcmd,'--title',self.title,
-                       '--backtitle', self.backtitle]
-            for key,val in kw.items():
-                dlgargs.append('--'+key)
-                dlgargs.append(val)
-            dlgargs += args            
-            os.execlp(self.dlgcmd,*dlgargs)
-
-        os.close(outdesc)
-        
-        try:
-            errout = os.fdopen(indesc,'r')
-            data = errout.read()
-            errout.close()
-            pid,status = os.wait()
-        except:
-            os.system('reset') # Reset terminal
-            raise
-        
-        if not os.WIFEXITED(status):
-            os.system('reset') # Reset terminal
-            raise EOFError
-        
-        status = os.WEXITSTATUS(status)
-        if status == 255:
-            raise EOFError
-        return status,data
-        
-    def yesno(self, text, default=None):
-        if text[-1] not in ('?',':'):
-            text = text + ':'
-        width = '50'
-        height = '5'
-        if len(text) < 48:
-            text = ' '*int(((48-len(text))/2)) + text
-        else:
-            width = '0'
-            height = '0'
-        if default == 'n':
-            res,data = self.calldlg('--defaultno','--yesno',text,height,width)
-        else:
-            res,data = self.calldlg('--yesno',text,height,width)
-
-        if res == 0:
-            return 'y'
-        return 'n'
-    yesno = eof_checker(yesno)
-
-    def menu(self, text, choices, button, defopt=None):
-        self.title = 'Main menu'
-        text = text + ':'
-        width = '70'
-        height = str(8 + len(choices))
-        args = []
-        for key,val in choices:
-            args.append(key)
-            args.append(val)
-
-        kw = {}
-        if defopt:
-            kw['default-item'] = choices[defopt][0] 
-        res,data = self.calldlg('--ok-label','Change',
-                                '--extra-label',button[1],
-                                '--extra-button',
-                                '--menu',text,height,width,
-                                str(len(choices)),*args,**kw)
-        if res == 3:
-            return button[0]
-        if res == 1: # Cancel
-            sys.exit(1)
-        elif res:
-            print data
-            raise EOFError
-        return data
-    menu = eof_checker(menu)
-    
-    def choice(self, text, choices, defopt=None):
-        text = text + ':'
-        width = '50'
-        height = str(8 + len(choices))
-        args = []
-        for key,val in choices:
-            args.append(key)
-            args.append(val)
-
-        kw = {}
-        if defopt:
-            kw['default-item'] = choices[defopt][0] 
-        res,data = self.calldlg('--nocancel','--menu',text,height,width,
-                                str(len(choices)),*args, **kw)
-        if res:
-            print data
-            raise EOFError
-        return data
-    choice = eof_checker(choice)
-    
-def read_defaults(fname,defaults):
-    "Read saved values from last configuration run"
-    f = file(fname,'r')
-    for line in f:
-        res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
-        if res:
-            defaults[res.group(1)] = res.group(2)
-    f.close()
-
-def check_condition(text, defaults, asked_names):
-    seen_vars = [ x[0] for x in asked_names ]
-    ctype = 'cnf'
-    if ')|' in text or '|(' in text:
-        ctype = 'dnf'
-    
-    if ctype == 'cnf':
-        conds = text.split('&')
-    else:
-        conds = text.split('|')
-
-    for cond in conds:
-        if cond.startswith('(') and cond.endswith(')'):
-            cond = cond[1:-1]
-            
-        inside = check_inside(cond, defaults, ctype, seen_vars)
-        
-        if ctype == 'cnf' and not inside:
-            return False
-        if ctype == 'dnf' and inside:
-            return True
-
-    if ctype == 'cnf':
-        return True
-    return False
-
-def check_inside(text, defaults, ctype, seen_vars):
-    """
-    Check that the condition specified on input line is True
-
-    only CNF is supported
-    """
-    if ctype == 'cnf':
-        conds = text.split('|')
-    else:
-        conds = text.split('&')
-    for cond in conds:
-        res = re.match(r'^(.*?)(!?=)(.*)$', cond)
-        if not res:
-            raise RuntimeError("Invalid condition: %s" % cond)
-        condname = res.group(1)
-        oper = res.group(2)
-        condval = res.group(3)
-        if condname not in seen_vars:
-            varval = ''
-##             raise RuntimeError("Variable %s not defined before being asked." %\
-##                                condname)
-        elif not defaults.has_key(condname):
-            raise RuntimeError("Condition var %s does not exist: %s" % \
-                               (condname,text))
-        else:
-            varval = defaults[condname]
-        if ctype == 'cnf':
-            if oper == '=' and  condval == varval:
-                return True
-            if oper == '!=' and condval != varval:
-                return True
-        else:
-            if oper== '=' and condval != varval:
-                return False
-            if oper== '!=' and condval == varval:
-                return False
-    if ctype=='cnf':
-        return False
-    return True
-
-def parse_config(input, output, dlg, defaults={}, askonly=None):
-    "Parse configuration file and create Makefile.config on the fly"
-    def ask_the_question(dialog):
-        "Ask question based on the type of variables to ask"
-        # This is quite a hack, this thingy is written just to
-        # have access to local variables..
-        if vartype == 'y/n':
-            return dialog.yesno(comment, default)
-        elif vartype == 'n/y':
-            return dialog.noyes(comment, default)
-        elif vartype == 'choice':
-            defopt = None
-            if default is not None:
-                for i,(key,val) in enumerate(choices):
-                    if key == default:
-                        defopt = i
-                        break
-            return dialog.choice(comment, choices, defopt)
-        else:
-            raise RuntimeError("Bad method: %s" % vartype)
-
-    
-    f = file(input, 'r')
-    outf = file(output, 'w')
-
-    outf.write('#########################################\n')
-    outf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
-    outf.write('#########################################\n\n')
-
-    asked_names = []
-
-    comment = ''
-    default = None
-    choices = []
-    for line in f:
-        if line.startswith('%'):
-            res = re.match(r'^%\s*(?:\[(.*?)\])?\s*(.*)$', line)
-            if not res:
-                raise RuntimeError('Invalid command: %s' % line)
-            if res.group(1):
-                if not check_condition(res.group(1), defaults,
-                                       asked_names):
-                    continue
-            args = res.group(2).strip().split(' ')
-            cmd = args[0].lower()
-            args = args[1:]
-            if cmd == 'saveas':
-                outf.write('%s = %s\n' % (args[1],defaults[args[0]]))
-            elif cmd == 'shellcmd':
-                varname = args[0]
-                args = args[1:]
-                for i,arg in enumerate(args):
-                    if arg.startswith('$'):
-                        args[i] = defaults[arg[1:]]
-                data,status = commands.getstatusoutput(' '.join(args))
-                if status:
-                    raise RuntimeError('Error running: %s' % ' '.join(args))
-                outf.write('%s = %s\n' % (varname,data.strip()))
-            continue
-            
-        if line.startswith('!'):
-            # Ask a question
-            res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
-            if not res:
-                raise RuntimeError("Weird line: %s" % line)
-            varname = res.group(2)
-            vartype = res.group(3)
-
-            default = defaults.get(varname,None)
-            
-            if res.group(1):
-                if not check_condition(res.group(1), defaults,
-                                       asked_names):
-                    if default is not None:
-                        outf.write('#!# %s = %s\n' % (varname, default))
-                    # Clear cumulated values
-                    comment = ''
-                    default = None
-                    choices = []
-                    continue
-                
-            asked_names.append((varname,comment))
-
-            if default is None or not askonly or askonly == varname:
-                default = ask_the_question(dlg)
-            else:
-                default = ask_the_question(DefaultDialog(dlg))
-
-            outf.write('%s = %s\n' % (varname, default))
-            # Remeber the selected value
-            defaults[varname] = default
-            # Clear cumulated values
-            comment = ''
-            default = None
-            choices = []
-            continue
-        
-        if line.startswith('@'):
-            # Add new line into the 'choice array' 
-            res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
-            if not res:
-                raise RuntimeError("Bad line: %s" % line)
-            if res.group(1):
-                if not check_condition(res.group(1),defaults,
-                                       asked_names):
-                    continue
-            choices.append((res.group(2), res.group(3)))
-            continue
-
-        # All other things print to output file
-        outf.write(line)
-        if re.match(r'^#[^#]', line):
-            # Last comment before question will be displayed to the user
-            comment = line[1:].strip()
-        elif line.startswith('## '):
-            # Set title of the dialog window
-            dlg.set_title(line[2:].strip())
-
-    outf.write('\n')
-    outf.write('REVISION = %s\n' % commands.getoutput('svnversion . 2> /dev/null'))
-    outf.write('TIMESTAMP = %s\n' % commands.getoutput('date "+%Y-%m-%d %H:%M:%S"'))
-    outf.close()
-    f.close()
-    return asked_names
-
-def main():
-    defaults = {}
-    try:
-        dlg = Dialog()
-    except NotImplementedError:
-        dlg = NoDialog()
-
-    if len(sys.argv) >= 2 and sys.argv[1]=='default':
-        defmode = True
-    else:
-        defmode = False
-
-    # Default run will update the configuration file
-    # with newest options
-    if os.path.exists(OUTPUT):
-        read_defaults(OUTPUT, defaults)
-
-	# Get ARCH from command line if specified	
-    if len(sys.argv) >= 3:
-        defaults['ARCH'] = sys.argv[2]
-
-    # Dry run only with defaults
-    varnames = parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
-    # If not in default mode, present selection of all possibilities
-    if not defmode:
-        defopt = 0
-        while 1:
-            # varnames contains variable names that were in the
-            # last question set
-            choices = [ (x[1],defaults[x[0]]) for x in varnames ]
-            res = dlg.menu('Configuration',choices,('save','Save'),defopt)
-            if res == 'save':
-                parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
-                break
-            # transfer description back to varname
-            for i,(vname,descr) in enumerate(varnames):
-                if res == descr:
-                    defopt = i
-                    break
-            # Ask the user a simple question, produce output
-            # as if the user answered all the other questions
-            # with default answer
-            varnames = parse_config(INPUT, TMPOUTPUT, dlg, defaults,
-                                    askonly=varnames[i][0])
-        
-    
-    if os.path.exists(OUTPUT):
-        os.unlink(OUTPUT)
-    os.rename(TMPOUTPUT, OUTPUT)
-    
-    if not defmode and dlg.yesno('Rebuild everything?') == 'y':
-        os.execlp('make','make','clean','build')
-
-if __name__ == '__main__':
-    main()
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/Makefile	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -27,21 +27,9 @@
 #
 
-## Kernel release
-#
-
-VERSION = 0
-PATCHLEVEL = 2
-SUBLEVEL = 0
-EXTRAVERSION = 2
-NAME = Daylight
-ifdef EXTRAVERSION
-RELEASE = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL).$(EXTRAVERSION)
-else
-RELEASE = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
-endif
 
 ## Include configuration
 #
 
+-include ../version
 -include Makefile.config
 
@@ -50,5 +38,5 @@
 
 DEFS = -D$(ARCH) -DARCH=\"$(ARCH)\" -DRELEASE=\"$(RELEASE)\" "-DNAME=\"$(NAME)\"" -DKERNEL
-CFLAGS = -fno-builtin -fomit-frame-pointer -Wall -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -Igeneric/include/ 
+CFLAGS = -fno-builtin -fomit-frame-pointer -Wall -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -Igeneric/include/
 LFLAGS = -M
 AFLAGS =
@@ -71,38 +59,47 @@
 	DEFS += -DCONFIG_DEBUG
 endif
+
 ifeq ($(CONFIG_DEBUG_SPINLOCK),y)
 	DEFS += -DCONFIG_DEBUG_SPINLOCK
 endif
+
 ifeq ($(CONFIG_DEBUG_AS_WATCHPOINT),y)
 	DEFS += -DCONFIG_DEBUG_AS_WATCHPOINT
 endif
+
 ifeq ($(CONFIG_FPU_LAZY),y)
 	DEFS += -DCONFIG_FPU_LAZY
 endif
+
 ifeq ($(CONFIG_DEBUG_ALLREGS),y)
 	DEFS += -DCONFIG_DEBUG_ALLREGS
 endif
+
 ifeq ($(CONFIG_VHPT),y)
 	DEFS += -DCONFIG_VHPT
 endif
+
 ifeq ($(CONFIG_POWEROFF),y)
 	DEFS += -DCONFIG_POWEROFF
 endif
+
 ifeq ($(CONFIG_FB),y)
-ifeq ($(ARCH),ia32)
-	DEFS += -DCONFIG_VESA_WIDTH=$(CONFIG_VESA_WIDTH)
-	DEFS += -DCONFIG_VESA_HEIGHT=$(CONFIG_VESA_HEIGHT)
-	DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP)
-endif
-ifeq ($(ARCH),amd64)
-	DEFS += -DCONFIG_VESA_WIDTH=$(CONFIG_VESA_WIDTH)
-	DEFS += -DCONFIG_VESA_HEIGHT=$(CONFIG_VESA_HEIGHT)
-	DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP)
-endif
-ifeq ($(ARCH),xen32)
-	DEFS += -DCONFIG_VESA_WIDTH=$(CONFIG_VESA_WIDTH)
-	DEFS += -DCONFIG_VESA_HEIGHT=$(CONFIG_VESA_HEIGHT)
-	DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP)
-endif
+	ifeq ($(ARCH),ia32)
+		DEFS += -DCONFIG_VESA_WIDTH=$(CONFIG_VESA_WIDTH)
+		DEFS += -DCONFIG_VESA_HEIGHT=$(CONFIG_VESA_HEIGHT)
+		DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP)
+	endif
+	
+	ifeq ($(ARCH),amd64)
+		DEFS += -DCONFIG_VESA_WIDTH=$(CONFIG_VESA_WIDTH)
+		DEFS += -DCONFIG_VESA_HEIGHT=$(CONFIG_VESA_HEIGHT)
+		DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP)
+	endif
+	
+	ifeq ($(ARCH),xen32)
+		DEFS += -DCONFIG_VESA_WIDTH=$(CONFIG_VESA_WIDTH)
+		DEFS += -DCONFIG_VESA_HEIGHT=$(CONFIG_VESA_HEIGHT)
+		DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP)
+	endif
 endif
 
@@ -205,10 +202,5 @@
 
 all:
-	tools/config.py default $(NARCH)
-ifdef NARCH
- ifneq ($(ARCH), $(NARCH))
-	$(MAKE) -C . clean
- endif
-endif
+	../tools/config.py kernel.config default $(ARCH) $(COMPILER) $(CONFIG_DEBUG) $(MACHINE)
 	$(MAKE) -C . build
 
@@ -217,5 +209,5 @@
 config:
 	-rm Makefile.depend
-	tools/config.py
+	tools/config.py kernel.config
 
 -include Makefile.depend
@@ -227,7 +219,7 @@
 	-rm -f kernel.bin kernel.raw kernel.map kernel.map.pre kernel.objdump kernel.disasm generic/src/debug/real_map.bin Makefile.depend* generic/include/arch generic/include/genarch arch/$(ARCH)/_link.ld
 	find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.o' -follow -exec rm \{\} \;
-	for arch in arch/*; do \
-	    [ -e $$arch/_link.ld ] && rm $$arch/_link.ld 2>/dev/null;\
-	done;exit 0
+	for arch in arch/* ; do \
+	    [ -e $$arch/_link.ld ] && rm $$arch/_link.ld 2>/dev/null ; \
+	done ; exit 0
 
 archlinks:
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/arch/amd64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -36,18 +36,11 @@
 TOOLCHAIN_DIR = /usr/local/amd64/bin
 
-## Make some default assumptions
-#
-
-ifndef CPU
-	CPU = opteron
-endif
-
 CFLAGS += -fno-unwind-tables -m64 -mcmodel=kernel -mno-red-zone
-DEFS += -D_CPU=${CPU} -D__64_BITS__
+DEFS += -DMACHINE=$(MACHINE) -D__64_BITS__
 
 ## Accepted CPUs
 #
 
-ifeq ($(CPU),opteron)
+ifeq ($(MACHINE),opteron)
 	CFLAGS += -march=opteron
 	DEFS += -DFENCES=p4
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/arch/ia32/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -36,17 +36,10 @@
 TOOLCHAIN_DIR = /usr/local/i686/bin
 
-## Make some default assumptions
-#
-
-ifndef IA32_CPU
-	IA32_CPU = pentium4
-endif
-
-DEFS += -D_CPU=${IA32_CPU} -D__32_BITS__
+DEFS += -DMACHINE=$(MACHINE) -D__32_BITS__
 
 ## Accepted CPUs
 #
 
-ifeq ($(IA32_CPU),athlon-xp)
+ifeq ($(MACHINE),athlon-xp)
 	CFLAGS += -march=athlon-xp -mmmx -msse -m3dnow
 	DEFS += -DCONFIG_FENCES_P3
@@ -54,19 +47,19 @@
 	CONFIG_HT = n
 endif
-ifeq ($(IA32_CPU),athlon-mp)
+ifeq ($(MACHINE),athlon-mp)
 	CFLAGS += -march=athlon-mp -mmmx -msse -m3dnow
 	DEFS += -DCONFIG_FENCES_P3
 	CONFIG_HT = n
 endif
-ifeq ($(IA32_CPU),pentium3)
+ifeq ($(MACHINE),pentium3)
 	CFLAGS += -march=pentium3 -mmmx -msse
 	DEFS += -DCONFIG_FENCES_P3
 	CONFIG_HT = n
 endif
-ifeq ($(IA32_CPU),prescott)
+ifeq ($(MACHINE),prescott)
 	CFLAGS += -march=pentium4 -mfpmath=sse -mmmx -msse -msse2 -msse3
 	DEFS += -DCONFIG_FENCES_P4
 endif
-ifeq ($(IA32_CPU),pentium4)
+ifeq ($(MACHINE),pentium4)
 	CFLAGS += -march=pentium4 -mfpmath=sse -mmmx -msse -msse2
 	DEFS += -DCONFIG_FENCES_P4
Index: kernel/arch/ia64/Makefile.inc
===================================================================
--- kernel/arch/ia64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/arch/ia64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -35,7 +35,4 @@
 TARGET = ia64-pc-linux-gnu
 TOOLCHAIN_DIR = /usr/local/ia64/bin
-
-## Make some default assumptions
-#
 
 INIT0_ADDRESS = 0xe000000000400000
Index: kernel/arch/mips32/Makefile.inc
===================================================================
--- kernel/arch/mips32/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/arch/mips32/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -34,11 +34,4 @@
 TOOLCHAIN_DIR = /usr/local/mipsel/bin
 
-## Make some default assumptions
-#
-
-ifndef MIPS_MACHINE
-	MIPS_MACHINE = msim
-endif
-
 KERNEL_LOAD_ADDRESS = 0x80100000
 INIT_ADDRESS = 0x81000000
@@ -47,5 +40,5 @@
 CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss
 
-DEFS += -D__32_BITS__ -DMACHINE=${MIPS_MACHINE} -DKERNEL_LOAD_ADDRESS=${KERNEL_LOAD_ADDRESS} -DINIT_ADDRESS=${INIT_ADDRESS} -DINIT_SIZE=${INIT_SIZE}
+DEFS += -D__32_BITS__ -DMACHINE=$(MACHINE) -DKERNEL_LOAD_ADDRESS=${KERNEL_LOAD_ADDRESS} -DINIT_ADDRESS=${INIT_ADDRESS} -DINIT_SIZE=${INIT_SIZE}
 
 ## Compile with hierarchical page tables support.
@@ -64,5 +57,5 @@
 #
 
-ifeq ($(MIPS_MACHINE),indy)
+ifeq ($(MACHINE),indy)
 	# GCC 4.0.1 compiled for mipsEL has problems compiling in 
 	# BigEndian mode with the swl/swr/lwl/lwr instructions.
@@ -78,10 +71,10 @@
 	INIT_SIZE = 0
 endif
-ifeq ($(MIPS_MACHINE),lgxemul)
+ifeq ($(MACHINE),lgxemul)
 	BFD_NAME = elf32-tradlittlemips
 	BFD = binary
 	CFLAGS += -DFB_BIG_ENDIAN -DARCH_HAS_FPU -mips3
 endif
-ifeq ($(MIPS_MACHINE),bgxemul)
+ifeq ($(MACHINE),bgxemul)
 	BFD_NAME = elf32-bigmips
 	BFD = ecoff-bigmips
@@ -91,5 +84,5 @@
 	INIT_ADDRESS = 0x81800000
 endif
-ifeq ($(MIPS_MACHINE),simics)
+ifeq ($(MACHINE),simics)
 	# SIMICS 4kc emulation is broken, although for instructions
 	# that do not bother us
@@ -100,5 +93,5 @@
 	TLBCNT = 16
 endif
-ifeq ($(MIPS_MACHINE),msim)
+ifeq ($(MACHINE),msim)
 	BFD_NAME = elf32-tradlittlemips
 	BFD = binary
Index: kernel/arch/ppc32/Makefile.inc
===================================================================
--- kernel/arch/ppc32/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/arch/ppc32/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -35,7 +35,4 @@
 TARGET = ppc-linux-gnu
 TOOLCHAIN_DIR = /usr/local/ppc/bin
-
-## Make some default assumptions
-#
 
 CFLAGS += -mcpu=powerpc -msoft-float -m32
Index: kernel/arch/ppc64/Makefile.inc
===================================================================
--- kernel/arch/ppc64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/arch/ppc64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -36,7 +36,4 @@
 TOOLCHAIN_DIR = /usr/local/ppc64/bin
 
-## Make some default assumptions
-#
-
 CFLAGS += -mcpu=powerpc64 -msoft-float -m64
 AFLAGS += -a64
Index: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/arch/sparc64/Makefile.inc	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -35,7 +35,4 @@
 TARGET = sparc64-linux-gnu
 TOOLCHAIN_DIR = /usr/local/sparc64/bin
-
-## Make some default assumptions
-#
 
 CFLAGS += -mcpu=ultrasparc -m64
Index: kernel/kernel.config
===================================================================
--- kernel/kernel.config	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ kernel/kernel.config	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -8,26 +8,12 @@
 @ "ppc32" PowerPC 32-bit
 @ "ppc64" PowerPC 64-bit
-@ "sparc64" Sun UltraSPARC
+@ "sparc64" Sun UltraSPARC 64-bit
 @ "xen32" Xen 32-bit
 ! ARCH (choice)
-
-# IA32 Compiler
-@ "cross" Cross-compiler
-@ "native" Native
-! [ARCH=ia32] IA32_COMPILER (choice)
-% [ARCH=ia32] SAVEAS IA32_COMPILER COMPILER
-
-# AMD64 Compiler
-@ "cross" Cross-compiler
-@ "native" Native
-! [ARCH=amd64] AMD64_COMPILER (choice)
-% [ARCH=amd64] SAVEAS AMD64_COMPILER COMPILER
 
 # Compiler
 @ "cross" Cross-compiler
 @ "native" Native
-! [(ARCH!=amd64)&(ARCH!=ia32)] OTHER_COMPILER (choice)
-% [(ARCH!=amd64)&(ARCH!=ia32)] SAVEAS OTHER_COMPILER COMPILER
-
+! COMPILER (choice)
 
 # CPU type
@@ -37,7 +23,11 @@
 @ "athlon-mp" Athlon MP
 @ "prescott" Prescott
-! [ARCH=ia32|ARCH=xen32] IA32_CPU (choice)
+! [ARCH=ia32|ARCH=xen32] MACHINE (choice)
 
-# MIPS Machine type
+# CPU type
+@ "opteron" Opteron
+! [ARCH=amd64] MACHINE (choice)
+
+# Machine type
 @ "msim" MSIM Simulator
 @ "simics" Virtutech Simics simulator
@@ -45,11 +35,10 @@
 @ "bgxemul" GXEmul Big Endian
 @ "indy" SGI Indy
-! [ARCH=mips32] MIPS_MACHINE (choice)
+! [ARCH=mips32] MACHINE (choice)
 
 # Framebuffer support
-! [(ARCH=mips32&MIPS_MACHINE=lgxemul)|(ARCH=mips32&MIPS_MACHINE=bgxemul)|(ARCH=ia32)|(ARCH=amd64)|(ARCH=xen32)] CONFIG_FB (y/n)
+! [(ARCH=mips32&MACHINE=lgxemul)|(ARCH=mips32&MACHINE=bgxemul)|(ARCH=ia32)|(ARCH=amd64)|(ARCH=xen32)] CONFIG_FB (y/n)
 
 # Framebuffer width
-@ "320"
 @ "640"
 @ "800"
@@ -64,7 +53,4 @@
 
 # Framebuffer height
-@ "200"
-@ "240"
-@ "400"
 @ "480"
 @ "600"
@@ -85,6 +71,4 @@
 ! [(ARCH=ia32|ARCH=amd64|ARCH=xen32)&CONFIG_FB=y] CONFIG_VESA_BPP (choice)
 
-
-
 # Support for SMP
 ! [ARCH=ia32|ARCH=amd64|ARCH=xen32] CONFIG_SMP (y/n)
@@ -97,5 +81,5 @@
 
 # Lazy FPU context switching
-! [(ARCH=mips32&MIPS_MACHINE!=msim&MIPS_MACHINE!=simics)|ARCH=amd64|ARCH=ia32|ARCH=ia64|ARCH=xen32] CONFIG_FPU_LAZY (y/n)
+! [(ARCH=mips32&MACHINE!=msim&MACHINE!=simics)|ARCH=amd64|ARCH=ia32|ARCH=ia64|ARCH=xen32] CONFIG_FPU_LAZY (y/n)
 
 # Power off on halt
@@ -117,5 +101,5 @@
 
 # Use VHPT
-! [ARCH=ia64] CONFIG_VHPT (y/n)
+! [ARCH=ia64] CONFIG_VHPT (n/y)
 
 ## Run-time configuration directives
@@ -134,5 +118,5 @@
 @ [ARCH=ia32|ARCH=amd64|ARCH=ia64|ARCH=xen32] "fpu/fpu1" Intel fpu test 1
 @ [ARCH=ia32|ARCH=amd64|ARCH=xen32] "fpu/sse1" Intel Sse test 1
-@ [ARCH=mips32&MIPS_MACHINE!=msim&MIPS_MACHINE!=simics] "fpu/mips1" Mips FPU test 1
+@ [ARCH=mips32&MACHINE!=msim&MACHINE!=simics] "fpu/mips1" MIPS FPU test 1
 @ "print/print1" Printf test 1
 @ "thread/thread1" Thread test 1
@@ -140,9 +124,9 @@
 @ "mm/falloc1" Frame Allocation test 1
 @ "mm/falloc2" Frame Allocation test 2
-@ "mm/slab1" SLAB test1 - No CPU-cache
+@ "mm/slab1" SLAB test1 - No CPU cache
 @ "mm/slab2" SLAB test2 - SMP CPU cache
 @ "fault/fault1" Write to NULL (maybe page fault)
 @ "sysinfo" Sysinfo fill and dump test
 @ [ARCH=ia64] "mm/purge1" Itanium TLB purge test
-@ [ARCH=mips32] "debug/mips1" Mips breakpoint-debug test 
+@ [ARCH=mips32] "debug/mips1" MIPS breakpoint-debug test 
 ! CONFIG_TEST (choice)
Index: rnel/tools/config.py
===================================================================
--- kernel/tools/config.py	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ 	(revision )
@@ -1,494 +1,0 @@
-#!/usr/bin/env python
-"""
-Kernel configuration script
-"""
-import sys
-import os
-import re
-import commands
-
-INPUT = 'kernel.config'
-OUTPUT = 'Makefile.config'
-TMPOUTPUT = 'Makefile.config.tmp'
-
-class DefaultDialog:
-    "Wrapper dialog that tries to return default values"
-    def __init__(self, dlg):
-        self.dlg = dlg
-
-    def set_title(self,text):
-        self.dlg.set_title(text)
-        
-    def yesno(self, text, default=None):
-        if default is not None:
-            return default
-        return self.dlg.yesno(text, default)
-    def noyes(self, text, default=None):
-        if default is not None:
-            return default
-        return self.dlg.noyes(text, default)
-    
-    def choice(self, text, choices, defopt=None):
-        if defopt is not None:
-            return choices[defopt][0]
-        return self.dlg.choice(text, choices, defopt)
-
-class NoDialog:
-    def __init__(self):
-        self.printed = None
-        self.title = 'HelenOS Configuration'
-
-    def print_title(self):
-        if not self.printed:
-            sys.stdout.write("\n*** %s ***\n" % self.title)
-            self.printed = True
-
-    def set_title(self, text):
-        self.title = text
-        self.printed = False
-    
-    def noyes(self, text, default=None):
-        if not default:
-            default = 'n'
-        return self.yesno(text, default)
-    
-    def yesno(self, text, default=None):
-        self.print_title()
-        
-        if default != 'n':
-            default = 'y'
-        while 1:
-            sys.stdout.write("%s (y/n)[%s]: " % (text,default))
-            inp = sys.stdin.readline()
-            if not inp:
-                raise EOFError
-            inp = inp.strip().lower()
-            if not inp:
-                return default
-            if inp == 'y':
-                return 'y'
-            elif inp == 'n':
-                return 'n'
-
-    def _print_choice(self, text, choices, defopt):
-        sys.stdout.write('%s:\n' % text)
-        for i,(text,descr) in enumerate(choices):
-            sys.stdout.write('\t%2d. %s\n' % (i, descr))
-        if defopt is not None:
-            sys.stdout.write('Enter choice number[%d]: ' % defopt)
-        else:
-            sys.stdout.write('Enter choice number: ')
-
-    def menu(self, text, choices, button, defopt=None):
-        self.title = 'Main menu'
-        menu = []
-        for key, descr in choices:
-            txt = key + (45-len(key))*' ' + ': ' + descr
-            menu.append((key, txt))
-            
-        return self.choice(text, [button] + menu)
-        
-    def choice(self, text, choices, defopt=None):
-        self.print_title()
-        while 1:
-            self._print_choice(text, choices, defopt)
-            inp = sys.stdin.readline()
-            if not inp:
-                raise EOFError
-            if not inp.strip():
-                if defopt is not None:
-                    return choices[defopt][0]
-                continue
-            try:
-                number = int(inp.strip())
-            except ValueError:
-                continue
-            if number < 0 or number >= len(choices):
-                continue
-            return choices[number][0]
-
-
-def eof_checker(fnc):
-    def wrapper(self, *args, **kw):
-        try:
-            return fnc(self, *args, **kw)
-        except EOFError:
-            return getattr(self.bckdialog,fnc.func_name)(*args, **kw)
-    return wrapper
-
-class Dialog(NoDialog):
-    def __init__(self):
-        NoDialog.__init__(self)
-        self.dlgcmd = os.environ.get('DIALOG','dialog')
-        self.title = ''
-        self.backtitle = 'HelenOS Kernel Configuration'
-        
-        if os.system('%s --print-maxsize >/dev/null 2>&1' % self.dlgcmd) != 0:
-            raise NotImplementedError
-        
-        self.bckdialog = NoDialog()
-
-    def set_title(self,text):
-        self.title = text
-        self.bckdialog.set_title(text)
-        
-    def calldlg(self,*args,**kw):
-        "Wrapper for calling 'dialog' program"
-        indesc, outdesc = os.pipe()
-        pid = os.fork()
-        if not pid:
-            os.close(2)
-            os.dup(outdesc)
-            os.close(indesc)
-            
-            dlgargs = [self.dlgcmd,'--title',self.title,
-                       '--backtitle', self.backtitle]
-            for key,val in kw.items():
-                dlgargs.append('--'+key)
-                dlgargs.append(val)
-            dlgargs += args            
-            os.execlp(self.dlgcmd,*dlgargs)
-
-        os.close(outdesc)
-        
-        try:
-            errout = os.fdopen(indesc,'r')
-            data = errout.read()
-            errout.close()
-            pid,status = os.wait()
-        except:
-            os.system('reset') # Reset terminal
-            raise
-        
-        if not os.WIFEXITED(status):
-            os.system('reset') # Reset terminal
-            raise EOFError
-        
-        status = os.WEXITSTATUS(status)
-        if status == 255:
-            raise EOFError
-        return status,data
-        
-    def yesno(self, text, default=None):
-        if text[-1] not in ('?',':'):
-            text = text + ':'
-        width = '50'
-        height = '5'
-        if len(text) < 48:
-            text = ' '*int(((48-len(text))/2)) + text
-        else:
-            width = '0'
-            height = '0'
-        if default == 'n':
-            res,data = self.calldlg('--defaultno','--yesno',text,height,width)
-        else:
-            res,data = self.calldlg('--yesno',text,height,width)
-
-        if res == 0:
-            return 'y'
-        return 'n'
-    yesno = eof_checker(yesno)
-
-    def menu(self, text, choices, button, defopt=None):
-        self.title = 'Main menu'
-        text = text + ':'
-        width = '70'
-        height = str(8 + len(choices))
-        args = []
-        for key,val in choices:
-            args.append(key)
-            args.append(val)
-
-        kw = {}
-        if defopt:
-            kw['default-item'] = choices[defopt][0] 
-        res,data = self.calldlg('--ok-label','Change',
-                                '--extra-label',button[1],
-                                '--extra-button',
-                                '--menu',text,height,width,
-                                str(len(choices)),*args,**kw)
-        if res == 3:
-            return button[0]
-        if res == 1: # Cancel
-            sys.exit(1)
-        elif res:
-            print data
-            raise EOFError
-        return data
-    menu = eof_checker(menu)
-    
-    def choice(self, text, choices, defopt=None):
-        text = text + ':'
-        width = '50'
-        height = str(8 + len(choices))
-        args = []
-        for key,val in choices:
-            args.append(key)
-            args.append(val)
-
-        kw = {}
-        if defopt:
-            kw['default-item'] = choices[defopt][0] 
-        res,data = self.calldlg('--nocancel','--menu',text,height,width,
-                                str(len(choices)),*args, **kw)
-        if res:
-            print data
-            raise EOFError
-        return data
-    choice = eof_checker(choice)
-    
-def read_defaults(fname,defaults):
-    "Read saved values from last configuration run"
-    f = file(fname,'r')
-    for line in f:
-        res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
-        if res:
-            defaults[res.group(1)] = res.group(2)
-    f.close()
-
-def check_condition(text, defaults, asked_names):
-    seen_vars = [ x[0] for x in asked_names ]
-    ctype = 'cnf'
-    if ')|' in text or '|(' in text:
-        ctype = 'dnf'
-    
-    if ctype == 'cnf':
-        conds = text.split('&')
-    else:
-        conds = text.split('|')
-
-    for cond in conds:
-        if cond.startswith('(') and cond.endswith(')'):
-            cond = cond[1:-1]
-            
-        inside = check_inside(cond, defaults, ctype, seen_vars)
-        
-        if ctype == 'cnf' and not inside:
-            return False
-        if ctype == 'dnf' and inside:
-            return True
-
-    if ctype == 'cnf':
-        return True
-    return False
-
-def check_inside(text, defaults, ctype, seen_vars):
-    """
-    Check that the condition specified on input line is True
-
-    only CNF is supported
-    """
-    if ctype == 'cnf':
-        conds = text.split('|')
-    else:
-        conds = text.split('&')
-    for cond in conds:
-        res = re.match(r'^(.*?)(!?=)(.*)$', cond)
-        if not res:
-            raise RuntimeError("Invalid condition: %s" % cond)
-        condname = res.group(1)
-        oper = res.group(2)
-        condval = res.group(3)
-        if condname not in seen_vars:
-            varval = ''
-##             raise RuntimeError("Variable %s not defined before being asked." %\
-##                                condname)
-        elif not defaults.has_key(condname):
-            raise RuntimeError("Condition var %s does not exist: %s" % \
-                               (condname,text))
-        else:
-            varval = defaults[condname]
-        if ctype == 'cnf':
-            if oper == '=' and  condval == varval:
-                return True
-            if oper == '!=' and condval != varval:
-                return True
-        else:
-            if oper== '=' and condval != varval:
-                return False
-            if oper== '!=' and condval == varval:
-                return False
-    if ctype=='cnf':
-        return False
-    return True
-
-def parse_config(input, output, dlg, defaults={}, askonly=None):
-    "Parse configuration file and create Makefile.config on the fly"
-    def ask_the_question(dialog):
-        "Ask question based on the type of variables to ask"
-        # This is quite a hack, this thingy is written just to
-        # have access to local variables..
-        if vartype == 'y/n':
-            return dialog.yesno(comment, default)
-        elif vartype == 'n/y':
-            return dialog.noyes(comment, default)
-        elif vartype == 'choice':
-            defopt = None
-            if default is not None:
-                for i,(key,val) in enumerate(choices):
-                    if key == default:
-                        defopt = i
-                        break
-            return dialog.choice(comment, choices, defopt)
-        else:
-            raise RuntimeError("Bad method: %s" % vartype)
-
-    
-    f = file(input, 'r')
-    outf = file(output, 'w')
-
-    outf.write('#########################################\n')
-    outf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
-    outf.write('#########################################\n\n')
-
-    asked_names = []
-
-    comment = ''
-    default = None
-    choices = []
-    for line in f:
-        if line.startswith('%'):
-            res = re.match(r'^%\s*(?:\[(.*?)\])?\s*(.*)$', line)
-            if not res:
-                raise RuntimeError('Invalid command: %s' % line)
-            if res.group(1):
-                if not check_condition(res.group(1), defaults,
-                                       asked_names):
-                    continue
-            args = res.group(2).strip().split(' ')
-            cmd = args[0].lower()
-            args = args[1:]
-            if cmd == 'saveas':
-                outf.write('%s = %s\n' % (args[1],defaults[args[0]]))
-            elif cmd == 'shellcmd':
-                varname = args[0]
-                args = args[1:]
-                for i,arg in enumerate(args):
-                    if arg.startswith('$'):
-                        args[i] = defaults[arg[1:]]
-                data,status = commands.getstatusoutput(' '.join(args))
-                if status:
-                    raise RuntimeError('Error running: %s' % ' '.join(args))
-                outf.write('%s = %s\n' % (varname,data.strip()))
-            continue
-            
-        if line.startswith('!'):
-            # Ask a question
-            res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
-            if not res:
-                raise RuntimeError("Weird line: %s" % line)
-            varname = res.group(2)
-            vartype = res.group(3)
-
-            default = defaults.get(varname,None)
-            
-            if res.group(1):
-                if not check_condition(res.group(1), defaults,
-                                       asked_names):
-                    if default is not None:
-                        outf.write('#!# %s = %s\n' % (varname, default))
-                    # Clear cumulated values
-                    comment = ''
-                    default = None
-                    choices = []
-                    continue
-                
-            asked_names.append((varname,comment))
-
-            if default is None or not askonly or askonly == varname:
-                default = ask_the_question(dlg)
-            else:
-                default = ask_the_question(DefaultDialog(dlg))
-
-            outf.write('%s = %s\n' % (varname, default))
-            # Remeber the selected value
-            defaults[varname] = default
-            # Clear cumulated values
-            comment = ''
-            default = None
-            choices = []
-            continue
-        
-        if line.startswith('@'):
-            # Add new line into the 'choice array' 
-            res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
-            if not res:
-                raise RuntimeError("Bad line: %s" % line)
-            if res.group(1):
-                if not check_condition(res.group(1),defaults,
-                                       asked_names):
-                    continue
-            choices.append((res.group(2), res.group(3)))
-            continue
-
-        # All other things print to output file
-        outf.write(line)
-        if re.match(r'^#[^#]', line):
-            # Last comment before question will be displayed to the user
-            comment = line[1:].strip()
-        elif line.startswith('## '):
-            # Set title of the dialog window
-            dlg.set_title(line[2:].strip())
-
-    outf.write('\n')
-    outf.write('REVISION = %s\n' % commands.getoutput('svnversion . 2> /dev/null'))
-    outf.write('TIMESTAMP = %s\n' % commands.getoutput('date "+%Y-%m-%d %H:%M:%S"'))
-    outf.close()
-    f.close()
-    return asked_names
-
-def main():
-    defaults = {}
-    try:
-        dlg = Dialog()
-    except NotImplementedError:
-        dlg = NoDialog()
-
-    if len(sys.argv) >= 2 and sys.argv[1]=='default':
-        defmode = True
-    else:
-        defmode = False
-
-    # Default run will update the configuration file
-    # with newest options
-    if os.path.exists(OUTPUT):
-        read_defaults(OUTPUT, defaults)
-
-	# Get ARCH from command line if specified	
-    if len(sys.argv) >= 3:
-        defaults['ARCH'] = sys.argv[2]
-
-    # Dry run only with defaults
-    varnames = parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
-    # If not in default mode, present selection of all possibilities
-    if not defmode:
-        defopt = 0
-        while 1:
-            # varnames contains variable names that were in the
-            # last question set
-            choices = [ (x[1],defaults[x[0]]) for x in varnames ]
-            res = dlg.menu('Configuration',choices,('save','Save'),defopt)
-            if res == 'save':
-                parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
-                break
-            # transfer description back to varname
-            for i,(vname,descr) in enumerate(varnames):
-                if res == descr:
-                    defopt = i
-                    break
-            # Ask the user a simple question, produce output
-            # as if the user answered all the other questions
-            # with default answer
-            varnames = parse_config(INPUT, TMPOUTPUT, dlg, defaults,
-                                    askonly=varnames[i][0])
-        
-    
-    if os.path.exists(OUTPUT):
-        os.unlink(OUTPUT)
-    os.rename(TMPOUTPUT, OUTPUT)
-    
-    if not defmode and dlg.yesno('Rebuild kernel?') == 'y':
-        os.execlp('make','make','clean','build')
-
-if __name__ == '__main__':
-    main()
Index: tools/config.py
===================================================================
--- tools/config.py	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
+++ tools/config.py	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -0,0 +1,507 @@
+#!/usr/bin/env python
+"""
+HelenOS configuration script
+"""
+import sys
+import os
+import re
+import commands
+
+INPUT = sys.argv[1]
+OUTPUT = 'Makefile.config'
+TMPOUTPUT = 'Makefile.config.tmp'
+
+class DefaultDialog:
+    "Wrapper dialog that tries to return default values"
+    def __init__(self, dlg):
+        self.dlg = dlg
+
+    def set_title(self,text):
+        self.dlg.set_title(text)
+        
+    def yesno(self, text, default=None):
+        if default is not None:
+            return default
+        return self.dlg.yesno(text, default)
+    def noyes(self, text, default=None):
+        if default is not None:
+            return default
+        return self.dlg.noyes(text, default)
+    
+    def choice(self, text, choices, defopt=None):
+        if defopt is not None:
+            return choices[defopt][0]
+        return self.dlg.choice(text, choices, defopt)
+
+class NoDialog:
+    def __init__(self):
+        self.printed = None
+        self.title = 'HelenOS Configuration'
+
+    def print_title(self):
+        if not self.printed:
+            sys.stdout.write("\n*** %s ***\n" % self.title)
+            self.printed = True
+
+    def set_title(self, text):
+        self.title = text
+        self.printed = False
+    
+    def noyes(self, text, default=None):
+        if not default:
+            default = 'n'
+        return self.yesno(text, default)
+    
+    def yesno(self, text, default=None):
+        self.print_title()
+        
+        if default != 'n':
+            default = 'y'
+        while 1:
+            sys.stdout.write("%s (y/n)[%s]: " % (text,default))
+            inp = sys.stdin.readline()
+            if not inp:
+                raise EOFError
+            inp = inp.strip().lower()
+            if not inp:
+                return default
+            if inp == 'y':
+                return 'y'
+            elif inp == 'n':
+                return 'n'
+
+    def _print_choice(self, text, choices, defopt):
+        sys.stdout.write('%s:\n' % text)
+        for i,(text,descr) in enumerate(choices):
+            sys.stdout.write('\t%2d. %s\n' % (i, descr))
+        if defopt is not None:
+            sys.stdout.write('Enter choice number[%d]: ' % defopt)
+        else:
+            sys.stdout.write('Enter choice number: ')
+
+    def menu(self, text, choices, button, defopt=None):
+        self.title = 'Main menu'
+        menu = []
+        for key, descr in choices:
+            txt = key + (45-len(key))*' ' + ': ' + descr
+            menu.append((key, txt))
+            
+        return self.choice(text, [button] + menu)
+        
+    def choice(self, text, choices, defopt=None):
+        self.print_title()
+        while 1:
+            self._print_choice(text, choices, defopt)
+            inp = sys.stdin.readline()
+            if not inp:
+                raise EOFError
+            if not inp.strip():
+                if defopt is not None:
+                    return choices[defopt][0]
+                continue
+            try:
+                number = int(inp.strip())
+            except ValueError:
+                continue
+            if number < 0 or number >= len(choices):
+                continue
+            return choices[number][0]
+
+
+def eof_checker(fnc):
+    def wrapper(self, *args, **kw):
+        try:
+            return fnc(self, *args, **kw)
+        except EOFError:
+            return getattr(self.bckdialog,fnc.func_name)(*args, **kw)
+    return wrapper
+
+class Dialog(NoDialog):
+    def __init__(self):
+        NoDialog.__init__(self)
+        self.dlgcmd = os.environ.get('DIALOG','dialog')
+        self.title = ''
+        self.backtitle = 'HelenOS Configuration'
+        
+        if os.system('%s --print-maxsize >/dev/null 2>&1' % self.dlgcmd) != 0:
+            raise NotImplementedError
+        
+        self.bckdialog = NoDialog()
+
+    def set_title(self,text):
+        self.title = text
+        self.bckdialog.set_title(text)
+        
+    def calldlg(self,*args,**kw):
+        "Wrapper for calling 'dialog' program"
+        indesc, outdesc = os.pipe()
+        pid = os.fork()
+        if not pid:
+            os.close(2)
+            os.dup(outdesc)
+            os.close(indesc)
+            
+            dlgargs = [self.dlgcmd,'--title',self.title,
+                       '--backtitle', self.backtitle]
+            for key,val in kw.items():
+                dlgargs.append('--'+key)
+                dlgargs.append(val)
+            dlgargs += args            
+            os.execlp(self.dlgcmd,*dlgargs)
+
+        os.close(outdesc)
+        
+        try:
+            errout = os.fdopen(indesc,'r')
+            data = errout.read()
+            errout.close()
+            pid,status = os.wait()
+        except:
+            os.system('reset') # Reset terminal
+            raise
+        
+        if not os.WIFEXITED(status):
+            os.system('reset') # Reset terminal
+            raise EOFError
+        
+        status = os.WEXITSTATUS(status)
+        if status == 255:
+            raise EOFError
+        return status,data
+        
+    def yesno(self, text, default=None):
+        if text[-1] not in ('?',':'):
+            text = text + ':'
+        width = '50'
+        height = '5'
+        if len(text) < 48:
+            text = ' '*int(((48-len(text))/2)) + text
+        else:
+            width = '0'
+            height = '0'
+        if default == 'n':
+            res,data = self.calldlg('--defaultno','--yesno',text,height,width)
+        else:
+            res,data = self.calldlg('--yesno',text,height,width)
+
+        if res == 0:
+            return 'y'
+        return 'n'
+    yesno = eof_checker(yesno)
+
+    def menu(self, text, choices, button, defopt=None):
+        self.title = 'Main menu'
+        text = text + ':'
+        width = '70'
+        height = str(8 + len(choices))
+        args = []
+        for key,val in choices:
+            args.append(key)
+            args.append(val)
+
+        kw = {}
+        if defopt:
+            kw['default-item'] = choices[defopt][0] 
+        res,data = self.calldlg('--ok-label','Change',
+                                '--extra-label',button[1],
+                                '--extra-button',
+                                '--menu',text,height,width,
+                                str(len(choices)),*args,**kw)
+        if res == 3:
+            return button[0]
+        if res == 1: # Cancel
+            sys.exit(1)
+        elif res:
+            print data
+            raise EOFError
+        return data
+    menu = eof_checker(menu)
+    
+    def choice(self, text, choices, defopt=None):
+        text = text + ':'
+        width = '50'
+        height = str(8 + len(choices))
+        args = []
+        for key,val in choices:
+            args.append(key)
+            args.append(val)
+
+        kw = {}
+        if defopt:
+            kw['default-item'] = choices[defopt][0] 
+        res,data = self.calldlg('--nocancel','--menu',text,height,width,
+                                str(len(choices)),*args, **kw)
+        if res:
+            print data
+            raise EOFError
+        return data
+    choice = eof_checker(choice)
+    
+def read_defaults(fname,defaults):
+    "Read saved values from last configuration run"
+    f = file(fname,'r')
+    for line in f:
+        res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
+        if res:
+            defaults[res.group(1)] = res.group(2)
+    f.close()
+
+def check_condition(text, defaults, asked_names):
+    seen_vars = [ x[0] for x in asked_names ]
+    ctype = 'cnf'
+    if ')|' in text or '|(' in text:
+        ctype = 'dnf'
+    
+    if ctype == 'cnf':
+        conds = text.split('&')
+    else:
+        conds = text.split('|')
+
+    for cond in conds:
+        if cond.startswith('(') and cond.endswith(')'):
+            cond = cond[1:-1]
+            
+        inside = check_inside(cond, defaults, ctype, seen_vars)
+        
+        if ctype == 'cnf' and not inside:
+            return False
+        if ctype == 'dnf' and inside:
+            return True
+
+    if ctype == 'cnf':
+        return True
+    return False
+
+def check_inside(text, defaults, ctype, seen_vars):
+    """
+    Check that the condition specified on input line is True
+
+    only CNF is supported
+    """
+    if ctype == 'cnf':
+        conds = text.split('|')
+    else:
+        conds = text.split('&')
+    for cond in conds:
+        res = re.match(r'^(.*?)(!?=)(.*)$', cond)
+        if not res:
+            raise RuntimeError("Invalid condition: %s" % cond)
+        condname = res.group(1)
+        oper = res.group(2)
+        condval = res.group(3)
+        if condname not in seen_vars:
+            varval = ''
+##             raise RuntimeError("Variable %s not defined before being asked." %\
+##                                condname)
+        elif not defaults.has_key(condname):
+            raise RuntimeError("Condition var %s does not exist: %s" % \
+                               (condname,text))
+        else:
+            varval = defaults[condname]
+        if ctype == 'cnf':
+            if oper == '=' and  condval == varval:
+                return True
+            if oper == '!=' and condval != varval:
+                return True
+        else:
+            if oper== '=' and condval != varval:
+                return False
+            if oper== '!=' and condval == varval:
+                return False
+    if ctype=='cnf':
+        return False
+    return True
+
+def parse_config(input, output, dlg, defaults={}, askonly=None):
+    "Parse configuration file and create Makefile.config on the fly"
+    def ask_the_question(dialog):
+        "Ask question based on the type of variables to ask"
+        # This is quite a hack, this thingy is written just to
+        # have access to local variables..
+        if vartype == 'y/n':
+            return dialog.yesno(comment, default)
+        elif vartype == 'n/y':
+            return dialog.noyes(comment, default)
+        elif vartype == 'choice':
+            defopt = None
+            if default is not None:
+                for i,(key,val) in enumerate(choices):
+                    if key == default:
+                        defopt = i
+                        break
+            return dialog.choice(comment, choices, defopt)
+        else:
+            raise RuntimeError("Bad method: %s" % vartype)
+
+    
+    f = file(input, 'r')
+    outf = file(output, 'w')
+
+    outf.write('#########################################\n')
+    outf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
+    outf.write('#########################################\n\n')
+
+    asked_names = []
+
+    comment = ''
+    default = None
+    choices = []
+    for line in f:
+        if line.startswith('%'):
+            res = re.match(r'^%\s*(?:\[(.*?)\])?\s*(.*)$', line)
+            if not res:
+                raise RuntimeError('Invalid command: %s' % line)
+            if res.group(1):
+                if not check_condition(res.group(1), defaults,
+                                       asked_names):
+                    continue
+            args = res.group(2).strip().split(' ')
+            cmd = args[0].lower()
+            args = args[1:]
+            if cmd == 'saveas':
+                outf.write('%s = %s\n' % (args[1],defaults[args[0]]))
+            elif cmd == 'shellcmd':
+                varname = args[0]
+                args = args[1:]
+                for i,arg in enumerate(args):
+                    if arg.startswith('$'):
+                        args[i] = defaults[arg[1:]]
+                data,status = commands.getstatusoutput(' '.join(args))
+                if status:
+                    raise RuntimeError('Error running: %s' % ' '.join(args))
+                outf.write('%s = %s\n' % (varname,data.strip()))
+            continue
+            
+        if line.startswith('!'):
+            # Ask a question
+            res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
+            if not res:
+                raise RuntimeError("Weird line: %s" % line)
+            varname = res.group(2)
+            vartype = res.group(3)
+
+            default = defaults.get(varname,None)
+            
+            if res.group(1):
+                if not check_condition(res.group(1), defaults,
+                                       asked_names):
+                    if default is not None:
+                        outf.write('#!# %s = %s\n' % (varname, default))
+                    # Clear cumulated values
+                    comment = ''
+                    default = None
+                    choices = []
+                    continue
+                
+            asked_names.append((varname,comment))
+
+            if default is None or not askonly or askonly == varname:
+                default = ask_the_question(dlg)
+            else:
+                default = ask_the_question(DefaultDialog(dlg))
+
+            outf.write('%s = %s\n' % (varname, default))
+            # Remeber the selected value
+            defaults[varname] = default
+            # Clear cumulated values
+            comment = ''
+            default = None
+            choices = []
+            continue
+        
+        if line.startswith('@'):
+            # Add new line into the 'choice array' 
+            res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
+            if not res:
+                raise RuntimeError("Bad line: %s" % line)
+            if res.group(1):
+                if not check_condition(res.group(1),defaults,
+                                       asked_names):
+                    continue
+            choices.append((res.group(2), res.group(3)))
+            continue
+
+        # All other things print to output file
+        outf.write(line)
+        if re.match(r'^#[^#]', line):
+            # Last comment before question will be displayed to the user
+            comment = line[1:].strip()
+        elif line.startswith('## '):
+            # Set title of the dialog window
+            dlg.set_title(line[2:].strip())
+
+    outf.write('\n')
+    outf.write('REVISION = %s\n' % commands.getoutput('svnversion . 2> /dev/null'))
+    outf.write('TIMESTAMP = %s\n' % commands.getoutput('date "+%Y-%m-%d %H:%M:%S"'))
+    outf.close()
+    f.close()
+    return asked_names
+
+def main():
+    defaults = {}
+    try:
+        dlg = Dialog()
+    except NotImplementedError:
+        dlg = NoDialog()
+
+    if len(sys.argv) >= 3 and sys.argv[2]=='default':
+        defmode = True
+    else:
+        defmode = False
+
+    # Default run will update the configuration file
+    # with newest options
+    if os.path.exists(OUTPUT):
+        read_defaults(OUTPUT, defaults)
+
+	# Get ARCH from command line if specified
+    if len(sys.argv) >= 4:
+        defaults['ARCH'] = sys.argv[3]
+	
+	# Get COMPILER from command line if specified
+    if len(sys.argv) >= 5:
+        defaults['COMPILER'] = sys.argv[4]
+	
+	# Get CONFIG_DEBUG from command line if specified
+    if len(sys.argv) >= 6:
+        defaults['CONFIG_DEBUG'] = sys.argv[5]
+	
+	# Get MACHINE/IMAGE from command line if specified
+    if len(sys.argv) >= 7:
+        defaults['MACHINE'] = sys.argv[6]
+        defaults['IMAGE'] = sys.argv[6]
+
+    # Dry run only with defaults
+    varnames = parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
+    # If not in default mode, present selection of all possibilities
+    if not defmode:
+        defopt = 0
+        while 1:
+            # varnames contains variable names that were in the
+            # last question set
+            choices = [ (x[1],defaults[x[0]]) for x in varnames ]
+            res = dlg.menu('Configuration',choices,('save','Save'),defopt)
+            if res == 'save':
+                parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
+                break
+            # transfer description back to varname
+            for i,(vname,descr) in enumerate(varnames):
+                if res == descr:
+                    defopt = i
+                    break
+            # Ask the user a simple question, produce output
+            # as if the user answered all the other questions
+            # with default answer
+            varnames = parse_config(INPUT, TMPOUTPUT, dlg, defaults,
+                                    askonly=varnames[i][0])
+        
+    
+    if os.path.exists(OUTPUT):
+        os.unlink(OUTPUT)
+    os.rename(TMPOUTPUT, OUTPUT)
+    
+    if not defmode and dlg.yesno('Rebuild everything?') == 'y':
+        os.execlp('make','make','clean','build')
+
+if __name__ == '__main__':
+    main()
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ uspace/Makefile	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -30,4 +30,5 @@
 #
 
+-include ../version
 -include Makefile.config
 
@@ -48,9 +49,16 @@
 	DIRS += pci
 endif
+
 ifeq ($(ARCH), ia32)
 	DIRS += pci
 endif
 
-CFLAGS += -DCONFIG_MIPS_FPU
+ifeq ($(ARCH), mips32)
+	CFLAGS += -DCONFIG_MIPS_FPU
+endif
+
+ifeq ($(ARCH), mips32eb)
+	CFLAGS += -DCONFIG_MIPS_FPU
+endif
 
 BUILDS := $(addsuffix .build,$(DIRS))
@@ -60,14 +68,9 @@
 
 all:
-	tools/config.py default $(NARCH)
-ifdef NARCH
- ifneq ($(ARCH), $(NARCH))
-	$(MAKE) -C . clean
- endif
-endif
+	../tools/config.py uspace.config default $(ARCH) $(COMPILER) $(CONFIG_DEBUG)
 	$(MAKE) -C . build
 
 config:
-	tools/config.py
+	../tools/config.py uspace.config
 
 build: $(BUILDS)
Index: pace/tools/config.py
===================================================================
--- uspace/tools/config.py	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ 	(revision )
@@ -1,494 +1,0 @@
-#!/usr/bin/env python
-"""
-User space configuration script
-"""
-import sys
-import os
-import re
-import commands
-
-INPUT = 'uspace.config'
-OUTPUT = 'Makefile.config'
-TMPOUTPUT = 'Makefile.config.tmp'
-
-class DefaultDialog:
-    "Wrapper dialog that tries to return default values"
-    def __init__(self, dlg):
-        self.dlg = dlg
-
-    def set_title(self,text):
-        self.dlg.set_title(text)
-        
-    def yesno(self, text, default=None):
-        if default is not None:
-            return default
-        return self.dlg.yesno(text, default)
-    def noyes(self, text, default=None):
-        if default is not None:
-            return default
-        return self.dlg.noyes(text, default)
-    
-    def choice(self, text, choices, defopt=None):
-        if defopt is not None:
-            return choices[defopt][0]
-        return self.dlg.choice(text, choices, defopt)
-
-class NoDialog:
-    def __init__(self):
-        self.printed = None
-        self.title = 'HelenOS Configuration'
-
-    def print_title(self):
-        if not self.printed:
-            sys.stdout.write("\n*** %s ***\n" % self.title)
-            self.printed = True
-
-    def set_title(self, text):
-        self.title = text
-        self.printed = False
-    
-    def noyes(self, text, default=None):
-        if not default:
-            default = 'n'
-        return self.yesno(text, default)
-    
-    def yesno(self, text, default=None):
-        self.print_title()
-        
-        if default != 'n':
-            default = 'y'
-        while 1:
-            sys.stdout.write("%s (y/n)[%s]: " % (text,default))
-            inp = sys.stdin.readline()
-            if not inp:
-                raise EOFError
-            inp = inp.strip().lower()
-            if not inp:
-                return default
-            if inp == 'y':
-                return 'y'
-            elif inp == 'n':
-                return 'n'
-
-    def _print_choice(self, text, choices, defopt):
-        sys.stdout.write('%s:\n' % text)
-        for i,(text,descr) in enumerate(choices):
-            sys.stdout.write('\t%2d. %s\n' % (i, descr))
-        if defopt is not None:
-            sys.stdout.write('Enter choice number[%d]: ' % defopt)
-        else:
-            sys.stdout.write('Enter choice number: ')
-
-    def menu(self, text, choices, button, defopt=None):
-        self.title = 'Main menu'
-        menu = []
-        for key, descr in choices:
-            txt = key + (45-len(key))*' ' + ': ' + descr
-            menu.append((key, txt))
-            
-        return self.choice(text, [button] + menu)
-        
-    def choice(self, text, choices, defopt=None):
-        self.print_title()
-        while 1:
-            self._print_choice(text, choices, defopt)
-            inp = sys.stdin.readline()
-            if not inp:
-                raise EOFError
-            if not inp.strip():
-                if defopt is not None:
-                    return choices[defopt][0]
-                continue
-            try:
-                number = int(inp.strip())
-            except ValueError:
-                continue
-            if number < 0 or number >= len(choices):
-                continue
-            return choices[number][0]
-
-
-def eof_checker(fnc):
-    def wrapper(self, *args, **kw):
-        try:
-            return fnc(self, *args, **kw)
-        except EOFError:
-            return getattr(self.bckdialog,fnc.func_name)(*args, **kw)
-    return wrapper
-
-class Dialog(NoDialog):
-    def __init__(self):
-        NoDialog.__init__(self)
-        self.dlgcmd = os.environ.get('DIALOG','dialog')
-        self.title = ''
-        self.backtitle = 'HelenOS Kernel Configuration'
-        
-        if os.system('%s --print-maxsize >/dev/null 2>&1' % self.dlgcmd) != 0:
-            raise NotImplementedError
-        
-        self.bckdialog = NoDialog()
-
-    def set_title(self,text):
-        self.title = text
-        self.bckdialog.set_title(text)
-        
-    def calldlg(self,*args,**kw):
-        "Wrapper for calling 'dialog' program"
-        indesc, outdesc = os.pipe()
-        pid = os.fork()
-        if not pid:
-            os.close(2)
-            os.dup(outdesc)
-            os.close(indesc)
-            
-            dlgargs = [self.dlgcmd,'--title',self.title,
-                       '--backtitle', self.backtitle]
-            for key,val in kw.items():
-                dlgargs.append('--'+key)
-                dlgargs.append(val)
-            dlgargs += args            
-            os.execlp(self.dlgcmd,*dlgargs)
-
-        os.close(outdesc)
-        
-        try:
-            errout = os.fdopen(indesc,'r')
-            data = errout.read()
-            errout.close()
-            pid,status = os.wait()
-        except:
-            os.system('reset') # Reset terminal
-            raise
-        
-        if not os.WIFEXITED(status):
-            os.system('reset') # Reset terminal
-            raise EOFError
-        
-        status = os.WEXITSTATUS(status)
-        if status == 255:
-            raise EOFError
-        return status,data
-        
-    def yesno(self, text, default=None):
-        if text[-1] not in ('?',':'):
-            text = text + ':'
-        width = '50'
-        height = '5'
-        if len(text) < 48:
-            text = ' '*int(((48-len(text))/2)) + text
-        else:
-            width = '0'
-            height = '0'
-        if default == 'n':
-            res,data = self.calldlg('--defaultno','--yesno',text,height,width)
-        else:
-            res,data = self.calldlg('--yesno',text,height,width)
-
-        if res == 0:
-            return 'y'
-        return 'n'
-    yesno = eof_checker(yesno)
-
-    def menu(self, text, choices, button, defopt=None):
-        self.title = 'Main menu'
-        text = text + ':'
-        width = '70'
-        height = str(8 + len(choices))
-        args = []
-        for key,val in choices:
-            args.append(key)
-            args.append(val)
-
-        kw = {}
-        if defopt:
-            kw['default-item'] = choices[defopt][0] 
-        res,data = self.calldlg('--ok-label','Change',
-                                '--extra-label',button[1],
-                                '--extra-button',
-                                '--menu',text,height,width,
-                                str(len(choices)),*args,**kw)
-        if res == 3:
-            return button[0]
-        if res == 1: # Cancel
-            sys.exit(1)
-        elif res:
-            print data
-            raise EOFError
-        return data
-    menu = eof_checker(menu)
-    
-    def choice(self, text, choices, defopt=None):
-        text = text + ':'
-        width = '50'
-        height = str(8 + len(choices))
-        args = []
-        for key,val in choices:
-            args.append(key)
-            args.append(val)
-
-        kw = {}
-        if defopt:
-            kw['default-item'] = choices[defopt][0] 
-        res,data = self.calldlg('--nocancel','--menu',text,height,width,
-                                str(len(choices)),*args, **kw)
-        if res:
-            print data
-            raise EOFError
-        return data
-    choice = eof_checker(choice)
-    
-def read_defaults(fname,defaults):
-    "Read saved values from last configuration run"
-    f = file(fname,'r')
-    for line in f:
-        res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
-        if res:
-            defaults[res.group(1)] = res.group(2)
-    f.close()
-
-def check_condition(text, defaults, asked_names):
-    seen_vars = [ x[0] for x in asked_names ]
-    ctype = 'cnf'
-    if ')|' in text or '|(' in text:
-        ctype = 'dnf'
-    
-    if ctype == 'cnf':
-        conds = text.split('&')
-    else:
-        conds = text.split('|')
-
-    for cond in conds:
-        if cond.startswith('(') and cond.endswith(')'):
-            cond = cond[1:-1]
-            
-        inside = check_inside(cond, defaults, ctype, seen_vars)
-        
-        if ctype == 'cnf' and not inside:
-            return False
-        if ctype == 'dnf' and inside:
-            return True
-
-    if ctype == 'cnf':
-        return True
-    return False
-
-def check_inside(text, defaults, ctype, seen_vars):
-    """
-    Check that the condition specified on input line is True
-
-    only CNF is supported
-    """
-    if ctype == 'cnf':
-        conds = text.split('|')
-    else:
-        conds = text.split('&')
-    for cond in conds:
-        res = re.match(r'^(.*?)(!?=)(.*)$', cond)
-        if not res:
-            raise RuntimeError("Invalid condition: %s" % cond)
-        condname = res.group(1)
-        oper = res.group(2)
-        condval = res.group(3)
-        if condname not in seen_vars:
-            varval = ''
-##             raise RuntimeError("Variable %s not defined before being asked." %\
-##                                condname)
-        elif not defaults.has_key(condname):
-            raise RuntimeError("Condition var %s does not exist: %s" % \
-                               (condname,text))
-        else:
-            varval = defaults[condname]
-        if ctype == 'cnf':
-            if oper == '=' and  condval == varval:
-                return True
-            if oper == '!=' and condval != varval:
-                return True
-        else:
-            if oper== '=' and condval != varval:
-                return False
-            if oper== '!=' and condval == varval:
-                return False
-    if ctype=='cnf':
-        return False
-    return True
-
-def parse_config(input, output, dlg, defaults={}, askonly=None):
-    "Parse configuration file and create Makefile.config on the fly"
-    def ask_the_question(dialog):
-        "Ask question based on the type of variables to ask"
-        # This is quite a hack, this thingy is written just to
-        # have access to local variables..
-        if vartype == 'y/n':
-            return dialog.yesno(comment, default)
-        elif vartype == 'n/y':
-            return dialog.noyes(comment, default)
-        elif vartype == 'choice':
-            defopt = None
-            if default is not None:
-                for i,(key,val) in enumerate(choices):
-                    if key == default:
-                        defopt = i
-                        break
-            return dialog.choice(comment, choices, defopt)
-        else:
-            raise RuntimeError("Bad method: %s" % vartype)
-
-    
-    f = file(input, 'r')
-    outf = file(output, 'w')
-
-    outf.write('#########################################\n')
-    outf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
-    outf.write('#########################################\n\n')
-
-    asked_names = []
-
-    comment = ''
-    default = None
-    choices = []
-    for line in f:
-        if line.startswith('%'):
-            res = re.match(r'^%\s*(?:\[(.*?)\])?\s*(.*)$', line)
-            if not res:
-                raise RuntimeError('Invalid command: %s' % line)
-            if res.group(1):
-                if not check_condition(res.group(1), defaults,
-                                       asked_names):
-                    continue
-            args = res.group(2).strip().split(' ')
-            cmd = args[0].lower()
-            args = args[1:]
-            if cmd == 'saveas':
-                outf.write('%s = %s\n' % (args[1],defaults[args[0]]))
-            elif cmd == 'shellcmd':
-                varname = args[0]
-                args = args[1:]
-                for i,arg in enumerate(args):
-                    if arg.startswith('$'):
-                        args[i] = defaults[arg[1:]]
-                data,status = commands.getstatusoutput(' '.join(args))
-                if status:
-                    raise RuntimeError('Error running: %s' % ' '.join(args))
-                outf.write('%s = %s\n' % (varname,data.strip()))
-            continue
-            
-        if line.startswith('!'):
-            # Ask a question
-            res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
-            if not res:
-                raise RuntimeError("Weird line: %s" % line)
-            varname = res.group(2)
-            vartype = res.group(3)
-
-            default = defaults.get(varname,None)
-            
-            if res.group(1):
-                if not check_condition(res.group(1), defaults,
-                                       asked_names):
-                    if default is not None:
-                        outf.write('#!# %s = %s\n' % (varname, default))
-                    # Clear cumulated values
-                    comment = ''
-                    default = None
-                    choices = []
-                    continue
-                
-            asked_names.append((varname,comment))
-
-            if default is None or not askonly or askonly == varname:
-                default = ask_the_question(dlg)
-            else:
-                default = ask_the_question(DefaultDialog(dlg))
-
-            outf.write('%s = %s\n' % (varname, default))
-            # Remeber the selected value
-            defaults[varname] = default
-            # Clear cumulated values
-            comment = ''
-            default = None
-            choices = []
-            continue
-        
-        if line.startswith('@'):
-            # Add new line into the 'choice array' 
-            res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
-            if not res:
-                raise RuntimeError("Bad line: %s" % line)
-            if res.group(1):
-                if not check_condition(res.group(1),defaults,
-                                       asked_names):
-                    continue
-            choices.append((res.group(2), res.group(3)))
-            continue
-
-        # All other things print to output file
-        outf.write(line)
-        if re.match(r'^#[^#]', line):
-            # Last comment before question will be displayed to the user
-            comment = line[1:].strip()
-        elif line.startswith('## '):
-            # Set title of the dialog window
-            dlg.set_title(line[2:].strip())
-
-    outf.write('\n')
-    outf.write('REVISION = %s\n' % commands.getoutput('svnversion . 2> /dev/null'))
-    outf.write('TIMESTAMP = %s\n' % commands.getoutput('date "+%Y-%m-%d %H:%M:%S"'))
-    outf.close()
-    f.close()
-    return asked_names
-
-def main():
-    defaults = {}
-    try:
-        dlg = Dialog()
-    except NotImplementedError:
-        dlg = NoDialog()
-
-    if len(sys.argv) >= 2 and sys.argv[1]=='default':
-        defmode = True
-    else:
-        defmode = False
-
-    # Default run will update the configuration file
-    # with newest options
-    if os.path.exists(OUTPUT):
-        read_defaults(OUTPUT, defaults)
-
-	# Get ARCH from command line if specified	
-    if len(sys.argv) >= 3:
-        defaults['ARCH'] = sys.argv[2]
-
-    # Dry run only with defaults
-    varnames = parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
-    # If not in default mode, present selection of all possibilities
-    if not defmode:
-        defopt = 0
-        while 1:
-            # varnames contains variable names that were in the
-            # last question set
-            choices = [ (x[1],defaults[x[0]]) for x in varnames ]
-            res = dlg.menu('Configuration',choices,('save','Save'),defopt)
-            if res == 'save':
-                parse_config(INPUT, TMPOUTPUT, DefaultDialog(dlg), defaults)
-                break
-            # transfer description back to varname
-            for i,(vname,descr) in enumerate(varnames):
-                if res == descr:
-                    defopt = i
-                    break
-            # Ask the user a simple question, produce output
-            # as if the user answered all the other questions
-            # with default answer
-            varnames = parse_config(INPUT, TMPOUTPUT, dlg, defaults,
-                                    askonly=varnames[i][0])
-        
-    
-    if os.path.exists(OUTPUT):
-        os.unlink(OUTPUT)
-    os.rename(TMPOUTPUT, OUTPUT)
-    
-    if not defmode and dlg.yesno('Rebuild user space?') == 'y':
-        os.execlp('make','make','clean','build')
-
-if __name__ == '__main__':
-    main()
Index: uspace/uspace.config
===================================================================
--- uspace/uspace.config	(revision 41c4444557cd252a3e2577acb8db13800ce0d480)
+++ uspace/uspace.config	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -9,25 +9,12 @@
 @ "ppc32" PowerPC 32-bit
 @ "ppc64" PowerPC 64-bit
+@ "sparc64" Sun UltraSPARC 64-bit
 ! ARCH (choice)
 
-# IA32 Compiler
+# Compiler
 @ "cross" Cross-compiler
 @ "native" Native
-! [ARCH=ia32] IA32_COMPILER (choice)
-% [ARCH=ia32] SAVEAS IA32_COMPILER COMPILER
+! COMPILER (choice)
 
-# PPC32 Compiler
-@ "cross" Cross-compiler
-@ "native" Native
-! [ARCH=ppc32] PPC32_COMPILER (choice)
-% [ARCH=ppc32] SAVEAS PPC32_COMPILER COMPILER
-
-# PPC64 Compiler
-@ "cross" Cross-compiler
-@ "native" Native
-! [ARCH=ppc64] PPC64_COMPILER (choice)
-% [ARCH=ppc64] SAVEAS PPC64_COMPILER COMPILER
-
-# MIPS FPU support
-! [ARCH=mips32|ARCH=mips32eb] CONFIG_MIPS_FPU (n/y)
-
+# General debuging and assert checking
+! CONFIG_DEBUG (y/n)
Index: version
===================================================================
--- version	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
+++ version	(revision 41f7564e975bcef427a9a5bcbb0c12c9001f1a58)
@@ -0,0 +1,11 @@
+VERSION = 0
+PATCHLEVEL = 2
+SUBLEVEL = 0
+EXTRAVERSION = 2
+NAME = Daylight
+
+ifdef EXTRAVERSION
+	RELEASE = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL).$(EXTRAVERSION)
+else
+	RELEASE = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
+endif
