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

Last change on this file since 419 was 380, checked in by bird, 20 years ago

Big command dependency job. More installation stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1# $Id: GCC3.kmk 380 2005-12-18 13:52:47Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC.
5#
6# Copyright (c) 2004-2005 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)))
67ifeq ($(BUILD_TARGET),os2)
68TOOL_GCC3_LD_MAP = -Zmap=$(1)
69else
70TOOL_GCC3_LD_MAP = -Wl,-Map -Wl,$(1) -Wl,--cref
71endif
72ifeq ($(BUILD_TARGET),os2)
73TOOL_GCC3_LD_SYSMOD_MAP = -Zmap=$(1)
74else
75TOOL_GCC3_LD_SYSMOD_MAP = -Map $(1) --cref
76endif
77ifdef SLKRUNS
78TOOL_GCC3_CC += -fmessage-length=0
79TOOL_GCC3_CXX += -fmessage-length=0
80endif
81
82
83## Compile C source.
84# @param $(target) Normalized main target name.
85# @param $(source) Source filename (relative).
86# @param $(obj) Object file name. This shall be (re)created by the compilation.
87# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
88# @param $(flags) Flags.
89# @param $(defs) Definitions. No -D or something.
90# @param $(incs) Includes. No -I or something.
91# @param $(dirdep) Directory creation dependency.
92# @param $(deps) Other dependencies.
93#
94# @param $(outbase) Output basename (full). Use this for list files and such.
95# @param $(objsuff) Object suffix.
96TOOL_GCC3_COMPILE_C_OUTPUT =
97TOOL_GCC3_COMPILE_C_DEPEND =
98TOOL_GCC3_COMPILE_C_DEPORD =
99define TOOL_GCC3_COMPILE_C_CMDS
100 $(TOOL_GCC3_CC) -c\
101 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
102 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
103 -o $(obj)\
104 $(call ABSPATH,$(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# @param $(outbase) Output basename (full). Use this for list files and such.
119# @param $(objsuff) Object suffix.
120TOOL_GCC3_COMPILE_CXX_OUTPUT =
121TOOL_GCC3_COMPILE_CXX_DEPEND =
122TOOL_GCC3_COMPILE_CXX_DEPORD =
123define TOOL_GCC3_COMPILE_CXX_CMDS
124 $(TOOL_GCC3_CXX) -c\
125 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
126 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
127 -o $(obj)\
128 $(call ABSPATH,$(source))
129endef
130
131
132## Link library
133# @param $(target) Normalized main target name.
134# @param $(out) Library name.
135# @param $(objs) Object files to put in the library.
136# @param $(flags) Flags.
137# @param $(dirdep) Directory creation dependency.
138# @param $(deps) Other dependencies.
139# @param $(othersrc) Unhandled sources.
140# @param $(outbase) Output basename (full). Use this for list files and such.
141TOOL_GCC3_LINK_LIBRARY_OUTPUT = $(out).ar-script
142TOOL_GCC3_LINK_LIBRARY_DEPEND = $(filter %.a %.lib,$(othersrc))
143TOOL_GCC3_LINK_LIBRARY_DEPORD =
144define TOOL_GCC3_LINK_LIBRARY_CMDS
145 $(APPEND) $(out).ar-script "CREATE $(out)"
146 $(foreach o, $(objs)\
147 ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDMOD $(o)")
148 $(foreach srclib, $(filter %.a %.lib,$(othersrc))\
149 ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
150 $(APPEND) $(out).ar-script "SAVE"
151 $(APPEND) $(out).ar-script "END"
152 $(TOOL_GCC3_AR) -M < $(out).ar-script
153endef
154
155
156## Link program
157# @param $(target) Normalized main target name.
158# @param $(out) Program name.
159# @param $(objs) Object files to link together.
160# @param $(libs) Libraries to search.
161# @param $(libpath) Library search paths.
162# @param $(flags) Flags.
163# @param $(dirdep) Directory creation dependency.
164# @param $(deps) Other dependencies.
165# @param $(othersrc) Unhandled sources.
166# @param $(custom_pre) Custom step invoked before linking.
167# @param $(custom_post) Custom step invoked after linking.
168# @param $(outbase) Output basename (full). Use this for list files and such.
169TOOL_GCC3_LINK_PROGRAM_OUTPUT = $(outbase).map
170TOOL_GCC3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
171TOOL_GCC3_LINK_PROGRAM_DEPORD =
172define TOOL_GCC3_LINK_PROGRAM_CMDS
173 $(TOOL_GCC3_LD) $(flags) -o $(out) $(objs)\
174 $(foreach p,$(libpath), -L$(p))\
175 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
176 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
177endef
178
179
180## Link DLL
181# @param $(target) Normalized main target name.
182# @param $(out) Program name.
183# @param $(objs) Object files to link together.
184# @param $(libs) Libraries to search.
185# @param $(libpath) Library search paths.
186# @param $(flags) Flags.
187# @param $(dirdep) Directory creation dependency.
188# @param $(deps) Other dependencies.
189# @param $(othersrc) Unhandled sources.
190# @param $(custom_pre) Custom step invoked before linking.
191# @param $(custom_post) Custom step invoked after linking.
192# @param $(outbase) Output basename (full). Use this for list files and such.
193TOOL_GCC3_LINK_DLL_OUTPUT = $(outbase).map
194TOOL_GCC3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
195TOOL_GCC3_LINK_DLL_DEPORD =
196define TOOL_GCC3_LINK_DLL_CMDS
197 $(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $(out)\
198 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(out)))\
199 $(objs)\
200 $(foreach p,$(libpath), -L$(p))\
201 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
202 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
203endef
204
205
206## Link system module (windows aka driver, linux aka kernel module)
207# @param $(target) Normalized main target name.
208# @param $(out) System module name.
209# @param $(objs) Object files to link together.
210# @param $(libs) Libraries to search.
211# @param $(libpath) Library search paths.
212# @param $(flags) Flags.
213# @param $(dirdep) Directory creation dependency.
214# @param $(deps) Other dependencies.
215# @param $(othersrc) Unhandled sources.
216# @param $(custom_pre) Custom step invoked before linking.
217# @param $(custom_post) Custom step invoked after linking.
218# @param $(outbase) Output basename (full). Use this for list files and such.
219TOOL_GCC3_LINK_SYSMOD_OUTPUT = $(outbase).map
220TOOL_GCC3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
221TOOL_GCC3_LINK_SYSMOD_DEPORD =
222define TOOL_GCC3_LINK_SYSMOD_CMDS
223 $(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
224 $(foreach p,$(libpath), -L$(p))\
225 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
226 $(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map)
227endef
228
Note: See TracBrowser for help on using the repository browser.