| 1 | # $Id: CLANGCCMACHO.kmk 3580 2023-01-05 02:16:42Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | # kBuild Tool Config - LLVM Clang targeting Darwin (Mac OS X) Mach-O, for building C code.
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2004-2020 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
|
|---|
| 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 | #
|
|---|
| 26 | # As a special exception you are granted permission to include this file, via
|
|---|
| 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.
|
|---|
| 29 | # This exception does not however invalidate any other reasons why the makefile,
|
|---|
| 30 | # program, whatever should not be covered the GPL.
|
|---|
| 31 | #
|
|---|
| 32 | #
|
|---|
| 33 |
|
|---|
| 34 | ifndef INCLUDED_DARWIN_COMMON_KMK
|
|---|
| 35 | include $(KBUILD_PATH)/darwin-common.kmk
|
|---|
| 36 | endif
|
|---|
| 37 |
|
|---|
| 38 | TOOL_CLANGCCMACHO := LLVM Clang targeting Darwin (Mac OS X) Mach-O, for building C code.
|
|---|
| 39 |
|
|---|
| 40 | # Tool Specific Properties
|
|---|
| 41 | # PREFIX/SUFFIX: clang; PREFIX2/SUFFIX2: cctool;
|
|---|
| 42 | ifndef PATH_TOOL_CLANGCCMACHO
|
|---|
| 43 | PATH_TOOL_CLANGCCMACHO := $(substr $(firstfile $(foreachfile toolchaindir, $(DARWINCMN_TOOLCHAIN_DIRS) \
|
|---|
| 44 | , $(qwildcard ,$(toolchaindir)/usr/bin/clang++))), 1, -12)
|
|---|
| 45 | else
|
|---|
| 46 | PATH_TOOL_CLANGCCMACHO := $(PATH_TOOL_CLANGCCMACHO)
|
|---|
| 47 | endif
|
|---|
| 48 | ifndef TOOL_CLANGCCMACHO_PREFIX
|
|---|
| 49 | ifdef PATH_TOOL_CLANGCCMACHO
|
|---|
| 50 | TOOL_CLANGCCMACHO_PREFIX := $(PATH_TOOL_CLANGCCMACHO)/bin/
|
|---|
| 51 | else
|
|---|
| 52 | TOOL_CLANGCCMACHO_PREFIX :=
|
|---|
| 53 | endif
|
|---|
| 54 | endif
|
|---|
| 55 | ifndef TOOL_CLANGCCMACHO_SUFFIX
|
|---|
| 56 | TOOL_CLANGCCMACHO_SUFFIX := $(HOSTSUFF_EXE)
|
|---|
| 57 | endif
|
|---|
| 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)
|
|---|
| 72 |
|
|---|
| 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
|
|---|
| 78 |
|
|---|
| 79 | # General Properties used by kBuild
|
|---|
| 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 ?=
|
|---|
| 87 |
|
|---|
| 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 ?=
|
|---|
| 95 |
|
|---|
| 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)
|
|---|
| 103 |
|
|---|
| 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 ?=
|
|---|
| 111 |
|
|---|
| 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 ?=
|
|---|
| 119 |
|
|---|
| 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
|
|---|
| 124 |
|
|---|
| 125 | TOOL_CLANGCCMACHO_ARFLAGS ?= -c -rs
|
|---|
| 126 | TOOL_CLANGCCMACHO_ARLIBSUFF ?= .a
|
|---|
| 127 |
|
|---|
| 128 | TOOL_CLANGCCMACHO_LDFLAGS ?=
|
|---|
| 129 | TOOL_CLANGCCMACHO_LDFLAGS.debug ?= -g
|
|---|
| 130 | TOOL_CLANGCCMACHO_LDFLAGS.profile ?= -g
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | ##
|
|---|
| 135 | # Calculate the files in the debug bundle.
|
|---|
| 136 | # @param 1 The whole output filename.
|
|---|
| 137 | # @param 2 The output filename sans suffix.
|
|---|
| 138 | TOOL_CLANGCCMACHO_DEBUG_BUNDLE_FN = \
|
|---|
| 139 | $(1).dSYM/Contents/Info.plist \
|
|---|
| 140 | $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1))
|
|---|
| 141 |
|
|---|
| 142 | ##
|
|---|
| 143 | # Calculate the files in the debug bundle.
|
|---|
| 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).
|
|---|
| 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.
|
|---|
| 150 | TOOL_CLANGCCMACHO_DEBUG_INSTALL_FN= \
|
|---|
| 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 \
|
|---|
| 156 | $(1).dSYM/Contents/Resources/DWARF/$(notdir $(1))=>$(3).dSYM/Contents/Resources/DWARF/$(notdir $(3))
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 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.
|
|---|
| 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
|
|---|
| 177 | if "$(use_objcache)" != ""
|
|---|
| 178 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
|---|
| 179 | --kObjCache-cpp $(outbase).i\
|
|---|
| 180 | $(TOOL_CLANGCCMACHO_CC) -E -o -\
|
|---|
| 181 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 182 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 183 | $(abspath $(source))\
|
|---|
| 184 | --kObjCache-cc $(obj)\
|
|---|
| 185 | $(TOOL_CLANGCCMACHO_CC) -c\
|
|---|
| 186 | $(flags) -fpreprocessed -x c\
|
|---|
| 187 | -o $(obj)\
|
|---|
| 188 | -
|
|---|
| 189 | else
|
|---|
| 190 | $(QUIET)$(TOOL_CLANGCCMACHO_CC) -c\
|
|---|
| 191 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 192 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 193 | -o $(obj)\
|
|---|
| 194 | $(abspath $(source))
|
|---|
| 195 | endif
|
|---|
| 196 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 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.
|
|---|
| 204 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 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.
|
|---|
| 209 | # @param $(deps) Other dependencies.
|
|---|
| 210 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 211 | # @param $(objsuff) Object suffix.
|
|---|
| 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
|
|---|
| 217 | if "$(use_objcache)" != ""
|
|---|
| 218 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
|---|
| 219 | --kObjCache-cpp $(outbase).ii\
|
|---|
| 220 | $(TOOL_CLANGCCMACHO_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
|
|---|
| 221 | ,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
|
|---|
| 222 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 223 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 224 | $(abspath $(source))\
|
|---|
| 225 | --kObjCache-cc $(obj)\
|
|---|
| 226 | $(TOOL_CLANGCCMACHO_CXX) -c\
|
|---|
| 227 | $(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
|
|---|
| 228 | -o $(obj)\
|
|---|
| 229 | -
|
|---|
| 230 | else
|
|---|
| 231 | $(QUIET)$(TOOL_CLANGCCMACHO_CXX) -c\
|
|---|
| 232 | $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 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
|
|---|
| 238 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 239 | endef
|
|---|
| 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.
|
|---|
| 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\
|
|---|
| 259 | $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 260 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 261 | -o $(obj)\
|
|---|
| 262 | $(abspath $(source))
|
|---|
| 263 | $(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
|
|---|
| 264 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 265 | endef
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 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.
|
|---|
| 280 | TOOL_CLANGCCMACHO_COMPILE_OBJC_DEPEND =
|
|---|
| 281 | TOOL_CLANGCCMACHO_COMPILE_OBJC_DEPORD =
|
|---|
| 282 | ifdef KBUILD_USE_KOBJCACHE
|
|---|
| 283 | TOOL_CLANGCCMACHO_COMPILE_OBJC_USES_KOBJCACHE = 1
|
|---|
| 284 | TOOL_CLANGCCMACHO_COMPILE_OBJC_OUTPUT = $(outbase).mi
|
|---|
| 285 | define TOOL_CLANGCCMACHO_COMPILE_OBJC_CMDS
|
|---|
| 286 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
|---|
| 287 | --kObjCache-cpp $(outbase).ii\
|
|---|
| 288 | $(TOOL_CLANGCCMACHO_OBJC) -E -o -\
|
|---|
| 289 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 290 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 291 | $(abspath $(source))\
|
|---|
| 292 | --kObjCache-cc $(obj)\
|
|---|
| 293 | $(TOOL_CLANGCCMACHO_OBJC) -c\
|
|---|
| 294 | $(flags) -fpreprocessed -x objective-c \
|
|---|
| 295 | -o $(obj)\
|
|---|
| 296 | -
|
|---|
| 297 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 298 | endef
|
|---|
| 299 | else # !KBUILD_USE_KOBJCACHE
|
|---|
| 300 | TOOL_CLANGCCMACHO_COMPILE_OBJC_OUTPUT =
|
|---|
| 301 | define TOOL_CLANGCCMACHO_COMPILE_OBJC_CMDS
|
|---|
| 302 | $(QUIET)$(TOOL_CLANGCCMACHO_OBJC) -c\
|
|---|
| 303 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 304 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 305 | -o $(obj)\
|
|---|
| 306 | $(abspath $(source))
|
|---|
| 307 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 308 | endef
|
|---|
| 309 | endif # !KBUILD_USE_KOBJCACHE
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 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.
|
|---|
| 324 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_DEPEND =
|
|---|
| 325 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_DEPORD =
|
|---|
| 326 | ifdef KBUILD_USE_KOBJCACHE
|
|---|
| 327 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_USES_KOBJCACHE = 1
|
|---|
| 328 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_OUTPUT = $(outbase).mii
|
|---|
| 329 | define TOOL_CLANGCCMACHO_COMPILE_OBJCXX_CMDS
|
|---|
| 330 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
|---|
| 331 | --kObjCache-cpp $(outbase).mii\
|
|---|
| 332 | $(TOOL_CLANGCCMACHO_OBJCXX) -E -o -\
|
|---|
| 333 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 334 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 335 | $(abspath $(source))\
|
|---|
| 336 | --kObjCache-cc $(obj)\
|
|---|
| 337 | $(TOOL_CLANGCCMACHO_OBJCXX) -c\
|
|---|
| 338 | $(flags) -fpreprocessed -x objective-c++ \
|
|---|
| 339 | -o $(obj)\
|
|---|
| 340 | -
|
|---|
| 341 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 342 | endef
|
|---|
| 343 | else # !KBUILD_USE_KOBJCACHE
|
|---|
| 344 | TOOL_CLANGCCMACHO_COMPILE_OBJCXX_OUTPUT =
|
|---|
| 345 | define TOOL_CLANGCCMACHO_COMPILE_OBJCXX_CMDS
|
|---|
| 346 | $(QUIET)$(TOOL_CLANGCCMACHO_OBJCXX) -c\
|
|---|
| 347 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 348 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 349 | -o $(obj)\
|
|---|
| 350 | $(abspath $(source))
|
|---|
| 351 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 352 | endef
|
|---|
| 353 | endif # !KBUILD_USE_KOBJCACHE
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 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 | #
|
|---|
| 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\
|
|---|
| 374 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
|---|
| 375 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 376 | -o $(obj)\
|
|---|
| 377 | $(abspath $(source))
|
|---|
| 378 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 379 | endef
|
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 | ## Link library
|
|---|
| 383 | # @param $(target) Normalized main target name.
|
|---|
| 384 | # @param $(out) Library name.
|
|---|
| 385 | # @param $(objs) Object files to put in the library.
|
|---|
| 386 | # @param $(flags) Flags.
|
|---|
| 387 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 388 | # @param $(deps) Other dependencies.
|
|---|
| 389 | # @param $(othersrc) Unhandled sources.
|
|---|
| 390 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 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))))
|
|---|
| 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/ \
|
|---|
| 401 | && $(TOOL_CLANGCCMACHO_AR) -x $(abspath $(lib)) \
|
|---|
| 402 | && $(RM_EXT) -f ./__.SYMDEF* \
|
|---|
| 403 | && $(TOOL_CLANGCCMACHO_AR) $(flags) $(out) *) \
|
|---|
| 404 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
|
|---|
| 405 | $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
|
|---|
| 406 | endef
|
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 | ## Link program
|
|---|
| 410 | # @param $(target) Normalized main target name.
|
|---|
| 411 | # @param $(out) Program name.
|
|---|
| 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.
|
|---|
| 417 | # @param $(deps) Other dependencies.
|
|---|
| 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.
|
|---|
| 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
|
|---|
| 428 | $(QUIET)$(APPEND) -tn $(outbase).rsp $(filter-out %.h.gch,$(objs))
|
|---|
| 429 | $(QUIET)$(TOOL_CLANGCCMACHO_LD) $(flags) -o $(out)\
|
|---|
| 430 | -filelist $(outbase).rsp\
|
|---|
| 431 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 432 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
|---|
| 433 | ifeq ($(ld_debug),split)
|
|---|
| 434 | $(QUIET)$(TOOL_CLANGCCMACHO_DSYMUTIL) -o $(out).dSYM/ $(out)
|
|---|
| 435 | $(QUIET)$(TOOL_CLANGCCMACHO_STRIP_PROGRAM) $(out)
|
|---|
| 436 | endif
|
|---|
| 437 | endef
|
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 | ## Link DLL
|
|---|
| 441 | # @param $(target) Normalized main target name.
|
|---|
| 442 | # @param $(out) Program name.
|
|---|
| 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.
|
|---|
| 448 | # @param $(deps) Other dependencies.
|
|---|
| 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.
|
|---|
| 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
|
|---|
| 459 | $(QUIET)$(APPEND) -tn $(outbase).rsp $(filter-out %.h.gch,$(objs))
|
|---|
| 460 | $(QUIET)$(TOOL_CLANGCCMACHO_LD) $(TOOL_CLANGCCMACHO_LDFLAGS.dll) $(flags) -o $(out)\
|
|---|
| 461 | $(call TOOL_CLANGCCMACHO_LD_SONAME,$(target),$(out))\
|
|---|
| 462 | -filelist $(outbase).rsp\
|
|---|
| 463 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 464 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
|---|
| 465 | ifeq ($(ld_debug),split)
|
|---|
| 466 | $(QUIET)$(TOOL_CLANGCCMACHO_DSYMUTIL) -o $(out).dSYM/ $(out)
|
|---|
| 467 | $(QUIET)$(TOOL_CLANGCCMACHO_STRIP_DLL) $(out)
|
|---|
| 468 | endif
|
|---|
| 469 | endef
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 | ## Link system module (windows aka driver, linux aka kernel module)
|
|---|
| 473 | # @param $(target) Normalized main target name.
|
|---|
| 474 | # @param $(out) System module name.
|
|---|
| 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.
|
|---|
| 480 | # @param $(deps) Other dependencies.
|
|---|
| 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.
|
|---|
| 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
|
|---|
| 491 | $(QUIET)$(APPEND) -tn $(outbase).rsp $(filter-out %.h.gch,$(objs))
|
|---|
| 492 | $(QUIET)$(TOOL_CLANGCCMACHO_LD_SYSMOD) $(TOOL_CLANGCCMACHO_LDFLAGS.sysmod) $(flags) -o $(out)\
|
|---|
| 493 | -filelist $(outbase).rsp\
|
|---|
| 494 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 495 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
|---|
| 496 | ifeq ($(ld_debug),split)
|
|---|
| 497 | $(QUIET)$(TOOL_CLANGCCMACHO_DSYMUTIL) -o $(out).dSYM/ $(out)
|
|---|
| 498 | $(QUIET)$(TOOL_CLANGCCMACHO_STRIP_SYSMOD) $(out)
|
|---|
| 499 | endif
|
|---|
| 500 | endef
|
|---|
| 501 |
|
|---|