source: trunk/kBuild/tools/GXX32.kmk@ 1013

Last change on this file since 1013 was 971, checked in by bird, 18 years ago

GCC -> GXX. (the GCC is going to do plain C linking using gcc instead of g++ to fix these incorrect dependencies on the C++ RT when linking C progs.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.5 KB
Line 
1# $Id: GXX32.kmk 971 2007-05-27 16:45:22Z bird $
2## @file
3#
4# kBuild Tool Config - Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code.
5#
6# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@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_GXX32 := Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code. \
28 More or less Linux/ELF specfic.
29
30# Tool Specific Properties
31TOOL_GXX32_CC ?= gcc$(HOSTSUFF_EXE) -m32
32TOOL_GXX32_CXX ?= g++$(HOSTSUFF_EXE) -m32
33TOOL_GXX32_AS ?= gcc$(HOSTSUFF_EXE) -m32
34TOOL_GXX32_AR ?= ar$(HOSTSUFF_EXE)
35TOOL_GXX32_LD ?= g++$(HOSTSUFF_EXE) -m32
36TOOL_GXX32_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
37ifndef TOOL_GXX32_LDFLAGS.$(BUILD_TARGET)
38TOOL_GXX32_LDFLAGS.dll ?= -shared
39else
40TOOL_GXX32_LDFLAGS.dll ?= $(TOOL_GXX32_LDFLAGS.$(BUILD_TARGET))
41endif
42TOOL_GXX32_LDFLAGS.sysmod ?= -r -m elf_i386
43TOOL_GXX32_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
44ifeq ($(BUILD_TARGET),os2)
45TOOL_GXX32_LD_MAP ?= -Zmap=$(1)
46else
47TOOL_GXX32_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
48endif
49ifeq ($(BUILD_TARGET),os2)
50TOOL_GXX32_LD_SYSMOD_MAP ?= -Zmap=$(1)
51else
52TOOL_GXX32_LD_SYSMOD_MAP ?= -Map $(1) --cref
53endif
54ifdef SLKRUNS
55TOOL_GXX32_CC += -fmessage-length=0
56TOOL_GXX32_CXX += -fmessage-length=0
57endif
58
59# General Properties used by kBuild
60TOOL_GXX32_COBJSUFF ?= .o
61TOOL_GXX32_CFLAGS ?=
62TOOL_GXX32_CFLAGS.debug ?= -g
63TOOL_GXX32_CFLAGS.profile ?= -g -O2 #-pg
64TOOL_GXX32_CFLAGS.release ?= -O2
65TOOL_GXX32_CINCS ?=
66TOOL_GXX32_CDEFS ?=
67
68TOOL_GXX32_CXXOBJSUFF ?= .o
69TOOL_GXX32_CXXOBJSUFF ?= .o
70TOOL_GXX32_CXXFLAGS ?=
71TOOL_GXX32_CXXFLAGS.debug ?= -g
72TOOL_GXX32_CXXFLAGS.profile ?= -g -O2 #-pg
73TOOL_GXX32_CXXFLAGS.release ?= -O2
74TOOL_GXX32_CXXINCS ?=
75TOOL_GXX32_CXXDEFS ?=
76
77TOOL_GXX32_ASFLAGS ?= -x assembler-with-cpp
78TOOL_GXX32_ASFLAGS.debug ?= -g
79TOOL_GXX32_ASFLAGS.profile ?= -g
80TOOL_GXX32_ASOBJSUFF ?= .o
81
82TOOL_GXX32_ARFLAGS ?= cr
83TOOL_GXX32_ARLIBSUFF ?= .a
84
85TOOL_GXX32_LDFLAGS ?=
86TOOL_GXX32_LDFLAGS.debug ?= -g
87TOOL_GXX32_LDFLAGS.profile ?= -g
88
89
90## Compile C source.
91# @param $(target) Normalized main target name.
92# @param $(source) Source filename (relative).
93# @param $(obj) Object file name. This shall be (re)created by the compilation.
94# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
95# @param $(flags) Flags.
96# @param $(defs) Definitions. No -D or something.
97# @param $(incs) Includes. No -I or something.
98# @param $(dirdep) Directory creation dependency.
99# @param $(deps) Other dependencies.
100#
101# @param $(outbase) Output basename (full). Use this for list files and such.
102# @param $(objsuff) Object suffix.
103TOOL_GXX32_COMPILE_C_OUTPUT =
104TOOL_GXX32_COMPILE_C_DEPEND =
105TOOL_GXX32_COMPILE_C_DEPORD =
106define TOOL_GXX32_COMPILE_C_CMDS
107 $(QUIET)$(TOOL_GXX32_CC) -c\
108 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
109 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
110 -o $(obj)\
111 $(abspath $(source))
112endef
113
114
115## Compile C++ source.
116# @param $(target) Normalized main target name.
117# @param $(source) Source filename (relative).
118# @param $(obj) Object file name. This shall be (re)created by the compilation.
119# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
120# @param $(flags) Flags.
121# @param $(defs) Definitions. No -D or something.
122# @param $(incs) Includes. No -I or something.
123# @param $(dirdep) Directory creation dependency.
124# @param $(deps) Other dependencies.
125# @param $(outbase) Output basename (full). Use this for list files and such.
126# @param $(objsuff) Object suffix.
127TOOL_GXX32_COMPILE_CXX_OUTPUT =
128TOOL_GXX32_COMPILE_CXX_DEPEND =
129TOOL_GXX32_COMPILE_CXX_DEPORD =
130define TOOL_GXX32_COMPILE_CXX_CMDS
131 $(QUIET)$(TOOL_GXX32_CXX) -c\
132 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
133 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
134 -o $(obj)\
135 $(abspath $(source))
136endef
137
138
139## Compile Assembly source.
140# @param $(target) Normalized main target name.
141# @param $(source) Source filename (relative).
142# @param $(obj) Object file name. This shall be (re)created by the compilation.
143# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
144# @param $(flags) Flags.
145# @param $(defs) Definitions. No -D or something.
146# @param $(incs) Includes. No -I or something.
147# @param $(dirdep) Directory creation dependency.
148# @param $(deps) Other dependencies.
149# @param $(outbase) Output basename (full). Use this for list files and such.
150# @param $(objsuff) Object suffix.
151#
152TOOL_GXX32_COMPILE_AS_OUTPUT =
153TOOL_GXX32_COMPILE_AS_DEPEND =
154TOOL_GXX32_COMPILE_AS_DEPORD =
155define TOOL_GXX32_COMPILE_AS_CMDS
156 $(QUIET)$(TOOL_GXX32_AS) -c\
157 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
158 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
159 -o $(obj)\
160 $(abspath $(source))
161endef
162
163
164## Link library
165# @param $(target) Normalized main target name.
166# @param $(out) Library name.
167# @param $(objs) Object files to put in the library.
168# @param $(flags) Flags.
169# @param $(dirdep) Directory creation dependency.
170# @param $(deps) Other dependencies.
171# @param $(othersrc) Unhandled sources.
172# @param $(outbase) Output basename (full). Use this for list files and such.
173TOOL_GXX32_LINK_LIBRARY_OUTPUT = $(out).ar-script
174TOOL_GXX32_LINK_LIBRARY_DEPEND = $(othersrc)
175TOOL_GXX32_LINK_LIBRARY_DEPORD =
176ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
177define TOOL_GXX32_LINK_LIBRARY_CMDS
178 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
179 $(QUIET)$(APPEND) -n $(out).ar-script \
180 $(foreach o,$(objs), 'ADDMOD $(o)') \
181 $(foreach o,$(othersrc), 'ADDLIB $(o)')
182 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
183 $(QUIET)$(APPEND) $(out).ar-script 'END'
184 $(QUIET)$(TOOL_GXX32_AR) -M < $(out).ar-script
185endef
186else
187define TOOL_GXX32_LINK_LIBRARY_CMDS
188 $(QUIET)$(APPEND) $(out).ar-script "CREATE $(out)"
189 $(foreach o, $(objs)\
190 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDMOD $(o)")
191 $(foreach srclib,$(othersrc)\
192 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
193 $(QUIET)$(APPEND) $(out).ar-script "SAVE"
194 $(QUIET)$(APPEND) $(out).ar-script "END"
195 $(QUIET)$(TOOL_GXX32_AR) -M < $(out).ar-script
196endef
197endif
198
199
200## Link program
201# @param $(target) Normalized main target name.
202# @param $(out) Program name.
203# @param $(objs) Object files to link together.
204# @param $(libs) Libraries to search.
205# @param $(libpath) Library search paths.
206# @param $(flags) Flags.
207# @param $(dirdep) Directory creation dependency.
208# @param $(deps) Other dependencies.
209# @param $(othersrc) Unhandled sources.
210# @param $(custom_pre) Custom step invoked before linking.
211# @param $(custom_post) Custom step invoked after linking.
212# @param $(outbase) Output basename (full). Use this for list files and such.
213TOOL_GXX32_LINK_PROGRAM_OUTPUT = $(outbase).map
214TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
215TOOL_GXX32_LINK_PROGRAM_DEPORD =
216define TOOL_GXX32_LINK_PROGRAM_CMDS
217 $(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\
218 $(foreach p,$(libpath), -L$(p))\
219 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
220 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
221endef
222
223
224## Link DLL
225# @param $(target) Normalized main target name.
226# @param $(out) Program name.
227# @param $(objs) Object files to link together.
228# @param $(libs) Libraries to search.
229# @param $(libpath) Library search paths.
230# @param $(flags) Flags.
231# @param $(dirdep) Directory creation dependency.
232# @param $(deps) Other dependencies.
233# @param $(othersrc) Unhandled sources.
234# @param $(custom_pre) Custom step invoked before linking.
235# @param $(custom_post) Custom step invoked after linking.
236# @param $(outbase) Output basename (full). Use this for list files and such.
237TOOL_GXX32_LINK_DLL_OUTPUT = $(outbase).map
238TOOL_GXX32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
239TOOL_GXX32_LINK_DLL_DEPORD =
240define TOOL_GXX32_LINK_DLL_CMDS
241 $(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\
242 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GXX32_LD_SONAME,$(target),$(out)))\
243 $(objs)\
244 $(foreach p,$(libpath), -L$(p))\
245 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
246 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
247endef
248
249
250## Link system module (windows aka driver, linux aka kernel module)
251# @param $(target) Normalized main target name.
252# @param $(out) System module name.
253# @param $(objs) Object files to link together.
254# @param $(libs) Libraries to search.
255# @param $(libpath) Library search paths.
256# @param $(flags) Flags.
257# @param $(dirdep) Directory creation dependency.
258# @param $(deps) Other dependencies.
259# @param $(othersrc) Unhandled sources.
260# @param $(custom_pre) Custom step invoked before linking.
261# @param $(custom_post) Custom step invoked after linking.
262# @param $(outbase) Output basename (full). Use this for list files and such.
263TOOL_GXX32_LINK_SYSMOD_OUTPUT = $(outbase).map
264TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
265TOOL_GXX32_LINK_SYSMOD_DEPORD =
266define TOOL_GXX32_LINK_SYSMOD_CMDS
267 $(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
268 $(foreach p,$(libpath), -L$(p))\
269 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
270 $(call TOOL_GXX32_LD_SYSMOD_MAP,$(outbase).map)
271endef
272
Note: See TracBrowser for help on using the repository browser.