forked from xgugeng/TSF4G
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mk
83 lines (59 loc) · 1.93 KB
/
build.mk
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
CC=gcc
AR=ar
RM=/bin/rm -f
INSTALL=cp -rpf
TDR=tdr --MMD
PREFIX?=/usr/local/tsf4g/
SOURCES?=.
CFLAGS?=-Wall -Wconversion -Wcast-qual -Wpointer-arith -Wredundant-decls -Wmissing-declarations -Werror --pipe -fno-common
ifdef debug
DEBUG_CFLAGS=-g3 -ggdb3 -DMAKE_DEBUG
else
DEBUG_CFLAGS=-O3 -DMAKE_RELEASE
endif
ifdef big
CFLAGS+=-DTSF4G_BIGENDIAN
endif
REALCC=$(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(CINC)
REALLD=$(CC) $(LDPATH)
REALAR=$(AR)
REALINSTALL=$(INSTALL)
REALTDR=$(TDR) $(TDRINC)
TYPES_HFILE=$(TYPES_TDR_FILE:.tdr=_types.h)
READER_HFILE=$(READER_TDR_FILE:.tdr=_reader.h)
READER_CFILE=$(READER_HFILE:.h=.c)
WRITER_HFILE=$(WRITER_TDR_FILE:.tdr=_writer.h)
WRITER_CFILE=$(WRITER_HFILE:.h=.c)
RE2C_CFILE=$(REFILE:.re=.c)
RE2C_HFILE=$(REFILE:.re=.h)
OFILE=$(CFILE:.c=.o) $(READER_CFILE:.c=.o) $(WRITER_CFILE:.c=.o) $(RE2C_CFILE:.c=.o)
DFILE=$(OFILE:.o=.d) $(TYPES_HFILE:.h=.h.d) $(READER_HFILE:.h=.h.d) $(READER_CFILE:.c=.c.d) $(WRITER_HFILE:.h=.h.d) $(WRITER_CFILE:.c=.c.d)
GENFILE=$(TYPES_HFILE) $(WRITER_HFILE) $(WRITER_CFILE) $(READER_HFILE) $(READER_CFILE) $(RE2C_HFILE) $(RE2C_CFILE)
.PHONY: all clean dep install tags
all:dep $(GENFILE) $(TARGET)
$(LIBRARY): $(OFILE)
$(REALAR) r $(LIBRARY) $^
$(BINARY): $(OFILE) $(DEPOFILE)
$(REALLD) -o $@ $^ $(DEPLIBS)
%.o: %.c
$(REALCC) -o $@ -MMD -c $<
$(TYPES_HFILE):$(TYPES_TDR_FILE)
$(REALTDR) -g types_h $^
$(READER_HFILE):$(READER_TDR_FILE)
$(REALTDR) -g reader_h $^
$(READER_CFILE):$(READER_TDR_FILE)
$(REALTDR) -g reader_c $^
$(WRITER_HFILE):$(WRITER_TDR_FILE)
$(REALTDR) -g writer_h $^
$(WRITER_CFILE):$(WRITER_TDR_FILE)
$(REALTDR) -g writer_c $^
%.c: %.re
re2c -c -F -t$*.h -o$*.c $<
%.h: %.re
re2c -c -F -t$*.h -o$*.c $<
tags:$(GENFILE)
find $(SOURCES) $^ -name "*.c" -or -name "*.h" | xargs ctags -a --c-types=+p+x
find $(SOURCES) $^ -name "*.h" -or -name "*.c" | cscope -Rbq
clean:
$(RM) $(TARGET) $(OFILE) $(DFILE) $(GENFILE) tags cscope.in.out cscope.po.out cscope.out
-include $(DFILE)