-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
108 lines (91 loc) · 2.96 KB
/
Makefile
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
INCLUDE = -Isysport/ \
-Icompression/ \
-Icompression/liblzf/ \
-Icompression/zlib/ \
-Icompression/lzma/ \
-Icompression/huffman/
DEFAULT_CC = /usr/bin/gcc
DEFAULT_DEFINE = -DZ_PREFIX
#DEFAULT_ARCHFLAGS = -m64
DEFAULT_CFLAGS = -Wall -Wextra -fPIC $(INCLUDE) $(DEFAULT_DEFINE) \
$(DEFAULT_ARCHFLAGS)
PREFIX = /usr/local
OPTFLAGS = -fast -msse -DNDEBUG
DEBUGFLAGS = -O0 -g -DDEBUG
PGO1FLAGS = $(OPTFLAGS) -fprofile-generate
PGO2FLAGS = $(OPTFLAGS) -fprofile-use
SRCFILES := gtb-probe.c gtb-dec.c gtb-att.c sysport/sysport.c \
compression/wrap.c compression/huffman/hzip.c \
compression/lzma/LzmaEnc.c compression/lzma/LzmaDec.c \
compression/lzma/Alloc.c compression/lzma/LzFind.c \
compression/lzma/Lzma86Enc.c compression/lzma/Lzma86Dec.c \
compression/lzma/Bra86.c compression/zlib/zcompress.c \
compression/zlib/uncompr.c compression/zlib/inflate.c \
compression/zlib/deflate.c compression/zlib/adler32.c \
compression/zlib/crc32.c compression/zlib/infback.c \
compression/zlib/inffast.c compression/zlib/inftrees.c \
compression/zlib/trees.c compression/zlib/zutil.c \
compression/liblzf/lzf_c.c compression/liblzf/lzf_d.c
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
PROFFILES := $(SRCFILES:.c=.gcno) $(SRCFILES:.c=.gcda)
LIBNAME := libgtb.a
SONAME :=libgtb.so
SOVERSION := 1.0.1
SOMAJORVERSION := 1
.PHONY: all clean
.DEFAULT_GOAL := all
all:
$(MAKE) $(LIBNAME) \
CC='$(DEFAULT_CC)' \
ARCHFLAGS='$(DEFAULT_ARCHFLAGS)' \
DEFINE='$(DEFAULT_DEFINE)' \
CFLAGS='$(OPPTFLAGS) $(DEFAULT_CFLAGS)'
$(MAKE) $(SONAME) \
CC='$(DEFAULT_CC)' \
ARCHFLAGS='$(DEFAULT_ARCHFLAGS)' \
DEFINE='$(DEFAULT_DEFINE)' \
CFLAGS='$(OPPTFLAGS) $(DEFAULT_CFLAGS)'
$(LIBNAME): $(OBJFILES)
$(AR) rcs $@ $(OBJFILES)
$(SONAME): $(OBJFILES)
$(CC) -shared $(OBJFILES) -Wl,-soname=$(SONAME).$(SOMAJORVERSION) -o $(SONAME).$(SOVERSION)
opt:
$(MAKE) $(LIBNAME) \
CC='$(DEFAULT_CC)' \
ARCHFLAGS='$(DEFAULT_ARCHFLAGS)' \
DEFINE='$(DEFAULT_DEFINE)' \
CFLAGS='$(OPTFLAGS) $(DEFAULT_CFLAGS)' \
LDFLAGS='$(LDFLAGS)'
debug:
$(MAKE) $(LIBNAME) \
CC='$(DEFAULT_CC)' \
ARCHFLAGS='$(DEFAULT_ARCHFLAGS)' \
DEFINE='$(DEFAULT_DEFINE)' \
CFLAGS='$(DEBUGFLAGS) $(DEFAULT_CFLAGS)' \
LDFLAGS='$(LDFLAGS)'
pgo-start:
$(MAKE) $(LIBNAME) \
CC='$(DEFAULT_CC)' \
ARCHFLAGS='$(DEFAULT_ARCHFLAGS)' \
DEFINE='$(DEFAULT_DEFINE)' \
CFLAGS='$(PGO1FLAGS) $(DEFAULT_CFLAGS)' \
LDFLAGS='$(LDFLAGS) -fprofile-generate'
pgo-finish:
$(MAKE) $(LIBNAME) \
CC='$(DEFAULT_CC)' \
ARCHFLAGS='$(DEFAULT_ARCHFLAGS)' \
DEFINE='$(DEFAULT_DEFINE)' \
CFLAGS='$(PGO2FLAGS) $(DEFAULT_CFLAGS)' \
LDFLAGS='$(LDFLAGS) -fprofile-generate'
clean:
$(RM) -f $(OBJFILES) $(LIBNAME) $(SONAME)
pgo-clean:
$(RM) -f $(PROFFILES)
install:
install -m 755 -o root -g root $(LIBNAME) $(SONAME).$(SOVERSION) $(PREFIX)/lib
ln -sf $(SONAME).$(SOMAJORVERSION) $(PREFIX)/lib/$(SONAME)
install -m 644 -o root -g root gtb-probe.h $(PREFIX)/include
ldconfig
.depend:
$(CC) -MM $(DEFAULT_CFLAGS) $(SRCFILES) > $@
include .depend