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