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