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

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

dropped debug statement.

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