xref: /haiku/Jamrules (revision 4ff6d49f35f562a6eea4b5f35009809c821e247c)
19eea4522SIngo Weinhold# Vanilla Jam compatibility
29eea4522SIngo Weinholdif ! $(INVOCATION_SUBDIR_SET) {
39eea4522SIngo Weinhold
49eea4522SIngo Weinhold	rule FIsPrefix
59eea4522SIngo Weinhold	{
69eea4522SIngo Weinhold		# FIsPrefix <a> : <b> ;
79eea4522SIngo Weinhold		# Returns true, if list <a> is a prefix (a proper one or equal) of
89eea4522SIngo Weinhold		# list <b>, an empty list otherwise.
99eea4522SIngo Weinhold		local a = $(1) ;
109eea4522SIngo Weinhold		local b = $(2) ;
119eea4522SIngo Weinhold		while $(a) && $(a[1]) = $(b[1]) {
129eea4522SIngo Weinhold			a = $(a[2-]) ;
139eea4522SIngo Weinhold			b = $(b[2-]) ;
149eea4522SIngo Weinhold		}
159eea4522SIngo Weinhold
169eea4522SIngo Weinhold		if $(a) {
179eea4522SIngo Weinhold			return ;
189eea4522SIngo Weinhold		} else {
199eea4522SIngo Weinhold			return true ;
209eea4522SIngo Weinhold		}
219eea4522SIngo Weinhold	}
229eea4522SIngo Weinhold
239eea4522SIngo Weinhold	rule LocalClean { Clean $(1) : $(2) ; }
249eea4522SIngo Weinhold
259eea4522SIngo Weinhold	rule LocalDepends { Depends $(1) : $(2) ; }
269eea4522SIngo Weinhold
279eea4522SIngo Weinhold} # vanilla Jam compatibility
289eea4522SIngo Weinhold
29*4ff6d49fSIngo Weinhold# The directory for build system specific files
30*4ff6d49fSIngo WeinholdOBOS_BUILD_DIR = [ FDirName $(OBOS_TOP) build ] ;
31*4ff6d49fSIngo Weinhold
32*4ff6d49fSIngo Weinhold# Cache files for header scanning and jamfile caching
33*4ff6d49fSIngo WeinholdHCACHEFILE = header_cache ;
34*4ff6d49fSIngo WeinholdJCACHEFILE = jamfile_cache ;
35*4ff6d49fSIngo WeinholdLOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(OBOS_BUILD_DIR) ;
369eea4522SIngo Weinhold
3752a38012Sejakowatz# Include BuildConfig
3852a38012Sejakowatz{
39*4ff6d49fSIngo Weinhold	local buildConfig = [ GLOB $(OBOS_BUILD_DIR) : BuildConfig ] ;
4052a38012Sejakowatz	if ! $(buildConfig)
4152a38012Sejakowatz	{
42*4ff6d49fSIngo Weinhold		ECHO "No BuildConfig found in $(OBOS_BUILD_DIR)!" ;
43*4ff6d49fSIngo Weinhold		EXIT "Run ./configure in the source tree's root directory first!" ;
4452a38012Sejakowatz	}
45*4ff6d49fSIngo Weinhold	LOCATE on BuildConfig = $(OBOS_BUILD_DIR) ;
46*4ff6d49fSIngo Weinhold	include BuildConfig ;
4752a38012Sejakowatz}
4852a38012Sejakowatz
49a6c008e1Sbeveloper# We do not include any local BeOS system headers by default
50dd9f8062SIngo WeinholdCCFLAGS += -nostdinc ;
51dd9f8062SIngo WeinholdC++FLAGS += -nostdinc ;
52a6c008e1Sbeveloper
5352a38012Sejakowatz# Determine if we're building on PPC or x86
5452a38012Sejakowatz# Determine mimetype of executable
5552a38012Sejakowatz# Cross compiling can come later
5652a38012Sejakowatz
5752a38012Sejakowatzif $(METROWERKS) {
5878599cf0SIngo Weinhold	OBOS_TARGET ?= "ppc.R1" ;
5952a38012Sejakowatz	OBOS_TARGET_TYPE ?= "application/x-be-executable" ;
6052a38012Sejakowatz	OBOS_ARCH ?= "ppc" ;
6152a38012Sejakowatz	OBOS_TARGET_DEFINE ?= "ARCH_ppc" ;
6252a38012Sejakowatz} else {
6378599cf0SIngo Weinhold	OBOS_TARGET ?= "x86.R1" ;
6452a38012Sejakowatz	OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ;
6552a38012Sejakowatz	OBOS_ARCH ?= "x86" ;
6652a38012Sejakowatz	OBOS_TARGET_DEFINE ?= "ARCH_x86" ;
6752a38012Sejakowatz	OBOS_TARGET_DIR ?= "x86" ;
6852a38012Sejakowatz}
6952a38012Sejakowatz
70e5dc2d93Sbeveloper# Enable warnings only if WARNINGS is defined
71e5dc2d93Sbeveloper# Should be enabled by default later
7296d27465SIngo Weinhold#
73e5dc2d93Sbeveloperif $(WARNINGS) {
74e5dc2d93Sbeveloper	# For an explanation of the different warning options, see:
75e5dc2d93Sbeveloper	# http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html
76e5dc2d93Sbeveloper	# to get even more warnings, add:
77e5dc2d93Sbeveloper	# -Wwrite-strings  	(doesn't work well with some Be headers)
78e5dc2d93Sbeveloper	# -Wundef			(dito)
79e5dc2d93Sbeveloper	# -Wconversion		(gets you many warnings about implicit conversions)
80e5dc2d93Sbeveloper	# -W				(gets you even more warnigs)
81dd9f8062SIngo Weinhold	CCFLAGS += -Wall -Wno-multichar -Wmissing-prototypes ;
82dd9f8062SIngo Weinhold	CCFLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ;
83dd9f8062SIngo Weinhold	C++FLAGS += -Wall -Wno-multichar -Wmissing-prototypes -Wno-ctor-dtor-privacy -Woverloaded-virtual ;
84dd9f8062SIngo Weinhold	C++FLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ;
85e5dc2d93Sbeveloper}
86e5dc2d93Sbeveloper
879eea4522SIngo Weinhold# We might later want to introduce debug levels or handle the whole issue
889eea4522SIngo Weinhold# differently. For now there's only on or off.
899eea4522SIngo Weinhold#
909eea4522SIngo Weinholdif $(DEBUG) {
919eea4522SIngo Weinhold	OPTIM ?= -O0 ;
929eea4522SIngo Weinhold	CCFLAGS += -g ;
939eea4522SIngo Weinhold	C++FLAGS += -g ;
949eea4522SIngo Weinhold	LINKFLAGS += -g ;
959eea4522SIngo Weinhold} else {
969eea4522SIngo Weinhold	OPTIM ?= -O2 ;
979eea4522SIngo Weinhold}
9896d27465SIngo Weinhold#
9996d27465SIngo Weinhold# To disable for the tests OPTIM and DEBUG are overridden, set the environment
10096d27465SIngo Weinhold# variable NO_TEST_DEBUG.
1019eea4522SIngo Weinhold
102dd9f8062SIngo WeinholdKERNEL_CCFLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ;
103dd9f8062SIngo WeinholdKERNEL_CCFLAGS += -fno-builtin -D$(OBOS_TARGET_DEFINE) ;
104dd9f8062SIngo WeinholdKERNEL_CCFLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ;
10552a38012Sejakowatz
10616fa4445SIngo Weinhold# Instructs the Library rule to not make its object files temporary.
10716fa4445SIngo Weinhold# This is need as some objects are used in a static library and for an
10816fa4445SIngo Weinhold# executable.
10916fa4445SIngo WeinholdKEEPOBJS = true ;
11016fa4445SIngo Weinhold
11152a38012SejakowatzAR = ar r ;
11252a38012Sejakowatz
11352a38012Sejakowatz# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and
11452a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different
11552a38012Sejakowatz# builds mixing objects from different targets).
11652a38012Sejakowatzif ! $(OBOS_OBJECT_TARGET) {
11752a38012Sejakowatz	OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ;
11852a38012Sejakowatz}
11952a38012Sejakowatz
12052a38012Sejakowatz# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and
12152a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different
12252a38012Sejakowatz# builds mixing executables from different targets).
12352a38012Sejakowatzif ! $(OBOS_DISTRO_TARGET) {
12452a38012Sejakowatz	OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ;
12552a38012Sejakowatz}
12652a38012Sejakowatz
12752a38012Sejakowatz# Set our version number if not already set and mark it as a developer build
12852a38012Sejakowatzif ! $(OBOS_BUILD_VERSION) {
12952a38012Sejakowatz	OBOS_BUILD_VERSION ?= "1 0 0 a 1" ;
13052a38012Sejakowatz	OBOS_BUILD_DESCRIPTION ?= "Developer Build" ;
13152a38012Sejakowatz}
13252a38012Sejakowatz
13352a38012Sejakowatz# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as
13452a38012Sejakowatz# an unknown build.
13552a38012Sejakowatzif ! $(OBOS_BUILD_DESCRIPTION) {
13652a38012Sejakowatz	OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ;
13752a38012Sejakowatz}
13852a38012Sejakowatz
13952a38012Sejakowatz# Relative subdirs for distro dir (these are for *INTERNAL* use by the following rules only!)
1405f281ed5SejakowatzOBOS_APPS_DIR   ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ;
141f06de7f3SIngo WeinholdOBOS_BIN_DIR    ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ;
14252a38012SejakowatzOBOS_PREFS_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ;
14352a38012SejakowatzOBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ;
14452a38012SejakowatzOBOS_ADDON_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ;
14552a38012SejakowatzOBOS_SHLIB_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ;
14652a38012SejakowatzOBOS_STLIB_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ;
14752a38012SejakowatzOBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ;
14852a38012SejakowatzOBOS_TEST_DIR   ?= [ FDirName $(OBOS_TOP) tests ] ;
14952a38012Sejakowatz
15052a38012SejakowatzOBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ;
15152a38012SejakowatzOBOS_KERNEL = kernel.$(OBOS_ARCH) ;
15252a38012SejakowatzOBOS_FLOPPY = floppy.$(OBOS_ARCH) ;
15352a38012Sejakowatz
15452a38012Sejakowatzrule SetupIncludes
15552a38012Sejakowatz{
156cfc7b456Sshatty	# XXX add "opengl" later
157cfc7b456Sshatty	local os_includes = add-ons add-ons/file_system add-ons/graphics add-ons/input_server add-ons/screen_saver add-ons/tracker app device drivers game interface kernel media mail midi midi2 net storage support translation ;
158a6c008e1Sbeveloper
15928d2a30eSDaniel Reinhold	# Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times.
160a6c008e1Sbeveloper
161a6c008e1Sbeveloper	# Use headers directory, to allow to do things like include <posix/string.h>
16228d2a30eSDaniel Reinhold	HDRS = [ FDirName $(OBOS_TOP) headers ] ;
163a6c008e1Sbeveloper
164a6c008e1Sbeveloper	# Use posix headers directory
16528d2a30eSDaniel Reinhold	HDRS += [ FDirName $(OBOS_TOP) headers posix ] ;
166a6c008e1Sbeveloper
167a6c008e1Sbeveloper	# Use public OS header directories
16828d2a30eSDaniel Reinhold	HDRS += [ PublicHeaders $(os_includes) ] ;
169a6c008e1Sbeveloper
170a6c008e1Sbeveloper	# Used as a fallback, the R5 header directories (we should remove this as soon as possible)
17128d2a30eSDaniel Reinhold	HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ;
17252a38012Sejakowatz}
17352a38012Sejakowatz
174dd9f8062SIngo Weinholdrule SetupR5Includes
175dd9f8062SIngo Weinhold{
176dd9f8062SIngo Weinhold	# Unsets HDRS, so that the OBOS headers do not `shadow' the system headers.
177dd9f8062SIngo Weinhold	HDRS = ;
178dd9f8062SIngo Weinhold}
179dd9f8062SIngo Weinhold
18052a38012Sejakowatz#-------------------------------------------------------------------------------
18152a38012Sejakowatz# Things Jam needs in order to work :)
18252a38012Sejakowatz#-------------------------------------------------------------------------------
18352a38012Sejakowatz
18452a38012Sejakowatzrule UserObject
18552a38012Sejakowatz{
18652a38012Sejakowatz	switch $(2)
18752a38012Sejakowatz	{
18852a38012Sejakowatz	case *.S    : assemble $(1) : $(2) ;
18908125d07SIngo Weinhold	case *.o    : return ;
19052a38012Sejakowatz	case *      : ECHO "unknown suffix on" $(2) ;
19152a38012Sejakowatz	}
19252a38012Sejakowatz}
19352a38012Sejakowatz
19452a38012Sejakowatz# Override the default to give "prettier" command lines.
19552a38012Sejakowatzactions Cc
19652a38012Sejakowatz{
1970931b8f9SIngo Weinhold	$(CC) -c "$(2)" $(CCFLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ;
19852a38012Sejakowatz}
19952a38012Sejakowatz
20052a38012Sejakowatzactions C++
20152a38012Sejakowatz{
2020931b8f9SIngo Weinhold	$(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ;
20352a38012Sejakowatz}
20452a38012Sejakowatz
20552a38012Sejakowatz
20652a38012Sejakowatz#-------------------------------------------------------------------------------
20752a38012Sejakowatz# General High-level OBOS target rules
20852a38012Sejakowatz#-------------------------------------------------------------------------------
20952a38012Sejakowatz
2105f281ed5Sejakowatzrule App
2115f281ed5Sejakowatz{
2125f281ed5Sejakowatz	# App <name> : <sources> ;
213a6c008e1Sbeveloper	SetupIncludes ;
2145f281ed5Sejakowatz	SetupObjectsDir ;
2155f281ed5Sejakowatz	Main $(<) : $(>) ;
2165f281ed5Sejakowatz	MakeLocate $(<) : $(OBOS_APPS_DIR) ;
2175f281ed5Sejakowatz}
2185f281ed5Sejakowatz
219f06de7f3SIngo Weinholdrule BinCommand
220f06de7f3SIngo Weinhold{
221f06de7f3SIngo Weinhold	# BinCommand <name> : <sources> : <libraries> ;
222a6c008e1Sbeveloper	SetupIncludes ;
223f06de7f3SIngo Weinhold	SetupObjectsDir ;
224f06de7f3SIngo Weinhold	Main $(1) : $(2) ;
225f06de7f3SIngo Weinhold	MakeLocate $(1) : $(OBOS_BIN_DIR) ;
226f06de7f3SIngo Weinhold	LinkSharedOSLibs $(1) : $(3) ;
227f06de7f3SIngo Weinhold}
228f06de7f3SIngo Weinhold
229f06de7f3SIngo Weinholdrule StdBinCommands
230f06de7f3SIngo Weinhold{
231f06de7f3SIngo Weinhold	# StdBinCommands <sources> : <libs> ;
232a6c008e1Sbeveloper	SetupIncludes ;
233a6c008e1Sbeveloper	SetupObjectsDir ;
234f06de7f3SIngo Weinhold	local libs = $(2) ;
2359342c27aSIngo Weinhold	local source ;
236f06de7f3SIngo Weinhold	for source in $(1)
237f06de7f3SIngo Weinhold	{
238f06de7f3SIngo Weinhold		local target = $(source:S=) ;
239f06de7f3SIngo Weinhold		target = [ FGristFiles $(target) ] ;
240a6c008e1Sbeveloper
2413b4190abSbeveloper		BinCommand $(target) : $(source) : $(libs) ;
242f06de7f3SIngo Weinhold	}
243f06de7f3SIngo Weinhold}
244f06de7f3SIngo Weinhold
24552a38012Sejakowatzrule Preference
24652a38012Sejakowatz{
24752a38012Sejakowatz	# Preference <name> : <sources> ;
248a6c008e1Sbeveloper	SetupIncludes ;
24952a38012Sejakowatz	SetupObjectsDir ;
25052a38012Sejakowatz	Main $(<) : $(>) ;
25152a38012Sejakowatz	MakeLocate $(<) : $(OBOS_PREFS_DIR) ;
25252a38012Sejakowatz}
25352a38012Sejakowatz
25452a38012Sejakowatzrule Server
25552a38012Sejakowatz{
25652a38012Sejakowatz	# Server <name> : <sources> ;
25752a38012Sejakowatz
258a6c008e1Sbeveloper	SetupIncludes ;
25952a38012Sejakowatz	SetupObjectsDir ;
26052a38012Sejakowatz	Main $(<) : $(>) ;
26152a38012Sejakowatz	MakeLocate $(<) : $(OBOS_SERVER_DIR) ;
26252a38012Sejakowatz}
26352a38012Sejakowatz
26452a38012Sejakowatz# test pseudo targets
26552a38012SejakowatzNOTFILE obostests ;
26652a38012SejakowatzNOTFILE r5tests ;
26752a38012Sejakowatz
268d1f6c38fSTyler Dauwalderrule CommonTestLib
269d1f6c38fSTyler Dauwalder{
270c5ff4aa6STyler Dauwalder	# CommonTestLib <target> : <sources> : <obos libraries>
2719285de51STyler Dauwalder	#	: <r5 libraries> : <test libraries> : <public headers>;
272d1f6c38fSTyler Dauwalder	# Builds a unit test for both OBOS and R5 modules.
273d1f6c38fSTyler Dauwalder	# <target> The name of the target.
274d1f6c38fSTyler Dauwalder	# <sources> The list of sources.
275d1f6c38fSTyler Dauwalder	# <obos libraries> A list of link libraries for the OBOS tests (as passed
276d1f6c38fSTyler Dauwalder	# to LinkSharedOSLibs).
277d1f6c38fSTyler Dauwalder	# <r5 libraries> A list of link libraries for the R5 tests (as passed
278d1f6c38fSTyler Dauwalder	# to LinkSharedOSLibs).
2799285de51STyler Dauwalder	# <test libraries> A list of link libraries for both OBOS tests and R5 tests
2809285de51STyler Dauwalder	# that have a common name (i.e. specify libx.so and the OBOS tests will link
2819285de51STyler Dauwalder	# to libx.so and the R5 tests will link to libx_r5.so).
282d1f6c38fSTyler Dauwalder	# <public headers> A list of public header dirs (as passed to
283d1f6c38fSTyler Dauwalder	# UsePublicHeaders).
284d1f6c38fSTyler Dauwalder
285c5ff4aa6STyler Dauwalder	TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ;
286c5ff4aa6STyler Dauwalder	R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ;
287d1f6c38fSTyler Dauwalder}
288d1f6c38fSTyler Dauwalder
289d1f6c38fSTyler Dauwalderrule TestLib
290d1f6c38fSTyler Dauwalder{
291d1f6c38fSTyler Dauwalder	# TestLib <target> : <sources> : <dest> : <libraries> : <public headers>
292d1f6c38fSTyler Dauwalder	# Builds a unit test library for an OBOS module.
293d1f6c38fSTyler Dauwalder	# <target> The name of the target.
294d1f6c38fSTyler Dauwalder	# <sources> The list of sources.
295d1f6c38fSTyler Dauwalder	# <dest> The directory for the target (as passed to FDirName).
296d1f6c38fSTyler Dauwalder	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
297d1f6c38fSTyler Dauwalder	# <public headers> A list of public header dirs (as passed to
298d1f6c38fSTyler Dauwalder	# UsePublicHeaders).
299d1f6c38fSTyler Dauwalder
300d1f6c38fSTyler Dauwalder	local target = $(1) ;
301d1f6c38fSTyler Dauwalder	local sources = $(2) ;
302d1f6c38fSTyler Dauwalder	local dest = $(3) ;
303d1f6c38fSTyler Dauwalder	local libraries = $(4) ;
304d1f6c38fSTyler Dauwalder	local headerDirs = $(5) ;
3059342c27aSIngo Weinhold	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
306d1f6c38fSTyler Dauwalder
3079342c27aSIngo Weinhold	# Our Main replacement.
3089342c27aSIngo Weinhold	MainFromObjects $(target) : $(objects) ;
3099342c27aSIngo Weinhold	TestObjects $(sources) : $(headerDirs) ;
310d1f6c38fSTyler Dauwalder
311d1f6c38fSTyler Dauwalder	MakeLocate $(target) : $(dest) ;
3120d1cdd94SIngo Weinhold	Depends $(target) : libcppunit.so ;
3130d1cdd94SIngo Weinhold	Depends obostests : $(target) ;
314d1f6c38fSTyler Dauwalder	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
315d1f6c38fSTyler Dauwalder	LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ;
316d1f6c38fSTyler Dauwalder}
317d1f6c38fSTyler Dauwalder
318d1f6c38fSTyler Dauwalderrule R5TestLib
319d1f6c38fSTyler Dauwalder{
320c5ff4aa6STyler Dauwalder	# R5TestLib <target> : <sources> : <dest> : <libraries>
321d1f6c38fSTyler Dauwalder	# Builds a unit test for an R5 module. "_r5" is appended to the object
322d1f6c38fSTyler Dauwalder	# and the target name.
323d1f6c38fSTyler Dauwalder	# <target> The name of the target.
324d1f6c38fSTyler Dauwalder	# <sources> The list of sources.
325d1f6c38fSTyler Dauwalder	# <dest> The directory for the target (as passed to FDirName).
326d1f6c38fSTyler Dauwalder	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
327d1f6c38fSTyler Dauwalder
328d1f6c38fSTyler Dauwalder	local target = $(1:B)_r5$(1:S) ;
329d1f6c38fSTyler Dauwalder	local sources = $(2) ;
330c5ff4aa6STyler Dauwalder	local dest = $(3) ;
331d1f6c38fSTyler Dauwalder	local libraries = $(4) ;
332d1f6c38fSTyler Dauwalder	local objects = [ R5ObjectNames $(sources) ] ;
333d1f6c38fSTyler Dauwalder
334d1f6c38fSTyler Dauwalder	# Our Main replacement.
335d1f6c38fSTyler Dauwalder	MainFromObjects $(target) : $(objects) ;
3369342c27aSIngo Weinhold	TestObjects $(sources) : : true ;
337d1f6c38fSTyler Dauwalder
338d1f6c38fSTyler Dauwalder	MakeLocate $(target) : $(dest) ;
3390d1cdd94SIngo Weinhold	Depends $(target) : libcppunit.so ;
3400d1cdd94SIngo Weinhold	Depends r5tests : $(target) ;
341d1f6c38fSTyler Dauwalder	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
342d1f6c38fSTyler Dauwalder	LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ;
343d1f6c38fSTyler Dauwalder}
344d1f6c38fSTyler Dauwalder
34552a38012Sejakowatzrule CommonUnitTest
34652a38012Sejakowatz{
34752a38012Sejakowatz	# CommonUnitTest <target> : <sources> : <dest> : <obos libraries>
34852a38012Sejakowatz	#	: <r5 libraries> : <public headers>;
34952a38012Sejakowatz	# Builds a unit test for both OBOS and R5 modules.
35052a38012Sejakowatz	# <target> The name of the target.
35152a38012Sejakowatz	# <sources> The list of sources.
35252a38012Sejakowatz	# <dest> The directory for the target (as passed to FDirName).
35352a38012Sejakowatz	# <obos libraries> A list of link libraries for the OBOS tests (as passed
35452a38012Sejakowatz	# to LinkSharedOSLibs).
35552a38012Sejakowatz	# <r5 libraries> A list of link libraries for the R5 tests (as passed
35652a38012Sejakowatz	# to LinkSharedOSLibs).
35752a38012Sejakowatz	# <public headers> A list of public header dirs (as passed to
35852a38012Sejakowatz	# UsePublicHeaders).
35952a38012Sejakowatz
36052a38012Sejakowatz	UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ;
36152a38012Sejakowatz	R5UnitTest $(1) : $(2) : $(3) : $(5) ;
36252a38012Sejakowatz}
36352a38012Sejakowatz
36452a38012Sejakowatzrule UnitTest
36552a38012Sejakowatz{
36652a38012Sejakowatz	# UnitTest <target> : <sources> : <dest> : <libraries> : <public headers>
36752a38012Sejakowatz	# Builds a unit test for an OBOS module.
36852a38012Sejakowatz	# <target> The name of the target.
36952a38012Sejakowatz	# <sources> The list of sources.
37052a38012Sejakowatz	# <dest> The directory for the target (as passed to FDirName).
37152a38012Sejakowatz	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
37252a38012Sejakowatz	# <public headers> A list of public header dirs (as passed to
37352a38012Sejakowatz	# UsePublicHeaders).
37452a38012Sejakowatz
37552a38012Sejakowatz	local target = $(1) ;
37652a38012Sejakowatz	local sources = $(2) ;
37752a38012Sejakowatz	local dest = $(3) ;
37852a38012Sejakowatz	local libraries = $(4) ;
37952a38012Sejakowatz	local headerDirs = $(5) ;
3809342c27aSIngo Weinhold	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
38152a38012Sejakowatz
3829342c27aSIngo Weinhold	# Our Main replacement.
3839342c27aSIngo Weinhold	MainFromObjects $(target) : $(objects) ;
3849342c27aSIngo Weinhold	TestObjects $(sources) : $(headerDirs) ;
3853b9eae39SIngo Weinhold
38652a38012Sejakowatz	MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ;
3879eea4522SIngo Weinhold	Depends $(target) : libcppunit.so ;
3889eea4522SIngo Weinhold	Depends obostests : $(target) ;
38952a38012Sejakowatz	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
39052a38012Sejakowatz}
39152a38012Sejakowatz
39252a38012Sejakowatzrule R5UnitTest
39352a38012Sejakowatz{
39452a38012Sejakowatz	# R5UnitTest <target> : <sources> : <dest> : <libraries>
39552a38012Sejakowatz	# Builds a unit test for an R5 module. "_r5" is appended to the object
39652a38012Sejakowatz	# and the target name.
39752a38012Sejakowatz	# <target> The name of the target.
39852a38012Sejakowatz	# <sources> The list of sources.
39952a38012Sejakowatz	# <dest> The directory for the target (as passed to FDirName).
40052a38012Sejakowatz	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
40152a38012Sejakowatz
40252a38012Sejakowatz	local target = $(1)_r5 ;
40352a38012Sejakowatz	local sources = $(2) ;
40452a38012Sejakowatz	local dest = $(3) ;
40552a38012Sejakowatz	local libraries = $(4) ;
40652a38012Sejakowatz	local objects = [ R5ObjectNames $(sources) ] ;
40752a38012Sejakowatz
40852a38012Sejakowatz	# Our Main replacement.
40952a38012Sejakowatz	MainFromObjects $(target) : $(objects) ;
4109342c27aSIngo Weinhold	TestObjects $(sources) : : true ;
41152a38012Sejakowatz
41252a38012Sejakowatz	MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ;
4139eea4522SIngo Weinhold	Depends $(target) : libcppunit.so ;
4149eea4522SIngo Weinhold	Depends r5tests : $(target) ;
41552a38012Sejakowatz	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
41652a38012Sejakowatz}
41752a38012Sejakowatz
41852a38012Sejakowatzrule R5ObjectNames
41952a38012Sejakowatz{
42052a38012Sejakowatz	# R5ObjectNames <sources> ;
42152a38012Sejakowatz	# Returns a list of gristed object names given a list of source file names.
42252a38012Sejakowatz	# Moreover each object names gets "_r5" inserted before the object suffix.
42352a38012Sejakowatz	local objects = $(1:S=)_r5 ;
42452a38012Sejakowatz	return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ;
42552a38012Sejakowatz}
42652a38012Sejakowatz
4279342c27aSIngo Weinholdrule R5Objects
4289342c27aSIngo Weinhold{
4299342c27aSIngo Weinhold	# R5Objects <sources>
430dd9f8062SIngo Weinhold	# Similar to Objects, but appends "_r5" to the object file names and
431dd9f8062SIngo Weinhold	# removes `-nostdinc' from the CC and C++ flags to enable system headers.
4329342c27aSIngo Weinhold	# <sources> The source files.
4339342c27aSIngo Weinhold
434dd9f8062SIngo Weinhold	# Remove `-nostdinc' from CCFLAGS and C++FLAGS.
435dd9f8062SIngo Weinhold	local oldCCFLAGS = $(CCFLAGS) ;
436dd9f8062SIngo Weinhold	local oldC++FLAGS = $(C++FLAGS) ;
437dd9f8062SIngo Weinhold	CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ;
438dd9f8062SIngo Weinhold	C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ;
439dd9f8062SIngo Weinhold
4409342c27aSIngo Weinhold	local sources = $(1) ;
4419342c27aSIngo Weinhold	local source ;
4429342c27aSIngo Weinhold	for source in [ FGristFiles $(sources) ]
4439342c27aSIngo Weinhold	{
4449342c27aSIngo Weinhold		local object = [ R5ObjectNames $(source) ] ;
4459342c27aSIngo Weinhold		Object $(object) : $(source) ;
4469342c27aSIngo Weinhold		LocalDepends obj : $(object) ;
4479342c27aSIngo Weinhold	}
448dd9f8062SIngo Weinhold
449dd9f8062SIngo Weinhold	# Reset CCFLAGS and C++FLAGS to original values.
450dd9f8062SIngo Weinhold	CCFLAGS = $(oldCCFLAGS) ;
451dd9f8062SIngo Weinhold	C++FLAGS = $(oldC++FLAGS) ;
4529342c27aSIngo Weinhold}
4539342c27aSIngo Weinhold
4549342c27aSIngo Weinholdrule TestObjects
4559342c27aSIngo Weinhold{
4569342c27aSIngo Weinhold	# TestLib <sources> : <public headers> : <r5>
4579342c27aSIngo Weinhold	# Compiles objects for tests.
4589342c27aSIngo Weinhold	# <sources> The list of sources.
4599342c27aSIngo Weinhold	# <public headers> A list of public header dirs (as passed to
4609342c27aSIngo Weinhold	# UsePublicHeaders).
4619342c27aSIngo Weinhold	# <r5> If set, "_r5" is appended to the object file names and
4629342c27aSIngo Weinhold	# <public headers> is ignored. Furthermore the pre-processor macro
4639342c27aSIngo Weinhold	# TEST_R5 is defined, TEST_OBOS otherwise.
4649342c27aSIngo Weinhold
4659342c27aSIngo Weinhold	local sources = $(1) ;
4669342c27aSIngo Weinhold	local headerDirs = $(2) ;
4679342c27aSIngo Weinhold	local r5 = $(3) ;
4689342c27aSIngo Weinhold	local objects ;
4699342c27aSIngo Weinhold
4709342c27aSIngo Weinhold	# Turn optimization off.
47196d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
4729342c27aSIngo Weinhold		local optim = $(OPTIM) ;
4739342c27aSIngo Weinhold		OPTIM = ;
47496d27465SIngo Weinhold	}
4759342c27aSIngo Weinhold
4769342c27aSIngo Weinhold	SetupObjectsDir ;
4779342c27aSIngo Weinhold
4789342c27aSIngo Weinhold	# compile
4799342c27aSIngo Weinhold	if $(r5) {
480dd9f8062SIngo Weinhold		SetupR5Includes ;
4819342c27aSIngo Weinhold		objects = [ R5ObjectNames $(sources) ] ;
4829342c27aSIngo Weinhold		R5Objects $(sources) ;
4839342c27aSIngo Weinhold	} else {
484dd9f8062SIngo Weinhold		SetupIncludes ;
4859342c27aSIngo Weinhold		objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
4869342c27aSIngo Weinhold		Objects $(sources) ;
4879342c27aSIngo Weinhold	}
4889342c27aSIngo Weinhold
4899342c27aSIngo Weinhold	# set headers/defines
4909342c27aSIngo Weinhold	UseCppUnitObjectHeaders $(objects) ;
4919342c27aSIngo Weinhold	if $(r5) {
4929342c27aSIngo Weinhold		ObjectDefines $(objects) : TEST_R5 ;
4939342c27aSIngo Weinhold	} else {
4949342c27aSIngo Weinhold		UsePublicObjectHeaders $(objects) : $(headerDirs) ;
4959342c27aSIngo Weinhold		ObjectDefines $(objects) : TEST_OBOS ;
4969342c27aSIngo Weinhold	}
4979342c27aSIngo Weinhold
49896d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
4999342c27aSIngo Weinhold		# Turn debugging on. That is usually desired for test code.
5009342c27aSIngo Weinhold		ObjectCcFlags $(objects) : "-g" ;
5019342c27aSIngo Weinhold		ObjectC++Flags $(objects) : "-g" ;
5029342c27aSIngo Weinhold
5039342c27aSIngo Weinhold		# Turn optimization on again.
5049342c27aSIngo Weinhold		OPTIM = $(optim) ;
5059342c27aSIngo Weinhold	}
50696d27465SIngo Weinhold}
5079342c27aSIngo Weinhold
5089285de51STyler Dauwalderrule R5SharedLibraryNames
5099285de51STyler Dauwalder{
5109285de51STyler Dauwalder	# R5SharedLibraryNames <sources> ;
5119285de51STyler Dauwalder	# Returns a list of shared library names given a list of file names. NO
5129285de51STyler Dauwalder	# GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted
5139285de51STyler Dauwalder	# before the shared lib suffix.
5149285de51STyler Dauwalder	return $(1:S=)_r5.so ;
5159285de51STyler Dauwalder}
5169285de51STyler Dauwalder
5179fc6b2e1SIngo Weinholdrule SimpleTest
5189fc6b2e1SIngo Weinhold{
5199fc6b2e1SIngo Weinhold	# UnitTest <target> : <sources> : <libraries>
5209fc6b2e1SIngo Weinhold	# Builds a unit test for an OBOS module.
5219fc6b2e1SIngo Weinhold	# <target> The name of the target.
5229fc6b2e1SIngo Weinhold	# <sources> The list of sources.
5239fc6b2e1SIngo Weinhold	# <dest> The directory for the target (as passed to FDirName).
5249fc6b2e1SIngo Weinhold	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
5259fc6b2e1SIngo Weinhold	# <public headers> A list of public header dirs (as passed to
5269fc6b2e1SIngo Weinhold	# UsePublicHeaders).
5279fc6b2e1SIngo Weinhold
5289fc6b2e1SIngo Weinhold	local target = $(1) ;
5299fc6b2e1SIngo Weinhold	local sources = $(2) ;
5309fc6b2e1SIngo Weinhold	local libraries = $(3) ;
5319fc6b2e1SIngo Weinhold	local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ;
5329fc6b2e1SIngo Weinhold
5339fc6b2e1SIngo Weinhold	# Turn optimization off.
53496d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
5359fc6b2e1SIngo Weinhold		local optim = $(OPTIM) ;
5369fc6b2e1SIngo Weinhold		OPTIM = ;
53796d27465SIngo Weinhold	}
5389fc6b2e1SIngo Weinhold
539a6c008e1Sbeveloper	SetupIncludes ;
5409fc6b2e1SIngo Weinhold	SetupObjectsDir ;
5419fc6b2e1SIngo Weinhold	MakeLocateObjects $(sources) ;
5429fc6b2e1SIngo Weinhold	Main $(target) : $(sources) ;
5439fc6b2e1SIngo Weinhold	MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ;
5449eea4522SIngo Weinhold	Depends obostests : $(target) ;
5459fc6b2e1SIngo Weinhold	LinkSharedOSLibs $(target) : $(libraries) ;
5469fc6b2e1SIngo Weinhold	ObjectDefines $(sources) : TEST_OBOS ;
5479fc6b2e1SIngo Weinhold
54896d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
5499fc6b2e1SIngo Weinhold		# Turn debugging on. That is usually desired for test code.
5509fc6b2e1SIngo Weinhold		ObjectCcFlags $(sources) : "-g" ;
5519fc6b2e1SIngo Weinhold		ObjectC++Flags $(sources) : "-g" ;
5529fc6b2e1SIngo Weinhold
5539fc6b2e1SIngo Weinhold		# Turn optimization on again.
5549fc6b2e1SIngo Weinhold		OPTIM = $(optim) ;
5559fc6b2e1SIngo Weinhold	}
55696d27465SIngo Weinhold}
5579fc6b2e1SIngo Weinhold
55852a38012Sejakowatzrule Addon
55952a38012Sejakowatz{
5607a384fdeSIngo Weinhold	# Addon <name> : <relpath> : <sources> : <is executable> ;
5617a384fdeSIngo Weinhold	# <name>: Name of the add-on.
5627a384fdeSIngo Weinhold	# <relpath>: Path where the add-on shall live relative to the add-on dir.
5637a384fdeSIngo Weinhold	# <sources>: Source files.
5647a384fdeSIngo Weinhold	# <is executable>: true, if the target shall be executable as well
5657a384fdeSIngo Weinhold
5667a384fdeSIngo Weinhold	local isExecutable = $(4) ;
56752a38012Sejakowatz
568a6c008e1Sbeveloper	SetupIncludes ;
56952a38012Sejakowatz	SetupObjectsDir ;
57052a38012Sejakowatz	Main $(1) : $(3) ;
57152a38012Sejakowatz
57252a38012Sejakowatz	# Create output dir path for addon
57352a38012Sejakowatz	local targetdir;
57452a38012Sejakowatz	targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ;
57552a38012Sejakowatz
57652a38012Sejakowatz	MakeLocate $(1) : $(targetdir) ;
5777a384fdeSIngo Weinhold
5787a384fdeSIngo Weinhold	local linkFlags = -Xlinker -soname=\"$(1)\" ;
5797a384fdeSIngo Weinhold	if $(isExecutable) != true {
5807a384fdeSIngo Weinhold		linkFlags = -nostart $(linkFlags) ;
5817a384fdeSIngo Weinhold	}
5827a384fdeSIngo Weinhold	LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ;
583af28904fSIngo Weinhold}
584af28904fSIngo Weinhold
58558efc9d8SIngo Weinholdrule R5KernelAddon
586af28904fSIngo Weinhold{
58758efc9d8SIngo Weinhold	# R5KernelAddon <name> : <relpath> : <sources> ;
588af28904fSIngo Weinhold
589af28904fSIngo Weinhold	local sources = $(3) ;
590af28904fSIngo Weinhold
591af28904fSIngo Weinhold	Addon $(1) : $(2) : $(3) ;
592af28904fSIngo Weinhold	ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ;
593af28904fSIngo Weinhold	ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic
594af28904fSIngo Weinhold								-fno-exceptions -fno-rtti ;
5959eea4522SIngo Weinhold	LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ;
596af28904fSIngo Weinhold	LinkSharedOSLibs $(1) : /boot/develop/lib/x86/_KERNEL_ ;
59752a38012Sejakowatz}
59852a38012Sejakowatz
5994fb5add0SMatthew Wilberrule Translator
6004fb5add0SMatthew Wilber{
6014fb5add0SMatthew Wilber	# Translator <name> : <sources> ;
602a6c008e1Sbeveloper	SetupIncludes ;
6034fb5add0SMatthew Wilber	SetupObjectsDir ;
6044fb5add0SMatthew Wilber	Main $(1) : $(2) ;
6054fb5add0SMatthew Wilber
6064fb5add0SMatthew Wilber	# Create output dir path for translator
6074fb5add0SMatthew Wilber	local targetdir;
6084fb5add0SMatthew Wilber	targetdir = [ FDirName $(OBOS_ADDON_DIR) translators ] ;
6094fb5add0SMatthew Wilber	MakeLocate $(1) : $(targetdir) ;
6104fb5add0SMatthew Wilber}
6114fb5add0SMatthew Wilber
61252a38012Sejakowatzrule MakeLocateObjects
61352a38012Sejakowatz{
61421df5945SIngo Weinhold	# MakeLocateObjects <sources_or_objects> ;
61552a38012Sejakowatz
61621df5945SIngo Weinhold	local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ;
61752a38012Sejakowatz
61852a38012Sejakowatz	for o in $(_objs)
61952a38012Sejakowatz	{
62052a38012Sejakowatz		local dir = $(o:D) ;
62152a38012Sejakowatz		if $(dir) {
62252a38012Sejakowatz			MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ;
62352a38012Sejakowatz		} else {
62452a38012Sejakowatz			MakeLocate $(o) : $(LOCATE_TARGET) ;
62552a38012Sejakowatz		}
62652a38012Sejakowatz	}
62752a38012Sejakowatz}
62852a38012Sejakowatz
62952a38012Sejakowatzrule StaticLibrary
63052a38012Sejakowatz{
63152a38012Sejakowatz	# StaticLibrary <name> : <sources> ;
63252a38012Sejakowatz
633a6c008e1Sbeveloper	SetupIncludes ;
63452a38012Sejakowatz	SetupObjectsDir ;
63552a38012Sejakowatz	MakeLocateObjects $(2) ;
63652a38012Sejakowatz	Library lib$(<).a : $(>) ;
63752a38012Sejakowatz	MakeLocate lib$(<).a : $(OBOS_STLIB_DIR) ;
63852a38012Sejakowatz}
63952a38012Sejakowatz
64080721244SAxel Dörflerrule MergeObjectFromObjects
64180721244SAxel Dörfler{
64280721244SAxel Dörfler	# MergeObjectFromObjects <name> : <objects> ;
64380721244SAxel Dörfler	MakeLocate $(1) : $(LOCATE_TARGET) ;
64480721244SAxel Dörfler	Depends $(<) : $(>) ;
64580721244SAxel Dörfler	LINK on $(1) = ld ;
64654b7cbe1SIngo Weinhold	MergeObjectFromObjects1 $(1) : [ FGristFiles $(2) ] ;
64780721244SAxel Dörfler}
64880721244SAxel Dörfler
64954b7cbe1SIngo Weinholdactions MergeObjectFromObjects1
65080721244SAxel Dörfler{
65180721244SAxel Dörfler	$(LINK) -r $(2) -o $(1) ;
65280721244SAxel Dörfler}
65380721244SAxel Dörfler
65480721244SAxel Dörflerrule MergeObject
65580721244SAxel Dörfler{
65680721244SAxel Dörfler	# MergeObject <name> : <sources> ;
65780721244SAxel Dörfler	SetupIncludes ;
65880721244SAxel Dörfler	SetupObjectsDir ;
65980721244SAxel Dörfler	MakeLocateObjects $(2) ;
66080721244SAxel Dörfler	Objects $(2) ;
66180721244SAxel Dörfler	MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) ;
66280721244SAxel Dörfler}
66380721244SAxel Dörfler
66421df5945SIngo Weinholdrule SharedLibraryFromObjects
66552a38012Sejakowatz{
66621df5945SIngo Weinhold	# SharedLibraryFromObjects <name> : <objects> ;
66752a38012Sejakowatz	local _lib = lib$(1).so ;
66821df5945SIngo Weinhold	MainFromObjects $(_lib) : $(2) ;
66952a38012Sejakowatz	MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ;
6709eea4522SIngo Weinhold	LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ]
6719eea4522SIngo Weinhold						   -nostart -Xlinker -soname=\"$(_lib)\" ;
67252a38012Sejakowatz}
67352a38012Sejakowatz
67421df5945SIngo Weinholdrule SharedLibrary
67521df5945SIngo Weinhold{
67621df5945SIngo Weinhold	# SharedLibrary <name> : <sources> ;
677a6c008e1Sbeveloper	SetupIncludes ;
67821df5945SIngo Weinhold	SetupObjectsDir ;
67921df5945SIngo Weinhold	MakeLocateObjects $(2) ;
68021df5945SIngo Weinhold	Objects $(2) ;
68121df5945SIngo Weinhold	SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) ;
68221df5945SIngo Weinhold}
68321df5945SIngo Weinhold
68452a38012Sejakowatzrule LinkSharedOSLibs
68552a38012Sejakowatz{
68652a38012Sejakowatz	# LinkSharedOSLibs <name> : <libs> ;
68752a38012Sejakowatz	# Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or
6884236d490SIngo Weinhold	# "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy
6894236d490SIngo Weinhold	# has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the
6904236d490SIngo Weinhold	# file will be bound!), otherwise it is prefixed "-l" and added to
6914236d490SIngo Weinhold	# LINKLIBS.
69252a38012Sejakowatz
69352a38012Sejakowatz	for i in $(>)
69452a38012Sejakowatz	{
6954236d490SIngo Weinhold		local isfile = ;
6964236d490SIngo Weinhold		if $(i:D) || $(i:G) {
6974236d490SIngo Weinhold			isfile = true ;
6984236d490SIngo Weinhold		} else {
69952a38012Sejakowatz			switch $(i:B)
70052a38012Sejakowatz			{
7014236d490SIngo Weinhold				case lib*	: isfile = true ;
7024236d490SIngo Weinhold				case *		: isfile = ;
7034236d490SIngo Weinhold			}
7044236d490SIngo Weinhold		}
7054236d490SIngo Weinhold		if $(isfile) {
7069eea4522SIngo Weinhold			NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ;
7079eea4522SIngo Weinhold			Depends $(1) : $(i) ;
7084236d490SIngo Weinhold		} else {
7099eea4522SIngo Weinhold			LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ;
71052a38012Sejakowatz		}
71152a38012Sejakowatz	}
71252a38012Sejakowatz}
71352a38012Sejakowatz
71452a38012Sejakowatzrule LinkStaticOSLibs
71552a38012Sejakowatz{
71652a38012Sejakowatz	# LinkStaticOSLibs <name> : <libs> ;
71752a38012Sejakowatz
71852a38012Sejakowatz	for i in $(>)
71952a38012Sejakowatz	{
72052a38012Sejakowatz		LINKLIBS on $(<) = $(LINKLIBS) -l $(i) ;
72152a38012Sejakowatz	}
72252a38012Sejakowatz}
72352a38012Sejakowatz
72452a38012Sejakowatzrule AddResources
72552a38012Sejakowatz{
72652a38012Sejakowatz	# AddResources <name> : <resourcefiles> ;
72752a38012Sejakowatz
7289fc6b2e1SIngo Weinhold	SEARCH on $(2) += $(SEARCH_SOURCE) ;
72978599cf0SIngo Weinhold	RESFILES on $(1) += $(2) ;
73052a38012Sejakowatz}
73152a38012Sejakowatz
7327d7f280eSIngo Weinholdrule PublicHeaders
73352a38012Sejakowatz{
7347d7f280eSIngo Weinhold	# PublicHeaders <group list>
73552a38012Sejakowatz	#
7367d7f280eSIngo Weinhold	# Returns the directory names for the public header dirs identified by
7377d7f280eSIngo Weinhold	# <group list>.
73852a38012Sejakowatz
73952a38012Sejakowatz	local list = $(1) ;
740b005dbe3SAxel Dörfler	local dirs = [ FDirName $(OBOS_TOP) headers os ] ;
741b005dbe3SAxel Dörfler
74252a38012Sejakowatz	for i in $(list) {
7437d7f280eSIngo Weinhold		dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ;
7447d7f280eSIngo Weinhold	}
7457d7f280eSIngo Weinhold	return $(dirs) ;
74652a38012Sejakowatz}
74752a38012Sejakowatz
7487d7f280eSIngo Weinholdrule PrivateHeaders
7497d7f280eSIngo Weinhold{
7507d7f280eSIngo Weinhold	# PrivateHeaders <group list>
7517d7f280eSIngo Weinhold	#
7527d7f280eSIngo Weinhold	# Returns the directory names for the private header dirs identified by
7537d7f280eSIngo Weinhold	# <group list>.
7547d7f280eSIngo Weinhold
7557d7f280eSIngo Weinhold	local list = $(1) ;
7567d7f280eSIngo Weinhold	local dirs ;
7577d7f280eSIngo Weinhold	for i in $(list) {
7587d7f280eSIngo Weinhold		dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ;
7597d7f280eSIngo Weinhold	}
7607d7f280eSIngo Weinhold	return $(dirs) ;
7617d7f280eSIngo Weinhold}
7627d7f280eSIngo Weinhold
7637d7f280eSIngo Weinholdrule ArchHeaders
7647d7f280eSIngo Weinhold{
7657d7f280eSIngo Weinhold	# usage: ArchHeaders <arch> ;
7667d7f280eSIngo Weinhold	#
7677d7f280eSIngo Weinhold	# <arch> specifies the architecture (e.g. x86).
7687d7f280eSIngo Weinhold
7697d7f280eSIngo Weinhold	return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ;
7707d7f280eSIngo Weinhold}
7717d7f280eSIngo Weinhold
7727d7f280eSIngo Weinholdrule UsePublicHeaders
7737d7f280eSIngo Weinhold{
774a6c008e1Sbeveloper	# XXX changed to do nothing
7757d7f280eSIngo Weinhold}
7767d7f280eSIngo Weinhold
7777d7f280eSIngo Weinholdrule UsePublicObjectHeaders
7787d7f280eSIngo Weinhold{
7797d7f280eSIngo Weinhold	# UsePublicObjectHeaders <sources_or_objects> : <group list> ;
7807d7f280eSIngo Weinhold	#
7817d7f280eSIngo Weinhold	# Adds the public C header dirs given by <group list> to the header search
7827d7f280eSIngo Weinhold	# dirs of <sources_or_objects>.
7837d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
7847d7f280eSIngo Weinhold
7857d7f280eSIngo Weinhold	ObjectHdrs $(1) : [ PublicHeaders $(2) ] ;
78652a38012Sejakowatz}
78752a38012Sejakowatz
78852a38012Sejakowatzrule UsePrivateHeaders
78952a38012Sejakowatz{
7907d7f280eSIngo Weinhold	# UsePrivateHeaders <group list> ;
79152a38012Sejakowatz	#
79252a38012Sejakowatz	# Adds the private C header dirs given by <group list> to the header search
7937d7f280eSIngo Weinhold	# dirs of the subdirectory.
7947d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *before* the rule that builds the objects.
79552a38012Sejakowatz
7967d7f280eSIngo Weinhold	UseHeaders [ PrivateHeaders $(1) ] ;
79752a38012Sejakowatz}
79852a38012Sejakowatz
7997d7f280eSIngo Weinholdrule UsePrivateObjectHeaders
8007d7f280eSIngo Weinhold{
8017d7f280eSIngo Weinhold	# UsePrivateObjectHeaders <sources_or_objects> : <group list> ;
8027d7f280eSIngo Weinhold	#
8037d7f280eSIngo Weinhold	# Adds the private C header dirs given by <group list> to the header search
8047d7f280eSIngo Weinhold	# dirs of <sources_or_objects>.
8057d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
8067d7f280eSIngo Weinhold
8077d7f280eSIngo Weinhold	ObjectHdrs $(1) : [ PrivateHeaders $(2) ] ;
80852a38012Sejakowatz}
80952a38012Sejakowatz
81052a38012Sejakowatzrule UseHeaders
81152a38012Sejakowatz{
8127d7f280eSIngo Weinhold	# UseHeaders <headers> ;
81352a38012Sejakowatz	#
81452a38012Sejakowatz	# Adds the C header dirs <headers> to the header search
8157d7f280eSIngo Weinhold	# dirs of the subdirectory.
8167d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *before* the rule that builds the objects.
81752a38012Sejakowatz
8187d7f280eSIngo Weinhold	local header ;
8197d7f280eSIngo Weinhold	for header in $(1) {
82052a38012Sejakowatz		SubDirHdrs $(header) ;
82152a38012Sejakowatz	}
82252a38012Sejakowatz}
82352a38012Sejakowatz
82452a38012Sejakowatzrule UseCppUnitHeaders
82552a38012Sejakowatz{
8267d7f280eSIngo Weinhold	SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ;
82752a38012Sejakowatz}
82852a38012Sejakowatz
829be5af1baSIngo Weinholdrule UseCppUnitObjectHeaders
830be5af1baSIngo Weinhold{
831be5af1baSIngo Weinhold	ObjectHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] ;
832be5af1baSIngo Weinhold}
833be5af1baSIngo Weinhold
83452a38012Sejakowatzrule UseArchHeaders
83552a38012Sejakowatz{
8367d7f280eSIngo Weinhold	# usage: UseArchHeaders <arch> ;
8377d7f280eSIngo Weinhold	#
83852a38012Sejakowatz	# <arch> specifies the architecture (e.g. x86).
8397d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *before* the rule that builds the objects.
8407d7f280eSIngo Weinhold
8417d7f280eSIngo Weinhold	local headers = [ ArchHeaders $(1) ] ;
84252a38012Sejakowatz	local opt = -D$(OBOS_TARGET_DEFINE) ;
843c633961aSIngo Weinhold
84452a38012Sejakowatz	SubDirCcFlags $(opt)  ;
84552a38012Sejakowatz	SubDirC++Flags $(opt)  ;
846089a0629Sbeveloper	HDRS += $(headers) ;
847c633961aSIngo Weinhold}
848c633961aSIngo Weinhold
8497d7f280eSIngo Weinholdrule UseArchObjectHeaders
8507d7f280eSIngo Weinhold{
8517d7f280eSIngo Weinhold	# usage: UseArchObjectHeaders <sources_or_objects> : <arch> ;
8527d7f280eSIngo Weinhold	#
8537d7f280eSIngo Weinhold	# <arch> specifies the architecture (e.g. x86).
8547d7f280eSIngo Weinhold	# <sources_or_objects> Source or object files.
8557d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
8567d7f280eSIngo Weinhold
8577d7f280eSIngo Weinhold	local targets = $(1) ;
8587d7f280eSIngo Weinhold	local headers = [ ArchHeaders $(2) ] ;
8597d7f280eSIngo Weinhold	local opt = -D$(OBOS_TARGET_DEFINE) ;
8607d7f280eSIngo Weinhold
8617d7f280eSIngo Weinhold	ObjectCcFlags $(targets) : $(opt)  ;
8627d7f280eSIngo Weinhold	ObjectC++Flags $(targets) : $(opt)  ;
8637d7f280eSIngo Weinhold	ObjectHdrs $(targets) : $(headers) ;
86452a38012Sejakowatz}
86552a38012Sejakowatz
866d25a77b4SIngo Weinholdrule UsePosixHeaders
867d25a77b4SIngo Weinhold{
868a6c008e1Sbeveloper	# XXX changed to do nothing
869d25a77b4SIngo Weinhold}
870d25a77b4SIngo Weinhold
871d25a77b4SIngo Weinholdrule UsePosixObjectHeaders
872d25a77b4SIngo Weinhold{
873d25a77b4SIngo Weinhold	# UsePosixObjectHeaders <sources_or_objects> ;
874d25a77b4SIngo Weinhold	#
875d25a77b4SIngo Weinhold	# Adds the POSIX header dir to the header search
876d25a77b4SIngo Weinhold	# dirs of <sources_or_objects>.
877d25a77b4SIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
878d25a77b4SIngo Weinhold
879d25a77b4SIngo Weinhold	ObjectHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] ;
880d25a77b4SIngo Weinhold}
881d25a77b4SIngo Weinhold
8823b9eae39SIngo Weinholdrule SplitPath
8833b9eae39SIngo Weinhold{
8843b9eae39SIngo Weinhold	# SplitPath <path> ;
8853b9eae39SIngo Weinhold	# Decomposes a path into its components.
8863b9eae39SIngo Weinhold	local path = $(1:G=) ;
8873b9eae39SIngo Weinhold	local components ;
8888c27f58dSIngo Weinhold	# $(path:D) for "/" is "/". Therefore the second condition.
8898c27f58dSIngo Weinhold	while $(path:D) && $(path:D) != $(path)
8903b9eae39SIngo Weinhold	{
8913b9eae39SIngo Weinhold		# Note: $(path:B) returns "." for "..", but $(path:D=) is fine.
8923b9eae39SIngo Weinhold		components = $(path:D=) $(components) ;
8933b9eae39SIngo Weinhold		path = $(path:D) ;
8943b9eae39SIngo Weinhold	}
8953b9eae39SIngo Weinhold	components = $(path) $(components) ;
8963b9eae39SIngo Weinhold	return $(components) ;
8973b9eae39SIngo Weinhold}
8983b9eae39SIngo Weinhold
8999fc6b2e1SIngo Weinholdrule PrependObjectHdrs
9009fc6b2e1SIngo Weinhold{
9019fc6b2e1SIngo Weinhold	# PrependObjectHdrs <objects_or_sources> : <dirs> ;
9029fc6b2e1SIngo Weinhold	# Prepends <dirs> to the list of header search dirs of the objects
9039fc6b2e1SIngo Weinhold	# specified by <objects_or_sources>. The HDRS variable will not be
9049fc6b2e1SIngo Weinhold	# changed, only CCHDRS.
9059fc6b2e1SIngo Weinhold	# Note: A subsequent ObjectHdrs invocation will therefore undo the
9069fc6b2e1SIngo Weinhold	# effect of this rule.
9079fc6b2e1SIngo Weinhold	# NOTE: This is a hack.
9089fc6b2e1SIngo Weinhold
9099fc6b2e1SIngo Weinhold	local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ;
9109fc6b2e1SIngo Weinhold	local dirs = $(2) ;
9119fc6b2e1SIngo Weinhold	for object in $(objects) {
9129fc6b2e1SIngo Weinhold		# Don't change HDRS to avoid screwing up the header scanning.
9139fc6b2e1SIngo Weinhold		PREPENDED_HDRS on $(object)
9149fc6b2e1SIngo Weinhold			= $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ;
9159fc6b2e1SIngo Weinhold		CCHDRS on $(object)
9169fc6b2e1SIngo Weinhold			= [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ;
9179fc6b2e1SIngo Weinhold	}
9189fc6b2e1SIngo Weinhold}
9199fc6b2e1SIngo Weinhold
9203b9eae39SIngo Weinholdrule SymLink
9213b9eae39SIngo Weinhold{
9223b9eae39SIngo Weinhold	# SymLink <target> : <source> ;
9233b9eae39SIngo Weinhold	# Links <target> to <source>.
9243b9eae39SIngo Weinhold	# <source> is the exact link contents. No binding is done.
9253b9eae39SIngo Weinhold	LINKCONTENTS on $(1) = $(2) ;
9263b9eae39SIngo Weinhold	SymLink1 $(1) ;
9279eea4522SIngo Weinhold	LocalDepends all : $(target) ;
9283b9eae39SIngo Weinhold}
9293b9eae39SIngo Weinhold
9303b9eae39SIngo Weinholdactions SymLink1
9313b9eae39SIngo Weinhold{
9320931b8f9SIngo Weinhold	$(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)"
9330931b8f9SIngo Weinhold}
9340931b8f9SIngo Weinhold
9350931b8f9SIngo Weinholdrule RelSymLink
9360931b8f9SIngo Weinhold{
9370931b8f9SIngo Weinhold	# RelSymLink <link> : <link target>
9380931b8f9SIngo Weinhold	# Creates a relative symbolic link from <link> to <link target>.
9390931b8f9SIngo Weinhold	# <link> and <link target> can be usual targets. They may have a grist
9400931b8f9SIngo Weinhold	# and don't need to have any dirname. Their LOCATE variables are used to
9410931b8f9SIngo Weinhold	# find their locations.
9420931b8f9SIngo Weinhold
9430931b8f9SIngo Weinhold	local target = $(1) ;
9440931b8f9SIngo Weinhold	local source = $(2) ;
9450931b8f9SIngo Weinhold	local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ;
9460931b8f9SIngo Weinhold	local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ;
9470931b8f9SIngo Weinhold	local sourcePath = $(source:G=) ;
9480931b8f9SIngo Weinhold	sourcePath = $(sourcePath:D=$(sourceDir)) ;
9490931b8f9SIngo Weinhold	local targetDirComponents = [ SplitPath $(targetDir) ] ;
9500931b8f9SIngo Weinhold	local sourceComponents = [ SplitPath $(sourcePath) ] ;
9510931b8f9SIngo Weinhold
9520931b8f9SIngo Weinhold	SymLink $(target)
9530931b8f9SIngo Weinhold		: [ FRelPath $(targetDirComponents) : $(sourceComponents) ] ;
9540931b8f9SIngo Weinhold	NOUPDATE $(target);
9559eea4522SIngo Weinhold	Depends $(target) : $(source) ;
9566991af8cSIngo Weinhold	LocalClean clean : $(target) ;
9573b9eae39SIngo Weinhold}
9583b9eae39SIngo Weinhold
959d391d2ebSIngo Weinholdrule AbsSymLink
960d391d2ebSIngo Weinhold{
961d391d2ebSIngo Weinhold	# RelSymLink <link> : <link target> : <link dir>
962d391d2ebSIngo Weinhold	# Creates an absolute symbolic link from <link> to <link target>.
963d391d2ebSIngo Weinhold	# <link> and <link target> must be usual targets. If <link dir> is
964d391d2ebSIngo Weinhold	# given, then it is set as LOCATE directory on <link>.
965d391d2ebSIngo Weinhold
966d391d2ebSIngo Weinhold	LocalDepends files : $(1) ;
967d391d2ebSIngo Weinhold	Depends $(1) : $(2) ;
968d391d2ebSIngo Weinhold	if $(3) {
969d391d2ebSIngo Weinhold		MakeLocate $(1) : $(3) ;
970d391d2ebSIngo Weinhold	}
971d391d2ebSIngo Weinhold	SEARCH on $(2) += $(SEARCH_SOURCE) ;
972d391d2ebSIngo Weinhold	LocalClean clean : $(1) ;
973d391d2ebSIngo Weinhold}
974d391d2ebSIngo Weinhold
975d391d2ebSIngo Weinholdactions AbsSymLink
976d391d2ebSIngo Weinhold{
977d391d2ebSIngo Weinhold	target="$(2)"
978d391d2ebSIngo Weinhold	case "$target" in
979d391d2ebSIngo Weinhold		/*) ;;
980d391d2ebSIngo Weinhold		*) target=`pwd`/"$target";;
981d391d2ebSIngo Weinhold	esac
982d391d2ebSIngo Weinhold	$(RM) "$(1)" && $(LN) -s "$target" "$(1)"
983d391d2ebSIngo Weinhold}
984d391d2ebSIngo Weinhold
98552a38012Sejakowatz#-------------------------------------------------------------------------------
98652a38012Sejakowatz# Low-level OBOS utility rules
98752a38012Sejakowatz#-------------------------------------------------------------------------------
98852a38012Sejakowatzrule SetupObjectsDir
98952a38012Sejakowatz{
99052a38012Sejakowatz	local rel_objectsdir;
99152a38012Sejakowatz
99252a38012Sejakowatz	# Copy subdir tokens except the first, as that will be "sources", and we
99352a38012Sejakowatz	# do not want to include that :)
99452a38012Sejakowatz	rel_objectsdir = [ FDirName $(SUBDIR_TOKENS[2-]) ] ;
99552a38012Sejakowatz	LOCATE_TARGET = [ FDirName $(OBOS_OBJECT_TARGET) $(rel_objectsdir) ] ;
99652a38012Sejakowatz}
99752a38012Sejakowatz
99852a38012Sejakowatz#-------------------------------------------------------------------------------
99952a38012Sejakowatz# Link rule/action are overwritten as they don't handle linking files who's name
100052a38012Sejakowatz# contain spaces very well. Also adds resources and version to executable.
100152a38012Sejakowatz#-------------------------------------------------------------------------------
100252a38012Sejakowatzrule Link
100352a38012Sejakowatz{
100452a38012Sejakowatz	# Note: RESFILES must be set before invocation.
100552a38012Sejakowatz	MODE on $(<) = $(EXEMODE) ;
100652a38012Sejakowatz	on $(1) XRes $(1) : $(RESFILES) ;
100752a38012Sejakowatz	Chmod $(<) ;
100852a38012Sejakowatz	SetType $(1) ;
100952a38012Sejakowatz	MimeSet $(1) ;
10101419ae2bSshatty	SetVersion $(1) ;
101152a38012Sejakowatz}
101252a38012Sejakowatz
101352a38012Sejakowatzactions Link bind NEEDLIBS
101452a38012Sejakowatz{
10151eb18edfSIngo Weinhold	$(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ;
101652a38012Sejakowatz}
101752a38012Sejakowatz
101852a38012Sejakowatz# BeOS specific rules
101952a38012Sejakowatz
102052a38012Sejakowatzrule XRes
102152a38012Sejakowatz{
102252a38012Sejakowatz	# XRes <target> : <resource files>
102352a38012Sejakowatz	if $(2)
102452a38012Sejakowatz	{
10259eea4522SIngo Weinhold		Depends $(1) : $(2) ;
102652a38012Sejakowatz		XRes1 $(1) : $(2) ;
102752a38012Sejakowatz	}
102852a38012Sejakowatz}
102952a38012Sejakowatz
103052a38012Sejakowatzrule XRes1 { }
103152a38012Sejakowatz
103252a38012Sejakowatzrule SetVersion
103352a38012Sejakowatz{
103452a38012Sejakowatz	# SetVersion <target>
103552a38012Sejakowatz}
103652a38012Sejakowatz
103752a38012Sejakowatzrule SetType
103852a38012Sejakowatz{
103952a38012Sejakowatz	# SetType <target>
104052a38012Sejakowatz}
104152a38012Sejakowatz
104252a38012Sejakowatzrule MimeSet
104352a38012Sejakowatz{
104452a38012Sejakowatz	# SetType <target>
104552a38012Sejakowatz}
104652a38012Sejakowatz
104752a38012Sejakowatz
104852a38012Sejakowatzif $(OS) = BEOS
104952a38012Sejakowatz{
105052a38012Sejakowatz
105152a38012Sejakowatzactions XRes1
105252a38012Sejakowatz{
10530931b8f9SIngo Weinhold	xres -o "$(1)" "$(2)" ;
105452a38012Sejakowatz}
105552a38012Sejakowatz
105652a38012Sejakowatzactions SetVersion
105752a38012Sejakowatz{
105852a38012Sejakowatz	setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ;
105952a38012Sejakowatz}
106052a38012Sejakowatz
106152a38012Sejakowatzactions SetType
106252a38012Sejakowatz{
106352a38012Sejakowatz	settype -t $(OBOS_TARGET_TYPE) "$(1)" ;
106452a38012Sejakowatz}
106552a38012Sejakowatz
106652a38012Sejakowatzactions MimeSet
106752a38012Sejakowatz{
106852a38012Sejakowatz	mimeset -f "$(1)" ;
106952a38012Sejakowatz}
107052a38012Sejakowatz
107152a38012Sejakowatz}	# if BEOS
107252a38012Sejakowatz
107352a38012Sejakowatz
107452a38012Sejakowatzrule assemble
107552a38012Sejakowatz{
107694782cf7SIngo Weinhold	Depends $(<) : $(>) ;
107794782cf7SIngo Weinhold	ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ;
107894782cf7SIngo Weinhold	ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ;
107952a38012Sejakowatz}
108052a38012Sejakowatz
108152a38012Sejakowatzactions assemble
108252a38012Sejakowatz{
108394782cf7SIngo Weinhold	$(CC) -c "$(2)" -O2 $(ASFLAGS) $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ;
108452a38012Sejakowatz}
108552a38012Sejakowatz
10860931b8f9SIngo Weinhold# Overridden to allow spaces in file names.
10870931b8f9SIngo Weinholdactions Chmod1
10880931b8f9SIngo Weinhold{
10890931b8f9SIngo Weinhold	$(CHMOD) "$(MODE)" "$(1)"
10900931b8f9SIngo Weinhold}
10910931b8f9SIngo Weinhold
10926991af8cSIngo Weinhold# Overridden to allow spaces in file names.
10936991af8cSIngo Weinholdactions piecemeal together existing Clean
10946991af8cSIngo Weinhold{
10956991af8cSIngo Weinhold	$(RM) "$(>)"
10966991af8cSIngo Weinhold}
10976991af8cSIngo Weinhold
109808125d07SIngo Weinholdrule ObjectReference
109908125d07SIngo Weinhold{
110008125d07SIngo Weinhold	# ObjectReference <reference object> : <source object>
110108125d07SIngo Weinhold	# Makes <reference object> refer to the same file as <source object>.
110208125d07SIngo Weinhold	# The filenames must of course be identical.
110308125d07SIngo Weinhold	# <source object> must have already been LOCATEd.
110408125d07SIngo Weinhold
110508125d07SIngo Weinhold	local ref = $(1) ;
110608125d07SIngo Weinhold	local source = $(2) ;
110708125d07SIngo Weinhold	if $(ref) != $(source) {
11089eea4522SIngo Weinhold		Depends $(ref) : $(source) ;
110921df5945SIngo Weinhold		LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ;
111008125d07SIngo Weinhold	}
111108125d07SIngo Weinhold}
111208125d07SIngo Weinhold
111308125d07SIngo Weinholdrule ObjectReferences
111408125d07SIngo Weinhold{
111508125d07SIngo Weinhold	# ObjectReferences <source objects>
111608125d07SIngo Weinhold	# Creates local references to <source objects>, i.e. identifiers with the
111708125d07SIngo Weinhold	# current grist referring to the same files. <source objects> must have
111808125d07SIngo Weinhold	# already been LOCATEd.
111908125d07SIngo Weinhold
112008125d07SIngo Weinhold	local source ;
112108125d07SIngo Weinhold	for source in $(1) {
112208125d07SIngo Weinhold		ObjectReference [ FGristFiles $(source) ] : $(source) ;
112308125d07SIngo Weinhold	}
112408125d07SIngo Weinhold}
112508125d07SIngo Weinhold
11269fc6b2e1SIngo Weinholdrule Filter
11279fc6b2e1SIngo Weinhold{
11289fc6b2e1SIngo Weinhold	# Filter <list> : <excludes> ;
11299fc6b2e1SIngo Weinhold	# Removes all occurrences of <excludes> in <list>.
11309fc6b2e1SIngo Weinhold
11319fc6b2e1SIngo Weinhold	local list = $(1) ;
11329fc6b2e1SIngo Weinhold	local excludes = $(2) ;
11339fc6b2e1SIngo Weinhold	local newList ;
11349fc6b2e1SIngo Weinhold	local item ;
11359fc6b2e1SIngo Weinhold	for item in $(list) {
11369fc6b2e1SIngo Weinhold		local skip ;
11379fc6b2e1SIngo Weinhold		local exclude ;
11389fc6b2e1SIngo Weinhold		for exclude in $(excludes) {
11399fc6b2e1SIngo Weinhold			if $(item) = $(exclude) {
11409fc6b2e1SIngo Weinhold				skip = true ;
11419fc6b2e1SIngo Weinhold			}
11429fc6b2e1SIngo Weinhold		}
11439fc6b2e1SIngo Weinhold		if ! $(skip) {
1144dd9f8062SIngo Weinhold			newList += $(item) ;
11459fc6b2e1SIngo Weinhold		}
11469fc6b2e1SIngo Weinhold	}
11479fc6b2e1SIngo Weinhold	return $(newList) ;
11489fc6b2e1SIngo Weinhold}
11499fc6b2e1SIngo Weinhold
11500931b8f9SIngo Weinhold
115152a38012Sejakowatz## Kernel stuff!
115252a38012Sejakowatz
115352a38012Sejakowatzrule SetupKernel
115452a38012Sejakowatz{
115552a38012Sejakowatz	# Usage SetupKernel <sources_or_objects> : <extra_cc_flags>;
115652a38012Sejakowatz
115752a38012Sejakowatz	local _objs = $(1:S=$(SUFOBJ)) ;
115852a38012Sejakowatz
115928d2a30eSDaniel Reinhold	#Setup Kernel header directories
1160089a0629Sbeveloper	local public_kernel_includes = add-ons/file_system add-ons/graphics device drivers kernel storage support ;
1161089a0629Sbeveloper	local private_kernel_includes = kernel libroot ;
1162a6c008e1Sbeveloper	# Use posix headers directory
116328d2a30eSDaniel Reinhold	HDRS = [ FDirName $(OBOS_TOP) headers posix ] ;
1164a6c008e1Sbeveloper	# Use public OS header directories
1165089a0629Sbeveloper	HDRS += [ PublicHeaders $(public_kernel_includes) ] ;
1166089a0629Sbeveloper	# Use private directories
1167089a0629Sbeveloper	HDRS += [ PrivateHeaders $(private_kernel_includes) ] ;
1168a6c008e1Sbeveloper
116952a38012Sejakowatz	UseArchHeaders $(OBOS_ARCH) ;
117052a38012Sejakowatz
117152a38012Sejakowatz	SetupObjectsDir ;
117252a38012Sejakowatz
117352a38012Sejakowatz	CCFLAGS on $(_objs) = $(KERNEL_CCFLAGS) $(2) ;
117452a38012Sejakowatz	C++FLAGS on $(_objs) = $(KERNEL_CCFLAGS) $(2) ;
117552a38012Sejakowatz}
117652a38012Sejakowatz
117752a38012Sejakowatzrule KernelObjects
117852a38012Sejakowatz{
117952a38012Sejakowatz	SetupKernel $(1) : $(2) ;
118052a38012Sejakowatz
118152a38012Sejakowatz	Objects $(1) ;
118252a38012Sejakowatz}
118352a38012Sejakowatz
118452a38012Sejakowatzrule KernelLd
118552a38012Sejakowatz{
118680721244SAxel Dörfler	# KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> : <config_section> ;
118752a38012Sejakowatz
118852a38012Sejakowatz	SetupKernel $(2) ;
118952a38012Sejakowatz	LINK on $(1) = ld ;
119052a38012Sejakowatz
119152a38012Sejakowatz	LINKFLAGS on $(1) = $(4) ;
119252a38012Sejakowatz	if $(3) { LINKFLAGS on $(1) += --script=$(3) ; }
119352a38012Sejakowatz
119452a38012Sejakowatz	# Remove any preset LINKLIBS
119552a38012Sejakowatz	LINKLIBS on $(1) =  ;
119652a38012Sejakowatz
119752a38012Sejakowatz	# Show that we depend on the libraries we need
11989eea4522SIngo Weinhold	LocalClean clean : $(1) ;
11999eea4522SIngo Weinhold	LocalDepends all : $(1) ;
120052a38012Sejakowatz	Depends $(1) : $(2) ;
120152a38012Sejakowatz
120252a38012Sejakowatz	if $(6) {
120352a38012Sejakowatz		for i in $(6) {
12042a83bfb4SIngo Weinhold			KernelConfigSection $(i) : elf32 : $(1) ;
120552a38012Sejakowatz		}
120652a38012Sejakowatz	}
120752a38012Sejakowatz
120852a38012Sejakowatz	MakeLocate $(1) : $(LOCATE_TARGET) ;
120952a38012Sejakowatz
121052a38012Sejakowatz	# Add libgcc.a - NB this should be detected not hard coded!
121152a38012Sejakowatz	if ! $(5) {
12121eb18edfSIngo Weinhold		LINKLIBS on $(1) += -L $(GCC_PATH) -lgcc ;
121352a38012Sejakowatz	}
121452a38012Sejakowatz}
121552a38012Sejakowatz
121652a38012Sejakowatzactions KernelLd
121752a38012Sejakowatz{
12181eb18edfSIngo Weinhold	$(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ;
121952a38012Sejakowatz}
122052a38012Sejakowatz
122180721244SAxel Dörflerrule KernelMergeObject
122280721244SAxel Dörfler{
122380721244SAxel Dörfler	# KernelMergeObject <name> : <sources> : <extra CFLAGS> ;
122480721244SAxel Dörfler
122580721244SAxel Dörfler	SetupKernel $(2) : $(3) ;
122680721244SAxel Dörfler
122780721244SAxel Dörfler	MakeLocateObjects $(2) ;
122880721244SAxel Dörfler	Objects $(2) ;
122980721244SAxel Dörfler	MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) ;
123080721244SAxel Dörfler}
123180721244SAxel Dörfler
123252a38012Sejakowatzrule KernelStaticLibrary
123352a38012Sejakowatz{
123452a38012Sejakowatz	# Usage KernelStaticLibrary <name> : <sources> : <extra cc flags>  ;
123552a38012Sejakowatz	# This is designed to take a set of sources and libraries and create
123652a38012Sejakowatz	# a file called lib<name>.a
123752a38012Sejakowatz
123852a38012Sejakowatz	SetupKernel $(2) : $(3) ;
123952a38012Sejakowatz
124052a38012Sejakowatz	MakeLocateObjects $(2) ;
124152a38012Sejakowatz	Library $(1) : $(2) ;
124252a38012Sejakowatz}
124352a38012Sejakowatz
124452a38012Sejakowatzrule KernelStaticLibraryObjects
124552a38012Sejakowatz{
124652a38012Sejakowatz	# Usage KernelStaticLibrary <name> : <sources> ;
124752a38012Sejakowatz	# This is designed to take a set of sources and libraries and create
124852a38012Sejakowatz	# a file called <name>
124952a38012Sejakowatz
125052a38012Sejakowatz	SetupKernel $(2) ;
125152a38012Sejakowatz
125252a38012Sejakowatz	# Show that we depend on the libraries we need
12539eea4522SIngo Weinhold	LocalClean clean : $(1) ;
12549eea4522SIngo Weinhold	LocalDepends all : $(1) ;
125552a38012Sejakowatz	Depends $(1) : $(2) ;
125652a38012Sejakowatz
125752a38012Sejakowatz	MakeLocate $(1) : $(LOCATE_TARGET) ;
125852a38012Sejakowatz}
125952a38012Sejakowatz
126052a38012Sejakowatzactions KernelStaticLibraryObjects
126152a38012Sejakowatz{
12620931b8f9SIngo Weinhold	ar -r "$(1)" "$(2)" ;
126352a38012Sejakowatz}
126452a38012Sejakowatz
126552a38012Sejakowatzrule SystemMain
126652a38012Sejakowatz{
12670c0b2cd0SIngo Weinhold	# Usage SystemMain <target> : <sources> ;
126852a38012Sejakowatz	SetupObjectsDir ;
126952a38012Sejakowatz
12700c0b2cd0SIngo Weinhold	LINKLIBS on $(1) = ;
127152a38012Sejakowatz
127252a38012Sejakowatz	Main $(1) : $(2) ;
127352a38012Sejakowatz}
127452a38012Sejakowatz
127552a38012Sejakowatzrule KernelConfigSection
127652a38012Sejakowatz{
127752a38012Sejakowatz	# KernelConfigSection <section> : <type> : <file>  ;
12782a83bfb4SIngo Weinhold
12792a83bfb4SIngo Weinhold	SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ;
12802a83bfb4SIngo Weinhold	SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ;
12812a83bfb4SIngo Weinhold	SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ;
12822a83bfb4SIngo Weinhold
12832a83bfb4SIngo Weinhold	Depends $(OBOS_KERNEL_CONFIG) : $(3) ;
128452a38012Sejakowatz}
128552a38012Sejakowatz
128652a38012Sejakowatzrule WriteKernelConfig
128752a38012Sejakowatz{
128852a38012Sejakowatz	# usage: WriteKernelConfig <target> ;
128952a38012Sejakowatz
12909eea4522SIngo Weinhold	LocalDepends files : $(1) ;
129152a38012Sejakowatz
12922a83bfb4SIngo Weinhold	MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ;
129352a38012Sejakowatz
12949eea4522SIngo Weinhold	LocalClean clean : $(1) ;
129552a38012Sejakowatz}
129652a38012Sejakowatz
12972a83bfb4SIngo Weinholdactions WriteKernelConfig bind SECTION_FILES
129852a38012Sejakowatz{
12990931b8f9SIngo Weinhold	target="$(1)"
13000931b8f9SIngo Weinhold	echo "# OpenBeOS Kernel Config File" > "$target"
13010931b8f9SIngo Weinhold	echo "# Automatically generated - do not edit!" >> "$target"
13022a83bfb4SIngo Weinhold	count=0
13032a83bfb4SIngo Weinhold	for section in "$(SECTION_NAMES)" ; do
13042a83bfb4SIngo Weinhold		count=`expr $count + 1`
13052a83bfb4SIngo Weinhold		eval section$count="$section"
13062a83bfb4SIngo Weinhold	done
13072a83bfb4SIngo Weinhold	i=1
13082a83bfb4SIngo Weinhold	for type in "$(SECTION_TYPES)" ; do
13092a83bfb4SIngo Weinhold		eval type$i="$type"
13102a83bfb4SIngo Weinhold		i=`expr $i + 1`
13112a83bfb4SIngo Weinhold	done
13122a83bfb4SIngo Weinhold	i=1
13132a83bfb4SIngo Weinhold	for file in "$(SECTION_FILES)" ; do
13142a83bfb4SIngo Weinhold		eval file$i="$file"
13152a83bfb4SIngo Weinhold		i=`expr $i + 1`
13162a83bfb4SIngo Weinhold	done
13172a83bfb4SIngo Weinhold	for i in `seq $count` ; do
13182a83bfb4SIngo Weinhold		eval section="\$section$i"
13192a83bfb4SIngo Weinhold		eval type="\$type$i"
13202a83bfb4SIngo Weinhold		eval file="\$file$i"
13210931b8f9SIngo Weinhold		echo "" >> "$target"
13222a83bfb4SIngo Weinhold		echo "["$section"]" >> "$target"
13232a83bfb4SIngo Weinhold		echo "type="$type >> "$target"
13240931b8f9SIngo Weinhold		case "$file" in
132552a38012Sejakowatz			/*) ;;
13260931b8f9SIngo Weinhold			*) file=`pwd`/"$file";;
132752a38012Sejakowatz		esac
13282a83bfb4SIngo Weinhold		echo "file="$file >> "$target"
132952a38012Sejakowatz	done
133052a38012Sejakowatz}
133152a38012Sejakowatz
133252a38012Sejakowatzrule BuildKernel
133352a38012Sejakowatz{
133452a38012Sejakowatz	# Usage BuildKernel <target> : <config_file> ;
13350c0b2cd0SIngo Weinhold	local kernel = $(1) ;
13360c0b2cd0SIngo Weinhold	local configFile = $(2) ;
13370c0b2cd0SIngo Weinhold	local bootmaker = bootmaker ;
133852a38012Sejakowatz
13399eea4522SIngo Weinhold	LocalDepends all : $(kernel) ;
13400c0b2cd0SIngo Weinhold	Depends $(kernel) : $(configFile) $(bootmaker) ;
13419eea4522SIngo Weinhold	LocalClean clean : $(kernel) ;
13420c0b2cd0SIngo Weinhold	MakeLocate $(kernel) : $(LOCATE_TARGET) ;
134352a38012Sejakowatz
13440c0b2cd0SIngo Weinhold	BOOT_MAKER on $(kernel) = $(bootmaker) ;
134552a38012Sejakowatz}
134652a38012Sejakowatz
13470c0b2cd0SIngo Weinholdactions BuildKernel bind BOOT_MAKER
134852a38012Sejakowatz{
13490c0b2cd0SIngo Weinhold	"$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ;
135052a38012Sejakowatz	echo ""
135152a38012Sejakowatz	echo "Kernel linked!"
135252a38012Sejakowatz	echo ""
135352a38012Sejakowatz}
135452a38012Sejakowatz
135552a38012Sejakowatzrule KernelFloppyImage
135652a38012Sejakowatz{
135752a38012Sejakowatz	# Usage KernelFloppyImage <target> : <kernel> : <bootblock> ;
13580c0b2cd0SIngo Weinhold	local floppy = $(1) ;
13590c0b2cd0SIngo Weinhold	local kernel = $(2) ;
13600c0b2cd0SIngo Weinhold	local bootblock = $(3) ;
13610c0b2cd0SIngo Weinhold	local makeflop = makeflop ;
136252a38012Sejakowatz
13639eea4522SIngo Weinhold	LocalDepends all : $(floppy) ;
13640c0b2cd0SIngo Weinhold	Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ;
13659eea4522SIngo Weinhold	LocalClean clean : $(floppy) ;
13660c0b2cd0SIngo Weinhold	MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ;
136752a38012Sejakowatz
13680c0b2cd0SIngo Weinhold	BOOT_BLOCK on $(floppy) = $(bootblock) ;
13690c0b2cd0SIngo Weinhold	MAKE_FLOP on $(floppy) = $(makeflop) ;
137052a38012Sejakowatz}
137152a38012Sejakowatz
137252a38012Sejakowatz# This may be a bit verbose, but I think it's useful to show what's
137352a38012Sejakowatz# going on, at least in this early stage of development.
13740c0b2cd0SIngo Weinholdactions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP
137552a38012Sejakowatz{
13767378dd7fSAxel Dörfler	"$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ;
13770c0b2cd0SIngo Weinhold
137852a38012Sejakowatz	echo ""
137952a38012Sejakowatz	echo "*************************************************"
138052a38012Sejakowatz	echo "*         Kernel build completed!               *"
138152a38012Sejakowatz	echo "*    Boot image for a 1.44M floppy created      *"
138252a38012Sejakowatz	echo "*************************************************"
138352a38012Sejakowatz	echo ""
13840c0b2cd0SIngo Weinhold	echo "Floppy image is $(1)"
138552a38012Sejakowatz	echo "The following command will write it to a floppy on BeOS"
13860c0b2cd0SIngo Weinhold	echo "  dd if=$(1) of=/dev/disk/floppy/raw bs=18k"
13870c0b2cd0SIngo Weinhold	echo "Alternatively you can run"
13880c0b2cd0SIngo Weinhold	echo "  ./configure --floppy /dev/disk/floppy/raw"
13890c0b2cd0SIngo Weinhold	echo "once and build + write the image subsequently via"
13900c0b2cd0SIngo Weinhold	echo "  jam installfloppy"
139152a38012Sejakowatz	echo ""
139252a38012Sejakowatz}
139352a38012Sejakowatz
13940c0b2cd0SIngo Weinholdrule InstallFloppy
13950c0b2cd0SIngo Weinhold{
13960c0b2cd0SIngo Weinhold	# InstallFloppy <target> : <floppy>
13970c0b2cd0SIngo Weinhold	# "dd"s <floppy> to $(FLOPPY_PATH).
13980c0b2cd0SIngo Weinhold
13990c0b2cd0SIngo Weinhold	local target = $(1) ;
14000c0b2cd0SIngo Weinhold	local floppy = $(2) ;
14010c0b2cd0SIngo Weinhold
14020c0b2cd0SIngo Weinhold	NotFile $(target) ;
14030c0b2cd0SIngo Weinhold	Always $(target) ;
14040c0b2cd0SIngo Weinhold	Depends $(target) : $(floppy) ;
14050c0b2cd0SIngo Weinhold}
14060c0b2cd0SIngo Weinhold
14070c0b2cd0SIngo Weinholdactions InstallFloppy
14080c0b2cd0SIngo Weinhold{
14090c0b2cd0SIngo Weinhold	if [ -z $(FLOPPY_PATH) ] ; then
14100c0b2cd0SIngo Weinhold		echo "Can't install floppy: FLOPPY_PATH not set."
14110c0b2cd0SIngo Weinhold		echo "run: ./configure --floppy <floppy path>"
14120c0b2cd0SIngo Weinhold		echo
14130c0b2cd0SIngo Weinhold		exit 0
14140c0b2cd0SIngo Weinhold	fi
14150c0b2cd0SIngo Weinhold	dd if=$(2) of=$(FLOPPY_PATH) bs=18k
14160c0b2cd0SIngo Weinhold}
141752a38012Sejakowatz
141821df5945SIngo Weinhold
141921df5945SIngo Weinhold#-------------------------------------------------------------------------------
142021df5945SIngo Weinhold# FreeType 2 specific rules and variables
142121df5945SIngo Weinhold#-------------------------------------------------------------------------------
142221df5945SIngo Weinhold
142321df5945SIngo WeinholdFT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ;
142421df5945SIngo WeinholdFT2_SRC     = [ FDirName $(OBOS_TOP) src libs freetype2 ] ;
142521df5945SIngo Weinhold
142621df5945SIngo WeinholdFT2_LIB     = freetype ;
142721df5945SIngo Weinhold
142821df5945SIngo Weinholdrule UseFreeTypeHeaders
142921df5945SIngo Weinhold{
143021df5945SIngo Weinhold	SubDirHdrs $(FT2_INCLUDE) ;
143121df5945SIngo Weinhold}
143221df5945SIngo Weinhold
143321df5945SIngo Weinholdrule UseFreeTypeObjectHeaders
143421df5945SIngo Weinhold{
143521df5945SIngo Weinhold	ObjectHdrs $(1) : $(FT2_INCLUDE) ;
143621df5945SIngo Weinhold}
143721df5945SIngo Weinhold
143821df5945SIngo Weinholdrule FT2_SubDir
143921df5945SIngo Weinhold{
144021df5945SIngo Weinhold	# FT2_SubDir <dir>
144121df5945SIngo Weinhold	# <dir>: Components of a directory in the original hierarchy.
144221df5945SIngo Weinhold	local dir = $(1) ;
144321df5945SIngo Weinhold	local topDir ;
144421df5945SIngo Weinhold	switch $(dir[1])
144521df5945SIngo Weinhold	{
144621df5945SIngo Weinhold		case "include"	: topDir = $(FT2_INCLUDE) ;
144721df5945SIngo Weinhold		case src		: topDir = $(FT2_SRC) ;
144821df5945SIngo Weinhold		case *			: ECHO "Unknown FreeType2 directory: " $(dir) ;
144921df5945SIngo Weinhold	}
145021df5945SIngo Weinhold	return [ FDirName $(topDir) $(dir[2-]) ] ;
145121df5945SIngo Weinhold}
145221df5945SIngo Weinhold
145321df5945SIngo Weinholdrule FT2_Library
145421df5945SIngo Weinhold{
145521df5945SIngo Weinhold	# FT2_Library <libname> : <sources>
145621df5945SIngo Weinhold	# Builds objects from sources and adds the objects to the list of objects
145721df5945SIngo Weinhold	# to be linked into the library.
145821df5945SIngo Weinhold	# <libname> The name of the library.
145921df5945SIngo Weinhold	# <sources> The sources.
146021df5945SIngo Weinhold
146121df5945SIngo Weinhold	local library = lib$(1).so ;
146221df5945SIngo Weinhold	local sources = $(2) ;
146328d2a30eSDaniel Reinhold	SetupIncludes ;
146421df5945SIngo Weinhold	SetupObjectsDir ;
146521df5945SIngo Weinhold	MakeLocateObjects $(sources) ;
146621df5945SIngo Weinhold	Objects $(sources) ;
146721df5945SIngo Weinhold	LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
146821df5945SIngo Weinhold}
146921df5945SIngo Weinhold
147021df5945SIngo Weinholdrule FT2_LinkLibrary
147121df5945SIngo Weinhold{
147221df5945SIngo Weinhold	# FT2_LinkLibrary <libname>
147321df5945SIngo Weinhold	# Links the library from the objects build with FT2_LIBRARY before.
147421df5945SIngo Weinhold
147521df5945SIngo Weinhold	local library = lib$(1).so ;
147621df5945SIngo Weinhold	local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ;
147721df5945SIngo Weinhold	ObjectReferences $(objects) ;
147821df5945SIngo Weinhold	objects = [ FGristFiles $(objects) ] ;
147921df5945SIngo Weinhold	SharedLibraryFromObjects $(1) : $(objects) ;
148021df5945SIngo Weinhold}
148121df5945SIngo Weinhold
1482