1 | # $Id: MINGW32.kmk 235 2005-02-10 22:38:52Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild Tool Config - MINGW32 GCC.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004 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)as$(_TOOL_MINGW32_SUFF_EXE)
|
---|
78 | TOOL_MINGW32_ASOBJSUFF := .o
|
---|
79 |
|
---|
80 | TOOL_MINGW32_AR := $(_TOOL_MINGW32_PREFIX)ar$(_TOOL_MINGW32_SUFF_EXE)
|
---|
81 | TOOL_MINGW32_ARFLAGS := cr
|
---|
82 | TOOL_MINGW32_ARLIBSUFF := .a
|
---|
83 |
|
---|
84 | # The linux cross compiler ebuild haven't got g++, this is a hack for that.
|
---|
85 | ifndef _TOOL_MINGW32_XCOMPILE
|
---|
86 | TOOL_MINGW32_LD := $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
|
---|
87 | else
|
---|
88 | TOOL_MINGW32_LD := $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
|
---|
89 | endif
|
---|
90 | TOOL_MINGW32_LDFLAGS :=
|
---|
91 | TOOL_MINGW32_LDFLAGS.debug := -g
|
---|
92 | TOOL_MINGW32_LDFLAGS.release := -s
|
---|
93 |
|
---|
94 | TOOL_MINGW32_DLLWRAP := $(_TOOL_MINGW32_PREFIX)dllwrap$(_TOOL_MINGW32_SUFF_EXE)
|
---|
95 | TOOL_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 | #
|
---|
109 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
110 | # @param $(objsuff) Object suffix.
|
---|
111 | define TOOL_MINGW32_COMPILE_C
|
---|
112 | #$ (warning dbg: TOOL_MINGW32_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
113 | $(obj): $(source) $(deps) | $(dirdep)
|
---|
114 | $(call MSG_L2,Compiling $$@ using MINGW32)
|
---|
115 | $(TOOL_MINGW32_CC) -c\
|
---|
116 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
117 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
---|
118 | -o $$@\
|
---|
119 | $(call ABSPATH,$(source))
|
---|
120 |
|
---|
121 | endef
|
---|
122 |
|
---|
123 |
|
---|
124 | ## Compile C++ source.
|
---|
125 | # @param $(target) Normalized main target name.
|
---|
126 | # @param $(source) Source filename (relative).
|
---|
127 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
128 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
129 | # @param $(flags) Flags.
|
---|
130 | # @param $(defs) Definitions. No -D or something.
|
---|
131 | # @param $(incs) Includes. No -I or something.
|
---|
132 | # @param $(dirdep) Directory creation dependency.
|
---|
133 | # @param $(deps) Other dependencies.
|
---|
134 | #
|
---|
135 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
136 | # @param $(objsuff) Object suffix.
|
---|
137 | define TOOL_MINGW32_COMPILE_CXX
|
---|
138 | #$ (warning dbg: TOOL_MINGW32_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
139 | $(obj): $(source) $(deps) | $(dirdep)
|
---|
140 | $(call MSG_L2,Compiling $$@ using MINGW32)
|
---|
141 | $(TOOL_MINGW32_CXX) -c\
|
---|
142 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
143 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
---|
144 | -o $$@\
|
---|
145 | $(call ABSPATH,$(source))
|
---|
146 |
|
---|
147 | endef
|
---|
148 |
|
---|
149 |
|
---|
150 | ## Link library
|
---|
151 | # @param $(target) Normalized main target name.
|
---|
152 | # @param $(lib) Library name.
|
---|
153 | # @param $(objs) Object files to put in the library.
|
---|
154 | # @param $(flags) Flags.
|
---|
155 | # @param $(dirdep) Directory creation dependency.
|
---|
156 | # @param $(deps) Other dependencies.
|
---|
157 | #
|
---|
158 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
159 | define TOOL_MINGW32_LINK_LIBRARY
|
---|
160 | #$ (warning dbg: TOOL_MINGW32_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
|
---|
161 | $(lib): $(objs) $(deps) | $(dirdep)
|
---|
162 | $(call MSG_L1,Creating Library $$@)
|
---|
163 | $(RM) -f $$@
|
---|
164 | $(TOOL_MINGW32_AR) $(flags) $$@ $(objs)
|
---|
165 |
|
---|
166 | endef
|
---|
167 |
|
---|
168 |
|
---|
169 | ## Link program
|
---|
170 | # @param $(target) Normalized main target name.
|
---|
171 | # @param $(exe) Program name.
|
---|
172 | # @param $(objs) Object files to link together.
|
---|
173 | # @param $(libs) Libraries to search.
|
---|
174 | # @param $(libpath) Library search paths.
|
---|
175 | # @param $(flags) Flags.
|
---|
176 | # @param $(dirdep) Directory creation dependency.
|
---|
177 | # @param $(deps) Other dependencies.
|
---|
178 | # @param $(othersrc) Unhandled sources.
|
---|
179 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
180 | # @param $(custom_post) Custom step invoked after linking.
|
---|
181 | #
|
---|
182 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
183 | define TOOL_MINGW32_LINK_PROGRAM
|
---|
184 | #$ (warning dbg: TOOL_MINGW32_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
---|
185 | $(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
|
---|
186 | $(call MSG_L1,Creating Program $$@)
|
---|
187 | ifneq ($(custom_pre),)
|
---|
188 | $(eval $(custom_pre))
|
---|
189 | endif
|
---|
190 | $(TOOL_MINGW32_LD) $(flags) -o $$@ $(objs) \
|
---|
191 | $(foreach p,$(libpath), -L$(p)) \
|
---|
192 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
193 | ifneq ($(custom_post),)
|
---|
194 | $(eval $(custom_post))
|
---|
195 | endif
|
---|
196 |
|
---|
197 | endef
|
---|
198 |
|
---|
199 |
|
---|
200 | ## Link system module (windows aka driver, linux aka kernel module)
|
---|
201 | # @param $(target) Normalized main target name.
|
---|
202 | # @param $(dll) System module 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.
|
---|
214 | define TOOL_MINGW32_LINK_DLL
|
---|
215 | #$ (warning dbg: TOOL_MINGW32_LINK_DLL: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
|
---|
216 | $(dll): $(call DIRDEP,$(PATH_LIB)) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
|
---|
217 | $(call MSG_L1,Creating Program $$@)
|
---|
218 | ifneq ($(custom_pre),)
|
---|
219 | $(eval $(custom_pre))
|
---|
220 | endif
|
---|
221 | $(TOOL_MINGW32_DLLWRAP) $(flags) \
|
---|
222 | --dllname=$(dll) \
|
---|
223 | --output-exp=$(outbase).exp \
|
---|
224 | --output-lib=$(outbase).a \
|
---|
225 | $(foreach def,$(filter %.def,$(othersrc)), --def $(def)) \
|
---|
226 | $(filter %.res,$(othersrc)) \
|
---|
227 | $(objs) \
|
---|
228 | $(foreach p,$(libpath), -L$(p)) \
|
---|
229 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
230 | ifeq ($(filter %.exp .def,$(othersrc)),)
|
---|
231 | $(CP) $(outbase).exp $(outbase).a $(PATH_LIB)/
|
---|
232 | endif
|
---|
233 | ifneq ($(custom_post),)
|
---|
234 | $(eval $(custom_post))
|
---|
235 | endif
|
---|
236 | _OUT_FILES += $(outbase).map $(outbase).a $(outbase).exp
|
---|
237 |
|
---|
238 | endef
|
---|
239 |
|
---|