source: trunk/kBuild/tools/GCC.kmk@ 973

Last change on this file since 973 was 973, checked in by bird, 18 years ago

WARNING! The GCC* tools are no using gcc and NOT g++ for linking.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.1 KB
RevLine 
[72]1# $Id: GCC.kmk 973 2007-05-27 17:09:49Z bird $
2## @file
3#
[667]4# kBuild Tool Config - Generic GCC Using The System GCC.
[72]5#
[782]6# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
[72]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
[667]27TOOL_GCC := Generic GCC Using The System GCC.
[72]28
[667]29# Tool Specific Properties
30TOOL_GCC_CC ?= gcc$(HOSTSUFF_EXE)
31TOOL_GCC_CXX ?= g++$(HOSTSUFF_EXE)
32TOOL_GCC_AS ?= gcc$(HOSTSUFF_EXE)
33TOOL_GCC_AR ?= ar$(HOSTSUFF_EXE)
[846]34TOOL_GCC_RANLIB ?= ranlib$(HOSTSUFF_EXE)
[973]35TOOL_GCC_LD ?= gcc$(HOSTSUFF_EXE)
[667]36TOOL_GCC_LDFLAGS.dll.os2 ?= -Zdll
[846]37TOOL_GCC_LDFLAGS.dll.darwin ?= -dynamiclib
[667]38ifndef TOOL_GCC_LDFLAGS.$(BUILD_TARGET)
39TOOL_GCC_LDFLAGS.dll ?= -shared
40else
41TOOL_GCC_LDFLAGS.dll ?= $(TOOL_GCC_LDFLAGS.$(BUILD_TARGET))
42endif
[73]43
[667]44# General Properties used by kBuild
45TOOL_GCC_COBJSUFF ?= .o
[782]46TOOL_GCC_CFLAGS ?=
[667]47TOOL_GCC_CFLAGS.debug ?= -g
48TOOL_GCC_CFLAGS.profile ?= -g -O2 #-pg
49TOOL_GCC_CFLAGS.release ?= -O2
50TOOL_GCC_CINCS ?=
51TOOL_GCC_CDEFS ?=
[72]52
[667]53TOOL_GCC_CXXOBJSUFF ?= .o
54TOOL_GCC_CXXOBJSUFF ?= .o
[782]55TOOL_GCC_CXXFLAGS ?=
[667]56TOOL_GCC_CXXFLAGS.debug ?= -g -O0
57TOOL_GCC_CXXFLAGS.profile ?= -g -O2 #-pg
58TOOL_GCC_CXXFLAGS.release ?= -O2
59TOOL_GCC_CXXINCS ?=
60TOOL_GCC_CXXDEFS ?=
[72]61
[667]62TOOL_GCC_ASFLAGS ?= -x assembler-with-cpp
63TOOL_GCC_ASFLAGS.debug ?= -g
64TOOL_GCC_ASFLAGS.profile ?= -g
65TOOL_GCC_ASOBJSUFF ?= .o
[73]66
[667]67TOOL_GCC_ARFLAGS ?= cr
68TOOL_GCC_ARLIBSUFF ?= .a
[73]69
[667]70TOOL_GCC_LDFLAGS ?=
71TOOL_GCC_LDFLAGS.debug ?= -g
72TOOL_GCC_LDFLAGS.profile ?= -g
[73]73
[74]74
[72]75## Compile C source.
[73]76# @param $(target) Normalized main target name.
77# @param $(source) Source filename (relative).
[235]78# @param $(obj) Object file name. This shall be (re)created by the compilation.
[73]79# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
80# @param $(flags) Flags.
81# @param $(defs) Definitions. No -D or something.
82# @param $(incs) Includes. No -I or something.
[235]83# @param $(dirdep) Directory creation dependency.
84# @param $(deps) Other dependencies.
[73]85# @param $(outbase) Output basename (full). Use this for list files and such.
[235]86# @param $(objsuff) Object suffix.
[380]87#
88TOOL_GCC_COMPILE_C_OUTPUT =
89TOOL_GCC_COMPILE_C_DEPEND =
90TOOL_GCC_COMPILE_C_DEPORD =
91define TOOL_GCC_COMPILE_C_CMDS
[696]92 $(QUIET)$(TOOL_GCC_CC) -c\
[73]93 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
[846]94 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
95 -o $(obj)\
[697]96 $(abspath $(source))
[72]97endef
98
[73]99
[77]100## Compile C++ source.
101# @param $(target) Normalized main target name.
102# @param $(source) Source filename (relative).
[235]103# @param $(obj) Object file name. This shall be (re)created by the compilation.
[77]104# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
105# @param $(flags) Flags.
106# @param $(defs) Definitions. No -D or something.
107# @param $(incs) Includes. No -I or something.
[235]108# @param $(dirdep) Directory creation dependency.
109# @param $(deps) Other dependencies.
[77]110#
111# @param $(outbase) Output basename (full). Use this for list files and such.
[235]112# @param $(objsuff) Object suffix.
[380]113TOOL_GCC_COMPILE_CXX_OUTPUT =
114TOOL_GCC_COMPILE_CXX_DEPEND =
115TOOL_GCC_COMPILE_CXX_DEPORD =
116define TOOL_GCC_COMPILE_CXX_CMDS
[696]117 $(QUIET)$(TOOL_GCC_CXX) -c\
[77]118 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
[846]119 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
120 -o $(obj)\
[697]121 $(abspath $(source))
[77]122endef
123
124
[465]125## Compile Assembly source.
126# @param $(target) Normalized main target name.
127# @param $(source) Source filename (relative).
128# @param $(obj) Object file name. This shall be (re)created by the compilation.
129# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
130# @param $(flags) Flags.
131# @param $(defs) Definitions. No -D or something.
132# @param $(incs) Includes. No -I or something.
133# @param $(dirdep) Directory creation dependency.
134# @param $(deps) Other dependencies.
135# @param $(outbase) Output basename (full). Use this for list files and such.
136# @param $(objsuff) Object suffix.
137#
[469]138TOOL_GCC_COMPILE_AS_OUTPUT =
[465]139TOOL_GCC_COMPILE_AS_DEPEND =
140TOOL_GCC_COMPILE_AS_DEPORD =
141define TOOL_GCC_COMPILE_AS_CMDS
[696]142 $(QUIET)$(TOOL_GCC_AS) -c\
[465]143 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
[846]144 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
145 -o $(obj)\
[697]146 $(abspath $(source))
[465]147endef
148
149
[73]150## Link library
151# @param $(target) Normalized main target name.
[380]152# @param $(out) Library name.
[73]153# @param $(objs) Object files to put in the library.
154# @param $(flags) Flags.
[235]155# @param $(dirdep) Directory creation dependency.
156# @param $(deps) Other dependencies.
[73]157#
158# @param $(outbase) Output basename (full). Use this for list files and such.
[380]159TOOL_GCC_LINK_LIBRARY_OUTPUT =
160TOOL_GCC_LINK_LIBRARY_DEPEND =
[465]161TOOL_GCC_LINK_LIBRARY_DEPORD =
[380]162define TOOL_GCC_LINK_LIBRARY_CMDS
[696]163 $(QUIET)$(TOOL_GCC_AR) $(flags) $(out) $(objs)
[846]164 $(call xargs,$(QUIET)$(TOOL_GCC_AR) $(flags) $(out),$(objs))
165 $(foreach lib,$(othersrc)\
166 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
167 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
168 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
169 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
170 && $(TOOL_GCC_AR) x $(abspath $(lib)) \
171 && $(TOOL_GCC_AR) $(flags) $(out) *) \
172 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
173 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
174 $(QUIET)$(TOOL_GCC_RANLIB) $(out)
[73]175endef
176
[74]177
178## Link program
179# @param $(target) Normalized main target name.
[353]180# @param $(out) Program name.
[74]181# @param $(objs) Object files to link together.
182# @param $(libs) Libraries to search.
183# @param $(libpath) Library search paths.
184# @param $(flags) Flags.
[235]185# @param $(dirdep) Directory creation dependency.
186# @param $(deps) Other dependencies.
187# @param $(othersrc) Unhandled sources.
188# @param $(custom_pre) Custom step invoked before linking.
189# @param $(custom_post) Custom step invoked after linking.
[74]190#
191# @param $(outbase) Output basename (full). Use this for list files and such.
[380]192TOOL_GCC_LINK_PROGRAM_OUTPUT =
193TOOL_GCC_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
[465]194TOOL_GCC_LINK_PROGRAM_DEPORD =
[380]195define TOOL_GCC_LINK_PROGRAM_CMDS
[696]196 $(QUIET)$(TOOL_GCC_LD) $(flags) -o $(out) $(objs) \
[380]197 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
[74]198endef
199
[130]200
[353]201## Link DLL
[130]202# @param $(target) Normalized main target name.
[353]203# @param $(out) Program name.
[130]204# @param $(objs) Object files to link together.
205# @param $(libs) Libraries to search.
206# @param $(libpath) Library search paths.
207# @param $(flags) Flags.
[235]208# @param $(dirdep) Directory creation dependency.
209# @param $(deps) Other dependencies.
210# @param $(othersrc) Unhandled sources.
211# @param $(custom_pre) Custom step invoked before linking.
212# @param $(custom_post) Custom step invoked after linking.
[380]213# @param $(outbase) Output basename (full). Use this for list files and such.
214TOOL_GCC_LINK_DLL_OUTPUT =
215TOOL_GCC_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
[465]216TOOL_GCC_LINK_DLL_DEPORD =
[380]217define TOOL_GCC_LINK_DLL_CMDS
[696]218 $(QUIET)$(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
[353]219 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
[130]220endef
221
Note: See TracBrowser for help on using the repository browser.