#  @configure_input@
version = @yard_version@

#  Scripts that will be installed
#  create_replacements is only used prior to installation.
SCRIPTS = make_root_fs check_root_fs write_rescue_disk create_loopback_file 

scripts_dest = @scripts_dest@
lib_dest = @lib_dest@
config_dest = @config_dest@


#  Paths to be filled in by configure
#  This is probably overkill
PERL = @PERL@
TAR = @TAR@
AS86 = @AS86@
LD86 = @LD86@
CP = @CP@
RM = @RM@
MKDIR = @MKDIR@
MV = @MV@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL@ -m 644

AS86_FLAGS = -0 -a
LD86_FLAGS = -0

.SUFFIXES:	.img .b
.PHONY:	clean test dist test_dist all
.DEFAULT: all

%.o: %.S
	$(AS86) $(AS86_FLAGS) -w -o $*.o $*.S

%.img: %.o
	$(LD86) $(LD86_FLAGS) -s -o $*.img $*.o

%.b: %.img
	$(DD) if=$*.img of=$*.b bs=32 skip=1

all: 
	scripts/create_replacements
	cd extras ; make bsect.b	
	@echo Now 'make install' to install the scripts and support files

install: 
	$(INSTALL) -d $(scripts_dest) $(lib_dest) $(config_dest)
	cd scripts ; $(INSTALL) -o root $(SCRIPTS) $(scripts_dest)
	cd extras ; make install
	$(INSTALL_DATA) -o root yard_utils.pl yardconfig.pm $(lib_dest)
	@echo !
	@echo !    Now installing configuration data, which may already exist.
	@echo !    Answer no if you want to preserve your existing file\(s\).
	@echo !
	$(CP) -ir Bootdisk_Contents Config.pl $(config_dest)
	$(CP) -ir Replacements $(lib_dest)
	
test:
	$(CP) -r tests/Bootdisk_Contents.errors1 Bootdisk_Contents
	$(PERL) make_root_fs.pl

dist: 
	cd extras ; $(MAKE) bsect.b
	cd doc    ; $(MAKE) docs
	$(RM) -rf yard-$(version)
	$(RM) -f ./Replacements/etc/fstab
	$(RM) -f ./Replacements/etc/lilo.conf
	$(MAKE) clean
	$(MKDIR) yard-$(version)
	$(CP) -r `cat 0_MANIFEST` yard-$(version)
	$(TAR) cvzf yard-$(version).tar.gz  yard-$(version) \
                --exclude=RCS --exclude=tests --exclude=Makefile --exclude=CVS
	$(RM) -rf yard-$(version)
	
test_dist:
	$(RM) -rf yard-$(version).tar.gz
	$(MAKE) dist
	$(RM) -rf test
	$(MKDIR) test
	$(MV) -f yard-$(version).tar.gz test
	cd test ; $(TAR) xvzf yard-$(version).tar.gz

clean:
	$(RM) -f *.log *~ *.~ .*~ *.*.~ *.OLD *.ls \#* *.bak
	$(RM) -f yard*.tar.gz 
	$(RM) -f yardconfig.pm
	$(RM) -f Config.pl Bootdisk_Contents
	$(RM) -f ./Replacements/*/*~
	cd doc ; $(MAKE) clean
	cd extras ; $(MAKE) clean
	cd scripts ; $(MAKE) clean

TAGS:
	etags --language=perl `find . -name "*.in" -print`
