forked from aressky/TSF4G
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mk
75 lines (54 loc) · 1.73 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
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
ifdef debug
DEBUG_CFLAGS=-g -ggdb -DMAKE_DEBUG
else
DEBUG_CFLAGS=-O3 -DMAKE_RELEASE
endif
REALCC=$(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(CINC)
REALLD=$(CC) $(LDPATH)
REALAR=$(AR)
REALINSTALL=$(INSTALL)
REALTDR=$(TDR) $(TDRINC)
SQL_FILE=$(SQL_TDR_FILE:.tdr=_tables.sql)
TYPES_HFILE=$(TYPES_TDR_FILE:.tdr=_types.h)
READER_HFILE=$(READER_TDR_FILE:.tdr=_reader.h)
READER_CFILE=$(READER_HFILE:.h=.c)
READER_OFILE=$(READER_HFILE:.h=.o)
WRITER_HFILE=$(WRITER_TDR_FILE:.tdr=_writer.h)
WRITER_CFILE=$(WRITER_HFILE:.h=.c)
WRITER_OFILE=$(WRITER_HFILE:.h=.o)
OFILE=$(CFILE:.c=.o) $(READER_CFILE:.c=.o) $(WRITER_CFILE:.c=.o)
GENFILE=$(SQL_FILE) $(TYPES_HFILE) $(WRITER_HFILE) $(WRITER_CFILE) $(READER_HFILE) $(READER_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 $<
$(SQL_FILE):$(SQL_TDR_FILE)
$(REALTDR) -g sql $^
$(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 $^
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)