Root/Makefile

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

Archive Download this file

Branches:
master



interactive