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

Last change on this file since 136 was 130, checked in by bird, 21 years ago

DLL

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1# $Id: MINGW32.kmk 130 2004-06-29 17:30:14Z 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
27TOOL_MINGW32 := MinGW32 GCC v3.3+
28
29# find latest installed version
30ifndef PATH_TOOL_MINGW32
31PATH_TOOL_MINGW32 := $(sort $(wildcard $(PATH_DEV)/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)/mingw32/v*.*))
32ifeq ($(PATH_TOOL_MINGW32),)
33PATH_TOOL_MINGW32 := $(sort $(wildcard $(PATH_DEV)/x86.win32/mingw32/v*.*))
34endif
35ifneq ($(PATH_TOOL_MINGW32),)
36PATH_TOOL_MINGW32 := $(call lastword,$(PATH_TOOL_MINGW32))
37endif
38endif
39
40# figure out if it's native or needs a win32 launcher
41_TOOL_MINGW32_PREFIX :=
42ifneq ($(PATH_TOOL_MINGW32),)
43_TOOL_MINGW32_PREFIX := $(PATH_TOOL_MINGW32)/bin/
44endif
45_TOOL_MINGW32_SUFF_EXE := $(HOSTSUFF_EXE)
46ifneq ($(BUILD_PLATFORM),win32)
47# we're cross compiling either using wine/odin or a cross compiler.
48ifneq ($(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
51else
52_TOOL_MINGW32_PREFIX := $(_TOOL_MINGW32_PREFIX)i386-mingw32msvc-
53_TOOL_MINGW32_SUFF_EXE :=
54_TOOL_MINGW32_XCOMPILE := 1
55endif
56endif
57
58TOOL_MINGW32_CC := $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
59TOOL_MINGW32_COBJSUFF := .o
60TOOL_MINGW32_CFLAGS := -g
61TOOL_MINGW32_CFLAGS.debug := -O0
62TOOL_MINGW32_CFLAGS.release := -O2
63TOOL_MINGW32_CFLAGS.profile := -pg
64TOOL_MINGW32_CINCS :=
65TOOL_MINGW32_CDEFS :=
66
67TOOL_MINGW32_CXX := $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
68TOOL_MINGW32_CXXOBJSUFF := .o
69TOOL_MINGW32_CXXOBJSUFF := .o
70TOOL_MINGW32_CXXFLAGS := -g
71TOOL_MINGW32_CXXFLAGS.debug := -O0
72TOOL_MINGW32_CXXFLAGS.release := -O2
73TOOL_MINGW32_CXXFLAGS.profile := -pg
74TOOL_MINGW32_CXXINCS :=
75TOOL_MINGW32_CXXDEFS :=
76
77TOOL_MINGW32_AS := $(_TOOL_MINGW32_PREFIX)as$(_TOOL_MINGW32_SUFF_EXE)
78TOOL_MINGW32_ASOBJSUFF := .o
79
80TOOL_MINGW32_AR := $(_TOOL_MINGW32_PREFIX)ar$(_TOOL_MINGW32_SUFF_EXE)
81TOOL_MINGW32_ARFLAGS := cr
82TOOL_MINGW32_ARLIBSUFF := .a
83
84# The linux cross compiler ebuild haven't got g++, this is a hack for that.
85ifndef _TOOL_MINGW32_XCOMPILE
86TOOL_MINGW32_LD := $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
87else
88TOOL_MINGW32_LD := $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
89endif
90TOOL_MINGW32_LDFLAGS :=
91TOOL_MINGW32_LDFLAGS.debug := -g
92TOOL_MINGW32_LDFLAGS.release := -s
93
94
95## Compile C source.
96# @param $(target) Normalized main target name.
97# @param $(source) Source filename (relative).
98# @param $(obj) Object file name. This shall be (re)created by the compilation.
99# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
100# @param $(flags) Flags.
101# @param $(defs) Definitions. No -D or something.
102# @param $(incs) Includes. No -I or something.
103# @param $(dirdep) Directory creation dependency.
104#
105# @param $(outbase) Output basename (full). Use this for list files and such.
106# @param $(objsuff) Object suffix.
107define TOOL_MINGW32_COMPILE_C
108#$ (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))
109$(obj): $(dirdep) $(source)
110 $(call MSG_L2,Compiling $$@ using MINGW32)
111 $(TOOL_MINGW32_CC) -c\
112 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
113 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
114 -o $$@\
115 $(call ABSPATH,$(source))
116
117endef
118
119
120## Compile C++ source.
121# @param $(target) Normalized main target name.
122# @param $(source) Source filename (relative).
123# @param $(obj) Object file name. This shall be (re)created by the compilation.
124# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
125# @param $(flags) Flags.
126# @param $(defs) Definitions. No -D or something.
127# @param $(incs) Includes. No -I or something.
128# @param $(dirdep) Directory creation dependency.
129#
130# @param $(outbase) Output basename (full). Use this for list files and such.
131# @param $(objsuff) Object suffix.
132define TOOL_MINGW32_COMPILE_CXX
133#$ (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))
134$(obj): $(dirdep) $(source)
135 $(call MSG_L2,Compiling $$@ using MINGW32)
136 $(TOOL_MINGW32_CXX) -c\
137 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
138 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
139 -o $$@\
140 $(call ABSPATH,$(source))
141
142endef
143
144
145## Link library
146# @param $(target) Normalized main target name.
147# @param $(lib) Library name.
148# @param $(objs) Object files to put in the library.
149# @param $(flags) Flags.
150# @param $(dirdep) Directory creation dependency.
151# @param $(deps) Other dependencies.
152#
153# @param $(outbase) Output basename (full). Use this for list files and such.
154define TOOL_MINGW32_LINK_LIBRARY
155#$ (warning dbg: TOOL_MINGW32_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
156$(lib): $(dirdep) $(objs) $(deps)
157 $(call MSG_L1,Creating Library $$@)
158 $(RM) -f $$@
159 $(TOOL_MINGW32_AR) $(flags) $$@ $(objs)
160
161endef
162
163
164## Link program
165# @param $(target) Normalized main target name.
166# @param $(exe) Program name.
167# @param $(objs) Object files to link together.
168# @param $(libs) Libraries to search.
169# @param $(libpath) Library search paths.
170# @param $(flags) Flags.
171# @param $(dirdep) Directory creation dependency.
172# @param $(deps) Other dependencies.
173# @param $(othersrc) Unhandled sources.
174# @param $(custom_pre) Custom step invoked before linking.
175# @param $(custom_post) Custom step invoked after linking.
176#
177# @param $(outbase) Output basename (full). Use this for list files and such.
178define TOOL_MINGW32_LINK_PROGRAM
179#$ (warning dbg: TOOL_MINGW32_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
180$(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
181 $(call MSG_L1,Creating Program $$@)
182ifneq ($(custom_pre),)
183 $(eval $(custom_pre))
184endif
185 $(TOOL_MINGW32_LD) $(flags) -o $$@ $(objs) \
186 $(foreach p,$(libpath), -L$(p)) \
187 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
188ifneq ($(custom_post),)
189 $(eval $(custom_post))
190endif
191
192endef
193
Note: See TracBrowser for help on using the repository browser.