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

Last change on this file since 1097 was 1034, checked in by bird, 18 years ago

MAYBE output. removed some obsolete stuff.

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