[93] | 1 | # $Id: GXX3.kmk 3567 2022-06-26 20:00:02Z bird $
|
---|
| 2 | ## @file
|
---|
[3391] | 3 | # kBuild Tool Config - Generic GCC v3.2+ using the system GCC and Binutils, for building C++ code.
|
---|
[93] | 4 | #
|
---|
[1547] | 5 |
|
---|
| 6 | #
|
---|
[3121] | 7 | # Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
|
---|
[93] | 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
|
---|
[1612] | 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 | #
|
---|
[93] | 33 |
|
---|
[971] | 34 | TOOL_GXX3 := Generic GCC v3.2.x or later using the system GCC and Binutils, for building C++ code.
|
---|
[93] | 35 |
|
---|
[667] | 36 | # Tool Specific Properties
|
---|
[3391] | 37 | ifndef TOOL_GXX3_PREFIX
|
---|
[3393] | 38 | TOOL_GXX3_PREFIX :=
|
---|
[3391] | 39 | endif
|
---|
| 40 | ifndef TOOL_GXX3_SUFFIX
|
---|
[3393] | 41 | TOOL_GXX3_SUFFIX := $(HOSTSUFF_EXE)
|
---|
[3391] | 42 | endif
|
---|
[3393] | 43 | if1of ($(KBUILD_HOST), solaris)
|
---|
| 44 | TOOL_GXX3_PREFIX2 ?= g
|
---|
[811] | 45 | else
|
---|
[3393] | 46 | TOOL_GXX3_PREFIX2 ?=
|
---|
[811] | 47 | endif
|
---|
[3393] | 48 | TOOL_GXX3_SUFFIX2 ?= $(HOSTSUFF_EXE)
|
---|
| 49 | TOOL_GXX3_PREFIX3 ?=
|
---|
| 50 | TOOL_GXX3_SUFFIX3 ?= $(HOSTSUFF_EXE)
|
---|
| 51 |
|
---|
| 52 | TOOL_GXX3_CC ?= $(TOOL_GXX3_PREFIX)gcc$(TOOL_GXX3_SUFFIX)
|
---|
| 53 | TOOL_GXX3_CXX ?= $(TOOL_GXX3_PREFIX)g++$(TOOL_GXX3_SUFFIX)
|
---|
| 54 | TOOL_GXX3_PCH ?= $(TOOL_GXX3_CXX)
|
---|
| 55 | TOOL_GXX3_AS ?= $(TOOL_GXX3_PREFIX)gcc$(TOOL_GXX3_SUFFIX)
|
---|
| 56 | TOOL_GXX3_AR ?= $(TOOL_GXX3_PREFIX2)ar$(TOOL_GXX3_SUFFIX2)
|
---|
[1504] | 57 | ifeq ($(KBUILD_TARGET),os2)
|
---|
[3393] | 58 | TOOL_GXX3_AR_IMP ?= $(TOOL_GXX3_PREFIX3)emximp$(TOOL_GXX3_SUFFIX3)
|
---|
[474] | 59 | else
|
---|
[3391] | 60 | TOOL_GXX3_AR_IMP ?= $(ECHO) not supported!
|
---|
[474] | 61 | endif
|
---|
[3391] | 62 | TOOL_GXX3_LD ?= $(TOOL_GXX3_PREFIX)g++$(TOOL_GXX3_SUFFIX)
|
---|
[3393] | 63 | if1of ($(KBUILD_HOST), solaris)
|
---|
| 64 | TOOL_GXX3_LD_SYSMOD ?= $(TOOL_GXX3_PREFIX3)ld$(TOOL_GXX3_SUFFIX3)
|
---|
| 65 | else
|
---|
| 66 | TOOL_GXX3_LD_SYSMOD ?= $(TOOL_GXX3_PREFIX2)ld$(TOOL_GXX3_SUFFIX2)
|
---|
| 67 | endif
|
---|
[1504] | 68 | ifndef TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET)
|
---|
[3391] | 69 | TOOL_GXX3_LDFLAGS.dll ?= -shared
|
---|
[130] | 70 | else
|
---|
[3391] | 71 | TOOL_GXX3_LDFLAGS.dll ?= $(TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET))
|
---|
[130] | 72 | endif
|
---|
[971] | 73 | TOOL_GXX3_LDFLAGS.sysmod ?= -r
|
---|
[3391] | 74 | TOOL_GXX3_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
---|
[1504] | 75 | ifeq ($(KBUILD_TARGET),os2)
|
---|
[3391] | 76 | TOOL_GXX3_LD_MAP ?= -Zmap=$(1)
|
---|
[971] | 77 | TOOL_GXX3_LD_SYSMOD_MAP ?= -Zmap=$(1)
|
---|
[1612] | 78 | else
|
---|
[3391] | 79 | TOOL_GXX3_LD_MAP ?=
|
---|
[1612] | 80 | TOOL_GXX3_LD_SYSMOD_MAP ?=
|
---|
[231] | 81 | endif
|
---|
[3393] | 82 | TOOL_GXX3_OBJCOPY ?= $(TOOL_GXX3_PREFIX)objcopy$(TOOL_GXX3_SUFFIX)
|
---|
[2534] | 83 |
|
---|
[667] | 84 | # General Properties used by kBuild
|
---|
[971] | 85 | TOOL_GXX3_COBJSUFF ?= .o
|
---|
| 86 | TOOL_GXX3_CFLAGS ?=
|
---|
| 87 | TOOL_GXX3_CFLAGS.debug ?= -g
|
---|
[1058] | 88 | TOOL_GXX3_CFLAGS.profile ?= -O2 #-g -pg
|
---|
[971] | 89 | TOOL_GXX3_CFLAGS.release ?= -O2
|
---|
| 90 | TOOL_GXX3_CINCS ?=
|
---|
| 91 | TOOL_GXX3_CDEFS ?=
|
---|
[137] | 92 |
|
---|
[971] | 93 | TOOL_GXX3_CXXOBJSUFF ?= .o
|
---|
| 94 | TOOL_GXX3_CXXFLAGS ?=
|
---|
| 95 | TOOL_GXX3_CXXFLAGS.debug ?= -g
|
---|
[1058] | 96 | TOOL_GXX3_CXXFLAGS.profile ?= -O2 #-g -pg
|
---|
[971] | 97 | TOOL_GXX3_CXXFLAGS.release ?= -O2
|
---|
| 98 | TOOL_GXX3_CXXINCS ?=
|
---|
| 99 | TOOL_GXX3_CXXDEFS ?=
|
---|
[667] | 100 |
|
---|
[3250] | 101 | TOOL_GXX3_PCHOBJSUFF ?= .h.gch
|
---|
| 102 | TOOL_GXX3_PCHFLAGS ?= $(TOOL_GXX3_CXXFLAGS)
|
---|
| 103 | TOOL_GXX3_PCHFLAGS.debug ?= $(TOOL_GXX3_CXXFLAGS.debug)
|
---|
| 104 | TOOL_GXX3_PCHFLAGS.profile ?= $(TOOL_GXX3_CXXFLAGS.profile)
|
---|
| 105 | TOOL_GXX3_PCHFLAGS.release ?= $(TOOL_GXX3_CXXFLAGS.release)
|
---|
| 106 | TOOL_GXX3_PCHINCS ?= $(TOOL_GXX3_CXXINCS)
|
---|
| 107 | TOOL_GXX3_PCHDEFS ?= $(TOOL_GXX3_CXXDEFS)
|
---|
| 108 |
|
---|
[971] | 109 | TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
|
---|
| 110 | TOOL_GXX3_ASFLAGS.debug ?= -g
|
---|
| 111 | TOOL_GXX3_ASFLAGS.profile ?= -g
|
---|
| 112 | TOOL_GXX3_ASOBJSUFF ?= .o
|
---|
[667] | 113 |
|
---|
[971] | 114 | TOOL_GXX3_ARFLAGS ?= cr
|
---|
| 115 | TOOL_GXX3_ARLIBSUFF ?= .a
|
---|
[667] | 116 |
|
---|
[971] | 117 | TOOL_GXX3_LDFLAGS ?=
|
---|
| 118 | TOOL_GXX3_LDFLAGS.debug ?= -g
|
---|
| 119 | TOOL_GXX3_LDFLAGS.profile ?= -g
|
---|
[667] | 120 |
|
---|
| 121 |
|
---|
[93] | 122 | ## Compile C source.
|
---|
| 123 | # @param $(target) Normalized main target name.
|
---|
| 124 | # @param $(source) Source filename (relative).
|
---|
[235] | 125 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
[93] | 126 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 127 | # @param $(flags) Flags.
|
---|
| 128 | # @param $(defs) Definitions. No -D or something.
|
---|
| 129 | # @param $(incs) Includes. No -I or something.
|
---|
[235] | 130 | # @param $(dirdep) Directory creation dependency.
|
---|
| 131 | # @param $(deps) Other dependencies.
|
---|
[93] | 132 | #
|
---|
| 133 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[235] | 134 | # @param $(objsuff) Object suffix.
|
---|
[971] | 135 | TOOL_GXX3_COMPILE_C_DEPEND =
|
---|
| 136 | TOOL_GXX3_COMPILE_C_DEPORD =
|
---|
[3256] | 137 | TOOL_GXX3_COMPILE_C_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
|
---|
| 138 | TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
|
---|
[971] | 139 | define TOOL_GXX3_COMPILE_C_CMDS
|
---|
[3256] | 140 | if "$(use_objcache)" != ""
|
---|
[1058] | 141 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
| 142 | --kObjCache-cpp $(outbase).i\
|
---|
[1015] | 143 | $(TOOL_GXX3_CC) -E -o -\
|
---|
[3566] | 144 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[1015] | 145 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
[1058] | 146 | $(abspath $(source))\
|
---|
| 147 | --kObjCache-cc $(obj)\
|
---|
[1015] | 148 | $(TOOL_GXX3_CC) -c\
|
---|
[1058] | 149 | $(flags) -fpreprocessed -x c\
|
---|
[1015] | 150 | -o $(obj)\
|
---|
[1058] | 151 | -
|
---|
[3256] | 152 | else
|
---|
[971] | 153 | $(QUIET)$(TOOL_GXX3_CC) -c\
|
---|
[3566] | 154 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[380] | 155 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 156 | -o $(obj)\
|
---|
[697] | 157 | $(abspath $(source))
|
---|
[3256] | 158 | endif
|
---|
[2431] | 159 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[93] | 160 | endef
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 | ## Compile C++ source.
|
---|
| 164 | # @param $(target) Normalized main target name.
|
---|
| 165 | # @param $(source) Source filename (relative).
|
---|
[235] | 166 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
[3255] | 167 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
[93] | 168 | # @param $(flags) Flags.
|
---|
| 169 | # @param $(defs) Definitions. No -D or something.
|
---|
| 170 | # @param $(incs) Includes. No -I or something.
|
---|
[235] | 171 | # @param $(dirdep) Directory creation dependency.
|
---|
[3255] | 172 | # @param $(deps) Other dependencies.
|
---|
[93] | 173 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[235] | 174 | # @param $(objsuff) Object suffix.
|
---|
[3257] | 175 | TOOL_GXX3_COMPILE_CXX_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
|
---|
[3256] | 176 | TOOL_GXX3_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
|
---|
| 177 | TOOL_GXX3_COMPILE_CXX_DEPORD =
|
---|
| 178 | TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
|
---|
[971] | 179 | define TOOL_GXX3_COMPILE_CXX_CMDS
|
---|
[3256] | 180 | if "$(use_objcache)" != ""
|
---|
[1058] | 181 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
| 182 | --kObjCache-cpp $(outbase).ii\
|
---|
[3255] | 183 | $(TOOL_GXX3_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
|
---|
| 184 | ,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
|
---|
[3566] | 185 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[1015] | 186 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
[1058] | 187 | $(abspath $(source))\
|
---|
| 188 | --kObjCache-cc $(obj)\
|
---|
[1015] | 189 | $(TOOL_GXX3_CXX) -c\
|
---|
[3255] | 190 | $(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
|
---|
[1015] | 191 | -o $(obj)\
|
---|
[1058] | 192 | -
|
---|
[3256] | 193 | else
|
---|
[971] | 194 | $(QUIET)$(TOOL_GXX3_CXX) -c\
|
---|
[3566] | 195 | $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[380] | 196 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
[3250] | 197 | -o $(obj) $(if-expr defined($(target)_PCH_HDR) \
|
---|
[3254] | 198 | ,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
|
---|
[697] | 199 | $(abspath $(source))
|
---|
[3256] | 200 | endif
|
---|
[2431] | 201 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[93] | 202 | endef
|
---|
| 203 |
|
---|
| 204 |
|
---|
[3250] | 205 | ## Precompile C++ header.
|
---|
| 206 | # @param $(target) Normalized main target name.
|
---|
| 207 | # @param $(source) Source filename (relative).
|
---|
| 208 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 209 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 210 | # @param $(flags) Flags.
|
---|
| 211 | # @param $(defs) Definitions. No -D or something.
|
---|
| 212 | # @param $(incs) Includes. No -I or something.
|
---|
| 213 | # @param $(dirdep) Directory creation dependency.
|
---|
| 214 | # @param $(deps) Other dependencies.
|
---|
| 215 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 216 | # @param $(objsuff) Object suffix.
|
---|
[3257] | 217 | TOOL_GXX3_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
|
---|
| 218 | TOOL_GXX3_COMPILE_PCH_DEPEND =
|
---|
[3250] | 219 | TOOL_GXX3_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
|
---|
| 220 | define TOOL_GXX3_COMPILE_PCH_CMDS
|
---|
| 221 | $(QUIET)$(TOOL_GXX3_PCH) -c\
|
---|
[3566] | 222 | $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[3250] | 223 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 224 | -o $(obj)\
|
---|
| 225 | $(abspath $(source))
|
---|
| 226 | $(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
|
---|
| 227 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
| 228 | endef
|
---|
| 229 |
|
---|
| 230 |
|
---|
[461] | 231 | ## Compile Assembly source.
|
---|
| 232 | # @param $(target) Normalized main target name.
|
---|
| 233 | # @param $(source) Source filename (relative).
|
---|
| 234 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 235 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 236 | # @param $(flags) Flags.
|
---|
| 237 | # @param $(defs) Definitions. No -D or something.
|
---|
| 238 | # @param $(incs) Includes. No -I or something.
|
---|
| 239 | # @param $(dirdep) Directory creation dependency.
|
---|
| 240 | # @param $(deps) Other dependencies.
|
---|
| 241 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 242 | # @param $(objsuff) Object suffix.
|
---|
| 243 | #
|
---|
[971] | 244 | TOOL_GXX3_COMPILE_AS_OUTPUT =
|
---|
| 245 | TOOL_GXX3_COMPILE_AS_DEPEND =
|
---|
| 246 | TOOL_GXX3_COMPILE_AS_DEPORD =
|
---|
| 247 | define TOOL_GXX3_COMPILE_AS_CMDS
|
---|
| 248 | $(QUIET)$(TOOL_GXX3_AS) -c\
|
---|
[3566] | 249 | $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
|
---|
[461] | 250 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
| 251 | -o $(obj)\
|
---|
[697] | 252 | $(abspath $(source))
|
---|
[2431] | 253 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
---|
[461] | 254 | endef
|
---|
| 255 |
|
---|
| 256 |
|
---|
[93] | 257 | ## Link library
|
---|
| 258 | # @param $(target) Normalized main target name.
|
---|
[3254] | 259 | # @param $(out) Library name.
|
---|
[93] | 260 | # @param $(objs) Object files to put in the library.
|
---|
| 261 | # @param $(flags) Flags.
|
---|
[235] | 262 | # @param $(dirdep) Directory creation dependency.
|
---|
[3254] | 263 | # @param $(deps) Other dependencies.
|
---|
[235] | 264 | # @param $(othersrc) Unhandled sources.
|
---|
[93] | 265 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[1034] | 266 | TOOL_GXX3_LINK_LIBRARY_OUTPUT = $(out).ar-script
|
---|
| 267 | TOOL_GXX3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
|
---|
[971] | 268 | TOOL_GXX3_LINK_LIBRARY_DEPEND = $(othersrc)
|
---|
| 269 | TOOL_GXX3_LINK_LIBRARY_DEPORD =
|
---|
| 270 | define TOOL_GXX3_LINK_LIBRARY_CMDS
|
---|
[772] | 271 | $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
|
---|
| 272 | $(QUIET)$(APPEND) -n $(out).ar-script \
|
---|
[3254] | 273 | $(foreach o,$(filter-out %.h.gch,$(objs)), 'ADDMOD $(o)') \
|
---|
[2775] | 274 | $(foreach o,$(filter-out %.def %.imp %.dll,$(othersrc)), 'ADDLIB $(o)')
|
---|
| 275 | $(if $(filter %.def %.imp %.dll,$(othersrc))\
|
---|
| 276 | ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
|
---|
[772] | 277 | $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
|
---|
| 278 | $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
|
---|
| 279 | $(QUIET)$(APPEND) $(out).ar-script 'END'
|
---|
[1315] | 280 | $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX3_AR) -M
|
---|
[772] | 281 | endef
|
---|
[206] | 282 |
|
---|
| 283 |
|
---|
[93] | 284 | ## Link program
|
---|
| 285 | # @param $(target) Normalized main target name.
|
---|
[353] | 286 | # @param $(out) Program name.
|
---|
[93] | 287 | # @param $(objs) Object files to link together.
|
---|
| 288 | # @param $(libs) Libraries to search.
|
---|
| 289 | # @param $(libpath) Library search paths.
|
---|
| 290 | # @param $(flags) Flags.
|
---|
[235] | 291 | # @param $(dirdep) Directory creation dependency.
|
---|
| 292 | # @param $(deps) Other dependencies.
|
---|
| 293 | # @param $(othersrc) Unhandled sources.
|
---|
| 294 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 295 | # @param $(custom_post) Custom step invoked after linking.
|
---|
[93] | 296 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[1034] | 297 | TOOL_GXX3_LINK_PROGRAM_OUTPUT =
|
---|
| 298 | TOOL_GXX3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
|
---|
[2534] | 299 | TOOL_GXX3_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
|
---|
| 300 | TOOL_GXX3_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
|
---|
[971] | 301 | TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
|
---|
[572] | 302 | $(filter %.def, $(othersrc))
|
---|
[971] | 303 | TOOL_GXX3_LINK_PROGRAM_DEPORD =
|
---|
| 304 | define TOOL_GXX3_LINK_PROGRAM_CMDS
|
---|
[3254] | 305 | $(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
|
---|
[572] | 306 | $(filter %.def, $(othersrc))\
|
---|
[380] | 307 | $(foreach p,$(libpath), -L$(p))\
|
---|
[1259] | 308 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
|
---|
[971] | 309 | $(call TOOL_GXX3_LD_MAP,$(outbase).map)
|
---|
[2534] | 310 | ifeq ($(ld_debug),split)
|
---|
[2774] | 311 | $(QUIET)$(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
|
---|
| 312 | $(QUIET)$(CHMOD) a-x $(outbase).debug
|
---|
| 313 | $(QUIET)$(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
|
---|
[2534] | 314 | endif
|
---|
[93] | 315 | endef
|
---|
| 316 |
|
---|
[130] | 317 |
|
---|
| 318 | ## Link DLL
|
---|
| 319 | # @param $(target) Normalized main target name.
|
---|
[353] | 320 | # @param $(out) Program name.
|
---|
[130] | 321 | # @param $(objs) Object files to link together.
|
---|
| 322 | # @param $(libs) Libraries to search.
|
---|
| 323 | # @param $(libpath) Library search paths.
|
---|
| 324 | # @param $(flags) Flags.
|
---|
[235] | 325 | # @param $(dirdep) Directory creation dependency.
|
---|
| 326 | # @param $(deps) Other dependencies.
|
---|
| 327 | # @param $(othersrc) Unhandled sources.
|
---|
| 328 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 329 | # @param $(custom_post) Custom step invoked after linking.
|
---|
[130] | 330 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[1034] | 331 | TOOL_GXX3_LINK_DLL_OUTPUT =
|
---|
| 332 | TOOL_GXX3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
|
---|
[2534] | 333 | TOOL_GXX3_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
|
---|
| 334 | TOOL_GXX3_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
|
---|
[971] | 335 | TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
|
---|
[572] | 336 | $(filter %.def, $(othersrc))
|
---|
[971] | 337 | TOOL_GXX3_LINK_DLL_DEPORD =
|
---|
| 338 | define TOOL_GXX3_LINK_DLL_CMDS
|
---|
| 339 | $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
|
---|
[2541] | 340 | $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\
|
---|
[3254] | 341 | $(filter-out %.h.gch,$(objs))\
|
---|
[572] | 342 | $(filter %.def, $(othersrc))\
|
---|
[380] | 343 | $(foreach p,$(libpath), -L$(p))\
|
---|
[1259] | 344 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
|
---|
[971] | 345 | $(call TOOL_GXX3_LD_MAP,$(outbase).map)
|
---|
[2534] | 346 | ifeq ($(ld_debug),split)
|
---|
[2774] | 347 | $(QUIET)$(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
|
---|
| 348 | $(QUIET)$(CHMOD) a-x $(outbase).debug
|
---|
| 349 | $(QUIET)$(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
|
---|
[2534] | 350 | endif
|
---|
[130] | 351 | endef
|
---|
| 352 |
|
---|
[380] | 353 |
|
---|
[137] | 354 | ## Link system module (windows aka driver, linux aka kernel module)
|
---|
| 355 | # @param $(target) Normalized main target name.
|
---|
[353] | 356 | # @param $(out) System module name.
|
---|
[137] | 357 | # @param $(objs) Object files to link together.
|
---|
| 358 | # @param $(libs) Libraries to search.
|
---|
| 359 | # @param $(libpath) Library search paths.
|
---|
| 360 | # @param $(flags) Flags.
|
---|
[235] | 361 | # @param $(dirdep) Directory creation dependency.
|
---|
| 362 | # @param $(deps) Other dependencies.
|
---|
| 363 | # @param $(othersrc) Unhandled sources.
|
---|
| 364 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 365 | # @param $(custom_post) Custom step invoked after linking.
|
---|
[137] | 366 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[1034] | 367 | TOOL_GXX3_LINK_SYSMOD_OUTPUT =
|
---|
| 368 | TOOL_GXX3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
|
---|
[2534] | 369 | TOOL_GXX3_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
|
---|
| 370 | TOOL_GXX3_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
|
---|
[971] | 371 | TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
|
---|
[572] | 372 | $(filter %.def, $(othersrc))
|
---|
[971] | 373 | TOOL_GXX3_LINK_SYSMOD_DEPORD =
|
---|
| 374 | define TOOL_GXX3_LINK_SYSMOD_CMDS
|
---|
[3254] | 375 | $(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
|
---|
[572] | 376 | $(filter %.def, $(othersrc))\
|
---|
[380] | 377 | $(foreach p,$(libpath), -L$(p))\
|
---|
[1259] | 378 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
|
---|
[971] | 379 | $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map)
|
---|
[2534] | 380 | ifeq ($(ld_debug),split)
|
---|
[2774] | 381 | $(QUIET)$(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
|
---|
| 382 | $(QUIET)$(CHMOD) a-x $(outbase).debug
|
---|
| 383 | $(QUIET)$(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
|
---|
[2534] | 384 | endif
|
---|
[137] | 385 | endef
|
---|
[184] | 386 |
|
---|