Root/Makefile

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

Archive Download this file

Branches:
master



interactive