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

Last change on this file since 125 was 123, checked in by bird, 21 years ago

initial config.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1# $Id: MINGW32.kmk 123 2004-06-25 20:25:51Z 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)/36mingw32/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_ARCH).$(BUILD_PLATFORM),x86.win32)
47ifneq ($(PATH_TOOL_MINGW32),$(subst x86.win32,,$(PATH_TOOL_MINGW32)))
48_TOOL_MINGW32_PREFIX := $(EXEC_X86_WIN32) $(_TOOL_MINGW32_PREFIX)
49_TOOL_MINGW32_SUFF_EXE := .exe
50endif
51endif
52
53TOOL_MINGW32_CC := $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
54TOOL_MINGW32_COBJSUFF := .o
55TOOL_MINGW32_CFLAGS := -g
56TOOL_MINGW32_CFLAGS.debug := -O0
57TOOL_MINGW32_CFLAGS.release := -O2
58TOOL_MINGW32_CFLAGS.profile := -pg
59TOOL_MINGW32_CINCS :=
60TOOL_MINGW32_CDEFS :=
61
62TOOL_MINGW32_CXX := $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
63TOOL_MINGW32_CXXOBJSUFF := .o
64TOOL_MINGW32_CXXOBJSUFF := .o
65TOOL_MINGW32_CXXFLAGS := -g
66TOOL_MINGW32_CXXFLAGS.debug := -O0
67TOOL_MINGW32_CXXFLAGS.release := -O2
68TOOL_MINGW32_CXXFLAGS.profile := -pg
69TOOL_MINGW32_CXXINCS :=
70TOOL_MINGW32_CXXDEFS :=
71
72TOOL_MINGW32_AS := $(_TOOL_MINGW32_PREFIX)as$(_TOOL_MINGW32_SUFF_EXE)
73TOOL_MINGW32_ASOBJSUFF := .o
74
75TOOL_MINGW32_AR := $(_TOOL_MINGW32_PREFIX)ar$(_TOOL_MINGW32_SUFF_EXE)
76TOOL_MINGW32_ARFLAGS := cr
77TOOL_MINGW32_ARLIBSUFF := .a
78
79TOOL_MINGW32_LD := $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
80TOOL_MINGW32_LDFLAGS :=
81TOOL_MINGW32_LDFLAGS.debug := -g
82TOOL_MINGW32_LDFLAGS.release := -s
83
84
85## Compile C source.
86# @param $(target) Normalized main target name.
87# @param $(source) Source filename (relative).
88# @param $(obj) Object file name. This shall be (re)created by the compilation.
89# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
90# @param $(flags) Flags.
91# @param $(defs) Definitions. No -D or something.
92# @param $(incs) Includes. No -I or something.
93# @param $(dirdep) Directory creation dependency.
94#
95# @param $(outbase) Output basename (full). Use this for list files and such.
96# @param $(objsuff) Object suffix.
97define TOOL_MINGW32_COMPILE_C
98#$ (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))
99$(obj): $(dirdep) $(source)
100 $(call MSG_L2,Compiling $$@ using MINGW32)
101 $(TOOL_MINGW32_CC) -c\
102 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
103 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
104 -o $$@\
105 $(source)
106
107endef
108
109
110## Compile C++ source.
111# @param $(target) Normalized main target name.
112# @param $(source) Source filename (relative).
113# @param $(obj) Object file name. This shall be (re)created by the compilation.
114# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
115# @param $(flags) Flags.
116# @param $(defs) Definitions. No -D or something.
117# @param $(incs) Includes. No -I or something.
118# @param $(dirdep) Directory creation dependency.
119#
120# @param $(outbase) Output basename (full). Use this for list files and such.
121# @param $(objsuff) Object suffix.
122define TOOL_MINGW32_COMPILE_CXX
123#$ (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))
124$(obj): $(dirdep) $(source)
125 $(call MSG_L2,Compiling $$@ using MINGW32)
126 $(TOOL_MINGW32_CXX) -c\
127 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
128 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
129 -o $$@\
130 $(source)
131
132endef
133
134
135## Link library
136# @param $(target) Normalized main target name.
137# @param $(lib) Library name.
138# @param $(objs) Object files to put in the library.
139# @param $(flags) Flags.
140# @param $(dirdep) Directory creation dependency.
141# @param $(deps) Other dependencies.
142#
143# @param $(outbase) Output basename (full). Use this for list files and such.
144define TOOL_MINGW32_LINK_LIBRARY
145#$ (warning dbg: TOOL_MINGW32_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
146$(lib): $(dirdep) $(objs) $(deps)
147 $(call MSG_L1,Creating Library $$@)
148 $(RM) -f $$@
149 $(TOOL_MINGW32_AR) $(flags) $$@ $(objs)
150 $(MKDIR) -p $(PATH_LIB)
151 $(CP) $$@ $(PATH_LIB)/
152
153endef
154
155
156## Link program
157# @param $(target) Normalized main target name.
158# @param $(exe) Program name.
159# @param $(objs) Object files to link together.
160# @param $(libs) Libraries to search.
161# @param $(libpath) Library search paths.
162# @param $(flags) Flags.
163# @param $(dirdep) Directory creation dependency.
164# @param $(deps) Other dependencies.
165# @param $(deffile) Definition file. (optional, PC only)
166# @param $(custom_pre) Custom step invoked before linking.
167# @param $(custom_post) Custom step invoked after linking.
168#
169# @param $(outbase) Output basename (full). Use this for list files and such.
170define TOOL_MINGW32_LINK_PROGRAM
171#$ (warning dbg: TOOL_MINGW32_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
172$(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
173 $(call MSG_L1,Creating Program $$@)
174ifneq ($(custom_pre),)
175 $(eval $(custom_pre))
176endif
177 $(TOOL_MINGW32_LD) $(flags) -o $$@ $(objs) \
178 $(foreach p,$(libpath), -L$(p)) \
179 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
180ifneq ($(custom_post),)
181 $(eval $(custom_post))
182endif
183 $(MKDIR) -p $(PATH_BIN)
184 $(CP) $$@ $(PATH_BIN)/
185
186endef
187
Note: See TracBrowser for help on using the repository browser.