1 | # $Id: GCC4MACH.kmk 474 2006-07-16 03:43:04Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild Tool Config - Darwin / Mac OS X / Mach-O 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 |
|
---|
27 | TOOL_GCC4MACHO := Mach-O GCC v4
|
---|
28 |
|
---|
29 | TOOL_GCC4MACHO_CC ?= gcc$(HOSTSUFF_EXE)
|
---|
30 | TOOL_GCC4MACHO_COBJSUFF ?= .o
|
---|
31 | TOOL_GCC4MACHO_CFLAGS ?=
|
---|
32 | TOOL_GCC4MACHO_CFLAGS.debug ?= -g
|
---|
33 | TOOL_GCC4MACHO_CFLAGS.profile ?= -g -O2 #-pg
|
---|
34 | TOOL_GCC4MACHO_CFLAGS.release ?= -O2
|
---|
35 | TOOL_GCC4MACHO_CINCS ?=
|
---|
36 | TOOL_GCC4MACHO_CDEFS ?=
|
---|
37 |
|
---|
38 | TOOL_GCC4MACHO_CXX ?= g++$(HOSTSUFF_EXE)
|
---|
39 | TOOL_GCC4MACHO_CXXOBJSUFF ?= .o
|
---|
40 | TOOL_GCC4MACHO_CXXOBJSUFF ?= .o
|
---|
41 | TOOL_GCC4MACHO_CXXFLAGS ?=
|
---|
42 | TOOL_GCC4MACHO_CXXFLAGS.debug ?= -g
|
---|
43 | TOOL_GCC4MACHO_CXXFLAGS.profile ?= -g -O2 #-pg
|
---|
44 | TOOL_GCC4MACHO_CXXFLAGS.release ?= -O2
|
---|
45 | TOOL_GCC4MACHO_CXXINCS ?=
|
---|
46 | TOOL_GCC4MACHO_CXXDEFS ?=
|
---|
47 |
|
---|
48 | TOOL_GCC4MACHO_AS ?= gcc$(HOSTSUFF_EXE)
|
---|
49 | TOOL_GCC4MACHO_ASFLAGS ?= -x assembler-with-cpp
|
---|
50 | TOOL_GCC4MACHO_ASFLAGS.debug ?= -g
|
---|
51 | TOOL_GCC4MACHO_ASFLAGS.profile ?= -g
|
---|
52 | TOOL_GCC4MACHO_ASOBJSUFF ?= .o
|
---|
53 |
|
---|
54 | TOOL_GCC4MACHO_AR ?= ar$(HOSTSUFF_EXE)
|
---|
55 | TOOL_GCC4MACHO_ARFLAGS ?= -c -rs
|
---|
56 | TOOL_GCC4MACHO_ARLIBSUFF ?= .a
|
---|
57 |
|
---|
58 | TOOL_GCC4MACHO_AR_IMP ?= $(ECHO) not supported!
|
---|
59 |
|
---|
60 | TOOL_GCC4MACHO_LD ?= g++$(HOSTSUFF_EXE)
|
---|
61 | TOOL_GCC4MACHO_LD_SYSMOD ?= g++$(HOSTSUFF_EXE)
|
---|
62 | TOOL_GCC4MACHO_LDFLAGS ?=
|
---|
63 | TOOL_GCC4MACHO_LDFLAGS.debug ?= -g
|
---|
64 | TOOL_GCC4MACHO_LDFLAGS.profile ?= -g
|
---|
65 | ifndef TOOL_GCC4MACHO_LDFLAGS.$(BUILD_TARGET)
|
---|
66 | TOOL_GCC4MACHO_LDFLAGS.dll ?= -dynamiclib
|
---|
67 | else
|
---|
68 | TOOL_GCC4MACHO_LDFLAGS.dll ?= $(TOOL_GCC4MACHO_LDFLAGS.$(BUILD_TARGET))
|
---|
69 | endif
|
---|
70 | TOOL_GCC4MACHO_LDFLAGS.sysmod ?= -r
|
---|
71 | #TOOL_GCC4MACHO_LD_SONAME = -Wl,-dylib_install_name $(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
---|
72 | TOOL_GCC4MACHO_LD_MAP ?=
|
---|
73 | TOOL_GCC4MACHO_LD_SYSMOD_MAP ?=
|
---|
74 |
|
---|
75 | ifdef SLKRUNS
|
---|
76 | TOOL_GCC4MACHO_CC += -fmessage-length=0
|
---|
77 | TOOL_GCC4MACHO_CXX += -fmessage-length=0
|
---|
78 | endif
|
---|
79 |
|
---|
80 |
|
---|
81 | ## Compile C source.
|
---|
82 | # @param $(target) Normalized main target name.
|
---|
83 | # @param $(source) Source filename (relative).
|
---|
84 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
85 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
86 | # @param $(flags) Flags.
|
---|
87 | # @param $(defs) Definitions. No -D or something.
|
---|
88 | # @param $(incs) Includes. No -I or something.
|
---|
89 | # @param $(dirdep) Directory creation dependency.
|
---|
90 | # @param $(deps) Other dependencies.
|
---|
91 | #
|
---|
92 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
93 | # @param $(objsuff) Object suffix.
|
---|
94 | TOOL_GCC4MACHO_COMPILE_C_OUTPUT =
|
---|
95 | TOOL_GCC4MACHO_COMPILE_C_DEPEND =
|
---|
96 | TOOL_GCC4MACHO_COMPILE_C_DEPORD =
|
---|
97 | define TOOL_GCC4MACHO_COMPILE_C_CMDS
|
---|
98 | $(TOOL_GCC4MACHO_CC) -c\
|
---|
99 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
100 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
101 | -o $(obj)\
|
---|
102 | $(call ABSPATH,$(source))
|
---|
103 | endef
|
---|
104 |
|
---|
105 |
|
---|
106 | ## Compile C++ source.
|
---|
107 | # @param $(target) Normalized main target name.
|
---|
108 | # @param $(source) Source filename (relative).
|
---|
109 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
110 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
111 | # @param $(flags) Flags.
|
---|
112 | # @param $(defs) Definitions. No -D or something.
|
---|
113 | # @param $(incs) Includes. No -I or something.
|
---|
114 | # @param $(dirdep) Directory creation dependency.
|
---|
115 | # @param $(deps) Other dependencies.
|
---|
116 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
117 | # @param $(objsuff) Object suffix.
|
---|
118 | TOOL_GCC4MACHO_COMPILE_CXX_OUTPUT =
|
---|
119 | TOOL_GCC4MACHO_COMPILE_CXX_DEPEND =
|
---|
120 | TOOL_GCC4MACHO_COMPILE_CXX_DEPORD =
|
---|
121 | define TOOL_GCC4MACHO_COMPILE_CXX_CMDS
|
---|
122 | $(TOOL_GCC4MACHO_CXX) -c\
|
---|
123 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
124 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
125 | -o $(obj)\
|
---|
126 | $(call ABSPATH,$(source))
|
---|
127 | endef
|
---|
128 |
|
---|
129 |
|
---|
130 | ## Compile Assembly source.
|
---|
131 | # @param $(target) Normalized main target name.
|
---|
132 | # @param $(source) Source filename (relative).
|
---|
133 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
134 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
135 | # @param $(flags) Flags.
|
---|
136 | # @param $(defs) Definitions. No -D or something.
|
---|
137 | # @param $(incs) Includes. No -I or something.
|
---|
138 | # @param $(dirdep) Directory creation dependency.
|
---|
139 | # @param $(deps) Other dependencies.
|
---|
140 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
141 | # @param $(objsuff) Object suffix.
|
---|
142 | #
|
---|
143 | TOOL_GCC4MACHO_COMPILE_AS_OUTPUT =
|
---|
144 | TOOL_GCC4MACHO_COMPILE_AS_DEPEND =
|
---|
145 | TOOL_GCC4MACHO_COMPILE_AS_DEPORD =
|
---|
146 | define TOOL_GCC4MACHO_COMPILE_AS_CMDS
|
---|
147 | $(TOOL_GCC4MACHO_AS) -c\
|
---|
148 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
149 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
150 | -o $(obj)\
|
---|
151 | $(call ABSPATH,$(source))
|
---|
152 | endef
|
---|
153 |
|
---|
154 |
|
---|
155 | ## Link library
|
---|
156 | # @param $(target) Normalized main target name.
|
---|
157 | # @param $(out) Library name.
|
---|
158 | # @param $(objs) Object files to put in the library.
|
---|
159 | # @param $(flags) Flags.
|
---|
160 | # @param $(dirdep) Directory creation dependency.
|
---|
161 | # @param $(deps) Other dependencies.
|
---|
162 | # @param $(othersrc) Unhandled sources.
|
---|
163 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
164 | TOOL_GCC4MACHO_LINK_LIBRARY_OUTPUT =
|
---|
165 | TOOL_GCC4MACHO_LINK_LIBRARY_DEPEND = $(filter %.a %.lib %.def %.imp,$(othersrc))
|
---|
166 | TOOL_GCC4MACHO_LINK_LIBRARY_DEPORD =
|
---|
167 | define TOOL_GCC4MACHO_LINK_LIBRARY_CMDS
|
---|
168 | $(TOOL_GCC4MACHO_AR) $(flags) $(out) $(objs) $(filter %.a %.lib, $(othersrc))
|
---|
169 | endef
|
---|
170 |
|
---|
171 |
|
---|
172 | ## Link program
|
---|
173 | # @param $(target) Normalized main target name.
|
---|
174 | # @param $(out) Program name.
|
---|
175 | # @param $(objs) Object files to link together.
|
---|
176 | # @param $(libs) Libraries to search.
|
---|
177 | # @param $(libpath) Library search paths.
|
---|
178 | # @param $(flags) Flags.
|
---|
179 | # @param $(dirdep) Directory creation dependency.
|
---|
180 | # @param $(deps) Other dependencies.
|
---|
181 | # @param $(othersrc) Unhandled sources.
|
---|
182 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
183 | # @param $(custom_post) Custom step invoked after linking.
|
---|
184 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
185 | TOOL_GCC4MACHO_LINK_PROGRAM_OUTPUT = $(outbase).map
|
---|
186 | TOOL_GCC4MACHO_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
187 | TOOL_GCC4MACHO_LINK_PROGRAM_DEPORD =
|
---|
188 | define TOOL_GCC4MACHO_LINK_PROGRAM_CMDS
|
---|
189 | $(TOOL_GCC4MACHO_LD) $(flags) -o $(out) $(objs)\
|
---|
190 | $(foreach p,$(libpath), -L$(p))\
|
---|
191 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
---|
192 | $(call TOOL_GCC4MACHO_LD_MAP,$(outbase).map)
|
---|
193 | endef
|
---|
194 |
|
---|
195 |
|
---|
196 | ## Link DLL
|
---|
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 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
209 | TOOL_GCC4MACHO_LINK_DLL_OUTPUT = $(outbase).map
|
---|
210 | TOOL_GCC4MACHO_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
211 | TOOL_GCC4MACHO_LINK_DLL_DEPORD =
|
---|
212 | define TOOL_GCC4MACHO_LINK_DLL_CMDS
|
---|
213 | $(TOOL_GCC4MACHO_LD) $(TOOL_GCC4MACHO_LDFLAGS.dll) $(flags) -o $(out)\
|
---|
214 | $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC4MACHO_LD_SONAME,$(target),$(out)))\
|
---|
215 | $(objs)\
|
---|
216 | $(foreach p,$(libpath), -L$(p))\
|
---|
217 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
---|
218 | $(call TOOL_GCC4MACHO_LD_MAP,$(outbase).map)
|
---|
219 | endef
|
---|
220 |
|
---|
221 |
|
---|
222 | ## Link system module (windows aka driver, linux aka kernel module)
|
---|
223 | # @param $(target) Normalized main target name.
|
---|
224 | # @param $(out) System module name.
|
---|
225 | # @param $(objs) Object files to link together.
|
---|
226 | # @param $(libs) Libraries to search.
|
---|
227 | # @param $(libpath) Library search paths.
|
---|
228 | # @param $(flags) Flags.
|
---|
229 | # @param $(dirdep) Directory creation dependency.
|
---|
230 | # @param $(deps) Other dependencies.
|
---|
231 | # @param $(othersrc) Unhandled sources.
|
---|
232 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
233 | # @param $(custom_post) Custom step invoked after linking.
|
---|
234 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
235 | TOOL_GCC4MACHO_LINK_SYSMOD_OUTPUT = $(outbase).map
|
---|
236 | TOOL_GCC4MACHO_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
237 | TOOL_GCC4MACHO_LINK_SYSMOD_DEPORD =
|
---|
238 | define TOOL_GCC4MACHO_LINK_SYSMOD_CMDS
|
---|
239 | $(TOOL_GCC4MACHO_LD_SYSMOD) $(TOOL_GCC4MACHO_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
|
---|
240 | $(foreach p,$(libpath), -L$(p))\
|
---|
241 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
---|
242 | $(call TOOL_GCC4MACHO_LD_SYSMOD_MAP,$(outbase).map)
|
---|
243 | endef
|
---|
244 |
|
---|