include ../../Mconfig
libc = ../Originals/disk/lib/libc.so.5
#libc = /lib/libc.so.5
DEFS = -DNC2=\"$(NC2)\" -DLR2=\"$(LR2)\" -DLC1=\"$(LC1)\" \
	-DLD1=\"$(LD1)\" -DLE2=\"$(LE2)\" -DDL1=\"$(DL1)\" \
	-DLM1=\"$(LM1)\" -DKVER=\"$(KVER)\"
.c.o:
	$(CC) $(CFLAGS) $(DEFS) -c $<
all:	init
	/bin/chown root.root init
	/bin/chmod 544 init
init:	init.o scsi.o $(libc)
	ld -m elf_i386 -dynamic-linker /lib/$(LD1) -o init -s \
	 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o $^ \
	 /usr/lib/crtend.o /usr/lib/crtn.o
	strip $@
scsi.o:	scsi.c
scsi.c: Makefile
	echo >$@ 'char *scsitab[] = {'
	ls /lib/modules/$(KVER)/block/x* /lib/modules/$(KVER)/scsi/*| \
	sed -e 's,.*/,,'|sort -fu|while read fn;do \
	if [ "$$fn" != sg.o -a "$$fn" != sr_mod.o -a "$$fn" != st.o ];then \
	echo "\"$$fn\"," >>$@;fi;done
	echo >>$@ '0}; int scsisize = sizeof(scsitab) / sizeof(char *) - 1;'

clean:
	rm -rf core init init.o scsi.o scsi.c
clobber:
	rm -rf scsi.c
.PHONY:	force all clean clobber
