source: trunk/kBuild/tools/GCC3PLAIN.kmk@ 3313

Last change on this file since 3313 was 3121, checked in by bird, 8 years ago

(C) year)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.0 KB
Line 
1# $Id: GCC3PLAIN.kmk 3121 2017-10-31 10:58:59Z bird $
2## @file
3# kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
4#
5
6#
7# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@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_GCC3PLAIN := Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
35
36# Tool Specific Properties
37TOOL_GCC3PLAIN_CC ?= gcc$(HOSTSUFF_EXE)
38TOOL_GCC3PLAIN_CXX ?= g++$(HOSTSUFF_EXE)
39TOOL_GCC3PLAIN_AS ?= gcc$(HOSTSUFF_EXE)
40TOOL_GCC3PLAIN_AR ?= ar$(HOSTSUFF_EXE)
41TOOL_GCC3PLAIN_RANLIB ?= ranlib$(HOSTSUFF_EXE)
42TOOL_GCC3PLAIN_LD ?= gcc$(HOSTSUFF_EXE)
43TOOL_GCC3PLAIN_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
44TOOL_GCC3PLAIN_LD_SYSMOD.os2 ?= g++$(HOSTSUFF_EXE)
45TOOL_GCC3PLAIN_LDFLAGS.dll.os2 ?= -Zdll
46TOOL_GCC3PLAIN_LDFLAGS.dll.darwin ?= -dynamiclib
47ifndef TOOL_GCC3PLAIN_LDFLAGS.$(KBUILD_TARGET)
48 TOOL_GCC3PLAIN_LDFLAGS.dll ?= -shared
49else
50 TOOL_GCC3PLAIN_LDFLAGS.dll ?= $(TOOL_GCC3PLAIN_LDFLAGS.$(KBUILD_TARGET))
51endif
52TOOL_GCC3PLAIN_LD_SONAME.darwin ?= $(NO_SUCH_VARIABLE)
53TOOL_GCC3PLAIN_LD_SONAME.os2 ?= $(NO_SUCH_VARIABLE)
54TOOL_GCC3PLAIN_LD_SONAME.solaris ?= -Wl,-h,$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
55TOOL_GCC3PLAIN_LD_SONAME.win ?= $(NO_SUCH_VARIABLE)
56ifndef TOOL_GCC3PLAIN_LD_SONAME.$(KBUILD_TARGET)
57 TOOL_GCC3PLAIN_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
58else
59 TOOL_GCC3PLAIN_LD_SONAME ?= $(TOOL_GCC3PLAIN_LD_SONAME.$(KBUILD_TARGET))
60endif
61ifdef SLKRUNS
62 TOOL_GCC3PLAIN_CC += -fmessage-length=0
63 TOOL_GCC3PLAIN_CXX += -fmessage-length=0
64endif
65
66# General Properties used by kBuild
67TOOL_GCC3PLAIN_COBJSUFF ?= .o
68TOOL_GCC3PLAIN_CFLAGS ?=
69TOOL_GCC3PLAIN_CFLAGS.debug ?= -g
70TOOL_GCC3PLAIN_CFLAGS.profile ?= -O2 #-g -pg
71TOOL_GCC3PLAIN_CFLAGS.release ?= -O2
72TOOL_GCC3PLAIN_CINCS ?=
73TOOL_GCC3PLAIN_CDEFS ?=
74
75TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
76TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
77TOOL_GCC3PLAIN_CXXFLAGS ?=
78TOOL_GCC3PLAIN_CXXFLAGS.debug ?= -g
79TOOL_GCC3PLAIN_CXXFLAGS.profile ?= -O2 #-g -pg
80TOOL_GCC3PLAIN_CXXFLAGS.release ?= -O2
81TOOL_GCC3PLAIN_CXXINCS ?=
82TOOL_GCC3PLAIN_CXXDEFS ?=
83
84TOOL_GCC3PLAIN_ASFLAGS ?= -x assembler-with-cpp
85TOOL_GCC3PLAIN_ASFLAGS.debug ?= -g
86TOOL_GCC3PLAIN_ASFLAGS.profile ?= -g
87TOOL_GCC3PLAIN_ASOBJSUFF ?= .o
88
89TOOL_GCC3PLAIN_ARFLAGS ?= cr
90TOOL_GCC3PLAIN_ARLIBSUFF ?= .a
91
92TOOL_GCC3PLAIN_LDFLAGS ?=
93
94
95## Compile C source.
96# @param $(target) Normalized main target name.
97# @param $(source) Source filename (relative).
98# @param $(obj) Object file name. This shall be (re)created by the compilation.
99# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
100# @param $(flags) Flags.
101# @param $(defs) Definitions. No -D or something.
102# @param $(incs) Includes. No -I or something.
103# @param $(dirdep) Directory creation dependency.
104# @param $(deps) Other dependencies.
105#
106# @param $(outbase) Output basename (full). Use this for list files and such.
107# @param $(objsuff) Object suffix.
108TOOL_GCC3PLAIN_COMPILE_C_DEPEND =
109TOOL_GCC3PLAIN_COMPILE_C_DEPORD =
110ifdef KBUILD_USE_KOBJCACHE
111TOOL_GCC3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
112TOOL_GCC3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
113define TOOL_GCC3PLAIN_COMPILE_C_CMDS
114 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
115 --kObjCache-cpp $(outbase).i\
116 $(TOOL_GCC3PLAIN_CC) -E -o -\
117 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
118 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
119 $(abspath $(source))\
120 --kObjCache-cc $(obj)\
121 $(TOOL_GCC3PLAIN_CC) -c\
122 $(flags) -fpreprocessed -x c\
123 -o $(obj)\
124 -
125 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
126endef
127else # !KBUILD_USE_KOBJCACHE
128TOOL_GCC3PLAIN_COMPILE_C_OUTPUT =
129define TOOL_GCC3PLAIN_COMPILE_C_CMDS
130 $(QUIET)$(TOOL_GCC3PLAIN_CC) -c\
131 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
132 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
133 -o $(obj)\
134 $(abspath $(source))
135 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
136endef
137endif # !KBUILD_USE_KOBJCACHE
138
139
140## Compile C++ source.
141# @param $(target) Normalized main target name.
142# @param $(source) Source filename (relative).
143# @param $(obj) Object file name. This shall be (re)created by the compilation.
144# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
145# @param $(flags) Flags.
146# @param $(defs) Definitions. No -D or something.
147# @param $(incs) Includes. No -I or something.
148# @param $(dirdep) Directory creation dependency.
149# @param $(deps) Other dependencies.
150# @param $(outbase) Output basename (full). Use this for list files and such.
151# @param $(objsuff) Object suffix.
152TOOL_GCC3PLAIN_COMPILE_CXX_DEPEND =
153TOOL_GCC3PLAIN_COMPILE_CXX_DEPORD =
154ifdef KBUILD_USE_KOBJCACHE
155TOOL_GCC3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
156TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
157define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
158 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
159 --kObjCache-cpp $(outbase).ii\
160 $(TOOL_GCC3PLAIN_CXX) -E -o -\
161 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
162 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
163 $(abspath $(source))\
164 --kObjCache-cc $(obj)\
165 $(TOOL_GCC3PLAIN_CXX) -c\
166 $(flags) -fpreprocessed -x c++\
167 -o $(obj)\
168 -
169 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
170endef
171else # !KBUILD_USE_KOBJCACHE
172TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT =
173define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
174 $(QUIET)$(TOOL_GCC3PLAIN_CXX) -c\
175 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
176 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
177 -o $(obj)\
178 $(abspath $(source))
179 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
180endef
181endif # !KBUILD_USE_KOBJCACHE
182
183
184## Compile Assembly source.
185# @param $(target) Normalized main target name.
186# @param $(source) Source filename (relative).
187# @param $(obj) Object file name. This shall be (re)created by the compilation.
188# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
189# @param $(flags) Flags.
190# @param $(defs) Definitions. No -D or something.
191# @param $(incs) Includes. No -I or something.
192# @param $(dirdep) Directory creation dependency.
193# @param $(deps) Other dependencies.
194# @param $(outbase) Output basename (full). Use this for list files and such.
195# @param $(objsuff) Object suffix.
196#
197TOOL_GCC3PLAIN_COMPILE_AS_OUTPUT =
198TOOL_GCC3PLAIN_COMPILE_AS_DEPEND =
199TOOL_GCC3PLAIN_COMPILE_AS_DEPORD =
200define TOOL_GCC3PLAIN_COMPILE_AS_CMDS
201 $(QUIET)$(TOOL_GCC3PLAIN_AS) -c\
202 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
203 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
204 -o $(obj)\
205 $(abspath $(source))
206 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
207endef
208
209
210## Link library
211# @param $(target) Normalized main target name.
212# @param $(out) Library name.
213# @param $(objs) Object files to put in the library.
214# @param $(flags) Flags.
215# @param $(dirdep) Directory creation dependency.
216# @param $(deps) Other dependencies.
217# @param $(othersrc) Unhandled sources.
218# @param $(outbase) Output basename (full). Use this for list files and such.
219TOOL_GCC3PLAIN_LINK_LIBRARY_OUTPUT =
220TOOL_GCC3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
221TOOL_GCC3PLAIN_LINK_LIBRARY_DEPORD =
222define TOOL_GCC3PLAIN_LINK_LIBRARY_CMDS
223 $(call xargs,$(QUIET)$(TOOL_GCC3PLAIN_AR) $(flags) $(out),$(objs))
224 $(foreach lib,$(othersrc)\
225 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
226 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
227 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
228 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
229 && $(TOOL_GCC3PLAIN_AR) x $(abspath $(lib)) \
230 && $(TOOL_GCC3PLAIN_AR) $(flags) $(out) *) \
231 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
232 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
233 $(QUIET)$(TOOL_GCC3PLAIN_RANLIB) $(out)
234endef
235
236
237## Link program
238# @param $(target) Normalized main target name.
239# @param $(out) Program name.
240# @param $(objs) Object files to link together.
241# @param $(libs) Libraries to search.
242# @param $(libpath) Library search paths.
243# @param $(flags) Flags.
244# @param $(dirdep) Directory creation dependency.
245# @param $(deps) Other dependencies.
246# @param $(othersrc) Unhandled sources.
247# @param $(custom_pre) Custom step invoked before linking.
248# @param $(custom_post) Custom step invoked after linking.
249# @param $(outbase) Output basename (full). Use this for list files and such.
250TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT =
251TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
252TOOL_GCC3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
253 $(filter %.def, $(othersrc))
254TOOL_GCC3PLAIN_LINK_PROGRAM_DEPORD =
255define TOOL_GCC3PLAIN_LINK_PROGRAM_CMDS
256 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(flags) -o $(out) $(objs)\
257 $(filter %.def, $(othersrc))\
258 $(foreach p,$(libpath), -L$(p))\
259 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
260endef
261
262
263## Link DLL
264# @param $(target) Normalized main target name.
265# @param $(out) Program name.
266# @param $(objs) Object files to link together.
267# @param $(libs) Libraries to search.
268# @param $(libpath) Library search paths.
269# @param $(flags) Flags.
270# @param $(dirdep) Directory creation dependency.
271# @param $(deps) Other dependencies.
272# @param $(othersrc) Unhandled sources.
273# @param $(custom_pre) Custom step invoked before linking.
274# @param $(custom_post) Custom step invoked after linking.
275# @param $(outbase) Output basename (full). Use this for list files and such.
276TOOL_GCC3PLAIN_LINK_DLL_OUTPUT =
277TOOL_GCC3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
278TOOL_GCC3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
279 $(filter %.def, $(othersrc))
280TOOL_GCC3PLAIN_LINK_DLL_DEPORD =
281define TOOL_GCC3PLAIN_LINK_DLL_CMDS
282 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(TOOL_GCC3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
283 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GCC3PLAIN_LD_SONAME,$(target),$(out)))\
284 $(objs)\
285 $(filter %.def, $(othersrc))\
286 $(foreach p,$(libpath), -L$(p))\
287 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
288endef
289
290
291## Link system module (windows aka driver, linux aka kernel module)
292# This tool target might not work everywhere, but is provided for the
293# platforms where it works (Solaris, etc).
294#
295# @param $(target) Normalized main target name.
296# @param $(out) System module name.
297# @param $(objs) Object files to link together.
298# @param $(libs) Libraries to search.
299# @param $(libpath) Library search paths.
300# @param $(flags) Flags.
301# @param $(dirdep) Directory creation dependency.
302# @param $(deps) Other dependencies.
303# @param $(othersrc) Unhandled sources.
304# @param $(custom_pre) Custom step invoked before linking.
305# @param $(custom_post) Custom step invoked after linking.
306# @param $(outbase) Output basename (full). Use this for list files and such.
307TOOL_GCC3PLAIN_LINK_SYSMOD_OUTPUT =
308TOOL_GCC3PLAIN_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
309TOOL_GCC3PLAIN_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
310 $(filter %.def, $(othersrc))
311TOOL_GCC3PLAIN_LINK_SYSMOD_DEPORD =
312define TOOL_GCC3PLAIN_LINK_SYSMOD_CMDS
313 $(QUIET)$(if $(TOOL_GCC3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GCC3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GCC3PLAIN_LD_SYSMOD))\
314 $(TOOL_GCC3PLAIN_LDFLAGS_SYSMOD.$(bld_trg)) $(flags) -o $(out)\
315 $(objs)\
316 $(filter %.def, $(othersrc))\
317 $(foreach p,$(libpath), -L$(p))\
318 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
319endef
320
Note: See TracBrowser for help on using the repository browser.