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

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

Corrected dependencies to match the ones generated by GCC3.kmk.

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