2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # Make sure variables in this Makefile do not conflict with other variables (e.g. from gbuild).
11 # You may occassionally want to override some of these
13 # Compile flags ('make CLANGCXXFLAGS=-g' if you need to debug the plugin)
14 CLANGCXXFLAGS
=-O2
-Wall
-Wextra
-g
16 # The uninteresting rest.
18 # Clang headers require these.
19 CLANGDEFS
=-D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
-fno-rtti
20 # All include locations needed.
21 CLANGINCLUDES
=-isystem
$(CLANGDIR
)/include -isystem
$(CLANGDIR
)/tools
/clang
/include -isystem
$(CLANGBUILD
)/include -isystem
$(CLANGBUILD
)/tools
/clang
/include
23 # Clang/LLVM libraries are intentionally not linked in, they are usually built as static libraries, which means the resulting
24 # plugin would be big (even though the clang binary already includes it all) and it'd be necessary to explicitly specify
25 # also all the dependency libraries.
27 CLANGINDIR
=$(SRCDIR
)/compilerplugins
/clang
28 # Cannot use $(WORKDIR), the plugin should survive even 'make clean', otherwise the rebuilt
29 # plugin will cause cache misses with ccache.
30 CLANGOUTDIR
=$(BUILDDIR
)/compilerplugins
/obj
32 QUIET
=$(if
$(VERBOSE
)$(verbose
),,@
)
34 ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS
),TRUE
)
35 CLANGWERROR
:= -Werror
38 compilerplugins
: compilerplugins-build
40 # The list of source files, generated automatically (all files in clang/, but not subdirs).
41 CLANGSRC
=$(foreach src
,$(wildcard $(CLANGINDIR
)/*.
cxx), $(notdir $(src
)))
42 # Remember the sources and if they have changed, force plugin relinking.
44 $(shell mkdir
-p
$(CLANGOUTDIR
) ; \
45 echo
$(CLANGSRC
) |
sort > $(CLANGOUTDIR
)/sources-new.txt
; \
46 if diff
$(CLANGOUTDIR
)/sources.txt
$(CLANGOUTDIR
)/sources-new.txt
>/dev
/null
2>/dev
/null
; then \
49 mv
$(CLANGOUTDIR
)/sources-new.txt
$(CLANGOUTDIR
)/sources.txt
; \
53 ifeq ($(CLANGSRCCHANGED
),1)
56 $(CLANGOUTDIR
)/plugin.so
: CLANGFORCE
58 # Make the .so also explicitly depend on the sources list, to force update in case CLANGSRCCHANGED was e.g. during 'make clean'.
59 $(CLANGOUTDIR
)/plugin.so
: $(CLANGOUTDIR
)/sources.txt
60 $(CLANGOUTDIR
)/sources.txt
:
63 compilerplugins-build
: $(CLANGOUTDIR
) $(CLANGOUTDIR
)/plugin.so
65 compilerplugins-clean
:
69 mkdir
-p
$(CLANGOUTDIR
)
74 $(3): $(2) $(SRCDIR
)/compilerplugins
/Makefile-clang.mk
$(CLANGOUTDIR
)/clang-timestamp
75 @echo
[build CXX
] $(subst $(SRCDIR
)/,,$(2))
76 $(QUIET
)$(CXX
) $(CLANGCXXFLAGS
) $(CLANGWERROR
) $(CLANGDEFS
) $(CLANGINCLUDES
) -I
$(BUILDDIR
)/config_host
$(2) -fPIC
$(CXXFLAGS_CXX11
) -c
-o
$(3) -MMD
-MT
$(3) -MP
-MF
$(CLANGOUTDIR
)/$(1).d
78 -include $(CLANGOUTDIR
)/$(1).d
80 $(CLANGOUTDIR
)/plugin.so
: $(3)
81 $(CLANGOUTDIR
)/plugin.so
: CLANGOBJS
+= $(3)
84 $(foreach src
, $(CLANGSRC
), $(eval
$(call clangbuildsrc
,$(src
),$(CLANGINDIR
)/$(src
),$(CLANGOUTDIR
)/$(src
:.
cxx=.o
))))
86 $(CLANGOUTDIR
)/plugin.so
: $(CLANGOBJS
)
87 @echo
[build LNK
] $(subst $(BUILDDIR
)/,,$@
)
88 $(QUIET
)$(CXX
) -shared
$(CLANGOBJS
) -o
$@
90 # Clang most probably doesn't maintain binary compatibility, so rebuild when clang changes.
91 $(CLANGOUTDIR
)/clang-timestamp
: $(CLANGBUILD
)/bin
/clang
94 # vim: set noet sw=4 ts=4: