xref: /haiku/build/jam/SystemLibraryRules (revision b247f935d133a42c427cad8a759a1bf2f65bc290)
1rule Libstdc++ForImage
2{
3	# Libstdc++ForImage
4	#
5	# Returns the c++-standard-library to be put onto the image.
6
7	if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
8		# the libstdc++.so for our legacy compiler (needs to be built)
9		return libstdc++.r4.so ;
10	}
11
12	# libstdc++.so for other architectures comes with the gcc_syslibs
13	# package, so there's no library to put onto the image directly.
14	return ;
15}
16
17
18rule TargetLibstdc++ asPath
19{
20	# TargetLibstdc++ [ <asPath> ]
21	#
22	# Returns the c++-standard-library for the target.
23	# Invoking with <asPath> = true will return the full library path.
24
25	if $(TARGET_PLATFORM) = haiku {
26		if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
27			# the libstdc++.so for our legacy compiler (needs to be built)
28			return libstdc++.r4.so ;
29		}
30		# return libstdc++.so from the gcc_syslibs build feature.
31		local flags ;
32		if $(asPath) = true {
33			flags += path ;
34		}
35		return [
36			BuildFeatureAttribute gcc_syslibs : libstdc++.so : $(flags)
37		] ;
38	} else {
39		if $(TARGET_PLATFORM) = libbe_test {
40			# Use the existing host library
41			return stdc++.r4 ;
42		}
43		# TODO: return libstdc++.so for non-Haiku target platform if needed
44	}
45}
46
47
48rule TargetLibsupc++ asPath
49{
50	# TargetLibsupc++ [ <asPath> ]
51	#
52	# Returns the c++-support-library for the target.
53	# Invoking with <asPath> = true will return the full library path.
54
55	if $(TARGET_PLATFORM) = haiku {
56		if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
57			# there is no libsupc++.so for the legacy compiler
58			return ;
59		}
60		# return libstdc++.so (which includes libsupc++) from the gcc_syslibs
61		# build feature.
62		local flags ;
63		if $(asPath) = true {
64			flags += path ;
65		}
66		return [
67			BuildFeatureAttribute gcc_syslibs : libstdc++.so : $(flags)
68		] ;
69	} else {
70		# TODO: return libsupc++.so for non-Haiku target platform if needed
71	}
72}
73
74
75rule TargetStaticLibsupc++ asPath
76{
77	# TargetStaticLibsupc++ [ <asPath> ]
78	#
79	# Returns the static c++-support-library for the target.
80	# Invoking with <asPath> = true will return the full library path.
81
82	if $(TARGET_PLATFORM) = haiku {
83		# return libsupc++.a from the gcc_syslibs_devel build feature.
84		local flags ;
85		if $(asPath) = true {
86			flags += path ;
87		}
88		return [
89			BuildFeatureAttribute gcc_syslibs_devel : libsupc++.a : $(flags)
90		] ;
91	} else {
92		# TODO: return libsupc++.a for non-Haiku target platform if needed
93	}
94}
95
96
97rule TargetKernelLibsupc++ asPath
98{
99	# TargetKernelLibsupc++ [ <asPath> ]
100	#
101	# Returns the static kernel c++-support-library for the target.
102	# Invoking with <asPath> = true will return the full library path.
103
104	if $(TARGET_PLATFORM) = haiku {
105		# return libsupc++-kernel.a from the gcc_syslibs_devel build feature.
106		local flags ;
107		if $(asPath) = true {
108			flags += path ;
109		}
110		return [
111			BuildFeatureAttribute gcc_syslibs_devel
112				: libsupc++-kernel.a : $(flags)
113		] ;
114	} else {
115		# There is no libsupc++-kernel.a for non-Haiku target platform
116	}
117}
118
119
120rule TargetBootLibsupc++ asPath
121{
122	# TargetBootLibsupc++ [ <asPath> ]
123	#
124	# Returns the static bootloader c++-support-library for the target.
125	# Invoking with <asPath> = true will return the full library path.
126
127	if $(TARGET_PLATFORM) = haiku {
128		if $(TARGET_PACKAGING_ARCH) = x86_64 {
129			# we need to use the 32-bit libsupc++.a built by the cross-compiler
130			return $(TARGET_BOOT_LIBSUPC++) ;
131
132			# TODO: ideally, we would build this as part of gcc_syslibs_devel,
133			#       but that isn't currently possible, as that would require
134			#       32-bit support (libraries and glue-code) on x86_64-Haiku.
135		}
136		# no special boot version of libsupc++.a needed, so we return
137		# libsupc++-kernel.a from the gcc_syslibs_devel build feature.
138		local flags ;
139		if $(asPath) = true {
140			flags += path ;
141		}
142		return [
143			BuildFeatureAttribute gcc_syslibs_devel
144				: libsupc++-kernel.a : $(flags)
145		] ;
146	} else {
147		# There is no libsupc++-boot.a for non-Haiku target platform
148	}
149}
150
151
152rule TargetLibgcc asPath
153{
154	# TargetLibgcc [ <asPath> ]
155	#
156	# Returns the default libgcc(s) for the target. On x86_gcc2, this is the
157	# static libgcc, on everything else this will return the shared libgcc_s
158	# followed by the static libgcc (both are needed as they do not contain
159	# the same set of symbols).
160	# Invoking with <asPath> = true will return the full library path.
161
162	if $(TARGET_PLATFORM) = haiku {
163		local flags ;
164		if $(asPath) = true {
165			flags += path ;
166		}
167		if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
168			# return libgcc.a from the gcc_syslibs_devel build feature.
169			return [
170				BuildFeatureAttribute gcc_syslibs_devel : libgcc.a : $(flags)
171			] ;
172		} else {
173			# return libgcc_s.so from the gcc_syslibs build feature and libgcc.a
174			# from the gcc_syslibs_devel build feature.
175			return [
176				BuildFeatureAttribute gcc_syslibs : libgcc_s.so : $(flags)
177			] [
178				BuildFeatureAttribute gcc_syslibs_devel : libgcc.a : $(flags)
179			] ;
180		}
181	} else {
182		# TODO: return libgcc for non-Haiku target platform if needed
183	}
184}
185
186
187rule TargetStaticLibgcc asPath
188{
189	# TargetStaticLibgcc [ <asPath> ]
190	#
191	# Returns the static libgcc for the target.
192	# Invoking with <asPath> = true will return the full library path.
193
194	if $(TARGET_PLATFORM) = haiku {
195		# return libgcc.a from the gcc_syslibs_devel build feature.
196		local flags ;
197		if $(asPath) = true {
198			flags += path ;
199		}
200		return [
201			BuildFeatureAttribute gcc_syslibs_devel : libgcc.a : $(flags)
202		] ;
203	} else {
204		# TODO: return libgcc.a for non-Haiku target platform if needed
205	}
206}
207
208
209rule TargetKernelLibgcc asPath
210{
211	# TargetKernelLibgcc [ <asPath> ]
212	#
213	# Returns the static kernel libgcc for the target.
214	# Invoking with <asPath> = true will return the full library path.
215
216	if $(TARGET_PLATFORM) = haiku {
217		# return libgcc-kernel.a from the gcc_syslibs_devel build feature.
218		local flags ;
219		if $(asPath) = true {
220			flags += path ;
221		}
222		return [
223			BuildFeatureAttribute gcc_syslibs_devel
224				: libgcc-kernel.a : $(flags)
225		] ;
226	} else {
227		# there is no libgcc-kernel.a for non-Haiku target platform
228	}
229}
230
231
232rule TargetBootLibgcc asPath
233{
234	# TargetBootLibgcc [ <asPath> ]
235	#
236	# Returns the static bootloader libgcc for the target.
237	# Invoking with <asPath> = true will return the full library path.
238
239	if $(TARGET_PLATFORM) = haiku {
240		if $(TARGET_PACKAGING_ARCH) = x86_64 {
241			# we need to use the 32-bit libgcc.a built by the cross-compiler
242			return $(TARGET_BOOT_LIBGCC) ;
243
244			# TODO: ideally, we would build this as part of gcc_syslibs_devel,
245			#       but that isn't currently possible, as that would require
246			#       32-bit support (libraries and glue-code) on x86_64-Haiku.
247		}
248		# no special boot version of libgcc needed, so we return
249		# libgcc-kernel.a from the gcc_syslibs_devel build feature.
250		local flags ;
251		if $(asPath) = true {
252			flags += path ;
253		}
254		return [
255			BuildFeatureAttribute gcc_syslibs_devel
256				: libgcc-kernel.a : $(flags)
257		] ;
258	} else {
259		# there is no libgcc-boot.a for non-Haiku target platform
260	}
261}
262
263
264rule TargetStaticLibgcceh asPath
265{
266	# TargetStaticLibgcceh [ <asPath> ]
267	#
268	# Returns the static libgcc_eh for the target.
269	# Invoking with <asPath> = true will return the full library path.
270
271	if $(TARGET_PLATFORM) = haiku {
272		# return libgcc.a from the gcc_syslibs_devel build feature.
273		local flags ;
274		if $(asPath) = true {
275			flags += path ;
276		}
277		return [
278			BuildFeatureAttribute gcc_syslibs_devel : libgcc_eh.a : $(flags)
279		] ;
280	} else {
281		# TODO: return libgcc_eh.a for non-Haiku target platform if needed
282	}
283}
284
285
286rule TargetKernelLibgcceh asPath
287{
288	# TargetKernelLibgcceh [ <asPath> ]
289	#
290	# Returns the static kernel libgcc_eh for the target.
291	# Invoking with <asPath> = true will return the full library path.
292
293	if $(TARGET_PLATFORM) = haiku {
294		# return libgcc_eh-kernel.a from the gcc_syslibs_devel build feature.
295		local flags ;
296		if $(asPath) = true {
297			flags += path ;
298		}
299		return [
300			BuildFeatureAttribute gcc_syslibs_devel
301				: libgcc_eh-kernel.a : $(flags)
302		] ;
303	} else {
304		# there is no libgcc_eh-kernel.a for non-Haiku target platform
305	}
306}
307
308
309rule C++HeaderDirectories architecture
310{
311	# C++HeaderDirectories
312	#
313	# Returns the c++ header directories to use for the given architecture.
314
315	local c++HeaderDirs ;
316	if $(architecture) = x86_gcc2 {
317		c++HeaderDirs = [ FDirName $(HAIKU_TOP) headers cpp ] ;
318	} else if $(PLATFORM) = bootstrap_stage0 {
319		# Currently, no c++-headers are needed for stage0 of the boostrap.
320	} else {
321		local baseDir = [
322			BuildFeatureAttribute gcc_syslibs_devel : c++-headers : path
323		] ;
324		if $(baseDir) {
325			c++HeaderDirs =
326				$(baseDir)
327				[ FDirName $(baseDir) $(HAIKU_GCC_MACHINE_$(architecture)) ]
328				[ FDirName $(baseDir) backward ]
329				[ FDirName $(baseDir) ext ]
330				;
331		}
332	}
333
334	return $(c++HeaderDirs) ;
335}
336
337rule GccHeaderDirectories architecture
338{
339	# GccHeaderDirectories
340	#
341	# Returns the gcc header directories to use for the given architecture.
342
343	local gccHeaderDirs ;
344	if $(architecture) = x86_gcc2 {
345		gccHeaderDirs = [ FDirName $(HAIKU_TOP) headers build gcc-2.95.3 ] ;
346	} else if $(PLATFORM) = bootstrap_stage0 {
347		gccHeaderDirs =
348			[ FDirName $(HAIKU_GCC_LIB_DIR_$(architecture)) include ]
349			[ FDirName $(HAIKU_GCC_LIB_DIR_$(architecture)) include-fixed ]
350			;
351	} else {
352		local baseDir = [
353			BuildFeatureAttribute gcc_syslibs_devel : gcc-headers : path
354		] ;
355		if $(baseDir) {
356			gccHeaderDirs =
357				[ FDirName $(baseDir) include ]
358				[ FDirName $(baseDir) include-fixed ]
359				;
360		}
361	}
362
363	return $(gccHeaderDirs) ;
364}
365