source: trunk/kBuild/tools/GCC4MACH.kmk@ 558

Last change on this file since 558 was 557, checked in by bird, 19 years ago

Initial Mac OS X / Darwin bootstrapping.

File size: 9.8 KB
Line 
1# $Id: GCC4MACH.kmk 474 2006-07-16 03:43:04Z bird $
2## @file
3#
4# kBuild Tool Config - Darwin / Mac OS X / Mach GCC (v4).
5#
6# Copyright (c) 2004-2006 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
27TOOL_GCC4MACH := Mach GCC v4
28
29TOOL_GCC4MACH_CC := gcc$(HOSTSUFF_EXE)
30TOOL_GCC4MACH_COBJSUFF := .o
31TOOL_GCC4MACH_CFLAGS := -g
32TOOL_GCC4MACH_CFLAGS.debug := -O0
33TOOL_GCC4MACH_CFLAGS.release := -O2
34TOOL_GCC4MACH_CFLAGS.profile := -O2 #-pg
35TOOL_GCC4MACH_CINCS :=
36TOOL_GCC4MACH_CDEFS :=
37
38TOOL_GCC4MACH_CXX := g++$(HOSTSUFF_EXE)
39TOOL_GCC4MACH_CXXOBJSUFF := .o
40TOOL_GCC4MACH_CXXOBJSUFF := .o
41TOOL_GCC4MACH_CXXFLAGS := -g
42TOOL_GCC4MACH_CXXFLAGS.debug := -O0
43TOOL_GCC4MACH_CXXFLAGS.release := -O2
44TOOL_GCC4MACH_CXXFLAGS.profile := -O2 #-pg
45TOOL_GCC4MACH_CXXINCS :=
46TOOL_GCC4MACH_CXXDEFS :=
47
48TOOL_GCC4MACH_AS := gcc$(HOSTSUFF_EXE)
49TOOL_GCC4MACH_ASFLAGS := -g -x assembler-with-cpp
50TOOL_GCC4MACH_ASOBJSUFF := .o
51
52TOOL_GCC4MACH_AR := ar$(HOSTSUFF_EXE)
53TOOL_GCC4MACH_ARFLAGS := -c -rs
54TOOL_GCC4MACH_ARLIBSUFF := .a
55
56TOOL_GCC4MACH_AR_IMP := $(ECHO) not supported!
57
58TOOL_GCC4MACH_LD := g++$(HOSTSUFF_EXE)
59TOOL_GCC4MACH_LD_SYSMOD := ld$(HOSTSUFF_EXE)
60TOOL_GCC4MACH_LDFLAGS :=
61TOOL_GCC4MACH_LDFLAGS.debug := -g
62TOOL_GCC4MACH_LDFLAGS.release := -s
63ifndef TOOL_GCC4MACH_LDFLAGS.$(BUILD_TARGET)
64TOOL_GCC4MACH_LDFLAGS.dll := -shared
65else
66TOOL_GCC4MACH_LDFLAGS.dll := $(TOOL_GCC4MACH_LDFLAGS.$(BUILD_TARGET))
67endif
68TOOL_GCC4MACH_LDFLAGS.sysmod := -r
69TOOL_GCC4MACH_LD_SONAME = -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
70TOOL_GCC4MACH_LD_MAP =
71TOOL_GCC4MACH_LD_SYSMOD_MAP =
72
73ifdef SLKRUNS
74TOOL_GCC4MACH_CC += -fmessage-length=0
75TOOL_GCC4MACH_CXX += -fmessage-length=0
76endif
77
78
79## Compile C source.
80# @param $(target) Normalized main target name.
81# @param $(source) Source filename (relative).
82# @param $(obj) Object file name. This shall be (re)created by the compilation.
83# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
84# @param $(flags) Flags.
85# @param $(defs) Definitions. No -D or something.
86# @param $(incs) Includes. No -I or something.
87# @param $(dirdep) Directory creation dependency.
88# @param $(deps) Other dependencies.
89#
90# @param $(outbase) Output basename (full). Use this for list files and such.
91# @param $(objsuff) Object suffix.
92TOOL_GCC4MACH_COMPILE_C_OUTPUT =
93TOOL_GCC4MACH_COMPILE_C_DEPEND =
94TOOL_GCC4MACH_COMPILE_C_DEPORD =
95define TOOL_GCC4MACH_COMPILE_C_CMDS
96 $(TOOL_GCC4MACH_CC) -c\
97 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
98 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
99 -o $(obj)\
100 $(call ABSPATH,$(source))
101endef
102
103
104## Compile C++ source.
105# @param $(target) Normalized main target name.
106# @param $(source) Source filename (relative).
107# @param $(obj) Object file name. This shall be (re)created by the compilation.
108# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
109# @param $(flags) Flags.
110# @param $(defs) Definitions. No -D or something.
111# @param $(incs) Includes. No -I or something.
112# @param $(dirdep) Directory creation dependency.
113# @param $(deps) Other dependencies.
114# @param $(outbase) Output basename (full). Use this for list files and such.
115# @param $(objsuff) Object suffix.
116TOOL_GCC4MACH_COMPILE_CXX_OUTPUT =
117TOOL_GCC4MACH_COMPILE_CXX_DEPEND =
118TOOL_GCC4MACH_COMPILE_CXX_DEPORD =
119define TOOL_GCC4MACH_COMPILE_CXX_CMDS
120 $(TOOL_GCC4MACH_CXX) -c\
121 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
122 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
123 -o $(obj)\
124 $(call ABSPATH,$(source))
125endef
126
127
128## Compile Assembly source.
129# @param $(target) Normalized main target name.
130# @param $(source) Source filename (relative).
131# @param $(obj) Object file name. This shall be (re)created by the compilation.
132# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
133# @param $(flags) Flags.
134# @param $(defs) Definitions. No -D or something.
135# @param $(incs) Includes. No -I or something.
136# @param $(dirdep) Directory creation dependency.
137# @param $(deps) Other dependencies.
138# @param $(outbase) Output basename (full). Use this for list files and such.
139# @param $(objsuff) Object suffix.
140#
141TOOL_GCC4MACH_COMPILE_AS_OUTPUT =
142TOOL_GCC4MACH_COMPILE_AS_DEPEND =
143TOOL_GCC4MACH_COMPILE_AS_DEPORD =
144define TOOL_GCC4MACH_COMPILE_AS_CMDS
145 $(TOOL_GCC4MACH_AS) -c\
146 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
147 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
148 -o $(obj)\
149 $(call ABSPATH,$(source))
150endef
151
152
153## Link library
154# @param $(target) Normalized main target name.
155# @param $(out) Library name.
156# @param $(objs) Object files to put in the library.
157# @param $(flags) Flags.
158# @param $(dirdep) Directory creation dependency.
159# @param $(deps) Other dependencies.
160# @param $(othersrc) Unhandled sources.
161# @param $(outbase) Output basename (full). Use this for list files and such.
162TOOL_GCC4MACH_LINK_LIBRARY_OUTPUT =
163TOOL_GCC4MACH_LINK_LIBRARY_DEPEND = $(filter %.a %.lib %.def %.imp,$(othersrc))
164TOOL_GCC4MACH_LINK_LIBRARY_DEPORD =
165define TOOL_GCC4MACH_LINK_LIBRARY_CMDS
166 $(TOOL_GCC4MACH_AR) $(flags) $(out) $(objs) $(filter %.a %.lib, $(othersrc))
167endef
168
169
170## Link program
171# @param $(target) Normalized main target name.
172# @param $(out) Program name.
173# @param $(objs) Object files to link together.
174# @param $(libs) Libraries to search.
175# @param $(libpath) Library search paths.
176# @param $(flags) Flags.
177# @param $(dirdep) Directory creation dependency.
178# @param $(deps) Other dependencies.
179# @param $(othersrc) Unhandled sources.
180# @param $(custom_pre) Custom step invoked before linking.
181# @param $(custom_post) Custom step invoked after linking.
182# @param $(outbase) Output basename (full). Use this for list files and such.
183TOOL_GCC4MACH_LINK_PROGRAM_OUTPUT = $(outbase).map
184TOOL_GCC4MACH_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
185TOOL_GCC4MACH_LINK_PROGRAM_DEPORD =
186define TOOL_GCC4MACH_LINK_PROGRAM_CMDS
187 $(TOOL_GCC4MACH_LD) $(flags) -o $(out) $(objs)\
188 $(foreach p,$(libpath), -L$(p))\
189 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
190 $(call TOOL_GCC4MACH_LD_MAP,$(outbase).map)
191endef
192
193
194## Link DLL
195# @param $(target) Normalized main target name.
196# @param $(out) Program name.
197# @param $(objs) Object files to link together.
198# @param $(libs) Libraries to search.
199# @param $(libpath) Library search paths.
200# @param $(flags) Flags.
201# @param $(dirdep) Directory creation dependency.
202# @param $(deps) Other dependencies.
203# @param $(othersrc) Unhandled sources.
204# @param $(custom_pre) Custom step invoked before linking.
205# @param $(custom_post) Custom step invoked after linking.
206# @param $(outbase) Output basename (full). Use this for list files and such.
207TOOL_GCC4MACH_LINK_DLL_OUTPUT = $(outbase).map
208TOOL_GCC4MACH_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
209TOOL_GCC4MACH_LINK_DLL_DEPORD =
210define TOOL_GCC4MACH_LINK_DLL_CMDS
211 $(TOOL_GCC4MACH_LD) $(TOOL_GCC4MACH_LDFLAGS.dll) $(flags) -o $(out)\
212 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC4MACH_LD_SONAME,$(target),$(out)))\
213 $(objs)\
214 $(foreach p,$(libpath), -L$(p))\
215 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
216 $(call TOOL_GCC4MACH_LD_MAP,$(outbase).map)
217endef
218
219
220## Link system module (windows aka driver, linux aka kernel module)
221# @param $(target) Normalized main target name.
222# @param $(out) System module name.
223# @param $(objs) Object files to link together.
224# @param $(libs) Libraries to search.
225# @param $(libpath) Library search paths.
226# @param $(flags) Flags.
227# @param $(dirdep) Directory creation dependency.
228# @param $(deps) Other dependencies.
229# @param $(othersrc) Unhandled sources.
230# @param $(custom_pre) Custom step invoked before linking.
231# @param $(custom_post) Custom step invoked after linking.
232# @param $(outbase) Output basename (full). Use this for list files and such.
233TOOL_GCC4MACH_LINK_SYSMOD_OUTPUT = $(outbase).map
234TOOL_GCC4MACH_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
235TOOL_GCC4MACH_LINK_SYSMOD_DEPORD =
236define TOOL_GCC4MACH_LINK_SYSMOD_CMDS
237 $(TOOL_GCC4MACH_LD_SYSMOD) $(TOOL_GCC4MACH_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
238 $(foreach p,$(libpath), -L$(p))\
239 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
240 $(call TOOL_GCC4MACH_LD_SYSMOD_MAP,$(outbase).map)
241endef
242
Note: See TracBrowser for help on using the repository browser.