source: trunk/kBuild/tools/GXX3OMF.kmk@ 3258

Last change on this file since 3258 was 3258, checked in by bird, 7 years ago

tools/*GXX*: Precompiled header and some kObjCache updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.9 KB
Line 
1# $Id: GXX3OMF.kmk 3258 2019-01-03 05:34:09Z bird $
2## @file
3# kBuild Tool Config - GCC v3 targeting OS/2 OMF, for building C++ code.
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_GXX3OMF := GCC v3 targeting OS/2 OMF, for building C++ code.
35
36# Tool Specific Properties
37TOOL_GXX3OMF_CC ?= gcc$(HOSTSUFF_EXE)
38TOOL_GXX3OMF_CXX ?= g++$(HOSTSUFF_EXE)
39TOOL_GXX3OMF_PCH ?= $(TOOL_GXX3OMF_CXX)
40TOOL_GXX3OMF_AS ?= gcc$(HOSTSUFF_EXE)
41TOOL_GXX3OMF_AR ?= emxomfar$(HOSTSUFF_EXE)
42TOOL_GXX3OMF_AR_IMP ?= emximp$(HOSTSUFF_EXE)
43TOOL_GXX3OMF_LD ?= g++$(HOSTSUFF_EXE)
44TOOL_GXX3OMF_LD_SYSMOD ?= g++$(HOSTSUFF_EXE)
45ifndef TOOL_GXX3OMF_LDFLAGS.$(KBUILD_TARGET)
46TOOL_GXX3OMF_LDFLAGS.dll ?= -shared -Zdll
47else
48TOOL_GXX3OMF_LDFLAGS.dll ?= $(TOOL_GXX3OMF_LDFLAGS.$(KBUILD_TARGET))
49endif
50TOOL_GXX3OMF_LDFLAGS.sysmod ?= -nostdlib
51TOOL_GXX3OMF_LD_MAP ?= -Zmap=$(1)
52TOOL_GXX3OMF_LD_SYSMOD_MAP ?= -Zmap=$(1)
53TOOL_GXX3OMF_RC = rc$(HOSTSUFF_EXE)
54
55ifdef SLKRUNS
56TOOL_GXX3OMF_CC += -fmessage-length=0
57TOOL_GXX3OMF_CXX += -fmessage-length=0
58endif
59
60# General Properties used by kBuild
61TOOL_GXX3OMF_COBJSUFF ?= .o
62TOOL_GXX3OMF_CFLAGS ?= -Zomf
63TOOL_GXX3OMF_CFLAGS.debug ?= -g
64TOOL_GXX3OMF_CFLAGS.profile ?= -O2 #-g -pg
65TOOL_GXX3OMF_CFLAGS.release ?= -O2
66TOOL_GXX3OMF_CINCS ?=
67TOOL_GXX3OMF_CDEFS ?=
68
69TOOL_GXX3OMF_CXXOBJSUFF ?= .o
70TOOL_GXX3OMF_CXXFLAGS ?= -Zomf
71TOOL_GXX3OMF_CXXFLAGS.debug ?= -g
72TOOL_GXX3OMF_CXXFLAGS.profile ?= -O2 #-g -pg
73TOOL_GXX3OMF_CXXFLAGS.release ?= -O2
74TOOL_GXX3OMF_CXXINCS ?=
75TOOL_GXX3OMF_CXXDEFS ?=
76
77TOOL_GXX3OMF_PCHOBJSUFF ?= .h.gch
78TOOL_GXX3OMF_PCHFLAGS ?= $(TOOL_GXX3OMF_CXXFLAGS)
79TOOL_GXX3OMF_PCHFLAGS.debug ?= $(TOOL_GXX3OMF_CXXFLAGS.debug)
80TOOL_GXX3OMF_PCHFLAGS.profile ?= $(TOOL_GXX3OMF_CXXFLAGS.profile)
81TOOL_GXX3OMF_PCHFLAGS.release ?= $(TOOL_GXX3OMF_CXXFLAGS.release)
82TOOL_GXX3OMF_PCHINCS ?= $(TOOL_GXX3OMF_CXXINCS)
83TOOL_GXX3OMF_PCHDEFS ?= $(TOOL_GXX3OMF_CXXDEFS)
84
85TOOL_GXX3OMF_ASFLAGS ?= -x assembler-with-cpp -Zomf
86TOOL_GXX3OMF_ASFLAGS.debug ?= -g
87TOOL_GXX3OMF_ASFLAGS.profile ?= -g
88TOOL_GXX3OMF_ASOBJSUFF ?= .obj
89
90TOOL_GXX3OMF_RCOBJSUFF ?= .res
91TOOL_GXX3OMF_RCFLAGS ?= -n
92TOOL_GXX3OMF_RCINCS ?= $(shell $(TOOL_GXX3OMF_CXX) -E -x c++ - 2>&1 < /dev/null \
93 | $(SED_EXT) -e "/search starts here/,/[Ee]nd of search list/!d" -e "/^ /!d")
94
95TOOL_GXX3OMF_ARFLAGS ?= cr
96TOOL_GXX3OMF_ARLIBSUFF ?= .lib
97
98TOOL_GXX3OMF_LDFLAGS ?= -Zomf
99TOOL_GXX3OMF_LDFLAGS.debug ?= -g
100TOOL_GXX3OMF_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_GXX3OMF_COMPILE_C_DEPEND =
117TOOL_GXX3OMF_COMPILE_C_DEPORD =
118TOOL_GXX3OMF_COMPILE_C_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
119TOOL_GXX3OMF_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
120define TOOL_GXX3OMF_COMPILE_C_CMDS
121if "$(use_objcache)" != ""
122 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
123 --kObjCache-cpp $(outbase).i\
124 $(TOOL_GXX3OMF_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_GXX3OMF_CC) -c\
130 $(flags) -fpreprocessed -x c\
131 -o $(obj)\
132 -
133else
134 $(QUIET)$(TOOL_GXX3OMF_CC) -c\
135 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
136 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
137 -o $(obj)\
138 $(abspath $(source))
139endif
140 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
141endef
142
143
144## Compile C++ source.
145# @param $(target) Normalized main target name.
146# @param $(source) Source filename (relative).
147# @param $(obj) Object file name. This shall be (re)created by the compilation.
148# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
149# @param $(flags) Flags.
150# @param $(defs) Definitions. No -D or something.
151# @param $(incs) Includes. No -I or something.
152# @param $(dirdep) Directory creation dependency.
153# @param $(deps) Other dependencies.
154# @param $(outbase) Output basename (full). Use this for list files and such.
155# @param $(objsuff) Object suffix.
156TOOL_GXX3OMF_COMPILE_CXX_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
157TOOL_GXX3OMF_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
158TOOL_GXX3OMF_COMPILE_CXX_DEPORD =
159TOOL_GXX3OMF_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
160define TOOL_GXX3OMF_COMPILE_CXX_CMDS
161if "$(use_objcache)" != ""
162 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
163 --kObjCache-cpp $(outbase).ii\
164 $(TOOL_GXX3OMF_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
165 ,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
166 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
167 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
168 $(abspath $(source))\
169 --kObjCache-cc $(obj)\
170 $(TOOL_GXX3OMF_CXX) -c\
171 $(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
172 -o $(obj)\
173 -
174else
175 $(QUIET)$(TOOL_GXX3OMF_CXX) -c\
176 $(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
177 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
178 -o $(obj) $(if-expr defined($(target)_PCH_HDR) \
179 ,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
180 $(abspath $(source))
181endif
182 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
183endef
184
185
186## Precompile C++ header.
187# @param $(target) Normalized main target name.
188# @param $(source) Source filename (relative).
189# @param $(obj) Object file name. This shall be (re)created by the compilation.
190# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
191# @param $(flags) Flags.
192# @param $(defs) Definitions. No -D or something.
193# @param $(incs) Includes. No -I or something.
194# @param $(dirdep) Directory creation dependency.
195# @param $(deps) Other dependencies.
196# @param $(outbase) Output basename (full). Use this for list files and such.
197# @param $(objsuff) Object suffix.
198TOOL_GXX3OMF_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
199TOOL_GXX3OMF_COMPILE_PCH_DEPEND =
200TOOL_GXX3OMF_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
201define TOOL_GXX3OMF_COMPILE_PCH_CMDS
202 $(QUIET)$(TOOL_GXX3OMF_PCH) -c\
203 $(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
204 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
205 -o $(obj)\
206 $(abspath $(source))
207 $(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
208 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
209endef
210
211
212## Compile Assembly source.
213# @param $(target) Normalized main target name.
214# @param $(source) Source filename (relative).
215# @param $(obj) Object file name. This shall be (re)created by the compilation.
216# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
217# @param $(flags) Flags.
218# @param $(defs) Definitions. No -D or something.
219# @param $(incs) Includes. No -I or something.
220# @param $(dirdep) Directory creation dependency.
221# @param $(deps) Other dependencies.
222# @param $(outbase) Output basename (full). Use this for list files and such.
223# @param $(objsuff) Object suffix.
224#
225TOOL_GXX3OMF_COMPILE_AS_OUTPUT =
226TOOL_GXX3OMF_COMPILE_AS_DEPEND =
227TOOL_GXX3OMF_COMPILE_AS_DEPORD =
228define TOOL_GXX3OMF_COMPILE_AS_CMDS
229 $(QUIET)$(TOOL_GXX3OMF_AS) -c\
230 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
231 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
232 -o $(obj)\
233 $(abspath $(source))
234 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
235endef
236
237
238## Compile resource source.
239# @param $(target) Normalized main target name.
240# @param $(source) Source filename (relative).
241# @param $(obj) Object file name. This shall be (re)created by the compilation.
242# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
243# @param $(flags) Flags.
244# @param $(defs) Definitions. No -D or something.
245# @param $(incs) Includes. No -I or something.
246# @param $(dirdep) Directory creation dependency.
247# @param $(deps) Other dependencies.
248#
249# @param $(outbase) Output basename (full). Use this for list files and such.
250# @param $(objsuff) Object suffix.
251TOOL_GXX3OMF_COMPILE_RC_OUTPUT =
252TOOL_GXX3OMF_COMPILE_RC_DEPEND =
253TOOL_GXX3OMF_COMPILE_RC_DEPORD =
254define TOOL_GXX3OMF_COMPILE_RC_CMDS
255 $(QUIET)$(REDIRECT) -E 'INCLUDE=' -- $(TOOL_GXX3OMF_RC) -r \
256 $(flags) $(addprefix -i, $(subst /,\\,$(subst /@unixroot,$(UNIXROOT),$(incs)))) $(addprefix -d, $(defs))\
257 $(subst /,\\,$(abspath $(source))) \
258 $(obj)
259endef
260
261
262## Link library
263# @param $(target) Normalized main target name.
264# @param $(out) Library name.
265# @param $(objs) Object files to put in the library.
266# @param $(flags) Flags.
267# @param $(dirdep) Directory creation dependency.
268# @param $(deps) Other dependencies.
269# @param $(othersrc) Unhandled sources.
270#
271# @param $(outbase) Output basename (full). Use this for list files and such.
272TOOL_GXX3OMF_LINK_LIBRARY_OUTPUT = $(outbase).rsp
273TOOL_GXX3OMF_LINK_LIBRARY_DEPEND = $(othersrc)
274TOOL_GXX3OMF_LINK_LIBRARY_DEPORD =
275define TOOL_GXX3OMF_LINK_LIBRARY_CMDS
276 $(if $(filter %.def %.imp %.dll,$(othersrc))\
277 ,$(QUIET)$(APPEND) -n $(outbase).rsp $(filter %.def %.imp %.dll,$(othersrc))\
278 $(NL)$(TAB)$(QUIET)$(QUIET)$(TOOL_GXX3OMF_AR_IMP) -o $(out) @$(outbase).rsp\
279 $(NL)$(TAB)$(QUIET)$(RM) -f $(outbase).rsp)
280 $(QUIET)$(APPEND) -n $(outbase).rsp $(flags) $(out) $(filter-out %.h.gch,$(objs)) $(filter-out %.def %.imp %.dll,$(othersrc))
281 $(QUIET)$(TOOL_GXX3OMF_AR) @$(outbase).rsp
282endef
283
284
285## Link program
286# @param $(target) Normalized main target name.
287# @param $(out) Program name.
288# @param $(objs) Object files to link together.
289# @param $(libs) Libraries to search.
290# @param $(libpath) Library search paths.
291# @param $(flags) Flags.
292# @param $(dirdep) Directory creation dependency.
293# @param $(deps) Other dependencies.
294# @param $(othersrc) Unhandled sources.
295# @param $(custom_pre) Custom step invoked before linking.
296# @param $(custom_post) Custom step invoked after linking.
297#
298# @param $(outbase) Output basename (full). Use this for list files and such.
299TOOL_GXX3OMF_LINK_PROGRAM_OUTPUT = $(outbase).map $(outbase).rsp
300TOOL_GXX3OMF_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
301TOOL_GXX3OMF_LINK_PROGRAM_DEPORD =
302define TOOL_GXX3OMF_LINK_PROGRAM_CMDS
303 $(QUIET)$(APPEND) -n $(outbase).rsp\
304 $(flags)\
305 -o $(out)\
306 $(filter-out %.h.gch,$(objs))\
307 $(foreach p,$(libpath), -L$(p))\
308 $(othersrc)\
309 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
310 -Zmap=$(outbase).map
311 $(QUIET)$(TOOL_GXX3OMF_LD) @$(outbase).rsp
312endef
313
314
315## Link DLL
316# @param $(target) Normalized main target name.
317# @param $(out) Program name.
318# @param $(objs) Object files to link together.
319# @param $(libs) Libraries to search.
320# @param $(libpath) Library search paths.
321# @param $(flags) Flags.
322# @param $(dirdep) Directory creation dependency.
323# @param $(deps) Other dependencies.
324# @param $(othersrc) Unhandled sources.
325# @param $(custom_pre) Custom step invoked before linking.
326# @param $(custom_post) Custom step invoked after linking.
327#
328# @param $(outbase) Output basename (full). Use this for list files and such.
329TOOL_GXX3OMF_LINK_DLL_OUTPUT = $(outbase).map $(outbase).rsp
330TOOL_GXX3OMF_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
331TOOL_GXX3OMF_LINK_DLL_DEPORD =
332define TOOL_GXX3OMF_LINK_DLL_CMDS
333 $(QUIET)$(APPEND) -n $(outbase).rsp\
334 $(TOOL_GXX3OMF_LDFLAGS.dll)\
335 $(flags)\
336 -o $(out)\
337 $(filter-out %.h.gch,$(objs))\
338 $(foreach p,$(libpath), -L$(p))\
339 $(othersrc)\
340 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
341 -Zmap=$(outbase).map
342 $(QUIET)$(TOOL_GXX3OMF_LD) @$(outbase).rsp
343endef
344
345
346## Link system module (windows aka driver, linux aka kernel module)
347# @param $(target) Normalized main target name.
348# @param $(out) System module name.
349# @param $(objs) Object files to link together.
350# @param $(libs) Libraries to search.
351# @param $(libpath) Library search paths.
352# @param $(flags) Flags.
353# @param $(dirdep) Directory creation dependency.
354# @param $(deps) Other dependencies.
355# @param $(othersrc) Unhandled sources.
356# @param $(custom_pre) Custom step invoked before linking.
357# @param $(custom_post) Custom step invoked after linking.
358#
359# @param $(outbase) Output basename (full). Use this for list files and such.
360TOOL_GXX3OMF_LINK_SYSMOD_OUTPUT = $(outbase).map $(outbase).rsp
361TOOL_GXX3OMF_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
362TOOL_GXX3OMF_LINK_SYSMOD_DEPORD =
363define TOOL_GXX3OMF_LINK_SYSMOD_CMDS
364 $(QUIET)$(APPEND) -n $(outbase).rsp\
365 $(TOOL_GXX3OMF_LDFLAGS.sysmod)\
366 $(flags)\
367 -o $(out)\
368 $(filter-out %.h.gch,$(objs))\
369 $(foreach p,$(libpath), -L$(p))\
370 $(othersrc)\
371 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
372 -Zmap=$(outbase).map
373 $(QUIET)$(TOOL_GXX3OMF_LD_SYSMOD) @$(outbase).rsp
374endef
375
Note: See TracBrowser for help on using the repository browser.