| 1 | # $Id: GCC3.kmk 380 2005-12-18 13:52:47Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild Tool Config - GCC Cross compiler for AMD64 (aka x86_64).
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
|
|---|
| 7 | #
|
|---|
| 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 |
|
|---|
| 27 | TOOL_XGCCAMD64LINUX := GCC Cross Compiler for AMD64
|
|---|
| 28 |
|
|---|
| 29 | #
|
|---|
| 30 | # Determin some stuff dynamically.
|
|---|
| 31 | #
|
|---|
| 32 | _TOOL_XGCCAMD64LINUX_PREFIX :=
|
|---|
| 33 | _TOOL_XGCCAMD64LINUX_EXEC_PREFIX :=
|
|---|
| 34 | _TOOL_XGCCAMD64LINUX_SUFF_EXE :=
|
|---|
| 35 | ifeq ($(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH),linux.amd64)
|
|---|
| 36 | # not x-compile.
|
|---|
| 37 | PATH_TOOL_XGCCAMD64LINUX :=
|
|---|
| 38 | else # x-compile:
|
|---|
| 39 | # find the latest xgcc build.
|
|---|
| 40 | _TOOL_XGCCAMD64LINUX_PREFIX := x86_64-unknown-linux-gnu-
|
|---|
| 41 | ifndef PATH_TOOL_XGCCAMD64LINUX
|
|---|
| 42 | PATH_TOOL_XGCCAMD64LINUX := $(sort $(wildcard $(PATH_DEV)/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)/x86_64-unknown-linux-gnu/*))
|
|---|
| 43 | ifeq ($(filter-out win64,$(BUILD_PLATFORM)),) # these can use the windows build.
|
|---|
| 44 | _TOOL_XGCCAMD64LINUX_EXEC_PREFIX := $(EXEC_X86_WIN32)
|
|---|
| 45 | PATH_TOOL_XGCCAMD64LINUX := $(sort $(wildcard $(PATH_DEV)/x86.win32/x86_64-unknown-linux-gnu/*))
|
|---|
| 46 | endif
|
|---|
| 47 | ifneq ($(PATH_TOOL_XGCCAMD64LINUX),)
|
|---|
| 48 | PATH_TOOL_XGCCAMD64LINUX := $(call lastword,$(PATH_TOOL_XGCCAMD64LINUX))
|
|---|
| 49 | endif
|
|---|
| 50 | endif # !PATH_TOOL_XGCCAMD64LINUX
|
|---|
| 51 | endif
|
|---|
| 52 | ifneq ($(PATH_TOOL_XGCCAMD64LINUX),)
|
|---|
| 53 | _TOOL_XGCCAMD64LINUX_PREFIX := $(_TOOL_XGCCAMD64LINUX_EXEC_PREFIX) $(PATH_TOOL_XGCCAMD64LINUX)/bin/$(_TOOL_XGCCAMD64LINUX_PREFIX)
|
|---|
| 54 | endif
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | TOOL_XGCCAMD64LINUX_CC := $(_TOOL_XGCCAMD64LINUX_PREFIX)gcc$(HOSTSUFF_EXE)
|
|---|
| 58 | TOOL_XGCCAMD64LINUX_COBJSUFF := .o
|
|---|
| 59 | TOOL_XGCCAMD64LINUX_CFLAGS := -g
|
|---|
| 60 | TOOL_XGCCAMD64LINUX_CFLAGS.debug := -O0
|
|---|
| 61 | TOOL_XGCCAMD64LINUX_CFLAGS.release := -O2
|
|---|
| 62 | TOOL_XGCCAMD64LINUX_CFLAGS.profile := -O2 #-pg
|
|---|
| 63 | TOOL_XGCCAMD64LINUX_CINCS :=
|
|---|
| 64 | TOOL_XGCCAMD64LINUX_CDEFS :=
|
|---|
| 65 |
|
|---|
| 66 | TOOL_XGCCAMD64LINUX_CXX := $(_TOOL_XGCCAMD64LINUX_PREFIX)g++$(HOSTSUFF_EXE)
|
|---|
| 67 | TOOL_XGCCAMD64LINUX_CXXOBJSUFF := .o
|
|---|
| 68 | TOOL_XGCCAMD64LINUX_CXXOBJSUFF := .o
|
|---|
| 69 | TOOL_XGCCAMD64LINUX_CXXFLAGS := -g
|
|---|
| 70 | TOOL_XGCCAMD64LINUX_CXXFLAGS.debug := -O0
|
|---|
| 71 | TOOL_XGCCAMD64LINUX_CXXFLAGS.release := -O2
|
|---|
| 72 | TOOL_XGCCAMD64LINUX_CXXFLAGS.profile := -O2 #-pg
|
|---|
| 73 | TOOL_XGCCAMD64LINUX_CXXINCS :=
|
|---|
| 74 | TOOL_XGCCAMD64LINUX_CXXDEFS :=
|
|---|
| 75 |
|
|---|
| 76 | TOOL_XGCCAMD64LINUX_AS := $(_TOOL_XGCCAMD64LINUX_PREFIX)gcc$(HOSTSUFF_EXE)
|
|---|
| 77 | TOOL_XGCCAMD64LINUX_ASFLAGS := -g -x assembler-with-cpp
|
|---|
| 78 | TOOL_XGCCAMD64LINUX_ASOBJSUFF := .o
|
|---|
| 79 |
|
|---|
| 80 | TOOL_XGCCAMD64LINUX_AR := $(_TOOL_XGCCAMD64LINUX_PREFIX)ar$(HOSTSUFF_EXE)
|
|---|
| 81 | TOOL_XGCCAMD64LINUX_ARFLAGS := cr
|
|---|
| 82 | TOOL_XGCCAMD64LINUX_ARLIBSUFF := .a
|
|---|
| 83 |
|
|---|
| 84 | TOOL_XGCCAMD64LINUX_LD := $(_TOOL_XGCCAMD64LINUX_PREFIX)g++$(HOSTSUFF_EXE)
|
|---|
| 85 | TOOL_XGCCAMD64LINUX_LD_SYSMOD := $(_TOOL_XGCCAMD64LINUX_PREFIX)ld$(HOSTSUFF_EXE)
|
|---|
| 86 | TOOL_XGCCAMD64LINUX_LDFLAGS :=
|
|---|
| 87 | TOOL_XGCCAMD64LINUX_LDFLAGS.debug := -g
|
|---|
| 88 | TOOL_XGCCAMD64LINUX_LDFLAGS.release := -s
|
|---|
| 89 | ifndef TOOL_XGCCAMD64LINUX_LDFLAGS.$(BUILD_TARGET)
|
|---|
| 90 | TOOL_XGCCAMD64LINUX_LDFLAGS.dll := -shared
|
|---|
| 91 | else
|
|---|
| 92 | TOOL_XGCCAMD64LINUX_LDFLAGS.dll := $(TOOL_XGCCAMD64LINUX_LDFLAGS.$(BUILD_TARGET))
|
|---|
| 93 | endif
|
|---|
| 94 | TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod := -r
|
|---|
| 95 | TOOL_XGCCAMD64LINUX_LD_SONAME = -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
|---|
| 96 | ifeq ($(BUILD_TARGET),os2)
|
|---|
| 97 | TOOL_XGCCAMD64LINUX_LD_MAP = -Zmap=$(1)
|
|---|
| 98 | else
|
|---|
| 99 | TOOL_XGCCAMD64LINUX_LD_MAP = -Wl,-Map -Wl,$(1) -Wl,--cref
|
|---|
| 100 | endif
|
|---|
| 101 | ifeq ($(BUILD_TARGET),os2)
|
|---|
| 102 | TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP = -Zmap=$(1)
|
|---|
| 103 | else
|
|---|
| 104 | TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP = -Map $(1) --cref
|
|---|
| 105 | endif
|
|---|
| 106 | ifdef SLKRUNS
|
|---|
| 107 | TOOL_XGCCAMD64LINUX_CC += -fmessage-length=0
|
|---|
| 108 | TOOL_XGCCAMD64LINUX_CXX += -fmessage-length=0
|
|---|
| 109 | endif
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | ## Compile C source.
|
|---|
| 113 | # @param $(target) Normalized main target name.
|
|---|
| 114 | # @param $(source) Source filename (relative).
|
|---|
| 115 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 116 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 117 | # @param $(flags) Flags.
|
|---|
| 118 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 119 | # @param $(incs) Includes. No -I or something.
|
|---|
| 120 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 121 | # @param $(deps) Other dependencies.
|
|---|
| 122 | #
|
|---|
| 123 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 124 | # @param $(objsuff) Object suffix.
|
|---|
| 125 | TOOL_XGCCAMD64LINUX_COMPILE_C_OUTPUT =
|
|---|
| 126 | TOOL_XGCCAMD64LINUX_COMPILE_C_DEPEND =
|
|---|
| 127 | TOOL_XGCCAMD64LINUX_COMPILE_C_DEPORD =
|
|---|
| 128 | define TOOL_XGCCAMD64LINUX_COMPILE_C_CMDS
|
|---|
| 129 | $(TOOL_XGCCAMD64LINUX_CC) -c\
|
|---|
| 130 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 131 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 132 | -o $(obj)\
|
|---|
| 133 | $(call ABSPATH,$(source))
|
|---|
| 134 | endef
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | ## Compile C++ source.
|
|---|
| 138 | # @param $(target) Normalized main target name.
|
|---|
| 139 | # @param $(source) Source filename (relative).
|
|---|
| 140 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 141 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 142 | # @param $(flags) Flags.
|
|---|
| 143 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 144 | # @param $(incs) Includes. No -I or something.
|
|---|
| 145 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 146 | # @param $(deps) Other dependencies.
|
|---|
| 147 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 148 | # @param $(objsuff) Object suffix.
|
|---|
| 149 | TOOL_XGCCAMD64LINUX_COMPILE_CXX_OUTPUT =
|
|---|
| 150 | TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPEND =
|
|---|
| 151 | TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPORD =
|
|---|
| 152 | define TOOL_XGCCAMD64LINUX_COMPILE_CXX_CMDS
|
|---|
| 153 | $(TOOL_XGCCAMD64LINUX_CXX) -c\
|
|---|
| 154 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 155 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 156 | -o $(obj)\
|
|---|
| 157 | $(call ABSPATH,$(source))
|
|---|
| 158 | endef
|
|---|
| 159 |
|
|---|
| 160 | ## Compile Assembly source.
|
|---|
| 161 | # @param $(target) Normalized main target name.
|
|---|
| 162 | # @param $(source) Source filename (relative).
|
|---|
| 163 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 164 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 165 | # @param $(flags) Flags.
|
|---|
| 166 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 167 | # @param $(incs) Includes. No -I or something.
|
|---|
| 168 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 169 | # @param $(deps) Other dependencies.
|
|---|
| 170 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 171 | # @param $(objsuff) Object suffix.
|
|---|
| 172 | #
|
|---|
| 173 | TOOL_XGCCAMD64LINUX_COMPILE_AS_OUTPUT =
|
|---|
| 174 | TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPEND =
|
|---|
| 175 | TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPORD =
|
|---|
| 176 | define TOOL_XGCCAMD64LINUX_COMPILE_AS_CMDS
|
|---|
| 177 | $(TOOL_XGCCAMD64LINUX_AS) -c\
|
|---|
| 178 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 179 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 180 | -o $(obj)\
|
|---|
| 181 | $(call ABSPATH,$(source))
|
|---|
| 182 | endef
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 | ## Link library
|
|---|
| 186 | # @param $(target) Normalized main target name.
|
|---|
| 187 | # @param $(out) Library name.
|
|---|
| 188 | # @param $(objs) Object files to put in the library.
|
|---|
| 189 | # @param $(flags) Flags.
|
|---|
| 190 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 191 | # @param $(deps) Other dependencies.
|
|---|
| 192 | # @param $(othersrc) Unhandled sources.
|
|---|
| 193 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 194 | TOOL_XGCCAMD64LINUX_LINK_LIBRARY_OUTPUT = $(out).ar-script
|
|---|
| 195 | TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPEND = $(filter %.a %.lib,$(othersrc))
|
|---|
| 196 | TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD =
|
|---|
| 197 | define TOOL_XGCCAMD64LINUX_LINK_LIBRARY_CMDS
|
|---|
| 198 | $(APPEND) $(out).ar-script "CREATE $(out)"
|
|---|
| 199 | $(foreach o, $(objs)\
|
|---|
| 200 | ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDMOD $(o)")
|
|---|
| 201 | $(foreach srclib, $(filter %.a %.lib,$(othersrc))\
|
|---|
| 202 | ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
|
|---|
| 203 | $(APPEND) $(out).ar-script "SAVE"
|
|---|
| 204 | $(APPEND) $(out).ar-script "END"
|
|---|
| 205 | $(TOOL_XGCCAMD64LINUX_AR) -M < $(out).ar-script
|
|---|
| 206 | endef
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 | ## Link program
|
|---|
| 210 | # @param $(target) Normalized main target name.
|
|---|
| 211 | # @param $(out) Program name.
|
|---|
| 212 | # @param $(objs) Object files to link together.
|
|---|
| 213 | # @param $(libs) Libraries to search.
|
|---|
| 214 | # @param $(libpath) Library search paths.
|
|---|
| 215 | # @param $(flags) Flags.
|
|---|
| 216 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 217 | # @param $(deps) Other dependencies.
|
|---|
| 218 | # @param $(othersrc) Unhandled sources.
|
|---|
| 219 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 220 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 221 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 222 | TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT = $(outbase).map
|
|---|
| 223 | TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 224 | TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD =
|
|---|
| 225 | define TOOL_XGCCAMD64LINUX_LINK_PROGRAM_CMDS
|
|---|
| 226 | $(TOOL_XGCCAMD64LINUX_LD) $(flags) -o $(out) $(objs)\
|
|---|
| 227 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 228 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 229 | $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
|
|---|
| 230 | endef
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 | ## Link DLL
|
|---|
| 234 | # @param $(target) Normalized main target name.
|
|---|
| 235 | # @param $(out) Program name.
|
|---|
| 236 | # @param $(objs) Object files to link together.
|
|---|
| 237 | # @param $(libs) Libraries to search.
|
|---|
| 238 | # @param $(libpath) Library search paths.
|
|---|
| 239 | # @param $(flags) Flags.
|
|---|
| 240 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 241 | # @param $(deps) Other dependencies.
|
|---|
| 242 | # @param $(othersrc) Unhandled sources.
|
|---|
| 243 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 244 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 245 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 246 | TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT = $(outbase).map
|
|---|
| 247 | TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 248 | TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD =
|
|---|
| 249 | define TOOL_XGCCAMD64LINUX_LINK_DLL_CMDS
|
|---|
| 250 | $(TOOL_XGCCAMD64LINUX_LD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.dll) $(flags) -o $(out)\
|
|---|
| 251 | $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_XGCCAMD64LINUX_LD_SONAME,$(target),$(out)))\
|
|---|
| 252 | $(objs)\
|
|---|
| 253 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 254 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 255 | $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
|
|---|
| 256 | endef
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 | ## Link system module (windows aka driver, linux aka kernel module)
|
|---|
| 260 | # @param $(target) Normalized main target name.
|
|---|
| 261 | # @param $(out) System module name.
|
|---|
| 262 | # @param $(objs) Object files to link together.
|
|---|
| 263 | # @param $(libs) Libraries to search.
|
|---|
| 264 | # @param $(libpath) Library search paths.
|
|---|
| 265 | # @param $(flags) Flags.
|
|---|
| 266 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 267 | # @param $(deps) Other dependencies.
|
|---|
| 268 | # @param $(othersrc) Unhandled sources.
|
|---|
| 269 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 270 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 271 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 272 | TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT = $(outbase).map
|
|---|
| 273 | TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 274 | TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD =
|
|---|
| 275 | define TOOL_XGCCAMD64LINUX_LINK_SYSMOD_CMDS
|
|---|
| 276 | $(TOOL_XGCCAMD64LINUX_LD_SYSMOD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
|
|---|
| 277 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 278 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 279 | $(call TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP,$(outbase).map)
|
|---|
| 280 | endef
|
|---|
| 281 |
|
|---|