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