-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (115 loc) · 4.03 KB
/
Makefile
File metadata and controls
138 lines (115 loc) · 4.03 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
# Copyright 2011, 2012, 2013 David Malcolm <dmalcolm@redhat.com>
# Copyright 2011, 2012, 2013 Red Hat, Inc.
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
.PHONY: all clean check-api install
HANDWRITTEN_C_FILES = \
gcc-callgraph.c \
gcc-cfg.c \
gcc-constant.c \
gcc-declaration.c \
gcc-diagnostics.c \
gcc-function.c \
gcc-gimple.c \
gcc-location.c \
gcc-option.c \
gcc-rtl.c \
gcc-tree.c \
gcc-type.c \
gcc-variable.c
GENERATED_C_FILES = \
autogenerated-casts.c
OBJECT_FILES_FROM_HANDWRITTEN_C_FILES:= $(patsubst %.c,%.o,$(HANDWRITTEN_C_FILES))
OBJECT_FILES_FROM_GENERATED_C_FILES:= $(patsubst %.c,%.o,$(GENERATED_C_FILES))
OBJECT_FILES:= $(OBJECT_FILES_FROM_HANDWRITTEN_C_FILES) $(OBJECT_FILES_FROM_GENERATED_C_FILES)
SOURCE_XML:= \
callgraph.xml \
cfg.xml \
constant.xml \
declaration.xml \
function.xml \
gimple.xml \
location.xml \
option.xml \
rtl.xml \
tree.xml \
type.xml \
variable.xml
GENERATED_HEADERS:= \
gcc-public-types.h \
gcc-semiprivate-types.h \
gcc-callgraph.h \
gcc-cfg.h \
gcc-constant.h \
gcc-declaration.h \
gcc-function.h \
gcc-gimple.h \
gcc-location.h \
gcc-option.h \
gcc-rtl.h \
gcc-tree.h \
gcc-type.h \
gcc-variable.h
TARGET_GCC:=$(CC)
GCCPLUGINS_DIR:= $(shell $(TARGET_GCC) --print-file-name=plugin)
LIBGCC_C_API_SO := libgcc-c-api.so
CPPFLAGS+= -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I.
# Allow user to pick optimization, choose whether warnings are fatal,
# and choose debugging information level.
CFLAGS?=-O2 -Werror -g
CXXFLAGS?=-O2 -Werror -g
# Force these settings
CFLAGS+= -fPIC -fno-strict-aliasing -Wall
CXXFLAGS+= -fPIC -fno-strict-aliasing -Wall
define run-cc
set -- $1; \
read gcc_cxx < "../autogenerated-EXTRA_CFLAGS.txt"; \
if [ "$$gcc_cxx" = '-x c' ]; then \
$(if $2,$2,$(CC) $(CFLAGS)) "$$@"; \
elif [ "$$gcc_cxx" = '-x c++' ]; then \
$(if $3,$3,$(CXX) $(CXXFLAGS)) "$$@"; \
else \
false; \
fi
endef
all: $(LIBGCC_C_API_SO)
$(LIBGCC_C_API_SO): $(OBJECT_FILES)
$(call run-cc,-shared $^ $(OUTPUT_OPTION) $(LIBS),$(LINK.c),$(LINK.cpp))
# This is the standard .c->.o recipe, but it needs to be stated
# explicitly to support the case that $(srcdir) is not blank.
$(OBJECT_FILES): %.o: $(srcdir)%.c $(GENERATED_HEADERS) ../autogenerated-EXTRA_CFLAGS.txt ../autogenerated-gcc-version
read gcc_version < ../autogenerated-gcc-version || exit 1; $(call run-cc,-DTARGET_GCC_VERSION="$$gcc_version" $< $(OUTPUT_OPTION),$(COMPILE.c),$(COMPILE.cpp))
autogenerated-casts.c: $(SOURCE_XML) xmltypes.py generate-casts-c.py
$(PYTHON) generate-casts-c.py $@
clean:
$(RM) *.so *.o $(GENERATED_HEADERS)
install: $(LIBGCC_C_API_SO)
mkdir -p $(DESTDIR)$(GCCPLUGINS_DIR)
cp libgcc-c-api.so $(DESTDIR)$(GCCPLUGINS_DIR)
# The python interpreter to use:
PYTHON=python
# Describe how to build the first generated header
$(firstword $(GENERATED_HEADERS)):
$(PYTHON) xml-to-h.py
# Make all generated headers depend on the true inputs
$(GENERATED_HEADERS): xml-to-h.py xmltypes.py $(SOURCE_XML)
# Add a fake dependency so that all headers other than the first will
# depend on the first. This allows the first generated header to do
# double duty as a flag file. This indirection ensures that Make will
# only run one instance of the generation rule, rather than one per
# required header file.
$(wordlist 2, $(words $(GENERATED_HEADERS)), $(GENERATED_HEADERS)): $(firstword $(GENERATED_HEADERS))
check-api:
xmllint --noout --relaxng api.rng *.xml