| 1 | # $Id: GCC3PLAIN.kmk 1033 2007-06-04 02:00:11Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@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_GCC3PLAIN := Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
|
|---|
| 28 |
|
|---|
| 29 | # Tool Specific Properties
|
|---|
| 30 | TOOL_GCC3PLAIN_CC ?= gcc$(HOSTSUFF_EXE)
|
|---|
| 31 | TOOL_GCC3PLAIN_CXX ?= g++$(HOSTSUFF_EXE)
|
|---|
| 32 | TOOL_GCC3PLAIN_AS ?= gcc$(HOSTSUFF_EXE)
|
|---|
| 33 | TOOL_GCC3PLAIN_AR ?= ar$(HOSTSUFF_EXE)
|
|---|
| 34 | TOOL_GCC3PLAIN_RANLIB ?= ranlib$(HOSTSUFF_EXE)
|
|---|
| 35 | TOOL_GCC3PLAIN_LD ?= gcc$(HOSTSUFF_EXE)
|
|---|
| 36 | TOOL_GCC3PLAIN_LDFLAGS.dll.os2 ?= -Zdll
|
|---|
| 37 | TOOL_GCC3PLAIN_LDFLAGS.dll.darwin ?= -dynamiclib
|
|---|
| 38 | ifndef TOOL_GCC3PLAIN_LDFLAGS.$(BUILD_TARGET)
|
|---|
| 39 | TOOL_GCC3PLAIN_LDFLAGS.dll ?= -shared
|
|---|
| 40 | else
|
|---|
| 41 | TOOL_GCC3PLAIN_LDFLAGS.dll ?= $(TOOL_GCC3PLAIN_LDFLAGS.$(BUILD_TARGET))
|
|---|
| 42 | endif
|
|---|
| 43 | TOOL_GCC3PLAIN_LD_SONAME.darwin ?= $(NO_SUCH_VARIABLE)
|
|---|
| 44 | TOOL_GCC3PLAIN_LD_SONAME.os2 ?= $(NO_SUCH_VARIABLE)
|
|---|
| 45 | TOOL_GCC3PLAIN_LD_SONAME.win ?= $(NO_SUCH_VARIABLE)
|
|---|
| 46 | ifndef TOOL_GCC3PLAIN_LD_SONAME.$(BUILD_TARGET)
|
|---|
| 47 | TOOL_GCC3PLAIN_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
|---|
| 48 | else
|
|---|
| 49 | TOOL_GCC3PLAIN_LD_SONAME ?= $(TOOL_GCC3PLAIN_LD_SONAME.$(BUILD_TARGET))
|
|---|
| 50 | endif
|
|---|
| 51 | ifdef SLKRUNS
|
|---|
| 52 | TOOL_GCC3PLAIN_CC += -fmessage-length=0
|
|---|
| 53 | TOOL_GCC3PLAIN_CXX += -fmessage-length=0
|
|---|
| 54 | endif
|
|---|
| 55 |
|
|---|
| 56 | # General Properties used by kBuild
|
|---|
| 57 | TOOL_GCC3PLAIN_COBJSUFF ?= .o
|
|---|
| 58 | TOOL_GCC3PLAIN_CFLAGS ?=
|
|---|
| 59 | TOOL_GCC3PLAIN_CFLAGS.debug ?= -g
|
|---|
| 60 | TOOL_GCC3PLAIN_CFLAGS.profile ?= -g -O2 #-pg
|
|---|
| 61 | TOOL_GCC3PLAIN_CFLAGS.release ?= -O2
|
|---|
| 62 | TOOL_GCC3PLAIN_CINCS ?=
|
|---|
| 63 | TOOL_GCC3PLAIN_CDEFS ?=
|
|---|
| 64 |
|
|---|
| 65 | TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
|
|---|
| 66 | TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
|
|---|
| 67 | TOOL_GCC3PLAIN_CXXFLAGS ?=
|
|---|
| 68 | TOOL_GCC3PLAIN_CXXFLAGS.debug ?= -g
|
|---|
| 69 | TOOL_GCC3PLAIN_CXXFLAGS.profile ?= -g -O2 #-pg
|
|---|
| 70 | TOOL_GCC3PLAIN_CXXFLAGS.release ?= -O2
|
|---|
| 71 | TOOL_GCC3PLAIN_CXXINCS ?=
|
|---|
| 72 | TOOL_GCC3PLAIN_CXXDEFS ?=
|
|---|
| 73 |
|
|---|
| 74 | TOOL_GCC3PLAIN_ASFLAGS ?= -x assembler-with-cpp
|
|---|
| 75 | TOOL_GCC3PLAIN_ASFLAGS.debug ?= -g
|
|---|
| 76 | TOOL_GCC3PLAIN_ASFLAGS.profile ?= -g
|
|---|
| 77 | TOOL_GCC3PLAIN_ASOBJSUFF ?= .o
|
|---|
| 78 |
|
|---|
| 79 | TOOL_GCC3PLAIN_ARFLAGS ?= cr
|
|---|
| 80 | TOOL_GCC3PLAIN_ARLIBSUFF ?= .a
|
|---|
| 81 |
|
|---|
| 82 | TOOL_GCC3PLAIN_LDFLAGS ?=
|
|---|
| 83 | TOOL_GCC3PLAIN_LDFLAGS.debug ?= -g
|
|---|
| 84 | TOOL_GCC3PLAIN_LDFLAGS.profile ?= -g
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | ## Compile C source.
|
|---|
| 88 | # @param $(target) Normalized main target name.
|
|---|
| 89 | # @param $(source) Source filename (relative).
|
|---|
| 90 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 91 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 92 | # @param $(flags) Flags.
|
|---|
| 93 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 94 | # @param $(incs) Includes. No -I or something.
|
|---|
| 95 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 96 | # @param $(deps) Other dependencies.
|
|---|
| 97 | #
|
|---|
| 98 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 99 | # @param $(objsuff) Object suffix.
|
|---|
| 100 | TOOL_GCC3PLAIN_COMPILE_C_DEPEND =
|
|---|
| 101 | TOOL_GCC3PLAIN_COMPILE_C_DEPORD =
|
|---|
| 102 | ifdef USE_KOBJCACHE
|
|---|
| 103 | TOOL_GCC3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
|
|---|
| 104 | TOOL_GCC3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
|
|---|
| 105 | define TOOL_GCC3PLAIN_COMPILE_C_CMDS
|
|---|
| 106 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -r --kObjCache-cpp $(outbase).i \
|
|---|
| 107 | $(TOOL_GCC3PLAIN_CC) -E -o -\
|
|---|
| 108 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 109 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 110 | $(abspath $(source)) \
|
|---|
| 111 | --kObjCache-cc $(obj) \
|
|---|
| 112 | $(TOOL_GCC3PLAIN_CC) -c\
|
|---|
| 113 | $(flags)\
|
|---|
| 114 | -o $(obj)\
|
|---|
| 115 | $(outbase).i
|
|---|
| 116 | endef
|
|---|
| 117 | else # !USE_KOBJCACHE
|
|---|
| 118 | TOOL_GCC3PLAIN_COMPILE_C_OUTPUT =
|
|---|
| 119 | define TOOL_GCC3PLAIN_COMPILE_C_CMDS
|
|---|
| 120 | $(QUIET)$(TOOL_GCC3PLAIN_CC) -c\
|
|---|
| 121 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 122 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 123 | -o $(obj)\
|
|---|
| 124 | $(abspath $(source))
|
|---|
| 125 | endef
|
|---|
| 126 | endif # !USE_KOBJCACHE
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | ## Compile C++ source.
|
|---|
| 130 | # @param $(target) Normalized main target name.
|
|---|
| 131 | # @param $(source) Source filename (relative).
|
|---|
| 132 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 133 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 134 | # @param $(flags) Flags.
|
|---|
| 135 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 136 | # @param $(incs) Includes. No -I or something.
|
|---|
| 137 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 138 | # @param $(deps) Other dependencies.
|
|---|
| 139 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 140 | # @param $(objsuff) Object suffix.
|
|---|
| 141 | TOOL_GCC3PLAIN_COMPILE_CXX_DEPEND =
|
|---|
| 142 | TOOL_GCC3PLAIN_COMPILE_CXX_DEPORD =
|
|---|
| 143 | ifdef USE_KOBJCACHE
|
|---|
| 144 | TOOL_GCC3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
|
|---|
| 145 | TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
|
|---|
| 146 | define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
|
|---|
| 147 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -r --kObjCache-cpp $(outbase).ii \
|
|---|
| 148 | $(TOOL_GCC3PLAIN_CXX) -E -o -\
|
|---|
| 149 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 150 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 151 | $(abspath $(source)) \
|
|---|
| 152 | --kObjCache-cc $(obj) \
|
|---|
| 153 | $(TOOL_GCC3PLAIN_CXX) -c\
|
|---|
| 154 | $(flags)\
|
|---|
| 155 | -o $(obj)\
|
|---|
| 156 | $(outbase).ii
|
|---|
| 157 | endef
|
|---|
| 158 | else # !USE_KOBJCACHE
|
|---|
| 159 | TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT =
|
|---|
| 160 | define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
|
|---|
| 161 | $(QUIET)$(TOOL_GCC3PLAIN_CXX) -c\
|
|---|
| 162 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 163 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 164 | -o $(obj)\
|
|---|
| 165 | $(abspath $(source))
|
|---|
| 166 | endef
|
|---|
| 167 | endif # !USE_KOBJCACHE
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 | ## Compile Assembly source.
|
|---|
| 171 | # @param $(target) Normalized main target name.
|
|---|
| 172 | # @param $(source) Source filename (relative).
|
|---|
| 173 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 174 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 175 | # @param $(flags) Flags.
|
|---|
| 176 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 177 | # @param $(incs) Includes. No -I or something.
|
|---|
| 178 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 179 | # @param $(deps) Other dependencies.
|
|---|
| 180 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 181 | # @param $(objsuff) Object suffix.
|
|---|
| 182 | #
|
|---|
| 183 | TOOL_GCC3PLAIN_COMPILE_AS_OUTPUT =
|
|---|
| 184 | TOOL_GCC3PLAIN_COMPILE_AS_DEPEND =
|
|---|
| 185 | TOOL_GCC3PLAIN_COMPILE_AS_DEPORD =
|
|---|
| 186 | define TOOL_GCC3PLAIN_COMPILE_AS_CMDS
|
|---|
| 187 | $(QUIET)$(TOOL_GCC3PLAIN_AS) -c\
|
|---|
| 188 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 189 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 190 | -o $(obj)\
|
|---|
| 191 | $(abspath $(source))
|
|---|
| 192 | endef
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | ## Link library
|
|---|
| 196 | # @param $(target) Normalized main target name.
|
|---|
| 197 | # @param $(out) Library name.
|
|---|
| 198 | # @param $(objs) Object files to put in the library.
|
|---|
| 199 | # @param $(flags) Flags.
|
|---|
| 200 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 201 | # @param $(deps) Other dependencies.
|
|---|
| 202 | # @param $(othersrc) Unhandled sources.
|
|---|
| 203 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 204 | TOOL_GCC3PLAIN_LINK_LIBRARY_OUTPUT = $(out).ar-script
|
|---|
| 205 | TOOL_GCC3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
|
|---|
| 206 | TOOL_GCC3PLAIN_LINK_LIBRARY_DEPORD =
|
|---|
| 207 | define TOOL_GCC3PLAIN_LINK_LIBRARY_CMDS
|
|---|
| 208 | $(call xargs,$(QUIET)$(TOOL_GCC3PLAIN_AR) $(flags) $(out),$(objs))
|
|---|
| 209 | $(foreach lib,$(othersrc)\
|
|---|
| 210 | ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
|
|---|
| 211 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
|
|---|
| 212 | $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
|
|---|
| 213 | $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
|
|---|
| 214 | && $(TOOL_GCC3PLAIN_AR) x $(abspath $(lib)) \
|
|---|
| 215 | && $(TOOL_GCC3PLAIN_AR) $(flags) $(out) *) \
|
|---|
| 216 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
|
|---|
| 217 | $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
|
|---|
| 218 | $(QUIET)$(TOOL_GCC3PLAIN_RANLIB) $(out)
|
|---|
| 219 | endef
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | ## Link program
|
|---|
| 223 | # @param $(target) Normalized main target name.
|
|---|
| 224 | # @param $(out) Program name.
|
|---|
| 225 | # @param $(objs) Object files to link together.
|
|---|
| 226 | # @param $(libs) Libraries to search.
|
|---|
| 227 | # @param $(libpath) Library search paths.
|
|---|
| 228 | # @param $(flags) Flags.
|
|---|
| 229 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 230 | # @param $(deps) Other dependencies.
|
|---|
| 231 | # @param $(othersrc) Unhandled sources.
|
|---|
| 232 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 233 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 234 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 235 | TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT =
|
|---|
| 236 | TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
|
|---|
| 237 | TOOL_GCC3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
|
|---|
| 238 | $(filter %.def, $(othersrc))
|
|---|
| 239 | TOOL_GCC3PLAIN_LINK_PROGRAM_DEPORD =
|
|---|
| 240 | define TOOL_GCC3PLAIN_LINK_PROGRAM_CMDS
|
|---|
| 241 | $(QUIET)$(TOOL_GCC3PLAIN_LD) $(flags) -o $(out) $(objs)\
|
|---|
| 242 | $(filter %.def, $(othersrc))\
|
|---|
| 243 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 244 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 245 | endef
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 | ## Link DLL
|
|---|
| 249 | # @param $(target) Normalized main target name.
|
|---|
| 250 | # @param $(out) Program name.
|
|---|
| 251 | # @param $(objs) Object files to link together.
|
|---|
| 252 | # @param $(libs) Libraries to search.
|
|---|
| 253 | # @param $(libpath) Library search paths.
|
|---|
| 254 | # @param $(flags) Flags.
|
|---|
| 255 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 256 | # @param $(deps) Other dependencies.
|
|---|
| 257 | # @param $(othersrc) Unhandled sources.
|
|---|
| 258 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 259 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 260 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 261 | TOOL_GCC3PLAIN_LINK_DLL_OUTPUT =
|
|---|
| 262 | TOOL_GCC3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
|
|---|
| 263 | TOOL_GCC3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
|
|---|
| 264 | $(filter %.def, $(othersrc))
|
|---|
| 265 | TOOL_GCC3PLAIN_LINK_DLL_DEPORD =
|
|---|
| 266 | define TOOL_GCC3PLAIN_LINK_DLL_CMDS
|
|---|
| 267 | $(QUIET)$(TOOL_GCC3PLAIN_LD) $(TOOL_GCC3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
|
|---|
| 268 | $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC3PLAIN_LD_SONAME,$(target),$(out)))\
|
|---|
| 269 | $(objs)\
|
|---|
| 270 | $(filter %.def, $(othersrc))\
|
|---|
| 271 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 272 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 273 | endef
|
|---|
| 274 |
|
|---|