################################################################
# $Id: Makefile 132 2010-08-18 10:29:03Z matutani $
################################################################

PIPO=		pipo
ICFB=		icfb
SCR_DIR=	scripts_misc

################################################################
# Setup
################################################################
setup:
	ln -s /home/vdec/lib/fujitsu65/CS200L_Technology100106/5.OPUSE_Enviroment/cs200l_layermaptable_r2.90 .
	ln -s /home/vdec/lib/fujitsu65/CS200L_Technology100106/5.OPUSE_Enviroment/cs200l_techfile_r2.90.il .
	ln -s /home/vdec/lib/fujitsu65/CS200L_Technology100106/5.OPUSE_Enviroment/cs200l_display_r2.90.drf display.drf
	rm -rf input
	mkdir input
	(cd input; ln -s ../../../cube/pr/cube.gds .)
	(cd input; ln -s ../../../ptp/pr/ptp.gds .)
	(cd input; ln -s ../../../sb4/pr/sb4.gds .)
	(cd input; ln -s ../../../CUBE_TOP/pr/CUBE_TOP.gds .)

################################################################
# Streamin all GDS files (make base)
################################################################
base: stdcell fmcell iocell frame cube ptp sb4 CUBE_TOP

cube:
	sed 's|__CELL_NAME__|./input/cube.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr
ptp:
	sed 's|__CELL_NAME__|./input/ptp.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr
sb4:
	sed 's|__CELL_NAME__|./input/sb4.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr
CUBE_TOP:
	sed 's|__CELL_NAME__|./input/CUBE_TOP.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr

stdcell:
	sed 's|__CELL_NAME__|/home/vdec/lib/fujitsu65/cs202_sc_io_lib/gds/CS202SZ/cs202sz_uc.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr
fmcell:
	sed 's|__CELL_NAME__|/home/vdec/lib/fujitsu65/cs202_sc_io_lib/gds/common/cs202_fm.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr
frame:
	sed 's|__CELL_NAME__|/home/vdec/lib/fujitsu65/frame/frames.str|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr
	sed 's|__CELL_NAME__|/home/vdec/lib/fujitsu65/frame/MB8AW4203_FRAME.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr
iocell:
	sed 's|__CELL_NAME__|/home/vdec/lib/fujitsu65/io/200806RDF_IO/RDF/lib/gds/CS202/common/cs202_io.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr

%.streamin:
	sed 's|__CELL_NAME__|$*.gds|g' $(SCR_DIR)/streamin.template > $(SCR_DIR)/streamin.scr
	$(PIPO) strmin $(SCR_DIR)/streamin.scr

%.streamout:
	sed 's|__CELL_NAME__|$*|g' $(SCR_DIR)/streamout.template > $(SCR_DIR)/streamout.scr
	$(PIPO) strmout $(SCR_DIR)/streamout.scr

################################################################
# Add frame and stream out (make CUBE_TOP.addframe)
################################################################
%.addframe: 
	sed 's|__CELL_NAME__|$*|g' $(SCR_DIR)/addframe.template > $(SCR_DIR)/addframe.scr
	sed 's|__CELL_NAME__|$*|g' $(SCR_DIR)/streamout.template > $(SCR_DIR)/streamout.scr
	MGC_CALIBRE_LAYOUT_SERVER=$(shell hostname):9189 $(ICFB) -log icfb_$*.log -replay $(SCR_DIR)/addframe.scr &


%.open: 
	sed 's|__CELL_NAME__|$*|g' $(SCR_DIR)/open.template > $(SCR_DIR)/open.scr
	MGC_CALIBRE_LAYOUT_SERVER=$(shell hostname):9189 $(ICFB) icfb_$*.log -replay $(SCR_DIR)/open.scr &

%.clean:
	rm -rf ./CS202/$*_*

################################################################
# Removed unused files
################################################################
clean: 
	rm -f PIPO.LOG pipo_xout_info icfb_*.log
	rm -f $(SCR_DIR)/streamin.scr
	rm -f $(SCR_DIR)/streamout.scr
	rm -f $(SCR_DIR)/addframe.scr
	rm -f $(SCR_DIR)/open.scr
allclean:
	make clean
	rm -rf CS202 input
	rm -f  CUBE_TOP.gds cds.lib
	rm -f  cs200l_layermaptable_r2.90 cs200l_techfile_r2.90.il display.drf

################################################################
