3 # +\ Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
6 # This file is part of Jam - see jam.c for Copyright information.
10 # JAMBASE - jam 2.5 ruleset providing make(1)-like functionality
12 # Supports UNIX, NT, and VMS.
14 # 12/27/93 (seiwald) - purturb library sources with SOURCE_GRIST
15 # 04/18/94 (seiwald) - use '?=' when setting OS specific vars
16 # 04/21/94 (seiwald) - do RmTemps together
17 # 05/05/94 (seiwald) - all supported C compilers support -o: relegate
18 # RELOCATE as an option; set Ranlib to "" to disable it
19 # 06/01/94 (seiwald) - new 'actions existing' to do existing sources
20 # 08/25/94 (seiwald) - new ObjectCcFlags rule to append to per-target CCFLAGS
21 # 08/29/94 (seiwald) - new ObjectHdrs rule to append to per-target HDRS
22 # 09/19/94 (seiwald) - LinkLibraries and Undefs now append
23 # - Rule names downshifted.
24 # 10/06/94 (seiwald) - Dumb yyacc stuff moved into Jamfile.
25 # 10/14/94 (seiwald) - (Crude) support for .s, .C, .cc, .cpp, and .f files.
26 # 01/08/95 (seiwald) - Shell now handled with awk, not sed
27 # 01/09/95 (seiwald) - Install* now take dest directory as target
28 # 01/10/95 (seiwald) - All entries sorted.
29 # 01/10/95 (seiwald) - NT support moved in, with LauraW's help.
30 # 01/10/95 (seiwald) - VMS support moved in.
31 # 02/06/95 (seiwald) - ObjectC++Flags and SubDirC++Flags added.
32 # 02/07/95 (seiwald) - Iron out when HDRSEARCH uses "" or SEARCH_SOURCE.
33 # 02/08/95 (seiwald) - SubDir works on VMS.
34 # 02/14/95 (seiwald) - MkDir and entourage.
35 # 04/30/95 (seiwald) - Use install -c flag so that it copies, not moves.
36 # 07/10/95 (taylor) - Support for Microsoft C++.
37 # 11/21/96 (peterk) - Support for BeOS
38 # 07/19/99 (sickel) - Support for Mac OS X Server (and maybe client)
39 # 02/18/00 (belmonte)- Support for Cygwin.
42 # [*] windoze support shortened (fuck it! %-)
43 # [-] OS/2 support removed (we'll cry for you...)
44 # [-] VMS support removed (nobody cares)
45 # [-] MAC support removed (should be rewritten!)
46 # [-] BEOS support removed (dead should be dead)
47 # [-] fortran support removed (who need that shit anyway?!)
48 # [+] C++ files will be compiled by g++, not gcc
49 # [+] MainC++ & MainC++FromObjects rules added (g++ linker instead of gcc)
50 # [+] LINKC++, LINKC++FLAGS, LINKC++LIBS, C++OPTIM variables added
51 # [+] LOCATE_BIN variable added (for Main rule)
52 # [+] PATH_SEPARATOR variable added
53 # [+] LOCATE_LIB and LOCATE_LIBSO variables added
54 # [+] xxxC++ renamed to C++xxx
55 # [+] SubIncludeOnce varname : TOP ... ;
56 # [-] xxxC++ rules removed (no need to keep obsolete crap)
57 # [-] aliases for compatibility with jam 2.2 removed
58 # [-] comented out all libtool crap
59 # [+] added rules: LinkFlagsOn, C++LinkFlagsOn, ObjCLinkFlagsOn
60 # [+] added rule: gcc-suggest-attrs
62 # Special targets defined in this file:
64 # all - parent of first, shell, files, lib, exe
65 # first - first dependent of 'all', for potential initialization
66 # shell - parent of all Shell targets
67 # files - parent of all File targets
68 # lib - parent of all Library targets
69 # exe - parent of all Main targets
70 # dirs - parent of all MkDir targets
71 # clean - removes all Shell, File, Library, and Main targets
72 # uninstall - removes all Install targets
75 # Rules defined by this file:
77 # as obj.o : source.s ; .s -> .o
78 # Bulk dir : files ; populate directory with many files
79 # Cc obj.o : source.c ; .c -> .o
80 # C++ obj.o : source.cc ; .cc -> .o
81 # Clean clean : sources ; remove sources with 'jam clean'
82 # File dest : source ; copy file
83 # GenFile source.c : program args ; make custom file
84 # HardLink target : source ; make link from source to target
85 # HdrRule source : headers ; handle #includes
86 # InstallInto dir : sources ; install any files
87 # InstallBin dir : sources ; install binaries
88 # InstallLib dir : sources ; install files
89 # InstallFile dir : sources ; install files
90 # InstallMan dir : sources ; install man pages
91 # InstallShell dir : sources ; install shell scripts
92 # Lex source.c : source.l ; .l -> .c
93 # Library lib : source ; archive library from compiled sources
94 # LibraryFromObjects lib : objects ; archive library from objects
95 # LinkLibraries images : libraries ; bag libraries onto Mains
96 # Main image : source ; link executable from compiled sources
97 # C++Main image : source ; link c++ executable from compiled sources
98 # ObjC-Main image : source ; link obj-c executable from compiled sources
99 # MainFromObjects image : objects ; link executable from objects
100 # C++MainFromObjects image : objects ; link c++ executable from objects
101 # ObjC-MainFromObjects image : objects ; link obj-c executable from objects
102 # MkDir dir ; make a directory, if not there
103 # Object object : source ; compile object from source
104 # ObjectCcFlags source : flags ; add compiler flags for object
105 # ObjectC++Flags source : flags ; add compiler flags for object
106 # ObjectObjCFlags source : flags ; add compiler flags for object
107 # ObjectHdrs source : dirs ; add include directories for object
108 # Objects sources ; compile sources
109 # RmTemps target : sources ; remove temp sources after target made
110 # Setuid images ; mark executables Setuid
111 # SoftLink target : source ; make symlink from source to target
112 # SubDir TOP d1 d2 ... ; start a subdirectory Jamfile
113 # SubDirCcFlags flags ; add compiler flags until next SubDir
114 # SubDirC++Flags flags ; add compiler flags until next SubDir
115 # SubDirHdrs d1 d2 ... ; add include dir until next SubDir
116 # SubInclude TOP d1 d2 ... ; include a subdirectory Jamfile
117 # Shell exe : source ; make a shell executable
118 # Undefines images : symbols ; save undef's for linking
119 # UserObject object : source ; handle unknown suffixes for Object
120 # Yacc source.c : source.y ; .y -> .c
122 # Utility rules that have no side effects (not supported):
124 # FAppendSuffix f1 f2 ... : $(SUF) ; return $(<) with suffixes
125 # FDirName d1 d2 ... ; return path from root to dir
126 # FGrist d1 d2 ... ; return d1!d2!...
127 # FGristFiles value ; return $(value:G=$(SOURCE_GRIST))
128 # FGristSourceFiles value ; return $(value:G=$(SOURCE_GRIST))
129 # FStripCommon v1 : v2 ; strip common initial parts of v1 v2
130 # FReverse a1 a2 ... ; return ... a2 a1
131 # FRelPath d1 : d2 ; return rel path from d1 to d2
132 # FSubDir d1 d2 ... ; return path to root
136 # Brief review of the jam language:
139 # rule RULE - statements to process a rule
140 # actions RULE - system commands to carry out target update
142 # Modifiers on actions:
143 # together - multiple instances of same rule on target get executed
144 # once with their sources ($(>)) concatenated
145 # updated - refers to updated sources ($(>)) only
146 # ignore - ignore return status of command
147 # quietly - don't trace its execution unless verbose
148 # piecemeal - iterate command each time with a small subset of $(>)
149 # existing - refers to currently existing sources ($(>)) only
150 # bind vars - subject to binding before expanding in actions
153 # Always - always build a target
154 # Depends - builds the dependency graph
155 # Echo - blurt out targets on stdout
156 # Exit - blurt out targets and exit
157 # Includes - marks sources as headers for target (a codependency)
158 # NoCare - don't panic if the target can't be built
159 # NoUpdate - create the target if needed but never update it
160 # NotFile - ignore the timestamp of the target (it's not a file)
161 # Temporary - target need not be present if sources haven't changed
163 # Special variables set by jam:
164 # $(<) - targets of a rule (to the left of the :)
165 # $(>) - sources of a rule (to the right of the :)
166 # $(xxx) - true on xxx (UNIX, VMS, NT, OS2, MAC)
167 # $(OS) - name of OS - varies wildly
168 # $(JAMVERSION) - version number (2.5)
170 # Special variables used by jam:
171 # SEARCH - where to find something (used during binding and actions)
172 # LOCATE - where to plop something not found with SEARCH
173 # HDRRULE - rule to call to handle include files
174 # HDRSCAN - egrep regex to extract include files
177 # all - default if none given on command line
180 # for perforce use -- jambase version
182 #JAMBASEDATE = 2004.10.07 ;
184 #THIS_IS_KJAM = "tan" ; # we are using kjam; removed as obsolete
185 THIS_IS_K8JAM = "tan" ; # we are using k8jam
187 # set to 'tan' for old 'libtool' behavior
188 #!LIBTOOL!#K8_USE_LIBTOOL = ;
191 # Initialize variables
194 ###############################################################################
196 ###############################################################################
198 OPTIM_SPEED = -O3 -march=native -mtune=native -mfpmath=sse ;
199 LINKFLAGS_SPEED = -s ;
201 OPTIM_SIZE = -Os -march=native -mtune=native ;
202 LINKFLAGS_SIZE = -s ;
204 OPTIM_DEBUG = -O0 -g ;
205 LINKFLAGS_DEBUG = -g ;
207 OPTIM_NOALIAS = -fno-strict-aliasing ;
211 # OS specific variable settings
214 ###############################################################################
216 ###############################################################################
218 PATH_SEPARATOR = "\\" ;
219 local SUPPORTED_TOOLSETS =
225 # if the JAM_TOOLSET environment variable is defined, check that it is
226 # one of our supported values
229 if ! $(JAM_TOOLSET) in $(SUPPORTED_TOOLSETS) {
230 Echo "The JAM_TOOLSET environment variable is defined but its value" ;
231 Echo "is invalid, please use one of the following:" ;
233 for t in $(SUPPORTED_TOOLSETS) { Echo " " $(t) ; }
238 if ! $(JAM_TOOLSET) {
239 Echo "The JAM_TOOLSET environment variable is not defined, defaults to MINGW" ;
240 JAM_TOOLSET = MINGW ;
241 MINGW = "c:\\mingw\\" ;
247 RMDIR ?= rmdir /s/q ;
254 if $(JAM_TOOLSET) = MINGW {
255 Echo "Compiler is GCC with MinGW" ;
261 C++FLAGS ?= $(CCFLAGS) ;
264 LINKLIBS ?= -lkernel32 ;
269 # MinGW-specific thingy
270 MINGW_GUI = "-Wl,-subsystem,windows" ;
271 MINGW_THREADS = "-mthreads" ;
273 C++OPTIM ?= $(OPTIM) ;
275 C++LINKFLAGS ?= $(LINKFLAGS) ;
276 C++LINKLIBS ?= $(LINKLIBS) ;
280 CC = "$(MINGW)$(CC:J= )" ;
281 C++ = "$(MINGW)$(C++:J= )" ;
282 LINK = "$(MINGW)$(LINK:J= )" ;
283 C++LINK = "$(MINGW)$(C++LINK:J= )" ;
284 AR = "$(MINGW)$(AR:J= )" ;
285 RANLIB = "$(MINGW)$(RANLIB:J= )" ;
287 } else if $(JAM_TOOLSET) = LCC {
288 Echo "Compiler is Win32-LCC" ;
300 } else if $(JAM_TOOLSET) = PELLESC {
301 Echo "Compiler is PellesC" ;
311 LINKLIBS ?= crt.lib oldnames.lib Win\\kernel32.lib ;
315 # XXX: We need better comments here !!
316 Exit "On NT, set MINGW to the root of the MinGW dir (but it won't help you anyway)" ;
321 ###############################################################################
323 ###############################################################################
325 PATH_SEPARATOR = "/" ;
329 CCFLAGS += -D__cygwin__ ;
342 OBJCFLAGS ?= $(CCFLAGS) ;
343 C++FLAGS ?= $(CCFLAGS) ;
348 LINKFLAGS ?= $(CCFLAGS) ;
356 #!LIBTOOL!# if $(K8_USE_LIBTOOL) {
357 #!LIBTOOL!# SUFOBJSHR ?= .lo ;
358 #!LIBTOOL!# SUFLIBSHR ?= .la ;
360 #!LIBTOOL!# SUFOBJSHR ?= .o ;
361 #!LIBTOOL!# SUFLIBSHR ?= .so ;
367 STDHDRS ?= /usr/include ;
370 # shared library object file suffix. We assume that it is identical
371 # than the normal one
372 SUFOBJSHR ?= $(SUFOBJ) ;
373 SUFLIBSHR ?= $(SUFLIB) ;
380 # General defaults; a lot like UNIX
382 PATH_SEPARATOR ?= "/" ;
387 BINDIR ?= /usr/local/bin ;
388 C++ ?= g++ ; # k8: was cc
390 CC ?= gcc ; # k8: was cc
399 INSTALLGRIST ?= installed ;
401 JAMRULES ?= Jamrules ;
403 LIBDIR ?= /usr/local/lib ;
408 MANDIR ?= /usr/local/man ;
417 SHELLHEADER ?= "#!/bin/sh" ;
421 SUBDIRRESET ?= ASFLAGS HDRS C++FLAGS CCFLAGS ;
425 UNDEFFLAG ?= "-u _" ;
431 HDRPATTERN = "^[[:space:]]*#[[:space:]]*include[[:space:]]*[<\"]([^\">]*)[\">].*$" ;
433 OSFULL = $(OS)$(OSVER)$(OSPLAT) $(OS)$(OSPLAT) $(OS)$(OSVER) $(OS) ;
436 C++OPTIM ?= $(OPTIM) ;
438 C++LINKFLAGS ?= $(LINKFLAGS) ;
439 C++LINKLIBS ?= $(LINKLIBS) ;
441 OBJCOPTIM ?= $(OPTIM) ;
443 OBJCLINKFLAGS ?= $(LINKFLAGS) ;
444 OBJCLINKLIBS ?= $(LINKLIBS) ;
445 OBJCLINKLIBS += -lobjc ;
448 if ( "gcc" in $(CC) ) && ! ( "-pipe" in $(CC) ) { CC += -pipe ; }
449 if ( "g++" in $(C++) ) && ! ( "-pipe" in $(C++) ) { C++ += -pipe ; }
453 #Echo "OSFULL:" $(OSFULL) ;
454 #Echo "UNIX:" $(UNIX) ;
459 # Base dependencies - first for "bootstrap" kinds of rules
461 Depends all : shell files lib exe obj ;
462 Depends all shell files lib exe obj : first ;
463 NotFile all first shell files lib exe obj dirs clean uninstall ;
464 Always clean uninstall ;
470 # /As object : source ;
472 # Assemble the file _source_, called by the @Object rule.
474 # Do not call this rule directly, since _object_ and _source_ may have
475 # have platform-specific file extensions
478 Depends $(<) : $(>) ;
479 ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ;
480 ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ;
483 # /Bulk directory : sources ;
485 # Copies _sources_ into _directory_
491 File $(i:D=$(<)) : $(i) ;
496 # /Dc object : source ;
498 # Compile the file source into object, usin the D compiler $(DC), its
499 # flags $(DCFLAGS) and $(DOPTIM)
500 # Called by the @Object rule
502 # Do not call this rule directly, since _object_ and _source_ may have
503 # have platform-specific file extensions
506 Depends $(<) : $(>) ;
507 # Just to clarify here: this sets the per-target DCFLAGS to
508 # be the current value of (global) DCFLAGS and SUBDIRDCFLAGS.
509 DCFLAGS on $(<) += $(DCFLAGS) $(SUBDIRDCFLAGS) ;
513 # /Cc object : source ;
515 # Compile the file source into object, using the C compiler $(CC), its
516 # flags $(CCFLAGS) and $(OPTIM), and the header file directories $(HDRS).
517 # Called by the @Object rule
519 # Do not call this rule directly, since _object_ and _source_ may have
520 # have platform-specific file extensions
523 Depends $(<) : $(>) ;
525 # If the compiler's -o flag doesn't work, relocate the .o
526 if $(RELOCATE) { CcMv $(<) : $(>) ; }
528 # Just to clarify here: this sets the per-target CCFLAGS to
529 # be the current value of (global) CCFLAGS and SUBDIRCCFLAGS.
530 # CCHDRS and CCDEFS must be reformatted each time for some
531 # compiles (VMS, NT) that malign multiple -D or -I flags.
532 CCFLAGS on $(<) += $(CCFLAGS) $(SUBDIRCCFLAGS) ;
533 CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
534 CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
538 # /C++ object : source ;
540 # Compile the C++ source file _source_. Similar to @CC, called by @Object
542 # Do not call this rule directly, since _object_ and _source_ may have
543 # have platform-specific file extensions
548 Depends $(<) : $(>) ;
550 if $(RELOCATE) { CcMv $(<) : $(>) ; }
552 # Just to clarify here: this sets the per-target CCFLAGS to
553 # be the current value of (global) CCFLAGS and SUBDIRCCFLAGS.
554 # CCHDRS and CCDEFS must be reformatted each time for some
555 # compiles (VMS, NT) that malign multiple -D or -I flags.
557 if ! $(ktmp) { ktmp = $(CCFLAGS) ; }
558 C++FLAGS on $(<) += $(ktmp) $(SUBDIRC++FLAGS) ;
561 if ! $(ktmp) { ktmp = $(OPTIM) ; }
562 C++OPTIM on $(<) += $(ktmp) ;
564 CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
565 CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
569 # /ObjC object : source ;
571 # Compile the ObjC source file _source_. Similar to @CC, called by @Object
573 # Do not call this rule directly, since _object_ and _source_ may have
574 # have platform-specific file extensions
579 Depends $(<) : $(>) ;
581 if $(RELOCATE) { CcMv $(<) : $(>) ; }
583 # Just to clarify here: this sets the per-target CCFLAGS to
584 # be the current value of (global) CCFLAGS and SUBDIRCCFLAGS.
585 # CCHDRS and CCDEFS must be reformatted each time for some
586 # compiles (VMS, NT) that malign multiple -D or -I flags.
587 ktmp = $(OBJCFLAGS) ;
588 if ! $(ktmp) { ktmp = $(CCFLAGS) ; }
589 OBJCFLAGS on $(<) += $(ktmp) $(SUBDIROBJCFLAGS) ;
591 ktmp = $(OBJCOPTIM) ;
592 if ! $(ktmp) { ktmp = $(OBJCOPTIM) ; }
593 OBJCOPTIM on $(<) += $(ktmp) ;
595 CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
596 CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
602 # (Unix and VMS only). Change file permissions on _target_ to target-specific
603 # $(MODE) value set by @Link, @File, @Install* and @Shell rules
606 if $(CHMOD) { Chmod1 $(<) ; }
609 # /Clean clean : targets ;
611 # Removes existing _targets_ when _clean_ is built. clean is not a dependency
612 # of all, and must be built explicitely for targets to be removed
616 # /File target : source ;
618 # Copies _source_ into _target_
621 Depends files : $(<) ;
622 Depends $(<) : $(>) ;
623 SEARCH on $(>) = $(SEARCH_SOURCE) ;
624 MODE on $(<) = $(FILEMODE) ;
629 # /GenFile target : image sources ;
631 # Runs the command "_image_ _target_ _sources_" to create _target_ from
632 # _sources_ and _image_ (where _image_ is an executable built by the
636 local _t = [ FGristSourceFiles $(<) ] ;
637 local _s = [ FAppendSuffix $(>[1]) : $(SUFEXE) ] ;
638 Depends $(_t) : $(_s) $(>[2-]) ;
639 GenFile1 $(_t) : $(_s) $(>[2-]) ;
640 Clean clean : $(_t) ;
644 MakeLocate $(<) : $(LOCATE_SOURCE) ;
645 SEARCH on $(>) = $(SEARCH_SOURCE) ;
649 # /HardLink target : source ;
651 # Makes _target_ a hard link to _source_, if it isn't one already
655 Depends files : $(<) ;
656 Depends $(<) : $(>) ;
657 SEARCH on $(>) = $(SEARCH_SOURCE) ;
663 # this rule is specific to FT-Jam. It is used to indicate that a given file
664 # contains definitions for filename macros (e.g. "#define MYFILE_H <myfile>.h")
665 # that can later be used in #include statements in the rest of the source
667 # these files must be parsed before any make is tried.
674 # /HdrRule source : headers ;
676 # Arranges the proper dependencies when the file _source_ includes the files
677 # _headers_ through the #include C preprocessor directive
679 # this rule is not intendend to be called explicitely. It is called
680 # automatically during header scanning on sources handled by the @Object
681 # rule (e.g. sources in @Main or @Library rules)
684 # HdrRule source : headers ;
686 # N.B. This rule is called during binding, potentially after
687 # the fate of many targets has been determined, and must be
688 # used with caution: don't add dependencies to unrelated
689 # targets, and don't set variables on $(<).
691 # Tell Jam that anything depending on $(<) also depends on $(>),
692 # set SEARCH so Jam can find the headers, but then say we don't
693 # care if we can't actually find the headers (they may have been
696 local s = $(>:G=$(HDRGRIST:E)) ;
698 Includes $(<) : $(s) ;
699 SEARCH on $(s) = $(HDRSEARCH) ;
702 # Propagate on $(<) to $(>)
704 HDRSEARCH on $(s) = $(HDRSEARCH) ;
705 HDRSCAN on $(s) = $(HDRSCAN) ;
706 HDRRULE on $(s) = $(HDRRULE) ;
707 HDRGRIST on $(s) = $(HDRGRIST) ;
711 # /Lex source.c : source.l ;
713 # Process the lex source file _source.l_ and rename the lex.yy.c
714 # to _source.c_ . Called by the @Object rule
717 ##LexMv $(<) : $(>) ;
718 Depends $(<) : $(>) ;
719 MakeLocate $(<) : $(LOCATE_SOURCE) ;
724 # /Library library : sources ;
726 # Compiles _sources_ and archives them into _library_. The intermediate
727 # objects are deleted. Calles @Object and @LibraryFromObjects
729 # If @Library is invoked with no suffix on _library_, the $(SUFLIB)
733 LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
738 # /SharedLibrary library : sources : def : import ;
740 # Compiles _sources_ and generates a shared _library_ (i.e. DLL on Windows,
741 # or shared object on Unix). Calls @SharedObjects and @SharedLibraryFromObjects
743 # If @SharedLibrary is invoked with no suffix on _library_, then
744 # $(SUFLIBSHR) suffix is used
746 # _def_ is the name of the corresponding definition file used to generate
747 # the library on Windows and OS/2 (ignored otherwise). If undefined, it
748 # will default to _library_ with the .def suffix
750 # _import_ is the name of the corresponding import library for Windows
751 # and OS/2 platforms (ignored otherwise). If undefined, it will default
752 # to _library_ with the .dll.lib suffix.
755 #Echo "SharedLibrary: $(<)" ; #dbg
756 #Echo "SharedLibrary: $(>:S=$(SUFOBJSHR))" ; #dbg
757 #Echo "SharedLibrary: $(3)" ; #dbg
758 #Echo "SharedLibrary: $(4)" ; #dbg
759 SharedLibraryFromObjects $(<) : $(>:S=$(SUFOBJSHR)) : $(3) : $(4) ;
763 ######################################################
765 ######################################################
766 #!LIBTOOL!#if $(UNIX) {
767 #!LIBTOOL!# # this rule is used to find the 'libtool' script in the current
768 #!LIBTOOL!# # path, this is required when compiling shared objects on Unix
769 #!LIBTOOL!# rule LibToolFind {
770 #!LIBTOOL!# if $(LIBTOOL) { return $(LIBTOOL) ; }
771 #!LIBTOOL!# local matches = [ Glob $(PATH) : libtool ] ;
772 #!LIBTOOL!# if ! $(matches) { Exit "could not find 'libtool' program in current path. Aborting !" ; }
773 #!LIBTOOL!# LIBTOOL = $(matches[1]) ;
774 #!LIBTOOL!# return $(LIBTOOL) ;
779 # /LibraryFromObjects library : objects ;
781 # Archives _objects_ into _library_. The _objects_ are then deleted
783 # If _library_ has no suffix, the $(SUFLIB) suffix is used
785 # Called by @Library rule. Most people should never call this rule
788 rule LibraryFromObjects {
791 # Add grist to file names
792 _s = [ FGristFiles $(>) ] ;
793 _l = $(<:S=$(SUFLIB)) ;
795 # library depends on its member objects
797 Depends obj : $(_s) ;
799 Depends lib : $(_l) ;
802 # Set LOCATE for the library and its contents. The bound
803 # value shows up as $(NEEDLIBS) on the Link actions.
804 # For compatibility, we only do this if the library doesn't
805 # already have a path.
807 #!!MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ;
808 MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_LIB) ;
812 # If we can't scan the library to timestamp its contents,
813 # we have to just make the library depend directly on the
814 # on-disk object files.
815 Depends $(_l) : $(_s) ;
817 # If we can scan the library, we make the library depend
818 # on its members and each member depend on the on-disk
820 Depends $(_l) : $(_l)($(_s:BS)) ;
822 Depends $(_l)($(_i:BS)) : $(_i) ;
826 Clean clean : $(_l) ;
828 if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
830 Archive $(_l) : $(_s) ;
832 if $(RANLIB) { Ranlib $(_l) ; }
834 # If we can't scan the library, we have to leave the .o's around.
835 if ! ( $(NOARSCAN) || $(NOARUPDATE) ) { RmTemps $(_l) : $(_s) ; }
839 # /SharedLibraryFromObjects library : objects : def : import ;
841 # Equivalent of @LibraryFromObjects for shared libraries.
843 # Called by @SharedLibrary. Most people shouldn't call this rule
846 rule SharedLibraryFromObjects {
849 # Add grist to file names
850 _s = [ FGristFiles $(>) ] ;
851 _l = $(<:S=$(SUFLIBSHR)) ;
853 #Echo "Library is $(_l)" ;
854 # library depends on its member objects
856 Depends obj : $(_s) ;
858 Depends lib : $(_l) ;
861 # Set LOCATE for the library and its contents. The bound
862 # value shows up as $(NEEDLIBS) on the Link actions.
863 # For compatibility, we only do this if the library doesn't
864 # already have a path.
866 #!!MakeLocate $(_l) : $(LOCATE_TARGET) ;
867 MakeLocate $(_l) : $(LOCATE_LIBSO) ;
870 #Echo "SharedLibraryFromObjects: _s = $(_s)" ; #dbg
871 #Echo "SharedLibraryFromObjects: _l = $(_l)" ; #dbg
873 # we never scan shared libraries for member objects
874 Depends $(_l) : $(_s) ;
876 Clean clean : $(_l) ;
878 # I don't know if VMS supports shared libraries, so I prefer
879 # to disable the following right now
881 #if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
883 # creating the library is so much fun on Unix :-)
885 #!LIBTOOL!# if $(K8_USE_LIBTOOL) {
886 #!LIBTOOL!# local libtool = [ LibToolFind ] ; # find the right libtool
887 #!LIBTOOL!# AR on $(_l) = "$(libtool) --mode=link $(AR:J= )" ;
889 LINKFLAGS on $(_l) += "-shared" ;
890 C++LINKFLAGS on $(_l) += "-shared" ;
891 LinkUnixLibrary $(_l) : $(_s) ;
894 local _implib = $(4) ;
897 _implib ?= $(_l:S=$(SUFLIBSHR)$(SUFLIB)) ;
898 _def ?= $(_l:S=.def) ;
900 Clean clean : $(_implib) ;
901 Depends lib : $(_implib) $(_def) ;
903 Depends $(_implib) : $(_def) $(_l) ;
904 Depends $(_l) : $(_def) ;
906 DEFFILENAME on $(_l) = $(_def) ;
907 IMPLIBNAME on $(_l) = $(_implib) ;
909 #!!MakeLocate $(_implib) : $(LOCATE_TARGET) ;
910 #!!MakeLocate $(_implib:S=.exp) : $(LOCATE_TARGET) ;
911 MakeLocate $(_implib) : $(LOCATE_LIBSO) ;
912 MakeLocate $(_implib:S=.exp) : $(LOCATE_LIBSO) ;
914 if $(JAM_TOOLSET) in VISUALC BORLANDC LCC WATCOM DIGITALMARS {
915 SharedLink-$(JAM_TOOLSET) $(_l) : $(_s) : $(_implib) : $(_def) ;
917 DllLink $(_l) : $(_s) ;
919 Echo "Sorry, I don't know how to make a shared library on your system" ;
920 Exit "Please *DON'T* contact the K8Jam maintainer for help" ;
925 # Since building shared libraries is so different depending on the
926 # compiler being used, I've broken this task into compiler-specific
929 rule SharedLink-LCC {
930 Echo "Sorry, but generating DLLs with LCC is not supported. That's" ;
931 Echo "because the 'lcclnk' tool that comes with this compiler is" ;
932 Echo "unreliable and doesn't work as expected." ;
935 # the 'lcclnk' tool is absolutely broken:
936 # - its -o flag doesn't work when there is a LIBRARY statement
939 # - it uses the LIBRARY name in the .def file to determine
940 # the name of the dll and its import library, and always
941 # places them in the current directory !!
943 # - if there is no LIBRARY statement, the -o flag is only
944 # used to determine where the DLL is placed, the import
945 # library will always be placed in the current directory !!
948 # clean the .exp file too, don't know how to get rid of it
949 Clean clean : $(4:S=.exp) ;
953 # /Link image : objects ;
955 # Links _image_ from _objects_ and sets permissions on _image_ to
956 # $(EXEMODE). _image_ must be an actual filename; suffix is not
959 # Called by @Main, shouldn't be called by most people
962 MODE on $(<) = $(EXEMODE) ;
967 # /C++Link image : objects ;
969 # Links _image_ from _objects_ and sets permissions on _image_ to
970 # $(EXEMODE). _image_ must be an actual filename; suffix is not
973 # Called by @Main, shouldn't be called by most people
976 MODE on $(<) = $(EXEMODE) ;
981 MODE on $(<) = $(EXEMODE) ;
986 # /LinkLibraries image : libraries ;
988 # Makes _image_ depend on _libraries_ and includes them during linking
990 # _image_ may be referenced without a suffix in this rule invocation.
991 # @LinkLibraries supplies the suffix
993 # You should only use this rule with libraries created through the
994 # @Library rule. For external libraries, use something else (XXX)
997 # make library dependencies of target
998 # set NEEDLIBS variable used by 'actions Main'
999 local _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1001 Depends $(_t) : $(>:S=$(SUFLIB)) ;
1002 NEEDLIBS on $(_t) += $(>:S=$(SUFLIB)) ;
1006 # /LinkSharedLibraries image : libraries :
1008 # Same as @LinkLibraries, but to link _image_ with shared libraries
1009 # generated through the @SharedLibrary rule
1011 rule LinkSharedLibraries {
1012 # make library dependencies of target
1013 # set NEEDLIBS variable used by 'actions Main'
1014 local _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1015 local _ext = $(SUFLIBSHR) ;
1018 # on NT, we need to link agains the import library, not the DLL itself !!
1019 _ext = $(SUFLIBSHR)$(SUFLIB) ;
1021 Depends $(_t) : $(>:S=$(_ext)) ;
1022 NEEDLIBS on $(_t) += $(>:S=$(_ext)) ;
1026 # /Main image : sources ;
1028 # Compiles _sources_ and links them into _image_. Calls @Objects and
1031 # _image_ may be supplied without suffix.
1034 MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1039 # /C++Main image : sources ;
1041 # Compiles _sources_ and links them into _image_. Calls @Objects and
1042 # @C++MainFromObjects.
1044 # _image_ may be supplied without suffix.
1047 C++MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1052 ObjC-MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1057 # /MainFromObjects image : objects ;
1059 # Links _objects_ into _image_. Dependency of exe.
1060 # @MainFromObjects provides a default suffix for _image_
1062 rule MainFromObjects {
1065 # Add grist to file names
1067 _s = [ FGristFiles $(>) ] ;
1068 _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1069 # so 'jam foo' works when it's really foo.exe
1072 Depends $(<) : $(_t) ;
1076 # make compiled sources a dependency of target
1077 Depends exe : $(_t) ;
1078 Depends $(_t) : $(_s) ;
1079 #k8:MakeLocate $(_t) : $(LOCATE_TARGET) ;
1080 MakeLocate $(_t) : $(LOCATE_BIN) ;
1081 Clean clean : $(_t) ;
1083 # special case for stupid Borland C++, which always generates a
1084 # .tds file for executables, even when no debug information is needed
1086 #if $(JAM_TOOLSET) = BORLANDC {
1087 # MakeLocate $(_t:S=.tds) : $(LOCATE_TARGET) ;
1088 # Clean clean : $(_t:S=.tds) ;
1091 Link $(_t) : $(_s) ;
1095 # /C++MainFromObjects image : objects ;
1097 # Links _objects_ into _image_. Dependency of exe.
1098 # @MainFromObjects provides a default suffix for _image_
1100 rule C++MainFromObjects {
1103 # Add grist to file names
1105 _s = [ FGristFiles $(>) ] ;
1106 _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1107 # so 'jam foo' works when it's really foo.exe
1110 Depends $(<) : $(_t) ;
1114 # make compiled sources a dependency of target
1115 Depends exe : $(_t) ;
1116 Depends $(_t) : $(_s) ;
1117 #k8:MakeLocate $(_t) : $(LOCATE_TARGET) ;
1118 MakeLocate $(_t) : $(LOCATE_BIN) ;
1119 Clean clean : $(_t) ;
1121 # special case for stupid Borland C++, which always generates a
1122 # .tds file for executables, even when no debug information is needed
1124 #if $(JAM_TOOLSET) = BORLANDC {
1125 # MakeLocate $(_t:S=.tds) : $(LOCATE_TARGET) ;
1126 # Clean clean : $(_t:S=.tds) ;
1129 C++Link $(_t) : $(_s) ; ###k8:FIXME
1133 rule ObjC-MainFromObjects {
1136 # Add grist to file names
1138 _s = [ FGristFiles $(>) ] ;
1139 _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1140 # so 'jam foo' works when it's really foo.exe
1143 Depends $(<) : $(_t) ;
1147 # make compiled sources a dependency of target
1148 Depends exe : $(_t) ;
1149 Depends $(_t) : $(_s) ;
1150 #k8:MakeLocate $(_t) : $(LOCATE_TARGET) ;
1151 MakeLocate $(_t) : $(LOCATE_BIN) ;
1152 Clean clean : $(_t) ;
1154 ObjC-Link $(_t) : $(_s) ; ###k8:FIXME
1158 # /MakeLocate targets : directory
1160 # Creates _dir_ and causes _target_ to be built into _dir_
1162 # This is done by setting the target-specific variable LOCATE
1163 # on _targets_, and arranges with @MkDir to create the target
1167 # Note we grist the directory name with 'dir',
1168 # so that directory path components and other
1169 # targets don't conflict.
1170 local srcname = $(<[1]:G=) ;
1171 local srcdir = $(srcname:D) ;
1172 local outdir = $(>[1]:G=dir) ;
1175 odir = $(outdir)$(PATH_SEPARATOR)$(srcdir) ;
1179 #Echo "MakeLocate:" "$(<)" "|" "$(>)" ;
1180 #Echo "srcname:" "$(srcname)" ;
1181 #Echo "srcdir :" "$(srcdir)" ;
1182 #Echo "outdir :" "$(outdir)" ;
1183 #Echo "odir :" "$(odir)" ;
1185 LOCATE on $(<) = $(>) ;
1186 Depends $(<) : $(odir) ;
1194 # Creates _dir_ and its parent directories
1197 # Ignore timestamps on directories: we only care if they exist.
1200 # Don't create . or any directory already created.
1201 if $(<:G=) != $(DOT) && ! $($(<)-mkdir) {
1202 # Cheesy gate to prevent multiple invocations on same dir
1203 # Arrange for jam dirs
1204 # MkDir1 has the actions
1206 Depends dirs : $(<) ;
1209 # Recursively make parent directories.
1210 # $(<:P) = $(<)'s parent, & we recurse until root
1213 # Don't try to create A: or A:\ on windows
1220 # handle "C:", "C:/", "/cygdrive" and "/cygdrive/" in Cygwin
1221 if $(UNIX) && $(OS) = CYGWIN {
1225 case "<dir>/cygdrive" : s = ;
1226 case "<dir>/cygdrive/" : s = ;
1231 # The parent is the same as the dir.
1232 # We're at the root, which some OS's can't stat, so we mark
1236 # There's a parent; recurse.
1237 Depends $(<) : $(s) ;
1244 # /Object object : source ;
1246 # Compile s a single _source_ file into _object_. The @Main and @Library
1247 # rules use it to compile sources.
1249 # Causes _source_ to be scanned for #include directives and calls @HdrRule
1250 # to make all included files dependencies of _object_.
1252 # Calls one of the following rules depending on the suffix to do the
1253 # actual compilation:
1256 # locate object and search for source, if wanted
1258 Clean clean : $(<) ;
1259 MakeLocate $(<) : $(LOCATE_TARGET) ;
1260 SEARCH on $(>) = $(SEARCH_SOURCE) ;
1262 # Save HDRS for -I$(HDRS) on compile.
1263 # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers
1264 # in the .c file's directory, but generated .c files (from
1265 # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly
1266 # different from $(SEARCH_SOURCE).
1267 HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ;
1269 # handle #includes for source: Jam scans for headers with
1270 # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
1271 # with the scanned file as the target and the found headers
1272 # as the sources. HDRSEARCH is the value of SEARCH used for
1273 # the found header files. Finally, if jam must deal with
1274 # header files of the same name in different directories,
1275 # they can be distinguished with HDRGRIST.
1277 # $(SEARCH_SOURCE:E) is where cc first looks for #include
1278 # "foo.h" files. If the source file is in a distant directory,
1279 # look there. Else, look in "" (the current directory).
1281 HDRRULE on $(>) = HdrRule ;
1282 HDRSCAN on $(>) = $(HDRPATTERN) ;
1283 HDRSEARCH on $(>) = $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ;
1284 HDRGRIST on $(>) = $(HDRGRIST) ;
1286 # propagate target specific-defines
1287 DEFINES on $(<) += $(DEFINES) ;
1289 if $(WINDOZE) && $(>:S) = ".rc" {
1290 WindozeResourceCompiler $(<) : $(>) ;
1291 } else if $(WINDOZE) && $(>:S) = ".o" {
1294 # if source is not .c, generate .c with specific rule
1296 case .asm : As $(<) : $(>) ;
1297 case .c : Cc $(<) : $(>) ;
1298 case .C : C++ $(<) : $(>) ;
1299 case .cc : C++ $(<) : $(>) ;
1300 case .cpp : C++ $(<) : $(>) ;
1301 case .cxx : C++ $(<) : $(>) ;
1302 case .c++ : C++ $(<) : $(>) ;
1303 case .C++ : C++ $(<) : $(>) ;
1304 case .m : ObjC $(<) : $(>) ;
1305 case .d : Dc $(<) : $(>) ;
1306 case .l : Cc $(<) : $(<:S=.c) ;
1307 Lex $(<:S=.c) : $(>) ;
1308 case .s : As $(<) : $(>) ;
1309 case .y : Cc $(<) : $(<:S=$(YACCGEN)) ;
1310 Yacc $(<:S=$(YACCGEN)) : $(>) ;
1311 case * : UserObject $(<) : $(>) ;
1317 # /ObjectCcFlags sources : flags ;
1319 # this rule is used to add compiler flags to the compilation of
1320 # specific C sources files.
1322 rule ObjectCcFlags {
1323 CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1327 # /ObjectC++Flags sources : flags ;
1329 # this rule is used to add compiler flags to the compilation of
1330 # specific C++ source files
1332 rule ObjectC++Flags {
1333 C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1337 rule ObjectObjCFlags {
1338 OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1342 # /LinkFlagsOn mains : flags ;
1344 # this rule is used to add compiler flags to the compilation of
1345 # specific C sources files.
1348 LINKFLAGS on [ FGristFiles $(<) ] += $(>) ;
1352 # /C++LinkFlagsOn mains : flags ;
1354 # this rule is used to add compiler flags to the compilation of
1355 # specific C++ source files
1357 rule C++LinkFlagsOn {
1358 C++LINKFLAGS on [ FGristFiles $(<) ] += $(>) ;
1362 rule ObjCLinkFlagsOn {
1363 OBJCLINKFLAGS on [ FGristFiles $(<) ] += $(>) ;
1367 # /ObjectDefines objects : macros ;
1369 # this rule is used to add macro defines to the compilation of
1370 # specific C and C++ source files
1372 rule ObjectDefines {
1373 # must reformat CCDEFS according to current defines
1374 local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
1376 DEFINES on $(s) += $(>) ;
1377 CCDEFS on $(s) = [ on $(s) FDefines $(DEFINES) ] ;
1381 # /ObjectHdrs sources : paths ;
1383 # this rule is used to add include paths to the compilation of
1384 # specific C and C++ source files
1387 # Add to HDRS for HdrScan's benefit.
1388 # must reformat CCHDRS according to headers
1389 local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
1391 HDRS on $(s) += $(>) ;
1392 CCHDRS on $(s) = [ on $(s) FIncludes $(HDRS) ] ;
1396 # /Objects sources ;
1398 # this rule is used to compile one or more sources into object files.
1399 # do not call it directly, it is used by the Main and Library rules
1405 for _i in [ FGristFiles $(<) ] {
1406 Object $(_i:S=$(SUFOBJ)) : $(_i) ;
1407 Depends obj : $(_i:S=$(SUFOBJ)) ;
1414 # this rule is used to compile one or more sources into 'shared object
1415 # files'. This means object files used to build either DLLs or Unix shared
1418 # do not call this rule directly, it is called by SharedLibrary automatically
1420 rule SharedObjects {
1421 # temporarily override SUFOBJ with $(SUFOBJSHR) to
1422 local SUFOBJ = $(SUFOBJSHR) ;
1424 # call the normal Objects rule
1427 # add the compiler-specific position-independent-code flag where needed
1428 ObjectCcFlags $(<) : $(PICFLAGS) ;
1430 # change the compiler invokation for all these objects
1431 # to use Libtool on Unix systems. We explicitely disable the
1432 # generation of static objects here
1433 #!LIBTOOL!# if $(UNIX) {
1434 #!LIBTOOL!# #libtool on $(<:S=$(SUFOBJ)) = [ LibToolFind ] ;
1435 #!LIBTOOL!# if $(K8_USE_LIBTOOL) {
1436 #!LIBTOOL!# local libtool = [ LibToolFind ] ;
1437 #!LIBTOOL!# CC on $(<:S=$(SUFOBJ)) = "$(libtool) --mode=compile $(CC:J= ) -dynamic" ;
1438 #!LIBTOOL!# C++ on $(<:S=$(SUFOBJ)) = "$(libtool) --mode=compile $(C++:J= ) -dynamic" ; #k8:?
1450 MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;
1455 Depends shell : $(<) ;
1456 Depends $(<) : $(>) ;
1457 SEARCH on $(>) = $(SEARCH_SOURCE) ;
1458 MODE on $(<) = $(SHELLMODE) ;
1459 Clean clean : $(<) ;
1465 Depends files : $(<) ;
1466 Depends $(<) : $(>) ;
1467 SEARCH on $(>) = $(SEARCH_SOURCE) ;
1468 Clean clean : $(<) ;
1474 # SubDir TOP d1 d2 ... ;
1476 # Support for a project tree spanning multiple directories.
1478 # SubDir declares a Jamfile's location in a project tree, setting
1479 # Jambase variables (SEARCH_SOURCE, LOCATE_TARGET) so that source
1480 # files can be found.
1482 # TOP is a user-select variable name for root of the tree, and
1483 # d1 d2 ... are the directory elements that lead from the root
1484 # of the tree to the directory of the Jamfile.
1486 # TOP can be set externally, but normally the first SubDir call
1487 # computes TOP as the path up from the current directory; the
1488 # path contains one ../ for each of d1 d2 ...
1490 # SubDir reads once the project-specific rules file Jamrules
1491 # in the TOP directory, if present. This can be overridden
1492 # with the variable TOPRULES.
1494 # SubDir supports multiple, overlaid project trees: SubDir
1495 # invocations with different TOPs can appear in the same Jamfile.
1496 # The location established by the first SubDir call is used set
1497 # the TOPs for the subsequent SubDir calls.
1499 # SubDir's public variables:
1501 # $(TOP) = path from CWD to root.
1502 # $(SUBDIR) = path from CWD to the directory SubDir names.
1503 # $(SUBDIR_TOKENS) = path from $(TOP) to $(SUBDIR) as dir names
1504 # $(SEARCH_SOURCE) = $(SUBDIR)
1505 # $(LOCATE_SOURCE) = $(ALL_LOCATE_TARGET) $(SUBDIR)
1506 # $(LOCATE_TARGET) = $(ALL_LOCATE_TARGET) $(SUBDIR)
1507 # $(LOCATE_BIN) = $(ALL_LOCATE_BIN) $(ALL_LOCATE_TARGET) $(SUBDIR)
1508 # $(LOCATE_LIB) = $(ALL_LOCATE_LIB) $(ALL_LOCATE_TARGET) $(SUBDIR)
1509 # $(LOCATE_LIBSO) = $(ALL_LOCATE_LIBSO) $(ALL_LOCATE_LIB) $(ALL_LOCATE_TARGET) $(SUBDIR)
1510 # $(SOURCE_GRIST) = $(SUBDIR_TOKENS) with !'s
1512 local _top = $(<[1]) ;
1513 local _tokens = $(<[2-]) ;
1517 # First time through sets up relative root and includes Jamrules.
1518 if ! $(_top) { Exit "SubDir syntax error" ; }
1520 if ! $($(_top)-SET) {
1521 $(_top)-SET = true ;
1522 # First time we've seen this TOP.
1523 # We'll initialize a number of internal variables:
1525 # $(TOP-UP) = directories from ROOT to a common point
1526 # $(TOP-DOWN) = directories from common point to TOP
1527 # $(TOP-ROOT) = root directory for UP/DOWN -- normally CWD
1528 # $(SUBDIR_UP) = current value of $(TOP-UP)
1529 # $(SUBDIR_DOWN) = current value of $(TOP-DOWN)
1530 # $(SUBDIR_ROOT) = current value of $(TOP-ROOT)
1533 # TOP externally set.
1534 # We'll ignore the relative (UP/DOWN) path that
1535 # got us here, and instead remember the hard ROOT.
1538 $(_top)-ROOT = $($(_top)) ;
1542 # Establishing a new TOP. In the simplest case,
1543 # (SUBDIR_UP/SUBDIR_DOWN/SUBDIR_ROOT unset), it's
1544 # merely a certain number of directories down from
1545 # the current directory, and FSubDirPath will set
1546 # TOP to a path consisting of ../ for each of the
1547 # elements of _tokens, because that represents how
1548 # far below TOP the current directory sits.
1550 # In the more complicated case, the starting directory
1551 # isn't the directory of jam's invocation but an
1552 # location established by previous SubDir call. The
1553 # starting directory is SUBDIR_UP directories up from
1554 # SUBDIR_ROOT, and then SUBDIR_DOWN directories down
1555 # from that. If SUBDIR_ROOT is not set, that means
1556 # SUBDIR_DOWN and SUBDIR_UP represent the path from
1557 # the directory of jam's invocation.
1559 # In the most complicated case, the _tokens also
1560 # represents directories down, because TOP is being
1561 # estalished in a directory other than TOP's root.
1562 # Hopefully, _tokens and SUBDIR_DOWN represent the
1563 # same final directory, relative to the new TOP and
1564 # the previous SubDIr's TOP. To find the new TOP,
1565 # we have to chop off any common directories from
1566 # then ends of _tokens and SUBDIR_DOWN. To do so,
1567 # we reverse each of them, call FStripCommon to
1568 # remove the initial common elements, and then
1569 # reverse them again. After this process, if
1570 # both _tokens and SUBDIR_DOWN have elements, it
1571 # means the directory names estalished by the two
1572 # SubDir calls don't match, and a warning is issued.
1573 # All hell will likely break loose at this point,
1574 # since the whole SubDir scheme relies on the SubDir
1575 # calls accurately naming the current directory.
1577 # Strip common trailing elements of _tokens and SUBDIR_DOWN.
1578 _tokens = [ FReverse $(_tokens) ] ;
1579 SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
1580 FStripCommon _tokens : SUBDIR_DOWN ;
1581 SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
1582 _tokens = [ FReverse $(_tokens) ] ;
1584 if $(SUBDIR_DOWN) && $(_tokens) { Echo "Warning:" SubDir $(<) "misplaced!" ; }
1586 # We'll remember the relative (UP/DOWN) path that
1587 # got us here, plus any hard ROOT starting point
1588 # for the UP/DOWN. If TOP is never set externally,
1589 # ROOT will always be "" (directory of jam's invocation).
1590 $(_top)-UP = $(SUBDIR_UP) $(_tokens) ;
1591 $(_top)-DOWN = $(SUBDIR_DOWN) ;
1592 $(_top)-ROOT = $(SUBDIR_ROOT:E="") ;
1593 $(_top) = [ FSubDirPath $(_top) ] ;
1596 # Set subdir vars for the inclusion of the Jamrules,
1597 # just in case they have SubDir rules of their own.
1598 # Note that SUBDIR_DOWN is empty: it's all the way
1599 # up where the Jamrules live. These gets overrided
1600 # just after the inclusion.
1601 SUBDIR_UP = $($(_top)-UP) ;
1603 SUBDIR_ROOT = $($(_top)-ROOT) ;
1605 # Include $(TOPRULES) or $(TOP)/Jamrules.
1606 # Include $(TOPRULES) if set.
1607 # Otherwise include $(TOP)/Jamrules if present.
1608 if $($(_top)RULES) {
1609 include $($(_top)RULES) ;
1611 NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1612 include $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1616 # Get path from $(TOP) to named directory.
1617 # Save dir tokens for other potential uses.
1618 SUBDIR_UP = $($(_top)-UP) ;
1619 SUBDIR_DOWN = $($(_top)-DOWN) $(_tokens) ;
1620 SUBDIR_ROOT = $($(_top)-ROOT) ;
1621 SUBDIR_TOKENS = $(SUBDIR_DOWN) ;
1623 SUBDIR = [ FSubDirPath $(<) ] ;
1625 # Now set up SEARCH_SOURCE, LOCATE_TARGET, LOCATE_BIN, SOURCE_GRIST
1626 # These can be reset if needed. For example, if the source
1627 # directory should not hold object files, LOCATE_TARGET can
1628 # subsequently be redefined.
1629 SEARCH_SOURCE = $(SUBDIR) ;
1630 LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ;
1631 LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ;
1633 ktmp = $(ALL_LOCATE_BIN) ;
1634 if ! $(ktmp) { ktmp = $(ALL_LOCATE_TARGET) ; }
1635 LOCATE_BIN = $(ktmp) $(SUBDIR) ;
1637 ktmp = $(ALL_LOCATE_LIB) ;
1638 if ! $(ktmp) { ktmp = $(ALL_LOCATE_TARGET) ; }
1639 LOCATE_LIB = $(ktmp) $(SUBDIR) ;
1641 ktmp = $(ALL_LOCATE_LIBSO) ;
1642 if ! $(ktmp) { ktmp = $(ALL_LOCATE_LIB) ; }
1643 if ! $(ktmp) { ktmp = $(ALL_LOCATE_TARGET) ; }
1644 LOCATE_LIBSO = $(ktmp) $(SUBDIR) ;
1646 SOURCE_GRIST = [ FGrist $(SUBDIR_TOKENS) ] ;
1647 #if ! $(LOCATE_BIN) { LOCATE_BIN = $(LOCATE_TARGET) ; }
1649 ## OPT_HEADER_CACHE_EXT
1650 # With the header cache, we can grist all files found
1651 # during a header scan without incurring a performance
1654 HDRGRIST = $(SOURCE_GRIST) ;
1656 # Reset per-directory ccflags, hdrs, etc,
1657 # listed in SUBDIRRESET.
1658 # Note use of variable expanded assignment var
1659 SUBDIR$(SUBDIRRESET) = ;
1661 # Invoke user-specific SubDir extensions,
1662 # rule names listed in SUBDIRRULES.
1663 # Note use of variable expanded rule invocation
1664 $(SUBDIRRULES) $(<) ;
1669 # FSubDirPath TOP d1 ... ;
1671 # Returns path to named directory.
1673 # If jam is invoked in a subdirectory of the TOP, then we
1674 # need to prepend a ../ for every level we must climb up
1675 # (TOP-UP), and then append the directory names we must
1676 # climb down (TOP-DOWN), plus the named directories d1 ...
1677 # If TOP was set externally, or computed from another TOP
1678 # that was, we'll have to reroot the whole thing at TOP-ROOT.
1679 local _r = [ FRelPath $($(<[1])-UP) : $($(<[1])-DOWN) $(<[2-]) ] ;
1681 return $(_r:R=$($(<[1])-ROOT)) ;
1685 rule SubDirDcFlags {
1686 SUBDIRDCFLAGS += $(<) ;
1690 rule SubDirCcFlags {
1691 SUBDIRCCFLAGS += $(<) ;
1695 rule SubDirC++Flags {
1696 SUBDIRC++FLAGS += $(<) ;
1700 rule SubDirObjCFlags {
1701 SUBDIROBJCFLAGS += $(<) ;
1706 SUBDIRHDRS += [ FDirName $(<) ] ;
1710 rule SubIncludeMany {
1711 # SubIncludeMany TOP d1 ... ;
1713 # Include a subdirectory's Jamfile.
1715 # We use SubDir to get there, in case the included Jamfile
1716 # either doesn't have its own SubDir (naughty) or is a subtree
1718 #Echo "including " $(<) " : " $(>) ;
1720 if ! $($(<[1])) { Exit "SubIncludeMany" $(<[1]) "without prior SubDir" $(<[1]) ; }
1722 include $(JAMFILE:D=$(SUBDIR)) ;
1726 rule SubIncludeOnce {
1727 # SubIncludeOnce varname : TOP d1 ... ;
1729 # Include a subdirectory's Jamfile.
1731 local _vn = $(<[1]) ;
1733 #Echo "processing $(_vn)" ;
1736 SubIncludeMany $(>) ;
1738 # Echo "skiped $(_vn) -- $($(_vn))" ;
1745 # SubInclude TOP d1 ... ;
1747 # Include a subdirectory's Jamfile.
1748 if ! $($(<[1])) { Exit "SubInclude" $(<[1]) "without prior SubDir" $(<[1]) ; }
1749 local _sbiguard = _K8JAM_SUB_GUARD_$(<:J=_) ;
1750 SubIncludeOnce $(_sbiguard) : $(<) ;
1755 # SubRules TOP d1 ... : Other-TOP ;
1757 # Read another tree's Jamrules, by giving it's path according
1758 # to this tree and it's own name.
1759 if ! $($(<[1])) { Exit "SubRules" $(<[1]) "without prior SubDir" $(<[1]) ; }
1766 UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;
1771 Exit "Unknown suffix on" $(>) "- see UserObject rule in Jamfile(5)." ;
1780 # Some places don't have a yacc.
1781 MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ;
1782 #MakeLocate $(>) $(_h) : $(LOCATE_SOURCE) ;
1787 #if $(tmp) { tmp = $(PATH_SEPARATOR)$(tmp) ; }
1788 #tmp = $(LOCATE_SOURCE[1])$(tmp) ;
1789 #CCFLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1790 #C++FLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1791 #OBJCFLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1792 #Echo "-------------------------" ;
1793 #Echo "LS:" "$(LOCATE_SOURCE)" ;
1794 #Echo "tmp:" "$(tmp)" ;
1795 #Echo "out:" "$(<)" ;
1796 #Echo "in :" "$(>)" ;
1797 #Echo "_h :" "$(_h)" ;
1798 #Echo "=========================" ;
1800 Depends $(<) $(_h) : $(>) ;
1802 #Yacc1 $(<) $(_h) : $(>) ;
1803 #YaccMv $(<) $(_h) : $(>) ;
1804 Clean clean : $(<) $(_h) ;
1807 # make sure someone includes $(_h) else it will be
1808 # a deadly independent target
1809 Includes $(<) : $(_h) ;
1814 # Utility rules; no side effects on these
1818 # /FGrist path to file ;
1820 # Returns a single string that is used as grist
1828 return $(<:G=$(SOURCE_GRIST:E)) ;
1832 rule FGristSourceFiles {
1833 ## LOCAL CHANGE: OPT_HEADER_CACHE_EXT
1834 # With header caching, there is no performance penalty to gristing
1835 # header files. It is also not correct to assume that header
1836 # files have global visibility.
1838 # Here we comment out the old version and replace it with the new.
1839 # # Produce source file name name with grist in it,
1840 # # if SOURCE_GRIST is set.
1842 # # Leave header files alone, because they have a global
1844 # if ! $(SOURCE_GRIST) {
1851 # case *.h : _o += $(_i) ;
1852 # case * : _o += $(_i:G=$(SOURCE_GRIST)) ;
1857 return [ FGristFiles $(<) ] ;
1862 if $(1) { return [ FReverse $(1[2-]) ] $(1[1]) ; }
1867 # If $(>) is the path to the current directory, compute the
1868 # path (using ../../ etc) back to that root directory.
1869 # Sets result in $(<)
1876 for _i in $(<[2-]) { _d = $(_d:R=$(DOTDOT)) ; }
1883 # FStripCommon v1 : v2 ;
1885 # Strip common initial elements of variables v1 and v2.
1886 # Modifies the variable values themselves.
1887 if $($(<)[1]) && $($(<)[1]) = $($(>)[1]) {
1888 $(<) = $($(<)[2-]) ;
1889 $(>) = $($(>)[2-]) ;
1890 FStripCommon $(<) : $(>) ;
1898 # first strip off common parts
1901 FStripCommon _l : _r ;
1903 # now make path to root and path down
1904 _l = [ FSubDir $(_l) ] ;
1905 _r = [ FDirName $(_r) ] ;
1907 # Concatenate and save
1908 # XXX This should be better
1909 if $(_r) = $(DOT) { return $(_l) ; } else { return $(_r:R=$(_l)) ; }
1913 rule FAppendSuffix {
1914 # E.g., "FAppendSuffix yacc lex foo.bat : $(SUFEXE) ;"
1915 # returns (yacc,lex,foo.bat) on Unix and
1916 # (yacc.exe,lex.exe,foo.bat) on NT.
1921 if $(_i:S) { _o += $(_i) ; } else { _o += $(_i:S=$(>)) ; }
1931 # Operating system specific utility rules
1932 # First, the (generic) UNIX versions
1935 rule FQuote { return "\\\"$(<)\\\"" ; }
1936 rule FDefines { return -D$(<) ; }
1937 rule FIncludes { return -I$(<) ; }
1940 # Turn individual elements in $(<) into a usable path.
1944 for _i in $(<) { _s = $(_i:R=$(_s)) ; }
1949 if $(NT) && $(JAM_TOOLSET) != MINGW && $(JAM_TOOLSET) != LCC {
1950 rule FDefines { return /D$(<) ; }
1951 rule FIncludes { return /I$(<) ; }
1956 # various install rules
1960 # InstallInto dir : sources ;
1964 t = $(>:G=$(INSTALLGRIST)) ;
1966 # Arrange for jam install
1967 # Arrange for jam uninstall
1968 # sources are in SEARCH_SOURCE
1969 # targets are in dir
1971 Depends install : $(t) ;
1972 Clean uninstall : $(t) ;
1973 SEARCH on $(>) = $(SEARCH_SOURCE) ;
1974 MakeLocate $(t) : $(<) ;
1976 # For each source, make gristed target name
1977 # and Install, Chmod, Chown, and Chgrp
1979 local tt = $(i:G=$(INSTALLGRIST)) ;
1981 Depends $(tt) : $(i) ;
1982 Install $(tt) : $(i) ;
1985 if $(OWNER) && $(CHOWN) {
1987 OWNER on $(tt) = $(OWNER) ;
1989 if $(GROUP) && $(CHGRP) {
1991 GROUP on $(tt) = $(GROUP) ;
1997 # /InstallBin dir : sources ;
1999 # Copy _sources_ into _dir_ with mode $(EXEMODE)
2002 local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;
2004 InstallInto $(<) : $(_t) ;
2005 MODE on $(_t:G=$(INSTALLGRIST)) = $(EXEMODE) ;
2009 # /InstallFile dir : sources ;
2011 # Copy _sources_ into _dir_ with mode $(FILEMODE)
2014 InstallInto $(<) : $(>) ;
2015 MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2019 # /InstallLib dir : sources ;
2021 # Copy _sources_ into _dir_ with mode $(FILEMODE)
2024 InstallInto $(<) : $(>) ;
2025 MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2029 # /InstallMan dir : sources ;
2031 # Copy _sources_ into the appropriate subdirectory of _dir_ with mode
2032 # $(FILEMODE). The subdirectory is manS, where S is the suffix of each of
2036 # Really this just strips the . from the suffix
2041 case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;
2042 case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;
2043 case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;
2044 case .n : s = n ; case .man : s = 1 ;
2047 InstallInto $(d:R=$(<)) : $(i) ;
2049 MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2053 # /InstallShell dir : sources ;
2055 # Copy _sources_ into _dir_ with mode $(SHELLMODE)
2058 InstallInto $(<) : $(>) ;
2059 MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;
2063 rule WindozeResourceCompiler {
2064 DEPENDS $(<) : $(>) ;
2065 Clean clean : $(<) ;
2070 if $(WINDOZE_THREADS) {
2074 local ss = $(WINSUBSYS) ;
2075 if ! $(ss) { ss = "console" ; }
2076 LINK += "-Wl,-subsystem,$(ss)" ;
2077 C++LINK += "-Wl,-subsystem,$(ss)" ;
2078 if $(WINLIBS) { LINKLIBS += $(WINLIBS) ; } else { LINKLIBS += -lkernel32 ; }
2086 actions WindozeResourceCompiler {
2087 "$(WINE)" $(MGPATH)windres.exe -i $(>) -o $(<)
2091 # First the defaults
2093 actions updated together piecemeal Archive {
2099 $(AS) $(ASFLAGS) $(ASHDRS) -o $(<) $(>)
2104 $(CC) -c -o $(<) $(CFLAGS.all) $(CCFLAGS) $(OPTIM.all) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2109 $(C++) -c -o $(<) $(CFLAGS.all) $(C++FLAGS) $(OPTIM.all) $(C++OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2114 $(OBJCC) -c -o $(<) $(CFLAGS.all) $(OBJCFLAGS) $(OPTIM.all) $(OBJCOPTIM) $(CCDEFS) $(CCHDRS) $(>)
2119 $(DC) -c -of$(<) $(DCFLAGS) $(DOPTIM) $(>)
2124 $(CHGRP) $(GROUP) $(<)
2129 $(CHMOD) $(MODE) $(<)
2134 $(CHOWN) $(OWNER) $(<)
2138 actions piecemeal together existing Clean {
2149 $(>[1]) $(<) $(>[2-])
2154 $(RM) $(<) && $(LN) $(>) $(<)
2169 ## $(MV) lex.yy.c $(<)
2173 actions Link bind NEEDLIBS {
2174 $(LINK) $(LINKFLAGS.all) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(LINKLIBS)
2177 actions C++Link bind NEEDLIBS {
2178 $(C++LINK) $(LINKFLAGS.all) $(C++LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(C++LINKLIBS)
2181 actions ObjC-Link bind NEEDLIBS {
2182 $(OBJCLINK) $(LINKFLAGS.all) $(OBJCLINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(OBJCLINKLIBS)
2186 actions updated together piecemeal LinkUnixLibrary bind NEEDLIBS {
2187 $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2190 actions updated together piecemeal C++LinkUnixLibrary bind NEEDLIBS {
2191 $(C++LINK) $(C++LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(C++LINKLIBS)
2200 actions together Ranlib {
2205 actions quietly updated piecemeal together RmTemps {
2213 NR == 1 { print "$(SHELLHEADER)" }
2214 NR == 1 && /^[#:]/ { next }
2223 $(RM) $(<) && $(LN) -s $(>) $(<)
2228 $(YACC) $(YACCFLAGS) $(>) -o $(<)
2233 #$(MV) $(YACCFILES).c $(<[1])
2234 #$(MV) $(YACCFILES).h $(<[2])
2239 # RELOCATE - for compilers with broken -o flags
2243 $(C++) -c $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2246 $(CC) -c $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2248 actions ignore CcMv {
2249 [ $(<) != $(>:BS=$(SUFOBJ)) ] && $(MV) $(>:BS=$(SUFOBJ)) $(<)
2255 # NOARUPDATE - can't update an archive
2265 # UNIX specific actions
2270 $(>[1]) $(<) $(>[2-])
2276 # NT specific actions
2279 if $(JAM_TOOLSET) = MINGW {
2280 actions together piecemeal Archive {
2284 $(CC) -c -o $(<) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2287 $(C++) -c -o $(<) $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2289 actions DllLink bind DEFFILENAME IMPLIBNAME {
2290 $(LINK) $(LINKFLAGS) -shared -o $(<) $(>) $(DEFFILENAME) -Wl,--out-implib,$(IMPLIBNAME)
2292 } else if $(JAM_TOOLSET) = LCC {
2293 actions together piecemeal Archive {
2294 $(AR) /out:$(<) $(>)
2297 $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -Fo$(<) -I$(STDHDRS) $(>)
2299 actions Link bind NEEDLIBS {
2300 $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2302 actions DllLink bind NEEDLIBS DEFFILENAME {
2303 $(LINK) $(LINKFLAGS) -DLL -o $(<) $(UNDEFS) $(>) $(DEFFILENAME) $(NEEDLIBS) $(LINKLIBS)
2305 actions ignore DllLinkMv {
2311 } else if $(JAM_TOOLSET) = PELLESC {
2312 actions together piecemeal Archive {
2313 $(AR) /OUT:$(<) $(>)
2316 $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) /Fo $(<) -I$(STDHDRS) $(>)
2318 actions Link bind NEEDLIBS {
2319 $(LINK) $(LINKFLAGS) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2321 actions DllLink bind NEEDLIBS DEFFILENAME IMPLIBNAME {
2322 $(LINK) $(LINKFLAGS) /DLL /DEF:$(DEFFILENAME) /IMPLIB:$(IMPLIBNAME) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2332 # Ketmar's additions
2335 if $(OS) != "LINUX" {
2336 DETECTED_CPU = "i486" ;
2337 OPTIM_SPEED = -O3 -march=i486 -mtune=i486 ;
2339 DETECTED_CPU = native ;
2340 OPTIM_SPEED = -O3 -march=native -mtune=native ;
2345 # VAR = [ RemoveOptWild regexp-options-to-remove : options-list ] ;
2346 # remove options from list with egrep-like regexps
2347 rule RemoveOptWild {
2348 local oname = $(1) ;
2353 #Echo "removing " $(oname) " from " $(str) ;
2355 t = [ Match $(oname) : $(f) ] ;
2356 #Echo $(f) ": " $(t) ;
2358 #Echo "include: " $(f) ;
2367 K8JAM-KNOWN-PROFILES =
2368 none default # don't change
2369 empty # remove optimisation flags
2370 speed # optimise for speed
2371 size # optimise for size
2372 debug # don't optimize, add debug info
2377 rule --k8jam-profile-none {
2378 Echo "MSG: default profile" ;
2382 rule --k8jam-profile-empty {
2383 Echo "MSG: default profile" ;
2386 rule --k8jam-profile-empty-- {
2387 Echo "MSG: empty profile" ;
2388 SLACK_PKG_ARCH = "i486" ;
2389 LINKFLAGS.all += -s ;
2392 rule --k8jam-profile-speed-- {
2393 Echo "MSG: 'speed' profile" ;
2394 SLACK_PKG_ARCH = "i686" ;
2395 CFLAGS.all += $(OPTIM_SPEED) ;
2396 LINKFLAGS.all += $(LINKFLAGS_SPEED) ;
2399 rule --k8jam-profile-size-- {
2400 Echo "MSG: 'size' profile" ;
2401 SLACK_PKG_ARCH = "i686" ;
2402 CFLAGS.all += $(OPTIM_SIZE) ;
2403 LINKFLAGS.all += $(LINKFLAGS_SIZE) ;
2406 rule --k8jam-profile-debug-- {
2407 Echo "MSG: 'debug' profile" ;
2408 SLACK_PKG_ARCH = "i486" ;
2409 LINKFLAGS.all -= -s ;
2410 CFLAGS.all += $(OPTIM_DEBUG) ;
2411 LINKFLAGS.all += $(LINKFLAGS_DEBUG) ;
2414 rule --k8jam-profile-standard-- {
2415 Echo "MSG: 'standard' profile" ;
2416 SLACK_PKG_ARCH = "i486" ;
2418 LINKFLAGS.all += -s ;
2423 # set compile flags for profile; works only for gcc/g++
2424 # available profiles:
2425 # none, default: don't change
2426 # empty: remove optimisation flags
2427 # speed: optimise for speed and pIII
2428 # size: optimise for size
2429 # debug: don't optimize, add debug info
2432 if ! $(1) in $(K8JAM-KNOWN-PROFILES) {
2433 Echo "known profiles: $(K8JAM-KNOWN-PROFILES)" ;
2434 Exit "unknown profile: $(1)" ;
2437 local orm = "(^\\-march\\=)" "(^\\-mtune\\=)" "(^\\-mfpmath\\=)" "(^\\-O.$)" ;
2438 local ormff = "(^\\-f[^n][^o])" ;
2440 OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM) ] ;
2441 C++OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(C++OPTIM) ] ;
2442 OBJCOPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OBJCOPTIM) ] ;
2443 OPTIM.all = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM.all) ] ;
2444 LINKFLAGS -= "-g" "-s" ;
2445 C++LINKFLAGS -= "-g" "-s" ;
2446 OBJCLINKFLAGS -= "-g" "-s" ;
2447 LINKFLAGS.all -= "-g" "-s" ;
2449 OPT_PROFILE = $(1) ;
2450 --k8jam-profile-$(OPT_PROFILE)-- ;
2452 #SLACK_PKG_ARCH ?= "i486" ;
2455 # selects 'debug', 'standard', 'speed' or 'size' profile according to vars:
2457 # OPT_SIZE = 1 : size
2458 # OPT_SPEED = 1 : speed
2463 } else if $(OPT_SIZE) {
2465 } else if $(OPT_SPEED) {
2468 profile "standard" ;
2471 CFLAGS.all -= "-g" "-s" ;
2472 LINKFLAGS.all -= "-g" "-s" ;
2474 LINKFLAGS.all += -g ;
2476 if ! $(NO_WARNINGS) {
2477 CFLAGS.all += -Wall ;
2482 # set default 'locate' vars -- _build/, etc
2483 rule set-default-subdir-locates {
2485 if ! $(d) { d = "." ; }
2486 ALL_LOCATE_BIN = $(d) ;
2487 ALL_LOCATE_LIBSO = $(d) ;
2489 ALL_LOCATE_TARGET = $(d)$(PATH_SEPARATOR)_wbuild ;
2490 ALL_LOCATE_LIB = $(d)$(PATH_SEPARATOR)_wbuild$(PATH_SEPARATOR)lib ;
2491 HCACHEFILE = $(d)$(PATH_SEPARATOR)_wbuild$(PATH_SEPARATOR).jamhdr.cache ;
2493 ALL_LOCATE_TARGET = $(d)$(PATH_SEPARATOR)_build ;
2494 ALL_LOCATE_LIB = $(d)$(PATH_SEPARATOR)_build$(PATH_SEPARATOR)lib ;
2495 HCACHEFILE = $(d)$(PATH_SEPARATOR)_build$(PATH_SEPARATOR).jamhdr.cache ;
2497 Clean clean : $(HCACHEFILE) ;
2501 rule set-default-target-locations {
2502 set-default-subdir-locates ;
2505 rule set-default-locations {
2506 set-default-subdir-locates ;
2509 rule set-target-locations {
2510 set-default-subdir-locates ;
2518 rule setup-windoze {
2519 if ! $(WINDOZE) { WINDOZE = 1 ; }
2522 #WINDOZE_THREADS = -mthreads ;
2523 #WINDOZE_THREADS = ;
2525 MGPATH ?= "c:\\\\mingw\\\\bin\\\\" ;
2526 MGCC ?= "mingw32-gcc.exe -static-libgcc" ;
2527 MG++ ?= "mingw32-g++.exe -static-libgcc -static-libstdc++" ;
2528 CC = "$(WINE)" $(MGPATH)$(MGCC) ;
2529 LINK = "$(WINE)" $(MGPATH)$(MGCC) -Wl,--enable-auto-import ;
2530 AR = "$(WINE)" $(MGPATH)ar.exe -ru ;
2531 RANLIB = "$(WINE)" $(MGPATH)ranlib.exe ;
2532 C++ = "$(WINE)" $(MGPATH)$(MG++) ;
2533 C++LINK = "$(WINE)" $(MGPATH)$(MG++) -Wl,--enable-auto-import ;
2534 #LINKLIBS += -lkernel32 ;
2535 #LINKLIBS += -luser32 ;
2536 #LINKLIBS += -ladvapi32 ;
2537 #LINKLIBS += -lws2_32 ;
2538 #WINSUBSYS = "windows" ;
2539 #WINSUBSYS = "console" ;
2541 #LINKFLAGS += "-Wl,-subsystem,$(WINSUBSYS)" ;
2545 rule check-setup-windoze {
2546 if $(WINDOZE) { setup-windoze ; }
2551 # ObjectNoAliasing filelist ;
2552 # turn off aliasing optimization for specified files
2553 # works only for gcc/g++
2554 rule ObjectNoAliasing {
2555 local isGCC = "ona" ;
2556 local isG++ = "ona" ;
2557 if ( "gcc" in $(CC) ) || ( $(JAM_TOOLSET) = MINGW ) { isGCC = "tan" ; }
2558 if ( "g++" in $(C++) ) || ( $(JAM_TOOLSET) = MINGW ) { isG++ = "tan" ; }
2559 if $(JAM_FORCE_GCC_OPTIONS) { isGCC = "tan" ; isG++ = "tan" ; }
2561 if $(isGCC) = "tan" { CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; }
2562 if $(isG++) = "tan" { C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; }
2563 OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ;
2567 rule gcc-suggest-attrs {
2568 if ! $(NO_SUGGEST) {
2569 CFLAGS.all += -Wsuggest-attribute=const ;
2570 CFLAGS.all += -Wsuggest-attribute=pure ;
2571 CFLAGS.all += -Wsuggest-attribute=noreturn ;
2577 # add output to var $(2)
2578 # return resulting (non-empty) string if library is present
2579 # if $(2) = "" -- don't add flags, just return
2580 # [ lib-config-ex "pkg-config sdl --cflags" : "CFLAGS" ]
2581 rule lib-config-ex {
2583 cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
2584 if $(cf[1]) = "0" && $(cf[2]) {
2596 # call $(1) --cflags and $(1) --libs (many libs provides such configurators)
2597 # add necessary flags to compiler and linker vars
2598 # return "tan" (non-empty string) if library is present
2599 # if $(2) != "" -- don't add flags, just check
2600 # [ lib-config "pkg-config sdl" ]
2604 cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
2606 if $(cf[1]) = "0" && $(cf[2]) {
2608 #Echo "flags:" $(cf[2-]) ;
2610 CCFLAGS += $(cf[2-]) ;
2611 C++FLAGS += $(cf[2-]) ;
2612 OBJCFLAGS += $(cf[2-]) ;
2616 lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
2618 if $(lf[1]) = "0" && $(lf[2]) {
2620 #Echo "flags:" $(lf[2-]) ;
2622 LINKFLAGS += $(lf[2-]) ;
2623 C++LINKFLAGS += $(lf[2-]) ;
2624 OBJCLINKFLAGS += $(lf[2-]) ;
2633 res = [ lib-config "pkg-config $(1)" ] ;
2638 rule pkg-config-has {
2640 res = [ lib-config-ex "pkg-config $(1) --cflags --libs" ] ;
2649 OBJC_GNUSTEP_BASE_LIB = gnustep-base ;
2650 OBJC_GNUSTEP_GUI_LIB = gnustep-gui ;
2655 rule ObjCUseGNUstepBase {
2656 if ! $(K8_INTERNAL_GNUSTEP_BASE) {
2657 #Echo "-l$(OBJC_GNUSTEP_BASE_LIB)" ;
2658 OBJCLINKLIBS += "-l$(OBJC_GNUSTEP_BASE_LIB)" ;
2659 K8_INTERNAL_GNUSTEP_BASE = tan ;
2663 rule ObjCUseGNUstepGui {
2664 ObjCUseGNUstepBase ;
2665 if ! $(K8_INTERNAL_GNUSTEP_GUI) {
2666 K8_INTERNAL_GNUSTEP_GUI = tan ;
2667 #Echo "-l$(OBJC_GNUSTEP_GUI_LIB)" ;
2668 OBJCLINKLIBS += "-l$(OBJC_GNUSTEP_GUI_LIB)" ;
2672 rule ObjCUseGNUstep {
2673 ObjCUseGNUstepBase ;
2679 # 'help' and 'push' targets
2681 rule ShowHelpProfile {
2682 NotFile help-profile ;
2683 Always help-profile ;
2684 AShowHelpProfile help-profile ;
2686 actions AShowHelpProfile {
2687 echo "profile flags:"
2688 echo " DEBUG=1 -- debug build"
2689 echo " OPT_SPEED=1 -- optimize for speed"
2690 echo " OPT_SIZE=1 -- optimize for size"
2691 echo " VALGRIND=1 -- do not strip debug info"
2692 echo " NO_WARNINGS=1 -- do not all '-Wall' flag"
2693 echo "WARNING: DON'T FORGET TO DO 'jam clean' before building with new flags!"
2701 #AShowHelpProfile help ;
2704 echo "WARNING: default help; override 'actions AShowHelp' definition to use 'help' target!"
2714 echo "WARNING: add 'actions AGitPush' definition to use 'push' target!"
2719 check-setup-windoze ;
2722 # Now include the user's Jamfile.
2724 include $(JAMFILE) ;