.PHONY: drc partlist

SCH=$(shell ls sch/*sch)

all: dirs drc bom clean

# hackish somewhat
dirs:
	if [ ! -e tmp ]; then mkdir tmp; fi
	if [ ! -e bom ]; then mkdir bom; fi

# i broke the makefile, (jelle)
# http://www.gnu.org/software/m4/manual/html_node/Patsubst.html
drc: $(addprefix drc/,$(patsubst %.sch,%.drc, $(notdir $(SCH))))

bom: $(addprefix bom/,$(patsubst %.sch,%.bom, $(notdir $(SCH))))

partlist: $(addprefix tmp/,$(patsubst %.sch,%.txt,$(notdir $(SCH))))
	sort $^ |uniq > $@

tmp/%.txt:	sch/%.sch
	gnetlist -g partslist3 -o $@ $^

drc/%.drc:	sch/%.sch
	gnetlist -g drc2 -o $@ $^

bom/%.bom:	sch/%.sch
	gnetlist -g partslist1 -n -o $@ $^

clean:
	if [ -e tmp ]; then rmdir tmp; fi

.PHONY: clean
