summaryrefslogtreecommitdiff
path: root/hw/Makefile
blob: 06a002d7d07e2f97f1db6fc13f44e6ae6317bc35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
NAME = neo900
SCHTOC = ../../misc/schtoc/schtoc.pl

.PHONY:		pull sync sch sort brd pdf view
.PHONY:		upload upload-all upload-pdf upload-tar upload-zip clean

#----- Repository helpers -----------------------------------------------------

pull:
		git pull
		git submodule update --init
		$(MAKE) -C kicad-libs/components

sync:
		git submodule update
		$(MAKE) -C kicad-libs/components

#----- Editing and PDF generation ---------------------------------------------

sch:
		[ -e kicad-libs ] || ln -s ../../../qi/kicad-libs .
		eeschema $(NAME).sch
		perl ./sortsheets.pl -q $(NAME).sch || \
		    { echo "sheet order changed -- run \"make sort\"" 1>&2; \
		    exit 1; }

sort:
		perl ./sortsheets.pl $(NAME).sch >_tmp && \
		    mv $(NAME).sch $(NAME).bak && mv _tmp $(NAME).sch

brd:
		pcbnew $(NAME).kicad_pcb
		sed -i '/(diff_pair_/d' $(NAME).kicad_pcb

pdf:
		$(SCHTOC) -n -z neo900.sch neo900.pdf >neo900-toc.pdf || \
		    { rm -f neo900-toc.pdf; exit 1; }

#----- Documentation ----------------------------------------------------------

view:		docdb.out
		EESHOW_VIEWER=eeshow-viewer \
		  EESHOW_PDF_VIEWER=$${EESHOW_PDF_VIEWER:-xpdf} \
		  eeshow -N 30 -d docdb.out neo900.pro

docdb.out:	docdb.in neo900_SS_*.sch
		./gendocdb.pl -c -i $^ >$@ || { rm -f $@; exit 1; }

#----- Snapshots --------------------------------------------------------------

DATE = $(shell date -u +"%Y%m%d-%H%MZ")
COMMIT = $(shell git log -1 --format='%h' -s)
PDF_NAME = neo900-$(DATE)-$(COMMIT).pdf
PDF_DIR = pub/werner/tmp/ee/pdf
TAR_NAME = neo900-$(DATE)-$(COMMIT).tar.bz2
TAR_DIR = pub/werner/tmp/ee/tar
TAR_EXTRA = kicad-libs/components/gencon.lib
ZIP_NAME = neo900-$(DATE)-$(COMMIT).zip
ZIP_DIR = pub/werner/tmp/ee/zip
ZIP_EXTRA = $(TAR_EXTRA)

upload:		upload-pdf

upload-all:	upload-pdf upload-tar upload-zip

upload-pdf:
		TZ=UTC eeplot -n -d "%{%F %T}s" HEAD:neo900.pro -o $(PDF_NAME)
		neo900 $(PDF_NAME) $(PDF_DIR)
		echo "cd $(PDF_DIR) && ln -sf $(PDF_NAME) neo900.pdf" | neo900
		rm -f $(PDF_NAME)

upload-tar:
		tar cfj $(TAR_NAME) \
		    --no-recursion --xform 's|^|neo900-$(DATE)-$(COMMIT)/|' \
		    `git ls-files` \
		    `git submodule --quiet foreach \
		    'git ls-files | sed "s|^|$$path/|"'` $(TAR_EXTRA)
		neo900 $(TAR_NAME) $(TAR_DIR)
		echo "cd $(TAR_DIR) && ln -sf $(TAR_NAME) neo900.tar.bz2" | \
		    neo900
		rm -f $(TAR_NAME)

upload-zip:
		zip $(ZIP_NAME) \
		    -nw -X \
		    `git ls-files` \
		    `git submodule --quiet foreach \
		    'git ls-files | sed "s|^|$$path/|"'` $(ZIP_EXTRA)
		neo900 $(ZIP_NAME) $(ZIP_DIR)
		echo "cd $(ZIP_DIR) && ln -sf $(ZIP_NAME) neo900.zip" | neo900
		rm -f $(ZIP_NAME)

#----- Cleanup ----------------------------------------------------------------

clean:
		rm -f _tmp
		rm -f dbdoc.out