VirtualBox

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

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

License clearification.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.4 KB
Line 
1# $Id: GXX.kmk 1547 2008-04-22 02:02:09Z bird $
2## @file
3# kBuild Tool Config - Generic GCC using the system GCC, for building C++ code.
4#
5
6#
7# Copyright (c) 2004-2008 knut st. osmundsen <[email protected]>
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# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
33
34TOOL_GXX := Generic GCC using the system GCC, for building C++ code.
35
36# Tool Specific Properties
37TOOL_GXX_CC ?= gcc$(HOSTSUFF_EXE)
38TOOL_GXX_CXX ?= g++$(HOSTSUFF_EXE)
39TOOL_GXX_AS ?= gcc$(HOSTSUFF_EXE)
40TOOL_GXX_AR ?= ar$(HOSTSUFF_EXE)
41TOOL_GXX_RANLIB ?= ranlib$(HOSTSUFF_EXE)
42TOOL_GXX_LD ?= g++$(HOSTSUFF_EXE)
43TOOL_GXX_LDFLAGS.dll.os2 ?= -Zdll
44TOOL_GXX_LDFLAGS.dll.darwin ?= -dynamiclib
45ifndef TOOL_GXX_LDFLAGS.$(KBUILD_TARGET)
46TOOL_GXX_LDFLAGS.dll ?= -shared
47else
48TOOL_GXX_LDFLAGS.dll ?= $(TOOL_GXX_LDFLAGS.$(KBUILD_TARGET))
49endif
50
51# General Properties used by kBuild
52TOOL_GXX_COBJSUFF ?= .o
53TOOL_GXX_CFLAGS ?=
54TOOL_GXX_CFLAGS.debug ?= -g
55TOOL_GXX_CFLAGS.profile ?= -g -O2 #-pg
56TOOL_GXX_CFLAGS.release ?= -O2
57TOOL_GXX_CINCS ?=
58TOOL_GXX_CDEFS ?=
59
60TOOL_GXX_CXXOBJSUFF ?= .o
61TOOL_GXX_CXXOBJSUFF ?= .o
62TOOL_GXX_CXXFLAGS ?=
63TOOL_GXX_CXXFLAGS.debug ?= -g -O0
64TOOL_GXX_CXXFLAGS.profile ?= -g -O2 #-pg
65TOOL_GXX_CXXFLAGS.release ?= -O2
66TOOL_GXX_CXXINCS ?=
67TOOL_GXX_CXXDEFS ?=
68
69TOOL_GXX_ASFLAGS ?= -x assembler-with-cpp
70TOOL_GXX_ASFLAGS.debug ?= -g
71TOOL_GXX_ASFLAGS.profile ?= -g
72TOOL_GXX_ASOBJSUFF ?= .o
73
74TOOL_GXX_ARFLAGS ?= cr
75TOOL_GXX_ARLIBSUFF ?= .a
76
77TOOL_GXX_LDFLAGS ?=
78TOOL_GXX_LDFLAGS.debug ?= -g
79TOOL_GXX_LDFLAGS.profile ?= -g
80
81
82## Compile C source.
83# @param $(target) Normalized main target name.
84# @param $(source) Source filename (relative).
85# @param $(obj) Object file name. This shall be (re)created by the compilation.
86# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
87# @param $(flags) Flags.
88# @param $(defs) Definitions. No -D or something.
89# @param $(incs) Includes. No -I or something.
90# @param $(dirdep) Directory creation dependency.
91# @param $(deps) Other dependencies.
92# @param $(outbase) Output basename (full). Use this for list files and such.
93# @param $(objsuff) Object suffix.
94#
95TOOL_GXX_COMPILE_C_OUTPUT =
96TOOL_GXX_COMPILE_C_DEPEND =
97TOOL_GXX_COMPILE_C_DEPORD =
98define TOOL_GXX_COMPILE_C_CMDS
99 $(QUIET)$(TOOL_GXX_CC) -c\
100 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
101 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
102 -o $(obj)\
103 $(abspath $(source))
104endef
105
106
107## Compile C++ source.
108# @param $(target) Normalized main target name.
109# @param $(source) Source filename (relative).
110# @param $(obj) Object file name. This shall be (re)created by the compilation.
111# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
112# @param $(flags) Flags.
113# @param $(defs) Definitions. No -D or something.
114# @param $(incs) Includes. No -I or something.
115# @param $(dirdep) Directory creation dependency.
116# @param $(deps) Other dependencies.
117#
118# @param $(outbase) Output basename (full). Use this for list files and such.
119# @param $(objsuff) Object suffix.
120TOOL_GXX_COMPILE_CXX_OUTPUT =
121TOOL_GXX_COMPILE_CXX_DEPEND =
122TOOL_GXX_COMPILE_CXX_DEPORD =
123define TOOL_GXX_COMPILE_CXX_CMDS
124 $(QUIET)$(TOOL_GXX_CXX) -c\
125 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
126 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
127 -o $(obj)\
128 $(abspath $(source))
129endef
130
131
132## Compile Assembly source.
133# @param $(target) Normalized main target name.
134# @param $(source) Source filename (relative).
135# @param $(obj) Object file name. This shall be (re)created by the compilation.
136# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
137# @param $(flags) Flags.
138# @param $(defs) Definitions. No -D or something.
139# @param $(incs) Includes. No -I or something.
140# @param $(dirdep) Directory creation dependency.
141# @param $(deps) Other dependencies.
142# @param $(outbase) Output basename (full). Use this for list files and such.
143# @param $(objsuff) Object suffix.
144#
145TOOL_GXX_COMPILE_AS_OUTPUT =
146TOOL_GXX_COMPILE_AS_DEPEND =
147TOOL_GXX_COMPILE_AS_DEPORD =
148define TOOL_GXX_COMPILE_AS_CMDS
149 $(QUIET)$(TOOL_GXX_AS) -c\
150 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
151 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
152 -o $(obj)\
153 $(abspath $(source))
154endef
155
156
157## Link library
158# @param $(target) Normalized main target name.
159# @param $(out) Library name.
160# @param $(objs) Object files to put in the library.
161# @param $(flags) Flags.
162# @param $(dirdep) Directory creation dependency.
163# @param $(deps) Other dependencies.
164#
165# @param $(outbase) Output basename (full). Use this for list files and such.
166TOOL_GXX_LINK_LIBRARY_OUTPUT =
167TOOL_GXX_LINK_LIBRARY_DEPEND =
168TOOL_GXX_LINK_LIBRARY_DEPORD =
169define TOOL_GXX_LINK_LIBRARY_CMDS
170 $(QUIET)$(TOOL_GXX_AR) $(flags) $(out) $(objs)
171 $(call xargs,$(QUIET)$(TOOL_GXX_AR) $(flags) $(out),$(objs))
172 $(foreach lib,$(othersrc)\
173 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
174 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
175 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
176 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
177 && $(TOOL_GXX_AR) x $(abspath $(lib)) \
178 && $(TOOL_GXX_AR) $(flags) $(out) *) \
179 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
180 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
181 $(QUIET)$(TOOL_GXX_RANLIB) $(out)
182endef
183
184
185## Link program
186# @param $(target) Normalized main target name.
187# @param $(out) Program name.
188# @param $(objs) Object files to link together.
189# @param $(libs) Libraries to search.
190# @param $(libpath) Library search paths.
191# @param $(flags) Flags.
192# @param $(dirdep) Directory creation dependency.
193# @param $(deps) Other dependencies.
194# @param $(othersrc) Unhandled sources.
195# @param $(custom_pre) Custom step invoked before linking.
196# @param $(custom_post) Custom step invoked after linking.
197#
198# @param $(outbase) Output basename (full). Use this for list files and such.
199TOOL_GXX_LINK_PROGRAM_OUTPUT =
200TOOL_GXX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
201TOOL_GXX_LINK_PROGRAM_DEPORD =
202define TOOL_GXX_LINK_PROGRAM_CMDS
203 $(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(objs) \
204 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
205endef
206
207
208## Link DLL
209# @param $(target) Normalized main target name.
210# @param $(out) Program name.
211# @param $(objs) Object files to link together.
212# @param $(libs) Libraries to search.
213# @param $(libpath) Library search paths.
214# @param $(flags) Flags.
215# @param $(dirdep) Directory creation dependency.
216# @param $(deps) Other dependencies.
217# @param $(othersrc) Unhandled sources.
218# @param $(custom_pre) Custom step invoked before linking.
219# @param $(custom_post) Custom step invoked after linking.
220# @param $(outbase) Output basename (full). Use this for list files and such.
221TOOL_GXX_LINK_DLL_OUTPUT =
222TOOL_GXX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
223TOOL_GXX_LINK_DLL_DEPORD =
224define TOOL_GXX_LINK_DLL_CMDS
225 $(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
226 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
227endef
228
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