Root/makefiles/Makefile.kicad

Source at commit 269b78f23fea1e7a6336f96af8f0e109bfb5cea5 created 6 years 10 months ago.
By Werner Almesberger, makefiles/Makefile.kicad: use variable TOP instead of hard-coding ../../ path
1#
2# Makefile.kicad - Makefile template for KiCAD projects
3#
4# Written 2011 by Werner Almesberger
5# Copyright 2011 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
85GERBERS = $(NAME)-SilkS_Front.gto $(NAME)-Mask_Front.gts \
86      $(NAME)-Front.gtl $(NAME)-Back.gbl $(NAME)-Mask_Back.gbs \
87      $(NAME)-PCB_Edges.gbr $(NAME)-SoldP_Front.gtp
88
89PCB_FILES = README-PCB $(NAME)-front.png $(NAME)-back.png \
90        $(NAME)-PCB_Edges.dxf $(NAME).drl $(GERBERS)
91
92SMT_FILES = README-SMT $(NAME)-front.png $(NAME)-bom.csv $(NAME)-pos.csv \
93        $(NAME)-footprints.pdf
94
95gerber: $(GERBERS)
96
97$(GERBERS): $(NAME).brd Makefile
98        pcbnew --plot=gerber --plot-aux-origin \
99          --layers=`pcbnew --list-layers $(BRD) | tr '\012' ,` \
100          --plot-fill-all-zones --plot-exclude-edge \
101          $(BRD)
102        $(GMERGE) $(NAME)-SilkS_Front.gto $(NAME)-Comments.gbr >_tmp \
103          || { rm -rf _tmp; exit 1; }
104        mv _tmp $(NAME)-SilkS_Front.gto
105
106fab: fab-pcb fab-smt
107
108$(NAME)-PCB_Edges.dxf: $(NAME).brd
109        pcbnew --plot=dxf --plot-aux-origin --layers=PCB_Edges $(BRD)
110
111$(NAME).drl: $(NAME).brd
112        pcbnew --drill --drill-aux-origin $(BRD)
113
114fab-pcb: $(PCB_FILES)
115        mkdir -p fab
116        tar Ccfz .. fab/$(NAME)-pcb-$(VERSION).tar.gz \
117          $(PCB_FILES:%=$(DIR)/%)
118        cd ..; zip -l $(DIR)/fab/$(NAME)-pcb-$(VERSION).zip \
119          $(PCB_FILES:%=$(DIR)/%)
120
121gerbv:
122        gerbv $(NAME)-SilkS_Front.gto \
123          $(NAME)-SoldP_Front.gtp \
124          $(NAME)-Front.gtl \
125          $(NAME)-Mask_Front.gts \
126          $(NAME)-Mask_Back.gbs \
127          $(NAME)-Back.gbl \
128          $(NAME)-PCB_Edges.gbr
129
130$(NAME)Front.pos:
131        pcbnew --pos $(BRD)
132
133%-pos.csv: %Front.pos %.cmp
134        $(POS2FAB) $^ >$@ || { rm -f "$@"; exit 1; }
135
136../bom/$(NAME)-bom.csv:
137        $(MAKE) -C ../bom $(NAME)-bom.csv
138
139%-bom.csv: ../bom/%-bom.csv
140        mv $< $@
141
142%-footprints.pdf: %.pro %.cmp %Front.pos
143        $(FPDOC) -a FIDUCIAL $< "$@" || { rm -f "$@"; exit 1; }
144
145fab-smt: $(SMT_FILES)
146        mkdir -p fab
147        tar Ccfz .. fab/$(NAME)-smt-$(VERSION).tar.gz \
148          $(SMT_FILES:%=$(DIR)/%)
149        cd ..; zip -l $(DIR)/fab/$(NAME)-smt-$(VERSION).zip \
150          $(SMT_FILES:%=$(DIR)/%)
151
152upload:
153        qippl \
154          fab/$(NAME)-pcb-$(VERSION).tar.gz \
155          fab/$(NAME)-pcb-$(VERSION).zip \
156          fab/$(NAME)-smt-$(VERSION).tar.gz \
157          fab/$(NAME)-smt-$(VERSION).zip \
158          wpan/fab
159
160# --- Overview images ---------------------------------------------------------
161
162%-Drill.gbr: %.drl
163        $(DRL2GERBER) $^ >$@ || { rm -f "$@"; exit 1; }
164
165$(NAME)-front.png: gerber $(NAME)-Drill.gbr
166        $(PRETTYGERBV) -d $(NAME)-Drill.gbr $(NAME) front \
167          $(NAME)-front.png
168
169$(NAME)-back.png: gerber $(NAME)-Drill.gbr
170        $(PRETTYGERBV) -d $(NAME)-Drill.gbr $(NAME) back \
171          $(NAME)-back.png
172
173$(NAME)-overview.png: gerber $(NAME)-Drill.gbr
174        $(PRETTYGERBV) -d $(NAME)-Drill.gbr $(NAME) all \
175          $(NAME)-overview.png
176
177overview: $(NAME)-overview.png
178        display $(NAME)-overview.png
179
180uoverview: $(NAME)-overview.png
181        qippl $(NAME)-overview.png \
182          wpan/tmp/$(NAME)-$(VERSION)-overview.png
183
184# --- Cleanup -----------------------------------------------------------------
185
186clean::
187        rm -f $(NAME)-Front.ps $(NAME)-Back.ps
188        rm -f $(NAME).drl $(NAME)-Drill.gbr
189        rm -f $(NAME)-PCB_Edges.gbr $(NAME)-PCB_Edges.dxf
190        rm -f $(NAME)-Front.gtl $(NAME)-Mask_Front.gts
191        rm -f $(NAME)-SilkS_Front.gto $(NAME)-SoldP_Front.gtp
192        rm -f $(NAME)-Back.gbl $(NAME)-Mask_Back.gbs
193        rm -f $(NAME)-SilkS_Back.gbo $(NAME)-SoldP_Back.gbp
194        rm -f $(NAME)-Comments.gbr $(NAME)-Drawings.gbr
195        rm -f $(NAME)-overview.png $(NAME)-front.png $(NAME)-back.png
196        rm -f $(NAME)Front.pos $(NAME)-pos.csv
197        rm -f $(NAME)-bom.csv $(NAME)-footprints.pdf
198
199spotless:: clean
200        rm -f '$$'savepcb.000 '$$'savepcb.brd
201        rm -f $(NAME)-cache.lib $(NAME)-cache.bak
202        rm -f $(NAME).000
203        rm -f $(NAME).net
204

Archive Download this file



interactive