source: trunk/kBuild/tools/GCC3.kmk@ 143

Last change on this file since 143 was 143, checked in by bird, 21 years ago

SLRUNS and message length.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.8 KB
Line 
1# $Id: GCC3.kmk 143 2004-09-02 14:57:05Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC.
5#
6# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@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
27TOOL_GCC3 := Generic GCC v3
28
29TOOL_GCC3_CC := gcc$(HOSTSUFF_EXE)
30TOOL_GCC3_COBJSUFF := .o
31TOOL_GCC3_CFLAGS := -g
32TOOL_GCC3_CFLAGS.debug := -O0
33TOOL_GCC3_CFLAGS.release := -O2
34TOOL_GCC3_CFLAGS.profile := -pg
35TOOL_GCC3_CINCS :=
36TOOL_GCC3_CDEFS :=
37
38TOOL_GCC3_CXX := g++$(HOSTSUFF_EXE)
39TOOL_GCC3_CXXOBJSUFF := .o
40TOOL_GCC3_CXXOBJSUFF := .o
41TOOL_GCC3_CXXFLAGS := -g
42TOOL_GCC3_CXXFLAGS.debug := -O0
43TOOL_GCC3_CXXFLAGS.release := -O2
44TOOL_GCC3_CXXFLAGS.profile := -pg
45TOOL_GCC3_CXXINCS :=
46TOOL_GCC3_CXXDEFS :=
47
48TOOL_GCC3_AS := as$(HOSTSUFF_EXE)
49TOOL_GCC3_ASOBJSUFF := .o
50
51TOOL_GCC3_AR := ar$(HOSTSUFF_EXE)
52TOOL_GCC3_ARFLAGS := cr
53TOOL_GCC3_ARLIBSUFF := .a
54
55TOOL_GCC3_LD := g++$(HOSTSUFF_EXE)
56TOOL_GCC3_LD_SYSMOD := ld$(HOSTSUFF_EXE)
57TOOL_GCC3_LDFLAGS :=
58TOOL_GCC3_LDFLAGS.debug := -g
59TOOL_GCC3_LDFLAGS.release := -s
60ifndef TOOL_GCC3_LDFLAGS.$(BUILD_TARGET)
61TOOL_GCC3_LDFLAGS.dll := -shared
62else
63TOOL_GCC3_LDFLAGS.dll := $(TOOL_GCC3_LDFLAGS.$(BUILD_TARGET))
64endif
65TOOL_GCC3_LDFLAGS.sysmod := -r
66
67ifdef SLKRUNS
68TOOL_GCC3_CC += -fmessage-length=0
69TOOL_GCC3_CXX += -fmessage-length=0
70endif
71
72
73## Compile C source.
74# @param $(target) Normalized main target name.
75# @param $(source) Source filename (relative).
76# @param $(obj) Object file name. This shall be (re)created by the compilation.
77# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
78# @param $(flags) Flags.
79# @param $(defs) Definitions. No -D or something.
80# @param $(incs) Includes. No -I or something.
81# @param $(dirdep) Directory creation dependency.
82#
83# @param $(outbase) Output basename (full). Use this for list files and such.
84# @param $(objsuff) Object suffix.
85define TOOL_GCC3_COMPILE_C
86#$ (warning dbg: TOOL_GCC3_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
87$(obj): $(dirdep) $(source)
88 $(call MSG_L2,Compiling $$@ using GCC3)
89 $(TOOL_GCC3_CC) -c\
90 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
91 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
92 -o $$@\
93 $(call ABSPATH,$(source))
94
95endef
96
97
98## Compile C++ source.
99# @param $(target) Normalized main target name.
100# @param $(source) Source filename (relative).
101# @param $(obj) Object file name. This shall be (re)created by the compilation.
102# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
103# @param $(flags) Flags.
104# @param $(defs) Definitions. No -D or something.
105# @param $(incs) Includes. No -I or something.
106# @param $(dirdep) Directory creation dependency.
107#
108# @param $(outbase) Output basename (full). Use this for list files and such.
109# @param $(objsuff) Object suffix.
110define TOOL_GCC3_COMPILE_CXX
111#$ (warning dbg: TOOL_GCC3_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
112$(obj): $(dirdep) $(source)
113 $(call MSG_L2,Compiling $$@ using GCC3)
114 $(TOOL_GCC3_CXX) -c\
115 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
116 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
117 -o $$@\
118 $(call ABSPATH,$(source))
119
120endef
121
122
123## Link library
124# @param $(target) Normalized main target name.
125# @param $(lib) Library name.
126# @param $(objs) Object files to put in the library.
127# @param $(flags) Flags.
128# @param $(dirdep) Directory creation dependency.
129# @param $(deps) Other dependencies.
130#
131# @param $(outbase) Output basename (full). Use this for list files and such.
132define TOOL_GCC3_LINK_LIBRARY
133#$ (warning dbg: TOOL_GCC3_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
134$(lib): $(dirdep) $(objs) $(deps)
135 $(call MSG_L1,Creating Library $$@)
136 $(RM) -f $$@
137 $(TOOL_GCC3_AR) $(flags) $$@ $(objs)
138
139endef
140
141
142## Link program
143# @param $(target) Normalized main target name.
144# @param $(exe) Program name.
145# @param $(objs) Object files to link together.
146# @param $(libs) Libraries to search.
147# @param $(libpath) Library search paths.
148# @param $(flags) Flags.
149# @param $(dirdep) Directory creation dependency.
150# @param $(deps) Other dependencies.
151# @param $(othersrc) Unhandled sources.
152# @param $(custom_pre) Custom step invoked before linking.
153# @param $(custom_post) Custom step invoked after linking.
154#
155# @param $(outbase) Output basename (full). Use this for list files and such.
156define TOOL_GCC3_LINK_PROGRAM
157#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
158$(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
159 $(call MSG_L1,Creating Program $$@)
160ifneq ($(custom_pre),)
161 $(eval $(custom_pre))
162endif
163 $(TOOL_GCC3_LD) $(flags) -o $$@ $(objs) \
164 $(foreach p,$(libpath), -L$(p)) \
165 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
166ifneq ($(custom_post),)
167 $(eval $(custom_post))
168endif
169
170endef
171
172
173## Link DLL
174# @param $(target) Normalized main target name.
175# @param $(dll) Program name.
176# @param $(objs) Object files to link together.
177# @param $(libs) Libraries to search.
178# @param $(libpath) Library search paths.
179# @param $(flags) Flags.
180# @param $(dirdep) Directory creation dependency.
181# @param $(deps) Other dependencies.
182# @param $(othersrc) Unhandled sources.
183# @param $(custom_pre) Custom step invoked before linking.
184# @param $(custom_post) Custom step invoked after linking.
185#
186# @param $(outbase) Output basename (full). Use this for list files and such.
187define TOOL_GCC3_LINK_DLL
188#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
189$(dll): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
190 $(call MSG_L1,Creating Program $$@)
191ifneq ($(custom_pre),)
192 $(eval $(custom_pre))
193endif
194 $(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
195 $(foreach p,$(libpath), -L$(p)) \
196 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
197ifneq ($(custom_post),)
198 $(eval $(custom_post))
199endif
200
201endef
202
203## Link system module (windows aka driver, linux aka kernel module)
204# @param $(target) Normalized main target name.
205# @param $(sys) System module name.
206# @param $(objs) Object files to link together.
207# @param $(libs) Libraries to search.
208# @param $(libpath) Library search paths.
209# @param $(flags) Flags.
210# @param $(dirdep) Directory creation dependency.
211# @param $(deps) Other dependencies.
212# @param $(othersrc) Unhandled sources.
213# @param $(custom_pre) Custom step invoked before linking.
214# @param $(custom_post) Custom step invoked after linking.
215#
216# @param $(outbase) Output basename (full). Use this for list files and such.
217define TOOL_GCC3_LINK_SYSMOD
218#$ (warning dbg: TOOL_GCC3_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
219$(sys): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
220 $(call MSG_L1,Creating Program $$@)
221ifneq ($(custom_pre),)
222 $(eval $(custom_pre))
223endif
224 $(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $$@ $(objs) \
225 $(foreach p,$(libpath), -L$(p)) \
226 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
227ifneq ($(custom_post),)
228 $(eval $(custom_post))
229endif
230
231endef
232
Note: See TracBrowser for help on using the repository browser.