1 | # $Id: GXX.kmk 1505 2008-04-09 00:13:14Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild Tool Config - Generic GCC using the system GCC, for building C++ code.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2008 knut st. osmundsen <[email protected]>
|
---|
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 |
|
---|
27 | TOOL_GXX := Generic GCC using the system GCC, for building C++ code.
|
---|
28 |
|
---|
29 | # Tool Specific Properties
|
---|
30 | TOOL_GXX_CC ?= gcc$(HOSTSUFF_EXE)
|
---|
31 | TOOL_GXX_CXX ?= g++$(HOSTSUFF_EXE)
|
---|
32 | TOOL_GXX_AS ?= gcc$(HOSTSUFF_EXE)
|
---|
33 | TOOL_GXX_AR ?= ar$(HOSTSUFF_EXE)
|
---|
34 | TOOL_GXX_RANLIB ?= ranlib$(HOSTSUFF_EXE)
|
---|
35 | TOOL_GXX_LD ?= g++$(HOSTSUFF_EXE)
|
---|
36 | TOOL_GXX_LDFLAGS.dll.os2 ?= -Zdll
|
---|
37 | TOOL_GXX_LDFLAGS.dll.darwin ?= -dynamiclib
|
---|
38 | ifndef TOOL_GXX_LDFLAGS.$(KBUILD_TARGET)
|
---|
39 | TOOL_GXX_LDFLAGS.dll ?= -shared
|
---|
40 | else
|
---|
41 | TOOL_GXX_LDFLAGS.dll ?= $(TOOL_GXX_LDFLAGS.$(KBUILD_TARGET))
|
---|
42 | endif
|
---|
43 |
|
---|
44 | # General Properties used by kBuild
|
---|
45 | TOOL_GXX_COBJSUFF ?= .o
|
---|
46 | TOOL_GXX_CFLAGS ?=
|
---|
47 | TOOL_GXX_CFLAGS.debug ?= -g
|
---|
48 | TOOL_GXX_CFLAGS.profile ?= -g -O2 #-pg
|
---|
49 | TOOL_GXX_CFLAGS.release ?= -O2
|
---|
50 | TOOL_GXX_CINCS ?=
|
---|
51 | TOOL_GXX_CDEFS ?=
|
---|
52 |
|
---|
53 | TOOL_GXX_CXXOBJSUFF ?= .o
|
---|
54 | TOOL_GXX_CXXOBJSUFF ?= .o
|
---|
55 | TOOL_GXX_CXXFLAGS ?=
|
---|
56 | TOOL_GXX_CXXFLAGS.debug ?= -g -O0
|
---|
57 | TOOL_GXX_CXXFLAGS.profile ?= -g -O2 #-pg
|
---|
58 | TOOL_GXX_CXXFLAGS.release ?= -O2
|
---|
59 | TOOL_GXX_CXXINCS ?=
|
---|
60 | TOOL_GXX_CXXDEFS ?=
|
---|
61 |
|
---|
62 | TOOL_GXX_ASFLAGS ?= -x assembler-with-cpp
|
---|
63 | TOOL_GXX_ASFLAGS.debug ?= -g
|
---|
64 | TOOL_GXX_ASFLAGS.profile ?= -g
|
---|
65 | TOOL_GXX_ASOBJSUFF ?= .o
|
---|
66 |
|
---|
67 | TOOL_GXX_ARFLAGS ?= cr
|
---|
68 | TOOL_GXX_ARLIBSUFF ?= .a
|
---|
69 |
|
---|
70 | TOOL_GXX_LDFLAGS ?=
|
---|
71 | TOOL_GXX_LDFLAGS.debug ?= -g
|
---|
72 | TOOL_GXX_LDFLAGS.profile ?= -g
|
---|
73 |
|
---|
74 |
|
---|
75 | ## Compile C source.
|
---|
76 | # @param $(target) Normalized main target name.
|
---|
77 | # @param $(source) Source filename (relative).
|
---|
78 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
79 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
80 | # @param $(flags) Flags.
|
---|
81 | # @param $(defs) Definitions. No -D or something.
|
---|
82 | # @param $(incs) Includes. No -I or something.
|
---|
83 | # @param $(dirdep) Directory creation dependency.
|
---|
84 | # @param $(deps) Other dependencies.
|
---|
85 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
86 | # @param $(objsuff) Object suffix.
|
---|
87 | #
|
---|
88 | TOOL_GXX_COMPILE_C_OUTPUT =
|
---|
89 | TOOL_GXX_COMPILE_C_DEPEND =
|
---|
90 | TOOL_GXX_COMPILE_C_DEPORD =
|
---|
91 | define TOOL_GXX_COMPILE_C_CMDS
|
---|
92 | $(QUIET)$(TOOL_GXX_CC) -c\
|
---|
93 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
94 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
---|
95 | -o $(obj)\
|
---|
96 | $(abspath $(source))
|
---|
97 | endef
|
---|
98 |
|
---|
99 |
|
---|
100 | ## Compile C++ source.
|
---|
101 | # @param $(target) Normalized main target name.
|
---|
102 | # @param $(source) Source filename (relative).
|
---|
103 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
104 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
105 | # @param $(flags) Flags.
|
---|
106 | # @param $(defs) Definitions. No -D or something.
|
---|
107 | # @param $(incs) Includes. No -I or something.
|
---|
108 | # @param $(dirdep) Directory creation dependency.
|
---|
109 | # @param $(deps) Other dependencies.
|
---|
110 | #
|
---|
111 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
112 | # @param $(objsuff) Object suffix.
|
---|
113 | TOOL_GXX_COMPILE_CXX_OUTPUT =
|
---|
114 | TOOL_GXX_COMPILE_CXX_DEPEND =
|
---|
115 | TOOL_GXX_COMPILE_CXX_DEPORD =
|
---|
116 | define TOOL_GXX_COMPILE_CXX_CMDS
|
---|
117 | $(QUIET)$(TOOL_GXX_CXX) -c\
|
---|
118 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
119 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
---|
120 | -o $(obj)\
|
---|
121 | $(abspath $(source))
|
---|
122 | endef
|
---|
123 |
|
---|
124 |
|
---|
125 | ## Compile Assembly source.
|
---|
126 | # @param $(target) Normalized main target name.
|
---|
127 | # @param $(source) Source filename (relative).
|
---|
128 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
129 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
130 | # @param $(flags) Flags.
|
---|
131 | # @param $(defs) Definitions. No -D or something.
|
---|
132 | # @param $(incs) Includes. No -I or something.
|
---|
133 | # @param $(dirdep) Directory creation dependency.
|
---|
134 | # @param $(deps) Other dependencies.
|
---|
135 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
136 | # @param $(objsuff) Object suffix.
|
---|
137 | #
|
---|
138 | TOOL_GXX_COMPILE_AS_OUTPUT =
|
---|
139 | TOOL_GXX_COMPILE_AS_DEPEND =
|
---|
140 | TOOL_GXX_COMPILE_AS_DEPORD =
|
---|
141 | define TOOL_GXX_COMPILE_AS_CMDS
|
---|
142 | $(QUIET)$(TOOL_GXX_AS) -c\
|
---|
143 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
144 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
---|
145 | -o $(obj)\
|
---|
146 | $(abspath $(source))
|
---|
147 | endef
|
---|
148 |
|
---|
149 |
|
---|
150 | ## Link library
|
---|
151 | # @param $(target) Normalized main target name.
|
---|
152 | # @param $(out) Library name.
|
---|
153 | # @param $(objs) Object files to put in the library.
|
---|
154 | # @param $(flags) Flags.
|
---|
155 | # @param $(dirdep) Directory creation dependency.
|
---|
156 | # @param $(deps) Other dependencies.
|
---|
157 | #
|
---|
158 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
159 | TOOL_GXX_LINK_LIBRARY_OUTPUT =
|
---|
160 | TOOL_GXX_LINK_LIBRARY_DEPEND =
|
---|
161 | TOOL_GXX_LINK_LIBRARY_DEPORD =
|
---|
162 | define TOOL_GXX_LINK_LIBRARY_CMDS
|
---|
163 | $(QUIET)$(TOOL_GXX_AR) $(flags) $(out) $(objs)
|
---|
164 | $(call xargs,$(QUIET)$(TOOL_GXX_AR) $(flags) $(out),$(objs))
|
---|
165 | $(foreach lib,$(othersrc)\
|
---|
166 | ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
|
---|
167 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
|
---|
168 | $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
|
---|
169 | $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
|
---|
170 | && $(TOOL_GXX_AR) x $(abspath $(lib)) \
|
---|
171 | && $(TOOL_GXX_AR) $(flags) $(out) *) \
|
---|
172 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
|
---|
173 | $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
|
---|
174 | $(QUIET)$(TOOL_GXX_RANLIB) $(out)
|
---|
175 | endef
|
---|
176 |
|
---|
177 |
|
---|
178 | ## Link program
|
---|
179 | # @param $(target) Normalized main target name.
|
---|
180 | # @param $(out) Program name.
|
---|
181 | # @param $(objs) Object files to link together.
|
---|
182 | # @param $(libs) Libraries to search.
|
---|
183 | # @param $(libpath) Library search paths.
|
---|
184 | # @param $(flags) Flags.
|
---|
185 | # @param $(dirdep) Directory creation dependency.
|
---|
186 | # @param $(deps) Other dependencies.
|
---|
187 | # @param $(othersrc) Unhandled sources.
|
---|
188 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
189 | # @param $(custom_post) Custom step invoked after linking.
|
---|
190 | #
|
---|
191 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
192 | TOOL_GXX_LINK_PROGRAM_OUTPUT =
|
---|
193 | TOOL_GXX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
194 | TOOL_GXX_LINK_PROGRAM_DEPORD =
|
---|
195 | define TOOL_GXX_LINK_PROGRAM_CMDS
|
---|
196 | $(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(objs) \
|
---|
197 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
---|
198 | endef
|
---|
199 |
|
---|
200 |
|
---|
201 | ## Link DLL
|
---|
202 | # @param $(target) Normalized main target name.
|
---|
203 | # @param $(out) Program name.
|
---|
204 | # @param $(objs) Object files to link together.
|
---|
205 | # @param $(libs) Libraries to search.
|
---|
206 | # @param $(libpath) Library search paths.
|
---|
207 | # @param $(flags) Flags.
|
---|
208 | # @param $(dirdep) Directory creation dependency.
|
---|
209 | # @param $(deps) Other dependencies.
|
---|
210 | # @param $(othersrc) Unhandled sources.
|
---|
211 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
212 | # @param $(custom_post) Custom step invoked after linking.
|
---|
213 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
214 | TOOL_GXX_LINK_DLL_OUTPUT =
|
---|
215 | TOOL_GXX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
216 | TOOL_GXX_LINK_DLL_DEPORD =
|
---|
217 | define TOOL_GXX_LINK_DLL_CMDS
|
---|
218 | $(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
|
---|
219 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
---|
220 | endef
|
---|
221 |
|
---|