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

Last change on this file since 3036 was 2775, checked in by bird, 10 years ago

tools/G*.kmk: The OS/2 librarian can convert .dll into import libraries, so pass .dll source files to it alongside .imp and .def files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.5 KB
Line 
1# $Id: GXX32.kmk 2775 2015-02-03 20:00:15Z bird $
2## @file
3# kBuild Tool Config - Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code.
4#
5
6#
7# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@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_GXX32 := Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code. \
35 More or less Linux/ELF specfic.
36
37# Tool Specific Properties
38TOOL_GXX32_CC ?= gcc$(HOSTSUFF_EXE) -m32
39TOOL_GXX32_CXX ?= g++$(HOSTSUFF_EXE) -m32
40TOOL_GXX32_AS ?= gcc$(HOSTSUFF_EXE) -m32
41TOOL_GXX32_AR ?= ar$(HOSTSUFF_EXE)
42TOOL_GXX32_LD ?= g++$(HOSTSUFF_EXE) -m32
43TOOL_GXX32_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
44ifndef TOOL_GXX32_LDFLAGS.$(KBUILD_TARGET)
45TOOL_GXX32_LDFLAGS.dll ?= -shared
46else
47TOOL_GXX32_LDFLAGS.dll ?= $(TOOL_GXX32_LDFLAGS.$(KBUILD_TARGET))
48endif
49TOOL_GXX32_LDFLAGS.sysmod ?= -r -m elf_i386$(if-expr "$(KBUILD_TARGET)" == "freebsd",_fbsd,)
50TOOL_GXX32_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
51ifeq ($(KBUILD_TARGET),os2)
52TOOL_GXX32_LD_MAP ?= -Zmap=$(1)
53else
54TOOL_GXX32_LD_MAP ?=
55endif
56ifeq ($(KBUILD_TARGET),os2)
57TOOL_GXX32_LD_SYSMOD_MAP ?= -Zmap=$(1)
58else
59TOOL_GXX32_LD_SYSMOD_MAP ?=
60endif
61if1of ($(KBUILD_HOST), solaris)
62 TOOL_GXX32_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE)
63else
64 TOOL_GXX32_OBJCOPY ?= objcopy$(HOSTSUFF_EXE)
65endif
66
67ifdef SLKRUNS
68 TOOL_GXX32_CC += -fmessage-length=0
69 TOOL_GXX32_CXX += -fmessage-length=0
70endif
71
72# General Properties used by kBuild
73TOOL_GXX32_COBJSUFF ?= .o
74TOOL_GXX32_CFLAGS ?=
75TOOL_GXX32_CFLAGS.debug ?= -g
76TOOL_GXX32_CFLAGS.profile ?= -O2 #-g -pg
77TOOL_GXX32_CFLAGS.release ?= -O2
78TOOL_GXX32_CINCS ?=
79TOOL_GXX32_CDEFS ?=
80
81TOOL_GXX32_CXXOBJSUFF ?= .o
82TOOL_GXX32_CXXOBJSUFF ?= .o
83TOOL_GXX32_CXXFLAGS ?=
84TOOL_GXX32_CXXFLAGS.debug ?= -g
85TOOL_GXX32_CXXFLAGS.profile ?= -O2 #-g -pg
86TOOL_GXX32_CXXFLAGS.release ?= -O2
87TOOL_GXX32_CXXINCS ?=
88TOOL_GXX32_CXXDEFS ?=
89
90TOOL_GXX32_ASFLAGS ?= -x assembler-with-cpp
91TOOL_GXX32_ASFLAGS.debug ?= -g
92TOOL_GXX32_ASFLAGS.profile ?= -g
93TOOL_GXX32_ASOBJSUFF ?= .o
94
95TOOL_GXX32_ARFLAGS ?= cr
96TOOL_GXX32_ARLIBSUFF ?= .a
97
98TOOL_GXX32_LDFLAGS ?=
99TOOL_GXX32_LDFLAGS.debug ?= -g
100TOOL_GXX32_LDFLAGS.profile ?= -g
101
102
103## Compile C source.
104# @param $(target) Normalized main target name.
105# @param $(source) Source filename (relative).
106# @param $(obj) Object file name. This shall be (re)created by the compilation.
107# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
108# @param $(flags) Flags.
109# @param $(defs) Definitions. No -D or something.
110# @param $(incs) Includes. No -I or something.
111# @param $(dirdep) Directory creation dependency.
112# @param $(deps) Other dependencies.
113#
114# @param $(outbase) Output basename (full). Use this for list files and such.
115# @param $(objsuff) Object suffix.
116TOOL_GXX32_COMPILE_C_DEPEND =
117TOOL_GXX32_COMPILE_C_DEPORD =
118ifdef KBUILD_USE_KOBJCACHE
119TOOL_GXX32_COMPILE_C_USES_KOBJCACHE = 1
120TOOL_GXX32_COMPILE_C_OUTPUT = $(outbase).i
121define TOOL_GXX32_COMPILE_C_CMDS
122 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
123 --kObjCache-cpp $(outbase).i\
124 $(TOOL_GXX32_CC) -E -o -\
125 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
126 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
127 $(abspath $(source))\
128 --kObjCache-cc $(obj)\
129 $(TOOL_GXX32_CC) -c\
130 $(flags) -fpreprocessed -x c\
131 -o $(obj)\
132 -
133 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
134endef
135else # !KBUILD_USE_KOBJCACHE
136TOOL_GXX32_COMPILE_C_OUTPUT =
137define TOOL_GXX32_COMPILE_C_CMDS
138 $(QUIET)$(TOOL_GXX32_CC) -c\
139 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
140 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
141 -o $(obj)\
142 $(abspath $(source))
143 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
144endef
145endif # !KBUILD_USE_KOBJCACHE
146
147
148## Compile C++ source.
149# @param $(target) Normalized main target name.
150# @param $(source) Source filename (relative).
151# @param $(obj) Object file name. This shall be (re)created by the compilation.
152# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
153# @param $(flags) Flags.
154# @param $(defs) Definitions. No -D or something.
155# @param $(incs) Includes. No -I or something.
156# @param $(dirdep) Directory creation dependency.
157# @param $(deps) Other dependencies.
158# @param $(outbase) Output basename (full). Use this for list files and such.
159# @param $(objsuff) Object suffix.
160TOOL_GXX32_COMPILE_CXX_DEPEND =
161TOOL_GXX32_COMPILE_CXX_DEPORD =
162ifdef KBUILD_USE_KOBJCACHE
163TOOL_GXX32_COMPILE_CXX_USES_KOBJCACHE = 1
164TOOL_GXX32_COMPILE_CXX_OUTPUT = $(outbase).ii
165define TOOL_GXX32_COMPILE_CXX_CMDS
166 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
167 --kObjCache-cpp $(outbase).ii\
168 $(TOOL_GXX32_CXX) -E -o -\
169 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
170 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
171 $(abspath $(source))\
172 --kObjCache-cc $(obj)\
173 $(TOOL_GXX32_CXX) -c\
174 $(flags) -fpreprocessed -x c++\
175 -o $(obj)\
176 -
177 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
178endef
179else # !KBUILD_USE_KOBJCACHE
180TOOL_GXX32_COMPILE_CXX_OUTPUT =
181define TOOL_GXX32_COMPILE_CXX_CMDS
182 $(QUIET)$(TOOL_GXX32_CXX) -c\
183 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
184 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
185 -o $(obj)\
186 $(abspath $(source))
187 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
188endef
189endif # !KBUILD_USE_KOBJCACHE
190
191
192## Compile Assembly source.
193# @param $(target) Normalized main target name.
194# @param $(source) Source filename (relative).
195# @param $(obj) Object file name. This shall be (re)created by the compilation.
196# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
197# @param $(flags) Flags.
198# @param $(defs) Definitions. No -D or something.
199# @param $(incs) Includes. No -I or something.
200# @param $(dirdep) Directory creation dependency.
201# @param $(deps) Other dependencies.
202# @param $(outbase) Output basename (full). Use this for list files and such.
203# @param $(objsuff) Object suffix.
204#
205TOOL_GXX32_COMPILE_AS_OUTPUT =
206TOOL_GXX32_COMPILE_AS_DEPEND =
207TOOL_GXX32_COMPILE_AS_DEPORD =
208define TOOL_GXX32_COMPILE_AS_CMDS
209 $(QUIET)$(TOOL_GXX32_AS) -c\
210 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
211 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
212 -o $(obj)\
213 $(abspath $(source))
214 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
215endef
216
217
218## Link library
219# @param $(target) Normalized main target name.
220# @param $(out) Library name.
221# @param $(objs) Object files to put in the library.
222# @param $(flags) Flags.
223# @param $(dirdep) Directory creation dependency.
224# @param $(deps) Other dependencies.
225# @param $(othersrc) Unhandled sources.
226# @param $(outbase) Output basename (full). Use this for list files and such.
227TOOL_GXX32_LINK_LIBRARY_OUTPUT = $(out).ar-script
228TOOL_GXX32_LINK_LIBRARY_DEPEND = $(othersrc)
229TOOL_GXX32_LINK_LIBRARY_DEPORD =
230define TOOL_GXX32_LINK_LIBRARY_CMDS
231 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
232 $(QUIET)$(APPEND) -n $(out).ar-script \
233 $(foreach o,$(objs), 'ADDMOD $(o)') \
234 $(foreach o,$(filter-out %.def %.imp %.dll,$(othersrc)), 'ADDLIB $(o)')
235 $(if $(filter %.def %.imp %.dll,$(othersrc))\
236 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
237 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
238 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
239 $(QUIET)$(APPEND) $(out).ar-script 'END'
240 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX32_AR) -M
241endef
242
243
244## Link program
245# @param $(target) Normalized main target name.
246# @param $(out) Program name.
247# @param $(objs) Object files to link together.
248# @param $(libs) Libraries to search.
249# @param $(libpath) Library search paths.
250# @param $(flags) Flags.
251# @param $(dirdep) Directory creation dependency.
252# @param $(deps) Other dependencies.
253# @param $(othersrc) Unhandled sources.
254# @param $(custom_pre) Custom step invoked before linking.
255# @param $(custom_post) Custom step invoked after linking.
256# @param $(outbase) Output basename (full). Use this for list files and such.
257TOOL_GXX32_LINK_PROGRAM_OUTPUT =
258TOOL_GXX32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
259TOOL_GXX32_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
260TOOL_GXX32_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
261TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
262 $(filter %.def, $(othersrc))
263TOOL_GXX32_LINK_PROGRAM_DEPORD =
264define TOOL_GXX32_LINK_PROGRAM_CMDS
265 $(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\
266 $(foreach p,$(libpath), -L$(p))\
267 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
268 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
269 ifeq ($(ld_debug),split)
270 $(QUIET)$(TOOL_GXX32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
271 $(QUIET)$(CHMOD) a-x $(outbase).debug
272 $(QUIET)$(TOOL_GXX32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
273 endif
274endef
275
276
277## Link DLL
278# @param $(target) Normalized main target name.
279# @param $(out) Program name.
280# @param $(objs) Object files to link together.
281# @param $(libs) Libraries to search.
282# @param $(libpath) Library search paths.
283# @param $(flags) Flags.
284# @param $(dirdep) Directory creation dependency.
285# @param $(deps) Other dependencies.
286# @param $(othersrc) Unhandled sources.
287# @param $(custom_pre) Custom step invoked before linking.
288# @param $(custom_post) Custom step invoked after linking.
289# @param $(outbase) Output basename (full). Use this for list files and such.
290TOOL_GXX32_LINK_DLL_OUTPUT =
291TOOL_GXX32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
292TOOL_GXX32_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
293TOOL_GXX32_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
294TOOL_GXX32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
295 $(filter %.def, $(othersrc))
296TOOL_GXX32_LINK_DLL_DEPORD =
297define TOOL_GXX32_LINK_DLL_CMDS
298 $(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\
299 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX32_LD_SONAME,$(target),$(out)))\
300 $(objs)\
301 $(foreach p,$(libpath), -L$(p))\
302 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
303 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
304 ifeq ($(ld_debug),split)
305 $(QUIET)$(TOOL_GXX32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
306 $(QUIET)$(CHMOD) a-x $(outbase).debug
307 $(QUIET)$(TOOL_GXX32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
308 endif
309endef
310
311
312## Link system module (windows aka driver, linux aka kernel module)
313# @param $(target) Normalized main target name.
314# @param $(out) System module name.
315# @param $(objs) Object files to link together.
316# @param $(libs) Libraries to search.
317# @param $(libpath) Library search paths.
318# @param $(flags) Flags.
319# @param $(dirdep) Directory creation dependency.
320# @param $(deps) Other dependencies.
321# @param $(othersrc) Unhandled sources.
322# @param $(custom_pre) Custom step invoked before linking.
323# @param $(custom_post) Custom step invoked after linking.
324# @param $(outbase) Output basename (full). Use this for list files and such.
325TOOL_GXX32_LINK_SYSMOD_OUTPUT =
326TOOL_GXX32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
327TOOL_GXX32_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
328TOOL_GXX32_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
329TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
330 $(filter %.def, $(othersrc))
331TOOL_GXX32_LINK_SYSMOD_DEPORD =
332define TOOL_GXX32_LINK_SYSMOD_CMDS
333 $(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
334 $(filter %.def, $(othersrc))\
335 $(foreach p,$(libpath), -L$(p))\
336 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
337 $(call TOOL_GXX32_LD_SYSMOD_MAP,$(outbase).map)
338 ifeq ($(ld_debug),split)
339 $(QUIET)$(TOOL_GXX32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
340 $(QUIET)$(CHMOD) a-x $(outbase).debug
341 $(QUIET)$(TOOL_GXX32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
342 endif
343endef
344
Note: See TracBrowser for help on using the repository browser.