xref: /haiku/build/jam/MainBuildRules (revision 239222b2369c39dc52df52b0a7cdd6cc0a91bc92)
1
2rule AddSharedObjectGlueCode
3{
4	# AddSharedObjectGlueCode <target> : <isExecutable> ;
5
6	# we link with -nostdlib and add the required libs manually, when building
7	# for Haiku
8	local platform ;
9	on $(1) {
10		platform = $(PLATFORM) ;
11		if $(platform) = haiku {
12			local stdLibs = libroot.so ;
13			local beginGlue ;
14			local endGlue ;
15			if $(2) = true {
16				beginGlue += $(HAIKU_EXECUTABLE_BEGIN_GLUE_CODE) ;
17				endGlue += $(HAIKU_EXECUTABLE_END_GLUE_CODE) ;
18			} else {
19				beginGlue += $(HAIKU_LIBRARY_BEGIN_GLUE_CODE) ;
20				endGlue += $(HAIKU_LIBRARY_END_GLUE_CODE) ;
21
22				# special case for libroot: don't link it against itself
23				if $(DONT_LINK_AGAINST_LIBROOT) {
24					stdLibs = ;
25				}
26			}
27
28			LINK_BEGIN_GLUE on $(1) = $(beginGlue) ;
29			LINK_END_GLUE on $(1) = $(endGlue) ;
30
31			NEEDLIBS on $(1) =  [ on $(1) return $(NEEDLIBS) ] $(stdLibs) ;
32			Depends $(1) : $(stdLibs) $(beginGlue) $(endGlue) ;
33			LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib
34				-Xlinker --no-undefined ;
35		}
36	}
37
38	# link against the compatibility libraries needed for the target
39	if $(platform) != host && $(TARGET_HAIKU_COMPATIBILITY_LIBS) {
40		LinkAgainst $(1) : $(TARGET_HAIKU_COMPATIBILITY_LIBS) ;
41	}
42}
43
44rule Executable
45{
46	# Executable <name> : <sources> : <libraries> : <res> ;
47	#
48	if ! [ IsPlatformSupportedForTarget $(1) ] {
49		return ;
50	}
51
52	AddResources $(1) : $(4) ;
53	Main $(1) : $(2) ;
54	LinkAgainst $(1) : $(3) ;
55	LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ]
56		-Xlinker -soname=_APP_  ;
57
58	# we link with -nostdlib and add the required libs manually, when building
59	# for Haiku
60	AddSharedObjectGlueCode $(1) : true ;
61}
62
63rule Application
64{
65	# Application <name> : <sources> : <libraries> : <res> ;
66	Executable $(1) : $(2) : $(3) : $(4) ;
67}
68
69rule BinCommand
70{
71	# BinCommand <name> : <sources> : <libraries> : <res> ;
72	Executable $(1) : $(2) : $(3) : $(4) ;
73}
74
75rule StdBinCommands
76{
77	# StdBinCommands <sources> : <libs> : <res> ;
78	local libs = $(2) ;
79	local ress = $(3) ;
80	local source ;
81	for source in $(1)
82	{
83		local target = $(source:S=) ;
84
85		BinCommand $(target) : $(source) : $(libs) : $(ress) ;
86	}
87}
88
89rule Preference
90{
91	# Preference <name> : <sources> : <libraries> : <res> ;
92	Executable $(1) : $(2) : $(3) : $(4) ;
93}
94
95rule Server
96{
97	# Server <name> : <sources> : <libraries> : <res> ;
98
99	Executable $(1) : $(2) : $(3) : $(4) ;
100}
101
102rule Addon target : sources : libraries : isExecutable
103{
104	# Addon <target> : <sources> : <is executable> : <libraries> ;
105	# <target>: The add-on.
106	# <sources>: Source files.
107	# <libraries>: Libraries to be linked against.
108	# <isExecutable>: true, if the target shall be executable as well.
109
110	if ! [ IsPlatformSupportedForTarget $(target) ] {
111		return ;
112	}
113
114	Main $(target) : $(sources) ;
115
116	local linkFlags = -Xlinker -soname=\"$(target:G=)\" ;
117	if $(isExecutable) != true {
118		linkFlags = -nostart $(linkFlags) ;
119	}
120	LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] $(linkFlags) ;
121	LinkAgainst $(target) : $(libraries) ;
122
123	AddSharedObjectGlueCode $(target) : $(isExecutable) ;
124}
125
126rule Translator target : sources : libraries : isExecutable
127{
128	# Translator <target> : <sources> : <libraries> : <isExecutable> ;
129	Addon $(target) : $(sources) : $(libraries) : $(isExecutable) ;
130}
131
132rule ScreenSaver target : sources : libraries
133{
134	# ScreenSaver <target> : <sources> : <libraries> ;
135	Addon $(target) : $(sources) : $(libraries) : false ;
136}
137
138rule StaticLibrary
139{
140	# StaticLibrary <lib> : <sources> : <otherObjects> ;
141	# Creates a static library from sources.
142	# <lib>: The static library to be built.
143	# <sources>: List of source files.
144	# <otherObjects>: List of additional object files.
145	#
146	local lib = $(1) ;
147	local sources = [ FGristFiles $(2) ] ;
148	local otherObjects = $(3) ;
149	local objects = $(sources:S=$(SUFOBJ)) ;
150
151	if ! [ IsPlatformSupportedForTarget $(1) ] {
152		return ;
153	}
154
155	InheritPlatform $(objects) : $(lib) ;
156
157	StaticLibraryFromObjects $(lib) : $(objects) $(otherObjects) ;
158	Objects $(2) ;
159}
160
161rule StaticLibraryFromObjects
162{
163	if ! [ IsPlatformSupportedForTarget $(1) ] {
164		return ;
165	}
166
167	LibraryFromObjects $(1) : $(2) ;
168}
169
170rule AssembleNasm
171{
172	Depends $(<) : $(>) ;
173}
174
175actions AssembleNasm
176{
177	if test $(ASFLAGS) ; then
178		$(HAIKU_YASM) -d $(ASFLAGS) -f elf32 -o $(1) $(2);
179	else
180		$(HAIKU_YASM) -f elf32 -o $(1) $(2);
181	fi
182}
183
184rule Ld
185{
186	# Ld <name> : <objs> : <linkerscript> : <flags> ;
187	#
188	local target = $(1) ;
189	local objects = $(2) ;
190	local linkerScript = $(3) ;
191	local linkerFlags = $(4) ;
192
193	if $(linkerScript) {
194		linkerFlags += --script=$(linkerScript) ;
195	}
196
197	on $(target) {
198		if $(PLATFORM) = host {
199			LINK on $(target) = $(HOST_LD) ;
200			LINKFLAGS on $(target) = $(HOST_LDFLAGS) $(LINKFLAGS) $(linkerFlags) ;
201		} else {
202			LINK on $(target) = $(TARGET_LD) ;
203			LINKFLAGS on $(target) = $(TARGET_LDFLAGS) $(LINKFLAGS)
204				$(linkerFlags) ;
205		}
206
207		NEEDLIBS on $(target) = $(NEEDLIBS) ;
208		LINKLIBS on $(target) = $(LINKLIBS) ;
209	}
210
211	LocalClean clean : $(target) ;
212	LocalDepends all : $(target) ;
213	Depends $(target) : $(objects) ;
214
215	MakeLocateDebug $(target) ;
216
217	on $(1) XRes $(1) : $(RESFILES) ;
218	if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] {
219		SetType $(1) ;
220		MimeSet $(1) ;
221		SetVersion $(1) ;
222	}
223}
224
225actions Ld
226{
227	$(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" "$(NEEDLIBS)" $(LINKLIBS)
228}
229
230rule CreateAsmStructOffsetsHeader header : source
231{
232	# CreateAsmStructOffsetsHeader header : source
233	#
234	# Grist will be added to both header and source.
235
236	header = [ FGristFiles $(header) ] ;
237	source = [ FGristFiles $(source) ] ;
238
239	# find out which headers, defines, etc. to use
240	local headers ;
241	local sysHeaders ;
242	local defines ;
243	local flags ;
244	local includesSeparator ;
245	local localIncludesOption ;
246	local systemIncludesOption ;
247
248	on $(header) { # use on $(1) variable values
249		if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) {
250			return ;
251		}
252
253		# headers and defines
254		headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS)
255			$(HDRS) ;
256		sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ;
257		defines = $(DEFINES) ;
258
259		if $(PLATFORM) = host {
260			sysHeaders += $(HOST_HDRS) ;
261			defines += $(HOST_DEFINES) ;
262
263			if $(USES_BE_API) {
264				sysHeaders += $(HOST_BE_API_HEADERS) ;
265			}
266
267		} else {
268			sysHeaders += $(TARGET_HDRS) ;
269			defines += $(TARGET_DEFINES) ;
270		}
271
272		# optimization flags
273		if $(DEBUG) = 0 {
274			flags += $(OPTIM) ;
275		} else {
276			flags += -O0 ;
277		}
278
279		if $(PLATFORM) = host {
280			# warning flags
281			if $(WARNINGS) != 0 {
282				flags += $(HOST_WARNING_C++FLAGS) ;
283			}
284
285			# debug and other flags
286			flags += $(HOST_C++FLAGS) $(HOST_DEBUG_$(DEBUG)_C++FLAGS)
287				$(SUBDIRC++FLAGS) $(C++FLAGS) ;
288
289			if $(USES_BE_API) {
290				flags += $(HOST_BE_API_C++FLAGS) ;
291			}
292
293			C++ on $(header) = $(HOST_C++) ;
294
295			includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
296			localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
297			systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
298
299		} else {
300			# warning flags
301			if $(WARNINGS) != 0 {
302				flags += $(TARGET_WARNING_C++FLAGS) ;
303			}
304
305			# debug and other flags
306			flags += $(TARGET_C++FLAGS) $(TARGET_DEBUG_$(DEBUG)_C++FLAGS)
307				$(SUBDIRC++FLAGS) $(C++FLAGS) ;
308
309			C++ on $(header) = $(TARGET_C++) ;
310
311			includesSeparator = $(TARGET_INCLUDES_SEPARATOR) ;
312			localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ;
313			systemIncludesOption = $(TARGET_SYSTEM_INCLUDES_OPTION) ;
314		}
315	}
316
317	# locate object, search for source, and set on target variables
318
319	Depends $(header) : $(source) ;
320	SEARCH on $(source) += $(SEARCH_SOURCE) ;
321	MakeLocateArch $(header) ;
322	LocalClean clean : $(header) ;
323
324	HDRRULE on $(source) = HdrRule ;
325	HDRSCAN on $(source) = $(HDRPATTERN) ;
326	HDRSEARCH on $(source) = $(headers) $(sysHeaders) $(STDHDRS) ;
327	HDRGRIST on $(source) = $(HDRGRIST) ;
328
329	C++FLAGS on $(header) = $(flags) ;
330	CCHDRS on $(header) = [ FIncludes $(headers) : $(localIncludesOption) ]
331		$(includesSeparator)
332		[ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ;
333	CCDEFS on $(header) = [ FDefines $(defines) ] ;
334
335	CreateAsmStructOffsetsHeader1 $(header) : $(source) ;
336}
337
338actions CreateAsmStructOffsetsHeader1
339{
340 	$(C++) -S "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o - \
341		| grep "#define" | sed -e 's/[\$\#]\([0-9]\)/\1/' > "$(1)"
342}
343
344rule MergeObjectFromObjects
345{
346	# MergeObjectFromObjects <name> : <objects> : <other objects> ;
347	# Merges object files to an object file.
348	# <name>: Name of the object file to create. No grist will be added.
349	# <objects>: Object files to be merged. Grist will be added.
350	# <other objects>: Object files or static libraries to be merged. No grist
351	#                  will be added.
352	#
353	local objects = [ FGristFiles $(2) ] ;
354
355	on $(1) {
356		if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) {
357			return ;
358		}
359
360		if $(PLATFORM) = host {
361			LINK on $(1) = $(HOST_LD) ;
362			LINKFLAGS on $(target) = $(HOST_LDFLAGS) ;
363		} else {
364			LINK on $(1) = $(TARGET_LD) ;
365			LINKFLAGS on $(target) = $(TARGET_LDFLAGS) ;
366		}
367	}
368
369	MakeLocateDebug $(1) ;
370	Depends $(1) : $(objects) ;
371	Depends $(1) : $(3) ;
372	LocalDepends obj : $(1) ;
373	MergeObjectFromObjects1 $(1) : $(objects) $(3) ;
374}
375
376actions MergeObjectFromObjects1
377{
378	$(LINK) $(LINKFLAGS) -r $(2) -o $(1) ;
379}
380
381rule MergeObject
382{
383	# MergeObject <name> : <sources> : <other objects> ;
384	# Compiles source files and merges the object files to an object file.
385	# <name>: Name of the object file to create. No grist will be added.
386	# <sources>: Sources to be compiled. Grist will be added.
387	# <other objects>: Object files or static libraries to be merged. No grist
388	#                  will be added.
389	#
390	local target = $(1) ;
391	local sources = [ FGristFiles $(2) ] ;
392	local otherObjects = $(3) ;
393	local objects = $(sources:S=$(SUFOBJ)) ;
394
395	if ! [ IsPlatformSupportedForTarget $(1) ] {
396		return ;
397	}
398
399	InheritPlatform $(objects) : $(target) ;
400	Objects $(sources) ;
401	MergeObjectFromObjects $(target) : $(objects) : $(otherObjects) ;
402}
403
404rule SharedLibraryFromObjects
405{
406	# SharedLibraryFromObjects <lib> : <objects> : <libraries> ;
407	#
408	local _lib = $(1) ;
409
410	if ! [ IsPlatformSupportedForTarget $(1) ] {
411		return ;
412	}
413
414	MainFromObjects $(_lib) : $(2) ;
415	LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ]
416		-nostart -Xlinker -soname=\"$(_lib:G=)\" ;
417	LinkAgainst $(_lib) : $(3) ;
418
419	AddSharedObjectGlueCode $(_lib) : false ;
420}
421
422rule SharedLibrary
423{
424	# SharedLibrary <lib> : <sources> : <libraries> ;
425	local lib = $(1) ;
426	local sources = [ FGristFiles $(2) ] ;
427	local objects = $(sources:S=$(SUFOBJ)) ;
428	local libs = $(3) ;
429
430	if ! [ IsPlatformSupportedForTarget $(1) ] {
431		return ;
432	}
433
434	InheritPlatform $(objects) : $(lib) ;
435	Objects $(sources) ;
436	SharedLibraryFromObjects $(lib) : $(objects) : $(libs) ;
437}
438
439rule LinkAgainst
440{
441	# LinkAgainst <name> : <libs> [ : <mapLibs> ] ;
442	# Valid elements for <libs> are e.g. "be" or "libtranslation.so" or
443	# "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy
444	# has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the
445	# file will be bound!), otherwise it is prefixed "-l" and added to
446	# LINKLIBS. If you want to specify a target that isn't a library and
447	# also has neither grist nor a dirname, you can prepend "<nogrist>" as
448	# grist; it will be stripped by this rule.
449	# <mapLibs> specifies whether the to translate library names (e.g. "be"
450	# to "libbe.so" in case of target platform "haiku"). Defaults to "true".
451	#
452	local target = $(1) ;
453	local libs = $(2) ;
454	local mapLibs = $(3:E=true) ;
455
456	on $(target) {
457		# map libraries, if desired and target platform is Haiku
458		if $(PLATFORM) != host && $(mapLibs) = true
459				&& $(TARGET_LIBRARY_NAME_MAP) {
460			local mappedLibs ;
461
462			for i in $(libs) {
463				local mapped = $($(TARGET_LIBRARY_NAME_MAP)_$(i)) ;
464				mapped ?= $(i) ;
465				mappedLibs += $(mapped) ;
466			}
467
468			libs = $(mappedLibs) ;
469		}
470
471		local linkLibs ;
472		local needLibs ;
473
474		for i in $(libs)
475		{
476			local isfile = ;
477			if $(i:D) || $(i:G) {
478				isfile = true ;
479				if $(i:G) = <nogrist> {
480					i = $(i:G=) ;
481				}
482			} else {
483				switch $(i:B)
484				{
485					# XXX: _APP_ and _KERNEL_ should not be needed for ELF.
486					case _APP_ : isfile = true ;
487					case _KERNEL_ : isfile = true ;
488					case lib*	: isfile = true ;
489					case *	: isfile = ;
490				}
491				if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) {
492					isfile = true ;
493				}
494			}
495
496			if $(isfile) {
497				needLibs += $(i) ;
498			} else {
499				linkLibs += $(i) ;
500			}
501		}
502
503		NEEDLIBS on $(1) = $(NEEDLIBS) $(needLibs) ;
504		LINKLIBS on $(1) = $(LINKLIBS) -l$(linkLibs) ;
505
506		if $(needLibs) && ! $(NO_LIBRARY_DEPENDENCIES) {
507			Depends $(1) : $(needLibs) ;
508		}
509	}
510}
511
512rule AddResources
513{
514	# AddResources <name> : <resourcefiles> ;
515
516	# add grist to the resource files which don't have any yet
517	local resfiles ;
518	local file ;
519	for file in $(2) {
520		if ! $(file:G) {
521			file = [ FGristFiles $(file) ] ;
522		}
523		resfiles += $(file) ;
524	}
525
526	SEARCH on $(resfiles) += $(SEARCH_SOURCE) ;
527
528	for file in $(resfiles) {
529		if $(file:S) = .rdef {
530			local rdef = $(file) ;
531			file = $(rdef:S=.rsrc) ;
532			ResComp $(file) : $(rdef) ;
533		}
534		InheritPlatform $(file) : $(1) ;
535		RESFILES on $(1) += $(file) ;
536	}
537}
538
539rule SetVersionScript target : versionScript
540{
541	# SetVersionScript <target> : <versionScript>
542	#
543	# Sets the version script for <target>. Grist will be added to
544	# <versionScript> and SEARCH will be set on it.
545
546	versionScript = [ FGristFiles $(versionScript) ] ;
547
548	SEARCH on $(versionScript) += $(SEARCH_SOURCE) ;
549
550	VERSION_SCRIPT on $(target) = $(versionScript) ;
551	Depends $(target) : $(versionScript) ;
552}
553
554rule BuildPlatformObjects
555{
556	# Usage BuildPlatformObjects <sources> ;
557	# <sources> The sources.
558	#
559	local sources = [ FGristFiles $(1) ] ;
560	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
561
562	PLATFORM on $(objects) = host ;
563	SUPPORTED_PLATFORMS on $(objects) = host ;
564
565	Objects $(sources) ;
566}
567
568actions CygwinExtensionFix
569{
570	if test -f $(1).exe ; then
571		rm -f $(1)
572		mv $(1).exe $(1)
573	fi
574}
575
576rule BuildPlatformMain
577{
578	# Usage BuildPlatformMain <target> : <sources> : <libraries> ;
579	# <target> The executable/library.
580	# <sources> The sources.
581	# <libraries> Libraries to link against.
582	#
583	local target = $(1) ;
584	local sources = $(2) ;
585	local libs = $(3) ;
586	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
587
588	PLATFORM on $(target) = host ;
589	SUPPORTED_PLATFORMS on $(target) = host ;
590	DONT_USE_BEOS_RULES on $(target) = true ;
591
592	local usesBeAPI = [ on $(target) return $(USES_BE_API) ] ;
593	if $(usesBeAPI) {
594		# propagate the flag to the objects
595		USES_BE_API on $(objects) = $(usesBeAPI) ;
596
597		# add the build libroot
598		if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
599			local libroot = [ on $(target) return $(HOST_LIBROOT) ] ;
600			Depends $(target) : $(libroot) ;
601			NEEDLIBS on $(target) += $(libroot) ;
602		}
603	}
604
605	Main $(target) : $(sources) ;
606	LinkAgainst $(target) : $(libs) ;
607	if $(HOST_PLATFORM) = cygwin {
608		# Cygwin gcc adds the ".exe" extension. We cannot force
609		# jam to use SUFEXE as haiku target executables are not
610		# supposed to have this extension, thus finding
611		# dependencies will fail for these.
612		# The hack is to remove the extension after a successful
613		# build of the Target.
614		CygwinExtensionFix $(target) ;
615	}
616}
617
618rule BuildPlatformSharedLibrary
619{
620	# Usage BuildPlatformSharedLibrary <target> : <sources> : <libraries> ;
621	# <target> The library.
622	# <sources> The sources.
623	# <libraries> Libraries to link against.
624	#
625	local target = $(1) ;
626	local sources = $(2) ;
627	local libs = $(3) ;
628
629	BuildPlatformMain $(target) : $(sources) : $(libs) ;
630
631	if $(HOST_PLATFORM) = darwin {
632		LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ]
633			-dynamic -dynamiclib -Xlinker -flat_namespace ;
634	} else if $(HOST_PLATFORM) = cygwin {
635		LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ]
636			-shared -Xlinker --allow-multiple-definition ;
637	} else {
638		LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ]
639			-shared -Xlinker -soname=\"$(target:G=)\" ;
640	}
641
642    local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
643	CCFLAGS on $(objects) += $(HOST_PIC_CCFLAGS) ;
644	C++FLAGS on $(objects) += $(HOST_PIC_C++FLAGS) ;
645}
646
647rule BuildPlatformMergeObject
648{
649	# BuildPlatformMergeObject <name> : <sources> : <other objects> ;
650	# Compiles source files and merges the object files to an object file.
651	# <name>: Name of the object file to create. No grist will be added.
652	# <sources>: Sources to be compiled. Grist will be added.
653	# <other objects>: Object files or static libraries to be merged. No grist
654	#                  will be added.
655	#
656	local target = $(1) ;
657	local sources = $(2) ;
658	local otherObjects = $(3) ;
659	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
660
661	PLATFORM on $(target) = host ;
662	SUPPORTED_PLATFORMS on $(target) = host ;
663
664	local usesBeAPI = [ on $(target[1]) return $(USES_BE_API) ] ;
665	if $(usesBeAPI) {
666		# propagate the flag to the objects
667		USES_BE_API on $(objects) = $(usesBeAPI) ;
668	}
669
670	MergeObject $(target) : $(sources) : $(otherObjects) ;
671}
672
673rule BuildPlatformMergeObjectPIC target : sources : otherObjects
674{
675	# BuildPlatformMergeObjectPIC <name> : <sources> : <other objects> ;
676	# Compiles source files and merges the object files to an object file.
677	# Same as BuildPlatformMergeObject rule but adds position-independent
678	# flags to the compiler (if any).
679	# <name>: Name of the object file to create. No grist will be added.
680	# <sources>: Sources to be compiled. Grist will be added.
681	# <other objects>: Object files or static libraries to be merged. No grist
682	#                  will be added.
683	#
684	ObjectCcFlags $(sources) : $(HOST_PIC_CCFLAGS) ;
685	ObjectC++Flags $(sources) : $(HOST_PIC_C++FLAGS) ;
686
687	BuildPlatformMergeObject $(target) : $(sources) : $(otherObjects) ;
688}
689
690rule BuildPlatformStaticLibrary lib : sources : otherObjects
691{
692	# BuildPlatformStaticLibrary <lib> : <sources> ;
693	# Creates a static library from sources.
694	# <lib>: The static library to be built.
695	# <sources>: List of source files.
696	# <otherObjects>: List of additional object files.
697	#
698
699	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
700
701	PLATFORM on $(lib) = host ;
702	SUPPORTED_PLATFORMS on $(lib) = host ;
703
704	local usesBeAPI = [ on $(lib) return $(USES_BE_API) ] ;
705	if $(usesBeAPI) {
706		# propagate the flag to the objects
707		USES_BE_API on $(objects) = $(usesBeAPI) ;
708	}
709
710	StaticLibrary $(lib) : $(sources) : $(otherObjects) ;
711}
712
713