ah; i'm an idiot; fix for gcc-suggest-attrs
[k8jam.git] / defaults / Jambase
blobc6ceb07ff80f8d5deee7e3dc4266f6032cf8df51
2 # /+\
3 #  +\    Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
4 # \+/
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.
41 #Ketmar's changelog:
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:
138 # Statements:
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
152 # Special rules:
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
176 # Special targets:
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 ###############################################################################
195 # special values
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 ###############################################################################
215 # Windoze
216 ###############################################################################
217 if $(NT) {
218   PATH_SEPARATOR = "\\" ;
219   local SUPPORTED_TOOLSETS =
220     MINGW
221     LCC
222     PELLESC
223   ;
225   # if the JAM_TOOLSET environment variable is defined, check that it is
226   # one of our supported values
227   #
228   if $(JAM_TOOLSET) {
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:" ;
232       Echo ;
233       for t in $(SUPPORTED_TOOLSETS) { Echo "  " $(t) ; }
234       Exit ;
235     }
236   }
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\\" ;
242   }
244   MV        ?= move /y ;
245   CP        ?= copy ;
246   RM        ?= del /f/q ;
247   RMDIR     ?= rmdir /s/q ;
248   SLASH     ?= \\ ;
249   SUFLIB    ?= .lib ;
250   SUFOBJ    ?= .obj ;
251   SUFEXE    ?= .exe ;
252   SUFLIBSHR ?= .dll ;
254   if $(JAM_TOOLSET) = MINGW {
255     Echo "Compiler is GCC with MinGW" ;
256     AR           ?= ar -ru ;
257     RANLIB       ?= ranlib ;
258     CC           ?= mingw-gcc ;
259     CCFLAGS      ?= "" ;
260     C++          ?= mingw-g++ ;
261     C++FLAGS     ?= $(CCFLAGS) ;
262     LINK         ?= $(CC) ;
263     LINKFLAGS    ?= "" ;
264     LINKLIBS     ?= -lkernel32 ;
265     OPTIM        ?= ;
266     SUFOBJ        = .o ;
267     SUFLIB        = .a ;
268     SLASH         = / ;
269     # MinGW-specific thingy
270     MINGW_GUI     = "-Wl,-subsystem,windows" ;
271     MINGW_THREADS = "-mthreads" ;
272     # k8
273     C++OPTIM     ?= $(OPTIM) ;
274     C++LINK      ?= $(C++) ;
275     C++LINKFLAGS ?= $(LINKFLAGS) ;
276     C++LINKLIBS  ?= $(LINKLIBS) ;
277     #NOARSCAN     ?= true ;
278     # set path if any
279     if $(MINGW) {
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= )" ;
286     }
287   } else if $(JAM_TOOLSET) = LCC {
288     Echo "Compiler is Win32-LCC" ;
289     AR        ?= lcclib ;
290     CC        ?= lcc ;
291     CCFLAGS   ?= "" ;
292     C++       ?= "error" ;
293     LINK      ?= lcclnk ;
294     LINKFLAGS ?= "" ;
295     LINKLIBS  ?= "" ;
296     OPTIM     ?= ;
297     NOARSCAN   = true ;
298     # k8
299     C++LINK    = "error" ;
300   } else if $(JAM_TOOLSET) = PELLESC {
301     Echo "Compiler is PellesC" ;
302     AR        ?= polib ;
303     CC        ?= pocc ;
304     CCFLAGS   ?= "" ;
305     C++       ?= "error" ;
306     LINK      ?= polink ;
307     LINKFLAGS ?= ;
308     LINKLIBS  ?= ;
309     OPTIM     ?= ;
310     NOARSCAN   = true ;
311     LINKLIBS  ?= crt.lib oldnames.lib Win\\kernel32.lib ;
312     # k8
313     C++LINK    = "error" ;
314   } else {
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)" ;
317   }
318   STDHRS ?= "" ;
319   PICFLAGS = ;
321 ###############################################################################
322 # UNIX
323 ###############################################################################
324 else if $(UNIX) {
325   PATH_SEPARATOR = "/" ;
326   switch $(OS) {
327     case CYGWIN :
328       CC       ?= gcc ;
329       CCFLAGS  += -D__cygwin__ ;
330       LEX      ?= flex ;
331       JAMSHELL ?= sh -c ;
332       RANLIB   ?= "" ;
333       SUFEXE   ?= .exe ;
334       YACC     ?= bison -y ;
335     }
337     # UNIX defaults
338     CC        ?= gcc ;
339     C++       ?= g++ ;
340     OBJCC     ?= gcc ;
341     CCFLAGS   ?= ;
342     OBJCFLAGS ?= $(CCFLAGS) ;
343     C++FLAGS  ?= $(CCFLAGS) ;
344     CHMOD     ?= chmod ;
345     CHGRP     ?= chgrp ;
346     CHOWN     ?= chown ;
347     LEX       ?= flex ;
348     LINKFLAGS ?= $(CCFLAGS) ;
349     LINKLIBS  ?= ;
350     OPTIM     ?= ;
351     RANLIB    ?= ranlib ;
352     YACC      ?= bison ;
353     YACCGEN   ?= .c ;
354     YACCFILES ?= y.tab ;
355     YACCFLAGS ?= -ld ;
356 #!LIBTOOL!#    if $(K8_USE_LIBTOOL) {
357 #!LIBTOOL!#      SUFOBJSHR ?= .lo ;
358 #!LIBTOOL!#      SUFLIBSHR ?= .la ;
359 #!LIBTOOL!#    } else {
360 #!LIBTOOL!#      SUFOBJSHR ?= .o ;
361 #!LIBTOOL!#      SUFLIBSHR ?= .so ;
362 #!LIBTOOL!#    }
363     SUFOBJSHR ?= .o ;
364     SUFLIBSHR ?= .so ;
365 #!LIBTOOL!#
366     PICFLAGS  ?= -fpic ;
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) ;
376 # the D compiler
377 DC ?= dmd ;
380 # General defaults; a lot like UNIX
382 PATH_SEPARATOR ?= "/" ;
383 AR          ?= ar ru ;
384 AS          ?= as ;
385 ASFLAGS     ?= ;
386 AWK         ?= awk ;
387 BINDIR      ?= /usr/local/bin ;
388 C++         ?= g++ ;  # k8: was cc
389 C++FLAGS    ?= ;
390 CC          ?= gcc ;  # k8: was cc
391 CCFLAGS     ?= ;
392 CP          ?= cp -f ;
393 CRELIB      ?= ;
394 DOT         ?= . ;
395 DOTDOT      ?= .. ;
396 EXEMODE     ?= 755 ;
397 FILEMODE    ?= 644 ;
398 HDRS        ?= ;
399 INSTALLGRIST    ?= installed ;
400 JAMFILE     ?= Jamfile ;
401 JAMRULES    ?= Jamrules ;
402 LEX         ?= ;
403 LIBDIR      ?= /usr/local/lib ;
404 LINK        ?= $(CC) ;
405 LINKFLAGS   ?= ;
406 LINKLIBS    ?= ;
407 LN          ?= ln ;
408 MANDIR      ?= /usr/local/man ;
409 MKDIR       ?= mkdir ;
410 MV          ?= mv -f ;
411 OPTIM       ?= ;
412 RCP         ?= rcp ;
413 RM          ?= rm -f ;
414 RMDIR       ?= $(RM) ;
415 RSH         ?= rsh ;
416 SED         ?= sed ;
417 SHELLHEADER ?= "#!/bin/sh" ;
418 SHELLMODE   ?= 755 ;
419 SLASH       ?= / ;
420 SUBDIRRULES ?= ;
421 SUBDIRRESET ?= ASFLAGS HDRS C++FLAGS CCFLAGS ;
422 SUFEXE      ?= "" ;
423 SUFLIB      ?= .a ;
424 SUFOBJ      ?= .o ;
425 UNDEFFLAG   ?= "-u _" ;
426 YACC        ?= ;
427 YACCGEN     ?= ;
428 YACCFILES   ?= ;
429 YACCFLAGS   ?= ;
431 HDRPATTERN = "^[[:space:]]*#[[:space:]]*include[[:space:]]*[<\"]([^\">]*)[\">].*$" ;
433 OSFULL = $(OS)$(OSVER)$(OSPLAT) $(OS)$(OSPLAT) $(OS)$(OSVER) $(OS) ;
435 # k8
436 C++OPTIM     ?= $(OPTIM) ;
437 C++LINK      ?= $(C++) ;
438 C++LINKFLAGS ?= $(LINKFLAGS) ;
439 C++LINKLIBS  ?= $(LINKLIBS) ;
441 OBJCOPTIM     ?= $(OPTIM) ;
442 OBJCLINK      ?= $(CC) ;
443 OBJCLINKFLAGS ?= $(LINKFLAGS) ;
444 OBJCLINKLIBS  ?= $(LINKLIBS) ;
445 OBJCLINKLIBS  += -lobjc ;
447 if $(OS) = "LINUX" {
448   if ( "gcc" in $(CC) ) && ! ( "-pipe" in $(CC) ) { CC += -pipe ; }
449   if ( "g++" in $(C++) ) && ! ( "-pipe" in $(C++) ) { C++ += -pipe ; }
452 #Echo "OS:" $(OS) ;
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 ;
467 # Rules
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
477 rule As {
478   Depends $(<) : $(>) ;
479   ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ;
480   ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ;
483 # /Bulk  directory : sources ;
485 # Copies _sources_ into _directory_
487 rule Bulk {
488   local i ;
490   for i in $(>) {
491     File $(i:D=$(<)) : $(i) ;
492   }
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
505 rule Dc {
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
522 rule Cc {
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
545 rule C++ {
546   local ktmp ;
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.
556   ktmp = $(C++FLAGS) ;
557   if ! $(ktmp) { ktmp = $(CCFLAGS) ; }
558   C++FLAGS on $(<) += $(ktmp) $(SUBDIRC++FLAGS) ;
560   ktmp = $(C++OPTIM) ;
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
576 rule ObjC {
577   local ktmp ;
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) ] ;
600 # /Chmod target ;
602 # (Unix and VMS only). Change file permissions on _target_ to target-specific
603 # $(MODE) value set by @Link, @File, @Install* and @Shell rules
605 rule Chmod {
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_
620 rule File {
621   Depends files : $(<) ;
622   Depends $(<) : $(>) ;
623   SEARCH on $(>) = $(SEARCH_SOURCE) ;
624   MODE on $(<) = $(FILEMODE) ;
625   Chmod $(<) ;
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
633 # @Main rule)
635 rule GenFile {
636   local _t = [ FGristSourceFiles $(<) ] ;
637   local _s = [ FAppendSuffix $(>[1]) : $(SUFEXE) ] ;
638   Depends $(_t) : $(_s) $(>[2-]) ;
639   GenFile1 $(_t) : $(_s) $(>[2-]) ;
640   Clean clean : $(_t) ;
643 rule GenFile1 {
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
652 # (Unix only)
654 rule HardLink {
655   Depends files : $(<) ;
656   Depends $(<) : $(>) ;
657   SEARCH on $(>) = $(SEARCH_SOURCE) ;
661 # /HdrMacroFile
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.
669 rule HdrMacroFile {
670   HDRMACRO $(<) ;
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)
683 rule HdrRule {
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
694   # within ifdefs),
696   local s = $(>:G=$(HDRGRIST:E)) ;
698   Includes $(<) : $(s) ;
699   SEARCH on $(s) = $(HDRSEARCH) ;
700   NoCare $(s) ;
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
716 rule Lex {
717   ##LexMv $(<) : $(>) ;
718   Depends $(<) : $(>) ;
719   MakeLocate $(<) : $(LOCATE_SOURCE) ;
720   Clean clean : $(<) ;
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)
730 #  suffix is used
732 rule Library {
733   LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
734   Objects $(>) ;
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.
754 rule SharedLibrary {
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) ;
760   SharedObjects $(>) ;
763 ######################################################
764 # k8: REWORK!
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) ;
775 #!LIBTOOL!#  }
776 #!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
786 # directly.
788 rule LibraryFromObjects {
789   local _i _l _s ;
791   # Add grist to file names
792   _s = [ FGristFiles $(>) ] ;
793   _l = $(<:S=$(SUFLIB)) ;
795   # library depends on its member objects
796   if $(KEEPOBJS) {
797     Depends obj : $(_s) ;
798   } else {
799     Depends lib : $(_l) ;
800   }
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.
806   if ! $(_l:D) {
807     #!!MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ;
808     MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_LIB) ;
809   }
811   if $(NOARSCAN) {
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) ;
816   } else {
817     # If we can scan the library, we make the library depend
818     # on its members and each member depend on the on-disk
819     # object file.
820     Depends $(_l) : $(_l)($(_s:BS)) ;
821     for _i in $(_s) {
822       Depends $(_l)($(_i:BS)) : $(_i) ;
823     }
824   }
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
844 # directly
846 rule SharedLibraryFromObjects {
847   local _i _l _s ;
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
855   if $(KEEPOBJS) {
856     Depends obj : $(_s) ;
857   } else {
858     Depends lib : $(_l) ;
859   }
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.
865   if ! $(_l:D) {
866     #!!MakeLocate $(_l) : $(LOCATE_TARGET) ;
867     MakeLocate $(_l) : $(LOCATE_LIBSO) ;
868   }
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
880   #
881   #if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
883   # creating the library is so much fun on Unix :-)
884   if $(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= )" ;
888 #!LIBTOOL!#    } else {
889       LINKFLAGS on $(_l) += "-shared" ;
890       C++LINKFLAGS on $(_l) += "-shared" ;
891       LinkUnixLibrary $(_l) : $(_s) ;
892 #!LIBTOOL!#    }
893   } else if $(NT) {
894     local _implib = $(4) ;
895     local _def    = $(3) ;
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) ;
916     }
917     DllLink $(_l) : $(_s) ;
918   } else {
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" ;
921   }
925 # Since building shared libraries is so different depending on the
926 # compiler being used, I've broken this task into compiler-specific
927 # ones
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." ;
933   Exit ;
935   # the 'lcclnk' tool is absolutely broken:
936   #   - its -o flag doesn't work when there is a LIBRARY statement
937   #     in the .def file.
938   #
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 !!
942   #
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 !!
946   #
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
957 # supplied.
959 # Called by @Main, shouldn't be called by most people
961 rule Link {
962   MODE on $(<) = $(EXEMODE) ;
963   Chmod $(<) ;
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
971 # supplied.
973 # Called by @Main, shouldn't be called by most people
975 rule C++Link {
976   MODE on $(<) = $(EXEMODE) ;
977   Chmod $(<) ;
980 rule ObjC-Link {
981   MODE on $(<) = $(EXEMODE) ;
982   Chmod $(<) ;
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)
996 rule LinkLibraries {
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) ;
1017   if $(NT) {
1018     # on NT, we need to link agains the import library, not the DLL itself !!
1019     _ext = $(SUFLIBSHR)$(SUFLIB) ;
1020   }
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
1029 # @MainFromObjects.
1031 # _image_ may be supplied without suffix.
1033 rule Main {
1034   MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1035   Objects $(>) ;
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.
1046 rule C++Main {
1047   C++MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1048   Objects $(>) ;
1051 rule ObjC-Main {
1052   ObjC-MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1053   Objects $(>) ;
1057 # /MainFromObjects image : objects ;
1059 # Links _objects_ into _image_. Dependency of exe.
1060 # @MainFromObjects provides a default suffix for _image_
1062 rule MainFromObjects {
1063   local _s _t ;
1065   # Add grist to file names
1066   # Add suffix to exe
1067   _s = [ FGristFiles $(>) ] ;
1068   _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1069   # so 'jam foo' works when it's really foo.exe
1071   if $(_t) != $(<) {
1072     Depends $(<) : $(_t) ;
1073     NotFile $(<) ;
1074   }
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
1085   #
1086   #if $(JAM_TOOLSET) = BORLANDC {
1087   #  MakeLocate $(_t:S=.tds) : $(LOCATE_TARGET) ;
1088   #  Clean  clean : $(_t:S=.tds) ;
1089   #}
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 {
1101   local _s _t ;
1103   # Add grist to file names
1104   # Add suffix to exe
1105   _s = [ FGristFiles $(>) ] ;
1106   _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1107   # so 'jam foo' works when it's really foo.exe
1109   if $(_t) != $(<) {
1110     Depends $(<) : $(_t) ;
1111     NotFile $(<) ;
1112   }
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
1123   #
1124   #if $(JAM_TOOLSET) = BORLANDC {
1125   #  MakeLocate $(_t:S=.tds) : $(LOCATE_TARGET) ;
1126   #  Clean  clean : $(_t:S=.tds) ;
1127   #}
1129   C++Link $(_t) : $(_s) ;  ###k8:FIXME
1133 rule ObjC-MainFromObjects {
1134   local _s _t ;
1136   # Add grist to file names
1137   # Add suffix to exe
1138   _s = [ FGristFiles $(>) ] ;
1139   _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1140   # so 'jam foo' works when it's really foo.exe
1142   if $(_t) != $(<) {
1143     Depends $(<) : $(_t) ;
1144     NotFile $(<) ;
1145   }
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
1164 # directory
1166 rule MakeLocate {
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) ;
1173   local odir ;
1174   if $(srcdir) {
1175     odir = $(outdir)$(PATH_SEPARATOR)$(srcdir) ;
1176   } else {
1177     odir = $(outdir) ;
1178   }
1179   #Echo "MakeLocate:" "$(<)" "|" "$(>)" ;
1180   #Echo "srcname:" "$(srcname)" ;
1181   #Echo "srcdir :" "$(srcdir)" ;
1182   #Echo "outdir :" "$(outdir)" ;
1183   #Echo "odir   :" "$(odir)" ;
1184   if $(>) {
1185     LOCATE on $(<) = $(>) ;
1186     Depends $(<) : $(odir) ;
1187     MkDir $(odir) ;
1188   }
1192 # /MkDir  dir ;
1194 # Creates _dir_ and its parent directories
1196 rule MkDir {
1197   # Ignore timestamps on directories: we only care if they exist.
1198   NoUpdate $(<) ;
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
1205     $(<)-mkdir = true ;
1206     Depends dirs : $(<) ;
1207     MkDir1 $(<) ;
1209     # Recursively make parent directories.
1210     # $(<:P) = $(<)'s parent, & we recurse until root
1211     local s = $(<:P) ;
1213     # Don't try to create A: or A:\ on windows
1214     if $(NT) {
1215       switch $(s) {
1216         case "*:"   : s = ;
1217         case "*:\\" : s = ;
1218       }
1219     }
1220     # handle "C:", "C:/", "/cygdrive" and "/cygdrive/" in Cygwin
1221     if $(UNIX) && $(OS) = CYGWIN {
1222       switch $(s) {
1223         case "?:"   : s = ;
1224         case "?:/"  : s = ;
1225         case "<dir>/cygdrive"   : s = ;
1226         case "<dir>/cygdrive/"  : s = ;
1227       }
1228     }
1230     if $(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
1233       # it as NotFile.
1234       NotFile $(s) ;
1235     } else if $(s:G=) {
1236       # There's a parent; recurse.
1237       Depends $(<) : $(s) ;
1238       MkDir $(s) ;
1239     }
1240   }
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:
1255 rule Object {
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" {
1292     # do nothing
1293   } else {
1294     # if source is not .c, generate .c with specific rule
1295     switch $(>:S) {
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 $(<) : $(>) ;
1312     }
1313   }
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.
1347 rule LinkFlagsOn {
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
1386 rule ObjectHdrs {
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
1400 # automatically
1402 rule Objects {
1403   local _i ;
1405   for _i in [ FGristFiles $(<) ] {
1406     Object $(_i:S=$(SUFOBJ)) : $(_i) ;
1407     Depends obj : $(_i:S=$(SUFOBJ)) ;
1408   }
1412 # /SharedObjects
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
1416 # libraries.
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
1425   Objects $(<) ;
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:?
1439 #!LIBTOOL!#    }
1440 #!LIBTOOL!#  }
1444 rule RmTemps {
1445   Temporary $(>) ;
1449 rule Setuid {
1450   MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;
1454 rule Shell {
1455   Depends shell : $(<) ;
1456   Depends $(<) : $(>) ;
1457   SEARCH on $(>) = $(SEARCH_SOURCE) ;
1458   MODE on $(<) = $(SHELLMODE) ;
1459   Clean clean : $(<) ;
1460   Chmod $(<) ;
1464 rule SoftLink {
1465   Depends files : $(<) ;
1466   Depends $(<) : $(>) ;
1467   SEARCH on $(>) = $(SEARCH_SOURCE) ;
1468   Clean clean : $(<) ;
1472 rule SubDir {
1473   #
1474   # SubDir TOP d1 d2 ... ;
1475   #
1476   # Support for a project tree spanning multiple directories.
1477   #
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.
1481   #
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.
1485   #
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 ...
1489   #
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.
1493   #
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.
1498   #
1499   # SubDir's public variables:
1500   #
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
1511   #
1512   local _top = $(<[1]) ;
1513   local _tokens = $(<[2-]) ;
1515   local ktmp ;
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:
1524     #
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)
1531     #
1532     if $($(_top)) {
1533       # TOP externally set.
1534       # We'll ignore the relative (UP/DOWN) path that
1535       # got us here, and instead remember the hard ROOT.
1536       $(_top)-UP = ;
1537       $(_top)-DOWN = ;
1538       $(_top)-ROOT = $($(_top)) ;
1539     } else {
1540       # TOP not preset.
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.
1549       #
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.
1558       #
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) ] ;
1594     }
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) ;
1602     SUBDIR_DOWN = ;
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) ;
1610     } else {
1611       NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1612       include $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1613     }
1614   }
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
1652   # penalty.
1653   #
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) $(<) ;
1668 rule FSubDirPath {
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 += $(<) ;
1705 rule SubDirHdrs {
1706   SUBDIRHDRS += [ FDirName $(<) ] ;
1710 rule SubIncludeMany {
1711   # SubIncludeMany TOP d1 ... ;
1712   #
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
1717   # with its own TOP.
1718   #Echo "including " $(<) " : " $(>) ;
1720   if ! $($(<[1])) { Exit "SubIncludeMany" $(<[1]) "without prior SubDir" $(<[1]) ; }
1721   SubDir $(<) ;
1722   include $(JAMFILE:D=$(SUBDIR)) ;
1726 rule SubIncludeOnce {
1727   # SubIncludeOnce varname : TOP d1 ... ;
1728   #
1729   # Include a subdirectory's Jamfile.
1731   local _vn = $(<[1]) ;
1732   if ! $($(_vn)) {
1733     #Echo "processing $(_vn)" ;
1734     #Echo "$(>)" ;
1735     $(_vn) = tan ;
1736     SubIncludeMany $(>) ;
1737   #} else {
1738   #  Echo "skiped $(_vn) -- $($(_vn))" ;
1739   #  Echo "$(>)" ;
1740   }
1744 rule SubInclude {
1745   # SubInclude TOP d1 ... ;
1746   #
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) : $(<) ;
1754 rule SubRules {
1755   # SubRules TOP d1 ... : Other-TOP ;
1756   #
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]) ; }
1760   SubDir $(<) ;
1761   SubDir $(>) ;
1765 rule Undefines {
1766   UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;
1770 rule UserObject {
1771   Exit "Unknown suffix on" $(>) "- see UserObject rule in Jamfile(5)." ;
1775 rule Yacc {
1776   local _h ;
1778   _h = $(<:BS=.h) ;
1780   # Some places don't have a yacc.
1781   MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ;
1782   #MakeLocate $(>) $(_h) : $(LOCATE_SOURCE) ;
1784   if $(YACC) {
1785     #local tmp ;
1786     #tmp = $(<:G=:D) ;
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 "=========================" ;
1799     #
1800     Depends $(<) $(_h) : $(>) ;
1801     Yacc1 $(<) : $(>) ;
1802     #Yacc1 $(<) $(_h) : $(>) ;
1803     #YaccMv $(<) $(_h) : $(>) ;
1804     Clean clean : $(<) $(_h) ;
1805   }
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
1822 rule FGrist {
1823   return $(<:J=!) ;
1827 rule FGristFiles {
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.
1837   #
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
1843 #  # visibility.
1844 #  if ! $(SOURCE_GRIST) {
1845 #    return $(<) ;
1846 #  } else {
1847 #    local _i _o ;
1849 #    for _i in $(<) {
1850 #      switch $(_i) {
1851 #        case *.h : _o += $(_i) ;
1852 #        case *   : _o += $(_i:G=$(SOURCE_GRIST)) ;
1853 #      }
1854 #    }
1855 #    return $(_o) ;
1856 #  }
1857   return [ FGristFiles $(<) ] ;
1861 rule FReverse {
1862   if $(1) { return [ FReverse $(1[2-]) ] $(1[1]) ; }
1866 rule FSubDir {
1867   # If $(>) is the path to the current directory, compute the
1868   # path (using ../../ etc) back to that root directory.
1869   # Sets result in $(<)
1870   if ! $(<[1]) {
1871     return $(DOT) ;
1872   } else {
1873     local _i _d ;
1875     _d = $(DOTDOT) ;
1876     for _i in $(<[2-]) { _d = $(_d:R=$(DOTDOT)) ; }
1877     return $(_d) ;
1878   }
1882 rule FStripCommon {
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 $(<) : $(>) ;
1891   }
1895 rule FRelPath {
1896   local _l _r ;
1898   # first strip off common parts
1899   _l = $(<) ;
1900   _r = $(>) ;
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.
1917   if $(>) {
1918     local _i _o ;
1920     for _i in $(<) {
1921       if $(_i:S) { _o += $(_i) ; } else { _o += $(_i:S=$(>)) ; }
1922     }
1923     return $(_o) ;
1924   } else {
1925     return $(<) ;
1926   }
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$(<) ; }
1939 rule FDirName {
1940   # Turn individual elements in $(<) into a usable path.
1941   local _i ;
1942   local _s = $(DOT) ;
1944   for _i in $(<) { _s = $(_i:R=$(_s)) ; }
1945   return $(_s) ;
1949 if $(NT) && $(JAM_TOOLSET) != MINGW && $(JAM_TOOLSET) != LCC {
1950   rule FDefines { return /D$(<) ; }
1951   rule FIncludes { return /I$(<) ; }
1956 # various install rules
1959 rule InstallInto {
1960   # InstallInto dir : sources ;
1962   local i t ;
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
1978   for i in $(>) {
1979     local tt = $(i:G=$(INSTALLGRIST)) ;
1981     Depends $(tt) : $(i) ;
1982     Install $(tt) : $(i) ;
1983     Chmod $(tt) ;
1985     if $(OWNER) && $(CHOWN) {
1986       Chown $(tt) ;
1987       OWNER on $(tt) = $(OWNER) ;
1988     }
1989     if $(GROUP) && $(CHGRP) {
1990       Chgrp $(tt) ;
1991       GROUP on $(tt) = $(GROUP) ;
1992     }
1993   }
1997 # /InstallBin dir : sources ;
1999 # Copy _sources_ into _dir_ with mode $(EXEMODE)
2001 rule InstallBin {
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)
2013 rule InstallFile {
2014   InstallInto $(<) : $(>) ;
2015   MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2019 # /InstallLib dir : sources ;
2021 # Copy _sources_ into _dir_ with mode $(FILEMODE)
2023 rule InstallLib {
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
2033 #  sources.
2035 rule InstallMan {
2036   # Really this just strips the . from the suffix
2037   local i s d ;
2039   for i in $(>) {
2040     switch $(i:S) {
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 ;
2045     }
2046     d = man$(s) ;
2047     InstallInto $(d:R=$(<)) : $(i) ;
2048   }
2049   MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2053 # /InstallShell dir : sources ;
2055 # Copy _sources_ into _dir_ with mode $(SHELLMODE)
2057 rule InstallShell {
2058   InstallInto $(<) : $(>) ;
2059   MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;
2063 rule WindozeResourceCompiler {
2064   DEPENDS $(<) : $(>) ;
2065   Clean clean : $(<) ;
2068 rule windoze-fix {
2069   if $(WINDOZE) {
2070     if $(WINDOZE_THREADS) {
2071       CC += -mthreads ;
2072       CC++ += -mthreads ;
2073     }
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 ; }
2079   }
2084 # Actions
2086 actions WindozeResourceCompiler {
2087   "$(WINE)" $(MGPATH)windres.exe -i $(>) -o $(<)
2091 # First the defaults
2093 actions updated together piecemeal Archive {
2094   $(AR) $(<) $(>)
2098 actions As {
2099   $(AS) $(ASFLAGS) $(ASHDRS) -o $(<) $(>)
2103 actions Cc {
2104   $(CC) -c -o $(<) $(CFLAGS.all) $(CCFLAGS) $(OPTIM.all) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2108 actions C++ {
2109   $(C++) -c -o $(<) $(CFLAGS.all) $(C++FLAGS) $(OPTIM.all) $(C++OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2113 actions ObjC {
2114   $(OBJCC) -c -o $(<) $(CFLAGS.all) $(OBJCFLAGS) $(OPTIM.all) $(OBJCOPTIM) $(CCDEFS) $(CCHDRS) $(>)
2118 actions Dc {
2119   $(DC) -c -of$(<) $(DCFLAGS) $(DOPTIM) $(>)
2123 actions Chgrp {
2124   $(CHGRP) $(GROUP) $(<)
2128 actions Chmod1 {
2129   $(CHMOD) $(MODE) $(<)
2133 actions Chown {
2134   $(CHOWN) $(OWNER) $(<)
2138 actions piecemeal together existing Clean {
2139   $(RM) $(>)
2143 actions File {
2144   $(CP) $(>) $(<)
2148 actions GenFile1 {
2149   $(>[1]) $(<) $(>[2-])
2153 actions HardLink {
2154   $(RM) $(<) && $(LN) $(>) $(<)
2158 actions Install {
2159   $(CP) $(>) $(<)
2163 actions Lex {
2164   $(LEX) -o $(<) $(>)
2168 ##actions LexMv {
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)
2195 actions MkDir1 {
2196   $(MKDIR) $(<)
2200 actions together Ranlib {
2201   $(RANLIB) $(<)
2205 actions quietly updated piecemeal together RmTemps {
2206   $(RM) $(>)
2210 actions Shell {
2211 #DONT_TOUCH
2212   $(AWK) '
2213     NR == 1 { print "$(SHELLHEADER)" }
2214     NR == 1 && /^[#:]/ { next }
2215     /^##/ { next }
2216     { print }
2217   ' < $(>) > $(<)
2218 #DONT_TOUCH
2222 actions SoftLink {
2223   $(RM) $(<) && $(LN) -s $(>) $(<)
2227 actions Yacc1 {
2228   $(YACC) $(YACCFLAGS) $(>) -o $(<)
2232 actions YaccMv {
2233   #$(MV) $(YACCFILES).c $(<[1])
2234   #$(MV) $(YACCFILES).h $(<[2])
2239 # RELOCATE - for compilers with broken -o flags
2241 if $(RELOCATE) {
2242   actions C++ {
2243     $(C++) -c $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2244   }
2245   actions Cc {
2246     $(CC) -c $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2247   }
2248   actions ignore CcMv {
2249     [ $(<) != $(>:BS=$(SUFOBJ)) ] && $(MV) $(>:BS=$(SUFOBJ)) $(<)
2250   }
2255 # NOARUPDATE - can't update an archive
2257 if $(NOARUPDATE) {
2258   actions Archive {
2259     $(AR) $(<) $(>)
2260   }
2265 # UNIX specific actions
2267 if $(UNIX) {
2268   actions GenFile1 {
2269     PATH="$PATH:."
2270     $(>[1]) $(<) $(>[2-])
2271   }
2276 # NT specific actions
2278 if $(NT) {
2279   if $(JAM_TOOLSET) = MINGW {
2280     actions together piecemeal Archive {
2281       $(AR) $(<) $(>:T)
2282     }
2283     actions Cc {
2284       $(CC) -c -o $(<) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2285     }
2286     actions C++ {
2287       $(C++) -c -o $(<) $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2288     }
2289     actions DllLink bind DEFFILENAME IMPLIBNAME {
2290       $(LINK) $(LINKFLAGS) -shared -o $(<) $(>) $(DEFFILENAME) -Wl,--out-implib,$(IMPLIBNAME)
2291     }
2292   } else if $(JAM_TOOLSET) = LCC {
2293     actions together piecemeal Archive {
2294       $(AR) /out:$(<) $(>)
2295     }
2296     actions Cc {
2297       $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -Fo$(<) -I$(STDHDRS) $(>)
2298     }
2299     actions Link bind NEEDLIBS {
2300       $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2301     }
2302     actions DllLink bind NEEDLIBS DEFFILENAME {
2303       $(LINK) $(LINKFLAGS) -DLL -o $(<) $(UNDEFS) $(>) $(DEFFILENAME) $(NEEDLIBS) $(LINKLIBS)
2304     }
2305     actions ignore DllLinkMv {
2306       $(MV) $(2) $(1)
2307     }
2308     actions Shell {
2309       $(CP) $(>) $(<)
2310     }
2311   } else if $(JAM_TOOLSET) = PELLESC {
2312     actions together piecemeal Archive {
2313       $(AR) /OUT:$(<) $(>)
2314     }
2315     actions Cc {
2316       $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS)   /Fo $(<) -I$(STDHDRS)  $(>)
2317     }
2318     actions Link bind NEEDLIBS {
2319       $(LINK) $(LINKFLAGS) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2320     }
2321     actions DllLink bind NEEDLIBS DEFFILENAME IMPLIBNAME {
2322       $(LINK) $(LINKFLAGS) /DLL /DEF:$(DEFFILENAME) /IMPLIB:$(IMPLIBNAME) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2323     }
2324     actions Shell {
2325       $(CP) $(>) $(<)
2326     }
2327   }
2332 # Ketmar's additions
2334 rule SetCPUFlags {
2335   if $(OS) != "LINUX" {
2336     DETECTED_CPU = "i486" ;
2337     OPTIM_SPEED = -O3 -march=i486 -mtune=i486 ;
2338   } else {
2339     DETECTED_CPU = native ;
2340     OPTIM_SPEED = -O3 -march=native -mtune=native ;
2341   }
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) ;
2349   local str = $(2) ;
2350   local res = ;
2351   local f ;
2352   local t ;
2353   #Echo "removing " $(oname) " from " $(str) ;
2354   for f in $(str) {
2355     t = [ Match $(oname) : $(f) ] ;
2356     #Echo $(f) ": " $(t) ;
2357     if $(t[1]) = "" {
2358       #Echo "include: " $(f) ;
2359       res += $(f) ;
2360     }
2361   }
2362   return $(res) ;
2366 # profile rules
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
2373   standard      # -O2
2377 rule --k8jam-profile-none {
2378   Echo "MSG: default profile" ;
2379   OPT_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" ;
2417   CFLAGS.all += -O2 ;
2418   LINKFLAGS.all += -s ;
2422 # profile "name" ;
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
2430 #  standard: -O2
2431 rule profile {
2432   if ! $(1) in $(K8JAM-KNOWN-PROFILES) {
2433     Echo "known profiles: $(K8JAM-KNOWN-PROFILES)" ;
2434     Exit "unknown profile: $(1)" ;
2435   }
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:
2456 #  DEBUG = 1 : debug
2457 #  OPT_SIZE = 1 : size
2458 #  OPT_SPEED = 1 : speed
2459 #  default: standard
2460 rule set-profile {
2461   if $(DEBUG) {
2462     profile "debug" ;
2463   } else if $(OPT_SIZE) {
2464     profile "size" ;
2465   } else if $(OPT_SPEED) {
2466     profile "speed" ;
2467   } else {
2468     profile "standard" ;
2469   }
2470   if $(VALGRIND) {
2471     CFLAGS.all -= "-g" "-s" ;
2472     LINKFLAGS.all -= "-g" "-s" ;
2473     CFLAGS.all += -g ;
2474     LINKFLAGS.all += -g ;
2475   }
2476   if ! $(NO_WARNINGS) {
2477     CFLAGS.all += -Wall ;
2478   }
2482 # set default 'locate' vars -- _build/, etc
2483 rule set-default-subdir-locates {
2484   local d = $(TOP) ;
2485   if ! $(d) { d = "." ; }
2486   ALL_LOCATE_BIN = $(d) ;
2487   ALL_LOCATE_LIBSO = $(d) ;
2488   if $(WINDOZE) {
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 ;
2492   } else {
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 ;
2496   }
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 ;
2515 # windoze setup
2518 rule setup-windoze {
2519   if ! $(WINDOZE) { WINDOZE = 1 ; }
2520   PICFLAGS = ;
2521   SUFLIBSHR = .dll ;
2522   #WINDOZE_THREADS = -mthreads ;
2523   #WINDOZE_THREADS = ;
2524   WINE ?= "wine" ;
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" ;
2540   SUFEXE = .exe ;
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 ;
2572   }
2576 # call $(1)
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 {
2582   local cf lf res ;
2583   cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
2584   if $(cf[1]) = "0" && $(cf[2]) {
2585     res = $(cf[2-]) ;
2586     if $(2) {
2587       $(2) += $(cf[2-]) ;
2588     }
2589   } else {
2590     res = ;
2591   }
2592   return $(res) ;
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" ]
2601 rule lib-config {
2602   local cf lf hasit ;
2604   cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
2605   #Echo "cf:" $(cf) ;
2606   if $(cf[1]) = "0" && $(cf[2]) {
2607     hasit = "tan" ;
2608     #Echo "flags:" $(cf[2-]) ;
2609     if ! $(2) {
2610       CCFLAGS += $(cf[2-]) ;
2611       C++FLAGS += $(cf[2-]) ;
2612       OBJCFLAGS += $(cf[2-]) ;
2613     }
2614   }
2616   lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
2617   #Echo "lf:" $(lf) ;
2618   if $(lf[1]) = "0" && $(lf[2]) {
2619     hasit = "tan" ;
2620     #Echo "flags:" $(lf[2-]) ;
2621     if ! $(2) {
2622       LINKFLAGS += $(lf[2-]) ;
2623       C++LINKFLAGS += $(lf[2-]) ;
2624       OBJCLINKFLAGS += $(lf[2-]) ;
2625     }
2626   }
2628   return $(hasit) ;
2631 rule pkg-config {
2632   local res ;
2633   res = [ lib-config "pkg-config $(1)" ] ;
2634   return $(res) ;
2638 rule pkg-config-has {
2639   local res ;
2640   res = [ lib-config-ex "pkg-config $(1) --cflags --libs" ] ;
2641   return $(res) ;
2646 # Objective C vars
2649 OBJC_GNUSTEP_BASE_LIB = gnustep-base ;
2650 OBJC_GNUSTEP_GUI_LIB = gnustep-gui ;
2653 # Objective C rules
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 ;
2660   }
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)" ;
2669   }
2672 rule ObjCUseGNUstep {
2673   ObjCUseGNUstepBase ;
2674   ObjCUseGNUstepGui ;
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!"
2695 ShowHelpProfile ;
2697 rule ShowHelp {
2698   NotFile help ;
2699   Always help ;
2700   AShowHelp help ;
2701   #AShowHelpProfile help ;
2703 actions AShowHelp {
2704   echo "WARNING: default help; override 'actions AShowHelp' definition to use 'help' target!"
2706 ShowHelp ;
2708 rule GitPush {
2709   NotFile push ;
2710   Always push ;
2711   AGitPush push ;
2713 actions AGitPush {
2714   echo "WARNING: add 'actions AGitPush' definition to use 'push' target!"
2716 GitPush ;
2719 check-setup-windoze ;
2722 # Now include the user's Jamfile.
2724 include $(JAMFILE) ;