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