| 1 | # $Id: GCC3.kmk 474 2006-07-16 03:43:04Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild Tool Config - Generic GCC.
|
|---|
| 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_GCC3 := Generic GCC v3
|
|---|
| 28 |
|
|---|
| 29 | TOOL_GCC3_CC := gcc$(HOSTSUFF_EXE)
|
|---|
| 30 | TOOL_GCC3_COBJSUFF := .o
|
|---|
| 31 | TOOL_GCC3_CFLAGS := -g
|
|---|
| 32 | TOOL_GCC3_CFLAGS.debug := -O0
|
|---|
| 33 | TOOL_GCC3_CFLAGS.release := -O2
|
|---|
| 34 | TOOL_GCC3_CFLAGS.profile := -O2 #-pg
|
|---|
| 35 | TOOL_GCC3_CINCS :=
|
|---|
| 36 | TOOL_GCC3_CDEFS :=
|
|---|
| 37 |
|
|---|
| 38 | TOOL_GCC3_CXX := g++$(HOSTSUFF_EXE)
|
|---|
| 39 | TOOL_GCC3_CXXOBJSUFF := .o
|
|---|
| 40 | TOOL_GCC3_CXXOBJSUFF := .o
|
|---|
| 41 | TOOL_GCC3_CXXFLAGS := -g
|
|---|
| 42 | TOOL_GCC3_CXXFLAGS.debug := -O0
|
|---|
| 43 | TOOL_GCC3_CXXFLAGS.release := -O2
|
|---|
| 44 | TOOL_GCC3_CXXFLAGS.profile := -O2 #-pg
|
|---|
| 45 | TOOL_GCC3_CXXINCS :=
|
|---|
| 46 | TOOL_GCC3_CXXDEFS :=
|
|---|
| 47 |
|
|---|
| 48 | TOOL_GCC3_AS := gcc$(HOSTSUFF_EXE)
|
|---|
| 49 | TOOL_GCC3_ASFLAGS := -g -x assembler-with-cpp
|
|---|
| 50 | TOOL_GCC3_ASOBJSUFF := .o
|
|---|
| 51 |
|
|---|
| 52 | TOOL_GCC3_AR := ar$(HOSTSUFF_EXE)
|
|---|
| 53 | TOOL_GCC3_ARFLAGS := cr
|
|---|
| 54 | TOOL_GCC3_ARLIBSUFF := .a
|
|---|
| 55 |
|
|---|
| 56 | ifeq ($(BUILD_TARGET),os2)
|
|---|
| 57 | TOOL_GCC3_AR_IMP := emximp$(HOSTSTUFF_EXE)
|
|---|
| 58 | else
|
|---|
| 59 | TOOL_GCC3_AR_IMP := $(ECHO) not supported!
|
|---|
| 60 | endif
|
|---|
| 61 |
|
|---|
| 62 | TOOL_GCC3_LD := g++$(HOSTSUFF_EXE)
|
|---|
| 63 | TOOL_GCC3_LD_SYSMOD := ld$(HOSTSUFF_EXE)
|
|---|
| 64 | TOOL_GCC3_LDFLAGS :=
|
|---|
| 65 | TOOL_GCC3_LDFLAGS.debug := -g
|
|---|
| 66 | TOOL_GCC3_LDFLAGS.release := -s
|
|---|
| 67 | ifndef TOOL_GCC3_LDFLAGS.$(BUILD_TARGET)
|
|---|
| 68 | TOOL_GCC3_LDFLAGS.dll := -shared
|
|---|
| 69 | else
|
|---|
| 70 | TOOL_GCC3_LDFLAGS.dll := $(TOOL_GCC3_LDFLAGS.$(BUILD_TARGET))
|
|---|
| 71 | endif
|
|---|
| 72 | TOOL_GCC3_LDFLAGS.sysmod := -r
|
|---|
| 73 | TOOL_GCC3_LD_SONAME = -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
|---|
| 74 | ifeq ($(BUILD_TARGET),os2)
|
|---|
| 75 | TOOL_GCC3_LD_MAP = -Zmap=$(1)
|
|---|
| 76 | else
|
|---|
| 77 | TOOL_GCC3_LD_MAP = -Wl,-Map -Wl,$(1) -Wl,--cref
|
|---|
| 78 | endif
|
|---|
| 79 | ifeq ($(BUILD_TARGET),os2)
|
|---|
| 80 | TOOL_GCC3_LD_SYSMOD_MAP = -Zmap=$(1)
|
|---|
| 81 | else
|
|---|
| 82 | TOOL_GCC3_LD_SYSMOD_MAP = -Map $(1) --cref
|
|---|
| 83 | endif
|
|---|
| 84 | ifdef SLKRUNS
|
|---|
| 85 | TOOL_GCC3_CC += -fmessage-length=0
|
|---|
| 86 | TOOL_GCC3_CXX += -fmessage-length=0
|
|---|
| 87 | endif
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | ## Compile C source.
|
|---|
| 91 | # @param $(target) Normalized main target name.
|
|---|
| 92 | # @param $(source) Source filename (relative).
|
|---|
| 93 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 94 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 95 | # @param $(flags) Flags.
|
|---|
| 96 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 97 | # @param $(incs) Includes. No -I or something.
|
|---|
| 98 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 99 | # @param $(deps) Other dependencies.
|
|---|
| 100 | #
|
|---|
| 101 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 102 | # @param $(objsuff) Object suffix.
|
|---|
| 103 | TOOL_GCC3_COMPILE_C_OUTPUT =
|
|---|
| 104 | TOOL_GCC3_COMPILE_C_DEPEND =
|
|---|
| 105 | TOOL_GCC3_COMPILE_C_DEPORD =
|
|---|
| 106 | define TOOL_GCC3_COMPILE_C_CMDS
|
|---|
| 107 | $(TOOL_GCC3_CC) -c\
|
|---|
| 108 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 109 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 110 | -o $(obj)\
|
|---|
| 111 | $(call ABSPATH,$(source))
|
|---|
| 112 | endef
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 | ## Compile C++ source.
|
|---|
| 116 | # @param $(target) Normalized main target name.
|
|---|
| 117 | # @param $(source) Source filename (relative).
|
|---|
| 118 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 119 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 120 | # @param $(flags) Flags.
|
|---|
| 121 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 122 | # @param $(incs) Includes. No -I or something.
|
|---|
| 123 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 124 | # @param $(deps) Other dependencies.
|
|---|
| 125 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 126 | # @param $(objsuff) Object suffix.
|
|---|
| 127 | TOOL_GCC3_COMPILE_CXX_OUTPUT =
|
|---|
| 128 | TOOL_GCC3_COMPILE_CXX_DEPEND =
|
|---|
| 129 | TOOL_GCC3_COMPILE_CXX_DEPORD =
|
|---|
| 130 | define TOOL_GCC3_COMPILE_CXX_CMDS
|
|---|
| 131 | $(TOOL_GCC3_CXX) -c\
|
|---|
| 132 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 133 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 134 | -o $(obj)\
|
|---|
| 135 | $(call ABSPATH,$(source))
|
|---|
| 136 | endef
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 | ## Compile Assembly source.
|
|---|
| 140 | # @param $(target) Normalized main target name.
|
|---|
| 141 | # @param $(source) Source filename (relative).
|
|---|
| 142 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 143 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 144 | # @param $(flags) Flags.
|
|---|
| 145 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 146 | # @param $(incs) Includes. No -I or something.
|
|---|
| 147 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 148 | # @param $(deps) Other dependencies.
|
|---|
| 149 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 150 | # @param $(objsuff) Object suffix.
|
|---|
| 151 | #
|
|---|
| 152 | TOOL_GCC3_COMPILE_AS_OUTPUT =
|
|---|
| 153 | TOOL_GCC3_COMPILE_AS_DEPEND =
|
|---|
| 154 | TOOL_GCC3_COMPILE_AS_DEPORD =
|
|---|
| 155 | define TOOL_GCC3_COMPILE_AS_CMDS
|
|---|
| 156 | $(TOOL_GCC3_AS) -c\
|
|---|
| 157 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 158 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 159 | -o $(obj)\
|
|---|
| 160 | $(call ABSPATH,$(source))
|
|---|
| 161 | endef
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 | ## Link library
|
|---|
| 165 | # @param $(target) Normalized main target name.
|
|---|
| 166 | # @param $(out) Library name.
|
|---|
| 167 | # @param $(objs) Object files to put in the library.
|
|---|
| 168 | # @param $(flags) Flags.
|
|---|
| 169 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 170 | # @param $(deps) Other dependencies.
|
|---|
| 171 | # @param $(othersrc) Unhandled sources.
|
|---|
| 172 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 173 | TOOL_GCC3_LINK_LIBRARY_OUTPUT = $(out).ar-script
|
|---|
| 174 | TOOL_GCC3_LINK_LIBRARY_DEPEND = $(filter %.a %.lib %.def %.imp,$(othersrc))
|
|---|
| 175 | TOOL_GCC3_LINK_LIBRARY_DEPORD =
|
|---|
| 176 | define TOOL_GCC3_LINK_LIBRARY_CMDS
|
|---|
| 177 | $(APPEND) $(out).ar-script "CREATE $(out)"
|
|---|
| 178 | $(foreach o, $(objs)\
|
|---|
| 179 | ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDMOD $(o)")
|
|---|
| 180 | $(foreach srclib, $(filter %.a %.lib,$(othersrc))\
|
|---|
| 181 | ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
|
|---|
| 182 | $(if $(filter %.def %.imp,$(othersrc))\
|
|---|
| 183 | ,$(TOOL_GCC3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
|
|---|
| 184 | $(NL)$(TAB)$(APPEND) $(out).ar-script "ADDLIB $(outbase).imp.a")
|
|---|
| 185 | $(APPEND) $(out).ar-script "SAVE"
|
|---|
| 186 | $(APPEND) $(out).ar-script "END"
|
|---|
| 187 | $(TOOL_GCC3_AR) -M < $(out).ar-script
|
|---|
| 188 | endef
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 | ## Link program
|
|---|
| 192 | # @param $(target) Normalized main target name.
|
|---|
| 193 | # @param $(out) Program name.
|
|---|
| 194 | # @param $(objs) Object files to link together.
|
|---|
| 195 | # @param $(libs) Libraries to search.
|
|---|
| 196 | # @param $(libpath) Library search paths.
|
|---|
| 197 | # @param $(flags) Flags.
|
|---|
| 198 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 199 | # @param $(deps) Other dependencies.
|
|---|
| 200 | # @param $(othersrc) Unhandled sources.
|
|---|
| 201 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 202 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 203 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 204 | TOOL_GCC3_LINK_PROGRAM_OUTPUT = $(outbase).map
|
|---|
| 205 | TOOL_GCC3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 206 | TOOL_GCC3_LINK_PROGRAM_DEPORD =
|
|---|
| 207 | define TOOL_GCC3_LINK_PROGRAM_CMDS
|
|---|
| 208 | $(TOOL_GCC3_LD) $(flags) -o $(out) $(objs)\
|
|---|
| 209 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 210 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 211 | $(call TOOL_GCC3_LD_MAP,$(outbase).map)
|
|---|
| 212 | endef
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 | ## Link DLL
|
|---|
| 216 | # @param $(target) Normalized main target name.
|
|---|
| 217 | # @param $(out) Program name.
|
|---|
| 218 | # @param $(objs) Object files to link together.
|
|---|
| 219 | # @param $(libs) Libraries to search.
|
|---|
| 220 | # @param $(libpath) Library search paths.
|
|---|
| 221 | # @param $(flags) Flags.
|
|---|
| 222 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 223 | # @param $(deps) Other dependencies.
|
|---|
| 224 | # @param $(othersrc) Unhandled sources.
|
|---|
| 225 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 226 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 227 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 228 | TOOL_GCC3_LINK_DLL_OUTPUT = $(outbase).map
|
|---|
| 229 | TOOL_GCC3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 230 | TOOL_GCC3_LINK_DLL_DEPORD =
|
|---|
| 231 | define TOOL_GCC3_LINK_DLL_CMDS
|
|---|
| 232 | $(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $(out)\
|
|---|
| 233 | $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(out)))\
|
|---|
| 234 | $(objs)\
|
|---|
| 235 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 236 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 237 | $(call TOOL_GCC3_LD_MAP,$(outbase).map)
|
|---|
| 238 | endef
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 | ## Link system module (windows aka driver, linux aka kernel module)
|
|---|
| 242 | # @param $(target) Normalized main target name.
|
|---|
| 243 | # @param $(out) System module name.
|
|---|
| 244 | # @param $(objs) Object files to link together.
|
|---|
| 245 | # @param $(libs) Libraries to search.
|
|---|
| 246 | # @param $(libpath) Library search paths.
|
|---|
| 247 | # @param $(flags) Flags.
|
|---|
| 248 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 249 | # @param $(deps) Other dependencies.
|
|---|
| 250 | # @param $(othersrc) Unhandled sources.
|
|---|
| 251 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 252 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 253 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 254 | TOOL_GCC3_LINK_SYSMOD_OUTPUT = $(outbase).map
|
|---|
| 255 | TOOL_GCC3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 256 | TOOL_GCC3_LINK_SYSMOD_DEPORD =
|
|---|
| 257 | define TOOL_GCC3_LINK_SYSMOD_CMDS
|
|---|
| 258 | $(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
|
|---|
| 259 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 260 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 261 | $(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map)
|
|---|
| 262 | endef
|
|---|
| 263 |
|
|---|