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

Last change on this file since 337 was 337, checked in by bird, 20 years ago

Added -Wp,-MP for better dependencies.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 KB
Line 
1# $Id: GCC3OMF.kmk 337 2005-11-07 16:15:35Z bird $
2## @file
3#
4# kBuild Tool Config - OS/2 GCC v3 OMF.
5#
6# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@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_GCC3OMF := OS/2 GCC v3 OMF
28
29TOOL_GCC3OMF_CC := gcc$(HOSTSUFF_EXE)
30TOOL_GCC3OMF_COBJSUFF := .o
31TOOL_GCC3OMF_CFLAGS := -g -Zomf
32TOOL_GCC3OMF_CFLAGS.debug := -O0
33TOOL_GCC3OMF_CFLAGS.release := -O2
34TOOL_GCC3OMF_CFLAGS.profile := -O2 #-pg
35TOOL_GCC3OMF_CINCS :=
36TOOL_GCC3OMF_CDEFS :=
37
38TOOL_GCC3OMF_CXX := g++$(HOSTSUFF_EXE)
39TOOL_GCC3OMF_CXXOBJSUFF := .o
40TOOL_GCC3OMF_CXXOBJSUFF := .o
41TOOL_GCC3OMF_CXXFLAGS := -g -Zomf
42TOOL_GCC3OMF_CXXFLAGS.debug := -O0
43TOOL_GCC3OMF_CXXFLAGS.release := -O2
44TOOL_GCC3OMF_CXXFLAGS.profile := -O2 #-pg
45TOOL_GCC3OMF_CXXINCS :=
46TOOL_GCC3OMF_CXXDEFS :=
47
48TOOL_GCC3OMF_AS := emxomfas$(HOSTSUFF_EXE)
49TOOL_GCC3OMF_ASOBJSUFF := .obj
50
51TOOL_GCC3OMF_AR := emxomfar$(HOSTSUFF_EXE)
52TOOL_GCC3OMF_ARFLAGS := cr
53TOOL_GCC3OMF_ARLIBSUFF := .lib
54TOOL_GCC3OMF_AR_IMP := emximp$(HOSTSUFF_EXE)
55
56TOOL_GCC3OMF_LD := g++$(HOSTSUFF_EXE)
57TOOL_GCC3OMF_LD_SYSMOD := emxomfld$(HOSTSUFF_EXE)
58TOOL_GCC3OMF_LDFLAGS := -Zomf
59TOOL_GCC3OMF_LDFLAGS.debug := -g
60TOOL_GCC3OMF_LDFLAGS.release := -s
61ifndef TOOL_GCC3OMF_LDFLAGS.$(BUILD_TARGET)
62TOOL_GCC3OMF_LDFLAGS.dll := -shared -Zdll
63else
64TOOL_GCC3OMF_LDFLAGS.dll := $(TOOL_GCC3OMF_LDFLAGS.$(BUILD_TARGET))
65endif
66TOOL_GCC3OMF_LDFLAGS.sysmod := -r
67TOOL_GCC3OMF_LD_MAP = -Zmap=$(1)
68TOOL_GCC3OMF_LD_SYSMOD_MAP = -Zmap=$(1)
69
70ifdef SLKRUNS
71TOOL_GCC3OMF_CC += -fmessage-length=0
72TOOL_GCC3OMF_CXX += -fmessage-length=0
73endif
74
75
76## Compile C source.
77# @param $(target) Normalized main target name.
78# @param $(source) Source filename (relative).
79# @param $(obj) Object file name. This shall be (re)created by the compilation.
80# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
81# @param $(flags) Flags.
82# @param $(defs) Definitions. No -D or something.
83# @param $(incs) Includes. No -I or something.
84# @param $(dirdep) Directory creation dependency.
85# @param $(deps) Other dependencies.
86#
87# @param $(outbase) Output basename (full). Use this for list files and such.
88# @param $(objsuff) Object suffix.
89define TOOL_GCC3OMF_COMPILE_C
90#$ (warning dbg: TOOL_GCC3OMF_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
91$(obj): $(deps) $(source) | $(dirdep)
92 $(call MSG_L2,Compiling $$@ using GCC3)
93 $(TOOL_GCC3OMF_CC) -c\
94 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
95 -Wp,-MD,$(dep) -Wp,-MT,$$@ -Wp,-MP \
96 -o $$@\
97 $(call ABSPATH,$(source))
98
99endef
100
101
102## Compile C++ source.
103# @param $(target) Normalized main target name.
104# @param $(source) Source filename (relative).
105# @param $(obj) Object file name. This shall be (re)created by the compilation.
106# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
107# @param $(flags) Flags.
108# @param $(defs) Definitions. No -D or something.
109# @param $(incs) Includes. No -I or something.
110# @param $(dirdep) Directory creation dependency.
111# @param $(deps) Other dependencies.
112#
113# @param $(outbase) Output basename (full). Use this for list files and such.
114# @param $(objsuff) Object suffix.
115define TOOL_GCC3OMF_COMPILE_CXX
116#$ (warning dbg: TOOL_GCC3OMF_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
117$(obj): $(deps) $(source) | $(dirdep)
118 $(call MSG_L2,Compiling $$@ using GCC3)
119 $(TOOL_GCC3OMF_CXX) -c\
120 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
121 -Wp,-MD,$(dep) -Wp,-MT,$$@ -Wp,-MP \
122 -o $$@\
123 $(call ABSPATH,$(source))
124
125endef
126
127
128## Link library
129# @param $(target) Normalized main target name.
130# @param $(lib) Library name.
131# @param $(objs) Object files to put in the library.
132# @param $(flags) Flags.
133# @param $(dirdep) Directory creation dependency.
134# @param $(deps) Other dependencies.
135# @param $(othersrc) Unhandled sources.
136#
137# @param $(outbase) Output basename (full). Use this for list files and such.
138define TOOL_GCC3OMF_LINK_LIBRARY
139#$ (warning dbg: TOOL_GCC3OMF_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
140$(lib): $(deps) $(objs) $(filter %.a %.lib %.def %.imp,$(othersrc)) | $(dirdep)
141 $(call MSG_L1,Creating Library $$@)
142 $(RM) -f $$@
143 $(if $(filter %.def %.imp,$(othersrc)),$(TOOL_GCC3OMF_AR_IMP) -o $$@ $(filter %.def %.imp,$(othersrc)),)
144 $(TOOL_GCC3OMF_AR) $(flags) $$@ $(objs) $(filter %.a %.lib,$(othersrc))
145
146endef
147
148
149## Link program
150# @param $(target) Normalized main target name.
151# @param $(exe) Program name.
152# @param $(objs) Object files to link together.
153# @param $(libs) Libraries to search.
154# @param $(libpath) Library search paths.
155# @param $(flags) Flags.
156# @param $(dirdep) Directory creation dependency.
157# @param $(deps) Other dependencies.
158# @param $(othersrc) Unhandled sources.
159# @param $(custom_pre) Custom step invoked before linking.
160# @param $(custom_post) Custom step invoked after linking.
161#
162# @param $(outbase) Output basename (full). Use this for list files and such.
163define TOOL_GCC3OMF_LINK_PROGRAM
164#$ (warning dbg: TOOL_GCC3OMF_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
165$(exe): $(deps) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(filter %.def, $(othersrc)) | $(dirdep)
166 $(call MSG_L1,Creating Program $$@)
167ifneq ($(custom_pre),)
168 $(eval $(custom_pre))
169endif
170 $(TOOL_GCC3OMF_LD) $(flags) -o $$@ $(objs) \
171 $(filter %.def, $(othersrc)) \
172 $(foreach p,$(libpath), -L$(p)) \
173 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib))) \
174 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
175ifneq ($(custom_post),)
176 $(eval $(custom_post))
177endif
178_OUT_FILES += $(outbase).map
179
180endef
181
182
183## Link DLL
184# @param $(target) Normalized main target name.
185# @param $(dll) Program name.
186# @param $(objs) Object files to link together.
187# @param $(libs) Libraries to search.
188# @param $(libpath) Library search paths.
189# @param $(flags) Flags.
190# @param $(dirdep) Directory creation dependency.
191# @param $(deps) Other dependencies.
192# @param $(othersrc) Unhandled sources.
193# @param $(custom_pre) Custom step invoked before linking.
194# @param $(custom_post) Custom step invoked after linking.
195#
196# @param $(outbase) Output basename (full). Use this for list files and such.
197define TOOL_GCC3OMF_LINK_DLL
198#$ (warning dbg: TOOL_GCC3OMF_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
199$(dll): $(deps) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(filter %.def, $(othersrc)) | $(dirdep)
200 $(call MSG_L1,Creating Program $$@)
201ifneq ($(custom_pre),)
202 $(eval $(custom_pre))
203endif
204 $(TOOL_GCC3OMF_LD) $(TOOL_GCC3OMF_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
205 $(filter %.def, $(othersrc)) \
206 $(foreach p,$(libpath), -L$(p)) \
207 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib))) \
208 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
209ifneq ($(custom_post),)
210 $(eval $(custom_post))
211endif
212_OUT_FILES += $(outbase).map
213
214endef
215
216## Link system module (windows aka driver, linux aka kernel module)
217# @param $(target) Normalized main target name.
218# @param $(sys) System module name.
219# @param $(objs) Object files to link together.
220# @param $(libs) Libraries to search.
221# @param $(libpath) Library search paths.
222# @param $(flags) Flags.
223# @param $(dirdep) Directory creation dependency.
224# @param $(deps) Other dependencies.
225# @param $(othersrc) Unhandled sources.
226# @param $(custom_pre) Custom step invoked before linking.
227# @param $(custom_post) Custom step invoked after linking.
228#
229# @param $(outbase) Output basename (full). Use this for list files and such.
230define TOOL_GCC3OMF_LINK_SYSMOD
231#$ (warning dbg: TOOL_GCC3OMF_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
232$(sys): $(deps) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(filter %.def, $(othersrc)) | $(dirdep)
233 $(call MSG_L1,Creating Program $$@)
234ifneq ($(custom_pre),)
235 $(eval $(custom_pre))
236endif
237 $(TOOL_GCC3OMF_LD_SYSMOD) $(TOOL_GCC3OMF_LDFLAGS.sysmod) $(flags) -o $$@ $(objs) \
238 $(filter %.def, $(othersrc)) \
239 $(foreach p,$(libpath), -L$(p)) \
240 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib))) \
241 $(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map)
242ifneq ($(custom_post),)
243 $(eval $(custom_post))
244endif
245_OUT_FILES += $(outbase).map
246
247endef
248
Note: See TracBrowser for help on using the repository browser.