Root/makefiles/Makefile.kicad

Source at commit 6caa0d36ab55987c506d2d242aef978132ec6f09 created 8 years 7 months ago.
By Werner Almesberger, consolidated atben/Makefile and atusb/Makefile into common template
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
20
21PLOT_BRD = pcbnew --plot=ps_a4 --ps-pads-drill-opt=none --fill-all-zones
22CPTX = ../../eda-tools/mlztx/cptx
23GMERGE = ../../eda-tools/gerber/gmerge
24PRETTYGERBV=../../eda-tools/gerber/prettygerbv
25
26DIR = $(shell pwd | sed 's|.*/||')
27
28SCH=$(shell pwd)/$(NAME).sch
29BRD=$(shell pwd)/$(NAME).brd
30
31
32.PHONY: all gen generate sch brd xpdf front back clean
33.PHONY: gerber gerbv fab
34
35all:
36        @echo "make what ? target: gen sch brd xpdf front back clean"
37        @exit 1
38
39gen generate:
40        eeschema --plot=ps $(SCH)
41        # need scripts
42
43sch:
44        eeschema $(SCH)
45
46brd:
47        pcbnew $(BRD)
48
49xpdf:
50        xpdf $(NAME).pdf
51
52front: $(NAME)-Front.ps
53        lpr $<
54
55back: $(NAME)-Back.ps
56        lpr $<
57
58# --- DIY production (toner transfer) -----------------------------------------
59
60#
61# Postscript for production of front/back layer, using the toner transfer
62# method. Note that other artwork transfer methods may require different
63# mirror settings.
64#
65# We use --ps-pads-drill-opt=none to avoid having any hole before drilling,
66# which yields the best results with a CNC drill. For manual drilling, "real"
67# would be preferrable. Do not use "small", for this created holes that are
68# larger (!) than designed.
69#
70
71%-Front.ps: %.brd
72        $(PLOT_BRD) -l Front --mirror $<
73
74%-Back.ps: %.brd
75        $(PLOT_BRD) -l Back $<
76
77# --- Industrial production ---------------------------------------------------
78
79PCB_FILES = README-PCB $(NAME)-PCB_Edges.dxf $(NAME).drl \
80        $(NAME)-SilkS_Front.gto $(NAME)-Mask_Front.gts \
81        $(NAME)-Front.gtl $(NAME)-Back.gbl $(NAME)-Mask_Back.gbs \
82        $(NAME)-PCB_Edges.gbr
83
84gerber:
85        pcbnew --plot=gerber --origin=aux \
86          -l `pcbnew --list-layers $(BRD) | tr '\012' ,` \
87          --fill-all-zones --exclude-pcb-edge \
88          $(BRD)
89        $(GMERGE) $(NAME)-SilkS_Front.gto $(NAME)-Comments.gbr >_tmp \
90          || { rm -rf _tmp; exit 1; }
91        mv _tmp $(NAME)-SilkS_Front.gto
92
93fab: gerber
94        pcbnew --plot=dxf --origin=aux -l PCB_Edges $(BRD)
95        pcbnew --drill --origin=aux $(BRD)
96        mkdir -p fab
97        tar Ccfz .. fab/$(NAME)-pcb-$(VERSION).tar.gz \
98          $(PCB_FILES:%=$(DIR)/%)
99        cd ..; zip -l $(DIR)/fab/$(NAME)-pcb-$(VERSION).zip \
100          $(PCB_FILES:%=$(DIR)/%)
101
102gerbv:
103        gerbv $(NAME)-SilkS_Front.gto \
104          $(NAME)-SoldP_Front.gtp \
105          $(NAME)-Front.gtl \
106          $(NAME)-Mask_Front.gts \
107          $(NAME)-Mask_Back.gbs \
108          $(NAME)-Back.gbl
109
110upload:
111        qippl fab/$(NAME)-pcb-$(VERSION).tar.gz \
112          fab/$(NAME)-pcb-$(VERSION).zip wpan/fab
113
114# --- Overview images ---------------------------------------------------------
115
116overview: gerber
117        $(PRETTYGERBV) $(NAME) all overview.png
118
119uoverview: overview
120        qippl overview.png wpan/tmp/$(NAME)-$(VERSION)-overview.png
121
122# --- Cleanup -----------------------------------------------------------------
123
124clean::
125        rm -f $(NAME)-Front.ps $(NAME)-Back.ps
126        rm -f $(NAME).drl $(NAME)-PCB_Edges.gbr $(NAME)-PCB_Edges.dxf
127        rm -f $(NAME)-Front.gtl $(NAME)-Mask_Front.gts
128        rm -f $(NAME)-SilkS_Front.gto $(NAME)-SoldP_Front.gtp
129        rm -f $(NAME)-Back.gbl $(NAME)-Mask_Back.gbs
130        rm -f $(NAME)-SilkS_Back.gbo $(NAME)-SoldP_Back.gbp
131        rm -f $(NAME)-Comments.gbr $(NAME)-Drawings.gbr
132        rm -f overview.png
133
134spotless:: clean
135        rm -f '$$'savepcb.000 '$$'savepcb.brd
136        rm -f $(NAME)-cache.lib $(NAME)-cache.bak
137        rm -f $(NAME).000
138        rm -f $(NAME).net
139

Archive Download this file



interactive