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

Last change on this file since 1690 was 1612, checked in by bird, 17 years ago

Drop the .map files when using gcc, except of course, for OS/2.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.4 KB
Line 
1# $Id: MINGW32.kmk 1612 2008-05-12 15:42:09Z bird $
2## @file
3# kBuild Tool Config - MinGW32 GCC v3.3+.
4#
5
6#
7# Copyright (c) 2004-2008 knut st. osmundsen <bird-kBuild-spam@anduin.net>
8#
9#
10# This file is part of kBuild.
11#
12# kBuild is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# kBuild is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with kBuild; if not, write to the Free Software
24# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25#
26#
27# As a special exception you are granted permission to include this file, via
28# the kmk include directive, as you wish without this in itself causing the
29# resulting makefile, program or whatever to be covered by the GPL license.
30# This exception does not however invalidate any other reasons why the makefile,
31# program, whatever should not be covered the GPL.
32#
33#
34
35TOOL_MINGW32 := MinGW32 GCC v3.3+.
36
37# Tool Specific Properties
38ifndef PATH_TOOL_MINGW32
39 PATH_TOOL_MINGW32 := $(wildcard $(PATH_DEVTOOLS_BLD)/mingw32/v*.*)
40 ifeq ($(PATH_TOOL_MINGW32),)
41 PATH_TOOL_MINGW32 := $(wildcard $(PATH_DEVTOOLS)/win.x86/mingw32/v*.*)
42 endif
43 ifeq ($(PATH_TOOL_MINGW32),)
44 PATH_TOOL_MINGW32 := $(wildcard $(PATH_DEVTOOLS)/x86.win32/mingw32/v*.*)
45 endif
46 ifneq ($(PATH_TOOL_MINGW32),)
47 PATH_TOOL_MINGW32 := $(lastword $(sort $(PATH_TOOL_MINGW32)))
48 endif
49else
50 # Resolve any fancy stuff once and for all.
51 PATH_TOOL_MINGW32 := $(PATH_TOOL_MINGW32)
52endif
53
54# figure out if it's native or needs a win32 launcher
55TOOL_MINGW32_HOSTSUFF_EXE ?= $(HOSTSUFF_EXE)
56ifndef TOOL_MINGW32_PREFIX
57 ifneq ($(PATH_TOOL_MINGW32),)
58 TOOL_MINGW32_PREFIX := $(PATH_TOOL_MINGW32)/bin/
59 else
60 TOOL_MINGW32_PREFIX :=
61 endif
62 ifneq ($(KBUILD_HOST),win)
63 # we're cross compiling either using an emulator (wine/odin) or a cross compiler.
64 ifneq ($(PATH_TOOL_MINGW32),$(subst /win.x86,,$(subst /x86.win,,$(PATH_TOOL_MINGW32))))
65 TOOL_MINGW32_PREFIX := $(EXEC_X86_WIN32) $(TOOL_MINGW32_PREFIX)
66 TOOL_MINGW32_HOSTSUFF_EXE := .exe
67 else
68 TOOL_MINGW32_PREFIX := $(TOOL_MINGW32_PREFIX)i386-mingw32msvc-
69 TOOL_MINGW32_HOSTSUFF_EXE :=
70 TOOL_MINGW32_XCOMPILE := 1
71 endif
72 endif
73else
74 # Resolve any fancy stuff once and for all.
75 TOOL_MINGW32_PREFIX :=
76endif
77
78TOOL_MINGW32_CC ?= $(TOOL_MINGW32_PREFIX)gcc$(TOOL_MINGW32_HOSTSUFF_EXE)
79TOOL_MINGW32_CXX ?= $(TOOL_MINGW32_PREFIX)g++$(TOOL_MINGW32_HOSTSUFF_EXE)
80TOOL_MINGW32_AS ?= $(TOOL_MINGW32_PREFIX)gcc$(TOOL_MINGW32_HOSTSUFF_EXE)
81TOOL_MINGW32_AR ?= $(TOOL_MINGW32_PREFIX)ar$(TOOL_MINGW32_HOSTSUFF_EXE)
82ifndef TOOL_MINGW32_XCOMPILE# The gentoo package doesn't have g++.
83TOOL_MINGW32_LD ?= $(TOOL_MINGW32_PREFIX)g++$(TOOL_MINGW32_HOSTSUFF_EXE)
84else
85TOOL_MINGW32_LD ?= $(TOOL_MINGW32_PREFIX)gcc$(TOOL_MINGW32_HOSTSUFF_EXE)
86endif
87TOOL_MINGW32_DLLWRAP ?= $(TOOL_MINGW32_PREFIX)dllwrap$(TOOL_MINGW32_HOSTSUFF_EXE)
88TOOL_MINGW32_DLLTOOL ?= $(TOOL_MINGW32_PREFIX)dlltool$(TOOL_MINGW32_HOSTSUFF_EXE)
89
90# General Properties used by kBuild
91TOOL_MINGW32_COBJSUFF ?= .o
92TOOL_MINGW32_CFLAGS ?= -g
93TOOL_MINGW32_CFLAGS.debug ?= -O0
94TOOL_MINGW32_CFLAGS.release ?= -O2
95TOOL_MINGW32_CFLAGS.profile ?= -O2 #-pg
96TOOL_MINGW32_CINCS ?=
97TOOL_MINGW32_CDEFS ?=
98
99TOOL_MINGW32_CXXOBJSUFF ?= .o
100TOOL_MINGW32_CXXOBJSUFF ?= .o
101TOOL_MINGW32_CXXFLAGS ?= -g
102TOOL_MINGW32_CXXFLAGS.debug ?= -O0
103TOOL_MINGW32_CXXFLAGS.release ?= -O2
104TOOL_MINGW32_CXXFLAGS.profile ?= -O2 #-pg
105TOOL_MINGW32_CXXINCS ?=
106TOOL_MINGW32_CXXDEFS ?=
107
108TOOL_MINGW32_ASFLAGS ?= -g -x assembler-with-cpp
109TOOL_MINGW32_ASOBJSUFF ?= .o
110
111TOOL_MINGW32_ARFLAGS ?= cr
112TOOL_MINGW32_ARLIBSUFF ?= .a
113
114TOOL_MINGW32_LDFLAGS ?=
115TOOL_MINGW32_LDFLAGS.debug ?= -g
116TOOL_MINGW32_LDFLAGS.release ?= -s
117
118
119## Compile C source.
120# @param $(target) Normalized main target name.
121# @param $(source) Source filename (relative).
122# @param $(obj) Object file name. This shall be (re)created by the compilation.
123# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
124# @param $(flags) Flags.
125# @param $(defs) Definitions. No -D or something.
126# @param $(incs) Includes. No -I or something.
127# @param $(dirdep) Directory creation dependency.
128# @param $(deps) Other dependencies.
129# @param $(outbase) Output basename (full). Use this for list files and such.
130# @param $(objsuff) Object suffix.
131TOOL_MINGW32_COMPILE_C_OUTPUT =
132TOOL_MINGW32_COMPILE_C_DEPEND =
133TOOL_MINGW32_COMPILE_C_DEPORD =
134define TOOL_MINGW32_COMPILE_C_CMDS
135 $(QUIET)$(TOOL_MINGW32_CC) -c\
136 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
137 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
138 -o $(obj)\
139 $(abspath $(source))
140endef
141
142
143## Compile C++ source.
144# @param $(target) Normalized main target name.
145# @param $(source) Source filename (relative).
146# @param $(obj) Object file name. This shall be (re)created by the compilation.
147# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
148# @param $(flags) Flags.
149# @param $(defs) Definitions. No -D or something.
150# @param $(incs) Includes. No -I or something.
151# @param $(dirdep) Directory creation dependency.
152# @param $(deps) Other dependencies.
153# @param $(outbase) Output basename (full). Use this for list files and such.
154# @param $(objsuff) Object suffix.
155TOOL_MINGW32_COMPILE_CXX_OUTPUT =
156TOOL_MINGW32_COMPILE_CXX_DEPEND =
157TOOL_MINGW32_COMPILE_CXX_DEPORD =
158define TOOL_MINGW32_COMPILE_CXX_CMDS
159 $(QUIET)$(TOOL_MINGW32_CXX) -c\
160 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
161 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
162 -o $(obj)\
163 $(abspath $(source))
164endef
165
166
167## Compile Assembly source.
168# @param $(target) Normalized main target name.
169# @param $(source) Source filename (relative).
170# @param $(obj) Object file name. This shall be (re)created by the compilation.
171# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
172# @param $(flags) Flags.
173# @param $(defs) Definitions. No -D or something.
174# @param $(incs) Includes. No -I or something.
175# @param $(dirdep) Directory creation dependency.
176# @param $(deps) Other dependencies.
177# @param $(outbase) Output basename (full). Use this for list files and such.
178# @param $(objsuff) Object suffix.
179#
180TOOL_MINGW32_COMPILE_AS_OUTPUT =
181TOOL_MINGW32_COMPILE_AS_DEPEND =
182TOOL_MINGW32_COMPILE_AS_DEPORD =
183define TOOL_MINGW32_COMPILE_AS_CMDS
184 $(QUIET)$(TOOL_MINGW32_AS) -c\
185 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
186 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
187 -o $(obj)\
188 $(abspath $(source))
189endef
190
191
192## Link library
193# @param $(target) Normalized main target name.
194# @param $(out) Library name.
195# @param $(objs) Object files to put in the library.
196# @param $(flags) Flags.
197# @param $(dirdep) Directory creation dependency.
198# @param $(deps) Other dependencies.
199#
200# @param $(outbase) Output basename (full). Use this for list files and such.
201TOOL_MINGW32_LINK_LIBRARY_OUTPUT = $(out).ar-script
202TOOL_MINGW32_LINK_LIBRARY_DEPEND = $(othersrc)
203TOOL_MINGW32_LINK_LIBRARY_DEPORD =
204define TOOL_MINGW32_LINK_LIBRARY_CMDS
205 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
206 $(QUIET)$(APPEND) -n $(out).ar-script \
207 $(foreach o,$(objs), 'ADDMOD $(o)') \
208 $(foreach o,$(othersrc), 'ADDLIB $(o)')
209 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
210 $(QUIET)$(APPEND) $(out).ar-script 'END'
211 $(QUIET)$(TOOL_MINGW32_AR) -M < $(out).ar-script
212endef
213
214
215
216## Link program
217# @param $(target) Normalized main target name.
218# @param $(out) Program name.
219# @param $(objs) Object files to link together.
220# @param $(libs) Libraries to search.
221# @param $(libpath) Library search paths.
222# @param $(flags) Flags.
223# @param $(dirdep) Directory creation dependency.
224# @param $(deps) Other dependencies.
225# @param $(othersrc) Unhandled sources.
226# @param $(custom_pre) Custom step invoked before linking.
227# @param $(custom_post) Custom step invoked after linking.
228#
229# @param $(outbase) Output basename (full). Use this for list files and such.
230TOOL_MINGW32_LINK_PROGRAM_OUTPUT =
231TOOL_MINGW32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
232TOOL_MINGW32_LINK_PROGRAM_DEPORD =
233define TOOL_MINGW32_LINK_PROGRAM_CMDS
234 $(QUIET)$(TOOL_MINGW32_LD) $(flags) -o $(out) $(objs)\
235 $(foreach p,$(libpath), -L$(p))\
236 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
237endef
238
239
240## Link DLL.
241# @param $(target) Normalized main target name.
242# @param $(out) DLL name.
243# @param $(objs) Object files to link together.
244# @param $(libs) Libraries to search.
245# @param $(libpath) Library search paths.
246# @param $(flags) Flags.
247# @param $(dirdep) Directory creation dependency.
248# @param $(deps) Other dependencies.
249# @param $(othersrc) Unhandled sources.
250# @param $(custom_pre) Custom step invoked before linking.
251# @param $(custom_post) Custom step invoked after linking.
252# @param $(outbase) Output basename (full). Use this for list files and such.
253TOOL_MINGW32_LINK_DLL_OUTPUT =
254TOOL_MINGW32_LINK_DLL_OUTPUT_MAYBE = $(outbase).a $(outbase).exp $(PATH_LIB)/$(notdir $(outbase)).exp $(PATH_LIB)/$(notdir $(outbase)).a
255## @todo Find a better solution for installing the extra files (.a, .exp, .pdb, etc).
256TOOL_MINGW32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
257 $(filter %.def %.res,$(othersrc))
258TOOL_MINGW32_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB))
259define TOOL_MINGW32_LINK_DLL_CMDS
260 $(QUIET)$(TOOL_MINGW32_DLLWRAP) $(flags)\
261 --dllname=$(out)\
262 --output-exp=$(outbase).exp\
263 --output-lib=$(outbase).a\
264 $(foreach def,$(filter %.def,$(othersrc)), --def $(def))\
265 $(filter %.res,$(othersrc))\
266 $(objs)\
267 $(foreach p,$(libpath), -L$(p))\
268 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
269 $(QUIET)$(CP) $(outbase).exp $(outbase).a $(PATH_LIB)/
270endef
271## @todo separate install stuff!
Note: See TracBrowser for help on using the repository browser.