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

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

Linux SYSMOD for GCC3. (bad feeling)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1# $Id: GCC3.kmk 137 2004-08-03 20:01:17Z 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
67
68
69## Compile C source.
70# @param $(target) Normalized main target name.
71# @param $(source) Source filename (relative).
72# @param $(obj) Object file name. This shall be (re)created by the compilation.
73# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
74# @param $(flags) Flags.
75# @param $(defs) Definitions. No -D or something.
76# @param $(incs) Includes. No -I or something.
77# @param $(dirdep) Directory creation dependency.
78#
79# @param $(outbase) Output basename (full). Use this for list files and such.
80# @param $(objsuff) Object suffix.
81define TOOL_GCC3_COMPILE_C
82#$ (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))
83$(obj): $(dirdep) $(source)
84 $(call MSG_L2,Compiling $$@ using GCC3)
85 $(TOOL_GCC3_CC) -c\
86 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
87 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
88 -o $$@\
89 $(call ABSPATH,$(source))
90
91endef
92
93
94## Compile C++ source.
95# @param $(target) Normalized main target name.
96# @param $(source) Source filename (relative).
97# @param $(obj) Object file name. This shall be (re)created by the compilation.
98# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
99# @param $(flags) Flags.
100# @param $(defs) Definitions. No -D or something.
101# @param $(incs) Includes. No -I or something.
102# @param $(dirdep) Directory creation dependency.
103#
104# @param $(outbase) Output basename (full). Use this for list files and such.
105# @param $(objsuff) Object suffix.
106define TOOL_GCC3_COMPILE_CXX
107#$ (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))
108$(obj): $(dirdep) $(source)
109 $(call MSG_L2,Compiling $$@ using GCC3)
110 $(TOOL_GCC3_CXX) -c\
111 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
112 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
113 -o $$@\
114 $(call ABSPATH,$(source))
115
116endef
117
118
119## Link library
120# @param $(target) Normalized main target name.
121# @param $(lib) Library name.
122# @param $(objs) Object files to put in the library.
123# @param $(flags) Flags.
124# @param $(dirdep) Directory creation dependency.
125# @param $(deps) Other dependencies.
126#
127# @param $(outbase) Output basename (full). Use this for list files and such.
128define TOOL_GCC3_LINK_LIBRARY
129#$ (warning dbg: TOOL_GCC3_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
130$(lib): $(dirdep) $(objs) $(deps)
131 $(call MSG_L1,Creating Library $$@)
132 $(RM) -f $$@
133 $(TOOL_GCC3_AR) $(flags) $$@ $(objs)
134
135endef
136
137
138## Link program
139# @param $(target) Normalized main target name.
140# @param $(exe) Program name.
141# @param $(objs) Object files to link together.
142# @param $(libs) Libraries to search.
143# @param $(libpath) Library search paths.
144# @param $(flags) Flags.
145# @param $(dirdep) Directory creation dependency.
146# @param $(deps) Other dependencies.
147# @param $(othersrc) Unhandled sources.
148# @param $(custom_pre) Custom step invoked before linking.
149# @param $(custom_post) Custom step invoked after linking.
150#
151# @param $(outbase) Output basename (full). Use this for list files and such.
152define TOOL_GCC3_LINK_PROGRAM
153#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
154$(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
155 $(call MSG_L1,Creating Program $$@)
156ifneq ($(custom_pre),)
157 $(eval $(custom_pre))
158endif
159 $(TOOL_GCC3_LD) $(flags) -o $$@ $(objs) \
160 $(foreach p,$(libpath), -L$(p)) \
161 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
162ifneq ($(custom_post),)
163 $(eval $(custom_post))
164endif
165
166endef
167
168
169## Link DLL
170# @param $(target) Normalized main target name.
171# @param $(dll) Program name.
172# @param $(objs) Object files to link together.
173# @param $(libs) Libraries to search.
174# @param $(libpath) Library search paths.
175# @param $(flags) Flags.
176# @param $(dirdep) Directory creation dependency.
177# @param $(deps) Other dependencies.
178# @param $(othersrc) Unhandled sources.
179# @param $(custom_pre) Custom step invoked before linking.
180# @param $(custom_post) Custom step invoked after linking.
181#
182# @param $(outbase) Output basename (full). Use this for list files and such.
183define TOOL_GCC3_LINK_DLL
184#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
185$(dll): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
186 $(call MSG_L1,Creating Program $$@)
187ifneq ($(custom_pre),)
188 $(eval $(custom_pre))
189endif
190 $(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
191 $(foreach p,$(libpath), -L$(p)) \
192 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
193ifneq ($(custom_post),)
194 $(eval $(custom_post))
195endif
196
197endef
198
199## Link system module (windows aka driver, linux aka kernel module)
200# @param $(target) Normalized main target name.
201# @param $(sys) System module name.
202# @param $(objs) Object files to link together.
203# @param $(libs) Libraries to search.
204# @param $(libpath) Library search paths.
205# @param $(flags) Flags.
206# @param $(dirdep) Directory creation dependency.
207# @param $(deps) Other dependencies.
208# @param $(othersrc) Unhandled sources.
209# @param $(custom_pre) Custom step invoked before linking.
210# @param $(custom_post) Custom step invoked after linking.
211#
212# @param $(outbase) Output basename (full). Use this for list files and such.
213define TOOL_GCC3_LINK_SYSMOD
214#$ (warning dbg: TOOL_GCC3_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
215$(sys): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
216 $(call MSG_L1,Creating Program $$@)
217ifneq ($(custom_pre),)
218 $(eval $(custom_pre))
219endif
220 $(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $$@ $(objs) \
221 $(foreach p,$(libpath), -L$(p)) \
222 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
223ifneq ($(custom_post),)
224 $(eval $(custom_post))
225endif
226
227endef
228
Note: See TracBrowser for help on using the repository browser.