New files: specifying the callback interface.
[gedcom-parse.git] / Makefile
1 # $Id$
2 # $Name$
3
4 YACC=bison
5 LEX=flex
6
7 DMALLOC_CFLAGS=
8 DMALLOC_LOADLIBES=
9 CFLAGS=-g -W -Wall -pedantic $(DMALLOC_CFLAGS)
10 YFLAGS=--debug --defines
11 LFLAGS=-8
12 LOADLIBES=$(DMALLOC_LOADLIBES)
13
14 all:    ansel_module gedcom_parse
15
16 gedcom_parse:   standalone.o lex.gedcom_1byte_.o lex.gedcom_hilo_.o \
17                 lex.gedcom_lohi_.o gedcom.tab.o message.o multilex.o \
18                 encoding.o
19         $(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
20
21 ansel_module:
22         cd ansel && $(MAKE)
23
24 lex.gedcom_1byte_.c:    gedcom_1byte.lex gedcom.tab.h gedcom.h multilex.h \
25                         gedcom_lex_common.c encoding.h
26         $(LEX) $(LFLAGS) -Pgedcom_1byte_ gedcom_1byte.lex
27
28 lex.gedcom_hilo_.c:     gedcom_hilo.lex gedcom.tab.h gedcom.h multilex.h \
29                         gedcom_lex_common.c encoding.h
30         $(LEX) $(LFLAGS) -Pgedcom_hilo_ gedcom_hilo.lex
31
32 lex.gedcom_lohi_.c:     gedcom_lohi.lex gedcom.tab.h gedcom.h multilex.h \
33                         gedcom_lex_common.c encoding.h
34         $(LEX) $(LFLAGS) -Pgedcom_lohi_ gedcom_lohi.lex
35
36 gedcom.tab.c gedcom.tab.h:      gedcom.y gedcom.h
37         $(YACC) $(YFLAGS) --name-prefix=gedcom_ gedcom.y
38
39 .PHONY: clean
40 clean:
41         rm -f core gedcom_parse lexer_* *.o lex.gedcom_* \
42         gedcom.tab.* gedcom.output
43         cd ansel && $(MAKE) clean
44
45 # Lexer test programs
46
47 lexer_1byte:    lex.gedcom_1byte_.test.o message.o encoding.o
48         $(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
49
50 lex.gedcom_1byte_.test.o:       lex.gedcom_1byte_.c
51         $(CC) -DLEXER_TEST -c $(CPPFLAGS) $(CFLAGS) $^ -o $@
52
53 test_1byte:     lexer_1byte
54         cat t/allged.ged | ./lexer_1byte
55
56 lexer_hilo:     lex.gedcom_hilo_.test.o message.o encoding.o
57         $(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
58
59 lex.gedcom_hilo_.test.o:        lex.gedcom_hilo_.c
60         $(CC) -DLEXER_TEST -c $(CPPFLAGS) $(CFLAGS) $^ -o $@
61
62 test_hilo:      lexer_hilo
63         cat t/uhlcl.ged | ./lexer_hilo
64
65 lexer_lohi:     lex.gedcom_lohi_.test.o message.o encoding.o
66         $(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
67
68 lex.gedcom_lohi_.test.o:        lex.gedcom_lohi_.c
69         $(CC) -DLEXER_TEST -c $(CPPFLAGS) $(CFLAGS) $^ -o $@
70
71 test_lohi:      lexer_lohi
72         cat t/ulhcl.ged | ./lexer_lohi
73
74 # Test of parser
75
76 test:   all
77         @export GCONV_PATH=./ansel; \
78         for file in t/*.ged; do \
79           echo "=== testing $$file"; \
80           ./gedcom_parse -2 $$file; \
81         done
82
83 testmem:        DMALLOC_CFLAGS=-DMALLOC
84 testmem:        DMALLOC_LOADLIBES=-ldmalloc
85 testmem:        clean test