Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / Executable.mk
bloba3767b5cca7299fe2593d10d87bcfd9e52a8fae0
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/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # Executable class
22 # defined by platform
23 # gb_Executable_Executable_platform
25 gb_Executable_LAYER_DIRS := \
26 UREBIN:$(INSTROOT)/$(LIBO_URE_BIN_FOLDER) \
27 OOO:$(INSTROOT)/$(LIBO_BIN_FOLDER) \
28 SDKBIN:$(INSTDIR)/$(SDKDIRNAME)/bin \
29 NONE:$(gb_Executable_BINDIR) \
31 gb_Executable_LAYER_DIRS_FOR_BUILD := \
32 UREBIN:$(INSTROOT_FOR_BUILD)/$(LIBO_URE_BIN_FOLDER_FOR_BUILD) \
33 OOO:$(INSTROOT_FOR_BUILD)/$(LIBO_BIN_FOLDER_FOR_BUILD) \
34 SDKBIN:$(INSTDIR_FOR_BUILD)/$(SDKDIRNAME_FOR_BUILD)/bin \
35 NONE:$(gb_Executable_BINDIR_FOR_BUILD) \
37 $(dir $(call gb_Executable_get_runtime_target,%)).dir :
38 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
40 $(dir $(call gb_Executable_get_runtime_target,%))%/.dir :
41 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
43 $(call gb_Executable_get_runtime_target,%) :
44 touch $@
46 .PHONY : $(call gb_Executable_get_clean_target,%)
47 $(call gb_Executable_get_clean_target,%) :
48 $(call gb_Helper_abbreviate_dirs,\
49 rm -f $(call gb_Executable_get_target,$*) \
50 $(call gb_Executable_get_runtime_target,$*) \
51 $(AUXTARGETS))
53 gb_Executable__get_dir_for_layer = $(patsubst $(1):%,%,$(filter $(1):%,$(call gb_Executable_LAYER_DIRS)))
54 gb_Executable__get_dir_for_layer_for_build = $(patsubst $(1):%,%,$(filter $(1):%,$(call gb_Executable_LAYER_DIRS_FOR_BUILD)))
55 gb_Executable__get_dir_for_exe = $(call gb_Executable__get_dir_for_layer,$(call gb_Executable_get_layer,$(1)))
56 gb_Executable__get_dir_for_exe_for_build = $(call gb_Executable__get_dir_for_layer_for_build,$(call gb_Executable_get_layer,$(1)))
58 define gb_Executable_Executable
59 $(call gb_Postprocess_register_target,AllExecutables,Executable,$(1))
60 ifeq (,$$(findstring $(1),$$(gb_Executable_KNOWN)))
61 $$(eval $$(call gb_Output_info,Currently known executables: $(sort $(gb_Executable_KNOWN)),ALL))
62 $$(eval $$(call gb_Output_error,Executable $(1) must be registered in Repository.mk or RepositoryExternal.mk))
63 endif
64 $(call gb_Executable__Executable_impl,$(1),$(call gb_Executable_get_linktarget,$(1)))
66 endef
68 # call gb_Executable__Executable_impl,exe,linktarget
69 define gb_Executable__Executable_impl
70 $(call gb_LinkTarget_LinkTarget,$(2),Executable_$(1),$(call gb_Executable_get_layer,$(1)))
71 $(call gb_LinkTarget_set_targettype,$(2),Executable)
72 $(call gb_LinkTarget_add_libs,$(2),$(gb_STDLIBS))
73 $(call gb_Executable_get_runtime_target,$(1)) :| $(dir $(call gb_Executable_get_runtime_target,$(1))).dir
74 $(call gb_Executable_get_runtime_target,$(1)) : $(call gb_Executable_get_target_for_build,$(1))
75 $(call gb_Executable_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
76 $(call gb_Executable_get_clean_target,$(1)) : AUXTARGETS :=
77 $(call gb_Executable_Executable_platform,$(1),$(2),$(gb_Executable_BINDIR)/$(1).lib)
79 $$(eval $$(call gb_Module_register_target,$(call gb_Executable_get_target,$(1)),$(call gb_Executable_get_clean_target,$(1))))
80 $(call gb_Helper_make_userfriendly_targets,$(1),Executable)
82 endef
84 define gb_Executable_set_targettype_gui
85 $(call gb_LinkTarget_get_target,$(call gb_Executable_get_linktarget,$(1))) : TARGETGUI := $(2)
86 endef
88 define gb_Executable_forward_to_Linktarget
89 gb_Executable_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_Executable_get_linktarget,$$(1)),$$(2),$$(3),Executable_$$(1))
91 endef
93 $(eval $(foreach method,\
94 add_cobject \
95 add_cobjects \
96 add_cxxobject \
97 add_cxxobjects \
98 add_objcobject \
99 add_objcobjects \
100 add_objcxxobject \
101 add_objcxxobjects \
102 add_grammar \
103 add_grammars \
104 add_scanner \
105 add_scanners \
106 add_exception_objects \
107 add_generated_cobjects \
108 add_generated_cxxobjects \
109 add_generated_exception_objects \
110 add_cflags \
111 add_cxxflags \
112 add_objcflags \
113 add_objcxxflags \
114 add_defs \
115 set_include \
116 add_ldflags \
117 set_ldflags \
118 add_libs \
119 disable_standard_system_libs \
120 use_system_darwin_frameworks \
121 use_system_win32_libs \
122 set_library_path_flags \
123 use_api \
124 use_sdk_api \
125 use_udk_api \
126 use_internal_api \
127 use_internal_bootstrap_api \
128 use_internal_comprehensive_api \
129 use_libraries \
130 use_static_libraries \
131 use_external \
132 use_externals \
133 use_custom_headers \
134 use_package \
135 use_packages \
136 use_unpacked \
137 add_sdi_headers \
138 set_precompiled_header \
139 add_nativeres \
140 set_warnings_not_errors \
141 set_external_code \
142 set_generated_cxx_suffix \
144 $(call gb_Executable_forward_to_Linktarget,$(method))\
147 # Run-time use
149 # Add dependencies needed for running the executable
151 # gb_Executable_add_runtime_dependencies executable dependencies
152 define gb_Executable_add_runtime_dependencies
153 $(call gb_Executable_get_runtime_target,$(1)) : $(2)
155 endef
157 # vim: set noet sw=4: