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-]) ;
1514 local _xpath = $(_tokens:J=$(PATH_SEPARATOR)) ;
1516 #Echo "$(_tokens)" ;
1518 if $(_xpath) != "" { _xpath = "$(PATH_SEPARATOR)$(_xpath)" ; }
1522 # First time through sets up relative root and includes Jamrules.
1523 if ! $(_top) { Exit "SubDir syntax error" ; }
1525 if ! $($(_top)-SET) {
1526 $(_top)-SET = true ;
1527 # First time we've seen this TOP.
1528 # We'll initialize a number of internal variables:
1530 # $(TOP-UP) = directories from ROOT to a common point
1531 # $(TOP-DOWN) = directories from common point to TOP
1532 # $(TOP-ROOT) = root directory for UP/DOWN -- normally CWD
1533 # $(SUBDIR_UP) = current value of $(TOP-UP)
1534 # $(SUBDIR_DOWN) = current value of $(TOP-DOWN)
1535 # $(SUBDIR_ROOT) = current value of $(TOP-ROOT)
1538 # TOP externally set.
1539 # We'll ignore the relative (UP/DOWN) path that
1540 # got us here, and instead remember the hard ROOT.
1543 $(_top)-ROOT = $($(_top)) ;
1547 # Establishing a new TOP. In the simplest case,
1548 # (SUBDIR_UP/SUBDIR_DOWN/SUBDIR_ROOT unset), it's
1549 # merely a certain number of directories down from
1550 # the current directory, and FSubDirPath will set
1551 # TOP to a path consisting of ../ for each of the
1552 # elements of _tokens, because that represents how
1553 # far below TOP the current directory sits.
1555 # In the more complicated case, the starting directory
1556 # isn't the directory of jam's invocation but an
1557 # location established by previous SubDir call. The
1558 # starting directory is SUBDIR_UP directories up from
1559 # SUBDIR_ROOT, and then SUBDIR_DOWN directories down
1560 # from that. If SUBDIR_ROOT is not set, that means
1561 # SUBDIR_DOWN and SUBDIR_UP represent the path from
1562 # the directory of jam's invocation.
1564 # In the most complicated case, the _tokens also
1565 # represents directories down, because TOP is being
1566 # estalished in a directory other than TOP's root.
1567 # Hopefully, _tokens and SUBDIR_DOWN represent the
1568 # same final directory, relative to the new TOP and
1569 # the previous SubDIr's TOP. To find the new TOP,
1570 # we have to chop off any common directories from
1571 # then ends of _tokens and SUBDIR_DOWN. To do so,
1572 # we reverse each of them, call FStripCommon to
1573 # remove the initial common elements, and then
1574 # reverse them again. After this process, if
1575 # both _tokens and SUBDIR_DOWN have elements, it
1576 # means the directory names estalished by the two
1577 # SubDir calls don't match, and a warning is issued.
1578 # All hell will likely break loose at this point,
1579 # since the whole SubDir scheme relies on the SubDir
1580 # calls accurately naming the current directory.
1582 # Strip common trailing elements of _tokens and SUBDIR_DOWN.
1583 _tokens = [ FReverse $(_tokens) ] ;
1584 SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
1585 FStripCommon _tokens : SUBDIR_DOWN ;
1586 SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
1587 _tokens = [ FReverse $(_tokens) ] ;
1589 if $(SUBDIR_DOWN) && $(_tokens) { Echo "Warning:" SubDir $(<) "misplaced!" ; }
1591 # We'll remember the relative (UP/DOWN) path that
1592 # got us here, plus any hard ROOT starting point
1593 # for the UP/DOWN. If TOP is never set externally,
1594 # ROOT will always be "" (directory of jam's invocation).
1595 $(_top)-UP = $(SUBDIR_UP) $(_tokens) ;
1596 $(_top)-DOWN = $(SUBDIR_DOWN) ;
1597 $(_top)-ROOT = $(SUBDIR_ROOT:E="") ;
1598 $(_top) = [ FSubDirPath $(_top) ] ;
1601 # Set subdir vars for the inclusion of the Jamrules,
1602 # just in case they have SubDir rules of their own.
1603 # Note that SUBDIR_DOWN is empty: it's all the way
1604 # up where the Jamrules live. These gets overrided
1605 # just after the inclusion.
1606 SUBDIR_UP = $($(_top)-UP) ;
1608 SUBDIR_ROOT = $($(_top)-ROOT) ;
1610 # Include $(TOPRULES) or $(TOP)/Jamrules.
1611 # Include $(TOPRULES) if set.
1612 # Otherwise include $(TOP)/Jamrules if present.
1613 if $($(_top)RULES) {
1614 include $($(_top)RULES) ;
1616 NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1617 include $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1621 # Get path from $(TOP) to named directory.
1622 # Save dir tokens for other potential uses.
1623 SUBDIR_UP = $($(_top)-UP) ;
1624 SUBDIR_DOWN = $($(_top)-DOWN) $(_tokens) ;
1625 SUBDIR_ROOT = $($(_top)-ROOT) ;
1626 SUBDIR_TOKENS = $(SUBDIR_DOWN) ;
1628 SUBDIR = [ FSubDirPath $(<) ] ;
1630 # Now set up SEARCH_SOURCE, LOCATE_TARGET, LOCATE_BIN, SOURCE_GRIST
1631 # These can be reset if needed. For example, if the source
1632 # directory should not hold object files, LOCATE_TARGET can
1633 # subsequently be redefined.
1634 SEARCH_SOURCE = $(SUBDIR) ;
1636 #if $(SUBDIR) = "." { sdr = "" ; } else { sdr = "$(PATH_SEPARATOR)$(SUBDIR)" ; }
1638 if $(ALL_LOCATE_TARGET) {
1639 LOCATE_TARGET = "$(ALL_LOCATE_TARGET)$(_xpath)" ;
1640 LOCATE_SOURCE = "$(ALL_LOCATE_TARGET)$(_xpath)" ;
1642 LOCATE_TARGET = $(SUBDIR) ;
1643 LOCATE_SOURCE = $(SUBDIR) ;
1646 if $(ALL_LOCATE_BIN) {
1647 LOCATE_BIN = $(ALL_LOCATE_BIN) ;
1649 LOCATE_BIN = $(LOCATE_TARGET) ;
1652 if $(ALL_LOCATE_LIB) {
1653 LOCATE_LIB = $(ALL_LOCATE_LIB) ;
1655 LOCATE_LIB = $(LOCATE_TARGET) ;
1658 if $(ALL_LOCATE_LIBSO) {
1659 LOCATE_LIBSO = $(ALL_LOCATE_LIBSO) ;
1661 LOCATE_LIBSO = $(LOCATE_LIB) ;
1664 #Echo "ALL_LOCATE_LIB = $(ALL_LOCATE_LIB)" ;
1665 #Echo "LOCATE_LIB = $(LOCATE_LIB)" ;
1667 SOURCE_GRIST = [ FGrist $(SUBDIR_TOKENS) ] ;
1668 #if ! $(LOCATE_BIN) { LOCATE_BIN = $(LOCATE_TARGET) ; }
1670 ## OPT_HEADER_CACHE_EXT
1671 # With the header cache, we can grist all files found
1672 # during a header scan without incurring a performance
1675 HDRGRIST = $(SOURCE_GRIST) ;
1677 # Reset per-directory ccflags, hdrs, etc,
1678 # listed in SUBDIRRESET.
1679 # Note use of variable expanded assignment var
1680 SUBDIR$(SUBDIRRESET) = ;
1682 # Invoke user-specific SubDir extensions,
1683 # rule names listed in SUBDIRRULES.
1684 # Note use of variable expanded rule invocation
1685 $(SUBDIRRULES) $(<) ;
1690 # FSubDirPath TOP d1 ... ;
1692 # Returns path to named directory.
1694 # If jam is invoked in a subdirectory of the TOP, then we
1695 # need to prepend a ../ for every level we must climb up
1696 # (TOP-UP), and then append the directory names we must
1697 # climb down (TOP-DOWN), plus the named directories d1 ...
1698 # If TOP was set externally, or computed from another TOP
1699 # that was, we'll have to reroot the whole thing at TOP-ROOT.
1700 local _r = [ FRelPath $($(<[1])-UP) : $($(<[1])-DOWN) $(<[2-]) ] ;
1702 return $(_r:R=$($(<[1])-ROOT)) ;
1706 rule SubDirDcFlags {
1707 SUBDIRDCFLAGS += $(<) ;
1711 rule SubDirCcFlags {
1712 SUBDIRCCFLAGS += $(<) ;
1716 rule SubDirC++Flags {
1717 SUBDIRC++FLAGS += $(<) ;
1721 rule SubDirObjCFlags {
1722 SUBDIROBJCFLAGS += $(<) ;
1727 SUBDIRHDRS += [ FDirName $(<) ] ;
1731 rule SubIncludeMany {
1732 # SubIncludeMany TOP d1 ... ;
1734 # Include a subdirectory's Jamfile.
1736 # We use SubDir to get there, in case the included Jamfile
1737 # either doesn't have its own SubDir (naughty) or is a subtree
1739 #Echo "including " $(<) " : " $(>) ;
1741 if ! $($(<[1])) { Exit "SubIncludeMany" $(<[1]) "without prior SubDir" $(<[1]) ; }
1743 include $(JAMFILE:D=$(SUBDIR)) ;
1747 rule SubIncludeOnce {
1748 # SubIncludeOnce varname : TOP d1 ... ;
1750 # Include a subdirectory's Jamfile.
1752 local _vn = $(<[1]) ;
1754 #Echo "processing $(_vn)" ;
1757 SubIncludeMany $(>) ;
1759 # Echo "skiped $(_vn) -- $($(_vn))" ;
1766 # SubInclude TOP d1 ... ;
1768 # Include a subdirectory's Jamfile.
1769 if ! $($(<[1])) { Exit "SubInclude" $(<[1]) "without prior SubDir" $(<[1]) ; }
1770 local _sbiguard = _K8JAM_SUB_GUARD_$(<:J=_) ;
1771 SubIncludeOnce $(_sbiguard) : $(<) ;
1776 # SubRules TOP d1 ... : Other-TOP ;
1778 # Read another tree's Jamrules, by giving it's path according
1779 # to this tree and it's own name.
1780 if ! $($(<[1])) { Exit "SubRules" $(<[1]) "without prior SubDir" $(<[1]) ; }
1787 UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;
1792 Exit "Unknown suffix on" $(>) "- see UserObject rule in Jamfile(5)." ;
1801 # Some places don't have a yacc.
1802 MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ;
1803 #MakeLocate $(>) $(_h) : $(LOCATE_SOURCE) ;
1808 #if $(tmp) { tmp = $(PATH_SEPARATOR)$(tmp) ; }
1809 #tmp = $(LOCATE_SOURCE[1])$(tmp) ;
1810 #CCFLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1811 #C++FLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1812 #OBJCFLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1813 #Echo "-------------------------" ;
1814 #Echo "LS:" "$(LOCATE_SOURCE)" ;
1815 #Echo "tmp:" "$(tmp)" ;
1816 #Echo "out:" "$(<)" ;
1817 #Echo "in :" "$(>)" ;
1818 #Echo "_h :" "$(_h)" ;
1819 #Echo "=========================" ;
1821 Depends $(<) $(_h) : $(>) ;
1823 #Yacc1 $(<) $(_h) : $(>) ;
1824 #YaccMv $(<) $(_h) : $(>) ;
1825 Clean clean : $(<) $(_h) ;
1828 # make sure someone includes $(_h) else it will be
1829 # a deadly independent target
1830 Includes $(<) : $(_h) ;
1835 # Utility rules; no side effects on these
1839 # /FGrist path to file ;
1841 # Returns a single string that is used as grist
1849 return $(<:G=$(SOURCE_GRIST:E)) ;
1853 rule FGristSourceFiles {
1854 ## LOCAL CHANGE: OPT_HEADER_CACHE_EXT
1855 # With header caching, there is no performance penalty to gristing
1856 # header files. It is also not correct to assume that header
1857 # files have global visibility.
1859 # Here we comment out the old version and replace it with the new.
1860 # # Produce source file name name with grist in it,
1861 # # if SOURCE_GRIST is set.
1863 # # Leave header files alone, because they have a global
1865 # if ! $(SOURCE_GRIST) {
1872 # case *.h : _o += $(_i) ;
1873 # case * : _o += $(_i:G=$(SOURCE_GRIST)) ;
1878 return [ FGristFiles $(<) ] ;
1883 if $(1) { return [ FReverse $(1[2-]) ] $(1[1]) ; }
1888 # If $(>) is the path to the current directory, compute the
1889 # path (using ../../ etc) back to that root directory.
1890 # Sets result in $(<)
1897 for _i in $(<[2-]) { _d = $(_d:R=$(DOTDOT)) ; }
1904 # FStripCommon v1 : v2 ;
1906 # Strip common initial elements of variables v1 and v2.
1907 # Modifies the variable values themselves.
1908 if $($(<)[1]) && $($(<)[1]) = $($(>)[1]) {
1909 $(<) = $($(<)[2-]) ;
1910 $(>) = $($(>)[2-]) ;
1911 FStripCommon $(<) : $(>) ;
1919 # first strip off common parts
1922 FStripCommon _l : _r ;
1924 # now make path to root and path down
1925 _l = [ FSubDir $(_l) ] ;
1926 _r = [ FDirName $(_r) ] ;
1928 # Concatenate and save
1929 # XXX This should be better
1930 if $(_r) = $(DOT) { return $(_l) ; } else { return $(_r:R=$(_l)) ; }
1934 rule FAppendSuffix {
1935 # E.g., "FAppendSuffix yacc lex foo.bat : $(SUFEXE) ;"
1936 # returns (yacc,lex,foo.bat) on Unix and
1937 # (yacc.exe,lex.exe,foo.bat) on NT.
1942 if $(_i:S) { _o += $(_i) ; } else { _o += $(_i:S=$(>)) ; }
1952 # Operating system specific utility rules
1953 # First, the (generic) UNIX versions
1956 rule FQuote { return "\\\"$(<)\\\"" ; }
1957 rule FDefines { return -D$(<) ; }
1958 rule FIncludes { return -I$(<) ; }
1961 # Turn individual elements in $(<) into a usable path.
1965 for _i in $(<) { _s = $(_i:R=$(_s)) ; }
1970 if $(NT) && $(JAM_TOOLSET) != MINGW && $(JAM_TOOLSET) != LCC {
1971 rule FDefines { return /D$(<) ; }
1972 rule FIncludes { return /I$(<) ; }
1977 # various install rules
1981 # InstallInto dir : sources ;
1985 t = $(>:G=$(INSTALLGRIST)) ;
1987 # Arrange for jam install
1988 # Arrange for jam uninstall
1989 # sources are in SEARCH_SOURCE
1990 # targets are in dir
1992 Depends install : $(t) ;
1993 Clean uninstall : $(t) ;
1994 SEARCH on $(>) = $(SEARCH_SOURCE) ;
1995 MakeLocate $(t) : $(<) ;
1997 # For each source, make gristed target name
1998 # and Install, Chmod, Chown, and Chgrp
2000 local tt = $(i:G=$(INSTALLGRIST)) ;
2002 Depends $(tt) : $(i) ;
2003 Install $(tt) : $(i) ;
2006 if $(OWNER) && $(CHOWN) {
2008 OWNER on $(tt) = $(OWNER) ;
2010 if $(GROUP) && $(CHGRP) {
2012 GROUP on $(tt) = $(GROUP) ;
2018 # /InstallBin dir : sources ;
2020 # Copy _sources_ into _dir_ with mode $(EXEMODE)
2023 local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;
2025 InstallInto $(<) : $(_t) ;
2026 MODE on $(_t:G=$(INSTALLGRIST)) = $(EXEMODE) ;
2030 # /InstallFile dir : sources ;
2032 # Copy _sources_ into _dir_ with mode $(FILEMODE)
2035 InstallInto $(<) : $(>) ;
2036 MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2040 # /InstallLib dir : sources ;
2042 # Copy _sources_ into _dir_ with mode $(FILEMODE)
2045 InstallInto $(<) : $(>) ;
2046 MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2050 # /InstallMan dir : sources ;
2052 # Copy _sources_ into the appropriate subdirectory of _dir_ with mode
2053 # $(FILEMODE). The subdirectory is manS, where S is the suffix of each of
2057 # Really this just strips the . from the suffix
2062 case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;
2063 case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;
2064 case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;
2065 case .n : s = n ; case .man : s = 1 ;
2068 InstallInto $(d:R=$(<)) : $(i) ;
2070 MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2074 # /InstallShell dir : sources ;
2076 # Copy _sources_ into _dir_ with mode $(SHELLMODE)
2079 InstallInto $(<) : $(>) ;
2080 MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;
2084 rule WindozeResourceCompiler {
2085 DEPENDS $(<) : $(>) ;
2086 Clean clean : $(<) ;
2091 if $(WINDOZE_THREADS) {
2095 local ss = $(WINSUBSYS) ;
2096 if ! $(ss) { ss = "console" ; }
2097 LINK += "-Wl,-subsystem,$(ss)" ;
2098 C++LINK += "-Wl,-subsystem,$(ss)" ;
2099 if $(WINLIBS) { LINKLIBS += $(WINLIBS) ; } else { LINKLIBS += -lkernel32 ; }
2107 actions WindozeResourceCompiler {
2108 "$(WINE)" $(MGPATH)windres.exe -i $(>) -o $(<)
2112 # First the defaults
2114 actions updated together piecemeal Archive {
2120 $(AS) $(ASFLAGS) $(ASHDRS) -o $(<) $(>)
2125 $(CC) -c -o $(<) $(CFLAGS.all) $(CCFLAGS) $(OPTIM.all) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2130 $(C++) -c -o $(<) $(CFLAGS.all) $(C++FLAGS) $(OPTIM.all) $(C++OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2135 $(OBJCC) -c -o $(<) $(CFLAGS.all) $(OBJCFLAGS) $(OPTIM.all) $(OBJCOPTIM) $(CCDEFS) $(CCHDRS) $(>)
2140 $(DC) -c -of$(<) $(DCFLAGS) $(DOPTIM) $(>)
2145 $(CHGRP) $(GROUP) $(<)
2150 $(CHMOD) $(MODE) $(<)
2155 $(CHOWN) $(OWNER) $(<)
2159 actions piecemeal together existing Clean {
2170 $(>[1]) $(<) $(>[2-])
2175 $(RM) $(<) && $(LN) $(>) $(<)
2190 ## $(MV) lex.yy.c $(<)
2194 actions Link bind NEEDLIBS {
2195 $(LINK) $(LINKFLAGS.all) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(LINKLIBS)
2198 actions C++Link bind NEEDLIBS {
2199 $(C++LINK) $(LINKFLAGS.all) $(C++LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(C++LINKLIBS)
2202 actions ObjC-Link bind NEEDLIBS {
2203 $(OBJCLINK) $(LINKFLAGS.all) $(OBJCLINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(OBJCLINKLIBS)
2207 actions updated together piecemeal LinkUnixLibrary bind NEEDLIBS {
2208 $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2211 actions updated together piecemeal C++LinkUnixLibrary bind NEEDLIBS {
2212 $(C++LINK) $(C++LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(C++LINKLIBS)
2221 actions together Ranlib {
2226 actions quietly updated piecemeal together RmTemps {
2234 NR == 1 { print "$(SHELLHEADER)" }
2235 NR == 1 && /^[#:]/ { next }
2244 $(RM) $(<) && $(LN) -s $(>) $(<)
2249 $(YACC) $(YACCFLAGS) $(>) -o $(<)
2254 #$(MV) $(YACCFILES).c $(<[1])
2255 #$(MV) $(YACCFILES).h $(<[2])
2260 # RELOCATE - for compilers with broken -o flags
2264 $(C++) -c $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2267 $(CC) -c $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2269 actions ignore CcMv {
2270 [ $(<) != $(>:BS=$(SUFOBJ)) ] && $(MV) $(>:BS=$(SUFOBJ)) $(<)
2276 # NOARUPDATE - can't update an archive
2286 # UNIX specific actions
2291 $(>[1]) $(<) $(>[2-])
2297 # NT specific actions
2300 if $(JAM_TOOLSET) = MINGW {
2301 actions together piecemeal Archive {
2305 $(CC) -c -o $(<) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2308 $(C++) -c -o $(<) $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2310 actions DllLink bind DEFFILENAME IMPLIBNAME {
2311 $(LINK) $(LINKFLAGS) -shared -o $(<) $(>) $(DEFFILENAME) -Wl,--out-implib,$(IMPLIBNAME)
2313 } else if $(JAM_TOOLSET) = LCC {
2314 actions together piecemeal Archive {
2315 $(AR) /out:$(<) $(>)
2318 $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -Fo$(<) -I$(STDHDRS) $(>)
2320 actions Link bind NEEDLIBS {
2321 $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2323 actions DllLink bind NEEDLIBS DEFFILENAME {
2324 $(LINK) $(LINKFLAGS) -DLL -o $(<) $(UNDEFS) $(>) $(DEFFILENAME) $(NEEDLIBS) $(LINKLIBS)
2326 actions ignore DllLinkMv {
2332 } else if $(JAM_TOOLSET) = PELLESC {
2333 actions together piecemeal Archive {
2334 $(AR) /OUT:$(<) $(>)
2337 $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) /Fo $(<) -I$(STDHDRS) $(>)
2339 actions Link bind NEEDLIBS {
2340 $(LINK) $(LINKFLAGS) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2342 actions DllLink bind NEEDLIBS DEFFILENAME IMPLIBNAME {
2343 $(LINK) $(LINKFLAGS) /DLL /DEF:$(DEFFILENAME) /IMPLIB:$(IMPLIBNAME) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2353 # Ketmar's additions
2356 if $(OS) != "LINUX" {
2357 DETECTED_CPU = "i486" ;
2358 OPTIM_SPEED = -O3 -march=i486 -mtune=i486 ;
2360 DETECTED_CPU = native ;
2361 OPTIM_SPEED = -O3 -march=native -mtune=native ;
2366 # VAR = [ RemoveOptWild regexp-options-to-remove : options-list ] ;
2367 # remove options from list with egrep-like regexps
2368 rule RemoveOptWild {
2369 local oname = $(1) ;
2374 #Echo "removing " $(oname) " from " $(str) ;
2376 t = [ Match $(oname) : $(f) ] ;
2377 #Echo $(f) ": " $(t) ;
2379 #Echo "include: " $(f) ;
2388 K8JAM-KNOWN-PROFILES =
2389 none default # don't change
2390 empty # remove optimisation flags
2391 speed # optimise for speed
2392 size # optimise for size
2393 debug # don't optimize, add debug info
2398 rule --k8jam-profile-none {
2399 Echo "MSG: default profile" ;
2403 rule --k8jam-profile-empty {
2404 Echo "MSG: default profile" ;
2407 rule --k8jam-profile-empty-- {
2408 Echo "MSG: empty profile" ;
2409 SLACK_PKG_ARCH = "i486" ;
2410 LINKFLAGS.all += -s ;
2413 rule --k8jam-profile-speed-- {
2414 Echo "MSG: 'speed' profile" ;
2415 SLACK_PKG_ARCH = "i686" ;
2416 CFLAGS.all += $(OPTIM_SPEED) ;
2417 LINKFLAGS.all += $(LINKFLAGS_SPEED) ;
2420 rule --k8jam-profile-size-- {
2421 Echo "MSG: 'size' profile" ;
2422 SLACK_PKG_ARCH = "i686" ;
2423 CFLAGS.all += $(OPTIM_SIZE) ;
2424 LINKFLAGS.all += $(LINKFLAGS_SIZE) ;
2427 rule --k8jam-profile-debug-- {
2428 Echo "MSG: 'debug' profile" ;
2429 SLACK_PKG_ARCH = "i486" ;
2430 LINKFLAGS.all -= -s ;
2431 CFLAGS.all += $(OPTIM_DEBUG) ;
2432 LINKFLAGS.all += $(LINKFLAGS_DEBUG) ;
2435 rule --k8jam-profile-standard-- {
2436 Echo "MSG: 'standard' profile" ;
2437 SLACK_PKG_ARCH = "i486" ;
2439 LINKFLAGS.all += -s ;
2444 # set compile flags for profile; works only for gcc/g++
2445 # available profiles:
2446 # none, default: don't change
2447 # empty: remove optimisation flags
2448 # speed: optimise for speed and pIII
2449 # size: optimise for size
2450 # debug: don't optimize, add debug info
2453 if ! $(1) in $(K8JAM-KNOWN-PROFILES) {
2454 Echo "known profiles: $(K8JAM-KNOWN-PROFILES)" ;
2455 Exit "unknown profile: $(1)" ;
2458 local orm = "(^\\-march\\=)" "(^\\-mtune\\=)" "(^\\-mfpmath\\=)" "(^\\-O.$)" ;
2459 local ormff = "(^\\-f[^n][^o])" ;
2461 OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM) ] ;
2462 C++OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(C++OPTIM) ] ;
2463 OBJCOPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OBJCOPTIM) ] ;
2464 OPTIM.all = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM.all) ] ;
2465 LINKFLAGS -= "-g" "-s" ;
2466 C++LINKFLAGS -= "-g" "-s" ;
2467 OBJCLINKFLAGS -= "-g" "-s" ;
2468 LINKFLAGS.all -= "-g" "-s" ;
2470 OPT_PROFILE = $(1) ;
2471 --k8jam-profile-$(OPT_PROFILE)-- ;
2473 #SLACK_PKG_ARCH ?= "i486" ;
2476 # selects 'debug', 'standard', 'speed' or 'size' profile according to vars:
2478 # OPT_SIZE = 1 : size
2479 # OPT_SPEED = 1 : speed
2480 # OPT=SIZE or OPT=SPEED
2485 if $(OPT) = "size" { otp = "size" ; }
2486 else if $(OPT) = "SIZE" { otp = "size" ; }
2487 if $(OPT) = "speed" { otp = "speed" ; }
2488 else if $(OPT) = "SPEED" { otp = "speed" ; }
2489 else if $(OPT_SIZE) { otp = "size" ; }
2490 else if $(OPT_SPEED) { otp = "speed" ; }
2494 } else if $(otp) = "size" {
2496 } else if $(otp) = "speed" {
2499 profile "standard" ;
2502 CFLAGS.all -= "-g" "-s" ;
2503 LINKFLAGS.all -= "-g" "-s" ;
2505 LINKFLAGS.all += -g ;
2507 if ! $(NO_WARNINGS) {
2508 CFLAGS.all += -Wall ;
2513 # set default 'locate' vars -- _build/, etc
2514 rule set-default-subdir-locates {
2518 if ! $(d) { d = "." ; }
2519 if $(WINDOZE) { bdir = _wbuild ; } else { bdir = _build ; }
2521 ALL_LOCATE_BIN = $(d) ;
2522 ALL_LOCATE_LIBSO = $(d) ;
2523 ALL_LOCATE_TARGET = "$(d)$(PATH_SEPARATOR)$(bdir)" ;
2524 ALL_LOCATE_LIB = "$(d)$(PATH_SEPARATOR)$(bdir)$(PATH_SEPARATOR)_libs" ;
2525 HCACHEFILE = "$(d)$(PATH_SEPARATOR)$(bdir)$(PATH_SEPARATOR).jamhdr.cache" ;
2527 Clean clean : $(HCACHEFILE) ;
2531 rule set-default-target-locations {
2532 set-default-subdir-locates ;
2535 rule set-default-locations {
2536 set-default-subdir-locates ;
2539 rule set-target-locations {
2540 set-default-subdir-locates ;
2548 rule setup-windoze {
2549 if ! $(WINDOZE) { WINDOZE = 1 ; }
2552 #WINDOZE_THREADS = -mthreads ;
2553 #WINDOZE_THREADS = ;
2555 MGPATH ?= "c:\\\\mingw\\\\bin\\\\" ;
2556 MGCC ?= "mingw32-gcc.exe -static-libgcc" ;
2557 MG++ ?= "mingw32-g++.exe -static-libgcc -static-libstdc++" ;
2558 CC = "$(WINE)" $(MGPATH)$(MGCC) ;
2559 LINK = "$(WINE)" $(MGPATH)$(MGCC) -Wl,--enable-auto-import ;
2560 AR = "$(WINE)" $(MGPATH)ar.exe -ru ;
2561 RANLIB = "$(WINE)" $(MGPATH)ranlib.exe ;
2562 C++ = "$(WINE)" $(MGPATH)$(MG++) ;
2563 C++LINK = "$(WINE)" $(MGPATH)$(MG++) -Wl,--enable-auto-import ;
2564 #LINKLIBS += -lkernel32 ;
2565 #LINKLIBS += -luser32 ;
2566 #LINKLIBS += -ladvapi32 ;
2567 #LINKLIBS += -lws2_32 ;
2568 #WINSUBSYS = "windows" ;
2569 #WINSUBSYS = "console" ;
2571 #LINKFLAGS += "-Wl,-subsystem,$(WINSUBSYS)" ;
2575 rule check-setup-windoze {
2576 if $(WINDOZE) { setup-windoze ; }
2581 CC = i686-pc-mingw32-gcc -pipe -static-libgcc ;
2582 C++ = i686-pc-mingw32-g++ -pipe -static-libgcc -static-libstdc++ ;
2583 LINK = i686-pc-mingw32-gcc -pipe -Wl,--enable-auto-import ;
2584 C++LINK = i686-pc-mingw32-g++ -pipe -Wl,--enable-auto-import ;
2585 AR = i686-pc-mingw32-ar -ru ;
2586 RANLIB = i686-pc-mingw32-ranlib ;
2588 actions WindozeResourceCompiler {
2589 i686-pc-mingw32-windres -i $(>) -o $(<)
2594 # ObjectNoAliasing filelist ;
2595 # turn off aliasing optimization for specified files
2596 # works only for gcc/g++
2597 rule ObjectNoAliasing {
2598 local isGCC = "ona" ;
2599 local isG++ = "ona" ;
2600 if ( "gcc" in $(CC) ) || ( $(JAM_TOOLSET) = MINGW ) { isGCC = "tan" ; }
2601 if ( "g++" in $(C++) ) || ( $(JAM_TOOLSET) = MINGW ) { isG++ = "tan" ; }
2602 if $(JAM_FORCE_GCC_OPTIONS) { isGCC = "tan" ; isG++ = "tan" ; }
2604 if $(isGCC) = "tan" { CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; }
2605 if $(isG++) = "tan" { C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; }
2606 OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ;
2610 rule gcc-suggest-attrs {
2612 CFLAGS.all += -Wsuggest-attribute=const ;
2613 CFLAGS.all += -Wsuggest-attribute=pure ;
2614 CFLAGS.all += -Wsuggest-attribute=noreturn ;
2620 # add output to var $(2)
2621 # return resulting (non-empty) string if library is present
2622 # if $(2) = "" -- don't add flags, just return
2623 # [ lib-config-ex "pkg-config sdl --cflags" : "CFLAGS" ]
2624 rule lib-config-ex {
2626 cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
2627 if $(cf[1]) = "0" && $(cf[2]) {
2639 # call $(1) --cflags and $(1) --libs (many libs provides such configurators)
2640 # add necessary flags to compiler and linker vars
2641 # return "tan" (non-empty string) if library is present
2642 # if $(2) != "" -- don't add flags, just check
2643 # [ lib-config "pkg-config sdl" ]
2647 cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
2649 if $(cf[1]) = "0" && $(cf[2]) {
2651 #Echo "flags:" $(cf[2-]) ;
2653 CCFLAGS += $(cf[2-]) ;
2654 C++FLAGS += $(cf[2-]) ;
2655 OBJCFLAGS += $(cf[2-]) ;
2659 lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
2661 if $(lf[1]) = "0" && $(lf[2]) {
2663 #Echo "flags:" $(lf[2-]) ;
2665 LINKFLAGS += $(lf[2-]) ;
2666 C++LINKFLAGS += $(lf[2-]) ;
2667 OBJCLINKFLAGS += $(lf[2-]) ;
2676 res = [ lib-config "pkg-config $(1)" ] ;
2681 rule pkg-config-has {
2683 res = [ lib-config-ex "pkg-config $(1) --cflags --libs" ] ;
2688 rule sys-has-command {
2691 cf = [ Command "which \"$(1)\" 2>/dev/null 1>&2" : exit-code code-first ] ;
2705 OBJC_GNUSTEP_BASE_LIB = gnustep-base ;
2706 OBJC_GNUSTEP_GUI_LIB = gnustep-gui ;
2711 rule ObjCUseGNUstepBase {
2712 if ! $(K8_INTERNAL_GNUSTEP_BASE) {
2713 #Echo "-l$(OBJC_GNUSTEP_BASE_LIB)" ;
2714 OBJCLINKLIBS += "-l$(OBJC_GNUSTEP_BASE_LIB)" ;
2715 K8_INTERNAL_GNUSTEP_BASE = tan ;
2719 rule ObjCUseGNUstepGui {
2720 ObjCUseGNUstepBase ;
2721 if ! $(K8_INTERNAL_GNUSTEP_GUI) {
2722 K8_INTERNAL_GNUSTEP_GUI = tan ;
2723 #Echo "-l$(OBJC_GNUSTEP_GUI_LIB)" ;
2724 OBJCLINKLIBS += "-l$(OBJC_GNUSTEP_GUI_LIB)" ;
2728 rule ObjCUseGNUstep {
2729 ObjCUseGNUstepBase ;
2735 # 'help' and 'push' targets
2737 rule ShowHelpProfile {
2738 NotFile help-profile ;
2739 Always help-profile ;
2740 AShowHelpProfile help-profile ;
2742 actions AShowHelpProfile {
2743 echo "profile flags:"
2744 echo " DEBUG=1 -- debug build"
2745 echo " OPT_SPEED=1 -- optimize for speed"
2746 echo " OPT_SIZE=1 -- optimize for size"
2747 echo " VALGRIND=1 -- do not strip debug info"
2748 echo " NO_WARNINGS=1 -- do not all '-Wall' flag"
2749 echo "WARNING: DON'T FORGET TO DO 'jam clean' before building with new flags!"
2757 #AShowHelpProfile help ;
2760 echo "WARNING: default help; override 'actions AShowHelp' definition to use 'help' target!"
2770 echo "WARNING: add 'actions AGitPush' definition to use 'push' target!"
2775 check-setup-windoze ;
2778 # Now include the user's Jamfile.
2780 include $(JAMFILE) ;