USCHS=	OSDCU_01.usch OSDCU_02.usch OSDCU_03.usch OSDCU_04.usch OSDCU_05.usch \
	OSDCU_06.usch OSDCU_07.usch OSDCU_08.usch OSDCU_09.usch OSDCU_10.usch \
	OSDCU_11.usch
BOMS=	OSDCU-AA.bom OSDCU-AB.bom OSDCU-FPGA.bom
SCHEMPROD=	OSDCU_schem.ps OSDCU_schem.pdf OSDCU.net OSDCU.pinlist

all:
	@echo  'Unfortunately the EDA technology is not at the point where one'
	@echo  'can go from a schematic source to gerbers with a single make'
	@echo  'command.  There are, however, a few documentation items that'
	@echo  'can be generated from others through a dependency chain.  The'
	@echo  'following make targets are available:'
	@echo
	@echo  'OSDCU_schem.ps		Printable schematics in PostScript'
	@echo  'OSDCU_schem.pdf		PDF version of the above'
	@echo  'OSDCU.net		Netlist'
	@echo  'OSDCU.pinlist		An inverted version of the above'
	@echo  'bom			Bill of Materials in several formats'
	@echo  'elements.pcb		Bundle of PCB footprints for handing'
	@echo  'elements.tar.Z		  to the layout person'
	@echo  'unix			Everything that can be built from the'
	@echo  'linux			  sources on respective host systems'

.SUFFIXES:	.usch .ps .pdf

OSDCU_schem.ps: ${USCHS} MCL
	uschem-print -m 36 ${USCHS} > $@

.usch.ps:
	uschem-print -m 36 $*.usch > $@

.ps.pdf:
	ps2pdf $*.ps

OSDCU.net:	${USCHS} MCL
	uschem-netlist -cs -o $@ ${USCHS}

OSDCU.pinlist:	${USCHS} MCL
	uschem-netlist -Opinlist -o $@ ${USCHS}

${SCHEMPROD}:	symbols/EPF10K30ATC144.pinout

bom:	${BOMS} shortbom.txt shortbom.ps

OSDCU-AA.bom:	MCL
	ueda-mkbom -c -p0,1 > $@

OSDCU-AB.bom:	MCL
	ueda-mkbom -p0 > $@

OSDCU-FPGA.bom:	MCL
	ueda-mkbom -p1 > $@

shortbom.txt:	MCL
	ueda-shortbom -pall > $@

shortbom.ps:	MCL
	ueda-shortbom -pall -t > tabbed.bom.temp
	soelim shortbom.troff.template | tbl | pstroff -ms > $@
	@rm -f tabbed.bom.temp

elements.pcb:	MCL
	ueda-getfps -c | ueda-runm4 > $@

elements.d:	elements.pcb
	-rm -rf $@
	mkdir $@
	cd $@; ueda-cutelements ../elements.pcb

elements.tar.Z:	elements.d
	tar cf - elements.d | compress > $@

drc:
	uschem-check -ms ${USCHS}

unix:	${SCHEMPROD} ${BOMS} shortbom.txt shortbom.ps elements.tar.Z
linux:	${SCHEMPROD} ${BOMS} shortbom.txt

clean:
	rm -f OSDCU_schem.* OSDCU.net OSDCU.pinlist
	rm -f ${BOMS} shortbom.txt shortbom.ps
	rm -rf elements.*
