1 # Overridden to allow spaces in file names.
4 $(CHMOD) "$(MODE)" "$(1)"
7 # Overridden to allow spaces in file names.
8 actions piecemeal together existing Clean
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 #-------------------------------------------------------------------------------
19 # Note: RESFILES must be set before invocation.
21 if [ on $(1) return $(PLATFORM) ] = host {
22 LINK on $(1) = $(HOST_LINK) ;
23 LINKFLAGS on $(1) = $(HOST_LINKFLAGS) [ on $(1) return $(LINKFLAGS) ] ;
25 LINK on $(1) = $(TARGET_LINK_$(TARGET_PACKAGING_ARCH)) ;
26 LINKFLAGS on $(1) = $(TARGET_LINKFLAGS_$(TARGET_PACKAGING_ARCH))
27 [ on $(1) return $(LINKFLAGS) ] ;
30 HAIKU_TARGET_IS_EXECUTABLE on $(1) = 1 ;
32 NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] ;
33 LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] ;
35 MODE on $(<) = $(EXEMODE) ;
36 on $(1) XRes $(1) : $(RESFILES) ;
37 if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] {
39 MimeSet $(1) : sharedObject ;
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) ;
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) ;
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".
62 if $(HOST_PLATFORM_BEOS_COMPATIBLE) || $(HAIKU_HOST_USE_XATTR) = 1 {
63 actions Link bind NEEDLIBS LINK_BEGIN_GLUE LINK_END_GLUE VERSION_SCRIPT
65 $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(LINK_BEGIN_GLUE)" "$(2)" \
66 "$(NEEDLIBS)" $(LINKLIBS) "$(LINK_END_GLUE)" \
67 -Wl,--version-script,$(VERSION_SCRIPT)
70 actions Link bind NEEDLIBS LINK_BEGIN_GLUE LINK_END_GLUE VERSION_SCRIPT
73 $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(LINK_BEGIN_GLUE)" "$(2)" \
74 "$(NEEDLIBS)" $(LINKLIBS) "$(LINK_END_GLUE)" \
75 -Wl,--version-script,$(VERSION_SCRIPT)
81 # find out which headers and defines to use
86 on $(1) { # use on $(1) variable values
87 if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) {
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).
97 headers = $(HAIKU_CONFIG_HEADERS) $(SEARCH_SOURCE) $(SUBDIRHDRS)
99 sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ;
100 defines = $(DEFINES) ;
102 if $(PLATFORM) = host {
103 sysHeaders += $(HOST_HDRS) ;
104 defines += $(HOST_DEFINES) ;
107 sysHeaders += $(HOST_BE_API_HEADERS) ;
111 sysHeaders += [ FStandardHeaders $(TARGET_PACKAGING_ARCH) ]
112 $(TARGET_HDRS_$(TARGET_PACKAGING_ARCH)) ;
113 defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH))
118 # locate object and search for source
120 LocalClean clean : $(<) ;
122 MakeLocateDebug $(<) ;
123 SEARCH on $(>) = $(SEARCH_SOURCE) ;
125 HDRS on $(<) = $(headers) ;
126 SYSHDRS on $(<) = $(sysHeaders) ;
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.
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).
140 HDRRULE on $(>) = HdrRule ;
141 HDRSCAN on $(>) = $(HDRPATTERN) ;
142 HDRSEARCH on $(>) = $(headers) $(sysHeaders) $(STDHDRS) ;
143 HDRGRIST on $(>) = $(HDRGRIST) ;
145 # propagate target specific-defines
147 DEFINES on $(1) = $(defines) ;
149 # if source is not .c, generate .c with specific rule
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) : $(>) ;
165 InheritPlatform $(<:S=.c) : $(1) ;
166 Cc $(<) : $(<:S=.c) ;
167 Lex $(<:S=.c) : $(>) ;
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) ;
177 InheritPlatform $(1:S=.c) $(1:S=.h) : $(1) ;
178 Cc $(1) : $(1:S=.c) ;
179 Yacc $(1:S=.c) $(1:S=.h) : $(2) ;
181 case * : UserObject $(<) : $(>) ;
188 local includesSeparator ;
189 local localIncludesOption ;
190 local systemIncludesOption ;
191 if [ on $(1) return $(PLATFORM) ] = host {
192 flags = [ on $(1) return $(HOST_ASFLAGS) $(ASFLAGS) ] ;
194 CC on $(1) = $(HOST_CC) ;
196 includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
197 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
198 systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
201 flags = [ on $(1) return $(TARGET_ASFLAGS_$(TARGET_PACKAGING_ARCH))
204 CC on $(1) = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
207 = $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
209 = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
211 = $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
214 Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
215 ASFLAGS on $(<) += $(flags) $(SUBDIRASFLAGS) ;
216 ASHDRS on $(<) = [ on $(<) FIncludes $(HDRS) : $(localIncludesOption) ]
218 [ on $(<) FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
219 ASDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
222 # TODO: The KERNEL_CCFLAGS were used here before. Check whether we need any
223 # flags we don't have now.
226 $(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(ASDEFS) $(ASHDRS) -o "$(1)" ;
231 Depends $(1) : $(2) [ on $(1) return $(PLATFORM) ] ;
232 MakeLocateArch $(1) ;
233 LocalClean clean : $(1) ;
238 $(LEX) $(LEXFLAGS) -o$(1) $(2)
243 local source = $(1[1]) ;
244 local header = $(1[2]) ;
245 local yaccSource = $(2) ;
247 MakeLocateArch $(source) $(header) ;
249 Depends $(source) $(header)
250 : $(yaccSource) [ on $(source) return $(PLATFORM) ] ;
251 Yacc1 $(source) $(header) : $(yaccSource) ;
252 LocalClean clean : $(source) $(header) ;
254 # make sure someone includes $(header) else it will be
255 # a deadly independent target
257 Includes $(source) : $(header) ;
262 bison $(YACCFLAGS) -o $(1[1]) $(2)
263 [ -f $(1[1]).h ] && mv $(1[1]).h $(1[2]) || true
268 Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
272 local includesSeparator ;
273 local localIncludesOption ;
274 local systemIncludesOption ;
283 if $(PLATFORM) = host {
285 if $(WARNINGS) != 0 {
286 flags += $(HOST_WARNING_CCFLAGS) ;
287 if $(WARNINGS) = treatAsErrors {
288 flags += -Werror $(HOST_WERROR_FLAGS) ;
292 # debug and other flags
293 flags += $(HOST_CCFLAGS) $(HOST_DEBUG_$(DEBUG)_CCFLAGS)
294 $(SUBDIRCCFLAGS) $(CCFLAGS) ;
297 flags += $(HOST_BE_API_CCFLAGS) ;
300 CC on $(1) = $(HOST_CC) ;
302 includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
303 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
304 systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
308 if $(WARNINGS) != 0 {
309 flags += $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)) ;
310 if $(WARNINGS) = treatAsErrors {
312 $(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
316 # debug and other flags
317 flags += $(TARGET_CCFLAGS_$(TARGET_PACKAGING_ARCH))
318 $(TARGET_DEBUG_$(DEBUG)_CCFLAGS_$(TARGET_PACKAGING_ARCH))
319 $(SUBDIRCCFLAGS) $(CCFLAGS) ;
321 CC on $(1) = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
324 = $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
326 = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
328 = $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
331 CCFLAGS on $(<) = $(flags) ;
332 CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
334 [ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
335 CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
341 $(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)" ;
346 Depends $(<) : $(>) [ on $(1) return $(PLATFORM) ] ;
350 local includesSeparator ;
351 local localIncludesOption ;
352 local systemIncludesOption ;
361 if $(PLATFORM) = host {
363 if $(WARNINGS) != 0 {
364 flags += $(HOST_WARNING_C++FLAGS) ;
365 if $(WARNINGS) = treatAsErrors {
366 flags += -Werror $(HOST_WERROR_FLAGS) ;
370 # debug and other flags
371 flags += $(HOST_C++FLAGS) $(HOST_DEBUG_$(DEBUG)_C++FLAGS)
372 $(SUBDIRC++FLAGS) $(C++FLAGS) ;
375 flags += $(HOST_BE_API_C++FLAGS) ;
378 C++ on $(1) = $(HOST_C++) ;
380 includesSeparator = $(HOST_INCLUDES_SEPARATOR) ;
381 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
382 systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ;
386 if $(WARNINGS) != 0 {
387 flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
388 if $(WARNINGS) = treatAsErrors {
390 $(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
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) ;
399 C++ on $(1) = $(TARGET_C++_$(TARGET_PACKAGING_ARCH)) ;
402 = $(TARGET_INCLUDES_SEPARATOR_$(TARGET_PACKAGING_ARCH)) ;
404 = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
406 = $(TARGET_SYSTEM_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
409 C++FLAGS on $(<) = $(flags) ;
410 CCHDRS on $(<) = [ FIncludes $(HDRS) : $(localIncludesOption) ]
412 [ FSysIncludes $(SYSHDRS) : $(systemIncludesOption) ] ;
413 CCDEFS on $(<) = [ FDefines $(DEFINES) ] ;
419 $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ;
422 actions together Archive
424 # Force recreation of the archive to avoid build errors caused by
425 # stale dependencies after renaming or deleting object files.
433 local sources = [ FGristFiles $(2) ] ;
434 local objects = $(sources:S=$(SUFOBJ)) ;
436 InheritPlatform $(objects) : $(lib) ;
437 LibraryFromObjects $(lib) : $(objects) ;
441 rule LibraryFromObjects
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.
450 _l = $(<:S=$(SUFLIB)) ;
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) ;
458 AR on $(_l) = $(TARGET_AR_$(TARGET_PACKAGING_ARCH))
459 $(TARGET_ARFLAGS_$(TARGET_PACKAGING_ARCH)) ;
460 RANLIB on $(_l) = $(TARGET_RANLIB_$(TARGET_PACKAGING_ARCH)) ;
463 # library depends on its member objects
467 LocalDepends obj : $(_s) ;
470 LocalDepends lib : $(_l) ;
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.
479 # locate the library only, if it hasn't been located yet
480 local dir = $(LOCATE[1]) ;
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.
487 MakeLocate $(_l)($(_s:BS)) : $(dir) ;
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.
496 Depends $(_l) : $(_s) ;
500 # If we can scan the library, we make the library depend
501 # on its members and each member depend on the on-disk
504 Depends $(_l) : $(_l)($(_s:BS)) ;
508 Depends $(_l)($(_i:BS)) : $(_i) ;
512 LocalClean clean : $(_l) ;
514 # bonefish: Not needed on the supported platforms. Maybe later...
515 # if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
517 Archive $(_l) : $(_s) ;
519 if $(RANLIB) { Ranlib $(_l) ; }
521 # If we can't scan the library, we have to leave the .o's around.
523 if ! ( $(KEEPOBJS) || $(NOARSCAN) || $(NOARUPDATE) ) {
524 RmTemps $(_l) : $(_s) ;
531 local target = $(1) ;
532 local sources = [ FGristFiles $(2) ] ;
533 local objects = $(sources:S=$(SUFOBJ)) ;
535 InheritPlatform $(objects) : $(target) ;
536 MainFromObjects $(target) : $(objects) ;
544 # Add grist to file names
547 _s = [ FGristFiles $(>) ] ;
548 _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
550 # so 'jam foo' works when it's really foo.exe
554 Depends $(<) : $(_t) ;
558 # make compiled sources a dependency of target
560 LocalDepends exe : $(_t) ;
561 Depends $(_t) : $(_s) ;
562 MakeLocateDebug $(_t) ;
564 LocalClean clean : $(_t) ;
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
574 local dir = $(2[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) ;
601 # make this and all super directories
603 # If dir exists, don't update it
604 # Do this even for $(DOT).
607 # Bail out when reaching the CWD (".") or a directory we've already
609 if $(dir:G=) = $(DOT) || $($(dir:G=)-mkdir) {
615 # Cheesy gate to prevent multiple invocations on same dir
616 # MkDir1 has the actions
617 # Arrange for jam dirs
619 $(dir:G=)-mkdir = true ;
621 LocalDepends dirs : $(dir) ;
623 # Recursively make parent directories.
624 # $(dir:P) = $(dir)'s parent, & we recurse until root
626 s = $(dir:P) ; # parent keeps grist
628 if $(s:G=) && $(s) != $(dir) {
629 Depends $(dir) : $(s) ;
640 # supports inheriting the global variable value
643 for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
644 CCFLAGS on $(file) = [ on $(file) return $(CCFLAGS) ] $(2) ;
650 # supports inheriting the global variable value
653 for file in [ FGristFiles $(1:S=$(SUFOBJ)) ] {
654 C++FLAGS on $(file) = [ on $(file) return $(C++FLAGS) ] $(2) ;
660 # supports inheriting the global variable value and multiple files
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) ] ;
673 # ObjectHdrs <sources or objects> : <headers> : <gristed objects>
674 # Note: Parameter 3 <gristed objects> is an extension.
676 local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] $(3) ;
677 local headers = $(2) ;
680 for file in $(objects) {
682 local localHeaders = $(HDRS) $(headers) ;
683 SYSHDRS on $(file) = $(localHeaders) ;
685 # reformat ASHDRS and CCHDRS
688 if $(PLATFORM) = host {
690 [ FIncludes $(localHeaders) : $(HOST_LOCAL_INCLUDES_OPTION) ]
691 $(HOST_INCLUDES_SEPARATOR)
692 [ FSysIncludes $(SYSHDRS)
693 : $(HOST_SYSTEM_INCLUDES_OPTION) ] ;
695 local architecture = $(TARGET_PACKAGING_ARCH) ;
697 [ FIncludes $(localHeaders)
698 : $(TARGET_LOCAL_INCLUDES_OPTION_$(architecture)) ]
699 $(TARGET_INCLUDES_SEPARATOR_$(architecture))
700 [ FSysIncludes $(SYSHDRS)
701 : $(TARGET_SYSTEM_INCLUDES_OPTION_$(architecture)) ] ;
704 ASHDRS on $(file) = $(fileHeaders) ;
705 CCHDRS on $(file) = $(fileHeaders) ;
710 # Overridden to avoid calling SubDir for a directory twice (in SubInclude
711 # and from the Jamfile in the directory).
714 # SubInclude TOP d1 ... ;
716 # Include a subdirectory's Jamfile.
720 Exit SubInclude $(<[1]) without prior SubDir $(<[1]) ;
723 # Set up the config variables for the subdirectory.
724 local config = [ ConfigObject $(1) ] ;
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) ;
733 # store SUBDIR_TOKENS
734 local oldSubDirTokens = $(SUBDIR_TOKENS) ;
737 include [ FDirName $($(1[1])) $(1[2-) $(JAMFILE) ] ;
740 # restore SUBDIR_TOKENS
741 SUBDIR_TOKENS = $(oldSubDirTokens) ;