#
# New suffixes to be handled by the Makefile
#    .mag : layout
#    .ext : extract file
# .sim/.al: sim file for irsim simulation
#  .irsim : irsim script file
#    .irx : dummy used to run an irsim simulation
#
.SUFFIXES: .mag .ext .sim .irx .irsim

#
#  Specify the gates you want to run here
#
GATES=inv.mag 

#
# The target is irsim simulations for each
# gate
#
GATES_IRX=$(GATES:.mag=.irx)

.PHONY: all
.SILENT:

all: $(GATES_IRX)

#
# Implicit rules using pattern matching
#

%.irx: %.sim %.al %.irsim 
	echo "Starting irsim for $*..."
	irsim sky130 $*.sim $*.al -@ $*.irsim

%.ext: %.mag
	echo "Extracting layout $*..."
	./magic_cmds $* extract >> $*.log 2>&1

%.sim %.al: %.ext
	echo "Generating sim file for $*..."
	./magic_cmds $* "ext2sim alias on; ext2sim" >> $*.log 2>&1
