xref: /haiku/build/jam/OverriddenJamRules (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1#-------------------------------------------------------------------------------
2# Link rule/action are overwritten as they don't handle linking files who's name
3# contain spaces very well. Also adds resources and version to executable.
4#-------------------------------------------------------------------------------
5rule Link
6{
7	# Note: RESFILES must be set before invocation.
8
9	if [ on $(1) return $(PLATFORM) ] = host {
10		LINK on $(1) = $(HOST_LINK) ;
11	 	LINKFLAGS on $(1) = $(HOST_LINKFLAGS) [ on $(1) return $(LINKFLAGS) ] ;
12	} else {
13		LINK on $(1) = $(TARGET_LINK_$(TARGET_PACKAGING_ARCH)) ;
14	 	LINKFLAGS on $(1) = $(TARGET_LINKFLAGS_$(TARGET_PACKAGING_ARCH))
15			[ on $(1) return $(LINKFLAGS) ] ;
16	}
17
18	HAIKU_TARGET_IS_EXECUTABLE on $(1) = 1 ;
19
20 	NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] ;
21 	LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] ;
22
23	MODE on $(<) = $(EXEMODE) ;
24	on $(1) XRes $(1) : $(RESFILES) ;
25	if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] {
26		SetType $(1) ;
27		MimeSet $(1) : sharedObject ;
28		SetVersion $(1) ;
29
30		# For applications for the target also generate the MIME DB entries.
31		if [ on $(1) return $(PLATFORM) ] != host
32			&& [ on $(1) return $(RESFILES) ] {
33			CreateAppMimeDBEntries $(1) ;
34		}
35
36		# If the generic attribute emulation is enabled, make sure the tool to
37		# remove the attributes is built first.
38		if $(HOST_RM_ATTRS_TARGET) {
39			Depends $(1) : $(HOST_RM_ATTRS_TARGET) ;
40		}
41	}
42	Chmod $(<) ;
43}
44
45# When using "real" attributes (i.e. BeOS attributes or xattr/extattr) on the
46# host platform, unlinking the main target by gcc will also automatically get
47# rid of the attributes. When using the generic attribute emulation, which
48# uses separate files, we need to remove the target explicitely first, so that
49# the attributes won't be "leaked".
50if $(HAIKU_HOST_USE_XATTR) = 1 {
51	actions Link bind NEEDLIBS LINK_BEGIN_GLUE LINK_END_GLUE VERSION_SCRIPT
52	{
53		$(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(LINK_BEGIN_GLUE)" "$(2)" \
54			"$(NEEDLIBS)" $(LINKLIBS) "$(LINK_END_GLUE)" \
55			-Wl,--version-script,$(VERSION_SCRIPT)
56	}
57} else {
58	actions Link bind NEEDLIBS LINK_BEGIN_GLUE LINK_END_GLUE VERSION_SCRIPT
59	{
60		$(RM) "$(1)"
61		$(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(LINK_BEGIN_GLUE)" "$(2)" \
62			"$(NEEDLIBS)" $(LINKLIBS) "$(LINK_END_GLUE)" \
63			-Wl,--version-script,$(VERSION_SCRIPT)
64	}
65}
66
67rule Object
68{
69	# find out which headers and defines to use
70	local headers ;
71	local sysHeaders ;
72	local defines ;
73
74	on $(1) { # use on $(1) variable values
75		if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) {
76			return ;
77		}
78
79		# Save HDRS for -I$(HDRS) on compile.
80		# We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers
81		# in the .c file's directory, but generated .c files (from
82		# yacc, lex, etc) are located in $(LOCATE_TARGET), possibly
83		# different from $(SEARCH_SOURCE).
84
85		headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS)
86			$(HDRS) ;
87		sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ;
88		defines = $(DEFINES) ;
89
90		if $(PLATFORM) = host {
91			sysHeaders += $(HOST_HDRS) ;
92			defines += $(HOST_DEFINES) ;
93
94			if $(USES_BE_API) {
95				sysHeaders += $(HOST_BE_API_HEADERS) ;
96			}
97
98		} else {
99			sysHeaders += [ FStandardHeaders $(TARGET_PACKAGING_ARCH) ]
100				$(TARGET_HDRS_$(TARGET_PACKAGING_ARCH)) ;
101			defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH))
102				$(TARGET_DEFINES) ;
103		}
104	}
105
106	# locate object and search for source
107
108	LocalClean clean : $(<) ;
109
110	MakeLocateDebug $(<) ;
111	SEARCH on $(>) = $(SEARCH_SOURCE) ;
112
113	HDRS on $(<) = $(headers) ;
114	SYSHDRS on $(<) = $(sysHeaders) ;
115
116	# handle #includes for source: Jam scans for headers with
117	# the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
118	# with the scanned file as the target and the found headers
119	# as the sources. HDRSEARCH is the value of SEARCH used for
120	# the found header files. Finally, if jam must deal with
121	# header files of the same name in different directories,
122	# they can be distinguished with HDRGRIST.
123
124	# $(SEARCH_SOURCE:E) is where cc first looks for #include
125	# "foo.h" files. If the source file is in a distant directory,
126	# look there. Else, look in "" (the current directory).
127
128	HDRRULE on $(>) = HdrRule ;
129	HDRSCAN on $(>) = $(HDRPATTERN) ;
130	HDRSEARCH on $(>) = $(headers) $(sysHeaders) $(STDHDRS) ;
131	HDRGRIST on $(>) = $(HDRGRIST) ;
132
133	# propagate target specific-defines
134
135	DEFINES on $(1) = $(defines) ;
136
137	# if source is not .c, generate .c with specific rule
138
139	switch $(>:S)
140	{
141		case .asm : As $(<) : $(>) ;
142		case .nasm : AssembleNasm $(<) : $(>) ;
143		case .c :	Cc $(<) : $(>) ;
144		case .C :	C++ $(<) : $(>) ;
145		case .cc :	C++ $(<) : $(>) ;
146		case .cpp : C++ $(<) : $(>) ;
147		case .f :	Fortran $(<) : $(>) ;
148		case .l :	if [ on $(2) return $(GENERATE_C++) ] {
149						InheritPlatform $(<:S=.cpp) : $(1) ;
150						C++ $(<) : $(<:S=.cpp) ;
151						Lex $(<:S=.cpp) : $(>) ;
152					} else {
153						InheritPlatform $(<:S=.c) : $(1) ;
154						Cc $(<) : $(<:S=.c) ;
155						Lex $(<:S=.c) : $(>) ;
156					}
157		case *.o :	return ;
158		case .s :	As $(<) : $(>) ;
159		case .S :	As $(<) : $(>) ;
160		case .y :	if [ on $(2) return $(GENERATE_C++) ] {
161						InheritPlatform $(1:S=.cpp) $(1:S=.hpp) : $(1) ;
162						C++ $(1) : $(1:S=.cpp) ;
163						Yacc $(1:S=.cpp) $(1:S=.hpp) : $(2) ;
164					} else {
165						InheritPlatform $(1:S=.c) $(1:S=.h) : $(1) ;
166						Cc $(1) : $(1:S=.c) ;
167						Yacc $(1:S=.c) $(1:S=.h) : $(2) ;
168					}
169		case * :	UserObject $(<) : $(>) ;
170	}
171}
172
173rule As
174{
175	local flags ;
176	local includesSeparator ;
177	local localIncludesOption ;
178	local systemIncludesOption ;
179	if [ on $(1) return $(PLATFORM) ] = host {
180		flags = [ on $(1) return $(HOST_ASFLAGS) $(ASFLAGS) ] ;
181
182		CC on $(1) = $(HOST_CC) ;
183
184		includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
185		localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
186		systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
187	} else {
188		flags = [ on $(1) return $(TARGET_ASFLAGS_$(TARGET_PACKAGING_ARCH))
189			$(ASFLAGS) ] ;
190
191		CC on $(1) = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
192
193		includesSeparator
194			= $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
195		localIncludesOption
196			= $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
197		systemIncludesOption
198			= $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
199	}
200
201	Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
202	ASFLAGS on $(<) += $(flags) $(SUBDIRASFLAGS) ;
203	ASHDRS on $(<) = [ on $(<) FIncludes $(HDRS) : $(localIncludesOption) ]
204		$(includesSeparator)
205		[ on $(<) FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
206	ASDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
207}
208
209actions As
210{
211	$(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(ASDEFS) $(ASHDRS) -o "$(1)"
212}
213
214rule Lex
215{
216	Depends $(1) : $(2) [ on $(1) return $(PLATFORM) ] ;
217	MakeLocateArch $(1) ;
218	LocalClean clean : $(1) ;
219}
220
221actions Lex
222{
223	$(LEX) $(LEXFLAGS) -o$(1) $(2)
224}
225
226rule Yacc
227{
228	local source = $(1[1]) ;
229	local header = $(1[2]) ;
230	local yaccSource = $(2) ;
231
232	MakeLocateArch $(source) $(header) ;
233
234	Depends $(source) $(header)
235		: $(yaccSource) [ on $(source) return $(PLATFORM) ] ;
236	Yacc1 $(source) $(header) : $(yaccSource) ;
237	LocalClean clean : $(source) $(header) ;
238
239	# make sure someone includes $(header) else it will be
240	# a deadly independent target
241
242	Includes $(source) : $(header) ;
243}
244
245actions Yacc1
246{
247	bison $(YACCFLAGS) -o $(1[1]) $(2)
248	[ -f $(1[1]).h ] && mv $(1[1]).h $(1[2]) || true
249}
250
251rule Cc
252{
253	Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
254
255	on $(1) {
256		local flags ;
257		local includesSeparator ;
258		local localIncludesOption ;
259		local systemIncludesOption ;
260
261		# optimization flags
262		if $(DEBUG) = 0 {
263			flags += $(OPTIM) ;
264		} else {
265			flags += -O0 ;
266		}
267
268		if $(PLATFORM) = host {
269			# warning flags
270			if $(WARNINGS) != 0 {
271				flags += $(HOST_WARNING_CCFLAGS) ;
272				if $(WARNINGS) = treatAsErrors {
273					flags += -Werror $(HOST_WERROR_FLAGS) ;
274				}
275			}
276
277			# debug and other flags
278			flags += $(HOST_CCFLAGS) $(HOST_DEBUG_$(DEBUG)_CCFLAGS)
279				$(SUBDIRCCFLAGS) $(CCFLAGS) ;
280
281			if $(USES_BE_API) {
282				flags += $(HOST_BE_API_CCFLAGS) ;
283			}
284
285			CC on $(1) = $(HOST_CC) ;
286
287			includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
288			localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
289			systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
290		} else {
291			# warning flags
292			if $(WARNINGS) != 0 {
293				flags += $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)) ;
294				if $(WARNINGS) = treatAsErrors {
295					flags += -Werror
296						$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
297				}
298			}
299
300			# debug and other flags
301			flags += $(TARGET_CCFLAGS_$(TARGET_PACKAGING_ARCH))
302				$(TARGET_DEBUG_$(DEBUG)_CCFLAGS_$(TARGET_PACKAGING_ARCH))
303				$(SUBDIRCCFLAGS) $(CCFLAGS) ;
304
305			CC on $(1) = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
306
307			includesSeparator
308				= $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
309			localIncludesOption
310				= $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
311			systemIncludesOption
312				= $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
313		}
314
315		CCFLAGS on $(<) = $(flags) ;
316		CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
317			$(includesSeparator)
318			[ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
319		CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
320	}
321}
322
323actions Cc
324{
325	$(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)"
326}
327
328rule C++
329{
330	Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
331
332	on $(1) {
333		local flags ;
334		local includesSeparator ;
335		local localIncludesOption ;
336		local systemIncludesOption ;
337
338		# optimization flags
339		if $(DEBUG) = 0 {
340			flags += $(OPTIM) ;
341		} else {
342			flags += -O0 ;
343		}
344
345		if $(PLATFORM) = host {
346			# warning flags
347			if $(WARNINGS) != 0 {
348				flags += $(HOST_WARNING_C++FLAGS) ;
349				if $(WARNINGS) = treatAsErrors {
350					flags += -Werror $(HOST_WERROR_FLAGS) ;
351				}
352			}
353
354			# debug and other flags
355			flags += $(HOST_C++FLAGS) $(HOST_DEBUG_$(DEBUG)_C++FLAGS)
356				$(SUBDIRC++FLAGS) $(C++FLAGS) ;
357
358			if $(USES_BE_API) {
359				flags += $(HOST_BE_API_C++FLAGS) ;
360			}
361
362			C++ on $(1) = $(HOST_C++) ;
363
364			includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
365			localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
366			systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
367		} else {
368			# warning flags
369			if $(WARNINGS) != 0 {
370				flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
371				if $(WARNINGS) = treatAsErrors {
372					flags += -Werror
373						$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
374				}
375			}
376
377			# debug and other flags
378			flags += $(TARGET_C++FLAGS_$(TARGET_PACKAGING_ARCH))
379				$(TARGET_DEBUG_$(DEBUG)_C++FLAGS_$(TARGET_PACKAGING_ARCH))
380				$(SUBDIRC++FLAGS) $(C++FLAGS) ;
381
382			C++ on $(1) = $(TARGET_C++_$(TARGET_PACKAGING_ARCH)) ;
383
384			includesSeparator
385				= $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
386			localIncludesOption
387				= $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
388			systemIncludesOption
389				= $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
390		}
391
392		C++FLAGS on $(<) = $(flags) ;
393		CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
394			$(includesSeparator)
395			[ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
396		CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
397	}
398}
399
400actions C++
401{
402	$(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)"
403}
404
405# Force recreation of the archive to avoid build errors caused by
406# stale dependencies after renaming or deleting object files.
407actions together Archive
408{
409	$(RM) $(<)
410	$(AR) $(<) $(>)
411}
412
413rule Library
414{
415	local lib = $(1) ;
416	local sources = [ FGristFiles $(2) ] ;
417	local objects = $(sources:S=$(SUFOBJ)) ;
418
419	InheritPlatform $(objects) : $(lib) ;
420	LibraryFromObjects $(lib) : $(objects) ;
421	Objects $(sources) ;
422}
423
424rule LibraryFromObjects
425{
426	local _i _l _s ;
427
428	# Add grist to file names
429	# bonefish: No, don't. The Library rule does that anyway, and when we
430	# have an object from another dir, we certainly don't want that.
431
432	_s = $(>) ;
433	_l = $(<:S=$(SUFLIB)) ;
434
435	on $(_l) {
436		# set the tools according to the platform
437		if $(PLATFORM) = host {
438			AR on $(_l) = $(HOST_AR) $(HOST_ARFLAGS) ;
439			RANLIB on $(_l) = $(HOST_RANLIB) ;
440		} else {
441			AR on $(_l) = $(TARGET_AR_$(TARGET_PACKAGING_ARCH))
442				$(TARGET_ARFLAGS_$(TARGET_PACKAGING_ARCH)) ;
443			RANLIB on $(_l) = $(TARGET_RANLIB_$(TARGET_PACKAGING_ARCH)) ;
444		}
445
446		# library depends on its member objects
447
448		if $(KEEPOBJS) {
449			LocalDepends obj : $(_s) ;
450		}
451
452		LocalDepends lib : $(_l) ;
453
454		# Set LOCATE for the library and its contents. The bound
455		# value shows up as $(NEEDLIBS) on the Link actions.
456		# For compatibility, we only do this if the library doesn't
457		# already have a path.
458
459		if ! $(_l:D) {
460			# locate the library only, if it hasn't been located yet
461			local dir = $(LOCATE[1]) ;
462			if ! $(dir) {
463				MakeLocateDebug $(_l) ;
464				dir = [ on $(_l) return $(LOCATE[1]) ] ;
465					# Note: The "on ..." is necessary, since our environment
466					# isn't changed by MakeLocateDebug.
467			}
468			MakeLocate $(_l)($(_s:BS)) : $(dir) ;
469		}
470
471		if $(NOARSCAN) {
472			# If we can't scan the library to timestamp its contents,
473			# we have to just make the library depend directly on the
474			# on-disk object files.
475
476			Depends $(_l) : $(_s) ;
477		} else {
478			# If we can scan the library, we make the library depend
479			# on its members and each member depend on the on-disk
480			# object file.
481
482			Depends $(_l) : $(_l)($(_s:BS)) ;
483
484			for _i in $(_s)
485			{
486			Depends $(_l)($(_i:BS)) : $(_i) ;
487			}
488		}
489
490		LocalClean clean : $(_l) ;
491
492		Archive $(_l) : $(_s) ;
493
494		if $(RANLIB) { Ranlib $(_l) ; }
495
496		# If we can't scan the library, we have to leave the .o's around.
497
498		if ! ( $(KEEPOBJS) || $(NOARSCAN) || $(NOARUPDATE) ) {
499			RmTemps $(_l) : $(_s) ;
500		}
501	}
502}
503
504rule Main
505{
506	local target = $(1) ;
507	local sources = [ FGristFiles $(2) ] ;
508	local objects = $(sources:S=$(SUFOBJ)) ;
509
510	InheritPlatform $(objects) : $(target) ;
511	MainFromObjects $(target) : $(objects) ;
512	Objects $(sources) ;
513}
514
515rule MainFromObjects
516{
517	local _s _t ;
518
519	# Add grist to file names
520	# Add suffix to exe
521
522	_s = [ FGristFiles $(>) ] ;
523	_t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
524
525	# so 'jam foo' works when it's really foo.exe
526
527	if $(_t) != $(<)
528	{
529		Depends $(<) : $(_t) ;
530		NotFile $(<) ;
531	}
532
533	# make compiled sources a dependency of target
534
535	LocalDepends exe : $(_t) ;
536	Depends $(_t) : $(_s) ;
537	MakeLocateDebug $(_t) ;
538
539	LocalClean clean : $(_t) ;
540
541	Link $(_t) : $(_s) ;
542}
543
544# Override Jam 2.5rc3 MakeLocate and MkDir to deal more intelligently
545# with grist set on the supplied directory name. Also do nothing for already
546# located files.
547rule MakeLocate
548{
549	local dir = $(2[1]) ;
550
551	if $(dir) {
552		if ! $(dir:G) {
553			dir = $(dir:G=dir) ;
554		}
555
556		local target ;
557		for target in $(1) {
558			# don't relocate once located
559			LOCATE on $(target) += $(dir:G=) ;
560			if [ on $(target) return $(LOCATE) ] = $(dir:G=) {
561				Depends $(target) : $(dir) ;
562				MkDir $(dir) ;
563			}
564		}
565	}
566}
567
568# Overridden to use "-p", as Jam does not properly normalize
569# paths passed to NoUpdate, and so tries to make some directories
570# twice: once for the relative path, and once for the absolute path.
571actions MkDir1
572{
573	$(MKDIR) -p "$(<)"
574}
575
576rule MkDir
577{
578	local dir = $(<) ;
579	if ! $(dir:G) {
580		dir = $(dir:G=dir) ;
581	}
582
583	# make this and all super directories
584	while true {
585		# If dir exists, don't update it
586		# Do this even for $(DOT).
587		NoUpdate $(dir) ;
588
589		# Bail out when reaching the CWD (".") or a directory we've already
590		# made.
591		if $(dir:G=) = $(DOT) || $($(dir:G=)-mkdir) {
592			return ;
593		}
594
595		local s ;
596
597		# Cheesy gate to prevent multiple invocations on same dir
598		# MkDir1 has the actions
599		# Arrange for jam dirs
600
601		$(dir:G=)-mkdir = true ;
602		MkDir1 $(dir) ;
603		LocalDepends dirs : $(dir) ;
604
605		# Recursively make parent directories.
606		# $(dir:P) = $(dir)'s parent, & we recurse until root
607
608		s = $(dir:P) ;	# parent keeps grist
609
610		if $(s:G=) && $(s) != $(dir) {
611			Depends $(dir) : $(s) ;
612			dir = $(s) ;
613		} else if $(s) {
614			NotFile $(s) ;
615			break ;
616		}
617	}
618}
619
620rule ObjectCcFlags
621{
622	# supports inheriting the global variable value
623
624	local file ;
625	for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
626		CCFLAGS on $(file) = [ on $(file) return $(CCFLAGS) ] $(2) ;
627	}
628}
629
630rule ObjectC++Flags
631{
632	# supports inheriting the global variable value
633
634	local file ;
635	for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
636		C++FLAGS on $(file) = [ on $(file) return $(C++FLAGS) ] $(2) ;
637	}
638}
639
640rule ObjectDefines
641{
642	# supports inheriting the global variable value and multiple files
643
644	if $(2) {
645		local file ;
646		for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
647			DEFINES on $(file) = [ on $(file) return $(DEFINES) ] $(2) ;
648			CCDEFS on $(file) = [ on $(file) FDefines $(DEFINES) ] ;
649		}
650	}
651}
652
653rule ObjectHdrs
654{
655	# ObjectHdrs <sources or objects> : <headers> : <gristed objects>
656	# Note: Parameter 3 <gristed objects> is an extension.
657
658	local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] $(3) ;
659	local headers = $(2) ;
660
661	local file ;
662	for file in $(objects) {
663		on $(file) {
664			local localHeaders = $(HDRS) $(headers) ;
665			SYSHDRS on $(file) = $(localHeaders) ;
666
667			# reformat ASHDRS and CCHDRS
668			local fileHeaders ;
669
670			if $(PLATFORM) = host {
671				fileHeaders =
672					[ FIncludes $(localHeaders) : $(HOST_LOCAL_INCLUDES_OPTION) ]
673					$(HOST_INCLUDES_SEPARATOR)
674					[ FSysIncludes $(SYSHDRS)
675						: $(HOST_SYSTEM_INCLUDES_OPTION) ] ;
676			} else {
677				local architecture = $(TARGET_PACKAGING_ARCH) ;
678				fileHeaders =
679					[ FIncludes $(localHeaders)
680						: $(TARGET_LOCAL_INCLUDES_OPTION_$(architecture)) ]
681					$(TARGET_INCLUDES_SEPARATOR_$(architecture))
682					[ FSysIncludes $(SYSHDRS)
683						: $(TARGET_SYSTEM_INCLUDES_OPTION_$(architecture)) ] ;
684			}
685
686			ASHDRS on $(file) = $(fileHeaders) ;
687			CCHDRS on $(file) = $(fileHeaders) ;
688		}
689	}
690}
691
692# Overridden to avoid calling SubDir for a directory twice (in SubInclude
693# and from the Jamfile in the directory).
694rule SubInclude
695{
696	# SubInclude TOP d1 ... ;
697	#
698	# Include a subdirectory's Jamfile.
699
700	if ! $($(<[1]))
701	{
702		Exit SubInclude $(<[1]) without prior SubDir $(<[1]) ;
703	}
704
705	# Set up the config variables for the subdirectory.
706	local config = [ ConfigObject $(1) ] ;
707
708	__configured = ;
709	if ! [ on $(config) return $(__configured) ] {
710		# No custom configuration defined for the subdir. We use the variable
711		# values inherited by the closest ancestor.
712		config = $(HAIKU_INHERITED_SUBDIR_CONFIG) ;
713	}
714
715	# store SUBDIR_TOKENS
716	local oldSubDirTokens = $(SUBDIR_TOKENS) ;
717
718	on $(config) {
719		include [ FDirName $($(1[1])) $(1[2-) $(JAMFILE) ] ;
720	}
721
722	# restore SUBDIR_TOKENS
723	SUBDIR_TOKENS = $(oldSubDirTokens) ;
724}
725