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 QUIET
=$(if
$(VERBOSE
)$(verbose
),,@
)
18 # The uninteresting rest.
20 # Clang headers require these.
21 CLANGDEFS
=-D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
-fno-rtti
22 # All include locations needed.
23 CLANGINCLUDES
=-I
$(CLANGDIR
)/include -I
$(CLANGDIR
)/tools
/clang
/include -I
$(CLANGBUILD
)/include -I
$(CLANGBUILD
)/tools
/clang
/include
25 # Clang/LLVM libraries are intentionally not linked in, they are usually built as static libraries, which means the resulting
26 # plugin would be big (even though the clang binary already includes it all) and it'd be necessary to explicitly specify
27 # also all the dependency libraries.
29 CLANGINDIR
=$(SRCDIR
)/compilerplugins
/clang
30 # Cannot use $(WORKDIR), the plugin should survive even 'make clean', otherwise the rebuilt
31 # plugin will cause cache misses with ccache.
32 CLANGOUTDIR
=$(BUILDDIR
)/compilerplugins
/obj
34 compilerplugins
: compilerplugins-build
36 # The list of source files, generated automatically (all files in clang/, but not subdirs).
37 CLANGSRC
=$(foreach src
,$(wildcard $(CLANGINDIR
)/*.
cxx), $(notdir $(src
)))
38 # Remember the sources and if they have changed, force plugin relinking.
40 $(shell mkdir
-p
$(CLANGOUTDIR
) ; \
41 echo
$(CLANGSRC
) |
sort > $(CLANGOUTDIR
)/sources-new.txt
; \
42 if diff
$(CLANGOUTDIR
)/sources.txt
$(CLANGOUTDIR
)/sources-new.txt
>/dev
/null
2>/dev
/null
; then \
45 mv
$(CLANGOUTDIR
)/sources-new.txt
$(CLANGOUTDIR
)/sources.txt
; \
49 ifeq ($(CLANGSRCCHANGED
),1)
52 $(CLANGOUTDIR
)/plugin.so
: CLANGFORCE
54 # Make the .so also explicitly depend on the sources list, to force update in case CLANGSRCCHANGED was e.g. during 'make clean'.
55 $(CLANGOUTDIR
)/plugin.so
: $(CLANGOUTDIR
)/sources.txt
56 $(CLANGOUTDIR
)/sources.txt
:
59 compilerplugins-build
: $(CLANGOUTDIR
) $(CLANGOUTDIR
)/plugin.so
61 compilerplugins-clean
:
65 mkdir
-p
$(CLANGOUTDIR
)
70 $(3): $(2) $(SRCDIR
)/compilerplugins
/Makefile-clang.mk
$(CLANGOUTDIR
)/clang-timestamp
71 @echo
[build CXX
] $(subst $(SRCDIR
)/,,$(2))
72 $(QUIET
)$(CXX
) $(CLANGCXXFLAGS
) $(CLANGDEFS
) $(CLANGINCLUDES
) -I
$(BUILDDIR
)/config_host
$(2) -fPIC
-std
=c
++11 -c
-o
$(3) -MMD
-MT
$(3) -MP
-MF
$(CLANGOUTDIR
)/$(1).d
74 -include $(CLANGOUTDIR
)/$(1).d
76 $(CLANGOUTDIR
)/plugin.so
: $(3)
77 $(CLANGOUTDIR
)/plugin.so
: CLANGOBJS
+= $(3)
80 $(foreach src
, $(CLANGSRC
), $(eval
$(call clangbuildsrc
,$(src
),$(CLANGINDIR
)/$(src
),$(CLANGOUTDIR
)/$(src
:.
cxx=.o
))))
82 $(CLANGOUTDIR
)/plugin.so
: $(CLANGOBJS
)
83 @echo
[build LNK
] $(subst $(BUILDDIR
)/,,$@
)
84 $(QUIET
)$(CXX
) -shared
$(CLANGOBJS
) -o
$@
86 # Clang most probably doesn't maintain binary compatibility, so rebuild when clang changes.
87 $(CLANGOUTDIR
)/clang-timestamp
: $(CLANGDIR
)/bin
/clang
90 # vim: set noet sw=4 ts=4: