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