one now should call 'setup-windoze' as the 1st rule if he wants windoze builds
[k8jam.git] / defaults / Jambase
blob6ce8dc4011d87fa0916c4bbb6cad902133f12aba
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
61 # Special targets defined in this file:
63 # all       - parent of first, shell, files, lib, exe
64 # first     - first dependent of 'all', for potential initialization
65 # shell     - parent of all Shell targets
66 # files     - parent of all File targets
67 # lib       - parent of all Library targets
68 # exe       - parent of all Main targets
69 # dirs      - parent of all MkDir targets
70 # clean     - removes all Shell, File, Library, and Main targets
71 # uninstall - removes all Install targets
74 # Rules defined by this file:
76 # as obj.o : source.s ;                  .s -> .o
77 # Bulk dir : files ;                     populate directory with many files
78 # Cc obj.o : source.c ;                  .c -> .o
79 # C++ obj.o : source.cc ;                .cc -> .o
80 # Clean clean : sources ;                remove sources with 'jam clean'
81 # File dest : source ;                   copy file
82 # GenFile source.c : program args ;      make custom file
83 # HardLink target : source ;             make link from source to target
84 # HdrRule source : headers ;             handle #includes
85 # InstallInto dir : sources ;            install any files
86 # InstallBin dir : sources ;             install binaries
87 # InstallLib dir : sources ;             install files
88 # InstallFile dir : sources ;            install files
89 # InstallMan dir : sources ;             install man pages
90 # InstallShell dir : sources ;           install shell scripts
91 # Lex source.c : source.l ;              .l -> .c
92 # Library lib : source ;                 archive library from compiled sources
93 # LibraryFromObjects lib : objects ;     archive library from objects
94 # LinkLibraries images : libraries ;     bag libraries onto Mains
95 # Main image : source ;                  link executable from compiled sources
96 # C++Main image : source ;               link c++ executable from compiled sources
97 # ObjC-Main image : source ;             link obj-c executable from compiled sources
98 # MainFromObjects image : objects ;      link executable from objects
99 # C++MainFromObjects image : objects ;   link c++ executable from objects
100 # ObjC-MainFromObjects image : objects ; link obj-c executable from objects
101 # MkDir dir ;                            make a directory, if not there
102 # Object object : source ;               compile object from source
103 # ObjectCcFlags source : flags ;         add compiler flags for object
104 # ObjectC++Flags source : flags ;        add compiler flags for object
105 # ObjectObjCFlags source : flags ;       add compiler flags for object
106 # ObjectHdrs source : dirs ;             add include directories for object
107 # Objects sources ;                      compile sources
108 # RmTemps target : sources ;             remove temp sources after target made
109 # Setuid images ;                        mark executables Setuid
110 # SoftLink target : source ;             make symlink from source to target
111 # SubDir TOP d1 d2 ... ;                 start a subdirectory Jamfile
112 # SubDirCcFlags flags ;                  add compiler flags until next SubDir
113 # SubDirC++Flags flags ;                 add compiler flags until next SubDir
114 # SubDirHdrs d1 d2 ... ;                 add include dir until next SubDir
115 # SubInclude TOP d1 d2 ... ;             include a subdirectory Jamfile
116 # Shell exe : source ;                   make a shell executable
117 # Undefines images : symbols ;           save undef's for linking
118 # UserObject object : source ;           handle unknown suffixes for Object
119 # Yacc source.c : source.y ;             .y -> .c
121 # Utility rules that have no side effects (not supported):
123 # FAppendSuffix f1 f2 ... : $(SUF) ;     return $(<) with suffixes
124 # FDirName d1 d2 ... ;                   return path from root to dir
125 # FGrist d1 d2 ... ;                     return d1!d2!...
126 # FGristFiles value ;                    return $(value:G=$(SOURCE_GRIST))
127 # FGristSourceFiles value ;              return $(value:G=$(SOURCE_GRIST))
128 # FStripCommon v1 : v2 ;                 strip common initial parts of v1 v2
129 # FReverse a1 a2 ... ;                   return ... a2 a1
130 # FRelPath d1 : d2 ;                     return rel path from d1 to d2
131 # FSubDir d1 d2 ... ;                    return path to root
135 # Brief review of the jam language:
137 # Statements:
138 #   rule RULE - statements to process a rule
139 #   actions RULE - system commands to carry out target update
141 # Modifiers on actions:
142 #   together - multiple instances of same rule on target get executed
143 #          once with their sources ($(>)) concatenated
144 #   updated - refers to updated sources ($(>)) only
145 #   ignore - ignore return status of command
146 #   quietly - don't trace its execution unless verbose
147 #   piecemeal - iterate command each time with a small subset of $(>)
148 #   existing - refers to currently existing sources ($(>)) only
149 #   bind vars - subject to binding before expanding in actions
151 # Special rules:
152 #   Always - always build a target
153 #   Depends - builds the dependency graph
154 #   Echo - blurt out targets on stdout
155 #   Exit - blurt out targets and exit
156 #   Includes - marks sources as headers for target (a codependency)
157 #   NoCare - don't panic if the target can't be built
158 #   NoUpdate - create the target if needed but never update it
159 #   NotFile - ignore the timestamp of the target (it's not a file)
160 #   Temporary - target need not be present if sources haven't changed
162 # Special variables set by jam:
163 #   $(<) - targets of a rule (to the left of the :)
164 #   $(>) - sources of a rule (to the right of the :)
165 #   $(xxx) - true on xxx (UNIX, VMS, NT, OS2, MAC)
166 #   $(OS) - name of OS - varies wildly
167 #   $(JAMVERSION) - version number (2.5)
169 # Special variables used by jam:
170 #   SEARCH - where to find something (used during binding and actions)
171 #   LOCATE - where to plop something not found with SEARCH
172 #   HDRRULE - rule to call to handle include files
173 #   HDRSCAN - egrep regex to extract include files
175 # Special targets:
176 #   all - default if none given on command line
179 # for perforce use -- jambase version
181 #JAMBASEDATE = 2004.10.07 ;
183 #THIS_IS_KJAM = "tan" ; # we are using kjam; removed as obsolete
184 THIS_IS_K8JAM = "tan" ; # we are using k8jam
186 # set to 'tan' for old 'libtool' behavior
187 #!LIBTOOL!#K8_USE_LIBTOOL = ;
190 # Initialize variables
193 ###############################################################################
194 # special values
195 ###############################################################################
197 OPTIM_SPEED = -O3 -march=native -mtune=native -mfpmath=sse ;
198 LINKFLAGS_SPEED = -s ;
200 OPTIM_SIZE = -Os -march=native -mtune=native ;
201 LINKFLAGS_SIZE = -s ;
203 OPTIM_DEBUG = -O0 -g ;
204 LINKFLAGS_DEBUG = -g ;
206 OPTIM_NOALIAS = -fno-strict-aliasing ;
210 # OS specific variable settings
213 ###############################################################################
214 # Windoze
215 ###############################################################################
216 if $(NT) {
217   PATH_SEPARATOR = "\\" ;
218   local SUPPORTED_TOOLSETS =
219     MINGW
220     LCC
221     PELLESC
222   ;
224   # if the JAM_TOOLSET environment variable is defined, check that it is
225   # one of our supported values
226   #
227   if $(JAM_TOOLSET) {
228     if ! $(JAM_TOOLSET) in $(SUPPORTED_TOOLSETS) {
229       Echo "The JAM_TOOLSET environment variable is defined but its value" ;
230       Echo "is invalid, please use one of the following:" ;
231       Echo ;
232       for t in $(SUPPORTED_TOOLSETS) { Echo "  " $(t) ; }
233       Exit ;
234     }
235   }
237   if ! $(JAM_TOOLSET) {
238     Echo "The JAM_TOOLSET environment variable is not defined, defaults to MINGW" ;
239     JAM_TOOLSET = MINGW ;
240     MINGW = "c:\\mingw\\" ;
241   }
243   MV        ?= move /y ;
244   CP        ?= copy ;
245   RM        ?= del /f/q ;
246   RMDIR     ?= rmdir /s/q ;
247   SLASH     ?= \\ ;
248   SUFLIB    ?= .lib ;
249   SUFOBJ    ?= .obj ;
250   SUFEXE    ?= .exe ;
251   SUFLIBSHR ?= .dll ;
253   if $(JAM_TOOLSET) = MINGW {
254     Echo "Compiler is GCC with MinGW" ;
255     AR           ?= ar -ru ;
256     RANLIB       ?= ranlib ;
257     CC           ?= mingw-gcc ;
258     CCFLAGS      ?= "" ;
259     C++          ?= mingw-g++ ;
260     C++FLAGS     ?= $(CCFLAGS) ;
261     LINK         ?= $(CC) ;
262     LINKFLAGS    ?= "" ;
263     LINKLIBS     ?= -lkernel32 ;
264     OPTIM        ?= ;
265     SUFOBJ        = .o ;
266     SUFLIB        = .a ;
267     SLASH         = / ;
268     # MinGW-specific thingy
269     MINGW_GUI     = "-Wl,-subsystem,windows" ;
270     MINGW_THREADS = "-mthreads" ;
271     # k8
272     C++OPTIM     ?= $(OPTIM) ;
273     C++LINK      ?= $(C++) ;
274     C++LINKFLAGS ?= $(LINKFLAGS) ;
275     C++LINKLIBS  ?= $(LINKLIBS) ;
276     #NOARSCAN     ?= true ;
277     # set path if any
278     if $(MINGW) {
279       CC = "$(MINGW)$(CC:J= )" ;
280       C++ = "$(MINGW)$(C++:J= )" ;
281       LINK = "$(MINGW)$(LINK:J= )" ;
282       C++LINK = "$(MINGW)$(C++LINK:J= )" ;
283       AR = "$(MINGW)$(AR:J= )" ;
284       RANLIB = "$(MINGW)$(RANLIB:J= )" ;
285     }
286   } else if $(JAM_TOOLSET) = LCC {
287     Echo "Compiler is Win32-LCC" ;
288     AR        ?= lcclib ;
289     CC        ?= lcc ;
290     CCFLAGS   ?= "" ;
291     C++       ?= "error" ;
292     LINK      ?= lcclnk ;
293     LINKFLAGS ?= "" ;
294     LINKLIBS  ?= "" ;
295     OPTIM     ?= ;
296     NOARSCAN   = true ;
297     # k8
298     C++LINK    = "error" ;
299   } else if $(JAM_TOOLSET) = PELLESC {
300     Echo "Compiler is PellesC" ;
301     AR        ?= polib ;
302     CC        ?= pocc ;
303     CCFLAGS   ?= "" ;
304     C++       ?= "error" ;
305     LINK      ?= polink ;
306     LINKFLAGS ?= ;
307     LINKLIBS  ?= ;
308     OPTIM     ?= ;
309     NOARSCAN   = true ;
310     LINKLIBS  ?= crt.lib oldnames.lib Win\\kernel32.lib ;
311     # k8
312     C++LINK    = "error" ;
313   } else {
314     # XXX: We need better comments here !!
315     Exit "On NT, set MINGW to the root of the MinGW dir (but it won't help you anyway)" ;
316   }
317   STDHRS ?= "" ;
318   PICFLAGS = ;
320 ###############################################################################
321 # UNIX
322 ###############################################################################
323 else if $(UNIX) {
324   PATH_SEPARATOR = "/" ;
325   switch $(OS) {
326     case CYGWIN :
327       CC       ?= gcc ;
328       CCFLAGS  += -D__cygwin__ ;
329       LEX      ?= flex ;
330       JAMSHELL ?= sh -c ;
331       RANLIB   ?= "" ;
332       SUFEXE   ?= .exe ;
333       YACC     ?= bison -y ;
334     }
336     # UNIX defaults
337     CC        ?= gcc ;
338     C++       ?= g++ ;
339     OBJCC     ?= gcc ;
340     CCFLAGS   ?= ;
341     OBJCFLAGS ?= $(CCFLAGS) ;
342     C++FLAGS  ?= $(CCFLAGS) ;
343     CHMOD     ?= chmod ;
344     CHGRP     ?= chgrp ;
345     CHOWN     ?= chown ;
346     LEX       ?= flex ;
347     LINKFLAGS ?= $(CCFLAGS) ;
348     LINKLIBS  ?= ;
349     OPTIM     ?= ;
350     RANLIB    ?= ranlib ;
351     YACC      ?= bison ;
352     YACCGEN   ?= .c ;
353     YACCFILES ?= y.tab ;
354     YACCFLAGS ?= -ld ;
355 #!LIBTOOL!#    if $(K8_USE_LIBTOOL) {
356 #!LIBTOOL!#      SUFOBJSHR ?= .lo ;
357 #!LIBTOOL!#      SUFLIBSHR ?= .la ;
358 #!LIBTOOL!#    } else {
359 #!LIBTOOL!#      SUFOBJSHR ?= .o ;
360 #!LIBTOOL!#      SUFLIBSHR ?= .so ;
361 #!LIBTOOL!#    }
362     SUFOBJSHR ?= .o ;
363     SUFLIBSHR ?= .so ;
364 #!LIBTOOL!#
365     PICFLAGS  ?= -fpic ;
366     STDHDRS   ?= /usr/include ;
368   if $(WINDOZE) { setup-windoze ; }
371 # shared library object file suffix. We assume that it is identical
372 # than the normal one
373 SUFOBJSHR ?= $(SUFOBJ) ;
374 SUFLIBSHR ?= $(SUFLIB) ;
377 # the D compiler
378 DC ?= dmd ;
381 # General defaults; a lot like UNIX
383 PATH_SEPARATOR ?= "/" ;
384 AR          ?= ar ru ;
385 AS          ?= as ;
386 ASFLAGS     ?= ;
387 AWK         ?= awk ;
388 BINDIR      ?= /usr/local/bin ;
389 C++         ?= g++ ;  # k8: was cc
390 C++FLAGS    ?= ;
391 CC          ?= gcc ;  # k8: was cc
392 CCFLAGS     ?= ;
393 CP          ?= cp -f ;
394 CRELIB      ?= ;
395 DOT         ?= . ;
396 DOTDOT      ?= .. ;
397 EXEMODE     ?= 755 ;
398 FILEMODE    ?= 644 ;
399 HDRS        ?= ;
400 INSTALLGRIST    ?= installed ;
401 JAMFILE     ?= Jamfile ;
402 JAMRULES    ?= Jamrules ;
403 LEX         ?= ;
404 LIBDIR      ?= /usr/local/lib ;
405 LINK        ?= $(CC) ;
406 LINKFLAGS   ?= ;
407 LINKLIBS    ?= ;
408 LN          ?= ln ;
409 MANDIR      ?= /usr/local/man ;
410 MKDIR       ?= mkdir ;
411 MV          ?= mv -f ;
412 OPTIM       ?= ;
413 RCP         ?= rcp ;
414 RM          ?= rm -f ;
415 RMDIR       ?= $(RM) ;
416 RSH         ?= rsh ;
417 SED         ?= sed ;
418 SHELLHEADER ?= "#!/bin/sh" ;
419 SHELLMODE   ?= 755 ;
420 SLASH       ?= / ;
421 SUBDIRRULES ?= ;
422 SUBDIRRESET ?= ASFLAGS HDRS C++FLAGS CCFLAGS ;
423 SUFEXE      ?= "" ;
424 SUFLIB      ?= .a ;
425 SUFOBJ      ?= .o ;
426 UNDEFFLAG   ?= "-u _" ;
427 YACC        ?= ;
428 YACCGEN     ?= ;
429 YACCFILES   ?= ;
430 YACCFLAGS   ?= ;
432 HDRPATTERN = "^[:space:]*#[:space:]*include[:space:]*[<\"]([^\">]*)[\">].*$" ;
434 OSFULL = $(OS)$(OSVER)$(OSPLAT) $(OS)$(OSPLAT) $(OS)$(OSVER) $(OS) ;
436 # k8
437 C++OPTIM     ?= $(OPTIM) ;
438 C++LINK      ?= $(C++) ;
439 C++LINKFLAGS ?= $(LINKFLAGS) ;
440 C++LINKLIBS  ?= $(LINKLIBS) ;
442 OBJCOPTIM     ?= $(OPTIM) ;
443 OBJCLINK      ?= $(CC) ;
444 OBJCLINKFLAGS ?= $(LINKFLAGS) ;
445 OBJCLINKLIBS  ?= $(LINKLIBS) ;
446 OBJCLINKLIBS  += -lobjc ;
448 if $(OS) = "LINUX" {
449   if ( "gcc" in $(CC) ) && ! ( "-pipe" in $(CC) ) { CC += -pipe ; }
450   if ( "g++" in $(C++) ) && ! ( "-pipe" in $(C++) ) { C++ += -pipe ; }
453 #Echo "OS:" $(OS) ;
454 #Echo "OSFULL:" $(OSFULL) ;
455 #Echo "UNIX:" $(UNIX) ;
460 # Base dependencies - first for "bootstrap" kinds of rules
462 Depends all : shell files lib exe obj ;
463 Depends all shell files lib exe obj : first ;
464 NotFile all first shell files lib exe obj dirs clean uninstall ;
465 Always  clean uninstall ;
468 # Rules
471 # /As object : source ;
473 # Assemble the file _source_, called by the @Object rule.
475 # Do not call this rule directly, since _object_ and _source_ may have
476 # have platform-specific file extensions
478 rule As {
479   Depends $(<) : $(>) ;
480   ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ;
481   ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ;
484 # /Bulk  directory : sources ;
486 # Copies _sources_ into _directory_
488 rule Bulk {
489   local i ;
491   for i in $(>) {
492     File $(i:D=$(<)) : $(i) ;
493   }
497 # /Dc object : source ;
499 # Compile the file source into object, usin the D compiler $(DC), its
500 # flags $(DCFLAGS) and $(DOPTIM)
501 # Called by the @Object rule
503 # Do not call this rule directly, since _object_ and _source_ may have
504 # have platform-specific file extensions
506 rule Dc {
507   Depends $(<) : $(>) ;
508   # Just to clarify here: this sets the per-target DCFLAGS to
509   # be the current value of (global) DCFLAGS and SUBDIRDCFLAGS.
510   DCFLAGS on $(<) += $(DCFLAGS) $(SUBDIRDCFLAGS) ;
514 # /Cc object : source ;
516 # Compile the file source into object, using the C compiler $(CC), its
517 # flags $(CCFLAGS) and $(OPTIM), and the header file directories $(HDRS).
518 # Called by the @Object rule
520 # Do not call this rule directly, since _object_ and _source_ may have
521 # have platform-specific file extensions
523 rule Cc {
524   Depends $(<) : $(>) ;
526   # If the compiler's -o flag doesn't work, relocate the .o
527   if $(RELOCATE) { CcMv $(<) : $(>) ; }
529   # Just to clarify here: this sets the per-target CCFLAGS to
530   # be the current value of (global) CCFLAGS and SUBDIRCCFLAGS.
531   # CCHDRS and CCDEFS must be reformatted each time for some
532   # compiles (VMS, NT) that malign multiple -D or -I flags.
533   CCFLAGS on $(<) += $(CCFLAGS) $(SUBDIRCCFLAGS) ;
534   CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
535   CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
539 # /C++ object : source ;
541 # Compile the C++ source file _source_. Similar to @CC, called by @Object
543 # Do not call this rule directly, since _object_ and _source_ may have
544 # have platform-specific file extensions
546 rule C++ {
547   local ktmp ;
549   Depends $(<) : $(>) ;
551   if $(RELOCATE) { CcMv $(<) : $(>) ; }
553   # Just to clarify here: this sets the per-target CCFLAGS to
554   # be the current value of (global) CCFLAGS and SUBDIRCCFLAGS.
555   # CCHDRS and CCDEFS must be reformatted each time for some
556   # compiles (VMS, NT) that malign multiple -D or -I flags.
557   ktmp = $(C++FLAGS) ;
558   if ! $(ktmp) { ktmp = $(CCFLAGS) ; }
559   C++FLAGS on $(<) += $(ktmp) $(SUBDIRC++FLAGS) ;
561   ktmp = $(C++OPTIM) ;
562   if ! $(ktmp) { ktmp = $(OPTIM) ; }
563   C++OPTIM on $(<) += $(ktmp) ;
565   CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
566   CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
570 # /ObjC object : source ;
572 # Compile the ObjC source file _source_. Similar to @CC, called by @Object
574 # Do not call this rule directly, since _object_ and _source_ may have
575 # have platform-specific file extensions
577 rule ObjC {
578   local ktmp ;
580   Depends $(<) : $(>) ;
582   if $(RELOCATE) { CcMv $(<) : $(>) ; }
584   # Just to clarify here: this sets the per-target CCFLAGS to
585   # be the current value of (global) CCFLAGS and SUBDIRCCFLAGS.
586   # CCHDRS and CCDEFS must be reformatted each time for some
587   # compiles (VMS, NT) that malign multiple -D or -I flags.
588   ktmp = $(OBJCFLAGS) ;
589   if ! $(ktmp) { ktmp = $(CCFLAGS) ; }
590   OBJCFLAGS on $(<) += $(ktmp) $(SUBDIROBJCFLAGS) ;
592   ktmp = $(OBJCOPTIM) ;
593   if ! $(ktmp) { ktmp = $(OBJCOPTIM) ; }
594   OBJCOPTIM on $(<) += $(ktmp) ;
596   CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
597   CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
601 # /Chmod target ;
603 # (Unix and VMS only). Change file permissions on _target_ to target-specific
604 # $(MODE) value set by @Link, @File, @Install* and @Shell rules
606 rule Chmod {
607   if $(CHMOD) { Chmod1 $(<) ; }
610 # /Clean  clean : targets ;
612 # Removes existing _targets_ when _clean_ is built. clean is not a dependency
613 # of all, and must be built explicitely for targets to be removed
617 # /File target : source ;
619 # Copies _source_ into _target_
621 rule File {
622   Depends files : $(<) ;
623   Depends $(<) : $(>) ;
624   SEARCH on $(>) = $(SEARCH_SOURCE) ;
625   MODE on $(<) = $(FILEMODE) ;
626   Chmod $(<) ;
630 # /GenFile target : image sources ;
632 # Runs the command "_image_ _target_ _sources_" to create _target_ from
633 # _sources_ and _image_ (where _image_ is an executable built by the
634 # @Main rule)
636 rule GenFile {
637   local _t = [ FGristSourceFiles $(<) ] ;
638   local _s = [ FAppendSuffix $(>[1]) : $(SUFEXE) ] ;
639   Depends $(_t) : $(_s) $(>[2-]) ;
640   GenFile1 $(_t) : $(_s) $(>[2-]) ;
641   Clean clean : $(_t) ;
644 rule GenFile1 {
645   MakeLocate $(<) : $(LOCATE_SOURCE) ;
646   SEARCH on $(>) = $(SEARCH_SOURCE) ;
650 # /HardLink target : source ;
652 # Makes _target_ a hard link to _source_, if it isn't one already
653 # (Unix only)
655 rule HardLink {
656   Depends files : $(<) ;
657   Depends $(<) : $(>) ;
658   SEARCH on $(>) = $(SEARCH_SOURCE) ;
662 # /HdrMacroFile
664 # this rule is specific to FT-Jam. It is used to indicate that a given file
665 # contains definitions for filename macros (e.g. "#define MYFILE_H <myfile>.h")
666 # that can later be used in #include statements in the rest of the source
668 # these files must be parsed before any make is tried.
670 rule HdrMacroFile {
671   HDRMACRO $(<) ;
675 # /HdrRule source : headers ;
677 # Arranges the proper dependencies when the file _source_ includes the files
678 # _headers_ through the #include C preprocessor directive
680 # this rule is not intendend to be called explicitely. It is called
681 # automatically during header scanning on sources handled by the @Object
682 # rule (e.g. sources in @Main or @Library rules)
684 rule HdrRule {
685   # HdrRule source : headers ;
687   # N.B.  This rule is called during binding, potentially after
688   # the fate of many targets has been determined, and must be
689   # used with caution: don't add dependencies to unrelated
690   # targets, and don't set variables on $(<).
692   # Tell Jam that anything depending on $(<) also depends on $(>),
693   # set SEARCH so Jam can find the headers, but then say we don't
694   # care if we can't actually find the headers (they may have been
695   # within ifdefs),
697   local s = $(>:G=$(HDRGRIST:E)) ;
699   Includes $(<) : $(s) ;
700   SEARCH on $(s) = $(HDRSEARCH) ;
701   NoCare $(s) ;
703   # Propagate on $(<) to $(>)
705   HDRSEARCH on $(s) = $(HDRSEARCH) ;
706   HDRSCAN on $(s) = $(HDRSCAN) ;
707   HDRRULE on $(s) = $(HDRRULE) ;
708   HDRGRIST on $(s) = $(HDRGRIST) ;
712 # /Lex source.c : source.l ;
714 # Process the lex source file _source.l_ and rename the lex.yy.c
715 # to _source.c_ . Called by the @Object rule
717 rule Lex {
718   LexMv $(<) : $(>) ;
719   Depends $(<) : $(>) ;
720   MakeLocate $(<) : $(LOCATE_SOURCE) ;
721   Clean clean : $(<) ;
725 # /Library  library : sources ;
727 #  Compiles _sources_ and archives them into _library_. The intermediate
728 #  objects are deleted. Calles @Object and @LibraryFromObjects
730 #  If @Library is invoked with no suffix on _library_, the $(SUFLIB)
731 #  suffix is used
733 rule Library {
734   LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
735   Objects $(>) ;
739 # /SharedLibrary  library : sources : def : import ;
741 # Compiles _sources_ and generates a shared _library_ (i.e. DLL on Windows,
742 # or shared object on Unix). Calls @SharedObjects and @SharedLibraryFromObjects
744 # If @SharedLibrary is invoked with no suffix on _library_, then
745 # $(SUFLIBSHR) suffix is used
747 # _def_ is the name of the corresponding definition file used to generate
748 # the library on Windows and OS/2 (ignored otherwise). If undefined, it
749 # will default to _library_ with the .def suffix
751 # _import_ is the name of the corresponding import library for Windows
752 # and OS/2 platforms (ignored otherwise). If undefined, it will default
753 # to _library_ with the .dll.lib suffix.
755 rule SharedLibrary {
756   #Echo "SharedLibrary: $(<)" ; #dbg
757   #Echo "SharedLibrary: $(>:S=$(SUFOBJSHR))" ; #dbg
758   #Echo "SharedLibrary: $(3)" ; #dbg
759   #Echo "SharedLibrary: $(4)" ; #dbg
760   SharedLibraryFromObjects $(<) : $(>:S=$(SUFOBJSHR)) : $(3) : $(4) ;
761   SharedObjects $(>) ;
764 ######################################################
765 # k8: REWORK!
766 ######################################################
767 #!LIBTOOL!#if $(UNIX) {
768 #!LIBTOOL!#  # this rule is used to find the 'libtool' script in the current
769 #!LIBTOOL!#  # path, this is required when compiling shared objects on Unix
770 #!LIBTOOL!#  rule LibToolFind {
771 #!LIBTOOL!#    if $(LIBTOOL) { return $(LIBTOOL) ; }
772 #!LIBTOOL!#    local matches = [ Glob $(PATH) : libtool ] ;
773 #!LIBTOOL!#    if ! $(matches) { Exit "could not find 'libtool' program in current path. Aborting !" ; }
774 #!LIBTOOL!#    LIBTOOL = $(matches[1]) ;
775 #!LIBTOOL!#    return $(LIBTOOL) ;
776 #!LIBTOOL!#  }
777 #!LIBTOOL!#}
780 # /LibraryFromObjects library : objects ;
782 # Archives _objects_ into _library_. The _objects_ are then deleted
784 # If _library_ has no suffix, the $(SUFLIB) suffix is used
786 # Called by @Library rule. Most people should never call this rule
787 # directly.
789 rule LibraryFromObjects {
790   local _i _l _s ;
792   # Add grist to file names
793   _s = [ FGristFiles $(>) ] ;
794   _l = $(<:S=$(SUFLIB)) ;
796   # library depends on its member objects
797   if $(KEEPOBJS) {
798     Depends obj : $(_s) ;
799   } else {
800     Depends lib : $(_l) ;
801   }
803   # Set LOCATE for the library and its contents.  The bound
804   # value shows up as $(NEEDLIBS) on the Link actions.
805   # For compatibility, we only do this if the library doesn't
806   # already have a path.
807   if ! $(_l:D) {
808     #!!MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ;
809     MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_LIB) ;
810   }
812   if $(NOARSCAN) {
813     # If we can't scan the library to timestamp its contents,
814     # we have to just make the library depend directly on the
815     # on-disk object files.
816     Depends $(_l) : $(_s) ;
817   } else {
818     # If we can scan the library, we make the library depend
819     # on its members and each member depend on the on-disk
820     # object file.
821     Depends $(_l) : $(_l)($(_s:BS)) ;
822     for _i in $(_s) {
823       Depends $(_l)($(_i:BS)) : $(_i) ;
824     }
825   }
827   Clean clean : $(_l) ;
829   if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
831   Archive $(_l) : $(_s) ;
833   if $(RANLIB) { Ranlib $(_l) ; }
835   # If we can't scan the library, we have to leave the .o's around.
836   if ! ( $(NOARSCAN) || $(NOARUPDATE) ) { RmTemps $(_l) : $(_s) ; }
840 # /SharedLibraryFromObjects  library : objects : def : import ;
842 # Equivalent of @LibraryFromObjects for shared libraries.
844 # Called by @SharedLibrary. Most people shouldn't call this rule
845 # directly
847 rule SharedLibraryFromObjects {
848   local _i _l _s ;
850   # Add grist to file names
851   _s = [ FGristFiles $(>) ] ;
852   _l = $(<:S=$(SUFLIBSHR)) ;
854   #Echo "Library is $(_l)"    ;
855   # library depends on its member objects
856   if $(KEEPOBJS) {
857     Depends obj : $(_s) ;
858   } else {
859     Depends lib : $(_l) ;
860   }
862   # Set LOCATE for the library and its contents.  The bound
863   # value shows up as $(NEEDLIBS) on the Link actions.
864   # For compatibility, we only do this if the library doesn't
865   # already have a path.
866   if ! $(_l:D) {
867     #!!MakeLocate $(_l) : $(LOCATE_TARGET) ;
868     MakeLocate $(_l) : $(LOCATE_LIBSO) ;
869   }
871   #Echo "SharedLibraryFromObjects: _s = $(_s)" ; #dbg
872   #Echo "SharedLibraryFromObjects: _l = $(_l)" ; #dbg
874   # we never scan shared libraries for member objects
875   Depends $(_l) : $(_s) ;
877   Clean clean : $(_l) ;
879   # I don't know if VMS supports shared libraries, so I prefer
880   # to disable the following right now
881   #
882   #if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
884   # creating the library is so much fun on Unix :-)
885   if $(UNIX) {
886 #!LIBTOOL!#    if $(K8_USE_LIBTOOL) {
887 #!LIBTOOL!#      local libtool = [ LibToolFind ] ;  # find the right libtool
888 #!LIBTOOL!#      AR on $(_l) = "$(libtool) --mode=link $(AR:J= )" ;
889 #!LIBTOOL!#    } else {
890       LINKFLAGS on $(_l) += "-shared" ;
891       C++LINKFLAGS on $(_l) += "-shared" ;
892       LinkUnixLibrary $(_l) : $(_s) ;
893 #!LIBTOOL!#    }
894   } else if $(NT) {
895     local _implib = $(4) ;
896     local _def    = $(3) ;
898     _implib ?= $(_l:S=$(SUFLIBSHR)$(SUFLIB)) ;
899     _def    ?= $(_l:S=.def) ;
901     Clean    clean : $(_implib) ;
902     Depends  lib   : $(_implib) $(_def) ;
904     Depends $(_implib) : $(_def) $(_l) ;
905     Depends $(_l)      : $(_def) ;
907     DEFFILENAME on $(_l) = $(_def) ;
908     IMPLIBNAME  on $(_l) = $(_implib) ;
910     #!!MakeLocate $(_implib)        : $(LOCATE_TARGET) ;
911     #!!MakeLocate $(_implib:S=.exp) : $(LOCATE_TARGET) ;
912     MakeLocate $(_implib)        : $(LOCATE_LIBSO) ;
913     MakeLocate $(_implib:S=.exp) : $(LOCATE_LIBSO) ;
915     if $(JAM_TOOLSET) in VISUALC BORLANDC LCC WATCOM DIGITALMARS {
916       SharedLink-$(JAM_TOOLSET) $(_l) : $(_s) : $(_implib) : $(_def) ;
917     }
918     DllLink $(_l) : $(_s) ;
919   } else {
920     Echo "Sorry, I don't know how to make a shared library on your system" ;
921     Exit "Please *DON'T* contact the K8Jam maintainer for help" ;
922   }
926 # Since building shared libraries is so different depending on the
927 # compiler being used, I've broken this task into compiler-specific
928 # ones
930 rule SharedLink-LCC {
931   Echo "Sorry, but generating DLLs with LCC is not supported. That's" ;
932   Echo "because the 'lcclnk' tool that comes with this compiler is" ;
933   Echo "unreliable and doesn't work as expected." ;
934   Exit ;
936   # the 'lcclnk' tool is absolutely broken:
937   #   - its -o flag doesn't work when there is a LIBRARY statement
938   #     in the .def file.
939   #
940   #   - it uses the LIBRARY name in the .def file to determine
941   #     the name of the dll and its import library, and always
942   #     places them in the current directory !!
943   #
944   #   - if there is no LIBRARY statement, the -o flag is only
945   #     used to determine where the DLL is placed, the import
946   #     library will always be placed in the current directory !!
947   #
949   # clean the .exp file too, don't know how to get rid of it
950   Clean clean : $(4:S=.exp) ;
954 # /Link  image : objects ;
956 # Links _image_ from _objects_ and sets permissions on _image_ to
957 # $(EXEMODE). _image_ must be an actual filename; suffix is not
958 # supplied.
960 # Called by @Main, shouldn't be called by most people
962 rule Link {
963   MODE on $(<) = $(EXEMODE) ;
964   Chmod $(<) ;
968 # /C++Link  image : objects ;
970 # Links _image_ from _objects_ and sets permissions on _image_ to
971 # $(EXEMODE). _image_ must be an actual filename; suffix is not
972 # supplied.
974 # Called by @Main, shouldn't be called by most people
976 rule C++Link {
977   MODE on $(<) = $(EXEMODE) ;
978   Chmod $(<) ;
981 rule ObjC-Link {
982   MODE on $(<) = $(EXEMODE) ;
983   Chmod $(<) ;
987 # /LinkLibraries image : libraries ;
989 # Makes _image_ depend on _libraries_ and includes them during linking
991 # _image_ may be referenced without a suffix in this rule invocation.
992 # @LinkLibraries supplies the suffix
994 # You should only use this rule with libraries created through the
995 # @Library rule. For external libraries, use something else (XXX)
997 rule LinkLibraries {
998   # make library dependencies of target
999   # set NEEDLIBS variable used by 'actions Main'
1000   local _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1002   Depends $(_t) : $(>:S=$(SUFLIB)) ;
1003   NEEDLIBS on $(_t) += $(>:S=$(SUFLIB)) ;
1007 # /LinkSharedLibraries image : libraries :
1009 # Same as @LinkLibraries, but to link _image_ with shared libraries
1010 # generated through the @SharedLibrary rule
1012 rule LinkSharedLibraries {
1013   # make library dependencies of target
1014   # set NEEDLIBS variable used by 'actions Main'
1015   local _t   = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1016   local _ext = $(SUFLIBSHR) ;
1018   if $(NT) {
1019     # on NT, we need to link agains the import library, not the DLL itself !!
1020     _ext = $(SUFLIBSHR)$(SUFLIB) ;
1021   }
1022   Depends $(_t) : $(>:S=$(_ext))  ;
1023   NEEDLIBS on $(_t) += $(>:S=$(_ext)) ;
1027 # /Main image : sources ;
1029 # Compiles _sources_ and links them into _image_. Calls @Objects and
1030 # @MainFromObjects.
1032 # _image_ may be supplied without suffix.
1034 rule Main {
1035   MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1036   Objects $(>) ;
1040 # /C++Main image : sources ;
1042 # Compiles _sources_ and links them into _image_. Calls @Objects and
1043 # @C++MainFromObjects.
1045 # _image_ may be supplied without suffix.
1047 rule C++Main {
1048   C++MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1049   Objects $(>) ;
1052 rule ObjC-Main {
1053   ObjC-MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1054   Objects $(>) ;
1058 # /MainFromObjects image : objects ;
1060 # Links _objects_ into _image_. Dependency of exe.
1061 # @MainFromObjects provides a default suffix for _image_
1063 rule MainFromObjects {
1064   local _s _t ;
1066   # Add grist to file names
1067   # Add suffix to exe
1068   _s = [ FGristFiles $(>) ] ;
1069   _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1070   # so 'jam foo' works when it's really foo.exe
1072   if $(_t) != $(<) {
1073     Depends $(<) : $(_t) ;
1074     NotFile $(<) ;
1075   }
1077   # make compiled sources a dependency of target
1078   Depends exe : $(_t) ;
1079   Depends $(_t) : $(_s) ;
1080   #k8:MakeLocate $(_t) : $(LOCATE_TARGET) ;
1081   MakeLocate $(_t) : $(LOCATE_BIN) ;
1082   Clean clean : $(_t) ;
1084   # special case for stupid Borland C++, which always generates a
1085   # .tds file for executables, even when no debug information is needed
1086   #
1087   #if $(JAM_TOOLSET) = BORLANDC {
1088   #  MakeLocate $(_t:S=.tds) : $(LOCATE_TARGET) ;
1089   #  Clean  clean : $(_t:S=.tds) ;
1090   #}
1092   Link $(_t) : $(_s) ;
1096 # /C++MainFromObjects image : objects ;
1098 # Links _objects_ into _image_. Dependency of exe.
1099 # @MainFromObjects provides a default suffix for _image_
1101 rule C++MainFromObjects {
1102   local _s _t ;
1104   # Add grist to file names
1105   # Add suffix to exe
1106   _s = [ FGristFiles $(>) ] ;
1107   _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1108   # so 'jam foo' works when it's really foo.exe
1110   if $(_t) != $(<) {
1111     Depends $(<) : $(_t) ;
1112     NotFile $(<) ;
1113   }
1115   # make compiled sources a dependency of target
1116   Depends exe : $(_t) ;
1117   Depends $(_t) : $(_s) ;
1118   #k8:MakeLocate $(_t) : $(LOCATE_TARGET) ;
1119   MakeLocate $(_t) : $(LOCATE_BIN) ;
1120   Clean clean : $(_t) ;
1122   # special case for stupid Borland C++, which always generates a
1123   # .tds file for executables, even when no debug information is needed
1124   #
1125   #if $(JAM_TOOLSET) = BORLANDC {
1126   #  MakeLocate $(_t:S=.tds) : $(LOCATE_TARGET) ;
1127   #  Clean  clean : $(_t:S=.tds) ;
1128   #}
1130   C++Link $(_t) : $(_s) ;  ###k8:FIXME
1134 rule ObjC-MainFromObjects {
1135   local _s _t ;
1137   # Add grist to file names
1138   # Add suffix to exe
1139   _s = [ FGristFiles $(>) ] ;
1140   _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1141   # so 'jam foo' works when it's really foo.exe
1143   if $(_t) != $(<) {
1144     Depends $(<) : $(_t) ;
1145     NotFile $(<) ;
1146   }
1148   # make compiled sources a dependency of target
1149   Depends exe : $(_t) ;
1150   Depends $(_t) : $(_s) ;
1151   #k8:MakeLocate $(_t) : $(LOCATE_TARGET) ;
1152   MakeLocate $(_t) : $(LOCATE_BIN) ;
1153   Clean clean : $(_t) ;
1155   ObjC-Link $(_t) : $(_s) ;  ###k8:FIXME
1159 # /MakeLocate  targets : directory
1161 # Creates _dir_ and causes _target_ to be built into _dir_
1163 # This is done by setting the target-specific variable LOCATE
1164 # on _targets_, and arranges with @MkDir to create the target
1165 # directory
1167 rule MakeLocate {
1168   # Note we grist the directory name with 'dir',
1169   # so that directory path components and other
1170   # targets don't conflict.
1171   local srcname = $(<[1]:G=) ;
1172   local srcdir = $(srcname:D) ;
1173   local outdir = $(>[1]:G=dir) ;
1174   local odir ;
1175   if $(srcdir) {
1176     odir = $(outdir)$(PATH_SEPARATOR)$(srcdir) ;
1177   } else {
1178     odir = $(outdir) ;
1179   }
1180   #Echo "MakeLocate:" "$(<)" "|" "$(>)" ;
1181   #Echo "srcname:" "$(srcname)" ;
1182   #Echo "srcdir :" "$(srcdir)" ;
1183   #Echo "outdir :" "$(outdir)" ;
1184   #Echo "odir   :" "$(odir)" ;
1185   if $(>) {
1186     LOCATE on $(<) = $(>) ;
1187     Depends $(<) : $(odir) ;
1188     MkDir $(odir) ;
1189   }
1193 # /MkDir  dir ;
1195 # Creates _dir_ and its parent directories
1197 rule MkDir {
1198   # Ignore timestamps on directories: we only care if they exist.
1199   NoUpdate $(<) ;
1201   # Don't create . or any directory already created.
1202   if $(<:G=) != $(DOT) && ! $($(<)-mkdir) {
1203     # Cheesy gate to prevent multiple invocations on same dir
1204     # Arrange for jam dirs
1205     # MkDir1 has the actions
1206     $(<)-mkdir = true ;
1207     Depends dirs : $(<) ;
1208     MkDir1 $(<) ;
1210     # Recursively make parent directories.
1211     # $(<:P) = $(<)'s parent, & we recurse until root
1212     local s = $(<:P) ;
1214     # Don't try to create A: or A:\ on windows
1215     if $(NT) {
1216       switch $(s) {
1217         case "*:"   : s = ;
1218         case "*:\\" : s = ;
1219       }
1220     }
1221     # handle "C:", "C:/", "/cygdrive" and "/cygdrive/" in Cygwin
1222     if $(UNIX) && $(OS) = CYGWIN {
1223       switch $(s) {
1224         case "?:"   : s = ;
1225         case "?:/"  : s = ;
1226         case "<dir>/cygdrive"   : s = ;
1227         case "<dir>/cygdrive/"  : s = ;
1228       }
1229     }
1231     if $(s) = $(<) {
1232       # The parent is the same as the dir.
1233       # We're at the root, which some OS's can't stat, so we mark
1234       # it as NotFile.
1235       NotFile $(s) ;
1236     } else if $(s:G=) {
1237       # There's a parent; recurse.
1238       Depends $(<) : $(s) ;
1239       MkDir $(s) ;
1240     }
1241   }
1245 # /Object object : source ;
1247 # Compile s a single _source_ file into _object_. The @Main and @Library
1248 # rules use it to compile sources.
1250 # Causes _source_ to be scanned for #include directives and calls @HdrRule
1251 # to make all included files dependencies of _object_.
1253 # Calls one of the following rules depending on the suffix to do the
1254 # actual compilation:
1256 rule Object {
1257   # locate object and search for source, if wanted
1259   Clean clean : $(<) ;
1260   MakeLocate $(<) : $(LOCATE_TARGET) ;
1261   SEARCH on $(>) = $(SEARCH_SOURCE) ;
1263   # Save HDRS for -I$(HDRS) on compile.
1264   # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers
1265   # in the .c file's directory, but generated .c files (from
1266   # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly
1267   # different from $(SEARCH_SOURCE).
1268   HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ;
1270   # handle #includes for source: Jam scans for headers with
1271   # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
1272   # with the scanned file as the target and the found headers
1273   # as the sources.  HDRSEARCH is the value of SEARCH used for
1274   # the found header files.  Finally, if jam must deal with
1275   # header files of the same name in different directories,
1276   # they can be distinguished with HDRGRIST.
1278   # $(SEARCH_SOURCE:E) is where cc first looks for #include
1279   # "foo.h" files.  If the source file is in a distant directory,
1280   # look there.  Else, look in "" (the current directory).
1282   HDRRULE on $(>) = HdrRule ;
1283   HDRSCAN on $(>) = $(HDRPATTERN) ;
1284   HDRSEARCH on $(>) = $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ;
1285   HDRGRIST on $(>) = $(HDRGRIST) ;
1287   # propagate target specific-defines
1288   DEFINES on $(<) += $(DEFINES) ;
1290   if $(WINDOZE) && $(>:S) = ".rc" {
1291     WindozeResourceCompiler $(<) : $(>) ;
1292   } else if $(WINDOZE) && $(>:S) = ".o" {
1293     # do nothing
1294   } else {
1295     # if source is not .c, generate .c with specific rule
1296     switch $(>:S) {
1297       case .asm : As $(<) : $(>) ;
1298       case .c   : Cc $(<) : $(>) ;
1299       case .C   : C++ $(<) : $(>) ;
1300       case .cc  : C++ $(<) : $(>) ;
1301       case .cpp : C++ $(<) : $(>) ;
1302       case .cxx : C++ $(<) : $(>) ;
1303       case .c++ : C++ $(<) : $(>) ;
1304       case .C++ : C++ $(<) : $(>) ;
1305       case .m   : ObjC $(<) : $(>) ;
1306       case .d   : Dc $(<) : $(>) ;
1307       case .l   : Cc $(<) : $(<:S=.c) ;
1308                   Lex $(<:S=.c) : $(>) ;
1309       case .s   : As $(<) : $(>) ;
1310       case .y   : Cc $(<) : $(<:S=$(YACCGEN)) ;
1311                   Yacc $(<:S=$(YACCGEN)) : $(>) ;
1312       case *    : UserObject $(<) : $(>) ;
1313     }
1314   }
1318 # /ObjectCcFlags  sources : flags ;
1320 # this rule is used to add compiler flags to the compilation of
1321 # specific C sources files.
1323 rule ObjectCcFlags {
1324   CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1328 # /ObjectC++Flags  sources : flags ;
1330 # this rule is used to add compiler flags to the compilation of
1331 # specific C++ source files
1333 rule ObjectC++Flags {
1334   C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1338 rule ObjectObjCFlags {
1339   OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1343 # /LinkFlagsOn  mains : flags ;
1345 # this rule is used to add compiler flags to the compilation of
1346 # specific C sources files.
1348 rule LinkFlagsOn {
1349   LINKFLAGS on [ FGristFiles $(<) ] += $(>) ;
1353 # /C++LinkFlagsOn  mains : flags ;
1355 # this rule is used to add compiler flags to the compilation of
1356 # specific C++ source files
1358 rule C++LinkFlagsOn {
1359   C++LINKFLAGS on [ FGristFiles $(<) ] += $(>) ;
1363 rule ObjCLinkFlagsOn {
1364   OBJCLINKFLAGS on [ FGristFiles $(<) ] += $(>) ;
1368 # /ObjectDefines  objects : macros ;
1370 # this rule is used to add macro defines to the compilation of
1371 # specific C and C++ source files
1373 rule ObjectDefines {
1374   # must reformat CCDEFS according to current defines
1375   local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
1377   DEFINES on $(s) += $(>) ;
1378   CCDEFS on $(s) = [ on $(s) FDefines $(DEFINES) ] ;
1382 # /ObjectHdrs  sources : paths ;
1384 # this rule is used to add include paths to the compilation of
1385 # specific C and C++ source files
1387 rule ObjectHdrs {
1388   # Add to HDRS for HdrScan's benefit.
1389   # must reformat CCHDRS according to headers
1390   local s = [ FGristFiles $(<:S=$(SUFOBJ)) ] ;
1392   HDRS on $(s) += $(>) ;
1393   CCHDRS on $(s) = [ on $(s) FIncludes $(HDRS) ] ;
1397 # /Objects sources ;
1399 # this rule is used to compile one or more sources into object files.
1400 # do not call it directly, it is used by the Main and Library rules
1401 # automatically
1403 rule Objects {
1404   local _i ;
1406   for _i in [ FGristFiles $(<) ] {
1407     Object $(_i:S=$(SUFOBJ)) : $(_i) ;
1408     Depends obj : $(_i:S=$(SUFOBJ)) ;
1409   }
1413 # /SharedObjects
1415 # this rule is used to compile one or more sources into 'shared object
1416 # files'. This means object files used to build either DLLs or Unix shared
1417 # libraries.
1419 # do not call this rule directly, it is called by SharedLibrary automatically
1421 rule SharedObjects {
1422   # temporarily override SUFOBJ with $(SUFOBJSHR) to
1423   local SUFOBJ = $(SUFOBJSHR) ;
1425   # call the normal Objects rule
1426   Objects $(<) ;
1428   # add the compiler-specific position-independent-code flag  where needed
1429   ObjectCcFlags $(<) : $(PICFLAGS) ;
1431   # change the compiler invokation for all these objects
1432   # to use Libtool on Unix systems. We explicitely disable the
1433   # generation of static objects here
1434 #!LIBTOOL!#  if $(UNIX) {
1435 #!LIBTOOL!#    #libtool on $(<:S=$(SUFOBJ)) = [ LibToolFind ] ;
1436 #!LIBTOOL!#    if $(K8_USE_LIBTOOL) {
1437 #!LIBTOOL!#      local libtool = [ LibToolFind ] ;
1438 #!LIBTOOL!#      CC on $(<:S=$(SUFOBJ)) = "$(libtool) --mode=compile $(CC:J= ) -dynamic" ;
1439 #!LIBTOOL!#      C++ on $(<:S=$(SUFOBJ)) = "$(libtool) --mode=compile $(C++:J= ) -dynamic" ; #k8:?
1440 #!LIBTOOL!#    }
1441 #!LIBTOOL!#  }
1445 rule RmTemps {
1446   Temporary $(>) ;
1450 rule Setuid {
1451   MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;
1455 rule Shell {
1456   Depends shell : $(<) ;
1457   Depends $(<) : $(>) ;
1458   SEARCH on $(>) = $(SEARCH_SOURCE) ;
1459   MODE on $(<) = $(SHELLMODE) ;
1460   Clean clean : $(<) ;
1461   Chmod $(<) ;
1465 rule SoftLink {
1466   Depends files : $(<) ;
1467   Depends $(<) : $(>) ;
1468   SEARCH on $(>) = $(SEARCH_SOURCE) ;
1469   Clean clean : $(<) ;
1473 rule SubDir {
1474   #
1475   # SubDir TOP d1 d2 ... ;
1476   #
1477   # Support for a project tree spanning multiple directories.
1478   #
1479   # SubDir declares a Jamfile's location in a project tree, setting
1480   # Jambase variables (SEARCH_SOURCE, LOCATE_TARGET) so that source
1481   # files can be found.
1482   #
1483   # TOP is a user-select variable name for root of the tree, and
1484   # d1 d2 ...  are the directory elements that lead from the root
1485   # of the tree to the directory of the Jamfile.
1486   #
1487   # TOP can be set externally, but normally the first SubDir call
1488   # computes TOP as the path up from the current directory; the
1489   # path contains one ../ for each of d1 d2 ...
1490   #
1491   # SubDir reads once the project-specific rules file Jamrules
1492   # in the TOP directory, if present.  This can be overridden
1493   # with the variable TOPRULES.
1494   #
1495   # SubDir supports multiple, overlaid project trees:  SubDir
1496   # invocations with different TOPs can appear in the same Jamfile.
1497   # The location established by the first SubDir call is used set
1498   # the TOPs for the subsequent SubDir calls.
1499   #
1500   # SubDir's public variables:
1501   #
1502   #   $(TOP) = path from CWD to root.
1503   #   $(SUBDIR) = path from CWD to the directory SubDir names.
1504   #   $(SUBDIR_TOKENS) = path from $(TOP) to $(SUBDIR) as dir names
1505   #   $(SEARCH_SOURCE) = $(SUBDIR)
1506   #   $(LOCATE_SOURCE) = $(ALL_LOCATE_TARGET) $(SUBDIR)
1507   #   $(LOCATE_TARGET) = $(ALL_LOCATE_TARGET) $(SUBDIR)
1508   #   $(LOCATE_BIN) = $(ALL_LOCATE_BIN) $(ALL_LOCATE_TARGET) $(SUBDIR)
1509   #   $(LOCATE_LIB) = $(ALL_LOCATE_LIB) $(ALL_LOCATE_TARGET) $(SUBDIR)
1510   #   $(LOCATE_LIBSO) = $(ALL_LOCATE_LIBSO) $(ALL_LOCATE_LIB) $(ALL_LOCATE_TARGET) $(SUBDIR)
1511   #   $(SOURCE_GRIST) = $(SUBDIR_TOKENS) with !'s
1512   #
1513   local _top = $(<[1]) ;
1514   local _tokens = $(<[2-]) ;
1516   local ktmp ;
1518   # First time through sets up relative root and includes Jamrules.
1519   if ! $(_top) { Exit "SubDir syntax error" ; }
1521   if ! $($(_top)-SET) {
1522     $(_top)-SET = true ;
1523     # First time we've seen this TOP.
1524     # We'll initialize a number of internal variables:
1525     #
1526     #   $(TOP-UP) = directories from ROOT to a common point
1527     #   $(TOP-DOWN) = directories from common point to TOP
1528     #   $(TOP-ROOT) = root directory for UP/DOWN -- normally CWD
1529     #   $(SUBDIR_UP) = current value of $(TOP-UP)
1530     #   $(SUBDIR_DOWN) = current value of $(TOP-DOWN)
1531     #   $(SUBDIR_ROOT) = current value of $(TOP-ROOT)
1532     #
1533     if $($(_top)) {
1534       # TOP externally set.
1535       # We'll ignore the relative (UP/DOWN) path that
1536       # got us here, and instead remember the hard ROOT.
1537       $(_top)-UP = ;
1538       $(_top)-DOWN = ;
1539       $(_top)-ROOT = $($(_top)) ;
1540     } else {
1541       # TOP not preset.
1543       # Establishing a new TOP.  In the simplest case,
1544       # (SUBDIR_UP/SUBDIR_DOWN/SUBDIR_ROOT unset), it's
1545       # merely a certain number of directories down from
1546       # the current directory, and FSubDirPath will set
1547       # TOP to a path consisting of ../ for each of the
1548       # elements of _tokens, because that represents how
1549       # far below TOP the current directory sits.
1550       #
1551       # In the more complicated case, the starting directory
1552       # isn't the directory of jam's invocation but an
1553       # location established by previous SubDir call.  The
1554       # starting directory is SUBDIR_UP directories up from
1555       # SUBDIR_ROOT, and then SUBDIR_DOWN directories down
1556       # from that.   If SUBDIR_ROOT is not set, that means
1557       # SUBDIR_DOWN and SUBDIR_UP represent the path from
1558       # the directory of jam's invocation.
1559       #
1560       # In the most complicated case, the _tokens also
1561       # represents directories down, because TOP is being
1562       # estalished in a directory other than TOP's root.
1563       # Hopefully, _tokens and SUBDIR_DOWN represent the
1564       # same final directory, relative to the new TOP and
1565       # the previous SubDIr's TOP.  To find the new TOP,
1566       # we have to chop off any common directories from
1567       # then ends of _tokens and SUBDIR_DOWN.  To do so,
1568       # we reverse each of them, call FStripCommon to
1569       # remove the initial common elements, and then
1570       # reverse them again.  After this process, if
1571       # both _tokens and SUBDIR_DOWN have elements, it
1572       # means the directory names estalished by the two
1573       # SubDir calls don't match, and a warning is issued.
1574       # All hell will likely break loose at this point,
1575       # since the whole SubDir scheme relies on the SubDir
1576       # calls accurately naming the current directory.
1578       # Strip common trailing elements of _tokens and SUBDIR_DOWN.
1579       _tokens = [ FReverse $(_tokens) ] ;
1580       SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
1581       FStripCommon _tokens : SUBDIR_DOWN ;
1582       SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
1583       _tokens = [ FReverse $(_tokens) ] ;
1585       if $(SUBDIR_DOWN) && $(_tokens) { Echo "Warning:" SubDir $(<) "misplaced!" ; }
1587       # We'll remember the relative (UP/DOWN) path that
1588       # got us here, plus any hard ROOT starting point
1589       # for the UP/DOWN.  If TOP is never set externally,
1590       # ROOT will always be "" (directory of jam's invocation).
1591       $(_top)-UP = $(SUBDIR_UP) $(_tokens) ;
1592       $(_top)-DOWN = $(SUBDIR_DOWN) ;
1593       $(_top)-ROOT = $(SUBDIR_ROOT:E="") ;
1594       $(_top) = [ FSubDirPath $(_top) ] ;
1595     }
1597     # Set subdir vars for the inclusion of the Jamrules,
1598     # just in case they have SubDir rules of their own.
1599     # Note that SUBDIR_DOWN is empty: it's all the way
1600     # up where the Jamrules live.  These gets overrided
1601     # just after the inclusion.
1602     SUBDIR_UP = $($(_top)-UP) ;
1603     SUBDIR_DOWN = ;
1604     SUBDIR_ROOT = $($(_top)-ROOT) ;
1606     # Include $(TOPRULES) or $(TOP)/Jamrules.
1607     # Include $(TOPRULES) if set.
1608     # Otherwise include $(TOP)/Jamrules if present.
1609     if $($(_top)RULES) {
1610       include $($(_top)RULES) ;
1611     } else {
1612       NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1613       include $(JAMRULES:R=$($(_top)):G=$(_top)) ;
1614     }
1615   }
1617   # Get path from $(TOP) to named directory.
1618   # Save dir tokens for other potential uses.
1619   SUBDIR_UP = $($(_top)-UP) ;
1620   SUBDIR_DOWN = $($(_top)-DOWN) $(_tokens) ;
1621   SUBDIR_ROOT = $($(_top)-ROOT) ;
1622   SUBDIR_TOKENS = $(SUBDIR_DOWN) ;
1624   SUBDIR = [ FSubDirPath $(<) ] ;
1626   # Now set up SEARCH_SOURCE, LOCATE_TARGET, LOCATE_BIN, SOURCE_GRIST
1627   # These can be reset if needed.  For example, if the source
1628   # directory should not hold object files, LOCATE_TARGET can
1629   # subsequently be redefined.
1630   SEARCH_SOURCE = $(SUBDIR) ;
1631   LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ;
1632   LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ;
1634   ktmp = $(ALL_LOCATE_BIN) ;
1635   if ! $(ktmp) { ktmp = $(ALL_LOCATE_TARGET) ; }
1636   LOCATE_BIN = $(ktmp) $(SUBDIR) ;
1638   ktmp = $(ALL_LOCATE_LIB) ;
1639   if ! $(ktmp) { ktmp = $(ALL_LOCATE_TARGET) ; }
1640   LOCATE_LIB = $(ktmp) $(SUBDIR) ;
1642   ktmp = $(ALL_LOCATE_LIBSO) ;
1643   if ! $(ktmp) { ktmp = $(ALL_LOCATE_LIB) ; }
1644   if ! $(ktmp) { ktmp = $(ALL_LOCATE_TARGET) ; }
1645   LOCATE_LIBSO = $(ktmp) $(SUBDIR) ;
1647   SOURCE_GRIST = [ FGrist $(SUBDIR_TOKENS) ] ;
1648   #if ! $(LOCATE_BIN) { LOCATE_BIN = $(LOCATE_TARGET) ; }
1650   ## OPT_HEADER_CACHE_EXT
1651   # With the header cache, we can grist all files found
1652   # during a header scan without incurring a performance
1653   # penalty.
1654   #
1655   HDRGRIST = $(SOURCE_GRIST) ;
1657   # Reset per-directory ccflags, hdrs, etc,
1658   # listed in SUBDIRRESET.
1659   # Note use of variable expanded assignment var
1660   SUBDIR$(SUBDIRRESET) = ;
1662   # Invoke user-specific SubDir extensions,
1663   # rule names listed in SUBDIRRULES.
1664   # Note use of variable expanded rule invocation
1665   $(SUBDIRRULES) $(<) ;
1669 rule FSubDirPath {
1670   # FSubDirPath TOP d1 ... ;
1672   # Returns path to named directory.
1674   # If jam is invoked in a subdirectory of the TOP, then we
1675   # need to prepend a ../ for every level we must climb up
1676   # (TOP-UP), and then append the directory names we must
1677   # climb down (TOP-DOWN), plus the named directories d1 ...
1678   # If TOP was set externally, or computed from another TOP
1679   # that was, we'll have to reroot the whole thing at TOP-ROOT.
1680   local _r = [ FRelPath $($(<[1])-UP) : $($(<[1])-DOWN) $(<[2-]) ] ;
1682   return $(_r:R=$($(<[1])-ROOT)) ;
1686 rule SubDirDcFlags {
1687   SUBDIRDCFLAGS += $(<) ;
1691 rule SubDirCcFlags {
1692   SUBDIRCCFLAGS += $(<) ;
1696 rule SubDirC++Flags {
1697   SUBDIRC++FLAGS += $(<) ;
1701 rule SubDirObjCFlags {
1702   SUBDIROBJCFLAGS += $(<) ;
1706 rule SubDirHdrs {
1707   SUBDIRHDRS += [ FDirName $(<) ] ;
1711 rule SubIncludeMany {
1712   # SubIncludeMany TOP d1 ... ;
1713   #
1714   # Include a subdirectory's Jamfile.
1716   # We use SubDir to get there, in case the included Jamfile
1717   # either doesn't have its own SubDir (naughty) or is a subtree
1718   # with its own TOP.
1719   #Echo "including " $(<) " : " $(>) ;
1721   if ! $($(<[1])) { Exit "SubIncludeMany" $(<[1]) "without prior SubDir" $(<[1]) ; }
1722   SubDir $(<) ;
1723   include $(JAMFILE:D=$(SUBDIR)) ;
1727 rule SubIncludeOnce {
1728   # SubIncludeOnce varname : TOP d1 ... ;
1729   #
1730   # Include a subdirectory's Jamfile.
1732   local _vn = $(<[1]) ;
1733   if ! $($(_vn)) {
1734     #Echo "processing $(_vn)" ;
1735     #Echo "$(>)" ;
1736     $(_vn) = tan ;
1737     SubIncludeMany $(>) ;
1738   #} else {
1739   #  Echo "skiped $(_vn) -- $($(_vn))" ;
1740   #  Echo "$(>)" ;
1741   }
1745 rule SubInclude {
1746   # SubInclude TOP d1 ... ;
1747   #
1748   # Include a subdirectory's Jamfile.
1749   if ! $($(<[1])) { Exit "SubInclude" $(<[1]) "without prior SubDir" $(<[1]) ; }
1750   local _sbiguard = _K8JAM_SUB_GUARD_$(<:J=_) ;
1751   SubIncludeOnce $(_sbiguard) : $(<) ;
1755 rule SubRules {
1756   # SubRules TOP d1 ... : Other-TOP ;
1757   #
1758   # Read another tree's Jamrules, by giving it's path according
1759   # to this tree and it's own name.
1760   if ! $($(<[1])) { Exit "SubRules" $(<[1]) "without prior SubDir" $(<[1]) ; }
1761   SubDir $(<) ;
1762   SubDir $(>) ;
1766 rule Undefines {
1767   UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;
1771 rule UserObject {
1772   Exit "Unknown suffix on" $(>) "- see UserObject rule in Jamfile(5)." ;
1776 rule Yacc {
1777   local _h ;
1779   _h = $(<:BS=.h) ;
1781   # Some places don't have a yacc.
1782   MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ;
1783   #MakeLocate $(>) $(_h) : $(LOCATE_SOURCE) ;
1785   if $(YACC) {
1786     #local tmp ;
1787     #tmp = $(<:G=:D) ;
1788     #if $(tmp) { tmp = $(PATH_SEPARATOR)$(tmp) ; }
1789     #tmp = $(LOCATE_SOURCE[1])$(tmp) ;
1790     #CCFLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1791     #C++FLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1792     #OBJCFLAGS on $(<:S=$(SUFOBJ)) += -I$(tmp) ;
1793     #Echo "-------------------------" ;
1794     #Echo "LS:" "$(LOCATE_SOURCE)" ;
1795     #Echo "tmp:" "$(tmp)" ;
1796     #Echo "out:" "$(<)" ;
1797     #Echo "in :" "$(>)" ;
1798     #Echo "_h :" "$(_h)" ;
1799     #Echo "=========================" ;
1800     #
1801     Depends $(<) $(_h) : $(>) ;
1802     Yacc1 $(<) : $(>) ;
1803     #Yacc1 $(<) $(_h) : $(>) ;
1804     #YaccMv $(<) $(_h) : $(>) ;
1805     Clean clean : $(<) $(_h) ;
1806   }
1808   # make sure someone includes $(_h) else it will be
1809   # a deadly independent target
1810   Includes $(<) : $(_h) ;
1815 # Utility rules; no side effects on these
1819 # /FGrist path to file ;
1821 # Returns a single string that is used as grist
1823 rule FGrist {
1824   return $(<:J=!) ;
1828 rule FGristFiles {
1829   return $(<:G=$(SOURCE_GRIST:E)) ;
1833 rule FGristSourceFiles {
1834   ## LOCAL CHANGE: OPT_HEADER_CACHE_EXT
1835   # With header caching, there is no performance penalty to gristing
1836   # header files. It is also not correct to assume that header
1837   # files have global visibility.
1838   #
1839   # Here we comment out the old version and replace it with the new.
1840 #  # Produce source file name name with grist in it,
1841 #  # if SOURCE_GRIST is set.
1843 #  # Leave header files alone, because they have a global
1844 #  # visibility.
1845 #  if ! $(SOURCE_GRIST) {
1846 #    return $(<) ;
1847 #  } else {
1848 #    local _i _o ;
1850 #    for _i in $(<) {
1851 #      switch $(_i) {
1852 #        case *.h : _o += $(_i) ;
1853 #        case *   : _o += $(_i:G=$(SOURCE_GRIST)) ;
1854 #      }
1855 #    }
1856 #    return $(_o) ;
1857 #  }
1858   return [ FGristFiles $(<) ] ;
1862 rule FReverse {
1863   if $(1) { return [ FReverse $(1[2-]) ] $(1[1]) ; }
1867 rule FSubDir {
1868   # If $(>) is the path to the current directory, compute the
1869   # path (using ../../ etc) back to that root directory.
1870   # Sets result in $(<)
1871   if ! $(<[1]) {
1872     return $(DOT) ;
1873   } else {
1874     local _i _d ;
1876     _d = $(DOTDOT) ;
1877     for _i in $(<[2-]) { _d = $(_d:R=$(DOTDOT)) ; }
1878     return $(_d) ;
1879   }
1883 rule FStripCommon {
1884   # FStripCommon v1 : v2 ;
1886   # Strip common initial elements of variables v1 and v2.
1887   # Modifies the variable values themselves.
1888   if $($(<)[1]) && $($(<)[1]) = $($(>)[1]) {
1889     $(<) = $($(<)[2-]) ;
1890     $(>) = $($(>)[2-]) ;
1891     FStripCommon $(<) : $(>) ;
1892   }
1896 rule FRelPath {
1897   local _l _r ;
1899   # first strip off common parts
1900   _l = $(<) ;
1901   _r = $(>) ;
1902   FStripCommon _l : _r ;
1904   # now make path to root and path down
1905   _l = [ FSubDir $(_l) ] ;
1906   _r = [ FDirName $(_r) ] ;
1908   # Concatenate and save
1909   # XXX This should be better
1910   if $(_r) = $(DOT) { return $(_l) ; } else { return $(_r:R=$(_l)) ; }
1914 rule FAppendSuffix {
1915   # E.g., "FAppendSuffix yacc lex foo.bat : $(SUFEXE) ;"
1916   # returns (yacc,lex,foo.bat) on Unix and
1917   # (yacc.exe,lex.exe,foo.bat) on NT.
1918   if $(>) {
1919     local _i _o ;
1921     for _i in $(<) {
1922       if $(_i:S) { _o += $(_i) ; } else { _o += $(_i:S=$(>)) ; }
1923     }
1924     return $(_o) ;
1925   } else {
1926     return $(<) ;
1927   }
1932 # Operating system specific utility rules
1933 # First, the (generic) UNIX versions
1936 rule FQuote { return "\\\"$(<)\\\"" ; }
1937 rule FDefines { return -D$(<) ; }
1938 rule FIncludes { return -I$(<) ; }
1940 rule FDirName {
1941   # Turn individual elements in $(<) into a usable path.
1942   local _i ;
1943   local _s = $(DOT) ;
1945   for _i in $(<) { _s = $(_i:R=$(_s)) ; }
1946   return $(_s) ;
1950 if $(NT) && $(JAM_TOOLSET) != MINGW && $(JAM_TOOLSET) != LCC {
1951   rule FDefines { return /D$(<) ; }
1952   rule FIncludes { return /I$(<) ; }
1957 # various install rules
1960 rule InstallInto {
1961   # InstallInto dir : sources ;
1963   local i t ;
1965   t = $(>:G=$(INSTALLGRIST)) ;
1967   # Arrange for jam install
1968   # Arrange for jam uninstall
1969   # sources are in SEARCH_SOURCE
1970   # targets are in dir
1972   Depends install : $(t) ;
1973   Clean uninstall : $(t) ;
1974   SEARCH on $(>) = $(SEARCH_SOURCE) ;
1975   MakeLocate $(t) : $(<) ;
1977   # For each source, make gristed target name
1978   # and Install, Chmod, Chown, and Chgrp
1979   for i in $(>) {
1980     local tt = $(i:G=$(INSTALLGRIST)) ;
1982     Depends $(tt) : $(i) ;
1983     Install $(tt) : $(i) ;
1984     Chmod $(tt) ;
1986     if $(OWNER) && $(CHOWN) {
1987       Chown $(tt) ;
1988       OWNER on $(tt) = $(OWNER) ;
1989     }
1990     if $(GROUP) && $(CHGRP) {
1991       Chgrp $(tt) ;
1992       GROUP on $(tt) = $(GROUP) ;
1993     }
1994   }
1998 # /InstallBin dir : sources ;
2000 # Copy _sources_ into _dir_ with mode $(EXEMODE)
2002 rule InstallBin {
2003   local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;
2005   InstallInto $(<) : $(_t) ;
2006   MODE on $(_t:G=$(INSTALLGRIST)) = $(EXEMODE) ;
2010 # /InstallFile dir : sources ;
2012 # Copy _sources_ into _dir_ with mode $(FILEMODE)
2014 rule InstallFile {
2015   InstallInto $(<) : $(>) ;
2016   MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2020 # /InstallLib dir : sources ;
2022 # Copy _sources_ into _dir_ with mode $(FILEMODE)
2024 rule InstallLib {
2025   InstallInto $(<) : $(>) ;
2026   MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2030 # /InstallMan dir : sources ;
2032 #  Copy _sources_ into the appropriate subdirectory of _dir_ with mode
2033 #  $(FILEMODE). The subdirectory is manS, where S is the suffix of each of
2034 #  sources.
2036 rule InstallMan {
2037   # Really this just strips the . from the suffix
2038   local i s d ;
2040   for i in $(>) {
2041     switch $(i:S) {
2042       case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;
2043       case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;
2044       case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;
2045       case .n : s = n ; case .man : s = 1 ;
2046     }
2047     d = man$(s) ;
2048     InstallInto $(d:R=$(<)) : $(i) ;
2049   }
2050   MODE on $(>:G=$(INSTALLGRIST)) = $(FILEMODE) ;
2054 # /InstallShell dir : sources ;
2056 # Copy _sources_ into _dir_ with mode $(SHELLMODE)
2058 rule InstallShell {
2059   InstallInto $(<) : $(>) ;
2060   MODE on $(>:G=$(INSTALLGRIST)) = $(SHELLMODE) ;
2064 rule WindozeResourceCompiler {
2065   DEPENDS $(<) : $(>) ;
2066   Clean clean : $(<) ;
2069 rule windoze-fix {
2070   if $(WINDOZE) {
2071     if $(WINDOZE_THREADS) {
2072       CC += -mthreads ;
2073       CC++ += -mthreads ;
2074     }
2075     local ss = $(WINSUBSYS) ;
2076     if ! $(ss) { ss = "console" ; }
2077     LINK += "-Wl,-subsystem,$(ss)" ;
2078     C++LINK += "-Wl,-subsystem,$(ss)" ;
2079     if $(WINLIBS) { LINKLIBS += $(WINLIBS) ; } else { LINKLIBS += -lkernel32 ; }
2080   }
2085 # Actions
2087 actions WindozeResourceCompiler {
2088   "$(WINE)" $(MGPATH)windres.exe -i $(>) -o $(<)
2092 # First the defaults
2094 actions updated together piecemeal Archive {
2095   $(AR) $(<) $(>)
2099 actions As {
2100   $(AS) $(ASFLAGS) $(ASHDRS) -o $(<) $(>)
2104 actions Cc {
2105   $(CC) -c -o $(<) $(CFLAGS.all) $(CCFLAGS) $(OPTIM.all) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2109 actions C++ {
2110   $(C++) -c -o $(<) $(CFLAGS.all) $(C++FLAGS) $(OPTIM.all) $(C++OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2114 actions ObjC {
2115   $(OBJCC) -c -o $(<) $(CFLAGS.all) $(OBJCFLAGS) $(OPTIM.all) $(OBJCOPTIM) $(CCDEFS) $(CCHDRS) $(>)
2119 actions Dc {
2120   $(DC) -c -of$(<) $(DCFLAGS) $(DOPTIM) $(>)
2124 actions Chgrp {
2125   $(CHGRP) $(GROUP) $(<)
2129 actions Chmod1 {
2130   $(CHMOD) $(MODE) $(<)
2134 actions Chown {
2135   $(CHOWN) $(OWNER) $(<)
2139 actions piecemeal together existing Clean {
2140   $(RM) $(>)
2144 actions File {
2145   $(CP) $(>) $(<)
2149 actions GenFile1 {
2150   $(>[1]) $(<) $(>[2-])
2154 actions HardLink {
2155   $(RM) $(<) && $(LN) $(>) $(<)
2159 actions Install {
2160   $(CP) $(>) $(<)
2164 actions Lex {
2165   $(LEX) $(>)
2169 actions LexMv {
2170   $(MV) lex.yy.c $(<)
2174 actions Link bind NEEDLIBS {
2175   $(LINK) $(LINKFLAGS.all) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(LINKLIBS)
2178 actions C++Link bind NEEDLIBS {
2179   $(C++LINK) $(LINKFLAGS.all) $(C++LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(C++LINKLIBS)
2182 actions ObjC-Link bind NEEDLIBS {
2183   $(OBJCLINK) $(LINKFLAGS.all) $(OBJCLINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS.all) $(OBJCLINKLIBS)
2187 actions updated together piecemeal LinkUnixLibrary bind NEEDLIBS {
2188   $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2191 actions updated together piecemeal C++LinkUnixLibrary bind NEEDLIBS {
2192   $(C++LINK) $(C++LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(C++LINKLIBS)
2196 actions MkDir1 {
2197   $(MKDIR) $(<)
2201 actions together Ranlib {
2202   $(RANLIB) $(<)
2206 actions quietly updated piecemeal together RmTemps {
2207   $(RM) $(>)
2211 actions Shell {
2212 #DONT_TOUCH
2213   $(AWK) '
2214     NR == 1 { print "$(SHELLHEADER)" }
2215     NR == 1 && /^[#:]/ { next }
2216     /^##/ { next }
2217     { print }
2218   ' < $(>) > $(<)
2219 #DONT_TOUCH
2223 actions SoftLink {
2224   $(RM) $(<) && $(LN) -s $(>) $(<)
2228 actions Yacc1 {
2229   $(YACC) $(YACCFLAGS) $(>) -o $(<)
2233 actions YaccMv {
2234   #$(MV) $(YACCFILES).c $(<[1])
2235   #$(MV) $(YACCFILES).h $(<[2])
2240 # RELOCATE - for compilers with broken -o flags
2242 if $(RELOCATE) {
2243   actions C++ {
2244     $(C++) -c $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2245   }
2246   actions Cc {
2247     $(CC) -c $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) $(>)
2248   }
2249   actions ignore CcMv {
2250     [ $(<) != $(>:BS=$(SUFOBJ)) ] && $(MV) $(>:BS=$(SUFOBJ)) $(<)
2251   }
2256 # NOARUPDATE - can't update an archive
2258 if $(NOARUPDATE) {
2259   actions Archive {
2260     $(AR) $(<) $(>)
2261   }
2266 # UNIX specific actions
2268 if $(UNIX) {
2269   actions GenFile1 {
2270     PATH="$PATH:."
2271     $(>[1]) $(<) $(>[2-])
2272   }
2277 # NT specific actions
2279 if $(NT) {
2280   if $(JAM_TOOLSET) = MINGW {
2281     actions together piecemeal Archive {
2282       $(AR) $(<) $(>:T)
2283     }
2284     actions Cc {
2285       $(CC) -c -o $(<) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2286     }
2287     actions C++ {
2288       $(C++) -c -o $(<) $(C++FLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -I$(STDHDRS) $(>)
2289     }
2290     actions DllLink bind DEFFILENAME IMPLIBNAME {
2291       $(LINK) $(LINKFLAGS) -shared -o $(<) $(>) $(DEFFILENAME) -Wl,--out-implib,$(IMPLIBNAME)
2292     }
2293   } else if $(JAM_TOOLSET) = LCC {
2294     actions together piecemeal Archive {
2295       $(AR) /out:$(<) $(>)
2296     }
2297     actions Cc {
2298       $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS) -Fo$(<) -I$(STDHDRS) $(>)
2299     }
2300     actions Link bind NEEDLIBS {
2301       $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2302     }
2303     actions DllLink bind NEEDLIBS DEFFILENAME {
2304       $(LINK) $(LINKFLAGS) -DLL -o $(<) $(UNDEFS) $(>) $(DEFFILENAME) $(NEEDLIBS) $(LINKLIBS)
2305     }
2306     actions ignore DllLinkMv {
2307       $(MV) $(2) $(1)
2308     }
2309     actions Shell {
2310       $(CP) $(>) $(<)
2311     }
2312   } else if $(JAM_TOOLSET) = PELLESC {
2313     actions together piecemeal Archive {
2314       $(AR) /OUT:$(<) $(>)
2315     }
2316     actions Cc {
2317       $(CC) $(CCFLAGS) $(OPTIM) $(CCDEFS) $(CCHDRS)   /Fo $(<) -I$(STDHDRS)  $(>)
2318     }
2319     actions Link bind NEEDLIBS {
2320       $(LINK) $(LINKFLAGS) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2321     }
2322     actions DllLink bind NEEDLIBS DEFFILENAME IMPLIBNAME {
2323       $(LINK) $(LINKFLAGS) /DLL /DEF:$(DEFFILENAME) /IMPLIB:$(IMPLIBNAME) /OUT:$(<) $(>) $(NEEDLIBS) $(LINKLIBS)
2324     }
2325     actions Shell {
2326       $(CP) $(>) $(<)
2327     }
2328   }
2333 # Ketmar's additions
2335 rule SetCPUFlags {
2336   if $(OS) != "LINUX" {
2337     DETECTED_CPU = "i486" ;
2338     OPTIM_SPEED = -O3 -march=i486 -mtune=i486 ;
2339   } else {
2340     DETECTED_CPU = native ;
2341     OPTIM_SPEED = -O3 -march=native -mtune=native ;
2342   }
2346 # VAR = [ RemoveOptWild regexp-options-to-remove : options-list ] ;
2347 # remove options from list with egrep-like regexps
2348 rule RemoveOptWild {
2349   local oname = $(1) ;
2350   local str = $(2) ;
2351   local res = ;
2352   local f ;
2353   local t ;
2354   #Echo "removing " $(oname) " from " $(str) ;
2355   for f in $(str) {
2356     t = [ Match $(oname) : $(f) ] ;
2357     #Echo $(f) ": " $(t) ;
2358     if $(t[1]) = "" {
2359       #Echo "include: " $(f) ;
2360       res += $(f) ;
2361     }
2362   }
2363   return $(res) ;
2367 # profile rules
2368 K8JAM-KNOWN-PROFILES =
2369   none default  # don't change
2370   empty         # remove optimisation flags
2371   speed         # optimise for speed
2372   size          # optimise for size
2373   debug         # don't optimize, add debug info
2374   standard      # -O2
2378 rule --k8jam-profile-none {
2379   Echo "MSG: default profile" ;
2380   OPT_PROFILE = ;
2383 rule --k8jam-profile-empty {
2384   Echo "MSG: default profile" ;
2387 rule --k8jam-profile-empty-- {
2388   Echo "MSG: empty profile" ;
2389   SLACK_PKG_ARCH = "i486" ;
2390   LINKFLAGS.all += -s ;
2393 rule --k8jam-profile-speed-- {
2394   Echo "MSG: 'speed' profile" ;
2395   SLACK_PKG_ARCH = "i686" ;
2396   CFLAGS.all += $(OPTIM_SPEED) ;
2397   LINKFLAGS.all += $(LINKFLAGS_SPEED) ;
2400 rule --k8jam-profile-size-- {
2401   Echo "MSG: 'size' profile" ;
2402   SLACK_PKG_ARCH = "i686" ;
2403   CFLAGS.all += $(OPTIM_SIZE) ;
2404   LINKFLAGS.all += $(LINKFLAGS_SIZE) ;
2407 rule --k8jam-profile-debug-- {
2408   Echo "MSG: 'debug' profile" ;
2409   SLACK_PKG_ARCH = "i486" ;
2410   LINKFLAGS.all -= -s ;
2411   CFLAGS.all += $(OPTIM_DEBUG) ;
2412   LINKFLAGS.all += $(LINKFLAGS_DEBUG) ;
2415 rule --k8jam-profile-standard-- {
2416   Echo "MSG: 'standard' profile" ;
2417   SLACK_PKG_ARCH = "i486" ;
2418   CFLAGS.all += -O2 ;
2419   LINKFLAGS.all += -s ;
2423 # profile "name" ;
2424 # set compile flags for profile; works only for gcc/g++
2425 # available profiles:
2426 #  none, default: don't change
2427 #  empty: remove optimisation flags
2428 #  speed: optimise for speed and pIII
2429 #  size: optimise for size
2430 #  debug: don't optimize, add debug info
2431 #  standard: -O2
2432 rule profile {
2433   if ! $(1) in $(K8JAM-KNOWN-PROFILES) {
2434     Echo "known profiles: $(K8JAM-KNOWN-PROFILES)" ;
2435     Exit "unknown profile: $(1)" ;
2436   }
2438   local orm = "(^\\-march\\=)" "(^\\-mtune\\=)" "(^\\-mfpmath\\=)" "(^\\-O.$)" ;
2439   local ormff = "(^\\-f[^n][^o])" ;
2441   OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM) ] ;
2442   C++OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(C++OPTIM) ] ;
2443   OBJCOPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OBJCOPTIM) ] ;
2444   OPTIM.all = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM.all) ] ;
2445   LINKFLAGS -= "-g" "-s" ;
2446   C++LINKFLAGS -= "-g" "-s" ;
2447   OBJCLINKFLAGS -= "-g" "-s" ;
2448   LINKFLAGS.all -= "-g" "-s" ;
2450   OPT_PROFILE = $(1) ;
2451   --k8jam-profile-$(OPT_PROFILE)-- ;
2453 #SLACK_PKG_ARCH ?= "i486" ;
2456 # selects 'debug', 'standard', 'speed' or 'size' profile according to vars:
2457 #  DEBUG = 1 : debug
2458 #  OPT_SIZE = 1 : size
2459 #  OPT_SPEED = 1 : speed
2460 #  default: standard
2461 rule set-profile {
2462   if $(DEBUG) {
2463     profile "debug" ;
2464   } else if $(OPT_SIZE) {
2465     profile "size" ;
2466   } else if $(OPT_SPEED) {
2467     profile "speed" ;
2468   } else {
2469     profile "standard" ;
2470   }
2471   if $(VALGRIND) {
2472     CFLAGS.all -= "-g" "-s" ;
2473     LINKFLAGS.all -= "-g" "-s" ;
2474     CFLAGS.all += -g ;
2475     LINKFLAGS.all += -g ;
2476   }
2477   if ! $(NO_WARNINGS) {
2478     CFLAGS.all += -Wall ;
2479   }
2483 # set default 'locate' vars -- _build/, etc
2484 rule set-default-subdir-locates {
2485   local d = $(TOP) ;
2486   if ! $(d) { d = "." ; }
2487   ALL_LOCATE_BIN = $(d) ;
2488   ALL_LOCATE_LIBSO = $(d) ;
2489   if $(WINDOZE) {
2490     ALL_LOCATE_TARGET = $(d)$(PATH_SEPARATOR)_wbuild ;
2491     ALL_LOCATE_LIB = $(d)$(PATH_SEPARATOR)_wbuild$(PATH_SEPARATOR)lib ;
2492   } else {
2493     ALL_LOCATE_TARGET = $(d)$(PATH_SEPARATOR)_build ;
2494     ALL_LOCATE_LIB = $(d)$(PATH_SEPARATOR)_build$(PATH_SEPARATOR)lib ;
2495   }
2496   HCACHEFILE = $(d)$(PATH_SEPARATOR)_build$(PATH_SEPARATOR).jamhdr.cache ;
2497   Clean clean : $(HCACHEFILE) ;
2501 rule set-default-target-locations {
2502   set-default-subdir-locates ;
2505 rule set-default-locations {
2506   set-default-subdir-locates ;
2509 rule set-target-locations {
2510   set-default-subdir-locates ;
2515 # ObjectNoAliasing filelist ;
2516 # turn off aliasing optimization for specified files
2517 # works only for gcc/g++
2518 rule ObjectNoAliasing {
2519   local isGCC = "ona" ;
2520   local isG++ = "ona" ;
2521   if ( "gcc" in $(CC) ) || ( $(JAM_TOOLSET) = MINGW ) { isGCC = "tan" ; }
2522   if ( "g++" in $(C++) ) || ( $(JAM_TOOLSET) = MINGW ) { isG++ = "tan" ; }
2523   if $(JAM_FORCE_GCC_OPTIONS) { isGCC = "tan" ; isG++ = "tan" ; }
2525   if $(isGCC) = "tan" { CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; }
2526   if $(isG++) = "tan" { C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ; }
2527   OBJCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(OPTIM_NOALIAS) ;
2531 # call $(1)
2532 # add output to var $(2)
2533 # return resulting (non-empty) string if library is present
2534 # if $(2) = "" -- don't add flags, just return
2535 # [ lib-config-ex "pkg-config sdl --cflags" : "CFLAGS" ]
2536 rule lib-config-ex {
2537   local cf lf res ;
2538   cf = [ Command "$(1) 2>/dev/null" : parse-output exit-code code-first ] ;
2539   if $(cf[1]) = "0" && $(cf[2]) {
2540     res = $(cf[2-]) ;
2541     if $(2) {
2542       $(2) += $(cf[2-]) ;
2543     }
2544   } else {
2545     res = ;
2546   }
2547   return $(res) ;
2551 # call $(1) --cflags and $(1) --libs (many libs provides such configurators)
2552 # add necessary flags to compiler and linker vars
2553 # return "tan" (non-empty string) if library is present
2554 # if $(2) != "" -- don't add flags, just check
2555 # [ lib-config "pkg-config sdl" ]
2556 rule lib-config {
2557   local cf lf hasit ;
2559   cf = [ Command "$(1) --cflags 2>/dev/null" : parse-output exit-code code-first ] ;
2560   #Echo "cf:" $(cf) ;
2561   if $(cf[1]) = "0" && $(cf[2]) {
2562     hasit = "tan" ;
2563     #Echo "flags:" $(cf[2-]) ;
2564     if ! $(2) {
2565       CCFLAGS += $(cf[2-]) ;
2566       C++FLAGS += $(cf[2-]) ;
2567       OBJCFLAGS += $(cf[2-]) ;
2568     }
2569   }
2571   lf = [ Command "$(1) --libs 2>/dev/null" : parse-output exit-code code-first ] ;
2572   #Echo "lf:" $(lf) ;
2573   if $(lf[1]) = "0" && $(lf[2]) {
2574     hasit = "tan" ;
2575     #Echo "flags:" $(lf[2-]) ;
2576     if ! $(2) {
2577       LINKFLAGS += $(lf[2-]) ;
2578       C++LINKFLAGS += $(lf[2-]) ;
2579       OBJCLINKFLAGS += $(lf[2-]) ;
2580     }
2581   }
2583   return $(hasit) ;
2586 rule pkg-config {
2587   local res ;
2588   res = [ lib-config "pkg-config $(1)" ] ;
2589   return $(res) ;
2593 rule pkg-config-has {
2594   local res ;
2595   res = [ lib-config-ex "pkg-config $(1) --cflags --libs" ] ;
2596   return $(res) ;
2601 # Objective C vars
2604 OBJC_GNUSTEP_BASE_LIB = gnustep-base ;
2605 OBJC_GNUSTEP_GUI_LIB = gnustep-gui ;
2608 # Objective C rules
2610 rule ObjCUseGNUstepBase {
2611   if ! $(K8_INTERNAL_GNUSTEP_BASE) {
2612     #Echo "-l$(OBJC_GNUSTEP_BASE_LIB)" ;
2613     OBJCLINKLIBS += "-l$(OBJC_GNUSTEP_BASE_LIB)" ;
2614     K8_INTERNAL_GNUSTEP_BASE = tan ;
2615   }
2618 rule ObjCUseGNUstepGui {
2619   ObjCUseGNUstepBase ;
2620   if ! $(K8_INTERNAL_GNUSTEP_GUI) {
2621     K8_INTERNAL_GNUSTEP_GUI = tan ;
2622     #Echo "-l$(OBJC_GNUSTEP_GUI_LIB)" ;
2623     OBJCLINKLIBS += "-l$(OBJC_GNUSTEP_GUI_LIB)" ;
2624   }
2627 rule ObjCUseGNUstep {
2628   ObjCUseGNUstepBase ;
2629   ObjCUseGNUstepGui ;
2634 # windoze setup
2637 rule setup-windoze {
2638   if ! $(WINDOZE) { WINDOZE="tan" ; }
2639   PICFLAGS = ;
2640   SUFLIBSHR = .dll ;
2641   #WINDOZE_THREADS = -mthreads ;
2642   #WINDOZE_THREADS = ;
2643   WINE ?= "wine" ;
2644   MGPATH ?= "c:\\\\mingw\\\\bin\\\\" ;
2645   MGCC ?= "mingw32-gcc.exe -static-libgcc" ;
2646   MG++ ?= "mingw32-g++.exe -static-libgcc -static-libstdc++" ;
2647   CC = "$(WINE)" $(MGPATH)$(MGCC) ;
2648   LINK = "$(WINE)" $(MGPATH)$(MGCC) -Wl,--enable-auto-import ;
2649   AR = "$(WINE)" $(MGPATH)ar.exe -ru ;
2650   RANLIB = "$(WINE)" $(MGPATH)ranlib.exe ;
2651   C++ = "$(WINE)" $(MGPATH)$(MG++) ;
2652   C++LINK = "$(WINE)" $(MGPATH)$(MG++) -Wl,--enable-auto-import ;
2653   #LINKLIBS += -lkernel32 ;
2654   #LINKLIBS += -luser32 ;
2655   #LINKLIBS += -ladvapi32 ;
2656   #LINKLIBS += -lws2_32 ;
2657   #WINSUBSYS = "windows" ;
2658   #WINSUBSYS = "console" ;
2659   SUFEXE = .exe ;
2660   #LINKFLAGS += "-Wl,-subsystem,$(WINSUBSYS)" ;
2665 # 'help' and 'push' targets
2667 rule ShowHelpProfile {
2668   NotFile help-profile ;
2669   Always help-profile ;
2670   AShowHelpProfile help-profile ;
2672 actions AShowHelpProfile {
2673   echo "profile flags:"
2674   echo "  DEBUG=1           -- debug build"
2675   echo "  OPT_SPEED=1       -- optimize for speed"
2676   echo "  OPT_SIZE=1        -- optimize for size"
2677   echo "  VALGRIND=1        -- do not strip debug info"
2678   echo "  NO_WARNINGS=1     -- do not all '-Wall' flag"
2679   echo "WARNING: DON'T FORGET TO DO 'jam clean' before building with new flags!"
2681 ShowHelpProfile ;
2683 rule ShowHelp {
2684   NotFile help ;
2685   Always help ;
2686   AShowHelp help ;
2687   #AShowHelpProfile help ;
2689 actions AShowHelp {
2690   echo "WARNING: default help; override 'actions AShowHelp' definition to use 'help' target!"
2692 ShowHelp ;
2694 rule GitPush {
2695   NotFile push ;
2696   Always push ;
2697   AGitPush push ;
2699 actions AGitPush {
2700   echo "WARNING: add 'actions AGitPush' definition to use 'push' target!"
2702 GitPush ;
2706 # Now include the user's Jamfile.
2708 include $(JAMFILE) ;