3 # kBuild Tool Config - Generic GCC Using The System GCC.
7 # Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
9 # This file is part of kBuild.
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.
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.
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
26 # As a special exception you are granted permission to include this file, via
27 # the kmk include directive, as you wish without this in itself causing the
28 # resulting makefile, program or whatever to be covered by the GPL license.
29 # This exception does not however invalidate any other reasons why the makefile,
30 # program, whatever should not be covered the GPL.
34 TOOL_GCC
:= Generic GCC Using The System GCC.
36 # Tool Specific Properties
37 TOOL_GCC_CC ?
= gcc
$(HOSTSUFF_EXE
)
38 TOOL_GCC_CXX ?
= g
++$(HOSTSUFF_EXE
)
39 TOOL_GCC_AS ?
= gcc
$(HOSTSUFF_EXE
)
40 TOOL_GCC_AR ?
= ar$(HOSTSUFF_EXE
)
41 TOOL_GCC_RANLIB ?
= ranlib
$(HOSTSUFF_EXE
)
42 TOOL_GCC_LD ?
= gcc
$(HOSTSUFF_EXE
)
43 TOOL_GCC_LDFLAGS.dll.os2 ?
= -Zdll
44 TOOL_GCC_LDFLAGS.dll.darwin ?
= -dynamiclib
45 ifndef TOOL_GCC_LDFLAGS.
$(KBUILD_TARGET
)
46 TOOL_GCC_LDFLAGS.dll ?
= -shared
48 TOOL_GCC_LDFLAGS.dll ?
= $(TOOL_GCC_LDFLAGS.
$(KBUILD_TARGET
))
51 # General Properties used by kBuild
52 TOOL_GCC_COBJSUFF ?
= .o
54 TOOL_GCC_CFLAGS.debug ?
= -g
55 TOOL_GCC_CFLAGS.profile ?
= -g
-O2
#-pg
56 TOOL_GCC_CFLAGS.release ?
= -O2
60 TOOL_GCC_CXXOBJSUFF ?
= .o
61 TOOL_GCC_CXXOBJSUFF ?
= .o
63 TOOL_GCC_CXXFLAGS.debug ?
= -g
-O0
64 TOOL_GCC_CXXFLAGS.profile ?
= -g
-O2
#-pg
65 TOOL_GCC_CXXFLAGS.release ?
= -O2
69 TOOL_GCC_ASFLAGS ?
= -x assembler-with-cpp
70 TOOL_GCC_ASFLAGS.debug ?
= -g
71 TOOL_GCC_ASFLAGS.profile ?
= -g
72 TOOL_GCC_ASOBJSUFF ?
= .o
74 TOOL_GCC_ARFLAGS ?
= cr
75 TOOL_GCC_ARLIBSUFF ?
= .a
78 TOOL_GCC_LDFLAGS.debug ?
= -g
79 TOOL_GCC_LDFLAGS.profile ?
= -g
83 # @param $(target) Normalized main target name.
84 # @param $(source) Source filename (relative).
85 # @param $(obj) Object file name. This shall be (re)created by the compilation.
86 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
87 # @param $(flags) Flags.
88 # @param $(defs) Definitions. No -D or something.
89 # @param $(incs) Includes. No -I or something.
90 # @param $(dirdep) Directory creation dependency.
91 # @param $(deps) Other dependencies.
92 # @param $(outbase) Output basename (full). Use this for list files and such.
93 # @param $(objsuff) Object suffix.
95 TOOL_GCC_COMPILE_C_OUTPUT
=
96 TOOL_GCC_COMPILE_C_DEPEND
=
97 TOOL_GCC_COMPILE_C_DEPORD
=
98 define TOOL_GCC_COMPILE_C_CMDS
99 $(QUIET
)$(TOOL_GCC_CC
) -c\
100 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
101 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) \
107 ## Compile C++ source.
108 # @param $(target) Normalized main target name.
109 # @param $(source) Source filename (relative).
110 # @param $(obj) Object file name. This shall be (re)created by the compilation.
111 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
112 # @param $(flags) Flags.
113 # @param $(defs) Definitions. No -D or something.
114 # @param $(incs) Includes. No -I or something.
115 # @param $(dirdep) Directory creation dependency.
116 # @param $(deps) Other dependencies.
118 # @param $(outbase) Output basename (full). Use this for list files and such.
119 # @param $(objsuff) Object suffix.
120 TOOL_GCC_COMPILE_CXX_OUTPUT
=
121 TOOL_GCC_COMPILE_CXX_DEPEND
=
122 TOOL_GCC_COMPILE_CXX_DEPORD
=
123 define TOOL_GCC_COMPILE_CXX_CMDS
124 $(QUIET
)$(TOOL_GCC_CXX
) -c\
125 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
126 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) \
132 ## Compile Assembly source.
133 # @param $(target) Normalized main target name.
134 # @param $(source) Source filename (relative).
135 # @param $(obj) Object file name. This shall be (re)created by the compilation.
136 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
137 # @param $(flags) Flags.
138 # @param $(defs) Definitions. No -D or something.
139 # @param $(incs) Includes. No -I or something.
140 # @param $(dirdep) Directory creation dependency.
141 # @param $(deps) Other dependencies.
142 # @param $(outbase) Output basename (full). Use this for list files and such.
143 # @param $(objsuff) Object suffix.
145 TOOL_GCC_COMPILE_AS_OUTPUT
=
146 TOOL_GCC_COMPILE_AS_DEPEND
=
147 TOOL_GCC_COMPILE_AS_DEPORD
=
148 define TOOL_GCC_COMPILE_AS_CMDS
149 $(QUIET
)$(TOOL_GCC_AS
) -c\
150 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
151 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) \
158 # @param $(target) Normalized main target name.
159 # @param $(out) Library name.
160 # @param $(objs) Object files to put in the library.
161 # @param $(flags) Flags.
162 # @param $(dirdep) Directory creation dependency.
163 # @param $(deps) Other dependencies.
165 # @param $(outbase) Output basename (full). Use this for list files and such.
166 TOOL_GCC_LINK_LIBRARY_OUTPUT
=
167 TOOL_GCC_LINK_LIBRARY_DEPEND
=
168 TOOL_GCC_LINK_LIBRARY_DEPORD
=
169 define TOOL_GCC_LINK_LIBRARY_CMDS
170 $(QUIET
)$(TOOL_GCC_AR
) $(flags
) $(out
) $(objs
)
171 $(call xargs
,$(QUIET
)$(TOOL_GCC_AR
) $(flags
) $(out
),$(objs
))
172 $(foreach lib
,$(othersrc
)\
173 ,$(NL
)$(TAB
)$(call MSG_AR_MERGE
,$(target
),$(out
),$(lib
)) \
174 $(NL
)$(TAB
)$(QUIET
)$(RM_EXT
) -f
$(dir $(outbase
))ar.tmp.
dir/* \
175 $(NL
)$(TAB
)$(QUIET
)$(MKDIR
) -p
$(dir $(outbase
))/ar.tmp.
dir/ \
176 $(NL
)$(TAB
)$(QUIET
)(cd
$(dir $(outbase
))ar.tmp.
dir/ \
177 && $(TOOL_GCC_AR
) x
$(abspath
$(lib
)) \
178 && $(TOOL_GCC_AR
) $(flags
) $(out
) *) \
179 $(NL
)$(TAB
)$(QUIET
)$(RM_EXT
) -f
$(dir $(outbase
))/ar.tmp.
dir/* \
180 $(NL
)$(TAB
)$(QUIET
)$(RMDIR
) $(dir $(outbase
))ar.tmp.
dir/)
181 $(QUIET
)$(TOOL_GCC_RANLIB
) $(out
)
186 # @param $(target) Normalized main target name.
187 # @param $(out) Program name.
188 # @param $(objs) Object files to link together.
189 # @param $(libs) Libraries to search.
190 # @param $(libpath) Library search paths.
191 # @param $(flags) Flags.
192 # @param $(dirdep) Directory creation dependency.
193 # @param $(deps) Other dependencies.
194 # @param $(othersrc) Unhandled sources.
195 # @param $(custom_pre) Custom step invoked before linking.
196 # @param $(custom_post) Custom step invoked after linking.
198 # @param $(outbase) Output basename (full). Use this for list files and such.
199 TOOL_GCC_LINK_PROGRAM_OUTPUT
=
200 TOOL_GCC_LINK_PROGRAM_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))
201 TOOL_GCC_LINK_PROGRAM_DEPORD
=
202 define TOOL_GCC_LINK_PROGRAM_CMDS
203 $(QUIET
)$(TOOL_GCC_LD
) $(flags
) -o
$(out
) $(objs
) \
204 $(foreach lib
,$(libs
), $(if
$(findstring $(lib
),$(subst /,x
,$(lib
))), -l
$(patsubst lib
%,%,$(lib
)), $(lib
)))
209 # @param $(target) Normalized main target name.
210 # @param $(out) Program name.
211 # @param $(objs) Object files to link together.
212 # @param $(libs) Libraries to search.
213 # @param $(libpath) Library search paths.
214 # @param $(flags) Flags.
215 # @param $(dirdep) Directory creation dependency.
216 # @param $(deps) Other dependencies.
217 # @param $(othersrc) Unhandled sources.
218 # @param $(custom_pre) Custom step invoked before linking.
219 # @param $(custom_post) Custom step invoked after linking.
220 # @param $(outbase) Output basename (full). Use this for list files and such.
221 TOOL_GCC_LINK_DLL_OUTPUT
=
222 TOOL_GCC_LINK_DLL_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))
223 TOOL_GCC_LINK_DLL_DEPORD
=
224 define TOOL_GCC_LINK_DLL_CMDS
225 $(QUIET
)$(TOOL_GCC_LD
) $(TOOL_GCC_LDFLAGS.dll
) $(flags
) -o
$(out
) $(objs
) \
226 $(foreach lib
,$(libs
), $(if
$(findstring $(lib
),$(subst /,x
,$(lib
))), -l
$(patsubst lib
%,%,$(lib
)), $(lib
)))