File: Makefile

package info (click to toggle)
fped 0.0%2Br5986-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 900 kB
  • sloc: ansic: 12,009; yacc: 1,088; sh: 688; lex: 197; makefile: 132
file content (196 lines) | stat: -rw-r--r-- 5,700 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#
# Makefile - Makefile of fped, the footprint editor
#
# Written 2009, 2010 by Werner Almesberger
# Copyright 2009, 2010 by Werner Almesberger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#

PREFIX ?= /usr/local

UPLOAD = werner@sita.openmoko.org:public_html/fped/

OBJS = fped.o expr.o coord.o obj.o delete.o inst.o util.o error.o \
       unparse.o file.o dump.o kicad.o postscript.o meas.o \
       layer.o overlap.o hole.o tsort.o bitset.o \
       cpp.o lex.yy.o y.tab.o \
       gui.o gui_util.o gui_style.o gui_inst.o gui_status.o gui_canvas.o \
       gui_tool.o gui_over.o gui_meas.o gui_frame.o gui_frame_drag.o

XPMS = point.xpm delete.xpm delete_off.xpm \
       vec.xpm frame.xpm \
       line.xpm rect.xpm pad.xpm rpad.xpm hole.xpm arc.xpm circ.xpm \
       meas.xpm meas_x.xpm meas_y.xpm \
       stuff.xpm stuff_off.xpm meas_off.xpm \
       bright.xpm bright_off.xpm all.xpm all_off.xpm

PNGS = intro-1.png intro-2.png intro-3.png intro-4.png intro-5.png \
       intro-6.png concept-inst.png

SHELL = /bin/bash
CFLAGS_GTK = `pkg-config --cflags gtk+-2.0`
LIBS_GTK = `pkg-config --libs gtk+-2.0`

CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \
	      -Wmissing-declarations -Wno-format-zero-length
CFLAGS = -g -std=gnu99 $(CFLAGS_GTK) -DCPP='"cpp"' \
         -DSVN_VERSION='"$(SVN_VERSION)$(SVN_STATUS)"' $(CFLAGS_WARN)
SLOPPY = -Wno-unused -Wno-implicit-function-declaration \
	 -Wno-missing-prototypes -Wno-missing-declarations
LDFLAGS =
LDLIBS = -lm -lfl $(LIBS_GTK)
YACC = bison -y
YYFLAGS = -v

SVN_VERSION:=$(shell svn info -R | sed '/Last Changed Rev: /s///p;d' | \
    sort -r | sed 1q)
SVN_STATUS:=$(shell [ -z "`svn status -q`" ] || echo +)


# ----- Verbosity control -----------------------------------------------------

CPP := $(CPP)   # make sure changing CC won't affect CPP

CC_normal	:= $(CC)
YACC_normal	:= $(YACC)
LEX_normal	:= $(LEX)
DEPEND_normal	:= $(CPP) $(CFLAGS) -MM -MG

CC_quiet	= @echo "  CC       " $@ && $(CC_normal)
YACC_quiet	= @echo "  YACC     " $@ && $(YACC_normal)
LEX_quiet	= @echo "  LEX      " $@ && $(LEX_normal)
GEN_quiet	= @echo "  GENERATE " $@ &&
DEPEND_quiet	= @$(DEPEND_normal)

ifeq ($(V),1)
    CC		= $(CC_normal)
    LEX		= $(LEX_normal)
    YACC	= $(YACC_normal)
    GEN		=
    DEPEND	= $(DEPEND_normal)
else
    CC		= $(CC_quiet)
    LEX		= $(LEX_quiet)
    YACC	= $(YACC_quiet)
    GEN		= $(GEN_quiet)
    DEPEND	= $(DEPEND_quiet)
endif

# ----- Rules -----------------------------------------------------------------

.PHONY:		all dep depend clean spotless
.PHONY:		install uninstall manual upload-manual
.PHONY:		update montage test tests valgrind

.SUFFIXES:	.fig .xpm .ppm

# compile and generate dependencies, based on
# http://scottmcpeak.com/autodepend/autodepend.html

%.o:		%.c
		$(CC) -c $(CFLAGS) $*.c -o $*.o
		$(DEPEND) $*.c | \
		  sed -e \
		    '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/  */:\n/g;H;}' \
		    -e '$${g;p;}' -e d >$*.d; \
		  [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }

# generate 26x26 pixels icons, then drop the 1-pixel frame

.fig.ppm:
		$(GEN) fig2dev -L ppm -Z 0.32 -S 4 $< | \
		  convert -crop 24x24+1+1 - - >$@; \
		  [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $@; exit 1; }

# ppmtoxpm is very chatty, so we suppress its stderr

.ppm.xpm:
		$(GEN) export TMP=_tmp$$$$; ppmcolormask white $< >$$TMP && \
		  ppmtoxpm -name xpm_`basename $@ .xpm` -alphamask $$TMP \
		  $< >$@ 2>/dev/null && rm -f $$TMP || \
		  { rm -f $@ $$TMP; exit 1; }

all:		fped

fped:		$(OBJS)
		$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

lex.yy.c:	fpd.l y.tab.h
		$(LEX) fpd.l

lex.yy.o:	lex.yy.c y.tab.h
		$(CC) -c $(CFLAGS) $(SLOPPY) lex.yy.c

y.tab.c y.tab.h: fpd.y
		$(YACC) $(YYFLAGS) -d fpd.y

y.tab.o:	y.tab.c
		$(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c

gui_tool.o gui.o: $(XPMS:%=icons/%)

# ----- Upload the GUI manual -------------------------------------------------

manual:		$(XPMS:%=icons/%)
		for n in $(XPMS:%.xpm=%); do \
		    convert icons/$$n.xpm manual/$$n.png || exit 1; done
		fig2dev -L png -S 4 manual/concept-inst.fig \
		    >manual/concept-inst.png

upload-manual:	manual
		scp gui.html README $(UPLOAD)/
		scp $(XPMS:%.xpm=manual/%.png) $(PNGS:%=manual/%) \
		  $(UPLOAD)/manual/

# ----- Debugging help --------------------------------------------------------

montage:
		montage -label %f -frame 3 __dbg????.png png:- | display -

# ----- Dependencies ----------------------------------------------------------

dep depend .depend:
		@echo 'no need to run "make depend" anymore' 1>&2

-include $(OBJS:.o=.d)

# ----- Tests -----------------------------------------------------------------

test tests:	all
		LANG= sh -c \
		  'passed=0 && cd test && \
		  for n in [a-z]*; do \
		  [ $$n != core ] && SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
		  echo "Passed all $$passed tests"'

valgrind:
		VALGRIND="valgrind -q" $(MAKE) tests

# ----- Cleanup ---------------------------------------------------------------

clean:
		rm -f $(OBJS) $(XPMS:%=icons/%) $(XPMS:%.xpm=icons/%.ppm)
		rm -f lex.yy.c y.tab.c y.tab.h y.output .depend $(OBJS:.o=.d)
		rm -f __dbg????.png _tmp* test/core

spotless:	clean
		rm -f fped

# ----- Install / uninstall ---------------------------------------------------

install:	all
		mkdir -p $(DESTDIR)/$(PREFIX)/bin/
		install -m 755 fped $(DESTDIR)/$(PREFIX)/bin/

uninstall:
		rm -f $(DESTDIR)/$(PREFIX)/bin/fped

# ----- SVN update ------------------------------------------------------------

update:
		svn update
		$(MAKE) dep all