[665] | 1 | # $Id: CLANGCCMACHO.kmk 3580 2023-01-05 02:16:42Z bird $
|
---|
[557] | 2 | ## @file
|
---|
[3403] | 3 | # kBuild Tool Config - LLVM Clang targeting Darwin (Mac OS X) Mach-O, for building C code.
|
---|
[557] | 4 | #
|
---|
[1547] | 5 |
|
---|
| 6 | #
|
---|
[3403] | 7 | # Copyright (c) 2004-2020 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
|
---|
[557] | 8 | #
|
---|
| 9 | # This file is part of kBuild.
|
---|
| 10 | #
|
---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with kBuild; if not, write to the Free Software
|
---|
| 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 24 | #
|
---|
| 25 | #
|
---|
[1547] | 26 | # As a special exception you are granted permission to include this file, via
|
---|
[2018] | 27 | # the kmk include directive, as you wish without this in itself causing the
|
---|
| 28 | # resulting makefile, program or whatever to be covered by the GPL license.
|
---|
[1547] | 29 | # This exception does not however invalidate any other reasons why the makefile,
|
---|
| 30 | # program, whatever should not be covered the GPL.
|
---|
| 31 | #
|
---|
| 32 | #
|
---|
[557] | 33 |
|
---|
[3401] | 34 | ifndef INCLUDED_DARWIN_COMMON_KMK
|
---|
| 35 | include $(KBUILD_PATH)/darwin-common.kmk
|
---|
| 36 | endif
|
---|
[557] | 37 |
|
---|
[3403] | 38 | TOOL_CLANGCCMACHO := LLVM Clang targeting Darwin (Mac OS X) Mach-O, for building C code.
|
---|
[3401] | 39 |
|
---|
[667] | 40 | # Tool Specific Properties
|
---|
[3401] | 41 | # PREFIX/SUFFIX: clang; PREFIX2/SUFFIX2: cctool;
|
---|
[3403] | 42 | ifndef PATH_TOOL_CLANGCCMACHO
|
---|
| 43 | PATH_TOOL_CLANGCCMACHO := $(substr $(firstfile $(foreachfile toolchaindir, $(DARWINCMN_TOOLCHAIN_DIRS) \
|
---|
[3401] | 44 | , $(qwildcard ,$(toolchaindir)/usr/bin/clang++))), 1, -12)
|
---|
| 45 | else
|
---|
[3403] | 46 | PATH_TOOL_CLANGCCMACHO := $(PATH_TOOL_CLANGCCMACHO)
|
---|
[3392] | 47 | endif
|
---|
[3403] | 48 | ifndef TOOL_CLANGCCMACHO_PREFIX
|
---|
| 49 | ifdef PATH_TOOL_CLANGCCMACHO
|
---|
| 50 | TOOL_CLANGCCMACHO_PREFIX := $(PATH_TOOL_CLANGCCMACHO)/bin/
|
---|
[3401] | 51 | else
|
---|
[3403] | 52 | TOOL_CLANGCCMACHO_PREFIX :=
|
---|
[3401] | 53 | endif
|
---|
[3392] | 54 | endif
|
---|
[3403] | 55 | ifndef TOOL_CLANGCCMACHO_SUFFIX
|
---|
| 56 | TOOL_CLANGCCMACHO_SUFFIX := $(HOSTSUFF_EXE)
|
---|
[3401] | 57 | endif
|
---|
[3403] | 58 | TOOL_CLANGCCMACHO_PREFIX2 ?= $(TOOL_CLANGCCMACHO_PREFIX)
|
---|
| 59 | TOOL_CLANGCCMACHO_SUFFIX2 ?= $(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 60 | TOOL_CLANGCCMACHO_CC ?= $(TOOL_CLANGCCMACHO_PREFIX)clang$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 61 | TOOL_CLANGCCMACHO_CXX ?= $(TOOL_CLANGCCMACHO_PREFIX)clang++$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 62 | TOOL_CLANGCCMACHO_PCH ?= $(TOOL_CLANGCCMACHO_CXX)
|
---|
| 63 | TOOL_CLANGCCMACHO_OBJC ?= $(TOOL_CLANGCCMACHO_PREFIX)clang$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 64 | TOOL_CLANGCCMACHO_OBJCXX ?= $(TOOL_CLANGCCMACHO_PREFIX)clang$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 65 | TOOL_CLANGCCMACHO_AS ?= $(TOOL_CLANGCCMACHO_PREFIX)clang$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 66 | TOOL_CLANGCCMACHO_LD ?= $(TOOL_CLANGCCMACHO_PREFIX)clang$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 67 | TOOL_CLANGCCMACHO_LD_SYSMOD ?= $(TOOL_CLANGCCMACHO_PREFIX)clang$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
| 68 | TOOL_CLANGCCMACHO_LDFLAGS.dll ?= -dynamiclib
|
---|
| 69 | TOOL_CLANGCCMACHO_LDFLAGS.sysmod ?= -r
|
---|
| 70 | #TOOL_CLANGCCMACHO_LD_SONAME = -Wl,-dylib_install_name $(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
---|
| 71 | TOOL_CLANGCCMACHO_DSYMUTIL ?= $(TOOL_CLANGCCMACHO_PREFIX)dsymutil$(TOOL_CLANGCCMACHO_SUFFIX)
|
---|
[557] | 72 |
|
---|
[3403] | 73 | TOOL_CLANGCCMACHO_AR ?= $(TOOL_CLANGCCMACHO_PREFIX2)ar$(TOOL_CLANGCCMACHO_SUFFIX2)
|
---|
| 74 | TOOL_CLANGCCMACHO_STRIP ?= $(TOOL_CLANGCCMACHO_PREFIX2)strip$(TOOL_CLANGCCMACHO_SUFFIX2)
|
---|
| 75 | TOOL_CLANGCCMACHO_STRIP_PROGRAM ?= $(TOOL_CLANGCCMACHO_STRIP) -SXxru
|
---|
| 76 | TOOL_CLANGCCMACHO_STRIP_DLL ?= $(TOOL_CLANGCCMACHO_STRIP) -Sxru
|
---|
| 77 | TOOL_CLANGCCMACHO_STRIP_SYSMOD ?= $(TOOL_CLANGCCMACHO_STRIP) -Sru
|
---|
[3392] | 78 |
|
---|
[667] | 79 | # General Properties used by kBuild
|
---|
[3403] | 80 | TOOL_CLANGCCMACHO_COBJSUFF ?= .o
|
---|
| 81 | TOOL_CLANGCCMACHO_CFLAGS ?=
|
---|
| 82 | TOOL_CLANGCCMACHO_CFLAGS.debug ?= -g
|
---|
| 83 | TOOL_CLANGCCMACHO_CFLAGS.profile ?= -O2 #-g -pg
|
---|
| 84 | TOOL_CLANGCCMACHO_CFLAGS.release ?= -O2
|
---|
| 85 | TOOL_CLANGCCMACHO_CINCS ?=
|
---|
| 86 | TOOL_CLANGCCMACHO_CDEFS ?=
|
---|
[557] | 87 |
|
---|
[3403] | 88 | TOOL_CLANGCCMACHO_CXXOBJSUFF ?= .o
|
---|
| 89 | TOOL_CLANGCCMACHO_CXXFLAGS ?=
|
---|
| 90 | TOOL_CLANGCCMACHO_CXXFLAGS.debug ?= -g
|
---|
| 91 | TOOL_CLANGCCMACHO_CXXFLAGS.profile ?= -O2 #-g -pg
|
---|
| 92 | TOOL_CLANGCCMACHO_CXXFLAGS.release ?= -O2
|
---|
| 93 | TOOL_CLANGCCMACHO_CXXINCS ?=
|
---|
| 94 | TOOL_CLANGCCMACHO_CXXDEFS ?=
|
---|
[667] | 95 |
|
---|
[3403] | 96 | TOOL_CLANGCCMACHO_PCHOBJSUFF ?= .h.gch
|
---|
| 97 | TOOL_CLANGCCMACHO_PCHFLAGS ?= $(TOOL_CLANGCCMACHO_CXXFLAGS)
|
---|
| 98 | TOOL_CLANGCCMACHO_PCHFLAGS.debug ?= $(TOOL_CLANGCCMACHO_CXXFLAGS.debug)
|
---|
| 99 | TOOL_CLANGCCMACHO_PCHFLAGS.profile ?= $(TOOL_CLANGCCMACHO_CXXFLAGS.profile)
|
---|
| 100 | TOOL_CLANGCCMACHO_PCHFLAGS.release ?= $(TOOL_CLANGCCMACHO_CXXFLAGS.release)
|
---|
| 101 | TOOL_CLANGCCMACHO_PCHINCS ?= $(TOOL_CLANGCCMACHO_CXXINCS)
|
---|
| 102 | TOOL_CLANGCCMACHO_PCHDEFS ?= $(TOOL_CLANGCCMACHO_CXXDEFS)
|
---|
[3258] | 103 |
|
---|
[3403] | 104 | TOOL_CLANGCCMACHO_OBJCOBJSUFF ?= .o
|
---|
| 105 | TOOL_CLANGCCMACHO_OBJCFLAGS ?=
|
---|
| 106 | TOOL_CLANGCCMACHO_OBJCFLAGS.debug ?= -g
|
---|
| 107 | TOOL_CLANGCCMACHO_OBJCFLAGS.profile?= -O2 #-g -pg
|
---|
| 108 | TOOL_CLANGCCMACHO_OBJCFLAGS.release?= -O2
|
---|
| 109 | TOOL_CLANGCCMACHO_OBJCINCS ?=
|
---|
| 110 | TOOL_CLANGCCMACHO_OBJCDEFS ?=
|
---|
[1257] | 111 |
|
---|
[3403] | 112 | TOOL_CLANGCCMACHO_OBJCXXOBJSUFF ?= .o
|
---|
| 113 | TOOL_CLANGCCMACHO_OBJCXXFLAGS ?=
|
---|
| 114 | TOOL_CLANGCCMACHO_OBJCXXFLAGS.debug ?= -g
|
---|
| 115 | TOOL_CLANGCCMACHO_OBJCXXFLAGS.profile ?= -O2 #-g -pg
|
---|
| 116 | TOOL_CLANGCCMACHO_OBJCXXFLAGS.release ?= -O2
|
---|
| 117 | TOOL_CLANGCCMACHO_OBJCXXINCS ?=
|
---|
| 118 | TOOL_CLANGCCMACHO_OBJCXXDEFS ?=
|
---|
[2356] | 119 |
|
---|
[3403] | 120 | TOOL_CLANGCCMACHO_ASFLAGS ?= -x assembler-with-cpp
|
---|
| 121 | TOOL_CLANGCCMACHO_ASFLAGS.debug ?= -g
|
---|
| 122 | TOOL_CLANGCCMACHO_ASFLAGS.profile ?= -g
|
---|
| 123 | TOOL_CLANGCCMACHO_ASOBJSUFF ?= .o
|
---|
[667] | 124 |
|
---|
[3403] | 125 | TOOL_CLANGCCMACHO_ARFLAGS ?= -c -rs
|
---|
| 126 | TOOL_CLANGCCMACHO_ARLIBSUFF ?= .a
|
---|
[667] | 127 |
|
---|
[3403] | 128 | TOOL_CLANGCCMACHO_LDFLAGS ?=
|
---|
| 129 | TOOL_CLANGCCMACHO_LDFLAGS.debug ?= -g
|
---|
| 130 | TOOL_CLANGCCMACHO_LDFLAGS.profile ?= -g
|
---|
[667] | 131 |
|
---|
| 132 |
|
---|
[2535] | 133 |
|
---|
[2527] | 134 | ##
|
---|
| 135 | # Calculate the files in the debug bundle.
|
---|
[3401] | 136 | # @param 1 The whole output filename.
|
---|
| 137 | # @param 2 The output filename sans suffix.
|
---|
[3403] | 138 | TOOL_CLANGCCMACHO_DEBUG_BUNDLE_FN = \
|
---|
[2527] | 139 | $(1).dSYM/Contents/Info.plist \
|
---|
| 140 | $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1))
|
---|
| 141 |
|
---|
| 142 | ##
|
---|
| 143 | # Calculate the files in the debug bundle.
|
---|
[3401] | 144 | # @param 1 The whole linker output filename.
|
---|
| 145 | # @param 2 The linker output filename sans suffix.
|
---|
| 146 | # @param 3 The desired install name (no dir slash).
|
---|
[2535] | 147 | # @remarks The Info.plist has some reference to the original name, but gdb
|
---|
| 148 | # does not care and only check for a symbol file in the DWARF
|
---|
| 149 | # directory with the same name as the debugged module.
|
---|
[3403] | 150 | TOOL_CLANGCCMACHO_DEBUG_INSTALL_FN= \
|
---|
[2527] | 151 | $(3).dSYM/ \
|
---|
| 152 | $(3).dSYM/Contents/ \
|
---|
| 153 | $(3).dSYM/Contents/Resources/ \
|
---|
| 154 | $(3).dSYM/Contents/Resources/DWARF/ \
|
---|
| 155 | $(1).dSYM/Contents/Info.plist=>$(3).dSYM/Contents/Info.plist \
|
---|
[2535] | 156 | $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1))=>$(3).dSYM/Contents/Resources/DWARF/$(notdir $(3))
|
---|
[2527] | 157 |
|
---|
| 158 |
|
---|
[557] | 159 | ## Compile C source.
|
---|
| 160 | # @param $(target) Normalized main target name.
|
---|
| 161 | # @param $(source) Source filename (relative).
|
---|
| 162 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 163 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 164 | # @param $(flags) Flags.
|
---|
| 165 | # @param $(defs) Definitions. No -D or something.
|
---|
| 166 | # @param $(incs) Includes. No -I or something.
|
---|
| 167 | # @param $(dirdep) Directory creation dependency.
|
---|
| 168 | # @param $(deps) Other dependencies.
|
---|
| 169 | #
|
---|
| 170 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 171 | # @param $(objsuff) Object suffix.
|
---|
[3403] | 172 | TOOL_CLANGCCMACHO_COMPILE_C_DEPEND =
|
---|
| 173 | TOOL_CLANGCCMACHO_COMPILE_C_DEPORD =
|
---|
| 174 | TOOL_CLANGCCMACHO_COMPILE_C_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
|
---|
| 175 | TOOL_CLANGCCMACHO_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
|
---|
| 176 | define TOOL_CLANGCCMACHO_COMPILE_C_CMDS
|
---|
[3258] | 177 | if "$(use_objcache)" != ""
|
---|
[1052] | 178 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
| 179 | --kObjCache-cpp $(outbase).i\
|
---|
[3403] | 180 | $(TOOL_CLANGCCMACHO_CC) -E -o -\
|
---|
[3579] | 181 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[1013] | 182 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
[1052] | 183 | $(abspath $(source))\
|
---|
| 184 | --kObjCache-cc $(obj)\
|
---|
[3403] | 185 | $(TOOL_CLANGCCMACHO_CC) -c\
|
---|
[1052] | 186 | $(flags) -fpreprocessed -x c\
|
---|
[1013] | 187 | -o $(obj)\
|
---|
[1052] | 188 | -
|
---|
[3258] | 189 | else
|
---|
[3403] | 190 | $(QUIET)$(TOOL_CLANGCCMACHO_CC) -c\
|
---|
[3579] | 191 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[557] | 192 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 193 | -o $(obj)\
|
---|
[697] | 194 | $(abspath $(source))
|
---|
[3258] | 195 | endif
|
---|
[2431] | 196 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[557] | 197 | endef
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | ## Compile C++ source.
|
---|
| 201 | # @param $(target) Normalized main target name.
|
---|
| 202 | # @param $(source) Source filename (relative).
|
---|
| 203 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
[3258] | 204 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
[557] | 205 | # @param $(flags) Flags.
|
---|
| 206 | # @param $(defs) Definitions. No -D or something.
|
---|
| 207 | # @param $(incs) Includes. No -I or something.
|
---|
| 208 | # @param $(dirdep) Directory creation dependency.
|
---|
[3258] | 209 | # @param $(deps) Other dependencies.
|
---|
[557] | 210 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 211 | # @param $(objsuff) Object suffix.
|
---|
[3403] | 212 | TOOL_CLANGCCMACHO_COMPILE_CXX_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
|
---|
| 213 | TOOL_CLANGCCMACHO_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
|
---|
| 214 | TOOL_CLANGCCMACHO_COMPILE_CXX_DEPORD =
|
---|
| 215 | TOOL_CLANGCCMACHO_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
|
---|
| 216 | define TOOL_CLANGCCMACHO_COMPILE_CXX_CMDS
|
---|
[3258] | 217 | if "$(use_objcache)" != ""
|
---|
[1052] | 218 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
| 219 | --kObjCache-cpp $(outbase).ii\
|
---|
[3403] | 220 | $(TOOL_CLANGCCMACHO_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
|
---|
[3258] | 221 | ,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
|
---|
[3579] | 222 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[1013] | 223 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
[1052] | 224 | $(abspath $(source))\
|
---|
| 225 | --kObjCache-cc $(obj)\
|
---|
[3403] | 226 | $(TOOL_CLANGCCMACHO_CXX) -c\
|
---|
[3258] | 227 | $(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
|
---|
[1013] | 228 | -o $(obj)\
|
---|
[1052] | 229 | -
|
---|
[3258] | 230 | else
|
---|
[3403] | 231 | $(QUIET)$(TOOL_CLANGCCMACHO_CXX) -c\
|
---|
[3580] | 232 | $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[3258] | 233 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 234 | -o $(obj) $(if-expr defined($(target)_PCH_HDR) \
|
---|
| 235 | ,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
|
---|
| 236 | $(abspath $(source))
|
---|
| 237 | endif
|
---|
[2431] | 238 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[1013] | 239 | endef
|
---|
[3258] | 240 |
|
---|
| 241 |
|
---|
| 242 | ## Precompile C++ header.
|
---|
| 243 | # @param $(target) Normalized main target name.
|
---|
| 244 | # @param $(source) Source filename (relative).
|
---|
| 245 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 246 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 247 | # @param $(flags) Flags.
|
---|
| 248 | # @param $(defs) Definitions. No -D or something.
|
---|
| 249 | # @param $(incs) Includes. No -I or something.
|
---|
| 250 | # @param $(dirdep) Directory creation dependency.
|
---|
| 251 | # @param $(deps) Other dependencies.
|
---|
| 252 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 253 | # @param $(objsuff) Object suffix.
|
---|
[3403] | 254 | TOOL_CLANGCCMACHO_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
|
---|
| 255 | TOOL_CLANGCCMACHO_COMPILE_PCH_DEPEND =
|
---|
| 256 | TOOL_CLANGCCMACHO_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
|
---|
| 257 | define TOOL_CLANGCCMACHO_COMPILE_PCH_CMDS
|
---|
| 258 | $(QUIET)$(TOOL_CLANGCCMACHO_PCH) -c\
|
---|
[3580] | 259 | $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[557] | 260 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 261 | -o $(obj)\
|
---|
[697] | 262 | $(abspath $(source))
|
---|
[3258] | 263 | $(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
|
---|
[2431] | 264 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[557] | 265 | endef
|
---|
| 266 |
|
---|
| 267 |
|
---|
[1257] | 268 | ## Compile Objective-C source.
|
---|
| 269 | # @param $(target) Normalized main target name.
|
---|
| 270 | # @param $(source) Source filename (relative).
|
---|
| 271 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 272 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 273 | # @param $(flags) Flags.
|
---|
| 274 | # @param $(defs) Definitions. No -D or something.
|
---|
| 275 | # @param $(incs) Includes. No -I or something.
|
---|
| 276 | # @param $(dirdep) Directory creation dependency.
|
---|
| 277 | # @param $(deps) Other dependencies.
|
---|
| 278 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 279 | # @param $(objsuff) Object suffix.
|
---|
[3403] | 280 | TOOL_CLANGCCMACHO_COMPILE_OBJC_DEPEND =
|
---|
| 281 | TOOL_CLANGCCMACHO_COMPILE_OBJC_DEPORD =
|
---|
[1418] | 282 | ifdef KBUILD_USE_KOBJCACHE
|
---|
[3403] | 283 | TOOL_CLANGCCMACHO_COMPILE_OBJC_USES_KOBJCACHE = 1
|
---|
| 284 | TOOL_CLANGCCMACHO_COMPILE_OBJC_OUTPUT = $(outbase).mi
|
---|
| 285 | define TOOL_CLANGCCMACHO_COMPILE_OBJC_CMDS
|
---|
[1257] | 286 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
| 287 | --kObjCache-cpp $(outbase).ii\
|
---|
[3403] | 288 | $(TOOL_CLANGCCMACHO_OBJC) -E -o -\
|
---|
[3579] | 289 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[1257] | 290 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 291 | $(abspath $(source))\
|
---|
| 292 | --kObjCache-cc $(obj)\
|
---|
[3403] | 293 | $(TOOL_CLANGCCMACHO_OBJC) -c\
|
---|
[1257] | 294 | $(flags) -fpreprocessed -x objective-c \
|
---|
| 295 | -o $(obj)\
|
---|
| 296 | -
|
---|
[2431] | 297 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[1257] | 298 | endef
|
---|
[1418] | 299 | else # !KBUILD_USE_KOBJCACHE
|
---|
[3403] | 300 | TOOL_CLANGCCMACHO_COMPILE_OBJC_OUTPUT =
|
---|
| 301 | define TOOL_CLANGCCMACHO_COMPILE_OBJC_CMDS
|
---|
| 302 | $(QUIET)$(TOOL_CLANGCCMACHO_OBJC) -c\
|
---|
[3579] | 303 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[1257] | 304 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 305 | -o $(obj)\
|
---|
| 306 | $(abspath $(source))
|
---|
[2431] | 307 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[1257] | 308 | endef
|
---|
[2523] | 309 | endif # !KBUILD_USE_KOBJCACHE
|
---|
[1257] | 310 |
|
---|
| 311 |
|
---|
[2356] | 312 | ## Compile Objective-C++ source.
|
---|
| 313 | # @param $(target) Normalized main target name.
|
---|
| 314 | # @param $(source) Source filename (relative).
|
---|
| 315 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 316 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 317 | # @param $(flags) Flags.
|
---|
| 318 | # @param $(defs) Definitions. No -D or something.
|
---|
| 319 | # @param $(incs) Includes. No -I or something.
|
---|
| 320 | # @param $(dirdep) Directory creation dependency.
|
---|
| 321 | # @param $(deps) Other dependencies.
|
---|
| 322 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 323 | # @param $(objsuff) Object suffix.
|
---|
[3403] | 324 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_DEPEND =
|
---|
| 325 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_DEPORD =
|
---|
[2356] | 326 | ifdef KBUILD_USE_KOBJCACHE
|
---|
[3403] | 327 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_USES_KOBJCACHE = 1
|
---|
| 328 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_OUTPUT = $(outbase).mii
|
---|
| 329 | define TOOL_CLANGCCMACHO_COMPILE_OBJCXX_CMDS
|
---|
[2356] | 330 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
| 331 | --kObjCache-cpp $(outbase).mii\
|
---|
[3403] | 332 | $(TOOL_CLANGCCMACHO_OBJCXX) -E -o -\
|
---|
[3579] | 333 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[2356] | 334 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 335 | $(abspath $(source))\
|
---|
| 336 | --kObjCache-cc $(obj)\
|
---|
[3403] | 337 | $(TOOL_CLANGCCMACHO_OBJCXX) -c\
|
---|
[2360] | 338 | $(flags) -fpreprocessed -x objective-c++ \
|
---|
[2356] | 339 | -o $(obj)\
|
---|
| 340 | -
|
---|
[2431] | 341 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[2356] | 342 | endef
|
---|
| 343 | else # !KBUILD_USE_KOBJCACHE
|
---|
[3403] | 344 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_OUTPUT =
|
---|
| 345 | define TOOL_CLANGCCMACHO_COMPILE_OBJCXX_CMDS
|
---|
| 346 | $(QUIET)$(TOOL_CLANGCCMACHO_OBJCXX) -c\
|
---|
[3579] | 347 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[2356] | 348 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 349 | -o $(obj)\
|
---|
| 350 | $(abspath $(source))
|
---|
[2431] | 351 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[2356] | 352 | endef
|
---|
[2523] | 353 | endif # !KBUILD_USE_KOBJCACHE
|
---|
[2356] | 354 |
|
---|
| 355 |
|
---|
[557] | 356 | ## Compile Assembly source.
|
---|
| 357 | # @param $(target) Normalized main target name.
|
---|
| 358 | # @param $(source) Source filename (relative).
|
---|
| 359 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 360 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 361 | # @param $(flags) Flags.
|
---|
| 362 | # @param $(defs) Definitions. No -D or something.
|
---|
| 363 | # @param $(incs) Includes. No -I or something.
|
---|
| 364 | # @param $(dirdep) Directory creation dependency.
|
---|
| 365 | # @param $(deps) Other dependencies.
|
---|
| 366 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 367 | # @param $(objsuff) Object suffix.
|
---|
| 368 | #
|
---|
[3403] | 369 | TOOL_CLANGCCMACHO_COMPILE_AS_OUTPUT =
|
---|
| 370 | TOOL_CLANGCCMACHO_COMPILE_AS_DEPEND =
|
---|
| 371 | TOOL_CLANGCCMACHO_COMPILE_AS_DEPORD =
|
---|
| 372 | define TOOL_CLANGCCMACHO_COMPILE_AS_CMDS
|
---|
| 373 | $(QUIET)$(TOOL_CLANGCCMACHO_AS) -c\
|
---|
[3579] | 374 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[557] | 375 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 376 | -o $(obj)\
|
---|
[697] | 377 | $(abspath $(source))
|
---|
[2431] | 378 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[557] | 379 | endef
|
---|
| 380 |
|
---|
| 381 |
|
---|
| 382 | ## Link library
|
---|
| 383 | # @param $(target) Normalized main target name.
|
---|
[3401] | 384 | # @param $(out) Library name.
|
---|
[557] | 385 | # @param $(objs) Object files to put in the library.
|
---|
| 386 | # @param $(flags) Flags.
|
---|
| 387 | # @param $(dirdep) Directory creation dependency.
|
---|
[3401] | 388 | # @param $(deps) Other dependencies.
|
---|
[557] | 389 | # @param $(othersrc) Unhandled sources.
|
---|
| 390 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[3403] | 391 | TOOL_CLANGCCMACHO_LINK_LIBRARY_OUTPUT =
|
---|
| 392 | TOOL_CLANGCCMACHO_LINK_LIBRARY_DEPEND = $(othersrc)
|
---|
| 393 | TOOL_CLANGCCMACHO_LINK_LIBRARY_DEPORD =
|
---|
| 394 | define TOOL_CLANGCCMACHO_LINK_LIBRARY_CMDS
|
---|
| 395 | $(if $(strip $(filter-out %.h.gch,$(objs))),$(call xargs,$(QUIET)$(TOOL_CLANGCCMACHO_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs))))
|
---|
[844] | 396 | $(foreach lib,$(othersrc)\
|
---|
| 397 | ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
|
---|
| 398 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
|
---|
| 399 | $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
|
---|
| 400 | $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
|
---|
[3403] | 401 | && $(TOOL_CLANGCCMACHO_AR) -x $(abspath $(lib)) \
|
---|
[856] | 402 | && $(RM_EXT) -f ./__.SYMDEF* \
|
---|
[3403] | 403 | && $(TOOL_CLANGCCMACHO_AR) $(flags) $(out) *) \
|
---|
[844] | 404 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
|
---|
| 405 | $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
|
---|
[557] | 406 | endef
|
---|
| 407 |
|
---|
| 408 |
|
---|
| 409 | ## Link program
|
---|
| 410 | # @param $(target) Normalized main target name.
|
---|
[3401] | 411 | # @param $(out) Program name.
|
---|
[557] | 412 | # @param $(objs) Object files to link together.
|
---|
| 413 | # @param $(libs) Libraries to search.
|
---|
| 414 | # @param $(libpath) Library search paths.
|
---|
| 415 | # @param $(flags) Flags.
|
---|
| 416 | # @param $(dirdep) Directory creation dependency.
|
---|
[3401] | 417 | # @param $(deps) Other dependencies.
|
---|
[557] | 418 | # @param $(othersrc) Unhandled sources.
|
---|
| 419 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 420 | # @param $(custom_post) Custom step invoked after linking.
|
---|
| 421 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[3403] | 422 | TOOL_CLANGCCMACHO_LINK_PROGRAM_OUTPUT_MAYBE_PRECIOUS = $(outbase).rsp
|
---|
| 423 | TOOL_CLANGCCMACHO_LINK_PROGRAM_OUTPUT_DEBUG = $(call TOOL_CLANGCCMACHO_DEBUG_BUNDLE_FN,$(out))
|
---|
| 424 | TOOL_CLANGCCMACHO_LINK_PROGRAM_DEBUG_INSTALL_FN = $(TOOL_CLANGCCMACHO_DEBUG_INSTALL_FN)
|
---|
| 425 | TOOL_CLANGCCMACHO_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
| 426 | TOOL_CLANGCCMACHO_LINK_PROGRAM_DEPORD =
|
---|
| 427 | define TOOL_CLANGCCMACHO_LINK_PROGRAM_CMDS
|
---|
[3404] | 428 | $(QUIET)$(APPEND) -tn $(outbase).rsp $(filter-out %.h.gch,$(objs))
|
---|
[3403] | 429 | $(QUIET)$(TOOL_CLANGCCMACHO_LD) $(flags) -o $(out)\
|
---|
[844] | 430 | -filelist $(outbase).rsp\
|
---|
[557] | 431 | $(foreach p,$(libpath), -L$(p))\
|
---|
[1259] | 432 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
---|
[2523] | 433 | ifeq ($(ld_debug),split)
|
---|
[3403] | 434 | $(QUIET)$(TOOL_CLANGCCMACHO_DSYMUTIL) -o $(out).dSYM/ $(out)
|
---|
| 435 | $(QUIET)$(TOOL_CLANGCCMACHO_STRIP_PROGRAM) $(out)
|
---|
[2523] | 436 | endif
|
---|
[557] | 437 | endef
|
---|
| 438 |
|
---|
| 439 |
|
---|
| 440 | ## Link DLL
|
---|
| 441 | # @param $(target) Normalized main target name.
|
---|
[3401] | 442 | # @param $(out) Program name.
|
---|
[557] | 443 | # @param $(objs) Object files to link together.
|
---|
| 444 | # @param $(libs) Libraries to search.
|
---|
| 445 | # @param $(libpath) Library search paths.
|
---|
| 446 | # @param $(flags) Flags.
|
---|
| 447 | # @param $(dirdep) Directory creation dependency.
|
---|
[3401] | 448 | # @param $(deps) Other dependencies.
|
---|
[557] | 449 | # @param $(othersrc) Unhandled sources.
|
---|
| 450 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 451 | # @param $(custom_post) Custom step invoked after linking.
|
---|
| 452 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[3403] | 453 | TOOL_CLANGCCMACHO_LINK_DLL_OUTPUT_MAYBE_PRECIOUS = $(outbase).rsp
|
---|
| 454 | TOOL_CLANGCCMACHO_LINK_DLL_OUTPUT_DEBUG = $(call TOOL_CLANGCCMACHO_DEBUG_BUNDLE_FN,$(out))
|
---|
| 455 | TOOL_CLANGCCMACHO_LINK_DLL_DEBUG_INSTALL_FN = $(TOOL_CLANGCCMACHO_DEBUG_INSTALL_FN)
|
---|
| 456 | TOOL_CLANGCCMACHO_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
| 457 | TOOL_CLANGCCMACHO_LINK_DLL_DEPORD =
|
---|
| 458 | define TOOL_CLANGCCMACHO_LINK_DLL_CMDS
|
---|
[3404] | 459 | $(QUIET)$(APPEND) -tn $(outbase).rsp $(filter-out %.h.gch,$(objs))
|
---|
[3403] | 460 | $(QUIET)$(TOOL_CLANGCCMACHO_LD) $(TOOL_CLANGCCMACHO_LDFLAGS.dll) $(flags) -o $(out)\
|
---|
| 461 | $(call TOOL_CLANGCCMACHO_LD_SONAME,$(target),$(out))\
|
---|
[844] | 462 | -filelist $(outbase).rsp\
|
---|
[557] | 463 | $(foreach p,$(libpath), -L$(p))\
|
---|
[1259] | 464 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
---|
[2523] | 465 | ifeq ($(ld_debug),split)
|
---|
[3403] | 466 | $(QUIET)$(TOOL_CLANGCCMACHO_DSYMUTIL) -o $(out).dSYM/ $(out)
|
---|
| 467 | $(QUIET)$(TOOL_CLANGCCMACHO_STRIP_DLL) $(out)
|
---|
[2523] | 468 | endif
|
---|
[557] | 469 | endef
|
---|
| 470 |
|
---|
| 471 |
|
---|
| 472 | ## Link system module (windows aka driver, linux aka kernel module)
|
---|
| 473 | # @param $(target) Normalized main target name.
|
---|
[3401] | 474 | # @param $(out) System module name.
|
---|
[557] | 475 | # @param $(objs) Object files to link together.
|
---|
| 476 | # @param $(libs) Libraries to search.
|
---|
| 477 | # @param $(libpath) Library search paths.
|
---|
| 478 | # @param $(flags) Flags.
|
---|
| 479 | # @param $(dirdep) Directory creation dependency.
|
---|
[3401] | 480 | # @param $(deps) Other dependencies.
|
---|
[557] | 481 | # @param $(othersrc) Unhandled sources.
|
---|
| 482 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 483 | # @param $(custom_post) Custom step invoked after linking.
|
---|
| 484 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[3403] | 485 | TOOL_CLANGCCMACHO_LINK_SYSMOD_OUTPUT_MAYBE_PRECIOUS = $(outbase).rsp
|
---|
| 486 | TOOL_CLANGCCMACHO_LINK_SYSMOD_OUTPUT_DEBUG = $(call TOOL_CLANGCCMACHO_DEBUG_BUNDLE_FN,$(out))
|
---|
| 487 | TOOL_CLANGCCMACHO_LINK_SYSMOD_DEBUG_INSTALL_FN = $(TOOL_CLANGCCMACHO_DEBUG_INSTALL_FN)
|
---|
| 488 | TOOL_CLANGCCMACHO_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
| 489 | TOOL_CLANGCCMACHO_LINK_SYSMOD_DEPORD =
|
---|
| 490 | define TOOL_CLANGCCMACHO_LINK_SYSMOD_CMDS
|
---|
[3404] | 491 | $(QUIET)$(APPEND) -tn $(outbase).rsp $(filter-out %.h.gch,$(objs))
|
---|
[3403] | 492 | $(QUIET)$(TOOL_CLANGCCMACHO_LD_SYSMOD) $(TOOL_CLANGCCMACHO_LDFLAGS.sysmod) $(flags) -o $(out)\
|
---|
[844] | 493 | -filelist $(outbase).rsp\
|
---|
[557] | 494 | $(foreach p,$(libpath), -L$(p))\
|
---|
[1259] | 495 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
---|
[2523] | 496 | ifeq ($(ld_debug),split)
|
---|
[3403] | 497 | $(QUIET)$(TOOL_CLANGCCMACHO_DSYMUTIL) -o $(out).dSYM/ $(out)
|
---|
| 498 | $(QUIET)$(TOOL_CLANGCCMACHO_STRIP_SYSMOD) $(out)
|
---|
[2523] | 499 | endif
|
---|
[557] | 500 | endef
|
---|
| 501 |
|
---|