#
# arch/i386/boot-gas/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License.  See the file "COPYING" in the main directory of this archive
# for more details.
#
# Copyright (C) 1994 by Linus Torvalds
#

BOOT_INCL =	$(TOPDIR)/include/linux/config.h \
		$(TOPDIR)/include/linux/autoconf.h \
		$(TOPDIR)/include/asm/boot.h

zImage: $(CONFIGURE) bootsect setup compressed/vmlinux tools/build
	$(OBJCOPY) compressed/vmlinux compressed/vmlinux.out
	tools/build -B bootsect setup compressed/vmlinux.out $(ROOT_DEV) > zImage

bzImage: $(CONFIGURE) bbootsect bsetup compressed/bvmlinux tools/build
	$(OBJCOPY) compressed/bvmlinux compressed/bvmlinux.out
	tools/build -B -b bbootsect bsetup compressed/bvmlinux.out $(ROOT_DEV) > bzImage

compressed/vmlinux: $(TOPDIR)/vmlinux
	@$(MAKE) -C compressed vmlinux

compressed/bvmlinux: $(TOPDIR)/vmlinux
	@$(MAKE) -C compressed bvmlinux

zdisk: $(BOOTIMAGE)
	dd bs=8192 if=$(BOOTIMAGE) of=/dev/fd0

zlilo: $(CONFIGURE) $(BOOTIMAGE)
	if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
	if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
	cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
	cp $(TOPDIR)/System.map $(INSTALL_PATH)/
	if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi

install: $(CONFIGURE) $(BOOTIMAGE)
	sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map "$(INSTALL_PATH)"

tools/build: tools/build.c
	$(HOSTCC) $(HOSTCFLAGS) -o $@ $< -I$(TOPDIR)/include

setup.o: setup.S video.S Makefile $(BOOT_INCL) $(TOPDIR)/include/linux/version.h 
	$(CC) $(AFLAGS)  $(SVGA_MODE) $(RAMDISK) -c -o $@ $<

setup: setup.o
	$(LD) -N -Ttext 0 $< -o $@.exec
	$(OBJCOPY) $@.exec $@

bsetup.o: setup.S video.S Makefile $(BOOT_INCL) $(TOPDIR)/include/linux/version.h
	$(CC) $(AFLAGS) -D__BIG_KERNEL__ $(SVGA_MODE) $(RAMDISK) -c -o $@ $<

bsetup: bsetup.o
	$(LD) -N -Ttext 0 $< -o $@.exec
	$(OBJCOPY) $@.exec $@

bootsect.o: bootsect.S Makefile $(BOOT_INCL)
	$(CC) $(AFLAGS) $(SVGA_MODE) $(RAMDISK) -c -o $@ $<

bootsect: bootsect.o
	$(LD) -N -Ttext 0 $< -o $@.exec
	$(OBJCOPY) $@.exec $@

bbootsect.o: bootsect.S Makefile $(BOOT_INCL)
	$(CC) $(AFLAGS) -D__BIG_KERNEL__ $(SVGA_MODE) $(RAMDISK) -c -o $@ $<

bbootsect: bbootsect.o
	$(LD) -N -Ttext 0 $< -o $@.exec
	$(OBJCOPY) $@.exec $@

dep:

clean:
	rm -f tools/build
	rm -f setup setup.exec bootsect bootsect.exec zImage compressed/vmlinux.out
	rm -f bsetup bsetup.exec bbootsect bbootsect.exec bzImage compressed/bvmlinux.out
	@$(MAKE) -C compressed clean
