source: trunk/kBuild/tools/GCC3OMF.kmk@ 3048

Last change on this file since 3048 was 2776, checked in by bird, 10 years ago

GCC3OMF,GXX3OMF: Added RC compiler (most OS/2 systems have rc.exe installed).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.0 KB
Line 
1# $Id: GCC3OMF.kmk 2776 2015-02-03 20:38:12Z bird $
2## @file
3# kBuild Tool Config - GCC v3 targeting OS/2 OMF.
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_GCC3OMF := GCC v3 targeting OS/2 OMF.
35
36# Tool Specific Properties
37TOOL_GCC3OMF_CC ?= gcc$(HOSTSUFF_EXE)
38TOOL_GCC3OMF_CXX ?= g++$(HOSTSUFF_EXE)
39TOOL_GCC3OMF_AS ?= gcc$(HOSTSUFF_EXE)
40TOOL_GCC3OMF_AR ?= emxomfar$(HOSTSUFF_EXE)
41TOOL_GCC3OMF_AR_IMP ?= emximp$(HOSTSUFF_EXE)
42TOOL_GCC3OMF_LD ?= gcc$(HOSTSUFF_EXE)
43TOOL_GCC3OMF_LD_SYSMOD ?= gcc$(HOSTSUFF_EXE)
44ifndef TOOL_GCC3OMF_LDFLAGS.$(KBUILD_TARGET)
45TOOL_GCC3OMF_LDFLAGS.dll ?= -shared -Zdll
46else
47TOOL_GCC3OMF_LDFLAGS.dll ?= $(TOOL_GCC3OMF_LDFLAGS.$(KBUILD_TARGET))
48endif
49TOOL_GCC3OMF_LDFLAGS.sysmod ?= -nostdlib
50TOOL_GCC3OMF_LD_MAP ?= -Zmap=$(1)
51TOOL_GCC3OMF_LD_SYSMOD_MAP ?= -Zmap=$(1)
52TOOL_GCC3OMF_RC = rc$(HOSTSUFF_EXE)
53
54ifdef SLKRUNS
55TOOL_GCC3OMF_CC += -fmessage-length=0
56TOOL_GCC3OMF_CXX += -fmessage-length=0
57endif
58
59# General Properties used by kBuild
60TOOL_GCC3OMF_COBJSUFF ?= .o
61TOOL_GCC3OMF_CFLAGS ?= -Zomf
62TOOL_GCC3OMF_CFLAGS.debug ?= -g
63TOOL_GCC3OMF_CFLAGS.profile ?= -O2 #-g -pg
64TOOL_GCC3OMF_CFLAGS.release ?= -O2
65TOOL_GCC3OMF_CINCS ?=
66TOOL_GCC3OMF_CDEFS ?=
67
68TOOL_GCC3OMF_CXXOBJSUFF ?= .o
69TOOL_GCC3OMF_CXXOBJSUFF ?= .o
70TOOL_GCC3OMF_CXXFLAGS ?= -Zomf
71TOOL_GCC3OMF_CXXFLAGS.debug ?= -g
72TOOL_GCC3OMF_CXXFLAGS.profile ?= -O2 #-g -pg
73TOOL_GCC3OMF_CXXFLAGS.release ?= -O2
74TOOL_GCC3OMF_CXXINCS ?=
75TOOL_GCC3OMF_CXXDEFS ?=
76
77TOOL_GCC3OMF_ASFLAGS ?= -x assembler-with-cpp -Zomf
78TOOL_GCC3OMF_ASFLAGS.debug ?= -g
79TOOL_GCC3OMF_ASFLAGS.profile ?= -g
80TOOL_GCC3OMF_ASOBJSUFF ?= .obj
81
82TOOL_GCC3OMF_RCOBJSUFF ?= .res
83TOOL_GCC3OMF_RCFLAGS ?= -n
84TOOL_GCC3OMF_RCINCS ?= $(shell $(TOOL_GCC3OMF_CXX) -E -x c++ - 2>&1 < /dev/null \
85 | $(SED_EXT) -e "/search starts here/,/[Ee]nd of search list/!d" -e "/^ /!d")
86
87TOOL_GCC3OMF_ARFLAGS ?= cr
88TOOL_GCC3OMF_ARLIBSUFF ?= .lib
89
90TOOL_GCC3OMF_LDFLAGS ?= -Zomf
91TOOL_GCC3OMF_LDFLAGS.debug ?= -g
92TOOL_GCC3OMF_LDFLAGS.profile ?= -g
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_GCC3OMF_COMPILE_C_DEPEND =
109TOOL_GCC3OMF_COMPILE_C_DEPORD =
110ifdef KBUILD_USE_KOBJCACHE
111TOOL_GCC3OMF_COMPILE_C_USES_KOBJCACHE = 1
112TOOL_GCC3OMF_COMPILE_C_OUTPUT = $(outbase).i
113define TOOL_GCC3OMF_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_GCC3OMF_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_GCC3OMF_CC) -c\
122 $(flags) -fpreprocessed -x c\
123 -o $(obj)\
124 -
125 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
126endef
127else # !KBUILD_USE_KOBJCACHE
128TOOL_GCC3OMF_COMPILE_C_OUTPUT =
129define TOOL_GCC3OMF_COMPILE_C_CMDS
130 $(QUIET)$(TOOL_GCC3OMF_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#
151# @param $(outbase) Output basename (full). Use this for list files and such.
152# @param $(objsuff) Object suffix.
153TOOL_GCC3OMF_COMPILE_CXX_DEPEND =
154TOOL_GCC3OMF_COMPILE_CXX_DEPORD =
155ifdef KBUILD_USE_KOBJCACHE
156TOOL_GCC3OMF_COMPILE_CXX_USES_KOBJCACHE = 1
157TOOL_GCC3OMF_COMPILE_CXX_OUTPUT = $(outbase).ii
158define TOOL_GCC3OMF_COMPILE_CXX_CMDS
159 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
160 --kObjCache-cpp $(outbase).ii\
161 $(TOOL_GCC3OMF_CXX) -E -o -\
162 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
163 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
164 $(abspath $(source))\
165 --kObjCache-cc $(obj)\
166 $(TOOL_GCC3OMF_CXX) -c\
167 $(flags) -fpreprocessed -x c++\
168 -o $(obj)\
169 -
170 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
171endef
172else # !KBUILD_USE_KOBJCACHE
173TOOL_GCC3OMF_COMPILE_CXX_OUTPUT =
174define TOOL_GCC3OMF_COMPILE_CXX_CMDS
175 $(QUIET)$(TOOL_GCC3OMF_CXX) -c\
176 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
177 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP \
178 -o $(obj)\
179 $(abspath $(source))
180 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
181endef
182endif # !KBUILD_USE_KOBJCACHE
183
184
185## Compile Assembly source.
186# @param $(target) Normalized main target name.
187# @param $(source) Source filename (relative).
188# @param $(obj) Object file name. This shall be (re)created by the compilation.
189# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
190# @param $(flags) Flags.
191# @param $(defs) Definitions. No -D or something.
192# @param $(incs) Includes. No -I or something.
193# @param $(dirdep) Directory creation dependency.
194# @param $(deps) Other dependencies.
195# @param $(outbase) Output basename (full). Use this for list files and such.
196# @param $(objsuff) Object suffix.
197#
198TOOL_GCC3OMF_COMPILE_AS_OUTPUT =
199TOOL_GCC3OMF_COMPILE_AS_DEPEND =
200TOOL_GCC3OMF_COMPILE_AS_DEPORD =
201define TOOL_GCC3OMF_COMPILE_AS_CMDS
202 $(QUIET)$(TOOL_GCC3OMF_AS) -c\
203 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
204 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
205 -o $(obj)\
206 $(abspath $(source))
207 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
208endef
209
210
211## Compile resource source.
212# @param $(target) Normalized main target name.
213# @param $(source) Source filename (relative).
214# @param $(obj) Object file name. This shall be (re)created by the compilation.
215# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
216# @param $(flags) Flags.
217# @param $(defs) Definitions. No -D or something.
218# @param $(incs) Includes. No -I or something.
219# @param $(dirdep) Directory creation dependency.
220# @param $(deps) Other dependencies.
221#
222# @param $(outbase) Output basename (full). Use this for list files and such.
223# @param $(objsuff) Object suffix.
224TOOL_GCC3OMF_COMPILE_RC_OUTPUT =
225TOOL_GCC3OMF_COMPILE_RC_DEPEND =
226TOOL_GCC3OMF_COMPILE_RC_DEPORD =
227define TOOL_GCC3OMF_COMPILE_RC_CMDS
228 $(QUIET)$(REDIRECT) -E 'INCLUDE=' -- $(TOOL_GCC3OMF_RC) -r \
229 $(flags) $(addprefix -i, $(subst /,\\,$(subst /@unixroot,$(UNIXROOT),$(incs)))) $(addprefix -d, $(defs))\
230 $(subst /,\\,$(abspath $(source))) \
231 $(obj)
232endef
233## Link library
234# @param $(target) Normalized main target name.
235# @param $(out) Library name.
236# @param $(objs) Object files to put in the library.
237# @param $(flags) Flags.
238# @param $(dirdep) Directory creation dependency.
239# @param $(deps) Other dependencies.
240# @param $(othersrc) Unhandled sources.
241#
242# @param $(outbase) Output basename (full). Use this for list files and such.
243TOOL_GCC3OMF_LINK_LIBRARY_OUTPUT = $(outbase).rsp
244TOOL_GCC3OMF_LINK_LIBRARY_DEPEND = $(othersrc)
245TOOL_GCC3OMF_LINK_LIBRARY_DEPORD =
246define TOOL_GCC3OMF_LINK_LIBRARY_CMDS
247 $(if $(filter %.def %.imp %.dll,$(othersrc))\
248 ,$(QUIET)$(APPEND) -n $(outbase).rsp $(filter %.def %.imp %.dll,$(othersrc))\
249 $(NL)$(TAB)$(QUIET)$(QUIET)$(TOOL_GCC3OMF_AR_IMP) -o $(out) @$(outbase).rsp\
250 $(NL)$(TAB)$(QUIET)$(RM) -f $(outbase).rsp)
251 $(QUIET)$(APPEND) -n $(outbase).rsp $(flags) $(out) $(objs) $(filter-out %.def %.imp %.dll,$(othersrc))
252 $(QUIET)$(TOOL_GCC3OMF_AR) @$(outbase).rsp
253endef
254
255
256## Link program
257# @param $(target) Normalized main target name.
258# @param $(out) Program name.
259# @param $(objs) Object files to link together.
260# @param $(libs) Libraries to search.
261# @param $(libpath) Library search paths.
262# @param $(flags) Flags.
263# @param $(dirdep) Directory creation dependency.
264# @param $(deps) Other dependencies.
265# @param $(othersrc) Unhandled sources.
266# @param $(custom_pre) Custom step invoked before linking.
267# @param $(custom_post) Custom step invoked after linking.
268#
269# @param $(outbase) Output basename (full). Use this for list files and such.
270TOOL_GCC3OMF_LINK_PROGRAM_OUTPUT = $(outbase).map $(outbase).rsp
271TOOL_GCC3OMF_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
272TOOL_GCC3OMF_LINK_PROGRAM_DEPORD =
273define TOOL_GCC3OMF_LINK_PROGRAM_CMDS
274 $(QUIET)$(APPEND) -n $(outbase).rsp\
275 $(flags)\
276 -o $(out)\
277 $(objs)\
278 $(foreach p,$(libpath), -L$(p))\
279 $(othersrc)\
280 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
281 -Zmap=$(outbase).map
282 $(QUIET)$(TOOL_GCC3OMF_LD) @$(outbase).rsp
283endef
284
285
286## Link DLL
287# @param $(target) Normalized main target name.
288# @param $(out) Program name.
289# @param $(objs) Object files to link together.
290# @param $(libs) Libraries to search.
291# @param $(libpath) Library search paths.
292# @param $(flags) Flags.
293# @param $(dirdep) Directory creation dependency.
294# @param $(deps) Other dependencies.
295# @param $(othersrc) Unhandled sources.
296# @param $(custom_pre) Custom step invoked before linking.
297# @param $(custom_post) Custom step invoked after linking.
298#
299# @param $(outbase) Output basename (full). Use this for list files and such.
300TOOL_GCC3OMF_LINK_DLL_OUTPUT = $(outbase).map $(outbase).rsp
301TOOL_GCC3OMF_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
302TOOL_GCC3OMF_LINK_DLL_DEPORD =
303define TOOL_GCC3OMF_LINK_DLL_CMDS
304 $(QUIET)$(APPEND) -n $(outbase).rsp\
305 $(TOOL_GCC3OMF_LDFLAGS.dll)\
306 $(flags)\
307 -o $(out)\
308 $(objs)\
309 $(foreach p,$(libpath), -L$(p))\
310 $(othersrc)\
311 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
312 -Zmap=$(outbase).map
313 $(QUIET)$(TOOL_GCC3OMF_LD) @$(outbase).rsp
314endef
315
316
317## Link system module (windows aka driver, linux aka kernel module)
318# @param $(target) Normalized main target name.
319# @param $(out) System module name.
320# @param $(objs) Object files to link together.
321# @param $(libs) Libraries to search.
322# @param $(libpath) Library search paths.
323# @param $(flags) Flags.
324# @param $(dirdep) Directory creation dependency.
325# @param $(deps) Other dependencies.
326# @param $(othersrc) Unhandled sources.
327# @param $(custom_pre) Custom step invoked before linking.
328# @param $(custom_post) Custom step invoked after linking.
329#
330# @param $(outbase) Output basename (full). Use this for list files and such.
331TOOL_GCC3OMF_LINK_SYSMOD_OUTPUT = $(outbase).map $(outbase).rsp
332TOOL_GCC3OMF_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
333TOOL_GCC3OMF_LINK_SYSMOD_DEPORD =
334define TOOL_GCC3OMF_LINK_SYSMOD_CMDS
335 $(QUIET)$(APPEND) -n $(outbase).rsp\
336 $(TOOL_GCC3OMF_LDFLAGS.sysmod)\
337 $(flags)\
338 -o $(out)\
339 $(objs)\
340 $(foreach p,$(libpath), -L$(p))\
341 $(othersrc)\
342 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
343 -Zmap=$(outbase).map
344 $(QUIET)$(TOOL_GCC3OMF_LD_SYSMOD) @$(outbase).rsp
345endef
346
Note: See TracBrowser for help on using the repository browser.