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