Root/Makefile.kicad

1#
2# Makefile.kicad - Makefile template for KiCAD projects
3#
4# Written 2011, 2013 by Werner Almesberger
5# Copyright 2011, 2013 Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13#
14# Define before including this template:
15#
16# NAME project name
17# VERSION "release" version number
18#
19
20ifndef TOP
21TOP = ../..
22endif
23
24PLOT_BRD = pcbnew --plot=ps --plot-fill-all-zones
25CPTX = $(TOP)/eda-tools/mlztx/cptx
26GMERGE = $(TOP)/eda-tools/fab/gmerge
27DRL2GERBER = $(TOP)/eda-tools/fab/drl2gerber
28PRETTYGERBV = $(TOP)/eda-tools/fab/prettygerbv
29POS2FAB = $(TOP)/eda-tools/fab/pos2fab
30FPDOC = PATH=$$PATH:$(TOP)/eda-tools/fab:$(TOP)/eda-tools/fpd2pdf fpdoc
31
32DIR = $(shell pwd | sed 's|.*/||')
33
34SCH=$(shell pwd)/$(NAME).sch
35BRD=$(shell pwd)/$(NAME).brd
36
37
38.PHONY: all gen generate sch brd xpdf front back clean
39.PHONY: gerber gerbv fab fab-pcb fab-smt overview
40
41all:
42        @echo "make what ? target: gen sch brd xpdf front back clean"
43        @exit 1
44
45gen generate:
46        eeschema --plot=ps $(SCH)
47        # need scripts
48
49sch:
50        eeschema $(SCH)
51
52brd:
53        pcbnew $(BRD)
54
55xpdf:
56        xpdf $(NAME).pdf
57
58front: $(NAME)-Front.ps
59        lpr $<
60
61back: $(NAME)-Back.ps
62        lpr $<
63
64# --- DIY production (toner transfer) -----------------------------------------
65
66#
67# Postscript for production of front/back layer, using the toner transfer
68# method. Note that other artwork transfer methods may require different
69# mirror settings.
70#
71# We use --ps-pads-drill-opt=none to avoid having any hole before drilling,
72# which yields the best results with a CNC drill. For manual drilling, "real"
73# would be preferrable. Do not use "small", for this created holes that are
74# larger (!) than designed.
75#
76
77%-Front.ps: %.brd
78        $(PLOT_BRD) --layers=Front --plot-mirror $<
79
80%-Back.ps: %.brd
81        $(PLOT_BRD) --layers=Back $<
82
83# --- Industrial production ---------------------------------------------------
84
85# $(call choose, basename, old-suffix, new-suffix)
86
87choose = $(if $(wildcard $(1)-$(3)), $(1)-$(3), $(1)-$(2))
88
89GERBERS = $(call choose, $(NAME),SilkS_Front.gto,F_SilkS.gto) \
90      $(call choose, $(NAME),Mask_Front.gts,F_Mask.gts) \
91      $(call choose, $(NAME),Front.gtl,F_Cu.gtl) \
92      $(call choose, $(NAME),Back.gbl,B_Cu.gbl) \
93      $(call choose, $(NAME),Mask_Back.gbs,B_Mask.gbs) \
94      $(call choose, $(NAME),PCB_Edges.gbr,Edge_Cuts.gbr) \
95      $(call choose, $(NAME),SoldP_Front.gtp,F_Paste.gtp)
96
97PCB_FILES = README-PCB $(NAME)-front.png $(NAME)-back.png \
98        $(NAME)-PCB_Edges.dxf $(NAME).drl $(GERBERS)
99
100SMT_FILES = README-SMT $(NAME)-front.png $(NAME)-bom.csv $(NAME)-pos.csv \
101        $(NAME)-footprints.pdf
102
103gerber: $(GERBERS)
104
105$(GERBERS): $(NAME).brd Makefile
106        pcbnew --plot=gerber --plot-aux-origin \
107          --layers=`pcbnew --list-layers $(BRD) | tr '\012' ,` \
108          --plot-fill-all-zones --plot-exclude-edge \
109          $(BRD)
110        $(GMERGE) $(NAME)-SilkS_Front.gto $(NAME)-Comments.gbr >_tmp \
111          || { rm -rf _tmp; exit 1; }
112        mv _tmp $(NAME)-SilkS_Front.gto
113
114fab: fab-pcb fab-smt
115
116$(NAME)-PCB_Edges.dxf: $(NAME).brd
117        pcbnew --plot=dxf --plot-aux-origin --layers=PCB_Edges $(BRD)
118
119$(NAME).drl: $(NAME).brd
120        pcbnew --drill --drill-aux-origin $(BRD)
121
122fab-pcb: $(PCB_FILES)
123        mkdir -p fab
124        tar Ccfz .. fab/$(NAME)-pcb-$(VERSION).tar.gz \
125          $(PCB_FILES:%=$(DIR)/%)
126        cd ..; zip -l $(DIR)/fab/$(NAME)-pcb-$(VERSION).zip \
127          $(PCB_FILES:%=$(DIR)/%)
128
129gerbv:
130        gerbv $(NAME)-SilkS_Front.gto \
131          $(NAME)-SoldP_Front.gtp \
132          $(NAME)-Front.gtl \
133          $(NAME)-Mask_Front.gts \
134          $(NAME)-Mask_Back.gbs \
135          $(NAME)-Back.gbl \
136          $(NAME)-PCB_Edges.gbr
137
138$(NAME)Front.pos:
139        pcbnew --pos $(BRD)
140
141%-pos.csv: %Front.pos %.cmp
142        $(POS2FAB) $^ >$@ || { rm -f "$@"; exit 1; }
143
144../bom/$(NAME)-bom.csv:
145        $(MAKE) -C ../bom $(NAME)-bom.csv
146
147%-bom.csv: ../bom/%-bom.csv
148        mv $< $@
149
150%-footprints.pdf: %.pro %.cmp %Front.pos
151        $(FPDOC) -a FIDUCIAL $< "$@" || { rm -f "$@"; exit 1; }
152
153fab-smt: $(SMT_FILES)
154        mkdir -p fab
155        tar Ccfz .. fab/$(NAME)-smt-$(VERSION).tar.gz \
156          $(SMT_FILES:%=$(DIR)/%)
157        cd ..; zip -l $(DIR)/fab/$(NAME)-smt-$(VERSION).zip \
158          $(SMT_FILES:%=$(DIR)/%)
159
160upload:
161        qippl \
162          fab/$(NAME)-pcb-$(VERSION).tar.gz \
163          fab/$(NAME)-pcb-$(VERSION).zip \
164          fab/$(NAME)-smt-$(VERSION).tar.gz \
165          fab/$(NAME)-smt-$(VERSION).zip \
166          wpan/fab
167
168# --- Overview images ---------------------------------------------------------
169
170%-Drill.gbr: %.drl
171        $(DRL2GERBER) $^ >$@ || { rm -f "$@"; exit 1; }
172
173$(NAME)-front.png: gerber $(NAME)-Drill.gbr
174        $(PRETTYGERBV) -d $(NAME)-Drill.gbr $(NAME) front \
175          $(NAME)-front.png
176
177$(NAME)-back.png: gerber $(NAME)-Drill.gbr
178        $(PRETTYGERBV) -d $(NAME)-Drill.gbr $(NAME) back \
179          $(NAME)-back.png
180
181$(NAME)-overview.png: gerber $(NAME)-Drill.gbr
182        $(PRETTYGERBV) -d $(NAME)-Drill.gbr $(NAME) all \
183          $(NAME)-overview.png
184
185overview: $(NAME)-overview.png
186        display $(NAME)-overview.png
187
188uoverview: $(NAME)-overview.png
189        qippl $(NAME)-overview.png \
190          wpan/tmp/$(NAME)-$(VERSION)-overview.png
191
192# --- Cleanup -----------------------------------------------------------------
193
194clean::
195        rm -f $(NAME)-Front.ps $(NAME)-Back.ps
196        rm -f $(NAME).drl $(NAME)-Drill.gbr
197        rm -f $(NAME)-PCB_Edges.gbr $(NAME)-PCB_Edges.dxf
198        rm -f $(NAME)-Front.gtl $(NAME)-Mask_Front.gts
199        rm -f $(NAME)-SilkS_Front.gto $(NAME)-SoldP_Front.gtp
200        rm -f $(NAME)-Back.gbl $(NAME)-Mask_Back.gbs
201        rm -f $(NAME)-SilkS_Back.gbo $(NAME)-SoldP_Back.gbp
202        rm -f $(NAME)-Comments.gbr $(NAME)-Drawings.gbr
203        rm -f $(NAME)-overview.png $(NAME)-front.png $(NAME)-back.png
204        rm -f $(NAME)Front.pos $(NAME)-pos.csv
205        rm -f $(NAME)-bom.csv $(NAME)-footprints.pdf
206
207spotless:: clean
208        rm -f '$$'savepcb.000 '$$'savepcb.brd
209        rm -f $(NAME)-cache.lib $(NAME)-cache.bak
210        rm -f $(NAME).000
211        rm -f $(NAME).net
212

Archive Download this file

Branches:
master



interactive