source: trunk/kBuild/tools/GCC.kmk

Last change on this file was 3566, checked in by bird, 3 years ago

tools/G*.kmk,header.kmk: Use qaddprefix in sh-mode for -D and -I processing, just like VCC14*.kmk does. Forced update of header.kmk so KMK_REVISION can be used to detect the changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1# $Id: GCC.kmk 3566 2022-06-13 15:37:08Z bird $
2## @file
3# kBuild Tool Config - Generic GCC Using The System GCC.
4#
5
6#
7# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
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# 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.
31#
32#
33
34TOOL_GCC := Generic GCC Using The System GCC.
35
36# Tool Specific Properties
37ifndef TOOL_GCC_PREFIX
38 TOOL_GCC_PREFIX :=
39endif
40ifndef TOOL_GCC_SUFFIX
41 TOOL_GCC_SUFFIX := $(HOSTSUFF_EXE)
42endif
43TOOL_GCC_PREFIX2 ?= $(TOOL_GCC_PREFIX)
44TOOL_GCC_SUFFIX2 ?= $(TOOL_GCC_SUFFIX)
45TOOL_GCC_CC ?= $(TOOL_GCC_PREFIX)gcc$(TOOL_GCC_SUFFIX)
46TOOL_GCC_CXX ?= $(TOOL_GCC_PREFIX)g++$(TOOL_GCC_SUFFIX)
47TOOL_GCC_AS ?= $(TOOL_GCC_PREFIX)gcc$(TOOL_GCC_SUFFIX)
48TOOL_GCC_AR ?= $(TOOL_GCC_PREFIX2)ar$(TOOL_GCC_SUFFIX2)
49TOOL_GCC_RANLIB ?= $(TOOL_GCC_PREFIX2)ranlib$(TOOL_GCC_SUFFIX2)
50TOOL_GCC_LD ?= $(TOOL_GCC_PREFIX)gcc$(TOOL_GCC_SUFFIX)
51TOOL_GCC_LDFLAGS.dll.os2 ?= -Zdll
52TOOL_GCC_LDFLAGS.dll.darwin ?= -dynamiclib
53ifndef TOOL_GCC_LDFLAGS.$(KBUILD_TARGET)
54 TOOL_GCC_LDFLAGS.dll ?= -shared
55else
56 TOOL_GCC_LDFLAGS.dll ?= $(TOOL_GCC_LDFLAGS.$(KBUILD_TARGET))
57endif
58
59# General Properties used by kBuild
60TOOL_GCC_COBJSUFF ?= .o
61TOOL_GCC_CFLAGS ?=
62TOOL_GCC_CFLAGS.debug ?= -g
63TOOL_GCC_CFLAGS.profile ?= -g -O2 #-pg
64TOOL_GCC_CFLAGS.release ?= -O2
65TOOL_GCC_CINCS ?=
66TOOL_GCC_CDEFS ?=
67
68TOOL_GCC_CXXOBJSUFF ?= .o
69TOOL_GCC_CXXOBJSUFF ?= .o
70TOOL_GCC_CXXFLAGS ?=
71TOOL_GCC_CXXFLAGS.debug ?= -g -O0
72TOOL_GCC_CXXFLAGS.profile ?= -g -O2 #-pg
73TOOL_GCC_CXXFLAGS.release ?= -O2
74TOOL_GCC_CXXINCS ?=
75TOOL_GCC_CXXDEFS ?=
76
77TOOL_GCC_ASFLAGS ?= -x assembler-with-cpp
78TOOL_GCC_ASFLAGS.debug ?= -g
79TOOL_GCC_ASFLAGS.profile ?= -g
80TOOL_GCC_ASOBJSUFF ?= .o
81
82TOOL_GCC_ARFLAGS ?= cr
83TOOL_GCC_ARLIBSUFF ?= .a
84
85TOOL_GCC_LDFLAGS ?=
86TOOL_GCC_LDFLAGS.debug ?= -g
87TOOL_GCC_LDFLAGS.profile ?= -g
88
89
90## Compile C source.
91# @param $(target) Normalized main target name.
92# @param $(source) Source filename (relative).
93# @param $(obj) Object file name. This shall be (re)created by the compilation.
94# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
95# @param $(flags) Flags.
96# @param $(defs) Definitions. No -D or something.
97# @param $(incs) Includes. No -I or something.
98# @param $(dirdep) Directory creation dependency.
99# @param $(deps) Other dependencies.
100# @param $(outbase) Output basename (full). Use this for list files and such.
101# @param $(objsuff) Object suffix.
102#
103TOOL_GCC_COMPILE_C_OUTPUT =
104TOOL_GCC_COMPILE_C_DEPEND =
105TOOL_GCC_COMPILE_C_DEPORD =
106define TOOL_GCC_COMPILE_C_CMDS
107 $(QUIET)$(TOOL_GCC_CC) -c\
108 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
109 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
110 -o $(obj)\
111 $(abspath $(source))
112 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
113endef
114
115
116## Compile C++ source.
117# @param $(target) Normalized main target name.
118# @param $(source) Source filename (relative).
119# @param $(obj) Object file name. This shall be (re)created by the compilation.
120# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
121# @param $(flags) Flags.
122# @param $(defs) Definitions. No -D or something.
123# @param $(incs) Includes. No -I or something.
124# @param $(dirdep) Directory creation dependency.
125# @param $(deps) Other dependencies.
126#
127# @param $(outbase) Output basename (full). Use this for list files and such.
128# @param $(objsuff) Object suffix.
129TOOL_GCC_COMPILE_CXX_OUTPUT =
130TOOL_GCC_COMPILE_CXX_DEPEND =
131TOOL_GCC_COMPILE_CXX_DEPORD =
132define TOOL_GCC_COMPILE_CXX_CMDS
133 $(QUIET)$(TOOL_GCC_CXX) -c\
134 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
135 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
136 -o $(obj)\
137 $(abspath $(source))
138 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
139endef
140
141
142## Compile Assembly source.
143# @param $(target) Normalized main target name.
144# @param $(source) Source filename (relative).
145# @param $(obj) Object file name. This shall be (re)created by the compilation.
146# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
147# @param $(flags) Flags.
148# @param $(defs) Definitions. No -D or something.
149# @param $(incs) Includes. No -I or something.
150# @param $(dirdep) Directory creation dependency.
151# @param $(deps) Other dependencies.
152# @param $(outbase) Output basename (full). Use this for list files and such.
153# @param $(objsuff) Object suffix.
154#
155TOOL_GCC_COMPILE_AS_OUTPUT =
156TOOL_GCC_COMPILE_AS_DEPEND =
157TOOL_GCC_COMPILE_AS_DEPORD =
158define TOOL_GCC_COMPILE_AS_CMDS
159 $(QUIET)$(TOOL_GCC_AS) -c\
160 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
161 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
162 -o $(obj)\
163 $(abspath $(source))
164 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
165endef
166
167
168## Link library
169# @param $(target) Normalized main target name.
170# @param $(out) Library name.
171# @param $(objs) Object files to put in the library.
172# @param $(flags) Flags.
173# @param $(dirdep) Directory creation dependency.
174# @param $(deps) Other dependencies.
175#
176# @param $(outbase) Output basename (full). Use this for list files and such.
177TOOL_GCC_LINK_LIBRARY_OUTPUT =
178TOOL_GCC_LINK_LIBRARY_DEPEND =
179TOOL_GCC_LINK_LIBRARY_DEPORD =
180define TOOL_GCC_LINK_LIBRARY_CMDS
181 $(QUIET)$(TOOL_GCC_AR) $(flags) $(out) $(objs)
182 $(call xargs,$(QUIET)$(TOOL_GCC_AR) $(flags) $(out),$(objs))
183 $(foreach lib,$(othersrc)\
184 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
185 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
186 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
187 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
188 && $(TOOL_GCC_AR) x $(abspath $(lib)) \
189 && $(TOOL_GCC_AR) $(flags) $(out) *) \
190 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
191 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
192 $(QUIET)$(TOOL_GCC_RANLIB) $(out)
193endef
194
195
196## Link program
197# @param $(target) Normalized main target name.
198# @param $(out) Program name.
199# @param $(objs) Object files to link together.
200# @param $(libs) Libraries to search.
201# @param $(libpath) Library search paths.
202# @param $(flags) Flags.
203# @param $(dirdep) Directory creation dependency.
204# @param $(deps) Other dependencies.
205# @param $(othersrc) Unhandled sources.
206# @param $(custom_pre) Custom step invoked before linking.
207# @param $(custom_post) Custom step invoked after linking.
208#
209# @param $(outbase) Output basename (full). Use this for list files and such.
210TOOL_GCC_LINK_PROGRAM_OUTPUT =
211TOOL_GCC_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
212TOOL_GCC_LINK_PROGRAM_DEPORD =
213define TOOL_GCC_LINK_PROGRAM_CMDS
214 $(QUIET)$(TOOL_GCC_LD) $(flags) -o $(out) $(objs) \
215 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
216endef
217
218
219## Link DLL
220# @param $(target) Normalized main target name.
221# @param $(out) Program name.
222# @param $(objs) Object files to link together.
223# @param $(libs) Libraries to search.
224# @param $(libpath) Library search paths.
225# @param $(flags) Flags.
226# @param $(dirdep) Directory creation dependency.
227# @param $(deps) Other dependencies.
228# @param $(othersrc) Unhandled sources.
229# @param $(custom_pre) Custom step invoked before linking.
230# @param $(custom_post) Custom step invoked after linking.
231# @param $(outbase) Output basename (full). Use this for list files and such.
232TOOL_GCC_LINK_DLL_OUTPUT =
233TOOL_GCC_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
234TOOL_GCC_LINK_DLL_DEPORD =
235define TOOL_GCC_LINK_DLL_CMDS
236 $(QUIET)$(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
237 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
238endef
239
Note: See TracBrowser for help on using the repository browser.