File: Makefile

package info (click to toggle)
confetti 20120731-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 264 kB
  • ctags: 183
  • sloc: ansic: 2,404; lex: 568; yacc: 539; makefile: 123; perl: 13
file content (87 lines) | stat: -rw-r--r-- 1,745 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
CC=gcc
AR=ar
RANLIB=ranlib
LD=ld
BISON=bison -y -d 
FLEX=flex

ARFLAGS=rcv
LDFLAGS=-r
CFLAGS=-Wall -g -O0 -Werror -pedantic -std=gnu99
INCLUDE=-I.
LIB=

OBJS=confetti.o h_dump.o f_dump.o c_dump.o p_dump.o d_dump.o
PRSSRC = prscfl

all: confetti

ifdef PRSSRC
OBJS += $(PRSSRC:%=%_scan.o)
OBJS += $(PRSSRC:%=%_gram.o)

$(PRSSRC:%=%_scan.o): $(PRSSRC:%=%_gram.c)

$(PRSSRC:%=%_scan.c): $(PRSSRC:%=%.l)
	$(FLEX) -o$@ $<

$(PRSSRC:%=%_gram.c): $(PRSSRC:%=%.y)
	$(BISON) $<
	mv -f y.tab.c $@
	mv -f y.tab.h $(@:%.c=%.h)
endif

.SUFFIXES: .o.c

.c.o:
	$(CC) $(CFLAGS) $(INCLUDE) -c $<

confetti: $(OBJS)
	$(CC) -o $@ $(OBJS) $(LIB)

example: all
	$(MAKE) -C example -f Makefile all


p_dump.c: parse_source.c header_source.c

p_dump.o: p_dump.c parse_source.c header_source.c

parse_source.c: prscfg_gram.c prscfg_gram.h prscfg_scan.c
	cat prscfg_gram.h prscfg_gram.c prscfg_scan.c | \
		perl ./makec.pl \
	> $@

header_source.c: prscfg.h
	perl ./makec.pl < $< > $@

prscfg_scan.c: prscfg.l
	$(FLEX) -o$@ $<

prscfg_gram.c: prscfg.y
	$(BISON) $<
	mv -f y.tab.c $@
	mv -f y.tab.h $(@:%.c=%.h)

test: example
	@[ -d results ] || mkdir results
	@[ -d diffs ] || mkdir diffs
	@for FILE in dump default defcfg custom buffer ; do \
		printf "%-12s  ........ " $$FILE ; \
		if sh tests/$$FILE > results/$$FILE 2>results/$$FILE.errout && diff -c expected/$$FILE results/$$FILE > diffs/$$FILE ; then \
			echo ok ; \
		else \
			echo FAILED ; \
		fi ; \
	done

clean:
	rm -rf confetti $(OBJS)
	rm -rf *core y.tab.*
	rm -rf results diffs
ifdef PRSSRC
	for prs in $(PRSSRC); do rm -rf $${prs}_gram.c $${prs}_scan.c $${prs}_gram.h ; done
endif
	rm -f prscfg_gram.c prscfg_gram.h prscfg_scan.c parse_source.c header_source.c
	$(MAKE) -C example -f Makefile clean