Root/
Source at commit 5a5bc8cbaaef2872c2e2d7cbfeab2c627721f32e created 13 years 3 months ago. By Xiangfu Liu, update the homepage to help webpage | |
---|---|
1 | # |
2 | # Makefile - Makefile of fped, the footprint editor |
3 | # |
4 | # Written 2009, 2010 by Werner Almesberger |
5 | # Copyright 2009, 2010 by 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 | PREFIX ?= /usr/local |
14 | |
15 | UPLOAD = werner@sita.openmoko.org:public_html/fped/ |
16 | |
17 | OBJS = fped.o expr.o coord.o obj.o delete.o inst.o util.o error.o \ |
18 | unparse.o file.o dump.o kicad.o postscript.o meas.o \ |
19 | layer.o overlap.o hole.o tsort.o bitset.o \ |
20 | cpp.o lex.yy.o y.tab.o \ |
21 | gui.o gui_util.o gui_style.o gui_inst.o gui_status.o gui_canvas.o \ |
22 | gui_tool.o gui_over.o gui_meas.o gui_frame.o gui_frame_drag.o |
23 | |
24 | XPMS = point.xpm delete.xpm delete_off.xpm \ |
25 | vec.xpm frame.xpm \ |
26 | line.xpm rect.xpm pad.xpm rpad.xpm hole.xpm arc.xpm circ.xpm \ |
27 | meas.xpm meas_x.xpm meas_y.xpm \ |
28 | stuff.xpm stuff_off.xpm meas_off.xpm \ |
29 | bright.xpm bright_off.xpm all.xpm all_off.xpm |
30 | |
31 | PNGS = intro-1.png intro-2.png intro-3.png intro-4.png intro-5.png \ |
32 | intro-6.png concept-inst.png |
33 | |
34 | SHELL = /bin/bash |
35 | CFLAGS_GTK = `pkg-config --cflags gtk+-2.0` |
36 | LIBS_GTK = `pkg-config --libs gtk+-2.0` |
37 | |
38 | CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \ |
39 | -Wmissing-declarations -Wno-format-zero-length |
40 | CFLAGS = -g -std=gnu99 $(CFLAGS_GTK) -DCPP='"cpp"' \ |
41 | -DSVN_VERSION='"$(SVN_VERSION)$(SVN_STATUS)"' $(CFLAGS_WARN) |
42 | SLOPPY = -Wno-unused -Wno-implicit-function-declaration \ |
43 | -Wno-missing-prototypes -Wno-missing-declarations |
44 | LDFLAGS = |
45 | LDLIBS = -lm -lfl $(LIBS_GTK) |
46 | YACC = bison -y |
47 | YYFLAGS = -v |
48 | |
49 | SVN_VERSION:=$(shell svn info -R | sed '/Last Changed Rev: /s///p;d' | \ |
50 | sort -r | sed 1q) |
51 | SVN_STATUS:=$(shell [ -z "`svn status -q`" ] || echo +) |
52 | |
53 | |
54 | # ----- Verbosity control ----------------------------------------------------- |
55 | |
56 | CPP := $(CPP) # make sure changing CC won't affect CPP |
57 | |
58 | CC_normal := $(CC) |
59 | YACC_normal := $(YACC) |
60 | LEX_normal := $(LEX) |
61 | DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG |
62 | |
63 | CC_quiet = @echo " CC " $@ && $(CC_normal) |
64 | YACC_quiet = @echo " YACC " $@ && $(YACC_normal) |
65 | LEX_quiet = @echo " LEX " $@ && $(LEX_normal) |
66 | GEN_quiet = @echo " GENERATE " $@ && |
67 | DEPEND_quiet = @$(DEPEND_normal) |
68 | |
69 | ifeq ($(V),1) |
70 | CC = $(CC_normal) |
71 | LEX = $(LEX_normal) |
72 | YACC = $(YACC_normal) |
73 | GEN = |
74 | DEPEND = $(DEPEND_normal) |
75 | else |
76 | CC = $(CC_quiet) |
77 | LEX = $(LEX_quiet) |
78 | YACC = $(YACC_quiet) |
79 | GEN = $(GEN_quiet) |
80 | DEPEND = $(DEPEND_quiet) |
81 | endif |
82 | |
83 | # ----- Rules ----------------------------------------------------------------- |
84 | |
85 | .PHONY: all dep depend clean spotless |
86 | .PHONY: install uninstall manual upload-manual |
87 | .PHONY: update montage test tests valgrind |
88 | |
89 | .SUFFIXES: .fig .xpm .ppm |
90 | |
91 | # compile and generate dependencies, based on |
92 | # http://scottmcpeak.com/autodepend/autodepend.html |
93 | |
94 | %.o: %.c |
95 | $(CC) -c $(CFLAGS) $*.c -o $*.o |
96 | $(DEPEND) $*.c | \ |
97 | sed -e \ |
98 | '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \ |
99 | -e '$${g;p;}' -e d >$*.d; \ |
100 | [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; } |
101 | |
102 | # generate 26x26 pixels icons, then drop the 1-pixel frame |
103 | |
104 | .fig.ppm: |
105 | $(GEN) fig2dev -L ppm -Z 0.32 -S 4 $< | \ |
106 | convert -crop 24x24+1+1 - - >$@; \ |
107 | [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $@; exit 1; } |
108 | |
109 | # ppmtoxpm is very chatty, so we suppress its stderr |
110 | |
111 | .ppm.xpm: |
112 | $(GEN) export TMP=_tmp$$$$; ppmcolormask white $< >$$TMP && \ |
113 | ppmtoxpm -name xpm_`basename $@ .xpm` -alphamask $$TMP \ |
114 | $< >$@ 2>/dev/null && rm -f $$TMP || \ |
115 | { rm -f $@ $$TMP; exit 1; } |
116 | |
117 | all: fped |
118 | |
119 | fped: $(OBJS) |
120 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) |
121 | |
122 | lex.yy.c: fpd.l y.tab.h |
123 | $(LEX) fpd.l |
124 | |
125 | lex.yy.o: lex.yy.c y.tab.h |
126 | $(CC) -c $(CFLAGS) $(SLOPPY) lex.yy.c |
127 | |
128 | y.tab.c y.tab.h: fpd.y |
129 | $(YACC) $(YYFLAGS) -d fpd.y |
130 | |
131 | y.tab.o: y.tab.c |
132 | $(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c |
133 | |
134 | gui_tool.o gui.o: $(XPMS:%=icons/%) |
135 | |
136 | # ----- Upload the GUI manual ------------------------------------------------- |
137 | |
138 | manual: $(XPMS:%=icons/%) |
139 | for n in $(XPMS:%.xpm=%); do \ |
140 | convert icons/$$n.xpm manual/$$n.png || exit 1; done |
141 | fig2dev -L png -S 4 manual/concept-inst.fig \ |
142 | >manual/concept-inst.png |
143 | |
144 | upload-manual: manual |
145 | scp gui.html README $(UPLOAD)/ |
146 | scp $(XPMS:%.xpm=manual/%.png) $(PNGS:%=manual/%) \ |
147 | $(UPLOAD)/manual/ |
148 | |
149 | # ----- Debugging help -------------------------------------------------------- |
150 | |
151 | montage: |
152 | montage -label %f -frame 3 __dbg????.png png:- | display - |
153 | |
154 | # ----- Dependencies ---------------------------------------------------------- |
155 | |
156 | dep depend .depend: |
157 | @echo 'no need to run "make depend" anymore' 1>&2 |
158 | |
159 | -include $(OBJS:.o=.d) |
160 | |
161 | # ----- Tests ----------------------------------------------------------------- |
162 | |
163 | test tests: all |
164 | LANG= sh -c \ |
165 | 'passed=0 && cd test && \ |
166 | for n in [a-z]*; do \ |
167 | [ $$n != core ] && SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \ |
168 | echo "Passed all $$passed tests"' |
169 | |
170 | valgrind: |
171 | VALGRIND="valgrind -q" $(MAKE) tests |
172 | |
173 | # ----- Cleanup --------------------------------------------------------------- |
174 | |
175 | clean: |
176 | rm -f $(OBJS) $(XPMS:%=icons/%) $(XPMS:%.xpm=icons/%.ppm) |
177 | rm -f lex.yy.c y.tab.c y.tab.h y.output .depend $(OBJS:.o=.d) |
178 | rm -f __dbg????.png _tmp* test/core |
179 | |
180 | spotless: clean |
181 | rm -f fped |
182 | |
183 | # ----- Install / uninstall --------------------------------------------------- |
184 | |
185 | install: all |
186 | mkdir -p $(DESTDIR)/$(PREFIX)/bin/ |
187 | install -m 755 fped $(DESTDIR)/$(PREFIX)/bin/ |
188 | |
189 | uninstall: |
190 | rm -f $(DESTDIR)/$(PREFIX)/bin/fped |
191 | |
192 | # ----- SVN update ------------------------------------------------------------ |
193 | |
194 | update: |
195 | svn update |
196 | $(MAKE) dep all |
197 |
Branches:
master