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

Last change on this file since 2431 was 2431, checked in by bird, 15 years ago

tools/G*.kmk: Add dummy source rule/dep to the gcc generated dependency files to make it less painful to move a source file without changing the target names. Fixes #101.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1# $Id: GXX.kmk 2431 2010-11-19 11:06:42Z bird $
2## @file
3# kBuild Tool Config - Generic GCC using the system GCC, for building C++ code.
4#
5
6#
7# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
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))
104 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
105endef
106
107
108## Compile C++ source.
109# @param $(target) Normalized main target name.
110# @param $(source) Source filename (relative).
111# @param $(obj) Object file name. This shall be (re)created by the compilation.
112# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
113# @param $(flags) Flags.
114# @param $(defs) Definitions. No -D or something.
115# @param $(incs) Includes. No -I or something.
116# @param $(dirdep) Directory creation dependency.
117# @param $(deps) Other dependencies.
118#
119# @param $(outbase) Output basename (full). Use this for list files and such.
120# @param $(objsuff) Object suffix.
121TOOL_GXX_COMPILE_CXX_OUTPUT =
122TOOL_GXX_COMPILE_CXX_DEPEND =
123TOOL_GXX_COMPILE_CXX_DEPORD =
124define TOOL_GXX_COMPILE_CXX_CMDS
125 $(QUIET)$(TOOL_GXX_CXX) -c\
126 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
127 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
128 -o $(obj)\
129 $(abspath $(source))
130 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
131endef
132
133
134## Compile Assembly source.
135# @param $(target) Normalized main target name.
136# @param $(source) Source filename (relative).
137# @param $(obj) Object file name. This shall be (re)created by the compilation.
138# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
139# @param $(flags) Flags.
140# @param $(defs) Definitions. No -D or something.
141# @param $(incs) Includes. No -I or something.
142# @param $(dirdep) Directory creation dependency.
143# @param $(deps) Other dependencies.
144# @param $(outbase) Output basename (full). Use this for list files and such.
145# @param $(objsuff) Object suffix.
146#
147TOOL_GXX_COMPILE_AS_OUTPUT =
148TOOL_GXX_COMPILE_AS_DEPEND =
149TOOL_GXX_COMPILE_AS_DEPORD =
150define TOOL_GXX_COMPILE_AS_CMDS
151 $(QUIET)$(TOOL_GXX_AS) -c\
152 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
153 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
154 -o $(obj)\
155 $(abspath $(source))
156 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
157endef
158
159
160## Link library
161# @param $(target) Normalized main target name.
162# @param $(out) Library name.
163# @param $(objs) Object files to put in the library.
164# @param $(flags) Flags.
165# @param $(dirdep) Directory creation dependency.
166# @param $(deps) Other dependencies.
167#
168# @param $(outbase) Output basename (full). Use this for list files and such.
169TOOL_GXX_LINK_LIBRARY_OUTPUT =
170TOOL_GXX_LINK_LIBRARY_DEPEND =
171TOOL_GXX_LINK_LIBRARY_DEPORD =
172define TOOL_GXX_LINK_LIBRARY_CMDS
173 $(QUIET)$(TOOL_GXX_AR) $(flags) $(out) $(objs)
174 $(call xargs,$(QUIET)$(TOOL_GXX_AR) $(flags) $(out),$(objs))
175 $(foreach lib,$(othersrc)\
176 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
177 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
178 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
179 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
180 && $(TOOL_GXX_AR) x $(abspath $(lib)) \
181 && $(TOOL_GXX_AR) $(flags) $(out) *) \
182 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
183 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
184 $(QUIET)$(TOOL_GXX_RANLIB) $(out)
185endef
186
187
188## Link program
189# @param $(target) Normalized main target name.
190# @param $(out) Program name.
191# @param $(objs) Object files to link together.
192# @param $(libs) Libraries to search.
193# @param $(libpath) Library search paths.
194# @param $(flags) Flags.
195# @param $(dirdep) Directory creation dependency.
196# @param $(deps) Other dependencies.
197# @param $(othersrc) Unhandled sources.
198# @param $(custom_pre) Custom step invoked before linking.
199# @param $(custom_post) Custom step invoked after linking.
200#
201# @param $(outbase) Output basename (full). Use this for list files and such.
202TOOL_GXX_LINK_PROGRAM_OUTPUT =
203TOOL_GXX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
204TOOL_GXX_LINK_PROGRAM_DEPORD =
205define TOOL_GXX_LINK_PROGRAM_CMDS
206 $(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(objs) \
207 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
208endef
209
210
211## Link DLL
212# @param $(target) Normalized main target name.
213# @param $(out) Program name.
214# @param $(objs) Object files to link together.
215# @param $(libs) Libraries to search.
216# @param $(libpath) Library search paths.
217# @param $(flags) Flags.
218# @param $(dirdep) Directory creation dependency.
219# @param $(deps) Other dependencies.
220# @param $(othersrc) Unhandled sources.
221# @param $(custom_pre) Custom step invoked before linking.
222# @param $(custom_post) Custom step invoked after linking.
223# @param $(outbase) Output basename (full). Use this for list files and such.
224TOOL_GXX_LINK_DLL_OUTPUT =
225TOOL_GXX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
226TOOL_GXX_LINK_DLL_DEPORD =
227define TOOL_GXX_LINK_DLL_CMDS
228 $(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
229 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
230endef
231
Note: See TracBrowser for help on using the repository browser.