VirtualBox

source: kBuild/trunk/kBuild/tools/GXX.kmk@ 1505

Last change on this file since 1505 was 1505, checked in by bird, 17 years ago

Updated the copyright year.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.1 KB
Line 
1# $Id: GXX.kmk 1505 2008-04-09 00:13:14Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC using the system GCC, for building C++ code.
5#
6# Copyright (c) 2004-2008 knut st. osmundsen <[email protected]>
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
27TOOL_GXX := Generic GCC using the system GCC, for building C++ code.
28
29# Tool Specific Properties
30TOOL_GXX_CC ?= gcc$(HOSTSUFF_EXE)
31TOOL_GXX_CXX ?= g++$(HOSTSUFF_EXE)
32TOOL_GXX_AS ?= gcc$(HOSTSUFF_EXE)
33TOOL_GXX_AR ?= ar$(HOSTSUFF_EXE)
34TOOL_GXX_RANLIB ?= ranlib$(HOSTSUFF_EXE)
35TOOL_GXX_LD ?= g++$(HOSTSUFF_EXE)
36TOOL_GXX_LDFLAGS.dll.os2 ?= -Zdll
37TOOL_GXX_LDFLAGS.dll.darwin ?= -dynamiclib
38ifndef TOOL_GXX_LDFLAGS.$(KBUILD_TARGET)
39TOOL_GXX_LDFLAGS.dll ?= -shared
40else
41TOOL_GXX_LDFLAGS.dll ?= $(TOOL_GXX_LDFLAGS.$(KBUILD_TARGET))
42endif
43
44# General Properties used by kBuild
45TOOL_GXX_COBJSUFF ?= .o
46TOOL_GXX_CFLAGS ?=
47TOOL_GXX_CFLAGS.debug ?= -g
48TOOL_GXX_CFLAGS.profile ?= -g -O2 #-pg
49TOOL_GXX_CFLAGS.release ?= -O2
50TOOL_GXX_CINCS ?=
51TOOL_GXX_CDEFS ?=
52
53TOOL_GXX_CXXOBJSUFF ?= .o
54TOOL_GXX_CXXOBJSUFF ?= .o
55TOOL_GXX_CXXFLAGS ?=
56TOOL_GXX_CXXFLAGS.debug ?= -g -O0
57TOOL_GXX_CXXFLAGS.profile ?= -g -O2 #-pg
58TOOL_GXX_CXXFLAGS.release ?= -O2
59TOOL_GXX_CXXINCS ?=
60TOOL_GXX_CXXDEFS ?=
61
62TOOL_GXX_ASFLAGS ?= -x assembler-with-cpp
63TOOL_GXX_ASFLAGS.debug ?= -g
64TOOL_GXX_ASFLAGS.profile ?= -g
65TOOL_GXX_ASOBJSUFF ?= .o
66
67TOOL_GXX_ARFLAGS ?= cr
68TOOL_GXX_ARLIBSUFF ?= .a
69
70TOOL_GXX_LDFLAGS ?=
71TOOL_GXX_LDFLAGS.debug ?= -g
72TOOL_GXX_LDFLAGS.profile ?= -g
73
74
75## Compile C source.
76# @param $(target) Normalized main target name.
77# @param $(source) Source filename (relative).
78# @param $(obj) Object file name. This shall be (re)created by the compilation.
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.
83# @param $(dirdep) Directory creation dependency.
84# @param $(deps) Other dependencies.
85# @param $(outbase) Output basename (full). Use this for list files and such.
86# @param $(objsuff) Object suffix.
87#
88TOOL_GXX_COMPILE_C_OUTPUT =
89TOOL_GXX_COMPILE_C_DEPEND =
90TOOL_GXX_COMPILE_C_DEPORD =
91define TOOL_GXX_COMPILE_C_CMDS
92 $(QUIET)$(TOOL_GXX_CC) -c\
93 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
94 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
95 -o $(obj)\
96 $(abspath $(source))
97endef
98
99
100## Compile C++ source.
101# @param $(target) Normalized main target name.
102# @param $(source) Source filename (relative).
103# @param $(obj) Object file name. This shall be (re)created by the compilation.
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.
108# @param $(dirdep) Directory creation dependency.
109# @param $(deps) Other dependencies.
110#
111# @param $(outbase) Output basename (full). Use this for list files and such.
112# @param $(objsuff) Object suffix.
113TOOL_GXX_COMPILE_CXX_OUTPUT =
114TOOL_GXX_COMPILE_CXX_DEPEND =
115TOOL_GXX_COMPILE_CXX_DEPORD =
116define TOOL_GXX_COMPILE_CXX_CMDS
117 $(QUIET)$(TOOL_GXX_CXX) -c\
118 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
119 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
120 -o $(obj)\
121 $(abspath $(source))
122endef
123
124
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#
138TOOL_GXX_COMPILE_AS_OUTPUT =
139TOOL_GXX_COMPILE_AS_DEPEND =
140TOOL_GXX_COMPILE_AS_DEPORD =
141define TOOL_GXX_COMPILE_AS_CMDS
142 $(QUIET)$(TOOL_GXX_AS) -c\
143 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
144 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
145 -o $(obj)\
146 $(abspath $(source))
147endef
148
149
150## Link library
151# @param $(target) Normalized main target name.
152# @param $(out) Library name.
153# @param $(objs) Object files to put in the library.
154# @param $(flags) Flags.
155# @param $(dirdep) Directory creation dependency.
156# @param $(deps) Other dependencies.
157#
158# @param $(outbase) Output basename (full). Use this for list files and such.
159TOOL_GXX_LINK_LIBRARY_OUTPUT =
160TOOL_GXX_LINK_LIBRARY_DEPEND =
161TOOL_GXX_LINK_LIBRARY_DEPORD =
162define TOOL_GXX_LINK_LIBRARY_CMDS
163 $(QUIET)$(TOOL_GXX_AR) $(flags) $(out) $(objs)
164 $(call xargs,$(QUIET)$(TOOL_GXX_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_GXX_AR) x $(abspath $(lib)) \
171 && $(TOOL_GXX_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_GXX_RANLIB) $(out)
175endef
176
177
178## Link program
179# @param $(target) Normalized main target name.
180# @param $(out) Program name.
181# @param $(objs) Object files to link together.
182# @param $(libs) Libraries to search.
183# @param $(libpath) Library search paths.
184# @param $(flags) Flags.
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.
190#
191# @param $(outbase) Output basename (full). Use this for list files and such.
192TOOL_GXX_LINK_PROGRAM_OUTPUT =
193TOOL_GXX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
194TOOL_GXX_LINK_PROGRAM_DEPORD =
195define TOOL_GXX_LINK_PROGRAM_CMDS
196 $(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(objs) \
197 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
198endef
199
200
201## Link DLL
202# @param $(target) Normalized main target name.
203# @param $(out) Program name.
204# @param $(objs) Object files to link together.
205# @param $(libs) Libraries to search.
206# @param $(libpath) Library search paths.
207# @param $(flags) Flags.
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.
213# @param $(outbase) Output basename (full). Use this for list files and such.
214TOOL_GXX_LINK_DLL_OUTPUT =
215TOOL_GXX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
216TOOL_GXX_LINK_DLL_DEPORD =
217define TOOL_GXX_LINK_DLL_CMDS
218 $(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
219 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
220endef
221
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette