MAJORVER = 0 # 1 before my life is over, I hope :)
MINORVER = 0  
SUBLEVEL = 0
PATCHLEV = 0

#
# if you want the ram-disk device, define this to be the
# size in blocks.
#
RAMDISK = #-DRAMDISK=512

AS86	=as86 -0 -a
LD86	=ld86 -0

AS	=as
LD	=ld86
LDFLAGS	=-0 -i 
CC	=bcc $(RAMDISK)
CFLAGS	=-Wall
CPP	=$(CC) -I/usr/src/linuxmt/include -E

#
# ROOT_DEV specifies the default root-device when making the image.
# This can be either FLOPPY, /dev/xxxx or empty, in which case the
# default of /dev/hd6 is used by 'build'.
#
ROOT_DEV=FLOPPY
SWAP_DEV=/dev/hd2

#ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o
ARCHIVES=kernel/kernel.a arch/i86/kernel/akernel.a
DRIVERS =drivers/char/chr_drv.a #drivers/block/block.a
#MATH	=kernel/math/math.a
#LIBS	=lib/lib.a

.c.s:
	$(CC) $(CFLAGS) \
	-0 -nostdinc -Iinclude -S -o $*.s $<
.s.o:
	$(AS) -0 -I/usr/src/linuxmt/include -c -o $*.o $<
.S.s:
	gcc -E -traditional -o $*.s $<
.c.o:
	$(CC) $(CFLAGS) \
	-0 -nostdinc -Iinclude -c -o $*.o $<

all:	Image	

Image: arch/i86/boot/bootsect arch/i86/boot/setup arch/i86/tools/system arch/i86/tools/build
	arch/i86/tools/build arch/i86/boot/bootsect arch/i86/boot/setup arch/i86/tools/system $(ROOT_DEV) > Image
	sync

disk: Image
	dd bs=8192 if=Image of=/dev/PS0

arch/i86/tools/build: arch/i86/tools/build.c
	gcc -o arch/i86/tools/build arch/i86/tools/build.c

arch/i86/tools/system: init/main.o \
		$(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS)
	$(LD) $(LDFLAGS) init/main.o \
	$(ARCHIVES) \
	$(DRIVERS) \
	$(MATH) \
	$(LIBS) \
	-t -o arch/i86/tools/system > System.map

#kernel/math/math.a:
#	(cd kernel/math; make)

#kernel/blk_drv/blk_drv.a:
#	(cd kernel/blk_drv; make)

drivers/char/chr_drv.a:
	(cd drivers/char; make)

kernel/kernel.a:
	(cd kernel; make)

arch/i86/kernel/akernel.a:
	(cd arch/i86/kernel; make)

#mm/mm.o:
#	(cd mm; make)

#fs/fs.o:
#	(cd fs; make)

#lib/lib.a:
#	(cd lib; make)

arch/i86/boot/setup: arch/i86/boot/setup.S
	gcc -E -traditional -I/usr/src/linuxmt/include/ -o arch/i86/boot/setup.s arch/i86/boot/setup.S
	$(AS86) -o arch/i86/boot/setup.o arch/i86/boot/setup.s
	$(LD86) -s -o arch/i86/boot/setup arch/i86/boot/setup.o

arch/i86/boot/bootsect:	arch/i86/boot/bootsect.S
	gcc -E -traditional -I/usr/src/linuxmt/include/ -o arch/i86/boot/bootsect.s arch/i86/boot/bootsect.S
	$(AS86) -0 -o arch/i86/boot/bootsect.o arch/i86/boot/bootsect.s
	$(LD86) -0 -s -o arch/i86/boot/bootsect arch/i86/boot/bootsect.o

clean:
	rm -f Image System.map tmp_make core boot/bootsect boot/setup \
		boot/bootsect.s boot/setup.s
	rm -f init/*.o tools/system tools/build boot/*.o
#	(cd mm;make clean)
#	(cd fs;make clean)
	(cd kernel;make clean)
#	(cd lib;make clean)
	(cd arch/i86/kernel; make clean)

backup: clean
	(cd .. ; tar cf - linuxmt | compress - > backup.Z)
	sync

dep:
	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
	(for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done) >> tmp_make
	cp tmp_make Makefile
	(cd fs; make dep)
	(cd kernel; make dep)
	(cd mm; make dep)

### Dependencies:
