1 | # $Id: GCC.kmk 235 2005-02-10 22:38:52Z 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 |
|
---|
28 | TOOL_GCC := Generic GCC
|
---|
29 |
|
---|
30 | TOOL_GCC_CC := gcc$(HOSTSUFF_EXE)
|
---|
31 | TOOL_GCC_COBJSUFF := .o
|
---|
32 | TOOL_GCC_CFLAGS := -g
|
---|
33 | TOOL_GCC_CFLAGS.debug := -O0
|
---|
34 | TOOL_GCC_CFLAGS.release := -O2
|
---|
35 | TOOL_GCC_CFLAGS.profile := -O2 #-pg
|
---|
36 | TOOL_GCC_CINCS :=
|
---|
37 | TOOL_GCC_CDEFS :=
|
---|
38 |
|
---|
39 | TOOL_GCC_CXX := g++$(HOSTSUFF_EXE)
|
---|
40 | TOOL_GCC_CXXOBJSUFF := .o
|
---|
41 | TOOL_GCC_CXXOBJSUFF := .o
|
---|
42 | TOOL_GCC_CXXFLAGS := -g
|
---|
43 | TOOL_GCC_CXXFLAGS.debug := -O0
|
---|
44 | TOOL_GCC_CXXFLAGS.release := -O2
|
---|
45 | TOOL_GCC_CXXFLAGS.profile := -O2 #-pg
|
---|
46 | TOOL_GCC_CXXINCS :=
|
---|
47 | TOOL_GCC_CXXDEFS :=
|
---|
48 |
|
---|
49 | TOOL_GCC_AS := as$(HOSTSUFF_EXE)
|
---|
50 | TOOL_GCC_ASOBJSUFF := .o
|
---|
51 |
|
---|
52 | TOOL_GCC_AR := ar$(HOSTSUFF_EXE)
|
---|
53 | TOOL_GCC_ARFLAGS := cr
|
---|
54 | TOOL_GCC_ARLIBSUFF := .a
|
---|
55 |
|
---|
56 | TOOL_GCC_LD := g++$(HOSTSUFF_EXE)
|
---|
57 | TOOL_GCC_LDFLAGS :=
|
---|
58 | TOOL_GCC_LDFLAGS.debug := -g
|
---|
59 | TOOL_GCC_LDFLAGS.release := -s
|
---|
60 | TOOL_GCC_LDFLAGS.dll.os2 := -Zdll
|
---|
61 | ifndef TOOL_GCC_LDFLAGS.$(BUILD_TARGET)
|
---|
62 | TOOL_GCC_LDFLAGS.dll := -shared
|
---|
63 | else
|
---|
64 | TOOL_GCC_LDFLAGS.dll := $(TOOL_GCC_LDFLAGS.$(BUILD_TARGET))
|
---|
65 | endif
|
---|
66 |
|
---|
67 |
|
---|
68 | ## Compile C source.
|
---|
69 | # @param $(target) Normalized main target name.
|
---|
70 | # @param $(source) Source filename (relative).
|
---|
71 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
72 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
73 | # @param $(flags) Flags.
|
---|
74 | # @param $(defs) Definitions. No -D or something.
|
---|
75 | # @param $(incs) Includes. No -I or something.
|
---|
76 | # @param $(dirdep) Directory creation dependency.
|
---|
77 | # @param $(deps) Other dependencies.
|
---|
78 | #
|
---|
79 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
80 | # @param $(objsuff) Object suffix.
|
---|
81 | define TOOL_GCC_COMPILE_C
|
---|
82 | #$ (warning dbg: TOOL_GCC_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
83 | $(obj): $(PATH_CURRENT)/$(source) $(deps) | $(dirdep)
|
---|
84 | $(call MSG_L2,Compiling $$@ using GCC)
|
---|
85 | $(TOOL_GCC_CC) -c\
|
---|
86 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
87 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
---|
88 | -o $$@\
|
---|
89 | $(call ABSPATH,$(source))
|
---|
90 |
|
---|
91 | endef
|
---|
92 |
|
---|
93 |
|
---|
94 | ## Compile C++ source.
|
---|
95 | # @param $(target) Normalized main target name.
|
---|
96 | # @param $(source) Source filename (relative).
|
---|
97 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
98 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
99 | # @param $(flags) Flags.
|
---|
100 | # @param $(defs) Definitions. No -D or something.
|
---|
101 | # @param $(incs) Includes. No -I or something.
|
---|
102 | # @param $(dirdep) Directory creation dependency.
|
---|
103 | # @param $(deps) Other dependencies.
|
---|
104 | #
|
---|
105 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
106 | # @param $(objsuff) Object suffix.
|
---|
107 | define TOOL_GCC_COMPILE_CXX
|
---|
108 | #$ (warning dbg: TOOL_GCC_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
109 | $(obj): $(source) $(deps) | $(dirdep)
|
---|
110 | $(call MSG_L2,Compiling $$@ using GCC)
|
---|
111 | $(TOOL_GCC_CXX) -c\
|
---|
112 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
113 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
---|
114 | -o $$@\
|
---|
115 | $(call ABSPATH,$(source))
|
---|
116 |
|
---|
117 | endef
|
---|
118 |
|
---|
119 |
|
---|
120 | ## Link library
|
---|
121 | # @param $(target) Normalized main target name.
|
---|
122 | # @param $(lib) Library name.
|
---|
123 | # @param $(objs) Object files to put in the library.
|
---|
124 | # @param $(flags) Flags.
|
---|
125 | # @param $(dirdep) Directory creation dependency.
|
---|
126 | # @param $(deps) Other dependencies.
|
---|
127 | #
|
---|
128 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
129 | define TOOL_GCC_LINK_LIBRARY
|
---|
130 | #$ (warning dbg: TOOL_GCC_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
|
---|
131 | $(lib): $(objs) $(deps) | $(dirdep)
|
---|
132 | $(call MSG_L1,Creating Library $$@)
|
---|
133 | $(RM) -f $$@
|
---|
134 | $(TOOL_GCC_AR) $(flags) $$@ $(objs)
|
---|
135 |
|
---|
136 | endef
|
---|
137 |
|
---|
138 |
|
---|
139 | ## Link program
|
---|
140 | # @param $(target) Normalized main target name.
|
---|
141 | # @param $(exe) Program name.
|
---|
142 | # @param $(objs) Object files to link together.
|
---|
143 | # @param $(libs) Libraries to search.
|
---|
144 | # @param $(libpath) Library search paths.
|
---|
145 | # @param $(flags) Flags.
|
---|
146 | # @param $(dirdep) Directory creation dependency.
|
---|
147 | # @param $(deps) Other dependencies.
|
---|
148 | # @param $(othersrc) Unhandled sources.
|
---|
149 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
150 | # @param $(custom_post) Custom step invoked after linking.
|
---|
151 | #
|
---|
152 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
153 | define TOOL_GCC_LINK_PROGRAM
|
---|
154 | #$ (warning dbg: TOOL_GCC_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
---|
155 | $(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
|
---|
156 | $(call MSG_L1,Creating Program $$@)
|
---|
157 | ifneq ($(custom_pre),)
|
---|
158 | $(eval $(custom_pre))
|
---|
159 | endif
|
---|
160 | $(TOOL_GCC_LD) $(flags) -o $$@ $(objs) \
|
---|
161 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
162 | ifneq ($(custom_post),)
|
---|
163 | $(eval $(custom_post))
|
---|
164 | endif
|
---|
165 |
|
---|
166 | endef
|
---|
167 |
|
---|
168 |
|
---|
169 | ## Link program
|
---|
170 | # @param $(target) Normalized main target name.
|
---|
171 | # @param $(exe) Program name.
|
---|
172 | # @param $(objs) Object files to link together.
|
---|
173 | # @param $(libs) Libraries to search.
|
---|
174 | # @param $(libpath) Library search paths.
|
---|
175 | # @param $(flags) Flags.
|
---|
176 | # @param $(dirdep) Directory creation dependency.
|
---|
177 | # @param $(deps) Other dependencies.
|
---|
178 | # @param $(othersrc) Unhandled sources.
|
---|
179 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
180 | # @param $(custom_post) Custom step invoked after linking.
|
---|
181 | #
|
---|
182 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
183 | define TOOL_GCC_LINK_DLL
|
---|
184 | #$ (warning dbg: TOOL_GCC_LINK_DLL: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
---|
185 | $(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
|
---|
186 | $(call MSG_L1,Creating Program $$@)
|
---|
187 | ifneq ($(custom_pre),)
|
---|
188 | $(eval $(custom_pre))
|
---|
189 | endif
|
---|
190 | $(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
|
---|
191 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
192 | ifneq ($(custom_post),)
|
---|
193 | $(eval $(custom_post))
|
---|
194 | endif
|
---|
195 |
|
---|
196 | endef
|
---|
197 |
|
---|