1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 ifeq ($(gb_FULLDEPS
),$(true
))
11 ifneq (,$(CCACHE_HARDLINK
))
12 # cannot move hardlink over itself, so create dep file directly, even if that
13 # might leave a broken file behind in case the build is interrupted forcefully
14 define gb_cxx_dep_generation_options
15 -MMD
-MT
$(1) -MP
-MF
$(2)
17 define gb_cxx_dep_copy
20 define gb_cxx_dep_generation_options
21 -MMD
-MT
$(1) -MP
-MF
$(2)_
23 define gb_cxx_dep_copy
28 define gb_cxx_dep_generation_options
30 define gb_cxx_dep_copy
36 gb_AsmObject_get_source
= $(1)/$(2).s
38 # $(call gb_AsmObject__command,object,relative-source,source,dep-file)
39 define gb_AsmObject__command
40 $(call gb_Output_announce
,$(2),$(true
),ASM
,3)
41 $(call gb_Helper_abbreviate_dirs
,\
42 mkdir
-p
$(dir $(1)) $(dir $(4)) && cd
$(SRCDIR
) && \
44 -x assembler-with-cpp \
47 $(if
$(HAVE_ASM_END_BRANCH_INS_SUPPORT
),-DEND_BRANCH_INS_SUPPORT
) \
51 echo
"$(1) : $(3)" > $(4)
56 # $(call gb_CObject__compiler,source,compiler)
57 define gb_CObject__compiler
58 $(if
$(filter %.c
%.m
,$(1)), \
59 $(if
$(2), $(2), $(gb_CC
)), \
60 $(if
$(2), $(2), $(gb_CXX
)))
63 # When gb_LinkTarget_use_clang is used, filter out GCC flags that Clang doesn't know.
64 # $(call gb_CObject__filter_out_clang_cflags,cflags)
65 define gb_CObject__filter_out_clang_cflags
66 $(filter-out $(gb_FilterOutClangCFLAGS
),$(1))
69 # $(call gb_CObject__command_pattern,object,flags,source,dep-file,compiler-plugins,compiler)
70 define gb_CObject__command_pattern
71 $(call gb_Helper_abbreviate_dirs
,\
72 mkdir
-p
$(dir $(1)) $(dir $(4)) && cd
$(SRCDIR
) && \
73 $(gb_COMPILER_SETUP
) \
74 $(if
$(5),$(gb_COMPILER_PLUGINS_SETUP
)) \
75 $(call gb_CObject__compiler
,$(3),$(6)) \
78 $(if
$(VISIBILITY
),,$(gb_VISIBILITY_FLAGS
)) \
79 $(if
$(WARNINGS_NOT_ERRORS
),$(if
$(ENABLE_WERROR
),$(if
$(PLUGIN_WARNINGS_AS_ERRORS
),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
))),$(gb_CFLAGS_WERROR
)) \
80 $(if
$(5),$(gb_COMPILER_PLUGINS
)) \
81 $(if
$(COMPILER_TEST
),-fsyntax-only
-ferror-limit
=0 -Xclang
-verify
) \
82 $(if
$(6), $(call gb_CObject__filter_out_clang_cflags
,$(2)),$(2)) \
83 $(if
$(WARNINGS_DISABLED
),$(gb_CXXFLAGS_DISABLE_WARNINGS
)) \
84 $(if
$(EXTERNAL_CODE
),$(gb_CXXFLAGS_Wundef
),$(gb_DEFS_INTERNAL
)) \
85 $(if
$(COMPILER_TEST
),,-c
) $(3) \
87 $(if
$(COMPILER_TEST
),,$(call gb_cxx_dep_generation_options
,$(1),$(4))) \
90 $(if
$(COMPILER_TEST
),,$(call gb_cxx_dep_copy
,$(4))) \
94 # PrecompiledHeader class
96 ifeq ($(COM_IS_CLANG
),TRUE
)
97 gb_PrecompiledHeader_get_enableflags
= -include-pch
$(call gb_PrecompiledHeader_get_target
,$(1),$(2))
98 gb_PrecompiledHeader_EXT
:= .pch
99 # Workaround: Apple Clang version 12.0.5 sometimes tries to compile instead of generating PCH
100 # when used just with -c c++-header, so help it by being explicit.
101 gb_PrecompiledHeader_emit_pch
:= -Xclang
-emit-pch
103 gb_PrecompiledHeader_get_enableflags
= \
104 -include $(dir $(call gb_PrecompiledHeader_get_target
,$(1),$(2)))$(notdir $(subst .gch
,,$(call gb_PrecompiledHeader_get_target
,$(1),$(2))))
105 gb_PrecompiledHeader_EXT
:= .gch
106 gb_PrecompiledHeader_emit_pch
:=
109 gb_PrecompiledHeader_extra_pch_cxxflags
+= $(PCH_INSTANTIATE_TEMPLATES
)
111 # Clang supports building extra object file where it puts code that would be shared by all users of the PCH.
112 # Unlike with MSVC it is built as a separate step. The relevant options are used only when generating the PCH
113 # and when creating the PCH's object file, normal compilations using the PCH do not need extra options.
114 gb_PrecompiledHeader_pch_with_obj
+= $(BUILDING_PCH_WITH_OBJ
)
115 gb_PrecompiledHeader_extra_pch_cxxflags
+= $(BUILDING_PCH_WITH_OBJ
)
116 ifneq ($(BUILDING_PCH_WITH_OBJ
),)
117 # If using Clang's PCH extra object, we may need to strip unused sections, otherwise inline and template functions
118 # emitted in that object may in some cases cause unresolved references to private symbols in other libraries.
119 gb_LinkTarget_LDFLAGS
+= $(LD_GC_SECTIONS
)
120 gb_PrecompiledHeader_pch_with_obj
+= -ffunction-sections
-fdata-sections
121 # Enable generating more shared code and debuginfo in the PCH object file.
122 gb_PrecompiledHeader_extra_pch_cxxflags
+= $(PCH_DEBUGINFO
)
123 ifeq ($(ENABLE_OPTIMIZED
),)
124 # -fmodules-codegen appears to be worth it only if not optimizing, otherwise optimizing all the functions emitted
125 # in the PCH object file may take way too long, especially given that many of those may get thrown away
126 gb_PrecompiledHeader_extra_pch_cxxflags
+= $(PCH_CODEGEN
)
130 # This is for MSVC's object file built directly as a side-effect of building the PCH.
131 gb_PrecompiledHeader_get_objectfile
=
133 # $(call gb_PrecompiledHeader__command,pchfile,pchtarget,source,cxxflags,includes,linktargetmakefilename,compiler)
134 define gb_PrecompiledHeader__command
135 $(call gb_Output_announce
,$(2),$(true
),PCH
,1)
136 $(call gb_Trace_StartRange
,$(2),PCH
)
137 $(call gb_Helper_abbreviate_dirs
,\
138 mkdir
-p
$(dir $(1)) $(dir $(call gb_PrecompiledHeader_get_dep_target
,$(2),$(6))) && \
140 CCACHE_DISABLE
=1 $(gb_COMPILER_SETUP
) \
141 $(if
$(7),$(7),$(gb_CXX
)) \
142 -x c
++-header
$(gb_PrecompiledHeader_emit_pch
) \
143 $(if
$(7), $(call gb_CObject__filter_out_clang_cflags
,$(4)),$(4)) \
144 $(if
$(WARNINGS_DISABLED
),$(gb_CXXFLAGS_DISABLE_WARNINGS
)) \
145 $(gb_COMPILERDEPFLAGS
) \
146 $(if
$(VISIBILITY
),,$(gb_VISIBILITY_FLAGS
)) \
147 $(if
$(EXTERNAL_CODE
),$(gb_CXXFLAGS_Wundef
),$(gb_DEFS_INTERNAL
)) \
148 $(gb_NO_PCH_TIMESTAMP
) \
149 $(gb_PrecompiledHeader_extra_pch_cxxflags
) \
151 $(call gb_cxx_dep_generation_options
,$(1),$(call gb_PrecompiledHeader_get_dep_target_tmp
,$(2),$(6))) \
152 -c
$(patsubst %.
cxx,%.hxx
,$(3)) \
154 $(call gb_cxx_dep_copy
,$(call gb_PrecompiledHeader_get_dep_target_tmp
,$(2),$(6))) \
156 $(call gb_Trace_EndRange
,$(2),PCH
)
159 ifeq ($(COM_IS_CLANG
),TRUE
)
160 # Clang has -fno-pch-timestamp, just checksum the file for CCACHE_PCH_EXTSUM
161 # $(call gb_PrecompiledHeader__sum_command,pchfile,pchtarget,source,cxxflags,includes,linktargetmakefilename,compiler)
162 define gb_PrecompiledHeader__sum_command
163 $(SHA256SUM
) $(1) >$(1).sum
166 # GCC does not generate the same .gch for the same input, so checksum the (preprocessed) input
167 # $(call gb_PrecompiledHeader__sum_command,pchfile,pchtarget,source,cxxflags,includes,linktargetmakefilename,compiler)
168 define gb_PrecompiledHeader__sum_command
169 $(call gb_Helper_abbreviate_dirs
,\
170 CCACHE_DISABLE
=1 $(gb_COMPILER_SETUP
) \
171 $(if
$(7),$(7),$(gb_CXX
)) \
174 $(if
$(WARNINGS_DISABLED
),$(gb_CXXFLAGS_DISABLE_WARNINGS
)) \
175 $(gb_COMPILERDEPFLAGS
) \
176 $(if
$(VISIBILITY
),,$(gb_VISIBILITY_FLAGS
)) \
177 $(if
$(EXTERNAL_CODE
),$(gb_CXXFLAGS_Wundef
),$(gb_DEFS_INTERNAL
)) \
178 $(gb_NO_PCH_TIMESTAMP
) \
180 -E
$(patsubst %.
cxx,%.hxx
,$(3)) \
182 |
$(SHA256SUM
) >$(1).sum \
188 gb_PrecompiledHeader__create_reuse_files
=
189 gb_PrecompiledHeader__copy_reuse_files
=
193 define gb_YaccTarget__command
194 $(call gb_Output_announce
,$(2),$(true
),YAC
,3)
195 $(call gb_Helper_abbreviate_dirs
,\
196 mkdir
-p
$(dir $(3)) && \
197 $(BISON
) $(T_YACCFLAGS
) -v
--defines
=$(4) -o
$(5) $(1) && touch
$(3) )
203 ifeq ($(strip $(DEBUGCPPUNIT
)),TRUE
)
204 ifeq ($(strip $(CPPUNITTRACE
)),)
205 CPPUNITTRACE
:= gdb
--args
207 ifeq ($(filter gdb
,$(CPPUNITTRACE
)),)
208 $(error For DEBUGCPPUNIT
=TRUE
, CPPUNITTRACE must be a command that runs gdb
)
210 gb_CppunitTest_DEBUGCPPUNIT
:= -nx
--batch
--command
=$(SRCDIR
)/solenv
/bin
/gdbtrycatchtrace-stdout
213 # ExternalProject class
215 gb_ExternalProject_use_autoconf
:=
216 gb_ExternalProject_use_nmake
:=
218 # StaticLibrary class
220 gb_StaticLibrary_get_filename
= lib
$(1).a
221 gb_StaticLibrary_PLAINEXT
:= .a
222 gb_StaticLibrary_StaticLibrary_platform
:=
224 gb_LinkTarget_get_linksearchpath_for_layer
= \
225 -L
$(gb_StaticLibrary_WORKDIR
) \
226 -L
$(call gb_Library_get_sdk_link_dir
) \
228 $(subst +, ,$(patsubst $(1):%.
,%,\
229 $(filter $(1):%.
,$(gb_LinkTarget_LAYER_LINKPATHS
)))),\
230 $(patsubst $(layer
):%,-L
%,\
231 $(filter $(layer
):%,$(gb_Library_LAYER_DIRS
))))
234 gb_ICU_PRECOMMAND
:= $(call gb_Helper_extend_ld_path
,$(WORKDIR_FOR_BUILD
)/UnpackedTarball
/icu
/source
/lib
)
238 # macOS sort(1) cannot read a response file
239 define gb_UIConfig__command
240 $(call gb_Helper_abbreviate_dirs
,\
241 $(SORT
) -u
$(UI_IMAGELISTS
) /dev
/null
> $@ \
246 define gb_UIConfig__gla11y_command
247 $(call gb_Helper_abbreviate_dirs
,\
248 $(gb_UIConfig_LXML_PATH
) $(if
$(SYSTEM_LIBXML
)$(SYSTEM_LIBXSLT
),,$(gb_Helper_set_ld_path
)) \
249 $(call gb_ExternalExecutable_get_command
,python
) \
250 $(gb_UIConfig_gla11y_SCRIPT
) $(gb_UIConfig_gla11y_PARAMETERS
) -o
$@
$(UIFILES
)
255 # vim: set noet sw=4 ts=4: