-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (109 loc) · 3.74 KB
/
Makefile
File metadata and controls
139 lines (109 loc) · 3.74 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
__nmk_dir=scripts/nmk/scripts/
export __nmk_dir
include $(__nmk_dir)include.mk
include $(__nmk_dir)install.mk
include $(__nmk_dir)macro.mk
include $(__nmk_dir)utils.mk
CFLAGS += $(USERCFLAGS)
export CFLAGS
SRC_DIR := $(CURDIR)
export SRC_DIR
DEFINES += -D_FILE_OFFSET_BITS=64
DEFINES += -D_GNU_SOURCE
WARNINGS := -Wall
ifneq ($(WERROR),0)
WARNINGS += -Werror
endif
ifeq ($(DEBUG),1)
DEFINES += -DDEBUG
CFLAGS += -O0 -ggdb3
else
CFLAGS += -O2 -g
endif
CFLAGS += -iquote include
CFLAGS += $(WARNINGS) $(DEFINES)
CRLOG_SO := libcrlog.so
CRLOG_UAPI_HEADERS := include/uapi/crlog.h
cflags-so += -rdynamic -Wl,-soname,$(CRLOG_SO).$(CRLOGSO_VERSION_MAJOR)
$(eval $(call gen-versions,CRLOGSO,1,0,,,))
$(eval $(call gen-built-in,src))
$(CRLOG_SO): src/built-in.o
$(call msg-link, $@)
$(Q) $(CC) -shared $(cflags-so) -o $@ $^
PLUGIN_INCLUDE := $(shell gcc -print-file-name=plugin)
ifeq ($(PLUGIN_INCLUDE),plugin)
$(error Error: GCC API for plugins is not installed on your system)
endif
CPRINTF := cprintf/cprintf
CPRINTF_SO := $(addsuffix .so,$(CPRINTF))
CXX := g++
CXXFLAGS += -I $(PLUGIN_INCLUDE)/include
CXXFLAGS += -fPIC -fno-rtti
LDFLAGS_PLUGIN := -shared -fno-rtti
$(CPRINTF_SO): $(CPRINTF).o
$(CXX) $(LDFLAGS) $(LDFLAGS_PLUGIN) -o $@ $<
$(CPRINTF).o: $(CPRINTF).cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
CLI := crlog
CLI-CPRINTF := crlog.cprintf
CLI-LIBS := $(shell pkg-config --libs libffi)
CFLAGS += $(shell pkg-config --cflags libffi)
cli/cli-cprintf.built-in.o: $(CPRINTF_SO)
$(eval $(call gen-built-in,cli))
$(CLI): cli/cli.built-in.o src/built-in.o
$(call msg-link, $@)
$(Q) $(CC) -o $@ $(CLI-LIBS) $^
$(CLI-CPRINTF): cli/cli-cprintf.built-in.o src/built-in.o
$(call msg-link, $@)
$(Q) $(CC) -o $@ $(CLI-LIBS) $^
clean:
$(Q) $(MAKE) $(build)=src $@
$(Q) $(MAKE) $(build)=cli $@
$(Q) $(RM) $(CRLOG_SO)
$(Q) $(RM) $(CLI) $(CLI-CPRINTF)
$(Q) $(RM) $(CPRINTF_SO) $(CPRINTF).o
.PHONY: clean
UAPI_HEADERS := include/uapi/crlog.h
install: $(CRLOG_SO) $(CLI)
$(E) " INSTALL " $(CLI) $(CRLOG_SO)
$(Q) mkdir -p $(DESTDIR)$(SBINDIR)
$(Q) install -m 755 $(CLI) $(DESTDIR)$(SBINDIR)
$(Q) mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(Q) install -m 644 $(UAPI_HEADERS) $(DESTDIR)$(INCLUDEDIR)
$(Q) mkdir -p $(DESTDIR)$(LIBDIR)
$(Q) install -m 755 $(CRLOG_SO) $(DESTDIR)$(LIBDIR)/$(CRLOG_SO).$(CRLOGSO_VERSION_MAJOR).$(CRLOGSO_VERSION_MINOR)
$(Q) ln -fns $(CRLOG_SO).$(CRLOGSO_VERSION_MAJOR).$(CRLOGSO_VERSION_MINOR) $(DESTDIR)$(LIBDIR)/$(CRLOG_SO).$(CRLOGSO_VERSION_MAJOR)
$(Q) ln -fns $(CRLOG_SO).$(CRLOGSO_VERSION_MAJOR).$(CRLOGSO_VERSION_MINOR) $(DESTDIR)$(LIBDIR)/$(CRLOG_SO)
.PHONY: install
uninstall:
$(E) " UNINSTALL" $(CRLOG_SO) $(CLI)
$(Q) $(RM) $(addprefix $(DESTDIR)$(SBINDIR)/,$(CLI))
$(Q) $(RM) $(addprefix $(DESTDIR)$(INCLUDEDIR)/,$(notdir $(UAPI_HEADERS)))
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/,$(CRLOG_SO).$(CRLOGSO_VERSION_MAJOR))
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/,$(CRLOG_SO))
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/,$(CRLOG_SO).$(CRLOGSO_VERSION_MAJOR).$(CRLOGSO_VERSION_MINOR))
.PHONY: uninstall
tags:
$(call msg-gen, $@)
$(Q) $(RM) tags
$(Q) $(FIND) . -name '*.[hcS]' ! -path './.*' ! -path './tests/*' -print | xargs $(CTAGS) -a
.PHONY: tags
etags:
$(call msg-gen, $@)
$(Q) $(RM) TAGS
$(Q) $(FIND) . -name '*.[hcS]' ! -path './.*' ! -path './tests/*' -print | xargs $(ETAGS) -a
.PHONY: etags
cscope:
$(call msg-gen, $@)
$(Q) $(FIND) . -name '*.[hcS]' ! -path './.*' ! -path './tests/*' ! -type l -print > cscope.files
$(Q) $(CSCOPE) -bkqu
.PHONY: cscope
all: $(CRLOG_SO) $(CLI) $(CLI-CPRINTF)
@true
.PHONY: all
test: override CPP=g++
test: $(CLI) $(CPRINTF_SO) $(CLI-CPRINTF)
$(Q) $(CPP) tests/fstream.cpp -o tests/fstream
$(Q) tests/test00
.PHONY: test
.DEFAULT_GOAL := all