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

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

Soname fix.

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