xref: /haiku/Jamrules (revision 9fcaa61d0451f66b79986d79f01a4f9f31d9438a)
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
294ff6d49fSIngo Weinhold# The directory for build system specific files
304ff6d49fSIngo WeinholdOBOS_BUILD_DIR = [ FDirName $(OBOS_TOP) build ] ;
314ff6d49fSIngo Weinhold
324ff6d49fSIngo Weinhold# Cache files for header scanning and jamfile caching
334ff6d49fSIngo WeinholdHCACHEFILE = header_cache ;
344ff6d49fSIngo WeinholdJCACHEFILE = jamfile_cache ;
354ff6d49fSIngo WeinholdLOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(OBOS_BUILD_DIR) ;
369eea4522SIngo Weinhold
3752a38012Sejakowatz# Include BuildConfig
3852a38012Sejakowatz{
394ff6d49fSIngo Weinhold	local buildConfig = [ GLOB $(OBOS_BUILD_DIR) : BuildConfig ] ;
4052a38012Sejakowatz	if ! $(buildConfig)
4152a38012Sejakowatz	{
424ff6d49fSIngo Weinhold		ECHO "No BuildConfig found in $(OBOS_BUILD_DIR)!" ;
434ff6d49fSIngo Weinhold		EXIT "Run ./configure in the source tree's root directory first!" ;
4452a38012Sejakowatz	}
454ff6d49fSIngo Weinhold	LOCATE on BuildConfig = $(OBOS_BUILD_DIR) ;
464ff6d49fSIngo Weinhold	include BuildConfig ;
4752a38012Sejakowatz}
4852a38012Sejakowatz
495dc4e1efSIngo Weinhold# Save the platform default headers.
505dc4e1efSIngo WeinholdPLATFORM_DEFAULT_HEADERS = $(HDRS) ;
515dc4e1efSIngo Weinhold
52a6c008e1Sbeveloper# We do not include any local BeOS system headers by default
53dd9f8062SIngo WeinholdCCFLAGS += -nostdinc ;
54dd9f8062SIngo WeinholdC++FLAGS += -nostdinc ;
55a6c008e1Sbeveloper
5652a38012Sejakowatz# Determine if we're building on PPC or x86
5752a38012Sejakowatz# Determine mimetype of executable
5852a38012Sejakowatz# Cross compiling can come later
5952a38012Sejakowatz
60c9882d9eSAxel DörflerTARGET_CPU ?= $(OSPLAT:L) ;
611f622a7bSAxel DörflerOBOS_VERSION ?= R1 ;
621f622a7bSAxel Dörfler
631f622a7bSAxel Dörflerswitch $(TARGET_CPU) {
641f622a7bSAxel Dörfler	case ppc :
651f622a7bSAxel Dörfler	{
6652a38012Sejakowatz		if $(METROWERKS) {
671f622a7bSAxel Dörfler			# at least parts of OpenBeOS still can be compiled with
681f622a7bSAxel Dörfler			# the Metrowerks compiler on BeOS/PPC
6952a38012Sejakowatz			OBOS_TARGET_TYPE ?= "application/x-be-executable" ;
7052a38012Sejakowatz		} else {
7152a38012Sejakowatz			OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ;
721f622a7bSAxel Dörfler		}
73dd22481eSAxel Dörfler		DEFINES += __POWERPC__ ;
7498cc804cSAxel Dörfler		OBOS_BOOT_LIB = openfirmware ;
751f622a7bSAxel Dörfler	}
761f622a7bSAxel Dörfler	case x86 :
771f622a7bSAxel Dörfler	{
781f622a7bSAxel Dörfler		# nothing special to do here...
7998cc804cSAxel Dörfler		OBOS_BOOT_LIB = bios_ia32 ;
801f622a7bSAxel Dörfler	}
811f622a7bSAxel Dörfler	case * :
821f622a7bSAxel Dörfler		Exit "Currently unsupported build platform:" $(TARGET_CPU) ;
831f622a7bSAxel Dörfler}
841f622a7bSAxel Dörfler
851f622a7bSAxel Dörfler# set target specific variables
861f622a7bSAxel Dörfler{
871f622a7bSAxel Dörfler	#Echo "Building for" $(TARGET_CPU) ;
881f622a7bSAxel Dörfler
891f622a7bSAxel Dörfler	OBOS_TARGET ?= $(TARGET_CPU).$(OBOS_VERSION) ;
901f622a7bSAxel Dörfler	OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ;
911f622a7bSAxel Dörfler	OBOS_ARCH ?= $(TARGET_CPU) ;
921f622a7bSAxel Dörfler	OBOS_TARGET_DEFINE ?= "ARCH_"$(TARGET_CPU) ;
9352a38012Sejakowatz}
9452a38012Sejakowatz
95e5dc2d93Sbeveloper# Enable warnings only if WARNINGS is defined
96e5dc2d93Sbeveloper# Should be enabled by default later
9796d27465SIngo Weinhold#
98e5dc2d93Sbeveloperif $(WARNINGS) {
99e5dc2d93Sbeveloper	# For an explanation of the different warning options, see:
100e5dc2d93Sbeveloper	# http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html
101e5dc2d93Sbeveloper	# to get even more warnings, add:
102e5dc2d93Sbeveloper	# -Wwrite-strings  	(doesn't work well with some Be headers)
103e5dc2d93Sbeveloper	# -Wundef			(dito)
104e5dc2d93Sbeveloper	# -Wconversion		(gets you many warnings about implicit conversions)
105e5dc2d93Sbeveloper	# -W				(gets you even more warnigs)
106dd9f8062SIngo Weinhold	CCFLAGS += -Wall -Wno-multichar -Wmissing-prototypes ;
107dd9f8062SIngo Weinhold	CCFLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ;
108dd9f8062SIngo Weinhold	C++FLAGS += -Wall -Wno-multichar -Wmissing-prototypes -Wno-ctor-dtor-privacy -Woverloaded-virtual ;
109dd9f8062SIngo Weinhold	C++FLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ;
11098cc804cSAxel Dörfler} else {
11198cc804cSAxel Dörfler	CCFLAGS += -Wno-multichar ;
11298cc804cSAxel Dörfler	C++FLAGS += -Wno-multichar ;
113e5dc2d93Sbeveloper}
114e5dc2d93Sbeveloper
11598cc804cSAxel Dörfler# standard kernel C/C++ flags
1160ff867c2SbeveloperKERNEL_CCFLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ;
1170ff867c2SbeveloperKERNEL_CCFLAGS += -fno-builtin -D$(OBOS_TARGET_DEFINE) ;
1180ff867c2SbeveloperKERNEL_CCFLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ;
11998cc804cSAxel DörflerKERNEL_C++FLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ;
12098cc804cSAxel DörflerKERNEL_C++FLAGS += -fno-builtin -fno-exceptions -fno-rtti -D$(OBOS_TARGET_DEFINE) ;
12198cc804cSAxel DörflerKERNEL_C++FLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ;
1220ff867c2Sbeveloper
1239eea4522SIngo Weinhold# We might later want to introduce debug levels or handle the whole issue
1249eea4522SIngo Weinhold# differently. For now there's only on or off.
1259eea4522SIngo Weinhold#
1269eea4522SIngo Weinholdif $(DEBUG) {
1279eea4522SIngo Weinhold	OPTIM ?= -O0 ;
1280ff867c2Sbeveloper	CCFLAGS += -g -DDEBUG=$(DEBUG) ;
1290ff867c2Sbeveloper	C++FLAGS += -g -DDEBUG=$(DEBUG)  ;
1300ff867c2Sbeveloper	KERNEL_CCFLAGS += -g -DDEBUG=$(DEBUG) ;
13198cc804cSAxel Dörfler	KERNEL_C++FLAGS += -g -DDEBUG=$(DEBUG) ;
1329eea4522SIngo Weinhold	LINKFLAGS += -g ;
1339eea4522SIngo Weinhold} else {
1349eea4522SIngo Weinhold	OPTIM ?= -O2 ;
1359eea4522SIngo Weinhold}
13696d27465SIngo Weinhold#
13796d27465SIngo Weinhold# To disable for the tests OPTIM and DEBUG are overridden, set the environment
13896d27465SIngo Weinhold# variable NO_TEST_DEBUG.
1399eea4522SIngo Weinhold
14016fa4445SIngo Weinhold# Instructs the Library rule to not make its object files temporary.
14116fa4445SIngo Weinhold# This is need as some objects are used in a static library and for an
14216fa4445SIngo Weinhold# executable.
14316fa4445SIngo WeinholdKEEPOBJS = true ;
14416fa4445SIngo Weinhold
1457bc56df1SIngo Weinhold# under BeOS use copyattr instead of cp
1467bc56df1SIngo Weinholdif $(OS) = BEOS
1477bc56df1SIngo Weinhold{
1487bc56df1SIngo Weinhold	CP = copyattr --data ;
1497bc56df1SIngo Weinhold}
1507bc56df1SIngo Weinhold
15152a38012Sejakowatz# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and
15252a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different
15352a38012Sejakowatz# builds mixing objects from different targets).
15452a38012Sejakowatzif ! $(OBOS_OBJECT_TARGET) {
15552a38012Sejakowatz	OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ;
15652a38012Sejakowatz}
15752a38012Sejakowatz
15852a38012Sejakowatz# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and
15952a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different
16052a38012Sejakowatz# builds mixing executables from different targets).
16152a38012Sejakowatzif ! $(OBOS_DISTRO_TARGET) {
16252a38012Sejakowatz	OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ;
16352a38012Sejakowatz}
16452a38012Sejakowatz
16552a38012Sejakowatz# Set our version number if not already set and mark it as a developer build
16652a38012Sejakowatzif ! $(OBOS_BUILD_VERSION) {
16752a38012Sejakowatz	OBOS_BUILD_VERSION ?= "1 0 0 a 1" ;
16852a38012Sejakowatz	OBOS_BUILD_DESCRIPTION ?= "Developer Build" ;
16952a38012Sejakowatz}
17052a38012Sejakowatz
17152a38012Sejakowatz# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as
17252a38012Sejakowatz# an unknown build.
17352a38012Sejakowatzif ! $(OBOS_BUILD_DESCRIPTION) {
17452a38012Sejakowatz	OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ;
17552a38012Sejakowatz}
17652a38012Sejakowatz
17752a38012Sejakowatz# Relative subdirs for distro dir (these are for *INTERNAL* use by the following rules only!)
1785f281ed5SejakowatzOBOS_APPS_DIR   ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ;
179f06de7f3SIngo WeinholdOBOS_BIN_DIR    ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ;
18052a38012SejakowatzOBOS_PREFS_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ;
18152a38012SejakowatzOBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ;
18252a38012SejakowatzOBOS_ADDON_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ;
18352a38012SejakowatzOBOS_SHLIB_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ;
18452a38012SejakowatzOBOS_STLIB_DIR  ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ;
18552a38012SejakowatzOBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ;
18652a38012SejakowatzOBOS_TEST_DIR   ?= [ FDirName $(OBOS_TOP) tests ] ;
18752a38012Sejakowatz
18852a38012SejakowatzOBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ;
18952a38012SejakowatzOBOS_KERNEL = kernel.$(OBOS_ARCH) ;
19052a38012SejakowatzOBOS_FLOPPY = floppy.$(OBOS_ARCH) ;
19152a38012Sejakowatz
19252a38012Sejakowatzrule SetupIncludes
19352a38012Sejakowatz{
194cfc7b456Sshatty	# XXX add "opengl" later
195cfc7b456Sshatty	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 ;
196a6c008e1Sbeveloper
19728d2a30eSDaniel Reinhold	# Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times.
198a6c008e1Sbeveloper
199a6c008e1Sbeveloper	# Use headers directory, to allow to do things like include <posix/string.h>
20028d2a30eSDaniel Reinhold	HDRS = [ FDirName $(OBOS_TOP) headers ] ;
201a6c008e1Sbeveloper
202a6c008e1Sbeveloper	# Use posix headers directory
20328d2a30eSDaniel Reinhold	HDRS += [ FDirName $(OBOS_TOP) headers posix ] ;
204a6c008e1Sbeveloper
205a6c008e1Sbeveloper	# Use public OS header directories
20628d2a30eSDaniel Reinhold	HDRS += [ PublicHeaders $(os_includes) ] ;
207a6c008e1Sbeveloper
208a6c008e1Sbeveloper	# Used as a fallback, the R5 header directories (we should remove this as soon as possible)
20928d2a30eSDaniel Reinhold	HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ;
21009c5682dSIngo Weinhold
21109c5682dSIngo Weinhold	# The platform dependent headers.
21209c5682dSIngo Weinhold	HDRS += $(PLATFORM_HEADERS) ;
21352a38012Sejakowatz}
21452a38012Sejakowatz
215dd9f8062SIngo Weinholdrule SetupR5Includes
216dd9f8062SIngo Weinhold{
217dd9f8062SIngo Weinhold	# Unsets HDRS, so that the OBOS headers do not `shadow' the system headers.
218dd9f8062SIngo Weinhold	HDRS = ;
219dd9f8062SIngo Weinhold}
220dd9f8062SIngo Weinhold
2215dc4e1efSIngo Weinholdrule SetupDefaultIncludes
2225dc4e1efSIngo Weinhold{
2235dc4e1efSIngo Weinhold	# Resets HDRS to the default headers for the build platform.
2245dc4e1efSIngo Weinhold	HDRS = $(PLATFORM_DEFAULT_HEADERS) ;
2255dc4e1efSIngo Weinhold}
2265dc4e1efSIngo Weinhold
22752a38012Sejakowatz#-------------------------------------------------------------------------------
22852a38012Sejakowatz# Things Jam needs in order to work :)
22952a38012Sejakowatz#-------------------------------------------------------------------------------
23052a38012Sejakowatz
2318d3308d9SIngo Weinholdrule Object
2328d3308d9SIngo Weinhold{
2338d3308d9SIngo Weinhold	# This is basically the original Jambase 2.4 Object rule stripped by
2348d3308d9SIngo Weinhold	# comments. Only the final switch statement has been changed to allow
2358d3308d9SIngo Weinhold	# intermediate C++ files for Yacc and Lex.
2368d3308d9SIngo Weinhold
2378d3308d9SIngo Weinhold	LocalClean clean : $(<) ;
2388d3308d9SIngo Weinhold
2398d3308d9SIngo Weinhold	MakeLocate $(<) : $(LOCATE_TARGET) ;
2408d3308d9SIngo Weinhold	SEARCH on $(>) = $(SEARCH_SOURCE) ;
2418d3308d9SIngo Weinhold
2428d3308d9SIngo Weinhold	HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ;
2438d3308d9SIngo Weinhold
2448d3308d9SIngo Weinhold	HDRRULE on $(>) = HdrRule ;
2458d3308d9SIngo Weinhold	HDRSCAN on $(>) = $(HDRPATTERN) ;
2468d3308d9SIngo Weinhold	HDRSEARCH on $(>) =
2478d3308d9SIngo Weinhold		$(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ;
2488d3308d9SIngo Weinhold
2498d3308d9SIngo Weinhold	HDRGRIST on $(>) = $(HDRGRIST) ;
2508d3308d9SIngo Weinhold
2518d3308d9SIngo Weinhold	DEFINES on $(<) += $(DEFINES) ;
2528d3308d9SIngo Weinhold
2538d3308d9SIngo Weinhold	# if source is not .c, generate .c with specific rule
2548d3308d9SIngo Weinhold
2558d3308d9SIngo Weinhold	switch $(>:S)
2568d3308d9SIngo Weinhold	{
2578d3308d9SIngo Weinhold	    case .asm : As $(<) : $(>) ;
2588d3308d9SIngo Weinhold	    case .c :	Cc $(<) : $(>) ;
2598d3308d9SIngo Weinhold	    case .C :	C++ $(<) : $(>) ;
2608d3308d9SIngo Weinhold	    case .cc :	C++ $(<) : $(>) ;
2618d3308d9SIngo Weinhold	    case .cpp : C++ $(<) : $(>) ;
2628d3308d9SIngo Weinhold	    case .f :	Fortran $(<) : $(>) ;
2638d3308d9SIngo Weinhold	    case .l :	if [ on $(2) return $(GENERATE_C++) ] {
2648d3308d9SIngo Weinhold						C++ $(<) : $(<:S=.cpp) ;
2658d3308d9SIngo Weinhold						LexC++ $(<:S=.cpp) : $(>) ;
2668d3308d9SIngo Weinhold					} else {
2678d3308d9SIngo Weinhold						Cc $(<) : $(<:S=.c) ;
2688d3308d9SIngo Weinhold						Lex $(<:S=.c) : $(>) ;
2698d3308d9SIngo Weinhold					}
2708d3308d9SIngo Weinhold	    case .s :	As $(<) : $(>) ;
2718d3308d9SIngo Weinhold	    case .y :	if [ on $(2) return $(GENERATE_C++) ] {
2728d3308d9SIngo Weinhold						C++ $(<) : $(<:S=.cpp) ;
2738d3308d9SIngo Weinhold						Bison $(<:S=.cpp) : $(>) ;
2748d3308d9SIngo Weinhold					} else {
2758d3308d9SIngo Weinhold						Cc $(<) : $(<:S=$(YACCGEN)) ;
2768d3308d9SIngo Weinhold						Yacc $(<:S=$(YACCGEN)) : $(>) ;
2778d3308d9SIngo Weinhold					}
2788d3308d9SIngo Weinhold	    case * :	UserObject $(<) : $(>) ;
2798d3308d9SIngo Weinhold	}
2808d3308d9SIngo Weinhold}
2818d3308d9SIngo Weinhold
28252a38012Sejakowatzrule UserObject
28352a38012Sejakowatz{
28452a38012Sejakowatz	switch $(2)
28552a38012Sejakowatz	{
28652a38012Sejakowatz	case *.S    : assemble $(1) : $(2) ;
28708125d07SIngo Weinhold	case *.o    : return ;
28852a38012Sejakowatz	case *      : ECHO "unknown suffix on" $(2) ;
28952a38012Sejakowatz	}
29052a38012Sejakowatz}
29152a38012Sejakowatz
29252a38012Sejakowatz# Override the default to give "prettier" command lines.
29352a38012Sejakowatzactions Cc
29452a38012Sejakowatz{
2950931b8f9SIngo Weinhold	$(CC) -c "$(2)" $(CCFLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ;
29652a38012Sejakowatz}
29752a38012Sejakowatz
29852a38012Sejakowatzactions C++
29952a38012Sejakowatz{
3000931b8f9SIngo Weinhold	$(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ;
30152a38012Sejakowatz}
30252a38012Sejakowatz
30352a38012Sejakowatz
30452a38012Sejakowatz#-------------------------------------------------------------------------------
30552a38012Sejakowatz# General High-level OBOS target rules
30652a38012Sejakowatz#-------------------------------------------------------------------------------
30752a38012Sejakowatz
3085f281ed5Sejakowatzrule App
3095f281ed5Sejakowatz{
3105f281ed5Sejakowatz	# App <name> : <sources> ;
311a6c008e1Sbeveloper	SetupIncludes ;
3125f281ed5Sejakowatz	SetupObjectsDir ;
3135f281ed5Sejakowatz	Main $(<) : $(>) ;
3145f281ed5Sejakowatz	MakeLocate $(<) : $(OBOS_APPS_DIR) ;
3155f281ed5Sejakowatz}
3165f281ed5Sejakowatz
317f06de7f3SIngo Weinholdrule BinCommand
318f06de7f3SIngo Weinhold{
319f06de7f3SIngo Weinhold	# BinCommand <name> : <sources> : <libraries> ;
320a6c008e1Sbeveloper	SetupIncludes ;
321f06de7f3SIngo Weinhold	SetupObjectsDir ;
322f06de7f3SIngo Weinhold	Main $(1) : $(2) ;
323f06de7f3SIngo Weinhold	MakeLocate $(1) : $(OBOS_BIN_DIR) ;
324f06de7f3SIngo Weinhold	LinkSharedOSLibs $(1) : $(3) ;
325f06de7f3SIngo Weinhold}
326f06de7f3SIngo Weinhold
327f06de7f3SIngo Weinholdrule StdBinCommands
328f06de7f3SIngo Weinhold{
329f06de7f3SIngo Weinhold	# StdBinCommands <sources> : <libs> ;
330a6c008e1Sbeveloper	SetupIncludes ;
331a6c008e1Sbeveloper	SetupObjectsDir ;
332f06de7f3SIngo Weinhold	local libs = $(2) ;
3339342c27aSIngo Weinhold	local source ;
334f06de7f3SIngo Weinhold	for source in $(1)
335f06de7f3SIngo Weinhold	{
336f06de7f3SIngo Weinhold		local target = $(source:S=) ;
337f06de7f3SIngo Weinhold		target = [ FGristFiles $(target) ] ;
338a6c008e1Sbeveloper
3393b4190abSbeveloper		BinCommand $(target) : $(source) : $(libs) ;
340f06de7f3SIngo Weinhold	}
341f06de7f3SIngo Weinhold}
342f06de7f3SIngo Weinhold
34352a38012Sejakowatzrule Preference
34452a38012Sejakowatz{
34552a38012Sejakowatz	# Preference <name> : <sources> ;
346a6c008e1Sbeveloper	SetupIncludes ;
34752a38012Sejakowatz	SetupObjectsDir ;
34852a38012Sejakowatz	Main $(<) : $(>) ;
34952a38012Sejakowatz	MakeLocate $(<) : $(OBOS_PREFS_DIR) ;
35052a38012Sejakowatz}
35152a38012Sejakowatz
35252a38012Sejakowatzrule Server
35352a38012Sejakowatz{
35452a38012Sejakowatz	# Server <name> : <sources> ;
35552a38012Sejakowatz
356a6c008e1Sbeveloper	SetupIncludes ;
35752a38012Sejakowatz	SetupObjectsDir ;
35852a38012Sejakowatz	Main $(<) : $(>) ;
35952a38012Sejakowatz	MakeLocate $(<) : $(OBOS_SERVER_DIR) ;
36052a38012Sejakowatz}
36152a38012Sejakowatz
36252a38012Sejakowatz# test pseudo targets
36352a38012SejakowatzNOTFILE obostests ;
36452a38012SejakowatzNOTFILE r5tests ;
36552a38012Sejakowatz
366d1f6c38fSTyler Dauwalderrule CommonTestLib
367d1f6c38fSTyler Dauwalder{
368c5ff4aa6STyler Dauwalder	# CommonTestLib <target> : <sources> : <obos libraries>
3699285de51STyler Dauwalder	#	: <r5 libraries> : <test libraries> : <public headers>;
370d1f6c38fSTyler Dauwalder	# Builds a unit test for both OBOS and R5 modules.
371d1f6c38fSTyler Dauwalder	# <target> The name of the target.
372d1f6c38fSTyler Dauwalder	# <sources> The list of sources.
373d1f6c38fSTyler Dauwalder	# <obos libraries> A list of link libraries for the OBOS tests (as passed
374d1f6c38fSTyler Dauwalder	# to LinkSharedOSLibs).
375d1f6c38fSTyler Dauwalder	# <r5 libraries> A list of link libraries for the R5 tests (as passed
376d1f6c38fSTyler Dauwalder	# to LinkSharedOSLibs).
3779285de51STyler Dauwalder	# <test libraries> A list of link libraries for both OBOS tests and R5 tests
3789285de51STyler Dauwalder	# that have a common name (i.e. specify libx.so and the OBOS tests will link
3799285de51STyler Dauwalder	# to libx.so and the R5 tests will link to libx_r5.so).
380d1f6c38fSTyler Dauwalder	# <public headers> A list of public header dirs (as passed to
381d1f6c38fSTyler Dauwalder	# UsePublicHeaders).
382d1f6c38fSTyler Dauwalder
383c5ff4aa6STyler Dauwalder	TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ;
384c5ff4aa6STyler Dauwalder	R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ;
385d1f6c38fSTyler Dauwalder}
386d1f6c38fSTyler Dauwalder
387d1f6c38fSTyler Dauwalderrule TestLib
388d1f6c38fSTyler Dauwalder{
389d1f6c38fSTyler Dauwalder	# TestLib <target> : <sources> : <dest> : <libraries> : <public headers>
390d1f6c38fSTyler Dauwalder	# Builds a unit test library for an OBOS module.
391d1f6c38fSTyler Dauwalder	# <target> The name of the target.
392d1f6c38fSTyler Dauwalder	# <sources> The list of sources.
393d1f6c38fSTyler Dauwalder	# <dest> The directory for the target (as passed to FDirName).
394d1f6c38fSTyler Dauwalder	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
395d1f6c38fSTyler Dauwalder	# <public headers> A list of public header dirs (as passed to
396d1f6c38fSTyler Dauwalder	# UsePublicHeaders).
397d1f6c38fSTyler Dauwalder
398d1f6c38fSTyler Dauwalder	local target = $(1) ;
399d1f6c38fSTyler Dauwalder	local sources = $(2) ;
400d1f6c38fSTyler Dauwalder	local dest = $(3) ;
401d1f6c38fSTyler Dauwalder	local libraries = $(4) ;
402d1f6c38fSTyler Dauwalder	local headerDirs = $(5) ;
4039342c27aSIngo Weinhold	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
404d1f6c38fSTyler Dauwalder
4059342c27aSIngo Weinhold	# Our Main replacement.
4069342c27aSIngo Weinhold	MainFromObjects $(target) : $(objects) ;
4079342c27aSIngo Weinhold	TestObjects $(sources) : $(headerDirs) ;
408d1f6c38fSTyler Dauwalder
409d1f6c38fSTyler Dauwalder	MakeLocate $(target) : $(dest) ;
4100d1cdd94SIngo Weinhold	Depends $(target) : libcppunit.so ;
4110d1cdd94SIngo Weinhold	Depends obostests : $(target) ;
412d1f6c38fSTyler Dauwalder	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
413d1f6c38fSTyler Dauwalder	LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ;
414d1f6c38fSTyler Dauwalder}
415d1f6c38fSTyler Dauwalder
416d1f6c38fSTyler Dauwalderrule R5TestLib
417d1f6c38fSTyler Dauwalder{
418c5ff4aa6STyler Dauwalder	# R5TestLib <target> : <sources> : <dest> : <libraries>
419d1f6c38fSTyler Dauwalder	# Builds a unit test for an R5 module. "_r5" is appended to the object
420d1f6c38fSTyler Dauwalder	# and the target name.
421d1f6c38fSTyler Dauwalder	# <target> The name of the target.
422d1f6c38fSTyler Dauwalder	# <sources> The list of sources.
423d1f6c38fSTyler Dauwalder	# <dest> The directory for the target (as passed to FDirName).
424d1f6c38fSTyler Dauwalder	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
425d1f6c38fSTyler Dauwalder
426d1f6c38fSTyler Dauwalder	local target = $(1:B)_r5$(1:S) ;
427d1f6c38fSTyler Dauwalder	local sources = $(2) ;
428c5ff4aa6STyler Dauwalder	local dest = $(3) ;
429d1f6c38fSTyler Dauwalder	local libraries = $(4) ;
430d1f6c38fSTyler Dauwalder	local objects = [ R5ObjectNames $(sources) ] ;
431d1f6c38fSTyler Dauwalder
432d1f6c38fSTyler Dauwalder	# Our Main replacement.
433d1f6c38fSTyler Dauwalder	MainFromObjects $(target) : $(objects) ;
4349342c27aSIngo Weinhold	TestObjects $(sources) : : true ;
435d1f6c38fSTyler Dauwalder
436d1f6c38fSTyler Dauwalder	MakeLocate $(target) : $(dest) ;
4370d1cdd94SIngo Weinhold	Depends $(target) : libcppunit.so ;
4380d1cdd94SIngo Weinhold	Depends r5tests : $(target) ;
439d1f6c38fSTyler Dauwalder	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
440d1f6c38fSTyler Dauwalder	LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ;
441d1f6c38fSTyler Dauwalder}
442d1f6c38fSTyler Dauwalder
44352a38012Sejakowatzrule CommonUnitTest
44452a38012Sejakowatz{
44552a38012Sejakowatz	# CommonUnitTest <target> : <sources> : <dest> : <obos libraries>
44652a38012Sejakowatz	#	: <r5 libraries> : <public headers>;
44752a38012Sejakowatz	# Builds a unit test for both OBOS and R5 modules.
44852a38012Sejakowatz	# <target> The name of the target.
44952a38012Sejakowatz	# <sources> The list of sources.
45052a38012Sejakowatz	# <dest> The directory for the target (as passed to FDirName).
45152a38012Sejakowatz	# <obos libraries> A list of link libraries for the OBOS tests (as passed
45252a38012Sejakowatz	# to LinkSharedOSLibs).
45352a38012Sejakowatz	# <r5 libraries> A list of link libraries for the R5 tests (as passed
45452a38012Sejakowatz	# to LinkSharedOSLibs).
45552a38012Sejakowatz	# <public headers> A list of public header dirs (as passed to
45652a38012Sejakowatz	# UsePublicHeaders).
45752a38012Sejakowatz
45852a38012Sejakowatz	UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ;
45952a38012Sejakowatz	R5UnitTest $(1) : $(2) : $(3) : $(5) ;
46052a38012Sejakowatz}
46152a38012Sejakowatz
46252a38012Sejakowatzrule UnitTest
46352a38012Sejakowatz{
46452a38012Sejakowatz	# UnitTest <target> : <sources> : <dest> : <libraries> : <public headers>
46552a38012Sejakowatz	# Builds a unit test for an OBOS module.
46652a38012Sejakowatz	# <target> The name of the target.
46752a38012Sejakowatz	# <sources> The list of sources.
46852a38012Sejakowatz	# <dest> The directory for the target (as passed to FDirName).
46952a38012Sejakowatz	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
47052a38012Sejakowatz	# <public headers> A list of public header dirs (as passed to
47152a38012Sejakowatz	# UsePublicHeaders).
47252a38012Sejakowatz
47352a38012Sejakowatz	local target = $(1) ;
47452a38012Sejakowatz	local sources = $(2) ;
47552a38012Sejakowatz	local dest = $(3) ;
47652a38012Sejakowatz	local libraries = $(4) ;
47752a38012Sejakowatz	local headerDirs = $(5) ;
4789342c27aSIngo Weinhold	local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
47952a38012Sejakowatz
4809342c27aSIngo Weinhold	# Our Main replacement.
4819342c27aSIngo Weinhold	MainFromObjects $(target) : $(objects) ;
4829342c27aSIngo Weinhold	TestObjects $(sources) : $(headerDirs) ;
4833b9eae39SIngo Weinhold
48452a38012Sejakowatz	MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ;
4859eea4522SIngo Weinhold	Depends $(target) : libcppunit.so ;
4869eea4522SIngo Weinhold	Depends obostests : $(target) ;
48752a38012Sejakowatz	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
48852a38012Sejakowatz}
48952a38012Sejakowatz
49052a38012Sejakowatzrule R5UnitTest
49152a38012Sejakowatz{
49252a38012Sejakowatz	# R5UnitTest <target> : <sources> : <dest> : <libraries>
49352a38012Sejakowatz	# Builds a unit test for an R5 module. "_r5" is appended to the object
49452a38012Sejakowatz	# and the target name.
49552a38012Sejakowatz	# <target> The name of the target.
49652a38012Sejakowatz	# <sources> The list of sources.
49752a38012Sejakowatz	# <dest> The directory for the target (as passed to FDirName).
49852a38012Sejakowatz	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
49952a38012Sejakowatz
50052a38012Sejakowatz	local target = $(1)_r5 ;
50152a38012Sejakowatz	local sources = $(2) ;
50252a38012Sejakowatz	local dest = $(3) ;
50352a38012Sejakowatz	local libraries = $(4) ;
50452a38012Sejakowatz	local objects = [ R5ObjectNames $(sources) ] ;
50552a38012Sejakowatz
50652a38012Sejakowatz	# Our Main replacement.
50752a38012Sejakowatz	MainFromObjects $(target) : $(objects) ;
5089342c27aSIngo Weinhold	TestObjects $(sources) : : true ;
50952a38012Sejakowatz
51052a38012Sejakowatz	MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ;
5119eea4522SIngo Weinhold	Depends $(target) : libcppunit.so ;
5129eea4522SIngo Weinhold	Depends r5tests : $(target) ;
51352a38012Sejakowatz	LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ;
51452a38012Sejakowatz}
51552a38012Sejakowatz
51652a38012Sejakowatzrule R5ObjectNames
51752a38012Sejakowatz{
51852a38012Sejakowatz	# R5ObjectNames <sources> ;
51952a38012Sejakowatz	# Returns a list of gristed object names given a list of source file names.
52052a38012Sejakowatz	# Moreover each object names gets "_r5" inserted before the object suffix.
52152a38012Sejakowatz	local objects = $(1:S=)_r5 ;
52252a38012Sejakowatz	return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ;
52352a38012Sejakowatz}
52452a38012Sejakowatz
5259342c27aSIngo Weinholdrule R5Objects
5269342c27aSIngo Weinhold{
5279342c27aSIngo Weinhold	# R5Objects <sources>
528dd9f8062SIngo Weinhold	# Similar to Objects, but appends "_r5" to the object file names and
529dd9f8062SIngo Weinhold	# removes `-nostdinc' from the CC and C++ flags to enable system headers.
5309342c27aSIngo Weinhold	# <sources> The source files.
5319342c27aSIngo Weinhold
532dd9f8062SIngo Weinhold	# Remove `-nostdinc' from CCFLAGS and C++FLAGS.
533dd9f8062SIngo Weinhold	local oldCCFLAGS = $(CCFLAGS) ;
534dd9f8062SIngo Weinhold	local oldC++FLAGS = $(C++FLAGS) ;
535dd9f8062SIngo Weinhold	CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ;
536dd9f8062SIngo Weinhold	C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ;
537dd9f8062SIngo Weinhold
5389342c27aSIngo Weinhold	local sources = $(1) ;
5399342c27aSIngo Weinhold	local source ;
5409342c27aSIngo Weinhold	for source in [ FGristFiles $(sources) ]
5419342c27aSIngo Weinhold	{
5429342c27aSIngo Weinhold		local object = [ R5ObjectNames $(source) ] ;
5439342c27aSIngo Weinhold		Object $(object) : $(source) ;
5449342c27aSIngo Weinhold		LocalDepends obj : $(object) ;
5459342c27aSIngo Weinhold	}
546dd9f8062SIngo Weinhold
547dd9f8062SIngo Weinhold	# Reset CCFLAGS and C++FLAGS to original values.
548dd9f8062SIngo Weinhold	CCFLAGS = $(oldCCFLAGS) ;
549dd9f8062SIngo Weinhold	C++FLAGS = $(oldC++FLAGS) ;
5509342c27aSIngo Weinhold}
5519342c27aSIngo Weinhold
5529342c27aSIngo Weinholdrule TestObjects
5539342c27aSIngo Weinhold{
5549342c27aSIngo Weinhold	# TestLib <sources> : <public headers> : <r5>
5559342c27aSIngo Weinhold	# Compiles objects for tests.
5569342c27aSIngo Weinhold	# <sources> The list of sources.
5579342c27aSIngo Weinhold	# <public headers> A list of public header dirs (as passed to
5589342c27aSIngo Weinhold	# UsePublicHeaders).
5599342c27aSIngo Weinhold	# <r5> If set, "_r5" is appended to the object file names and
5609342c27aSIngo Weinhold	# <public headers> is ignored. Furthermore the pre-processor macro
5619342c27aSIngo Weinhold	# TEST_R5 is defined, TEST_OBOS otherwise.
5629342c27aSIngo Weinhold
5639342c27aSIngo Weinhold	local sources = $(1) ;
5649342c27aSIngo Weinhold	local headerDirs = $(2) ;
5659342c27aSIngo Weinhold	local r5 = $(3) ;
5669342c27aSIngo Weinhold	local objects ;
5679342c27aSIngo Weinhold
5689342c27aSIngo Weinhold	# Turn optimization off.
56996d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
5709342c27aSIngo Weinhold		local optim = $(OPTIM) ;
5719342c27aSIngo Weinhold		OPTIM = ;
57296d27465SIngo Weinhold	}
5739342c27aSIngo Weinhold
5749342c27aSIngo Weinhold	SetupObjectsDir ;
5759342c27aSIngo Weinhold
5769342c27aSIngo Weinhold	# compile
5779342c27aSIngo Weinhold	if $(r5) {
578dd9f8062SIngo Weinhold		SetupR5Includes ;
5799342c27aSIngo Weinhold		objects = [ R5ObjectNames $(sources) ] ;
5809342c27aSIngo Weinhold		R5Objects $(sources) ;
5819342c27aSIngo Weinhold	} else {
582dd9f8062SIngo Weinhold		SetupIncludes ;
5839342c27aSIngo Weinhold		objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
5849342c27aSIngo Weinhold		Objects $(sources) ;
5859342c27aSIngo Weinhold	}
5869342c27aSIngo Weinhold
5879342c27aSIngo Weinhold	# set headers/defines
5889b60a208SIngo Weinhold	UseCppUnitObjectHeaders $(sources) : $(objects) ;
5899342c27aSIngo Weinhold	if $(r5) {
5909342c27aSIngo Weinhold		ObjectDefines $(objects) : TEST_R5 ;
5919342c27aSIngo Weinhold	} else {
5929b60a208SIngo Weinhold		UsePublicObjectHeaders $(sources) : $(headerDirs) : $(objects) ;
5939342c27aSIngo Weinhold		ObjectDefines $(objects) : TEST_OBOS ;
5949342c27aSIngo Weinhold	}
5959342c27aSIngo Weinhold
59696d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
5979342c27aSIngo Weinhold		# Turn debugging on. That is usually desired for test code.
5989342c27aSIngo Weinhold		ObjectCcFlags $(objects) : "-g" ;
5999342c27aSIngo Weinhold		ObjectC++Flags $(objects) : "-g" ;
6009342c27aSIngo Weinhold
6019342c27aSIngo Weinhold		# Turn optimization on again.
6029342c27aSIngo Weinhold		OPTIM = $(optim) ;
6039342c27aSIngo Weinhold	}
60496d27465SIngo Weinhold}
6059342c27aSIngo Weinhold
6069285de51STyler Dauwalderrule R5SharedLibraryNames
6079285de51STyler Dauwalder{
6089285de51STyler Dauwalder	# R5SharedLibraryNames <sources> ;
6099285de51STyler Dauwalder	# Returns a list of shared library names given a list of file names. NO
6109285de51STyler Dauwalder	# GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted
6119285de51STyler Dauwalder	# before the shared lib suffix.
6129285de51STyler Dauwalder	return $(1:S=)_r5.so ;
6139285de51STyler Dauwalder}
6149285de51STyler Dauwalder
6159fc6b2e1SIngo Weinholdrule SimpleTest
6169fc6b2e1SIngo Weinhold{
6179fc6b2e1SIngo Weinhold	# UnitTest <target> : <sources> : <libraries>
6189fc6b2e1SIngo Weinhold	# Builds a unit test for an OBOS module.
6199fc6b2e1SIngo Weinhold	# <target> The name of the target.
6209fc6b2e1SIngo Weinhold	# <sources> The list of sources.
6219fc6b2e1SIngo Weinhold	# <dest> The directory for the target (as passed to FDirName).
6229fc6b2e1SIngo Weinhold	# <libraries> A list of link libraries (as passed to LinkSharedOSLibs).
6239fc6b2e1SIngo Weinhold	# <public headers> A list of public header dirs (as passed to
6249fc6b2e1SIngo Weinhold	# UsePublicHeaders).
6259fc6b2e1SIngo Weinhold
6269fc6b2e1SIngo Weinhold	local target = $(1) ;
6279fc6b2e1SIngo Weinhold	local sources = $(2) ;
6289fc6b2e1SIngo Weinhold	local libraries = $(3) ;
6299fc6b2e1SIngo Weinhold	local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ;
6309fc6b2e1SIngo Weinhold
6319fc6b2e1SIngo Weinhold	# Turn optimization off.
63296d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
6339fc6b2e1SIngo Weinhold		local optim = $(OPTIM) ;
6349fc6b2e1SIngo Weinhold		OPTIM = ;
63596d27465SIngo Weinhold	}
6369fc6b2e1SIngo Weinhold
637a6c008e1Sbeveloper	SetupIncludes ;
6389fc6b2e1SIngo Weinhold	SetupObjectsDir ;
6399fc6b2e1SIngo Weinhold	MakeLocateObjects $(sources) ;
6409fc6b2e1SIngo Weinhold	Main $(target) : $(sources) ;
6419fc6b2e1SIngo Weinhold	MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ;
6429eea4522SIngo Weinhold	Depends obostests : $(target) ;
6439fc6b2e1SIngo Weinhold	LinkSharedOSLibs $(target) : $(libraries) ;
6449fc6b2e1SIngo Weinhold	ObjectDefines $(sources) : TEST_OBOS ;
6459fc6b2e1SIngo Weinhold
64696d27465SIngo Weinhold	if ! $(NO_TEST_DEBUG) {
6479fc6b2e1SIngo Weinhold		# Turn debugging on. That is usually desired for test code.
6489fc6b2e1SIngo Weinhold		ObjectCcFlags $(sources) : "-g" ;
6499fc6b2e1SIngo Weinhold		ObjectC++Flags $(sources) : "-g" ;
6509fc6b2e1SIngo Weinhold
6519fc6b2e1SIngo Weinhold		# Turn optimization on again.
6529fc6b2e1SIngo Weinhold		OPTIM = $(optim) ;
6539fc6b2e1SIngo Weinhold	}
65496d27465SIngo Weinhold}
6559fc6b2e1SIngo Weinhold
65652a38012Sejakowatzrule Addon
65752a38012Sejakowatz{
65883b3b0dfSIngo Weinhold	# Addon <name> : <relpath> : <sources> : <is executable> : <libraries> ;
6597a384fdeSIngo Weinhold	# <name>: Name of the add-on.
6607a384fdeSIngo Weinhold	# <relpath>: Path where the add-on shall live relative to the add-on dir.
6617a384fdeSIngo Weinhold	# <sources>: Source files.
66283b3b0dfSIngo Weinhold	# <is executable>: true, if the target shall be executable as well.
66383b3b0dfSIngo Weinhold	# <libraries>: Libraries to be linked against.
6647a384fdeSIngo Weinhold
6657a384fdeSIngo Weinhold	local isExecutable = $(4) ;
66652a38012Sejakowatz
667a6c008e1Sbeveloper	SetupIncludes ;
66852a38012Sejakowatz	SetupObjectsDir ;
66952a38012Sejakowatz	Main $(1) : $(3) ;
67052a38012Sejakowatz
67152a38012Sejakowatz	# Create output dir path for addon
67252a38012Sejakowatz	local targetdir;
67352a38012Sejakowatz	targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ;
67452a38012Sejakowatz
67552a38012Sejakowatz	MakeLocate $(1) : $(targetdir) ;
6767a384fdeSIngo Weinhold
6777a384fdeSIngo Weinhold	local linkFlags = -Xlinker -soname=\"$(1)\" ;
6787a384fdeSIngo Weinhold	if $(isExecutable) != true {
6797a384fdeSIngo Weinhold		linkFlags = -nostart $(linkFlags) ;
6807a384fdeSIngo Weinhold	}
6817a384fdeSIngo Weinhold	LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ;
68283b3b0dfSIngo Weinhold	LinkSharedOSLibs $(1) : $(5) ;
683af28904fSIngo Weinhold}
684af28904fSIngo Weinhold
68558efc9d8SIngo Weinholdrule R5KernelAddon
686af28904fSIngo Weinhold{
68758efc9d8SIngo Weinhold	# R5KernelAddon <name> : <relpath> : <sources> ;
688af28904fSIngo Weinhold
689af28904fSIngo Weinhold	local sources = $(3) ;
690af28904fSIngo Weinhold
691af28904fSIngo Weinhold	Addon $(1) : $(2) : $(3) ;
692af28904fSIngo Weinhold	ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ;
693af28904fSIngo Weinhold	ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic
694af28904fSIngo Weinhold								-fno-exceptions -fno-rtti ;
6959eea4522SIngo Weinhold	LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ;
696af28904fSIngo Weinhold	LinkSharedOSLibs $(1) : /boot/develop/lib/x86/_KERNEL_ ;
69752a38012Sejakowatz}
69852a38012Sejakowatz
6994fb5add0SMatthew Wilberrule Translator
7004fb5add0SMatthew Wilber{
7014fb5add0SMatthew Wilber	# Translator <name> : <sources> ;
702a6c008e1Sbeveloper	SetupIncludes ;
7034fb5add0SMatthew Wilber	SetupObjectsDir ;
7044fb5add0SMatthew Wilber	Main $(1) : $(2) ;
7054fb5add0SMatthew Wilber
7064fb5add0SMatthew Wilber	# Create output dir path for translator
7074fb5add0SMatthew Wilber	local targetdir;
7084fb5add0SMatthew Wilber	targetdir = [ FDirName $(OBOS_ADDON_DIR) translators ] ;
7094fb5add0SMatthew Wilber	MakeLocate $(1) : $(targetdir) ;
7104fb5add0SMatthew Wilber}
7114fb5add0SMatthew Wilber
71252a38012Sejakowatzrule MakeLocateObjects
71352a38012Sejakowatz{
71421df5945SIngo Weinhold	# MakeLocateObjects <sources_or_objects> ;
71552a38012Sejakowatz
71621df5945SIngo Weinhold	local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ;
71752a38012Sejakowatz
71852a38012Sejakowatz	for o in $(_objs)
71952a38012Sejakowatz	{
72052a38012Sejakowatz		local dir = $(o:D) ;
72152a38012Sejakowatz		if $(dir) {
72252a38012Sejakowatz			MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ;
72352a38012Sejakowatz		} else {
72452a38012Sejakowatz			MakeLocate $(o) : $(LOCATE_TARGET) ;
72552a38012Sejakowatz		}
72652a38012Sejakowatz	}
72752a38012Sejakowatz}
72852a38012Sejakowatz
72952a38012Sejakowatzrule StaticLibrary
73052a38012Sejakowatz{
73152a38012Sejakowatz	# StaticLibrary <name> : <sources> ;
73252a38012Sejakowatz
733a6c008e1Sbeveloper	SetupIncludes ;
73452a38012Sejakowatz	SetupObjectsDir ;
73552a38012Sejakowatz	MakeLocateObjects $(2) ;
73652a38012Sejakowatz	Library lib$(<).a : $(>) ;
73752a38012Sejakowatz	MakeLocate lib$(<).a : $(OBOS_STLIB_DIR) ;
73852a38012Sejakowatz}
73952a38012Sejakowatz
740dbf96817SIngo Weinholdrule R5KernelStaticLibrary
741dbf96817SIngo Weinhold{
742dbf96817SIngo Weinhold	# R5KernelStaticLibrary <name> : <sources> ;
743dbf96817SIngo Weinhold
744dbf96817SIngo Weinhold	local lib = lib$(1).a ;
745dbf96817SIngo Weinhold	local sources = $(2) ;
746dbf96817SIngo Weinhold
747dbf96817SIngo Weinhold	SetupIncludes ;
748dbf96817SIngo Weinhold	SetupObjectsDir ;
749dbf96817SIngo Weinhold	MakeLocateObjects $(sources) ;
750dbf96817SIngo Weinhold	Library $(lib) : $(sources) ;
751dbf96817SIngo Weinhold	ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ;
752dbf96817SIngo Weinhold	ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic
753dbf96817SIngo Weinhold								-fno-exceptions -fno-rtti ;
754dbf96817SIngo Weinhold}
755dbf96817SIngo Weinhold
75680721244SAxel Dörflerrule MergeObjectFromObjects
75780721244SAxel Dörfler{
75880721244SAxel Dörfler	# MergeObjectFromObjects <name> : <objects> ;
759c8aa252aSIngo Weinhold	local objects = [ FGristFiles $(2) ] ;
76080721244SAxel Dörfler	MakeLocate $(1) : $(LOCATE_TARGET) ;
761c8aa252aSIngo Weinhold	Depends $(1) : $(objects) ;
76280721244SAxel Dörfler	LINK on $(1) = ld ;
763c8aa252aSIngo Weinhold	MergeObjectFromObjects1 $(1) : $(objects) ;
76480721244SAxel Dörfler}
76580721244SAxel Dörfler
76654b7cbe1SIngo Weinholdactions MergeObjectFromObjects1
76780721244SAxel Dörfler{
76880721244SAxel Dörfler	$(LINK) -r $(2) -o $(1) ;
76980721244SAxel Dörfler}
77080721244SAxel Dörfler
77180721244SAxel Dörflerrule MergeObject
77280721244SAxel Dörfler{
77380721244SAxel Dörfler	# MergeObject <name> : <sources> ;
77480721244SAxel Dörfler	SetupIncludes ;
77580721244SAxel Dörfler	SetupObjectsDir ;
77680721244SAxel Dörfler	MakeLocateObjects $(2) ;
77780721244SAxel Dörfler	Objects $(2) ;
77880721244SAxel Dörfler	MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) ;
77980721244SAxel Dörfler}
78080721244SAxel Dörfler
78121df5945SIngo Weinholdrule SharedLibraryFromObjects
78252a38012Sejakowatz{
7838d3308d9SIngo Weinhold	# SharedLibraryFromObjects <name> : <objects> : <libraries> ;
78452a38012Sejakowatz	local _lib = lib$(1).so ;
78521df5945SIngo Weinhold	MainFromObjects $(_lib) : $(2) ;
78652a38012Sejakowatz	MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ;
7879eea4522SIngo Weinhold	LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ]
7889eea4522SIngo Weinhold						   -nostart -Xlinker -soname=\"$(_lib)\" ;
7898d3308d9SIngo Weinhold	LinkSharedOSLibs $(_lib) : $(3) ;
79052a38012Sejakowatz}
79152a38012Sejakowatz
79221df5945SIngo Weinholdrule SharedLibrary
79321df5945SIngo Weinhold{
7948d3308d9SIngo Weinhold	# SharedLibrary <name> : <sources> : <libraries> ;
795a6c008e1Sbeveloper	SetupIncludes ;
79621df5945SIngo Weinhold	SetupObjectsDir ;
79721df5945SIngo Weinhold	MakeLocateObjects $(2) ;
79821df5945SIngo Weinhold	Objects $(2) ;
7998d3308d9SIngo Weinhold	SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ;
80021df5945SIngo Weinhold}
80121df5945SIngo Weinhold
80252a38012Sejakowatzrule LinkSharedOSLibs
80352a38012Sejakowatz{
80452a38012Sejakowatz	# LinkSharedOSLibs <name> : <libs> ;
80552a38012Sejakowatz	# Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or
8064236d490SIngo Weinhold	# "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy
8074236d490SIngo Weinhold	# has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the
8084236d490SIngo Weinhold	# file will be bound!), otherwise it is prefixed "-l" and added to
8094236d490SIngo Weinhold	# LINKLIBS.
81052a38012Sejakowatz
81152a38012Sejakowatz	for i in $(>)
81252a38012Sejakowatz	{
8134236d490SIngo Weinhold		local isfile = ;
8144236d490SIngo Weinhold		if $(i:D) || $(i:G) {
8154236d490SIngo Weinhold			isfile = true ;
8164236d490SIngo Weinhold		} else {
81752a38012Sejakowatz			switch $(i:B)
81852a38012Sejakowatz			{
819f7901247SPhilippe Houdoin				case _APP_ : isfile = true ;
820f7901247SPhilippe Houdoin				case _KERNEL_ : isfile = true ;
821f7901247SPhilippe Houdoin				case *.so     : isfile = true ;
822f7901247SPhilippe Houdoin				case *.a      : isfile = true ;
8234236d490SIngo Weinhold				case lib*	: isfile = true ;
8244236d490SIngo Weinhold				case *	: isfile = ;
8254236d490SIngo Weinhold			}
8264236d490SIngo Weinhold		}
8274236d490SIngo Weinhold		if $(isfile) {
8289eea4522SIngo Weinhold			NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ;
8299eea4522SIngo Weinhold			Depends $(1) : $(i) ;
8304236d490SIngo Weinhold		} else {
8319eea4522SIngo Weinhold			LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ;
83252a38012Sejakowatz		}
83352a38012Sejakowatz	}
83452a38012Sejakowatz}
83552a38012Sejakowatz
83652a38012Sejakowatzrule LinkStaticOSLibs
83752a38012Sejakowatz{
83852a38012Sejakowatz	# LinkStaticOSLibs <name> : <libs> ;
83952a38012Sejakowatz
84052a38012Sejakowatz	for i in $(>)
84152a38012Sejakowatz	{
84252a38012Sejakowatz		LINKLIBS on $(<) = $(LINKLIBS) -l $(i) ;
84352a38012Sejakowatz	}
84452a38012Sejakowatz}
84552a38012Sejakowatz
84652a38012Sejakowatzrule AddResources
84752a38012Sejakowatz{
84852a38012Sejakowatz	# AddResources <name> : <resourcefiles> ;
84952a38012Sejakowatz
8508d3308d9SIngo Weinhold	local resfiles = [ FGristFiles $(2) ] ;
8518d3308d9SIngo Weinhold	SEARCH on $(resfiles) += $(SEARCH_SOURCE) ;
8528d3308d9SIngo Weinhold
8538d3308d9SIngo Weinhold	for file in $(resfiles) {
8548d3308d9SIngo Weinhold		if $(file:S) = .rdef {
8558d3308d9SIngo Weinhold			local rdef = $(file) ;
8568d3308d9SIngo Weinhold			file = $(rdef:S=.rsrc) ;
8578d3308d9SIngo Weinhold			ResComp $(file) : $(rdef) ;
8588d3308d9SIngo Weinhold		}
8598d3308d9SIngo Weinhold		RESFILES on $(1) += $(file) ;
8608d3308d9SIngo Weinhold	}
8618d3308d9SIngo Weinhold}
8628d3308d9SIngo Weinhold
8638d3308d9SIngo Weinholdrule ResComp
8648d3308d9SIngo Weinhold{
8658d3308d9SIngo Weinhold	# ResComp <resource file> : <rdef file> ;
8668d3308d9SIngo Weinhold	#
8678d3308d9SIngo Weinhold	# <resource file> and <rdef file> must be gristed.
8688d3308d9SIngo Weinhold
8698d3308d9SIngo Weinhold	SetupObjectsDir ;
8708d3308d9SIngo Weinhold
8719fc6b2e1SIngo Weinhold	SEARCH on $(2) += $(SEARCH_SOURCE) ;
8728d3308d9SIngo Weinhold	MakeLocate $(1) : $(LOCATE_TARGET) ;
8738d3308d9SIngo Weinhold	Depends $(1) : $(2) rc ;
8748d3308d9SIngo Weinhold	LocalClean clean : $(1) ;
8758d3308d9SIngo Weinhold	ResComp1 $(1) : rc $(2) ;
8768d3308d9SIngo Weinhold}
8778d3308d9SIngo Weinhold
8788d3308d9SIngo Weinholdactions ResComp1
8798d3308d9SIngo Weinhold{
8806af76074SIngo Weinhold	$(2[1]) -o $(1) $(2[2-])
88152a38012Sejakowatz}
88252a38012Sejakowatz
8839b60a208SIngo Weinholdrule SourceHdrs
8849b60a208SIngo Weinhold{
8859b60a208SIngo Weinhold	# SourceHdrs <sources> : <headers> [ : <gristed objects> ] ;
8869b60a208SIngo Weinhold	#
8879b60a208SIngo Weinhold	# Is a wrapper for ObjectHdrs, that passes <sources> and <headers> or,
8889b60a208SIngo Weinhold	# if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not
8899b60a208SIngo Weinhold	# done by ObjectHdrs).
8909b60a208SIngo Weinhold
8919b60a208SIngo Weinhold	local sources = [ FGristFiles $(1) ] ;
8929b60a208SIngo Weinhold	local headers = $(2) ;
8939b60a208SIngo Weinhold	local objects = $(3) ;
8949b60a208SIngo Weinhold
8959b60a208SIngo Weinhold	if $(objects) {
8969b60a208SIngo Weinhold		ObjectHdrs $(objects) : $(headers) ;
8979b60a208SIngo Weinhold	} else {
8989b60a208SIngo Weinhold		ObjectHdrs $(sources) : $(headers) ;
8999b60a208SIngo Weinhold	}
9009b60a208SIngo Weinhold
9019b60a208SIngo Weinhold	# Also add the header search dirs to HDRSEARCH. Note, that these dirs
9029b60a208SIngo Weinhold	# will be listed after the STDHDRS (if any), but that's better than not
9039b60a208SIngo Weinhold	# being listed at all.
9049b60a208SIngo Weinhold	HDRSEARCH on $(sources) += $(headers) ;
9059b60a208SIngo Weinhold}
9069b60a208SIngo Weinhold
9077d7f280eSIngo Weinholdrule PublicHeaders
90852a38012Sejakowatz{
9097d7f280eSIngo Weinhold	# PublicHeaders <group list>
91052a38012Sejakowatz	#
9117d7f280eSIngo Weinhold	# Returns the directory names for the public header dirs identified by
9127d7f280eSIngo Weinhold	# <group list>.
91352a38012Sejakowatz
91452a38012Sejakowatz	local list = $(1) ;
915b005dbe3SAxel Dörfler	local dirs = [ FDirName $(OBOS_TOP) headers os ] ;
916b005dbe3SAxel Dörfler
91752a38012Sejakowatz	for i in $(list) {
9187d7f280eSIngo Weinhold		dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ;
9197d7f280eSIngo Weinhold	}
9207d7f280eSIngo Weinhold	return $(dirs) ;
92152a38012Sejakowatz}
92252a38012Sejakowatz
9237d7f280eSIngo Weinholdrule PrivateHeaders
9247d7f280eSIngo Weinhold{
9257d7f280eSIngo Weinhold	# PrivateHeaders <group list>
9267d7f280eSIngo Weinhold	#
9277d7f280eSIngo Weinhold	# Returns the directory names for the private header dirs identified by
9287d7f280eSIngo Weinhold	# <group list>.
9297d7f280eSIngo Weinhold
9307d7f280eSIngo Weinhold	local list = $(1) ;
9317d7f280eSIngo Weinhold	local dirs ;
9327d7f280eSIngo Weinhold	for i in $(list) {
9337d7f280eSIngo Weinhold		dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ;
9347d7f280eSIngo Weinhold	}
9357d7f280eSIngo Weinhold	return $(dirs) ;
9367d7f280eSIngo Weinhold}
9377d7f280eSIngo Weinhold
9380f434a0aSDarkWyrmrule LibraryHeaders
9390f434a0aSDarkWyrm{
9400f434a0aSDarkWyrm	# LibraryHeaders <group list>
9410f434a0aSDarkWyrm	#
9420f434a0aSDarkWyrm	# Returns the directory names for the library header dirs identified by
9430f434a0aSDarkWyrm	# <group list>.
9440f434a0aSDarkWyrm
9450f434a0aSDarkWyrm	local list = $(1) ;
9460f434a0aSDarkWyrm	local dirs ;
9470f434a0aSDarkWyrm	for i in $(list) {
9480f434a0aSDarkWyrm		dirs += [ FDirName $(OBOS_TOP) headers libs $(i) ] ;
9490f434a0aSDarkWyrm	}
9500f434a0aSDarkWyrm	return $(dirs) ;
9510f434a0aSDarkWyrm}
9520f434a0aSDarkWyrm
9537d7f280eSIngo Weinholdrule ArchHeaders
9547d7f280eSIngo Weinhold{
9557d7f280eSIngo Weinhold	# usage: ArchHeaders <arch> ;
9567d7f280eSIngo Weinhold	#
9577d7f280eSIngo Weinhold	# <arch> specifies the architecture (e.g. x86).
9587d7f280eSIngo Weinhold
9597d7f280eSIngo Weinhold	return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ;
9607d7f280eSIngo Weinhold}
9617d7f280eSIngo Weinhold
9627d7f280eSIngo Weinholdrule UsePublicHeaders
9637d7f280eSIngo Weinhold{
964966528dcSIngo Weinhold	# UsePublicHeaders <group list> ;
965966528dcSIngo Weinhold	#
966966528dcSIngo Weinhold	# Adds the public C header dirs given by <group list> to the header search
967966528dcSIngo Weinhold	# dirs of the subdirectory.
968966528dcSIngo Weinhold	# NOTE: This rule must be invoked *before* the rule that builds the
969966528dcSIngo Weinhold	# objects.
970966528dcSIngo Weinhold
971966528dcSIngo Weinhold	UseHeaders [ PublicHeaders $(1) ] ;
9727d7f280eSIngo Weinhold}
9737d7f280eSIngo Weinhold
9747d7f280eSIngo Weinholdrule UsePublicObjectHeaders
9757d7f280eSIngo Weinhold{
9769b60a208SIngo Weinhold	# UsePublicObjectHeaders <sources> : <group list> [ : <objects> ] ;
9777d7f280eSIngo Weinhold	#
9787d7f280eSIngo Weinhold	# Adds the public C header dirs given by <group list> to the header search
9799b60a208SIngo Weinhold	# dirs of either the object targets of <sources> or if supplied to
9809b60a208SIngo Weinhold	# <objects>. Also adjusts HDRSEARCH of <sources>.
9817d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
9827d7f280eSIngo Weinhold
9839b60a208SIngo Weinhold	SourceHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ;
98452a38012Sejakowatz}
98552a38012Sejakowatz
98652a38012Sejakowatzrule UsePrivateHeaders
98752a38012Sejakowatz{
9887d7f280eSIngo Weinhold	# UsePrivateHeaders <group list> ;
98952a38012Sejakowatz	#
99052a38012Sejakowatz	# Adds the private C header dirs given by <group list> to the header search
9917d7f280eSIngo Weinhold	# dirs of the subdirectory.
9927d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *before* the rule that builds the objects.
99352a38012Sejakowatz
9947d7f280eSIngo Weinhold	UseHeaders [ PrivateHeaders $(1) ] ;
99552a38012Sejakowatz}
99652a38012Sejakowatz
9977d7f280eSIngo Weinholdrule UsePrivateObjectHeaders
9987d7f280eSIngo Weinhold{
9999b60a208SIngo Weinhold	# UsePrivateObjectHeaders <sources> : <group list> [ : <objects> ] ;
10007d7f280eSIngo Weinhold	#
10017d7f280eSIngo Weinhold	# Adds the private C header dirs given by <group list> to the header search
10029b60a208SIngo Weinhold	# dirs of either the object targets of <sources> or if supplied to
10039b60a208SIngo Weinhold	# <objects>. Also adjusts HDRSEARCH of <sources>.
10047d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
10057d7f280eSIngo Weinhold
10069b60a208SIngo Weinhold	SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ;
100752a38012Sejakowatz}
100852a38012Sejakowatz
100952a38012Sejakowatzrule UseHeaders
101052a38012Sejakowatz{
10117d7f280eSIngo Weinhold	# UseHeaders <headers> ;
101252a38012Sejakowatz	#
101352a38012Sejakowatz	# Adds the C header dirs <headers> to the header search
10147d7f280eSIngo Weinhold	# dirs of the subdirectory.
10157d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *before* the rule that builds the objects.
101652a38012Sejakowatz
10177d7f280eSIngo Weinhold	local header ;
10187d7f280eSIngo Weinhold	for header in $(1) {
101952a38012Sejakowatz		SubDirHdrs $(header) ;
102052a38012Sejakowatz	}
102152a38012Sejakowatz}
102252a38012Sejakowatz
102352a38012Sejakowatzrule UseCppUnitHeaders
102452a38012Sejakowatz{
10257d7f280eSIngo Weinhold	SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ;
102652a38012Sejakowatz}
102752a38012Sejakowatz
1028be5af1baSIngo Weinholdrule UseCppUnitObjectHeaders
1029be5af1baSIngo Weinhold{
10309b60a208SIngo Weinhold	# UseCppUnitObjectHeaders <sources> [ : <objects> ] ;
10319b60a208SIngo Weinhold	SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] : $(2) ;
1032be5af1baSIngo Weinhold}
1033be5af1baSIngo Weinhold
103452a38012Sejakowatzrule UseArchHeaders
103552a38012Sejakowatz{
10367d7f280eSIngo Weinhold	# usage: UseArchHeaders <arch> ;
10377d7f280eSIngo Weinhold	#
103852a38012Sejakowatz	# <arch> specifies the architecture (e.g. x86).
10397d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *before* the rule that builds the objects.
10407d7f280eSIngo Weinhold
10417d7f280eSIngo Weinhold	local headers = [ ArchHeaders $(1) ] ;
104252a38012Sejakowatz	local opt = -D$(OBOS_TARGET_DEFINE) ;
1043c633961aSIngo Weinhold
104452a38012Sejakowatz	SubDirCcFlags $(opt)  ;
104552a38012Sejakowatz	SubDirC++Flags $(opt)  ;
1046089a0629Sbeveloper	HDRS += $(headers) ;
1047c633961aSIngo Weinhold}
1048c633961aSIngo Weinhold
10497d7f280eSIngo Weinholdrule UseArchObjectHeaders
10507d7f280eSIngo Weinhold{
10519b60a208SIngo Weinhold	# usage: UseArchObjectHeaders <sources> : <arch> : [ <objects> ] ;
10527d7f280eSIngo Weinhold	#
10537d7f280eSIngo Weinhold	# <arch> specifies the architecture (e.g. x86).
10547d7f280eSIngo Weinhold	# <sources_or_objects> Source or object files.
10557d7f280eSIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
10567d7f280eSIngo Weinhold
10579b60a208SIngo Weinhold	local sources = $(1) ;
10587d7f280eSIngo Weinhold	local headers = [ ArchHeaders $(2) ] ;
10599b60a208SIngo Weinhold	local objects = $(3) ;
10609b60a208SIngo Weinhold	local targets ;
10619b60a208SIngo Weinhold	if $(objects) {
10629b60a208SIngo Weinhold		targets = $(objects) ;
10639b60a208SIngo Weinhold	} else {
10649b60a208SIngo Weinhold		targets = $(sources) ;
10659b60a208SIngo Weinhold	}
10667d7f280eSIngo Weinhold	local opt = -D$(OBOS_TARGET_DEFINE) ;
10677d7f280eSIngo Weinhold
10687d7f280eSIngo Weinhold	ObjectCcFlags $(targets) : $(opt)  ;
10697d7f280eSIngo Weinhold	ObjectC++Flags $(targets) : $(opt)  ;
10709b60a208SIngo Weinhold	SourceHdrs $(sources) : $(headers) : $(objects) ;
107152a38012Sejakowatz}
107252a38012Sejakowatz
1073d25a77b4SIngo Weinholdrule UsePosixHeaders
1074d25a77b4SIngo Weinhold{
1075a6c008e1Sbeveloper	# XXX changed to do nothing
1076d25a77b4SIngo Weinhold}
1077d25a77b4SIngo Weinhold
1078d25a77b4SIngo Weinholdrule UsePosixObjectHeaders
1079d25a77b4SIngo Weinhold{
10809b60a208SIngo Weinhold	# UsePosixObjectHeaders <sources> [ : <objects> ] ;
1081d25a77b4SIngo Weinhold	#
1082d25a77b4SIngo Weinhold	# Adds the POSIX header dir to the header search
10839b60a208SIngo Weinhold	# dirs of either the object targets of <sources> or if supplied to
10849b60a208SIngo Weinhold	# <objects>. Also adjusts HDRSEARCH of <sources>.
1085d25a77b4SIngo Weinhold	# NOTE: This rule must be invoked *after* the rule that builds the objects.
1086d25a77b4SIngo Weinhold
10879b60a208SIngo Weinhold	SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] : $(2) ;
1088d25a77b4SIngo Weinhold}
1089d25a77b4SIngo Weinhold
10900f434a0aSDarkWyrmrule UseLibraryHeaders
10910f434a0aSDarkWyrm{
10920f434a0aSDarkWyrm	# UseLibraryHeaders <group list> ;
10930f434a0aSDarkWyrm	#
10940f434a0aSDarkWyrm	# Adds the library header dirs given by <group list> to the header search
10950f434a0aSDarkWyrm	# dirs of the subdirectory.
10960f434a0aSDarkWyrm	# NOTE: This rule must be invoked *before* the rule that builds the objects.
10970f434a0aSDarkWyrm
10980f434a0aSDarkWyrm	UseHeaders [ LibraryHeaders $(1) ] ;
10990f434a0aSDarkWyrm}
11000f434a0aSDarkWyrm
11013b9eae39SIngo Weinholdrule SplitPath
11023b9eae39SIngo Weinhold{
11033b9eae39SIngo Weinhold	# SplitPath <path> ;
11043b9eae39SIngo Weinhold	# Decomposes a path into its components.
11053b9eae39SIngo Weinhold	local path = $(1:G=) ;
11063b9eae39SIngo Weinhold	local components ;
11078c27f58dSIngo Weinhold	# $(path:D) for "/" is "/". Therefore the second condition.
11088c27f58dSIngo Weinhold	while $(path:D) && $(path:D) != $(path)
11093b9eae39SIngo Weinhold	{
11103b9eae39SIngo Weinhold		# Note: $(path:B) returns "." for "..", but $(path:D=) is fine.
11113b9eae39SIngo Weinhold		components = $(path:D=) $(components) ;
11123b9eae39SIngo Weinhold		path = $(path:D) ;
11133b9eae39SIngo Weinhold	}
11143b9eae39SIngo Weinhold	components = $(path) $(components) ;
11153b9eae39SIngo Weinhold	return $(components) ;
11163b9eae39SIngo Weinhold}
11173b9eae39SIngo Weinhold
11189fc6b2e1SIngo Weinholdrule PrependObjectHdrs
11199fc6b2e1SIngo Weinhold{
11209fc6b2e1SIngo Weinhold	# PrependObjectHdrs <objects_or_sources> : <dirs> ;
11219fc6b2e1SIngo Weinhold	# Prepends <dirs> to the list of header search dirs of the objects
11229fc6b2e1SIngo Weinhold	# specified by <objects_or_sources>. The HDRS variable will not be
11239fc6b2e1SIngo Weinhold	# changed, only CCHDRS.
11249fc6b2e1SIngo Weinhold	# Note: A subsequent ObjectHdrs invocation will therefore undo the
11259fc6b2e1SIngo Weinhold	# effect of this rule.
11269fc6b2e1SIngo Weinhold	# NOTE: This is a hack.
11279fc6b2e1SIngo Weinhold
11289fc6b2e1SIngo Weinhold	local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ;
11299fc6b2e1SIngo Weinhold	local dirs = $(2) ;
11309fc6b2e1SIngo Weinhold	for object in $(objects) {
11319fc6b2e1SIngo Weinhold		# Don't change HDRS to avoid screwing up the header scanning.
11329fc6b2e1SIngo Weinhold		PREPENDED_HDRS on $(object)
11339fc6b2e1SIngo Weinhold			= $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ;
11349fc6b2e1SIngo Weinhold		CCHDRS on $(object)
11359fc6b2e1SIngo Weinhold			= [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ;
11369fc6b2e1SIngo Weinhold	}
11379fc6b2e1SIngo Weinhold}
11389fc6b2e1SIngo Weinhold
11393b9eae39SIngo Weinholdrule SymLink
11403b9eae39SIngo Weinhold{
11413b9eae39SIngo Weinhold	# SymLink <target> : <source> ;
11423b9eae39SIngo Weinhold	# Links <target> to <source>.
11433b9eae39SIngo Weinhold	# <source> is the exact link contents. No binding is done.
11443b9eae39SIngo Weinhold	LINKCONTENTS on $(1) = $(2) ;
11453b9eae39SIngo Weinhold	SymLink1 $(1) ;
11469eea4522SIngo Weinhold	LocalDepends all : $(target) ;
11473b9eae39SIngo Weinhold}
11483b9eae39SIngo Weinhold
11493b9eae39SIngo Weinholdactions SymLink1
11503b9eae39SIngo Weinhold{
11510931b8f9SIngo Weinhold	$(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)"
11520931b8f9SIngo Weinhold}
11530931b8f9SIngo Weinhold
11540931b8f9SIngo Weinholdrule RelSymLink
11550931b8f9SIngo Weinhold{
11560931b8f9SIngo Weinhold	# RelSymLink <link> : <link target>
11570931b8f9SIngo Weinhold	# Creates a relative symbolic link from <link> to <link target>.
11580931b8f9SIngo Weinhold	# <link> and <link target> can be usual targets. They may have a grist
11590931b8f9SIngo Weinhold	# and don't need to have any dirname. Their LOCATE variables are used to
11600931b8f9SIngo Weinhold	# find their locations.
11610931b8f9SIngo Weinhold
11620931b8f9SIngo Weinhold	local target = $(1) ;
11630931b8f9SIngo Weinhold	local source = $(2) ;
11640931b8f9SIngo Weinhold	local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ;
11650931b8f9SIngo Weinhold	local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ;
11660931b8f9SIngo Weinhold	local sourcePath = $(source:G=) ;
11670931b8f9SIngo Weinhold	sourcePath = $(sourcePath:D=$(sourceDir)) ;
11680931b8f9SIngo Weinhold	local targetDirComponents = [ SplitPath $(targetDir) ] ;
11690931b8f9SIngo Weinhold	local sourceComponents = [ SplitPath $(sourcePath) ] ;
11700931b8f9SIngo Weinhold
11710931b8f9SIngo Weinhold	SymLink $(target)
11720931b8f9SIngo Weinhold		: [ FRelPath $(targetDirComponents) : $(sourceComponents) ] ;
11730931b8f9SIngo Weinhold	NOUPDATE $(target) ;
11749eea4522SIngo Weinhold	Depends $(target) : $(source) ;
11756991af8cSIngo Weinhold	LocalClean clean : $(target) ;
11763b9eae39SIngo Weinhold}
11773b9eae39SIngo Weinhold
1178d391d2ebSIngo Weinholdrule AbsSymLink
1179d391d2ebSIngo Weinhold{
11807bc56df1SIngo Weinhold	# AbsSymLink <link> : <link target> : <link dir>
1181d391d2ebSIngo Weinhold	# Creates an absolute symbolic link from <link> to <link target>.
1182d391d2ebSIngo Weinhold	# <link> and <link target> must be usual targets. If <link dir> is
1183d391d2ebSIngo Weinhold	# given, then it is set as LOCATE directory on <link>.
1184d391d2ebSIngo Weinhold
1185d391d2ebSIngo Weinhold	LocalDepends files : $(1) ;
1186d391d2ebSIngo Weinhold	Depends $(1) : $(2) ;
1187d391d2ebSIngo Weinhold	if $(3) {
1188d391d2ebSIngo Weinhold		MakeLocate $(1) : $(3) ;
1189d391d2ebSIngo Weinhold	}
1190d391d2ebSIngo Weinhold	SEARCH on $(2) += $(SEARCH_SOURCE) ;
1191d391d2ebSIngo Weinhold	LocalClean clean : $(1) ;
1192d391d2ebSIngo Weinhold}
1193d391d2ebSIngo Weinhold
1194d391d2ebSIngo Weinholdactions AbsSymLink
1195d391d2ebSIngo Weinhold{
1196d391d2ebSIngo Weinhold	target="$(2)"
1197d391d2ebSIngo Weinhold	case "$target" in
1198d391d2ebSIngo Weinhold		/*) ;;
1199d391d2ebSIngo Weinhold		*) target=`pwd`/"$target";;
1200d391d2ebSIngo Weinhold	esac
1201d391d2ebSIngo Weinhold	$(RM) "$(1)" && $(LN) -s "$target" "$(1)"
1202d391d2ebSIngo Weinhold}
1203d391d2ebSIngo Weinhold
12047bc56df1SIngo Weinholdrule OBOSInstall
12057bc56df1SIngo Weinhold{
12067bc56df1SIngo Weinhold	# Usage: OBOSInstall <[ install [ and uninstall ] pseudotarget ]>
12077bc56df1SIngo Weinhold	#					 : <directory> : <sources to install>
12087bc56df1SIngo Weinhold	#					 : [ <installgrist> ] : [ <install rule> ] ;
12097bc56df1SIngo Weinhold	local install = $(1[1]) ;
12107bc56df1SIngo Weinhold	install ?= install ;
12117bc56df1SIngo Weinhold	local uninstall = $(1[2]) ;
12127bc56df1SIngo Weinhold	uninstall ?= un$(install) ;
12137bc56df1SIngo Weinhold	local dir = $(2) ;
12147bc56df1SIngo Weinhold	local sources = $(3) ;
12157bc56df1SIngo Weinhold	local installgrist = $(4) ;
12167bc56df1SIngo Weinhold	installgrist ?= $(INSTALLGRIST) ;
12177bc56df1SIngo Weinhold	local installRule = $(5) ;
12187bc56df1SIngo Weinhold	installRule ?= Install ;
12197bc56df1SIngo Weinhold	local targets = $(sources:G=$(installgrist)) ;
12207bc56df1SIngo Weinhold
12217bc56df1SIngo Weinhold	Depends $(install) : $(targets) ;
12227bc56df1SIngo Weinhold	Clean $(uninstall) : $(targets) ;
12237bc56df1SIngo Weinhold
12247bc56df1SIngo Weinhold	SEARCH on $(sources) += $(SEARCH_SOURCE) ;
12257bc56df1SIngo Weinhold	MakeLocate $(targets) : $(dir) ;
12267bc56df1SIngo Weinhold
12277bc56df1SIngo Weinhold	local source ;
12287bc56df1SIngo Weinhold	for source in $(sources) {
12297bc56df1SIngo Weinhold		local target = $(source:G=$(installgrist)) ;
12307bc56df1SIngo Weinhold
12317bc56df1SIngo Weinhold		Depends $(target) : $(source) ;
12327bc56df1SIngo Weinhold		$(installRule) $(target) : $(source) ;
12337bc56df1SIngo Weinhold
12347bc56df1SIngo Weinhold		if [ on $(target) return $(MODE) ] {
12357bc56df1SIngo Weinhold			Chmod $(target) ;
12367bc56df1SIngo Weinhold		}
12377bc56df1SIngo Weinhold
12387bc56df1SIngo Weinhold		if $(OWNER) && $(CHOWN) {
12397bc56df1SIngo Weinhold			Chown $(target) ;
12407bc56df1SIngo Weinhold			OWNER on $(target) = $(OWNER) ;
12417bc56df1SIngo Weinhold		}
12427bc56df1SIngo Weinhold
12437bc56df1SIngo Weinhold		if $(GROUP) && $(CHGRP) {
12447bc56df1SIngo Weinhold			Chgrp $(target) ;
12457bc56df1SIngo Weinhold			GROUP on $(target) = $(GROUP) ;
12467bc56df1SIngo Weinhold		}
12477bc56df1SIngo Weinhold	}
12487bc56df1SIngo Weinhold}
12497bc56df1SIngo Weinhold
12507bc56df1SIngo Weinholdrule OBOSInstallAbsSymLink
12517bc56df1SIngo Weinhold{
12527bc56df1SIngo Weinhold	# Usage: OBOSInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]>
12537bc56df1SIngo Weinhold	#							   : <directory> : <sources to install>
12547bc56df1SIngo Weinhold	#							   : [ <installgrist> ] ;
12557bc56df1SIngo Weinhold	OBOSInstall $(1) : $(2) : $(3) : $(4) : AbsSymLink ;
12567bc56df1SIngo Weinhold}
12577bc56df1SIngo Weinhold
12587bc56df1SIngo Weinholdrule InstallRelSymLinkAdapter
12597bc56df1SIngo Weinhold{
12607bc56df1SIngo Weinhold	# InstallRelSymLinkAdapter <link> : <link target>
12617bc56df1SIngo Weinhold	if ! [ on $(2) return $(TARGET) ] {
12627bc56df1SIngo Weinhold		TARGET on $(2) = [ on $(2) return $(SEARCH) ] ;
12637bc56df1SIngo Weinhold	}
12647bc56df1SIngo Weinhold	RelSymLink $(1) : $(2) ;
12657bc56df1SIngo Weinhold}
12667bc56df1SIngo Weinhold
12677bc56df1SIngo Weinholdrule OBOSInstallRelSymLink
12687bc56df1SIngo Weinhold{
12697bc56df1SIngo Weinhold	# Usage: OBOSInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]>
12707bc56df1SIngo Weinhold	#							   : <directory> : <sources to install>
12717bc56df1SIngo Weinhold	#							   : [ <installgrist> ] ;
12727bc56df1SIngo Weinhold	OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ;
12737bc56df1SIngo Weinhold}
12747bc56df1SIngo Weinhold
12757bc56df1SIngo Weinhold
127652a38012Sejakowatz#-------------------------------------------------------------------------------
127752a38012Sejakowatz# Low-level OBOS utility rules
127852a38012Sejakowatz#-------------------------------------------------------------------------------
127952a38012Sejakowatzrule SetupObjectsDir
128052a38012Sejakowatz{
128152a38012Sejakowatz	local rel_objectsdir;
128252a38012Sejakowatz
128352a38012Sejakowatz	# Copy subdir tokens except the first, as that will be "sources", and we
128452a38012Sejakowatz	# do not want to include that :)
128552a38012Sejakowatz	rel_objectsdir = [ FDirName $(SUBDIR_TOKENS[2-]) ] ;
128652a38012Sejakowatz	LOCATE_TARGET = [ FDirName $(OBOS_OBJECT_TARGET) $(rel_objectsdir) ] ;
12878d3308d9SIngo Weinhold	LOCATE_SOURCE = $(LOCATE_TARGET) ;
12888d3308d9SIngo Weinhold	SEARCH_SOURCE = [ Filter $(SEARCH_SOURCE) : $(LOCATE_TARGET) ]
12898d3308d9SIngo Weinhold					$(LOCATE_TARGET) ;
129052a38012Sejakowatz}
129152a38012Sejakowatz
129252a38012Sejakowatz#-------------------------------------------------------------------------------
129352a38012Sejakowatz# Link rule/action are overwritten as they don't handle linking files who's name
129452a38012Sejakowatz# contain spaces very well. Also adds resources and version to executable.
129552a38012Sejakowatz#-------------------------------------------------------------------------------
129652a38012Sejakowatzrule Link
129752a38012Sejakowatz{
129852a38012Sejakowatz	# Note: RESFILES must be set before invocation.
129952a38012Sejakowatz	MODE on $(<) = $(EXEMODE) ;
130052a38012Sejakowatz	on $(1) XRes $(1) : $(RESFILES) ;
130152a38012Sejakowatz	Chmod $(<) ;
130252a38012Sejakowatz	SetType $(1) ;
130352a38012Sejakowatz	MimeSet $(1) ;
13041419ae2bSshatty	SetVersion $(1) ;
130552a38012Sejakowatz}
130652a38012Sejakowatz
130752a38012Sejakowatzactions Link bind NEEDLIBS
130852a38012Sejakowatz{
13091eb18edfSIngo Weinhold	$(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ;
131052a38012Sejakowatz}
131152a38012Sejakowatz
13128d3308d9SIngo Weinholdrule LexC++
13138d3308d9SIngo Weinhold{
13148d3308d9SIngo Weinhold	Depends $(1) : $(2) ;
13158d3308d9SIngo Weinhold	MakeLocate $(1) : $(LOCATE_SOURCE) ;
13168d3308d9SIngo Weinhold	LocalClean clean : $(1) ;
13178d3308d9SIngo Weinhold}
13188d3308d9SIngo Weinhold
13198d3308d9SIngo Weinholdactions LexC++
13208d3308d9SIngo Weinhold{
13218d3308d9SIngo Weinhold	$(LEX) -o$(1) $(2)
13228d3308d9SIngo Weinhold}
13238d3308d9SIngo Weinhold
13248d3308d9SIngo Weinholdrule Bison
13258d3308d9SIngo Weinhold{
13268d3308d9SIngo Weinhold	local _h ;
13278d3308d9SIngo Weinhold
13288d3308d9SIngo Weinhold	_h = $(1).h ;
13298d3308d9SIngo Weinhold
13308d3308d9SIngo Weinhold	MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ;
13318d3308d9SIngo Weinhold
13328d3308d9SIngo Weinhold    Depends $(<) $(_h) : $(>) ;
13338d3308d9SIngo Weinhold    Bison1 $(<) $(_h) : $(>) ;
13348d3308d9SIngo Weinhold    LocalClean clean : $(<) $(_h) ;
13358d3308d9SIngo Weinhold
13368d3308d9SIngo Weinhold	# make sure someone includes $(_h) else it will be
13378d3308d9SIngo Weinhold	# a deadly independent target
13388d3308d9SIngo Weinhold
13398d3308d9SIngo Weinhold	Includes $(<) : $(_h) ;
13408d3308d9SIngo Weinhold}
13418d3308d9SIngo Weinhold
13428d3308d9SIngo Weinholdactions Bison1
13438d3308d9SIngo Weinhold{
13448d3308d9SIngo Weinhold	bison $(YACCFLAGS) -o $(1[1]) $(2)
13458d3308d9SIngo Weinhold}
13468d3308d9SIngo Weinhold
134752a38012Sejakowatz# BeOS specific rules
134852a38012Sejakowatz
134952a38012Sejakowatzrule XRes
135052a38012Sejakowatz{
135152a38012Sejakowatz	# XRes <target> : <resource files>
135252a38012Sejakowatz	if $(2)
135352a38012Sejakowatz	{
13549eea4522SIngo Weinhold		Depends $(1) : $(2) ;
135552a38012Sejakowatz		XRes1 $(1) : $(2) ;
135652a38012Sejakowatz	}
135752a38012Sejakowatz}
135852a38012Sejakowatz
135952a38012Sejakowatzrule XRes1 { }
136052a38012Sejakowatz
136152a38012Sejakowatzrule SetVersion
136252a38012Sejakowatz{
136352a38012Sejakowatz	# SetVersion <target>
136452a38012Sejakowatz}
136552a38012Sejakowatz
136652a38012Sejakowatzrule SetType
136752a38012Sejakowatz{
136852a38012Sejakowatz	# SetType <target>
136952a38012Sejakowatz}
137052a38012Sejakowatz
137152a38012Sejakowatzrule MimeSet
137252a38012Sejakowatz{
137352a38012Sejakowatz	# SetType <target>
137452a38012Sejakowatz}
137552a38012Sejakowatz
137652a38012Sejakowatz
137752a38012Sejakowatzif $(OS) = BEOS
137852a38012Sejakowatz{
137952a38012Sejakowatz
138052a38012Sejakowatzactions XRes1
138152a38012Sejakowatz{
13820931b8f9SIngo Weinhold	xres -o "$(1)" "$(2)" ;
138352a38012Sejakowatz}
138452a38012Sejakowatz
138552a38012Sejakowatzactions SetVersion
138652a38012Sejakowatz{
138752a38012Sejakowatz	setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ;
138852a38012Sejakowatz}
138952a38012Sejakowatz
139052a38012Sejakowatzactions SetType
139152a38012Sejakowatz{
139252a38012Sejakowatz	settype -t $(OBOS_TARGET_TYPE) "$(1)" ;
139352a38012Sejakowatz}
139452a38012Sejakowatz
139552a38012Sejakowatzactions MimeSet
139652a38012Sejakowatz{
139752a38012Sejakowatz	mimeset -f "$(1)" ;
139852a38012Sejakowatz}
139952a38012Sejakowatz
140052a38012Sejakowatz}	# if BEOS
140152a38012Sejakowatz
140252a38012Sejakowatz
140352a38012Sejakowatzrule assemble
140452a38012Sejakowatz{
140594782cf7SIngo Weinhold	Depends $(<) : $(>) ;
140694782cf7SIngo Weinhold	ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ;
140794782cf7SIngo Weinhold	ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ;
140852a38012Sejakowatz}
140952a38012Sejakowatz
141052a38012Sejakowatzactions assemble
141152a38012Sejakowatz{
1412a8687de4SAxel Dörfler	$(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ;
141352a38012Sejakowatz}
141452a38012Sejakowatz
14150931b8f9SIngo Weinhold# Overridden to allow spaces in file names.
14160931b8f9SIngo Weinholdactions Chmod1
14170931b8f9SIngo Weinhold{
14180931b8f9SIngo Weinhold	$(CHMOD) "$(MODE)" "$(1)"
14190931b8f9SIngo Weinhold}
14200931b8f9SIngo Weinhold
14216991af8cSIngo Weinhold# Overridden to allow spaces in file names.
14226991af8cSIngo Weinholdactions piecemeal together existing Clean
14236991af8cSIngo Weinhold{
14246991af8cSIngo Weinhold	$(RM) "$(>)"
14256991af8cSIngo Weinhold}
14266991af8cSIngo Weinhold
142708125d07SIngo Weinholdrule ObjectReference
142808125d07SIngo Weinhold{
142908125d07SIngo Weinhold	# ObjectReference <reference object> : <source object>
143008125d07SIngo Weinhold	# Makes <reference object> refer to the same file as <source object>.
143108125d07SIngo Weinhold	# The filenames must of course be identical.
143208125d07SIngo Weinhold	# <source object> must have already been LOCATEd.
143308125d07SIngo Weinhold
143408125d07SIngo Weinhold	local ref = $(1) ;
143508125d07SIngo Weinhold	local source = $(2) ;
143608125d07SIngo Weinhold	if $(ref) != $(source) {
14379eea4522SIngo Weinhold		Depends $(ref) : $(source) ;
143821df5945SIngo Weinhold		LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ;
143908125d07SIngo Weinhold	}
144008125d07SIngo Weinhold}
144108125d07SIngo Weinhold
144208125d07SIngo Weinholdrule ObjectReferences
144308125d07SIngo Weinhold{
144408125d07SIngo Weinhold	# ObjectReferences <source objects>
144508125d07SIngo Weinhold	# Creates local references to <source objects>, i.e. identifiers with the
144608125d07SIngo Weinhold	# current grist referring to the same files. <source objects> must have
144708125d07SIngo Weinhold	# already been LOCATEd.
144808125d07SIngo Weinhold
144908125d07SIngo Weinhold	local source ;
145008125d07SIngo Weinhold	for source in $(1) {
145108125d07SIngo Weinhold		ObjectReference [ FGristFiles $(source) ] : $(source) ;
145208125d07SIngo Weinhold	}
145308125d07SIngo Weinhold}
145408125d07SIngo Weinhold
14559fc6b2e1SIngo Weinholdrule Filter
14569fc6b2e1SIngo Weinhold{
14579fc6b2e1SIngo Weinhold	# Filter <list> : <excludes> ;
14589fc6b2e1SIngo Weinhold	# Removes all occurrences of <excludes> in <list>.
14599fc6b2e1SIngo Weinhold
14609fc6b2e1SIngo Weinhold	local list = $(1) ;
14619fc6b2e1SIngo Weinhold	local excludes = $(2) ;
14629fc6b2e1SIngo Weinhold	local newList ;
14639fc6b2e1SIngo Weinhold	local item ;
14649fc6b2e1SIngo Weinhold	for item in $(list) {
14659fc6b2e1SIngo Weinhold		local skip ;
14669fc6b2e1SIngo Weinhold		local exclude ;
14679fc6b2e1SIngo Weinhold		for exclude in $(excludes) {
14689fc6b2e1SIngo Weinhold			if $(item) = $(exclude) {
14699fc6b2e1SIngo Weinhold				skip = true ;
14709fc6b2e1SIngo Weinhold			}
14719fc6b2e1SIngo Weinhold		}
14729fc6b2e1SIngo Weinhold		if ! $(skip) {
1473dd9f8062SIngo Weinhold			newList += $(item) ;
14749fc6b2e1SIngo Weinhold		}
14759fc6b2e1SIngo Weinhold	}
14769fc6b2e1SIngo Weinhold	return $(newList) ;
14779fc6b2e1SIngo Weinhold}
14789fc6b2e1SIngo Weinhold
14790931b8f9SIngo Weinhold
148052a38012Sejakowatz## Kernel stuff!
148152a38012Sejakowatz
148252a38012Sejakowatzrule SetupKernel
148352a38012Sejakowatz{
148452a38012Sejakowatz	# Usage SetupKernel <sources_or_objects> : <extra_cc_flags>;
148552a38012Sejakowatz
14862dd47f63SIngo Weinhold	local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ;
148752a38012Sejakowatz
148828d2a30eSDaniel Reinhold	#Setup Kernel header directories
1489089a0629Sbeveloper	local public_kernel_includes = add-ons/file_system add-ons/graphics device drivers kernel storage support ;
1490089a0629Sbeveloper	local private_kernel_includes = kernel libroot ;
1491a6c008e1Sbeveloper	# Use posix headers directory
149228d2a30eSDaniel Reinhold	HDRS = [ FDirName $(OBOS_TOP) headers posix ] ;
1493a6c008e1Sbeveloper	# Use public OS header directories
1494089a0629Sbeveloper	HDRS += [ PublicHeaders $(public_kernel_includes) ] ;
1495089a0629Sbeveloper	# Use private directories
1496089a0629Sbeveloper	HDRS += [ PrivateHeaders $(private_kernel_includes) ] ;
149709c5682dSIngo Weinhold	# The platform dependent headers.
149809c5682dSIngo Weinhold	HDRS += $(PLATFORM_HEADERS) ;
1499a6c008e1Sbeveloper
150052a38012Sejakowatz	UseArchHeaders $(OBOS_ARCH) ;
150152a38012Sejakowatz
150252a38012Sejakowatz	SetupObjectsDir ;
150352a38012Sejakowatz
150452a38012Sejakowatz	CCFLAGS on $(_objs) = $(KERNEL_CCFLAGS) $(2) ;
150598cc804cSAxel Dörfler	C++FLAGS on $(_objs) = $(KERNEL_C++FLAGS) $(2) ;
150652a38012Sejakowatz}
150752a38012Sejakowatz
150852a38012Sejakowatzrule KernelObjects
150952a38012Sejakowatz{
151052a38012Sejakowatz	SetupKernel $(1) : $(2) ;
151152a38012Sejakowatz
151252a38012Sejakowatz	Objects $(1) ;
151352a38012Sejakowatz}
151452a38012Sejakowatz
151552a38012Sejakowatzrule KernelLd
151652a38012Sejakowatz{
151780721244SAxel Dörfler	# KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> : <config_section> ;
151852a38012Sejakowatz
151952a38012Sejakowatz	SetupKernel $(2) ;
152052a38012Sejakowatz	LINK on $(1) = ld ;
152152a38012Sejakowatz
152252a38012Sejakowatz	LINKFLAGS on $(1) = $(4) ;
152352a38012Sejakowatz	if $(3) { LINKFLAGS on $(1) += --script=$(3) ; }
152452a38012Sejakowatz
152552a38012Sejakowatz	# Remove any preset LINKLIBS
152652a38012Sejakowatz	LINKLIBS on $(1) =  ;
152752a38012Sejakowatz
152852a38012Sejakowatz	# Show that we depend on the libraries we need
15299eea4522SIngo Weinhold	LocalClean clean : $(1) ;
15309eea4522SIngo Weinhold	LocalDepends all : $(1) ;
153152a38012Sejakowatz	Depends $(1) : $(2) ;
153252a38012Sejakowatz
153352a38012Sejakowatz	if $(6) {
153452a38012Sejakowatz		for i in $(6) {
15352a83bfb4SIngo Weinhold			KernelConfigSection $(i) : elf32 : $(1) ;
153652a38012Sejakowatz		}
153752a38012Sejakowatz	}
153852a38012Sejakowatz
153952a38012Sejakowatz	MakeLocate $(1) : $(LOCATE_TARGET) ;
154052a38012Sejakowatz
154109c5682dSIngo Weinhold	# Add the platform specific static libs (libgcc.a).
154252a38012Sejakowatz	if ! $(5) {
154309c5682dSIngo Weinhold		LINKLIBS on $(1) += $(PLATFORM_LINKLIBS) ;
154452a38012Sejakowatz	}
154552a38012Sejakowatz}
154652a38012Sejakowatz
154752a38012Sejakowatzactions KernelLd
154852a38012Sejakowatz{
15491eb18edfSIngo Weinhold	$(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ;
155052a38012Sejakowatz}
155152a38012Sejakowatz
155280721244SAxel Dörflerrule KernelMergeObject
155380721244SAxel Dörfler{
155480721244SAxel Dörfler	# KernelMergeObject <name> : <sources> : <extra CFLAGS> ;
155580721244SAxel Dörfler
155680721244SAxel Dörfler	SetupKernel $(2) : $(3) ;
155780721244SAxel Dörfler
155880721244SAxel Dörfler	MakeLocateObjects $(2) ;
155980721244SAxel Dörfler	Objects $(2) ;
156080721244SAxel Dörfler	MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) ;
156180721244SAxel Dörfler}
156280721244SAxel Dörfler
156352a38012Sejakowatzrule KernelStaticLibrary
156452a38012Sejakowatz{
156552a38012Sejakowatz	# Usage KernelStaticLibrary <name> : <sources> : <extra cc flags>  ;
156652a38012Sejakowatz	# This is designed to take a set of sources and libraries and create
156752a38012Sejakowatz	# a file called lib<name>.a
156852a38012Sejakowatz
156952a38012Sejakowatz	SetupKernel $(2) : $(3) ;
157052a38012Sejakowatz
157152a38012Sejakowatz	MakeLocateObjects $(2) ;
157252a38012Sejakowatz	Library $(1) : $(2) ;
157352a38012Sejakowatz}
157452a38012Sejakowatz
157552a38012Sejakowatzrule KernelStaticLibraryObjects
157652a38012Sejakowatz{
157752a38012Sejakowatz	# Usage KernelStaticLibrary <name> : <sources> ;
157852a38012Sejakowatz	# This is designed to take a set of sources and libraries and create
157952a38012Sejakowatz	# a file called <name>
158052a38012Sejakowatz
158152a38012Sejakowatz	SetupKernel $(2) ;
158252a38012Sejakowatz
158352a38012Sejakowatz	# Show that we depend on the libraries we need
15849eea4522SIngo Weinhold	LocalClean clean : $(1) ;
15859eea4522SIngo Weinhold	LocalDepends all : $(1) ;
158652a38012Sejakowatz	Depends $(1) : $(2) ;
158752a38012Sejakowatz
158852a38012Sejakowatz	MakeLocate $(1) : $(LOCATE_TARGET) ;
158952a38012Sejakowatz}
159052a38012Sejakowatz
159152a38012Sejakowatzactions KernelStaticLibraryObjects
159252a38012Sejakowatz{
15930931b8f9SIngo Weinhold	ar -r "$(1)" "$(2)" ;
159452a38012Sejakowatz}
159552a38012Sejakowatz
15965dc4e1efSIngo Weinholdrule BuildPlatformMain
159752a38012Sejakowatz{
15985dc4e1efSIngo Weinhold	# Usage BuildPlatformMain <target> : <sources> ;
159952a38012Sejakowatz	SetupObjectsDir ;
16005dc4e1efSIngo Weinhold	SetupDefaultIncludes ;
160152a38012Sejakowatz
16025dc4e1efSIngo Weinhold	# Remove `-nostdinc' from CCFLAGS and C++FLAGS.
16035dc4e1efSIngo Weinhold	local oldCCFLAGS = $(CCFLAGS) ;
16045dc4e1efSIngo Weinhold	local oldC++FLAGS = $(C++FLAGS) ;
16055dc4e1efSIngo Weinhold	CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ;
16065dc4e1efSIngo Weinhold	C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ;
160752a38012Sejakowatz
160852a38012Sejakowatz	Main $(1) : $(2) ;
16095dc4e1efSIngo Weinhold
16105dc4e1efSIngo Weinhold	# Reset CCFLAGS and C++FLAGS to original values.
16115dc4e1efSIngo Weinhold	CCFLAGS = $(oldCCFLAGS) ;
16125dc4e1efSIngo Weinhold	C++FLAGS = $(oldC++FLAGS) ;
161352a38012Sejakowatz}
161452a38012Sejakowatz
1615*9fcaa61dSIngo Weinholdrule BuildPlatformTest
1616*9fcaa61dSIngo Weinhold{
1617*9fcaa61dSIngo Weinhold	# Usage BuildPlatformTest <target> : <sources> ;
1618*9fcaa61dSIngo Weinhold
1619*9fcaa61dSIngo Weinhold	local target = $(1) ;
1620*9fcaa61dSIngo Weinhold	local sources = $(2) ;
1621*9fcaa61dSIngo Weinhold
1622*9fcaa61dSIngo Weinhold	BuildPlatformMain $(target) : $(sources) ;
1623*9fcaa61dSIngo Weinhold	local relPath ;
1624*9fcaa61dSIngo Weinhold	if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] {
1625*9fcaa61dSIngo Weinhold		relPath = $(SUBDIR_TOKENS[3-]) ;
1626*9fcaa61dSIngo Weinhold	} else {
1627*9fcaa61dSIngo Weinhold		relPath = $(SUBDIR_TOKENS[2-]) ;
1628*9fcaa61dSIngo Weinhold	}
1629*9fcaa61dSIngo Weinhold	MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ;
1630*9fcaa61dSIngo Weinhold}
1631*9fcaa61dSIngo Weinhold
163252a38012Sejakowatzrule KernelConfigSection
163352a38012Sejakowatz{
163452a38012Sejakowatz	# KernelConfigSection <section> : <type> : <file>  ;
16352a83bfb4SIngo Weinhold
16362a83bfb4SIngo Weinhold	SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ;
16372a83bfb4SIngo Weinhold	SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ;
16382a83bfb4SIngo Weinhold	SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ;
16392a83bfb4SIngo Weinhold
16402a83bfb4SIngo Weinhold	Depends $(OBOS_KERNEL_CONFIG) : $(3) ;
164152a38012Sejakowatz}
164252a38012Sejakowatz
164352a38012Sejakowatzrule WriteKernelConfig
164452a38012Sejakowatz{
164552a38012Sejakowatz	# usage: WriteKernelConfig <target> ;
164652a38012Sejakowatz
16479eea4522SIngo Weinhold	LocalDepends files : $(1) ;
164852a38012Sejakowatz
16492a83bfb4SIngo Weinhold	MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ;
165052a38012Sejakowatz
16519eea4522SIngo Weinhold	LocalClean clean : $(1) ;
165252a38012Sejakowatz}
165352a38012Sejakowatz
16542a83bfb4SIngo Weinholdactions WriteKernelConfig bind SECTION_FILES
165552a38012Sejakowatz{
16560931b8f9SIngo Weinhold	target="$(1)"
16570931b8f9SIngo Weinhold	echo "# OpenBeOS Kernel Config File" > "$target"
16580931b8f9SIngo Weinhold	echo "# Automatically generated - do not edit!" >> "$target"
16592a83bfb4SIngo Weinhold	count=0
16602a83bfb4SIngo Weinhold	for section in "$(SECTION_NAMES)" ; do
16612a83bfb4SIngo Weinhold		count=`expr $count + 1`
16622a83bfb4SIngo Weinhold		eval section$count="$section"
16632a83bfb4SIngo Weinhold	done
16642a83bfb4SIngo Weinhold	i=1
16652a83bfb4SIngo Weinhold	for type in "$(SECTION_TYPES)" ; do
16662a83bfb4SIngo Weinhold		eval type$i="$type"
16672a83bfb4SIngo Weinhold		i=`expr $i + 1`
16682a83bfb4SIngo Weinhold	done
16692a83bfb4SIngo Weinhold	i=1
16702a83bfb4SIngo Weinhold	for file in "$(SECTION_FILES)" ; do
16712a83bfb4SIngo Weinhold		eval file$i="$file"
16722a83bfb4SIngo Weinhold		i=`expr $i + 1`
16732a83bfb4SIngo Weinhold	done
16742a83bfb4SIngo Weinhold	for i in `seq $count` ; do
16752a83bfb4SIngo Weinhold		eval section="\$section$i"
16762a83bfb4SIngo Weinhold		eval type="\$type$i"
16772a83bfb4SIngo Weinhold		eval file="\$file$i"
16780931b8f9SIngo Weinhold		echo "" >> "$target"
16792a83bfb4SIngo Weinhold		echo "["$section"]" >> "$target"
16802a83bfb4SIngo Weinhold		echo "type="$type >> "$target"
16810931b8f9SIngo Weinhold		case "$file" in
168252a38012Sejakowatz			/*) ;;
16830931b8f9SIngo Weinhold			*) file=`pwd`/"$file";;
168452a38012Sejakowatz		esac
16852a83bfb4SIngo Weinhold		echo "file="$file >> "$target"
168652a38012Sejakowatz	done
168752a38012Sejakowatz}
168852a38012Sejakowatz
168952a38012Sejakowatzrule BuildKernel
169052a38012Sejakowatz{
169152a38012Sejakowatz	# Usage BuildKernel <target> : <config_file> ;
16920c0b2cd0SIngo Weinhold	local kernel = $(1) ;
16930c0b2cd0SIngo Weinhold	local configFile = $(2) ;
16940c0b2cd0SIngo Weinhold	local bootmaker = bootmaker ;
169552a38012Sejakowatz
16969eea4522SIngo Weinhold	LocalDepends all : $(kernel) ;
16970c0b2cd0SIngo Weinhold	Depends $(kernel) : $(configFile) $(bootmaker) ;
16989eea4522SIngo Weinhold	LocalClean clean : $(kernel) ;
16990c0b2cd0SIngo Weinhold	MakeLocate $(kernel) : $(LOCATE_TARGET) ;
170052a38012Sejakowatz
17010c0b2cd0SIngo Weinhold	BOOT_MAKER on $(kernel) = $(bootmaker) ;
170252a38012Sejakowatz}
170352a38012Sejakowatz
17040c0b2cd0SIngo Weinholdactions BuildKernel bind BOOT_MAKER
170552a38012Sejakowatz{
17060c0b2cd0SIngo Weinhold	"$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ;
170752a38012Sejakowatz	echo ""
170852a38012Sejakowatz	echo "Kernel linked!"
170952a38012Sejakowatz	echo ""
171052a38012Sejakowatz}
171152a38012Sejakowatz
171252a38012Sejakowatzrule KernelFloppyImage
171352a38012Sejakowatz{
171452a38012Sejakowatz	# Usage KernelFloppyImage <target> : <kernel> : <bootblock> ;
17150c0b2cd0SIngo Weinhold	local floppy = $(1) ;
17160c0b2cd0SIngo Weinhold	local kernel = $(2) ;
17170c0b2cd0SIngo Weinhold	local bootblock = $(3) ;
17180c0b2cd0SIngo Weinhold	local makeflop = makeflop ;
171952a38012Sejakowatz
17209eea4522SIngo Weinhold	LocalDepends all : $(floppy) ;
17210c0b2cd0SIngo Weinhold	Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ;
17229eea4522SIngo Weinhold	LocalClean clean : $(floppy) ;
17230c0b2cd0SIngo Weinhold	MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ;
172452a38012Sejakowatz
17250c0b2cd0SIngo Weinhold	BOOT_BLOCK on $(floppy) = $(bootblock) ;
17260c0b2cd0SIngo Weinhold	MAKE_FLOP on $(floppy) = $(makeflop) ;
172752a38012Sejakowatz}
172852a38012Sejakowatz
172952a38012Sejakowatz# This may be a bit verbose, but I think it's useful to show what's
173052a38012Sejakowatz# going on, at least in this early stage of development.
17310c0b2cd0SIngo Weinholdactions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP
173252a38012Sejakowatz{
17337378dd7fSAxel Dörfler	"$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ;
17340c0b2cd0SIngo Weinhold
173552a38012Sejakowatz	echo ""
173652a38012Sejakowatz	echo "*************************************************"
173752a38012Sejakowatz	echo "*         Kernel build completed!               *"
173852a38012Sejakowatz	echo "*    Boot image for a 1.44M floppy created      *"
173952a38012Sejakowatz	echo "*************************************************"
174052a38012Sejakowatz	echo ""
17410c0b2cd0SIngo Weinhold	echo "Floppy image is $(1)"
174252a38012Sejakowatz	echo "The following command will write it to a floppy on BeOS"
17430c0b2cd0SIngo Weinhold	echo "  dd if=$(1) of=/dev/disk/floppy/raw bs=18k"
17440c0b2cd0SIngo Weinhold	echo "Alternatively you can run"
17450c0b2cd0SIngo Weinhold	echo "  ./configure --floppy /dev/disk/floppy/raw"
17460c0b2cd0SIngo Weinhold	echo "once and build + write the image subsequently via"
17470c0b2cd0SIngo Weinhold	echo "  jam installfloppy"
174852a38012Sejakowatz	echo ""
174952a38012Sejakowatz}
175052a38012Sejakowatz
17510c0b2cd0SIngo Weinholdrule InstallFloppy
17520c0b2cd0SIngo Weinhold{
17530c0b2cd0SIngo Weinhold	# InstallFloppy <target> : <floppy>
17540c0b2cd0SIngo Weinhold	# "dd"s <floppy> to $(FLOPPY_PATH).
17550c0b2cd0SIngo Weinhold
17560c0b2cd0SIngo Weinhold	local target = $(1) ;
17570c0b2cd0SIngo Weinhold	local floppy = $(2) ;
17580c0b2cd0SIngo Weinhold
17590c0b2cd0SIngo Weinhold	NotFile $(target) ;
17600c0b2cd0SIngo Weinhold	Always $(target) ;
17610c0b2cd0SIngo Weinhold	Depends $(target) : $(floppy) ;
17620c0b2cd0SIngo Weinhold}
17630c0b2cd0SIngo Weinhold
17640c0b2cd0SIngo Weinholdactions InstallFloppy
17650c0b2cd0SIngo Weinhold{
17660c0b2cd0SIngo Weinhold	if [ -z $(FLOPPY_PATH) ] ; then
17670c0b2cd0SIngo Weinhold		echo "Can't install floppy: FLOPPY_PATH not set."
17680c0b2cd0SIngo Weinhold		echo "run: ./configure --floppy <floppy path>"
17690c0b2cd0SIngo Weinhold		echo
17700c0b2cd0SIngo Weinhold		exit 0
17710c0b2cd0SIngo Weinhold	fi
17720c0b2cd0SIngo Weinhold	dd if=$(2) of=$(FLOPPY_PATH) bs=18k
17730c0b2cd0SIngo Weinhold}
177452a38012Sejakowatz
177521df5945SIngo Weinhold#-------------------------------------------------------------------------------
177621df5945SIngo Weinhold# FreeType 2 specific rules and variables
177721df5945SIngo Weinhold#-------------------------------------------------------------------------------
177821df5945SIngo Weinhold
177921df5945SIngo WeinholdFT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ;
178021df5945SIngo WeinholdFT2_SRC     = [ FDirName $(OBOS_TOP) src libs freetype2 ] ;
178121df5945SIngo Weinhold
178221df5945SIngo WeinholdFT2_LIB     = freetype ;
178321df5945SIngo Weinhold
1784fbd28219SIngo WeinholdFT2_COMPONENTS ?= gzip       # support for gzip-compressed files.
1785fbd28219SIngo Weinhold                  autohint   # auto-hinter
1786fbd28219SIngo Weinhold                  base       # base component (public APIs)
1787fbd28219SIngo Weinhold                  bdf        # BDF font driver
1788fbd28219SIngo Weinhold                  cache      # cache sub-system
1789fbd28219SIngo Weinhold                  cff        # CFF/CEF font driver
1790fbd28219SIngo Weinhold                  cid        # Postscript CID-keyed font driver
1791fbd28219SIngo Weinhold                  pcf        # PCF font driver
1792fbd28219SIngo Weinhold                  pfr        # PFR/TrueDoc font driver
1793fbd28219SIngo Weinhold                  psaux      # Common Postscript routines module
1794fbd28219SIngo Weinhold                  pshinter   # Postscript hinter module
1795fbd28219SIngo Weinhold                  psnames    # Postscript names handling
1796fbd28219SIngo Weinhold                  raster     # Monochrome rasterizer
1797fbd28219SIngo Weinhold                  smooth     # Anti-aliased rasterizer
1798fbd28219SIngo Weinhold                  sfnt       # SFNT-based format support routines
1799fbd28219SIngo Weinhold                  truetype   # TrueType font driver
1800fbd28219SIngo Weinhold                  type1      # Postscript Type 1 font driver
1801fbd28219SIngo Weinhold                  type42     # Postscript Type 42 (embedded TrueType) driver
1802fbd28219SIngo Weinhold                  winfonts   # Windows FON/FNT font driver
1803fbd28219SIngo Weinhold                  ;
1804fbd28219SIngo Weinhold
180521df5945SIngo Weinholdrule UseFreeTypeHeaders
180621df5945SIngo Weinhold{
180721df5945SIngo Weinhold	SubDirHdrs $(FT2_INCLUDE) ;
180821df5945SIngo Weinhold}
180921df5945SIngo Weinhold
181021df5945SIngo Weinholdrule UseFreeTypeObjectHeaders
181121df5945SIngo Weinhold{
18129b60a208SIngo Weinhold	# UseFreeTypeObjectHeaders <sources> [ : <objects> ] ;
18139b60a208SIngo Weinhold	SourceHdrs $(1) : $(FT2_INCLUDE) : $(2) ;
181421df5945SIngo Weinhold}
181521df5945SIngo Weinhold
181621df5945SIngo Weinholdrule FT2_SubDir
181721df5945SIngo Weinhold{
181821df5945SIngo Weinhold	# FT2_SubDir <dir>
181921df5945SIngo Weinhold	# <dir>: Components of a directory in the original hierarchy.
182021df5945SIngo Weinhold	local dir = $(1) ;
182121df5945SIngo Weinhold	local topDir ;
182221df5945SIngo Weinhold	switch $(dir[1])
182321df5945SIngo Weinhold	{
182421df5945SIngo Weinhold		case "include"	: topDir = $(FT2_INCLUDE) ;
182521df5945SIngo Weinhold		case src		: topDir = $(FT2_SRC) ;
182621df5945SIngo Weinhold		case *			: ECHO "Unknown FreeType2 directory: " $(dir) ;
182721df5945SIngo Weinhold	}
182821df5945SIngo Weinhold	return [ FDirName $(topDir) $(dir[2-]) ] ;
182921df5945SIngo Weinhold}
183021df5945SIngo Weinhold
183121df5945SIngo Weinholdrule FT2_Library
183221df5945SIngo Weinhold{
183321df5945SIngo Weinhold	# FT2_Library <libname> : <sources>
183421df5945SIngo Weinhold	# Builds objects from sources and adds the objects to the list of objects
183521df5945SIngo Weinhold	# to be linked into the library.
183621df5945SIngo Weinhold	# <libname> The name of the library.
183721df5945SIngo Weinhold	# <sources> The sources.
183821df5945SIngo Weinhold
183921df5945SIngo Weinhold	local library = lib$(1).so ;
184021df5945SIngo Weinhold	local sources = $(2) ;
184128d2a30eSDaniel Reinhold	SetupIncludes ;
184221df5945SIngo Weinhold	SetupObjectsDir ;
184321df5945SIngo Weinhold	MakeLocateObjects $(sources) ;
184421df5945SIngo Weinhold	Objects $(sources) ;
184521df5945SIngo Weinhold	LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ;
184621df5945SIngo Weinhold}
184721df5945SIngo Weinhold
184821df5945SIngo Weinholdrule FT2_LinkLibrary
184921df5945SIngo Weinhold{
185021df5945SIngo Weinhold	# FT2_LinkLibrary <libname>
185121df5945SIngo Weinhold	# Links the library from the objects build with FT2_LIBRARY before.
185221df5945SIngo Weinhold
185321df5945SIngo Weinhold	local library = lib$(1).so ;
185421df5945SIngo Weinhold	local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ;
185521df5945SIngo Weinhold	ObjectReferences $(objects) ;
185621df5945SIngo Weinhold	objects = [ FGristFiles $(objects) ] ;
185721df5945SIngo Weinhold	SharedLibraryFromObjects $(1) : $(objects) ;
185821df5945SIngo Weinhold}
185921df5945SIngo Weinhold
1860