source: trunk/kBuild/tools/MINGW32.kmk@ 657

Last change on this file since 657 was 657, checked in by bird, 19 years ago

win32/win confusion. ?= -> :=

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.1 KB
Line 
1# $Id: MINGW32.kmk 657 2006-12-04 16:32:58Z bird $
2## @file
3#
4# kBuild Tool Config - MINGW32 GCC.
5#
6# Copyright (c) 2004-2006 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_MINGW32 := MinGW32 GCC v3.3+
28
29# find latest installed version
30ifndef PATH_TOOL_MINGW32
31 PATH_DEV_BLD ?= $(PATH_DEV)/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
32 PATH_TOOL_MINGW32 := $(sort $(wildcard $(PATH_DEV_BLD)/mingw32/v*.*))
33 ifeq ($(PATH_TOOL_MINGW32),)
34 PATH_TOOL_MINGW32 := $(sort $(wildcard $(PATH_DEV)/x86.win32/mingw32/v*.*))
35 endif
36 ifneq ($(PATH_TOOL_MINGW32),)
37 PATH_TOOL_MINGW32 := $(call lastword,$(PATH_TOOL_MINGW32))
38 endif
39$(warning PATH_TOOL_MINGW32:=$(PATH_TOOL_MINGW32))
40endif
41
42# figure out if it's native or needs a win32 launcher
43ifneq ($(PATH_TOOL_MINGW32),)
44_TOOL_MINGW32_PREFIX ?= $(PATH_TOOL_MINGW32)/bin/
45else
46_TOOL_MINGW32_PREFIX ?=
47endif
48_TOOL_MINGW32_SUFF_EXE ?= $(HOSTSUFF_EXE)
49ifneq ($(BUILD_PLATFORM),win)
50 # we're cross compiling either using wine/odin or a cross compiler.
51 ifneq ($(PATH_TOOL_MINGW32),$(subst x86.win32,,$(PATH_TOOL_MINGW32)))
52 _TOOL_MINGW32_PREFIX := $(EXEC_X86_WIN32) $(_TOOL_MINGW32_PREFIX)
53 _TOOL_MINGW32_SUFF_EXE ?= .exe
54 else
55 _TOOL_MINGW32_PREFIX := $(_TOOL_MINGW32_PREFIX)i386-mingw32msvc-
56 _TOOL_MINGW32_SUFF_EXE ?=
57 _TOOL_MINGW32_XCOMPILE ?= 1
58 endif
59endif
60
61TOOL_MINGW32_CC ?= $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
62TOOL_MINGW32_COBJSUFF ?= .o
63TOOL_MINGW32_CFLAGS ?= -g
64TOOL_MINGW32_CFLAGS.debug ?= -O0
65TOOL_MINGW32_CFLAGS.release ?= -O2
66TOOL_MINGW32_CFLAGS.profile ?= -O2 #-pg
67TOOL_MINGW32_CINCS ?=
68TOOL_MINGW32_CDEFS ?=
69
70TOOL_MINGW32_CXX ?= $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
71TOOL_MINGW32_CXXOBJSUFF ?= .o
72TOOL_MINGW32_CXXOBJSUFF ?= .o
73TOOL_MINGW32_CXXFLAGS ?= -g
74TOOL_MINGW32_CXXFLAGS.debug ?= -O0
75TOOL_MINGW32_CXXFLAGS.release ?= -O2
76TOOL_MINGW32_CXXFLAGS.profile ?= -O2 #-pg
77TOOL_MINGW32_CXXINCS ?=
78TOOL_MINGW32_CXXDEFS ?=
79
80TOOL_MINGW32_AS ?= $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
81TOOL_MINGW32_ASFLAGS ?= -g -x assembler-with-cpp
82TOOL_MINGW32_ASOBJSUFF ?= .o
83
84TOOL_MINGW32_AR ?= $(_TOOL_MINGW32_PREFIX)ar$(_TOOL_MINGW32_SUFF_EXE)
85TOOL_MINGW32_ARFLAGS ?= cr
86TOOL_MINGW32_ARLIBSUFF ?= .a
87
88# The linux cross compiler ebuild haven't got g++, this is a hack for that.
89ifndef _TOOL_MINGW32_XCOMPILE
90TOOL_MINGW32_LD ?= $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
91else
92TOOL_MINGW32_LD ?= $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
93endif
94TOOL_MINGW32_LDFLAGS ?=
95TOOL_MINGW32_LDFLAGS.debug ?= -g
96TOOL_MINGW32_LDFLAGS.release ?= -s
97TOOL_MINGW32_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
98TOOL_MINGW32_LD_SYSMOD_MAP ?= -Map $(1) --cref
99
100TOOL_MINGW32_DLLWRAP ?= $(_TOOL_MINGW32_PREFIX)dllwrap$(_TOOL_MINGW32_SUFF_EXE)
101TOOL_MINGW32_DLLTOOL ?= $(_TOOL_MINGW32_PREFIX)dlltool$(_TOOL_MINGW32_SUFF_EXE)
102
103
104## Compile C source.
105# @param $(target) Normalized main target name.
106# @param $(source) Source filename (relative).
107# @param $(obj) Object file name. This shall be (re)created by the compilation.
108# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
109# @param $(flags) Flags.
110# @param $(defs) Definitions. No -D or something.
111# @param $(incs) Includes. No -I or something.
112# @param $(dirdep) Directory creation dependency.
113# @param $(deps) Other dependencies.
114# @param $(outbase) Output basename (full). Use this for list files and such.
115# @param $(objsuff) Object suffix.
116TOOL_MINGW32_COMPILE_C_OUTPUT =
117TOOL_MINGW32_COMPILE_C_DEPEND =
118TOOL_MINGW32_COMPILE_C_DEPORD =
119define TOOL_MINGW32_COMPILE_C_CMDS
120 $(TOOL_MINGW32_CC) -c\
121 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
122 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
123 -o $(obj)\
124 $(call ABSPATH,$(source))
125endef
126
127
128## Compile C++ source.
129# @param $(target) Normalized main target name.
130# @param $(source) Source filename (relative).
131# @param $(obj) Object file name. This shall be (re)created by the compilation.
132# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
133# @param $(flags) Flags.
134# @param $(defs) Definitions. No -D or something.
135# @param $(incs) Includes. No -I or something.
136# @param $(dirdep) Directory creation dependency.
137# @param $(deps) Other dependencies.
138# @param $(outbase) Output basename (full). Use this for list files and such.
139# @param $(objsuff) Object suffix.
140TOOL_MINGW32_COMPILE_CXX_OUTPUT =
141TOOL_MINGW32_COMPILE_CXX_DEPEND =
142TOOL_MINGW32_COMPILE_CXX_DEPORD =
143define TOOL_MINGW32_COMPILE_CXX_CMDS
144 $(TOOL_MINGW32_CXX) -c\
145 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
146 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
147 -o $(obj)\
148 $(call ABSPATH,$(source))
149endef
150
151
152## Compile Assembly source.
153# @param $(target) Normalized main target name.
154# @param $(source) Source filename (relative).
155# @param $(obj) Object file name. This shall be (re)created by the compilation.
156# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
157# @param $(flags) Flags.
158# @param $(defs) Definitions. No -D or something.
159# @param $(incs) Includes. No -I or something.
160# @param $(dirdep) Directory creation dependency.
161# @param $(deps) Other dependencies.
162# @param $(outbase) Output basename (full). Use this for list files and such.
163# @param $(objsuff) Object suffix.
164#
165TOOL_MINGW32_COMPILE_AS_OUTPUT =
166TOOL_MINGW32_COMPILE_AS_DEPEND =
167TOOL_MINGW32_COMPILE_AS_DEPORD =
168define TOOL_MINGW32_COMPILE_AS_CMDS
169 $(TOOL_MINGW32_AS) -c\
170 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
171 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
172 -o $(obj)\
173 $(call ABSPATH,$(source))
174endef
175
176
177## Link library
178# @param $(target) Normalized main target name.
179# @param $(lib) Library name.
180# @param $(objs) Object files to put in the library.
181# @param $(flags) Flags.
182# @param $(dirdep) Directory creation dependency.
183# @param $(deps) Other dependencies.
184#
185# @param $(outbase) Output basename (full). Use this for list files and such.
186TOOL_MINGW32_LINK_LIBRARY_OUTPUT = $(lib).ar-script
187TOOL_MINGW32_LINK_LIBRARY_DEPEND = $(filter %.a %.lib,$(othersrc))
188TOOL_MINGW32_LINK_LIBRARY_DEPORD =
189define TOOL_MINGW32_LINK_LIBRARY_CMDS
190 $(APPEND) $(lib).ar-script "CREATE $(out)"
191 $(foreach o, $(objs)\
192 ,$(NL)$(TAB)$(APPEND) $(lib).ar-script "ADDMOD $(o)")
193 $(foreach srclib, $(filter %.a %.lib,$(othersrc))\
194 ,$(NL)$(TAB)$(APPEND) $(lib).ar-script "ADDLIB $(srclib)")
195 $(APPEND) $(lib).ar-script "SAVE"
196 $(APPEND) $(lib).ar-script "END"
197 $(TOOL_MINGW32_AR) -M < $(lib).ar-script
198endef
199
200
201## Link program
202# @param $(target) Normalized main target name.
203# @param $(out) Program name.
204# @param $(objs) Object files to link together.
205# @param $(libs) Libraries to search.
206# @param $(libpath) Library search paths.
207# @param $(flags) Flags.
208# @param $(dirdep) Directory creation dependency.
209# @param $(deps) Other dependencies.
210# @param $(othersrc) Unhandled sources.
211# @param $(custom_pre) Custom step invoked before linking.
212# @param $(custom_post) Custom step invoked after linking.
213#
214# @param $(outbase) Output basename (full). Use this for list files and such.
215TOOL_MINGW32_LINK_PROGRAM_OUTPUT =
216TOOL_MINGW32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
217TOOL_MINGW32_LINK_PROGRAM_DEPORD =
218define TOOL_MINGW32_LINK_PROGRAM_CMDS
219 $(TOOL_MINGW32_LD) $(flags) -o $(out) $(objs)\
220 $(foreach p,$(libpath), -L$(p))\
221 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
222 $(call TOOL_MINGW32_LD_MAP,$(outbase).map)
223endef
224
225
226## Link DLL.
227# @param $(target) Normalized main target name.
228# @param $(out) DLL name.
229# @param $(objs) Object files to link together.
230# @param $(libs) Libraries to search.
231# @param $(libpath) Library search paths.
232# @param $(flags) Flags.
233# @param $(dirdep) Directory creation dependency.
234# @param $(deps) Other dependencies.
235# @param $(othersrc) Unhandled sources.
236# @param $(custom_pre) Custom step invoked before linking.
237# @param $(custom_post) Custom step invoked after linking.
238# @param $(outbase) Output basename (full). Use this for list files and such.
239TOOL_MINGW32_LINK_DLL_OUTPUT = $(outbase).a $(outbase).exp
240TOOL_MINGW32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
241 $(filter %.def %.res,$(othersrc))
242TOOL_MINGW32_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB))
243define TOOL_MINGW32_LINK_DLL_CMDS
244 $(TOOL_MINGW32_DLLWRAP) $(flags)\
245 --dllname=$(out)\
246 --output-exp=$(outbase).exp\
247 --output-lib=$(outbase).a\
248 $(foreach def,$(filter %.def,$(othersrc)), --def $(def))\
249 $(filter %.res,$(othersrc))\
250 $(objs)\
251 $(foreach p,$(libpath), -L$(p))\
252 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
253 $(call TOOL_MINGW32_LD_MAP,$(outbase).map)
254 $(CP) $(outbase).exp $(outbase).a $(PATH_LIB)/
255endef
256## @todo seperate install stuff!
Note: See TracBrowser for help on using the repository browser.