| 1 | # $Id: GXX64.kmk 2018 2008-11-02 00:08:56Z bird $ | 
|---|
| 2 | ## @file | 
|---|
| 3 | # kBuild Tool Config - Generic 64-bit GCC v3.2.x or later using the system GCC, for building C++ code. | 
|---|
| 4 | # | 
|---|
| 5 |  | 
|---|
| 6 | # | 
|---|
| 7 | # Copyright (c) 2004-2008 knut st. osmundsen <bird-kBuild-spam@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 | TOOL_GXX64 := Generic 64-bit GCC v3.2.x or later using the system GCC, for building C++ code. \ | 
|---|
| 35 | More or less Linux/ELF specfic. | 
|---|
| 36 |  | 
|---|
| 37 | # Tool Specific Properties | 
|---|
| 38 | TOOL_GXX64_CC  ?= gcc$(HOSTSUFF_EXE) -m64 | 
|---|
| 39 | TOOL_GXX64_CXX ?= g++$(HOSTSUFF_EXE) -m64 | 
|---|
| 40 | TOOL_GXX64_AS  ?= gcc$(HOSTSUFF_EXE) -m64 | 
|---|
| 41 | TOOL_GXX64_AR  ?= ar$(HOSTSUFF_EXE) | 
|---|
| 42 | TOOL_GXX64_LD  ?= g++$(HOSTSUFF_EXE) -m64 | 
|---|
| 43 | TOOL_GXX64_LD_SYSMOD ?= ld$(HOSTSUFF_EXE) | 
|---|
| 44 | ifndef TOOL_GXX64_LDFLAGS.$(KBUILD_TARGET) | 
|---|
| 45 | TOOL_GXX64_LDFLAGS.dll ?= -shared | 
|---|
| 46 | else | 
|---|
| 47 | TOOL_GXX64_LDFLAGS.dll ?= $(TOOL_GXX64_LDFLAGS.$(KBUILD_TARGET)) | 
|---|
| 48 | endif | 
|---|
| 49 | TOOL_GXX64_LDFLAGS.sysmod ?= -r -m elf_x86_64 | 
|---|
| 50 | TOOL_GXX64_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2))) | 
|---|
| 51 | ifeq ($(KBUILD_TARGET),os2) | 
|---|
| 52 | TOOL_GXX64_LD_MAP ?= -Zmap=$(1) | 
|---|
| 53 | else | 
|---|
| 54 | TOOL_GXX64_LD_MAP ?= | 
|---|
| 55 | endif | 
|---|
| 56 | ifeq ($(KBUILD_TARGET),os2) | 
|---|
| 57 | TOOL_GXX64_LD_SYSMOD_MAP ?= -Zmap=$(1) | 
|---|
| 58 | else | 
|---|
| 59 | TOOL_GXX64_LD_SYSMOD_MAP ?= | 
|---|
| 60 | endif | 
|---|
| 61 | ifdef SLKRUNS | 
|---|
| 62 | TOOL_GXX64_CC  += -fmessage-length=0 | 
|---|
| 63 | TOOL_GXX64_CXX += -fmessage-length=0 | 
|---|
| 64 | endif | 
|---|
| 65 |  | 
|---|
| 66 | # General Properties used by kBuild | 
|---|
| 67 | TOOL_GXX64_COBJSUFF         ?= .o | 
|---|
| 68 | TOOL_GXX64_CFLAGS           ?= | 
|---|
| 69 | TOOL_GXX64_CFLAGS.debug     ?= -g | 
|---|
| 70 | TOOL_GXX64_CFLAGS.profile   ?= -O2 #-g -pg | 
|---|
| 71 | TOOL_GXX64_CFLAGS.release   ?= -O2 | 
|---|
| 72 | TOOL_GXX64_CINCS            ?= | 
|---|
| 73 | TOOL_GXX64_CDEFS            ?= | 
|---|
| 74 |  | 
|---|
| 75 | TOOL_GXX64_CXXOBJSUFF       ?= .o | 
|---|
| 76 | TOOL_GXX64_CXXOBJSUFF       ?= .o | 
|---|
| 77 | TOOL_GXX64_CXXFLAGS         ?= | 
|---|
| 78 | TOOL_GXX64_CXXFLAGS.debug   ?= -g | 
|---|
| 79 | TOOL_GXX64_CXXFLAGS.profile ?= -O2 #-g -pg | 
|---|
| 80 | TOOL_GXX64_CXXFLAGS.release ?= -O2 | 
|---|
| 81 | TOOL_GXX64_CXXINCS          ?= | 
|---|
| 82 | TOOL_GXX64_CXXDEFS          ?= | 
|---|
| 83 |  | 
|---|
| 84 | TOOL_GXX64_ASFLAGS          ?= -x assembler-with-cpp | 
|---|
| 85 | TOOL_GXX64_ASFLAGS.debug    ?= -g | 
|---|
| 86 | TOOL_GXX64_ASFLAGS.profile  ?= -g | 
|---|
| 87 | TOOL_GXX64_ASOBJSUFF        ?= .o | 
|---|
| 88 |  | 
|---|
| 89 | TOOL_GXX64_ARFLAGS          ?= cr | 
|---|
| 90 | TOOL_GXX64_ARLIBSUFF        ?= .a | 
|---|
| 91 |  | 
|---|
| 92 | TOOL_GXX64_LDFLAGS          ?= | 
|---|
| 93 | TOOL_GXX64_LDFLAGS.debug    ?= -g | 
|---|
| 94 | TOOL_GXX64_LDFLAGS.profile  ?= -g | 
|---|
| 95 |  | 
|---|
| 96 |  | 
|---|
| 97 | ## Compile C source. | 
|---|
| 98 | # @param    $(target)   Normalized main target name. | 
|---|
| 99 | # @param    $(source)   Source filename (relative). | 
|---|
| 100 | # @param    $(obj)      Object file name. This shall be (re)created by the compilation. | 
|---|
| 101 | # @param    $(dep)          Dependcy file. This shall be (re)created by the compilation. | 
|---|
| 102 | # @param    $(flags)    Flags. | 
|---|
| 103 | # @param    $(defs)     Definitions. No -D or something. | 
|---|
| 104 | # @param    $(incs)     Includes. No -I or something. | 
|---|
| 105 | # @param    $(dirdep)   Directory creation dependency. | 
|---|
| 106 | # @param    $(deps)             Other dependencies. | 
|---|
| 107 | # | 
|---|
| 108 | # @param    $(outbase)  Output basename (full). Use this for list files and such. | 
|---|
| 109 | # @param    $(objsuff)  Object suffix. | 
|---|
| 110 | TOOL_GXX64_COMPILE_C_DEPEND = | 
|---|
| 111 | TOOL_GXX64_COMPILE_C_DEPORD = | 
|---|
| 112 | ifdef KBUILD_USE_KOBJCACHE | 
|---|
| 113 | TOOL_GXX64_COMPILE_C_USES_KOBJCACHE = 1 | 
|---|
| 114 | TOOL_GXX64_COMPILE_C_OUTPUT = $(outbase).i | 
|---|
| 115 | define TOOL_GXX64_COMPILE_C_CMDS | 
|---|
| 116 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\ | 
|---|
| 117 | --kObjCache-cpp $(outbase).i\ | 
|---|
| 118 | $(TOOL_GXX64_CC) -E -o -\ | 
|---|
| 119 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ | 
|---|
| 120 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ | 
|---|
| 121 | $(abspath $(source))\ | 
|---|
| 122 | --kObjCache-cc $(obj)\ | 
|---|
| 123 | $(TOOL_GXX64_CC) -c\ | 
|---|
| 124 | $(flags) -fpreprocessed -x c\ | 
|---|
| 125 | -o $(obj)\ | 
|---|
| 126 | - | 
|---|
| 127 | endef | 
|---|
| 128 | else # !KBUILD_USE_KOBJCACHE | 
|---|
| 129 | TOOL_GXX64_COMPILE_C_OUTPUT = | 
|---|
| 130 | define TOOL_GXX64_COMPILE_C_CMDS | 
|---|
| 131 | $(QUIET)$(TOOL_GXX64_CC) -c\ | 
|---|
| 132 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ | 
|---|
| 133 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ | 
|---|
| 134 | -o $(obj)\ | 
|---|
| 135 | $(abspath $(source)) | 
|---|
| 136 | endef | 
|---|
| 137 | endif # !KBUILD_USE_KOBJCACHE | 
|---|
| 138 |  | 
|---|
| 139 |  | 
|---|
| 140 | ## Compile C++ source. | 
|---|
| 141 | # @param    $(target)   Normalized main target name. | 
|---|
| 142 | # @param    $(source)   Source filename (relative). | 
|---|
| 143 | # @param    $(obj)      Object file name. This shall be (re)created by the compilation. | 
|---|
| 144 | # @param    $(dep)          Dependcy file. This shall be (re)created by the compilation. | 
|---|
| 145 | # @param    $(flags)    Flags. | 
|---|
| 146 | # @param    $(defs)     Definitions. No -D or something. | 
|---|
| 147 | # @param    $(incs)     Includes. No -I or something. | 
|---|
| 148 | # @param    $(dirdep)   Directory creation dependency. | 
|---|
| 149 | # @param    $(deps)             Other dependencies. | 
|---|
| 150 | # @param    $(outbase)  Output basename (full). Use this for list files and such. | 
|---|
| 151 | # @param    $(objsuff)  Object suffix. | 
|---|
| 152 | TOOL_GXX64_COMPILE_CXX_DEPEND = | 
|---|
| 153 | TOOL_GXX64_COMPILE_CXX_DEPORD = | 
|---|
| 154 | ifdef KBUILD_USE_KOBJCACHE | 
|---|
| 155 | TOOL_GXX64_COMPILE_CXX_USES_KOBJCACHE = 1 | 
|---|
| 156 | TOOL_GXX64_COMPILE_CXX_OUTPUT = $(outbase).ii | 
|---|
| 157 | define TOOL_GXX64_COMPILE_CXX_CMDS | 
|---|
| 158 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\ | 
|---|
| 159 | --kObjCache-cpp $(outbase).ii\ | 
|---|
| 160 | $(TOOL_GXX64_CXX) -E -o -\ | 
|---|
| 161 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ | 
|---|
| 162 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ | 
|---|
| 163 | $(abspath $(source))\ | 
|---|
| 164 | --kObjCache-cc $(obj)\ | 
|---|
| 165 | $(TOOL_GXX64_CXX) -c\ | 
|---|
| 166 | $(flags) -fpreprocessed -x c++\ | 
|---|
| 167 | -o $(obj)\ | 
|---|
| 168 | - | 
|---|
| 169 | endef | 
|---|
| 170 | else # !KBUILD_USE_KOBJCACHE | 
|---|
| 171 | TOOL_GXX64_COMPILE_CXX_OUTPUT = | 
|---|
| 172 | define TOOL_GXX64_COMPILE_CXX_CMDS | 
|---|
| 173 | $(QUIET)$(TOOL_GXX64_CXX) -c\ | 
|---|
| 174 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ | 
|---|
| 175 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ | 
|---|
| 176 | -o $(obj)\ | 
|---|
| 177 | $(abspath $(source)) | 
|---|
| 178 | endef | 
|---|
| 179 | endif # !KBUILD_USE_KOBJCACHE | 
|---|
| 180 |  | 
|---|
| 181 |  | 
|---|
| 182 | ## Compile Assembly source. | 
|---|
| 183 | # @param    $(target)   Normalized main target name. | 
|---|
| 184 | # @param    $(source)   Source filename (relative). | 
|---|
| 185 | # @param    $(obj)      Object file name. This shall be (re)created by the compilation. | 
|---|
| 186 | # @param    $(dep)      Dependcy file. This shall be (re)created by the compilation. | 
|---|
| 187 | # @param    $(flags)    Flags. | 
|---|
| 188 | # @param    $(defs)     Definitions. No -D or something. | 
|---|
| 189 | # @param    $(incs)     Includes. No -I or something. | 
|---|
| 190 | # @param    $(dirdep)   Directory creation dependency. | 
|---|
| 191 | # @param    $(deps)     Other dependencies. | 
|---|
| 192 | # @param    $(outbase)  Output basename (full). Use this for list files and such. | 
|---|
| 193 | # @param    $(objsuff)  Object suffix. | 
|---|
| 194 | # | 
|---|
| 195 | TOOL_GXX64_COMPILE_AS_OUTPUT = | 
|---|
| 196 | TOOL_GXX64_COMPILE_AS_DEPEND = | 
|---|
| 197 | TOOL_GXX64_COMPILE_AS_DEPORD = | 
|---|
| 198 | define TOOL_GXX64_COMPILE_AS_CMDS | 
|---|
| 199 | $(QUIET)$(TOOL_GXX64_AS) -c\ | 
|---|
| 200 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ | 
|---|
| 201 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ | 
|---|
| 202 | -o $(obj)\ | 
|---|
| 203 | $(abspath $(source)) | 
|---|
| 204 | endef | 
|---|
| 205 |  | 
|---|
| 206 |  | 
|---|
| 207 | ## Link library | 
|---|
| 208 | # @param    $(target)   Normalized main target name. | 
|---|
| 209 | # @param    $(out)              Library name. | 
|---|
| 210 | # @param    $(objs)     Object files to put in the library. | 
|---|
| 211 | # @param    $(flags)    Flags. | 
|---|
| 212 | # @param    $(dirdep)   Directory creation dependency. | 
|---|
| 213 | # @param    $(deps)             Other dependencies. | 
|---|
| 214 | # @param    $(othersrc) Unhandled sources. | 
|---|
| 215 | # @param    $(outbase)  Output basename (full). Use this for list files and such. | 
|---|
| 216 | TOOL_GXX64_LINK_LIBRARY_OUTPUT = $(out).ar-script | 
|---|
| 217 | TOOL_GXX64_LINK_LIBRARY_DEPEND = $(othersrc) | 
|---|
| 218 | TOOL_GXX64_LINK_LIBRARY_DEPORD = | 
|---|
| 219 | define TOOL_GXX64_LINK_LIBRARY_CMDS | 
|---|
| 220 | $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)' | 
|---|
| 221 | $(QUIET)$(APPEND) -n $(out).ar-script \ | 
|---|
| 222 | $(foreach o,$(objs), 'ADDMOD $(o)') \ | 
|---|
| 223 | $(foreach o,$(othersrc), 'ADDLIB $(o)') | 
|---|
| 224 | $(QUIET)$(APPEND) $(out).ar-script 'SAVE' | 
|---|
| 225 | $(QUIET)$(APPEND) $(out).ar-script 'END' | 
|---|
| 226 | $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX64_AR) -M | 
|---|
| 227 | endef | 
|---|
| 228 |  | 
|---|
| 229 |  | 
|---|
| 230 | ## Link program | 
|---|
| 231 | # @param    $(target)   Normalized main target name. | 
|---|
| 232 | # @param    $(out)              Program name. | 
|---|
| 233 | # @param    $(objs)     Object files to link together. | 
|---|
| 234 | # @param    $(libs)     Libraries to search. | 
|---|
| 235 | # @param    $(libpath)  Library search paths. | 
|---|
| 236 | # @param    $(flags)    Flags. | 
|---|
| 237 | # @param    $(dirdep)   Directory creation dependency. | 
|---|
| 238 | # @param    $(deps)             Other dependencies. | 
|---|
| 239 | # @param    $(othersrc) Unhandled sources. | 
|---|
| 240 | # @param    $(custom_pre)   Custom step invoked before linking. | 
|---|
| 241 | # @param    $(custom_post)  Custom step invoked after linking. | 
|---|
| 242 | # @param    $(outbase)  Output basename (full). Use this for list files and such. | 
|---|
| 243 | TOOL_GXX64_LINK_PROGRAM_OUTPUT = | 
|---|
| 244 | TOOL_GXX64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map | 
|---|
| 245 | TOOL_GXX64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) | 
|---|
| 246 | TOOL_GXX64_LINK_PROGRAM_DEPORD = | 
|---|
| 247 | define TOOL_GXX64_LINK_PROGRAM_CMDS | 
|---|
| 248 | $(QUIET)$(TOOL_GXX64_LD) $(flags) -o $(out) $(objs)\ | 
|---|
| 249 | $(foreach p,$(libpath), -L$(p))\ | 
|---|
| 250 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ | 
|---|
| 251 | $(call TOOL_GXX64_LD_MAP,$(outbase).map) | 
|---|
| 252 | endef | 
|---|
| 253 |  | 
|---|
| 254 |  | 
|---|
| 255 | ## Link DLL | 
|---|
| 256 | # @param    $(target)   Normalized main target name. | 
|---|
| 257 | # @param    $(out)              Program name. | 
|---|
| 258 | # @param    $(objs)     Object files to link together. | 
|---|
| 259 | # @param    $(libs)     Libraries to search. | 
|---|
| 260 | # @param    $(libpath)  Library search paths. | 
|---|
| 261 | # @param    $(flags)    Flags. | 
|---|
| 262 | # @param    $(dirdep)   Directory creation dependency. | 
|---|
| 263 | # @param    $(deps)             Other dependencies. | 
|---|
| 264 | # @param    $(othersrc) Unhandled sources. | 
|---|
| 265 | # @param    $(custom_pre)   Custom step invoked before linking. | 
|---|
| 266 | # @param    $(custom_post)  Custom step invoked after linking. | 
|---|
| 267 | # @param    $(outbase)  Output basename (full). Use this for list files and such. | 
|---|
| 268 | TOOL_GXX64_LINK_DLL_OUTPUT = | 
|---|
| 269 | TOOL_GXX64_LINK_DLL_OUTPUT_MAYBE = $(outbase).map | 
|---|
| 270 | TOOL_GXX64_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) | 
|---|
| 271 | TOOL_GXX64_LINK_DLL_DEPORD = | 
|---|
| 272 | define TOOL_GXX64_LINK_DLL_CMDS | 
|---|
| 273 | $(QUIET)$(TOOL_GXX64_LD) $(TOOL_GXX64_LDFLAGS.dll) $(flags) -o $(out)\ | 
|---|
| 274 | $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX64_LD_SONAME,$(target),$(out)))\ | 
|---|
| 275 | $(objs)\ | 
|---|
| 276 | $(foreach p,$(libpath), -L$(p))\ | 
|---|
| 277 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ | 
|---|
| 278 | $(call TOOL_GXX64_LD_MAP,$(outbase).map) | 
|---|
| 279 | endef | 
|---|
| 280 |  | 
|---|
| 281 |  | 
|---|
| 282 | ## Link system module (windows aka driver, linux aka kernel module) | 
|---|
| 283 | # @param    $(target)   Normalized main target name. | 
|---|
| 284 | # @param    $(out)              System module name. | 
|---|
| 285 | # @param    $(objs)     Object files to link together. | 
|---|
| 286 | # @param    $(libs)     Libraries to search. | 
|---|
| 287 | # @param    $(libpath)  Library search paths. | 
|---|
| 288 | # @param    $(flags)    Flags. | 
|---|
| 289 | # @param    $(dirdep)   Directory creation dependency. | 
|---|
| 290 | # @param    $(deps)             Other dependencies. | 
|---|
| 291 | # @param    $(othersrc) Unhandled sources. | 
|---|
| 292 | # @param    $(custom_pre)   Custom step invoked before linking. | 
|---|
| 293 | # @param    $(custom_post)  Custom step invoked after linking. | 
|---|
| 294 | # @param    $(outbase)  Output basename (full). Use this for list files and such. | 
|---|
| 295 | TOOL_GXX64_LINK_SYSMOD_OUTPUT = | 
|---|
| 296 | TOOL_GXX64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map | 
|---|
| 297 | TOOL_GXX64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) | 
|---|
| 298 | TOOL_GXX64_LINK_SYSMOD_DEPORD = | 
|---|
| 299 | define TOOL_GXX64_LINK_SYSMOD_CMDS | 
|---|
| 300 | $(QUIET)$(TOOL_GXX64_LD_SYSMOD) $(TOOL_GXX64_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\ | 
|---|
| 301 | $(foreach p,$(libpath), -L$(p))\ | 
|---|
| 302 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\ | 
|---|
| 303 | $(call TOOL_GXX64_LD_SYSMOD_MAP,$(outbase).map) | 
|---|
| 304 | endef | 
|---|
| 305 |  | 
|---|