Root/
| 1 | MASTER = db/all.equ db/all.dsc db/all.inv |
| 2 | PARTS = avx-cersmt johanson-cergp murata-grm panasonic-erj stackpole-rmcf \ |
| 3 | tdk-c yageo-cc yageo-rc |
| 4 | |
| 5 | .SECONDARY: # prevent *.cache from being automatically deleted |
| 6 | |
| 7 | .PHONY: all clean rebuild update spotless count |
| 8 | |
| 9 | all: $(MASTER) \ |
| 10 | $(PARTS:%=db/%.equ) \ |
| 11 | $(PARTS:%=db/%.inv) \ |
| 12 | $(PARTS:%=db/%.dsc) |
| 13 | |
| 14 | db/%.cache: db/%.equ |
| 15 | awk '/^#END/ { exit } /^DIGI-KEY / { print $$2 }' $< | \ |
| 16 | perl ./dk-db.pl query \ |
| 17 | `[ -r $@ ] && echo '' -i $@` >$(@)_ || \ |
| 18 | { rm -f $@ $(@)_; exit 1; } |
| 19 | mv $(@)_ $@ |
| 20 | |
| 21 | db: |
| 22 | mkdir -p db |
| 23 | |
| 24 | # |
| 25 | # We need "db" to create the directory. However, this also means that any |
| 26 | # change in the db/ directory triggers a rebuild of all.equ. This is cheap, so |
| 27 | # this is nothing but a small cosmetic issue. |
| 28 | # |
| 29 | |
| 30 | db/all.equ: db Makefile |
| 31 | for n in $(PARTS); do echo "include $$n.equ"; done >$@ |
| 32 | |
| 33 | db/all.inv: Makefile |
| 34 | for n in $(PARTS); do echo "include $$n.inv"; done >$@ |
| 35 | |
| 36 | db/all.dsc: Makefile |
| 37 | for n in $(PARTS); do echo "include $$n.dsc"; done >$@ |
| 38 | |
| 39 | db/%.equ: %.catq |
| 40 | perl ./dk-catq.pl $< >$@ || { rm -f $@; exit 1; } |
| 41 | |
| 42 | db/%.inv: db/%.cache |
| 43 | perl ./dk-db.pl inv $< >$@ || { rm -f $@; exit 1; } |
| 44 | |
| 45 | db/%.dsc: db/%.cache |
| 46 | perl ./dk-db.pl dsc $< >$@ || { rm -f $@; exit 1; } |
| 47 | |
| 48 | |
| 49 | # --- Cleanup ----------------------------------------------------------------- |
| 50 | |
| 51 | # |
| 52 | # We have various levels of cleanup: |
| 53 | # |
| 54 | # - clean: remove left-over temporary files |
| 55 | # - rebuild: remove everything that can be rebuilt from cached data |
| 56 | # - update: remove the short-lived inventory and pricing cache too |
| 57 | # - again: remove also the long-lived equivalences cache |
| 58 | # |
| 59 | # "clean" does not disturb use of the database. The run-time cost of recovering |
| 60 | # from "rebuild" is small. What takes a lot of time is "update". The additional |
| 61 | # cost of "spotless" is small again. |
| 62 | # |
| 63 | |
| 64 | clean: |
| 65 | rm -f $(PARTS:%=db/%.cache_) |
| 66 | |
| 67 | rebuild: clean |
| 68 | rm -f $(MASTER) |
| 69 | rm -f $(PARTS:%=db/%.inv) |
| 70 | rm -f $(PARTS:%=db/%.dsc) |
| 71 | |
| 72 | update: rebuild |
| 73 | rm -f $(PARTS:%=db/%.cache) |
| 74 | |
| 75 | spotless: update |
| 76 | rm -f $(PARTS:%=db/%.equ) |
| 77 | |
| 78 | count: |
| 79 | grep DIGI-KEY db/*.equ | wc -l |
| 80 |
Branches:
master
