1 | # $Id: GCC3.kmk 143 2004-09-02 14:57:05Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild Tool Config - Generic 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 |
|
---|
27 | TOOL_GCC3 := Generic GCC v3
|
---|
28 |
|
---|
29 | TOOL_GCC3_CC := gcc$(HOSTSUFF_EXE)
|
---|
30 | TOOL_GCC3_COBJSUFF := .o
|
---|
31 | TOOL_GCC3_CFLAGS := -g
|
---|
32 | TOOL_GCC3_CFLAGS.debug := -O0
|
---|
33 | TOOL_GCC3_CFLAGS.release := -O2
|
---|
34 | TOOL_GCC3_CFLAGS.profile := -pg
|
---|
35 | TOOL_GCC3_CINCS :=
|
---|
36 | TOOL_GCC3_CDEFS :=
|
---|
37 |
|
---|
38 | TOOL_GCC3_CXX := g++$(HOSTSUFF_EXE)
|
---|
39 | TOOL_GCC3_CXXOBJSUFF := .o
|
---|
40 | TOOL_GCC3_CXXOBJSUFF := .o
|
---|
41 | TOOL_GCC3_CXXFLAGS := -g
|
---|
42 | TOOL_GCC3_CXXFLAGS.debug := -O0
|
---|
43 | TOOL_GCC3_CXXFLAGS.release := -O2
|
---|
44 | TOOL_GCC3_CXXFLAGS.profile := -pg
|
---|
45 | TOOL_GCC3_CXXINCS :=
|
---|
46 | TOOL_GCC3_CXXDEFS :=
|
---|
47 |
|
---|
48 | TOOL_GCC3_AS := as$(HOSTSUFF_EXE)
|
---|
49 | TOOL_GCC3_ASOBJSUFF := .o
|
---|
50 |
|
---|
51 | TOOL_GCC3_AR := ar$(HOSTSUFF_EXE)
|
---|
52 | TOOL_GCC3_ARFLAGS := cr
|
---|
53 | TOOL_GCC3_ARLIBSUFF := .a
|
---|
54 |
|
---|
55 | TOOL_GCC3_LD := g++$(HOSTSUFF_EXE)
|
---|
56 | TOOL_GCC3_LD_SYSMOD := ld$(HOSTSUFF_EXE)
|
---|
57 | TOOL_GCC3_LDFLAGS :=
|
---|
58 | TOOL_GCC3_LDFLAGS.debug := -g
|
---|
59 | TOOL_GCC3_LDFLAGS.release := -s
|
---|
60 | ifndef TOOL_GCC3_LDFLAGS.$(BUILD_TARGET)
|
---|
61 | TOOL_GCC3_LDFLAGS.dll := -shared
|
---|
62 | else
|
---|
63 | TOOL_GCC3_LDFLAGS.dll := $(TOOL_GCC3_LDFLAGS.$(BUILD_TARGET))
|
---|
64 | endif
|
---|
65 | TOOL_GCC3_LDFLAGS.sysmod := -r
|
---|
66 |
|
---|
67 | ifdef SLKRUNS
|
---|
68 | TOOL_GCC3_CC += -fmessage-length=0
|
---|
69 | TOOL_GCC3_CXX += -fmessage-length=0
|
---|
70 | endif
|
---|
71 |
|
---|
72 |
|
---|
73 | ## Compile C source.
|
---|
74 | # @param $(target) Normalized main target name.
|
---|
75 | # @param $(source) Source filename (relative).
|
---|
76 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
77 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
78 | # @param $(flags) Flags.
|
---|
79 | # @param $(defs) Definitions. No -D or something.
|
---|
80 | # @param $(incs) Includes. No -I or something.
|
---|
81 | # @param $(dirdep) Directory creation dependency.
|
---|
82 | #
|
---|
83 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
84 | # @param $(objsuff) Object suffix.
|
---|
85 | define TOOL_GCC3_COMPILE_C
|
---|
86 | #$ (warning dbg: TOOL_GCC3_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
---|
87 | $(obj): $(dirdep) $(source)
|
---|
88 | $(call MSG_L2,Compiling $$@ using GCC3)
|
---|
89 | $(TOOL_GCC3_CC) -c\
|
---|
90 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
91 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
---|
92 | -o $$@\
|
---|
93 | $(call ABSPATH,$(source))
|
---|
94 |
|
---|
95 | endef
|
---|
96 |
|
---|
97 |
|
---|
98 | ## Compile C++ source.
|
---|
99 | # @param $(target) Normalized main target name.
|
---|
100 | # @param $(source) Source filename (relative).
|
---|
101 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
102 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
103 | # @param $(flags) Flags.
|
---|
104 | # @param $(defs) Definitions. No -D or something.
|
---|
105 | # @param $(incs) Includes. No -I or something.
|
---|
106 | # @param $(dirdep) Directory creation dependency.
|
---|
107 | #
|
---|
108 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
109 | # @param $(objsuff) Object suffix.
|
---|
110 | define TOOL_GCC3_COMPILE_CXX
|
---|
111 | #$ (warning dbg: TOOL_GCC3_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
---|
112 | $(obj): $(dirdep) $(source)
|
---|
113 | $(call MSG_L2,Compiling $$@ using GCC3)
|
---|
114 | $(TOOL_GCC3_CXX) -c\
|
---|
115 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
116 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
---|
117 | -o $$@\
|
---|
118 | $(call ABSPATH,$(source))
|
---|
119 |
|
---|
120 | endef
|
---|
121 |
|
---|
122 |
|
---|
123 | ## Link library
|
---|
124 | # @param $(target) Normalized main target name.
|
---|
125 | # @param $(lib) Library name.
|
---|
126 | # @param $(objs) Object files to put in the library.
|
---|
127 | # @param $(flags) Flags.
|
---|
128 | # @param $(dirdep) Directory creation dependency.
|
---|
129 | # @param $(deps) Other dependencies.
|
---|
130 | #
|
---|
131 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
132 | define TOOL_GCC3_LINK_LIBRARY
|
---|
133 | #$ (warning dbg: TOOL_GCC3_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
|
---|
134 | $(lib): $(dirdep) $(objs) $(deps)
|
---|
135 | $(call MSG_L1,Creating Library $$@)
|
---|
136 | $(RM) -f $$@
|
---|
137 | $(TOOL_GCC3_AR) $(flags) $$@ $(objs)
|
---|
138 |
|
---|
139 | endef
|
---|
140 |
|
---|
141 |
|
---|
142 | ## Link program
|
---|
143 | # @param $(target) Normalized main target name.
|
---|
144 | # @param $(exe) Program name.
|
---|
145 | # @param $(objs) Object files to link together.
|
---|
146 | # @param $(libs) Libraries to search.
|
---|
147 | # @param $(libpath) Library search paths.
|
---|
148 | # @param $(flags) Flags.
|
---|
149 | # @param $(dirdep) Directory creation dependency.
|
---|
150 | # @param $(deps) Other dependencies.
|
---|
151 | # @param $(othersrc) Unhandled sources.
|
---|
152 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
153 | # @param $(custom_post) Custom step invoked after linking.
|
---|
154 | #
|
---|
155 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
156 | define TOOL_GCC3_LINK_PROGRAM
|
---|
157 | #$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
---|
158 | $(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
|
---|
159 | $(call MSG_L1,Creating Program $$@)
|
---|
160 | ifneq ($(custom_pre),)
|
---|
161 | $(eval $(custom_pre))
|
---|
162 | endif
|
---|
163 | $(TOOL_GCC3_LD) $(flags) -o $$@ $(objs) \
|
---|
164 | $(foreach p,$(libpath), -L$(p)) \
|
---|
165 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
166 | ifneq ($(custom_post),)
|
---|
167 | $(eval $(custom_post))
|
---|
168 | endif
|
---|
169 |
|
---|
170 | endef
|
---|
171 |
|
---|
172 |
|
---|
173 | ## Link DLL
|
---|
174 | # @param $(target) Normalized main target name.
|
---|
175 | # @param $(dll) Program name.
|
---|
176 | # @param $(objs) Object files to link together.
|
---|
177 | # @param $(libs) Libraries to search.
|
---|
178 | # @param $(libpath) Library search paths.
|
---|
179 | # @param $(flags) Flags.
|
---|
180 | # @param $(dirdep) Directory creation dependency.
|
---|
181 | # @param $(deps) Other dependencies.
|
---|
182 | # @param $(othersrc) Unhandled sources.
|
---|
183 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
184 | # @param $(custom_post) Custom step invoked after linking.
|
---|
185 | #
|
---|
186 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
187 | define TOOL_GCC3_LINK_DLL
|
---|
188 | #$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
---|
189 | $(dll): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
|
---|
190 | $(call MSG_L1,Creating Program $$@)
|
---|
191 | ifneq ($(custom_pre),)
|
---|
192 | $(eval $(custom_pre))
|
---|
193 | endif
|
---|
194 | $(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
|
---|
195 | $(foreach p,$(libpath), -L$(p)) \
|
---|
196 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
197 | ifneq ($(custom_post),)
|
---|
198 | $(eval $(custom_post))
|
---|
199 | endif
|
---|
200 |
|
---|
201 | endef
|
---|
202 |
|
---|
203 | ## Link system module (windows aka driver, linux aka kernel module)
|
---|
204 | # @param $(target) Normalized main target name.
|
---|
205 | # @param $(sys) System module name.
|
---|
206 | # @param $(objs) Object files to link together.
|
---|
207 | # @param $(libs) Libraries to search.
|
---|
208 | # @param $(libpath) Library search paths.
|
---|
209 | # @param $(flags) Flags.
|
---|
210 | # @param $(dirdep) Directory creation dependency.
|
---|
211 | # @param $(deps) Other dependencies.
|
---|
212 | # @param $(othersrc) Unhandled sources.
|
---|
213 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
214 | # @param $(custom_post) Custom step invoked after linking.
|
---|
215 | #
|
---|
216 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
217 | define TOOL_GCC3_LINK_SYSMOD
|
---|
218 | #$ (warning dbg: TOOL_GCC3_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
|
---|
219 | $(sys): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
|
---|
220 | $(call MSG_L1,Creating Program $$@)
|
---|
221 | ifneq ($(custom_pre),)
|
---|
222 | $(eval $(custom_pre))
|
---|
223 | endif
|
---|
224 | $(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $$@ $(objs) \
|
---|
225 | $(foreach p,$(libpath), -L$(p)) \
|
---|
226 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
227 | ifneq ($(custom_post),)
|
---|
228 | $(eval $(custom_post))
|
---|
229 | endif
|
---|
230 |
|
---|
231 | endef
|
---|
232 |
|
---|