#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987,1988
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# $Header:Makefile 11.0$ 
# $ACIS:Makefile 11.0$ 
# $Source: /ibm/acis/usr/sys/standatr/RCS/Makefile,v $ 
#
#
# this file (Makefile) copies (by making symbolic links in most cases)
# the reference sources from $(STANDCA) into this directory. 
# it then builds a 'makefile' from the reference $(STANDCA)/makefile
# which make will find first when it looks for a rule file.
#
LINK=-s
STANDCA=../standca
OTHER=vga.o pc_bios.o ps2utils.o pcifprint.o bootblock.o partblock.o op.o ibm8514.o ibm8514_lo.o

all .DEFAULT:
	make -f Makefile copy
	make $@

copy:
	make -f Makefile clean
	-ln ${LINK} ${STANDCA}/*.[csh]* ${STANDCA}/codes* \
		${STANDCA}/samakefile ${STANDCA}/endcheck . 2>/dev/null
	-ln ${LINK} ../ca_atr/vga.c .
	-ln ${LINK} ../ca_atr/pc_bios.c .
	-ln ${LINK} ../ca_atr/ibm8514_lo.s .
	make -f Makefile makefile samake

samake: Makefile ${STANDCA}/Makefile
	sed -e 's;-DIBMRTPC;-DATR;' -e 's;-UATR;-UIBMRTPC;' <${STANDCA}/samake >samake ; \
	chmod +x samake

# build makefile from standca makefile with appropriate changes
makefile: Makefile ${STANDCA}/Makefile
	rm -f makefile
	sed -e 's; aedtty\.o ; ;g' \
		-e 's;OTHER=.*;OTHER=${OTHER};' \
		-e 's;apa[0-9a-z_]*\.o ;;g' \
		-e 's; dma.o ; ;' \
		-e 's; monotty.o ; ;' \
		-e 's;mpel[0-9a-z_]*\.o ; ;g' \
		-e 's; egatty.o ; ;' \
		-e 's;SAUTIL=.*;& fdisk.c installboot.c;' \
		-e '/ALL=/s;boot[hf]d ; ;g' \
		-e '/install .*boot[hf]d /d' \
		-e 's; atr_dummy; clean;' \
		-e 's;  *; ;g' \
		${STANDCA}/Makefile > makefile
	sed -n '/^##/,$$s;^#;;p' Makefile >> makefile

# remove all symbolic links
unlink:
	rm -f `find . -type l -print`

clean:
	make -f Makefile unlink
	rm -f makefile samake

# the ## following (to end of the file) marks lines added to
# makefile (see above) via sed. The leading # is stripped.
## these lines are from standatr/Makefile 
#fdisk: fdisk.c utils.o err.o atox.o
#	${CC} -o fdisk -DATR fdisk.c utils.o err.o atox.o

