OverriddenJamRules revision a07cdb6e
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_$(TARGET_PACKAGING_ARCH))
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 $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
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) [ on $(1) return $(PLATFORM) ] ;
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)
249		: $(yaccSource) [ on $(source) return $(PLATFORM) ] ;
250	Yacc1 $(source) $(header) : $(yaccSource) ;
251	LocalClean clean : $(source) $(header) ;
252
253	# make sure someone includes $(header) else it will be
254	# a deadly independent target
255
256	Includes $(source) : $(header) ;
257}
258
259actions Yacc1
260{
261	bison $(YACCFLAGS) -o $(1[1]) $(2)
262	[ -f $(1[1]).h ] && mv $(1[1]).h $(1[2]) || true
263}
264
265rule Cc
266{
267	Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
268
269	on $(1) {
270		local flags ;
271		local includesSeparator ;
272		local localIncludesOption ;
273		local systemIncludesOption ;
274
275		# optimization flags
276		if $(DEBUG) = 0 {
277			flags += $(OPTIM) ;
278		} else {
279			flags += -O0 ;
280		}
281
282		if $(PLATFORM) = host {
283			# warning flags
284			if $(WARNINGS) != 0 {
285				flags += $(HOST_WARNING_CCFLAGS) ;
286				if $(WARNINGS) = treatAsErrors {
287					flags += -Werror $(HOST_WERROR_FLAGS) ;
288				}
289			}
290
291			# debug and other flags
292			flags += $(HOST_CCFLAGS) $(HOST_DEBUG_$(DEBUG)_CCFLAGS)
293				$(SUBDIRCCFLAGS) $(CCFLAGS) ;
294
295			if $(USES_BE_API) {
296				flags += $(HOST_BE_API_CCFLAGS) ;
297			}
298
299			CC on $(1) = $(HOST_CC) ;
300
301			includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
302			localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
303			systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
304
305		} else {
306			# warning flags
307			if $(WARNINGS) != 0 {
308				flags += $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)) ;
309				if $(WARNINGS) = treatAsErrors {
310					flags += -Werror
311						$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
312				}
313			}
314
315			# debug and other flags
316			flags += $(TARGET_CCFLAGS_$(TARGET_PACKAGING_ARCH))
317				$(TARGET_DEBUG_$(DEBUG)_CCFLAGS_$(TARGET_PACKAGING_ARCH))
318				$(SUBDIRCCFLAGS) $(CCFLAGS) ;
319
320			CC on $(1) = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
321
322			includesSeparator
323				= $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
324			localIncludesOption
325				= $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
326			systemIncludesOption
327				= $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
328		}
329
330		CCFLAGS on $(<) = $(flags) ;
331		CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
332			$(includesSeparator)
333			[ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
334		CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
335	}
336}
337
338actions Cc
339{
340	$(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)" ;
341}
342
343rule C++
344{
345	Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
346
347	on $(1) {
348		local flags ;
349		local includesSeparator ;
350		local localIncludesOption ;
351		local systemIncludesOption ;
352
353		# optimization flags
354		if $(DEBUG) = 0 {
355			flags += $(OPTIM) ;
356		} else {
357			flags += -O0 ;
358		}
359
360		if $(PLATFORM) = host {
361			# warning flags
362			if $(WARNINGS) != 0 {
363				flags += $(HOST_WARNING_C++FLAGS) ;
364				if $(WARNINGS) = treatAsErrors {
365					flags += -Werror $(HOST_WERROR_FLAGS) ;
366				}
367			}
368
369			# debug and other flags
370			flags += $(HOST_C++FLAGS) $(HOST_DEBUG_$(DEBUG)_C++FLAGS)
371				$(SUBDIRC++FLAGS) $(C++FLAGS) ;
372
373			if $(USES_BE_API) {
374				flags += $(HOST_BE_API_C++FLAGS) ;
375			}
376
377			C++ on $(1) = $(HOST_C++) ;
378
379			includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
380			localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
381			systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
382
383		} else {
384			# warning flags
385			if $(WARNINGS) != 0 {
386				flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
387				if $(WARNINGS) = treatAsErrors {
388					flags += -Werror
389						$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
390				}
391			}
392
393			# debug and other flags
394			flags += $(TARGET_C++FLAGS_$(TARGET_PACKAGING_ARCH))
395				$(TARGET_DEBUG_$(DEBUG)_C++FLAGS_$(TARGET_PACKAGING_ARCH))
396				$(SUBDIRC++FLAGS) $(C++FLAGS) ;
397
398			C++ on $(1) = $(TARGET_C++_$(TARGET_PACKAGING_ARCH)) ;
399
400			includesSeparator
401				= $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
402			localIncludesOption
403				= $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
404			systemIncludesOption
405				= $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
406		}
407
408		C++FLAGS on $(<) = $(flags) ;
409		CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
410			$(includesSeparator)
411			[ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
412		CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
413	}
414}
415
416actions C++
417{
418	$(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ;
419}
420
421actions together Archive
422{
423	# Force recreation of the archive to avoid build errors caused by
424	# stale dependencies after renaming or deleting object files.
425	$(RM) $(<)
426	$(AR) $(<) $(>)
427}
428
429rule Library
430{
431	local lib = $(1) ;
432	local sources = [ FGristFiles $(2) ] ;
433	local objects = $(sources:S=$(SUFOBJ)) ;
434
435	InheritPlatform $(objects) : $(lib) ;
436	LibraryFromObjects $(lib) : $(objects) ;
437	Objects $(sources) ;
438}
439
440rule LibraryFromObjects
441{
442	local _i _l _s ;
443
444	# Add grist to file names
445	# bonefish: No, don't. The Library rule does that anyway, and when we
446	# have an object from another dir, we certainly don't want that.
447
448	_s = $(>) ;
449	_l = $(<:S=$(SUFLIB)) ;
450
451	on $(_l) {
452		# set the tools according to the platform
453		if $(PLATFORM) = host {
454			AR on $(_l) = $(HOST_AR) $(HOST_ARFLAGS) ;
455			RANLIB on $(_l) = $(HOST_RANLIB) ;
456		} else {
457			AR on $(_l) = $(TARGET_AR_$(TARGET_PACKAGING_ARCH))
458				$(TARGET_ARFLAGS_$(TARGET_PACKAGING_ARCH)) ;
459			RANLIB on $(_l) = $(TARGET_RANLIB_$(TARGET_PACKAGING_ARCH)) ;
460		}
461
462		# library depends on its member objects
463
464		if $(KEEPOBJS)
465		{
466			LocalDepends obj : $(_s) ;
467		}
468
469		LocalDepends lib : $(_l) ;
470
471		# Set LOCATE for the library and its contents.  The bound
472		# value shows up as $(NEEDLIBS) on the Link actions.
473		# For compatibility, we only do this if the library doesn't
474		# already have a path.
475
476		if ! $(_l:D)
477		{
478			# locate the library only, if it hasn't been located yet
479			local dir = $(LOCATE[1]) ;
480			if ! $(dir) {
481				MakeLocateDebug $(_l) ;
482				dir = [ on $(_l) return $(LOCATE[1]) ] ;
483					# Note: The "on ..." is necessary, since our environment
484					# isn't changed by MakeLocateDebug.
485			}
486			MakeLocate $(_l)($(_s:BS)) : $(dir) ;
487		}
488
489		if $(NOARSCAN)
490		{
491			# If we can't scan the library to timestamp its contents,
492			# we have to just make the library depend directly on the
493			# on-disk object files.
494
495			Depends $(_l) : $(_s) ;
496		}
497		else
498		{
499			# If we can scan the library, we make the library depend
500			# on its members and each member depend on the on-disk
501			# object file.
502
503			Depends $(_l) : $(_l)($(_s:BS)) ;
504
505			for _i in $(_s)
506			{
507			Depends $(_l)($(_i:BS)) : $(_i) ;
508			}
509		}
510
511		LocalClean clean : $(_l) ;
512
513		# bonefish: Not needed on the supported platforms. Maybe later...
514		# if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
515
516		Archive $(_l) : $(_s) ;
517
518		if $(RANLIB) { Ranlib $(_l) ; }
519
520		# If we can't scan the library, we have to leave the .o's around.
521
522		if ! ( $(KEEPOBJS) || $(NOARSCAN) || $(NOARUPDATE) ) {
523			RmTemps $(_l) : $(_s) ;
524		}
525	}
526}
527
528rule Main
529{
530	local target = $(1) ;
531	local sources = [ FGristFiles $(2) ] ;
532	local objects = $(sources:S=$(SUFOBJ)) ;
533
534	InheritPlatform $(objects) : $(target) ;
535	MainFromObjects $(target) : $(objects) ;
536	Objects $(sources) ;
537}
538
539rule MainFromObjects
540{
541	local _s _t ;
542
543	# Add grist to file names
544	# Add suffix to exe
545
546	_s = [ FGristFiles $(>) ] ;
547	_t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
548
549	# so 'jam foo' works when it's really foo.exe
550
551	if $(_t) != $(<)
552	{
553	    Depends $(<) : $(_t) ;
554	    NotFile $(<) ;
555	}
556
557	# make compiled sources a dependency of target
558
559	LocalDepends exe : $(_t) ;
560	Depends $(_t) : $(_s) ;
561	MakeLocateDebug $(_t) ;
562
563	LocalClean clean : $(_t) ;
564
565	Link $(_t) : $(_s) ;
566}
567
568# Override Jam 2.5rc3 MakeLocate and MkDir to deal more intelligently
569# with grist set on the supplied directory name. Also do nothing for already
570# located files.
571rule MakeLocate
572{
573	local dir = $(2[1]) ;
574
575	if $(dir)
576	{
577		if ! $(dir:G) {
578			dir = $(dir:G=dir) ;
579		}
580
581		local target ;
582		for target in $(1) {
583			# don't relocate once located
584		    LOCATE on $(target) += $(dir:G=) ;
585			if [ on $(target) return $(LOCATE) ] = $(dir:G=) {
586			    Depends $(target) : $(dir) ;
587		    	MkDir $(dir) ;
588			}
589		}
590	}
591}
592
593rule MkDir
594{
595	local dir = $(<) ;
596	if ! $(dir:G) {
597		dir = $(dir:G=dir) ;
598	}
599
600	# make this and all super directories
601	while true {
602		# If dir exists, don't update it
603		# Do this even for $(DOT).
604		NoUpdate $(dir) ;
605
606		# Bail out when reaching the CWD (".") or a directory we've already
607		# made.
608		if $(dir:G=) = $(DOT) || $($(dir:G=)-mkdir) {
609			return ;
610		}
611
612		local s ;
613
614		# Cheesy gate to prevent multiple invocations on same dir
615		# MkDir1 has the actions
616		# Arrange for jam dirs
617
618		$(dir:G=)-mkdir = true ;
619		MkDir1 $(dir) ;
620		LocalDepends dirs : $(dir) ;
621
622		# Recursively make parent directories.
623		# $(dir:P) = $(dir)'s parent, & we recurse until root
624
625		s = $(dir:P) ;	# parent keeps grist
626
627		if $(s:G=) && $(s) != $(dir) {
628			Depends $(dir) : $(s) ;
629			dir = $(s) ;
630		} else if $(s) {
631			NotFile $(s) ;
632			break ;
633		}
634	}
635}
636
637rule ObjectCcFlags
638{
639	# supports inheriting the global variable value
640
641	local file ;
642	for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
643		CCFLAGS on $(file) = [ on $(file) return $(CCFLAGS) ] $(2) ;
644	}
645}
646
647rule ObjectC++Flags
648{
649	# supports inheriting the global variable value
650
651	local file ;
652	for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
653		C++FLAGS on $(file) = [ on $(file) return $(C++FLAGS) ] $(2) ;
654	}
655}
656
657rule ObjectDefines
658{
659	# supports inheriting the global variable value and multiple files
660
661	if $(2) {
662		local file ;
663		for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
664			DEFINES on $(file) = [ on $(file) return $(DEFINES) ] $(2) ;
665			CCDEFS on $(file) = [ on $(file) FDefines $(DEFINES) ] ;
666		}
667	}
668}
669
670rule ObjectHdrs
671{
672	# ObjectHdrs <sources or objects> : <headers> : <gristed objects>
673	# Note: Parameter 3 <gristed objects> is an extension.
674
675	local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] $(3) ;
676	local headers = $(2) ;
677
678	local file ;
679	for file in $(objects) {
680		on $(file) {
681			local localHeaders = $(HDRS) $(headers) ;
682			SYSHDRS on $(file) = $(localHeaders) ;
683
684			# reformat ASHDRS and CCHDRS
685			local fileHeaders ;
686
687			if $(PLATFORM) = host {
688				fileHeaders =
689					[ FIncludes $(localHeaders) : $(HOST_LOCAL_INCLUDES_OPTION) ]
690					$(HOST_INCLUDES_SEPARATOR)
691					[ FSysIncludes $(SYSHDRS)
692						: $(HOST_SYSTEM_INCLUDES_OPTION) ] ;
693			} else {
694				local architecture = $(TARGET_PACKAGING_ARCH) ;
695				fileHeaders =
696					[ FIncludes $(localHeaders)
697						: $(TARGET_LOCAL_INCLUDES_OPTION_$(architecture)) ]
698					$(TARGET_INCLUDES_SEPARATOR_$(architecture))
699					[ FSysIncludes $(SYSHDRS)
700						: $(TARGET_SYSTEM_INCLUDES_OPTION_$(architecture)) ] ;
701			}
702
703			ASHDRS on $(file) = $(fileHeaders) ;
704			CCHDRS on $(file) = $(fileHeaders) ;
705		}
706	}
707}
708
709# Overridden to avoid calling SubDir for a directory twice (in SubInclude
710# and from the Jamfile in the directory).
711rule SubInclude
712{
713	# SubInclude TOP d1 ... ;
714	#
715	# Include a subdirectory's Jamfile.
716
717	if ! $($(<[1]))
718	{
719	    Exit SubInclude $(<[1]) without prior SubDir $(<[1]) ;
720	}
721
722	# Set up the config variables for the subdirectory.
723	local config = [ ConfigObject $(1) ] ;
724
725	__configured = ;
726	if ! [ on $(config) return $(__configured) ] {
727		# No custom configuration defined for the subdir. We use the variable
728		# values inherited by the closest ancestor.
729		config = $(HAIKU_INHERITED_SUBDIR_CONFIG) ;
730	}
731
732	# store SUBDIR_TOKENS
733	local oldSubDirTokens = $(SUBDIR_TOKENS) ;
734
735	on $(config) {
736		include [ FDirName $($(1[1])) $(1[2-) $(JAMFILE) ] ;
737	}
738
739	# restore SUBDIR_TOKENS
740	SUBDIR_TOKENS = $(oldSubDirTokens) ;
741}
742
743
744actions File
745{
746	$(CP) "$(>)" "$(<)"
747}
748