📄 jambase
字号:
if $(OWNER) && $(CHOWN) { Chown $(tt) ; OWNER on $(tt) = $(OWNER) ; } if $(GROUP) && $(CHGRP) { Chgrp $(tt) ; GROUP on $(tt) = $(GROUP) ; } }}rule InstallBin{ local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ; InstallInto $(<) : $(_t) ; MODE on $(_t:G=installed) = $(EXEMODE) ;}rule InstallFile{ InstallInto $(<) : $(>) ; MODE on $(>:G=installed) = $(FILEMODE) ;}rule InstallLib{ InstallInto $(<) : $(>) ; MODE on $(>:G=installed) = $(FILEMODE) ;}rule InstallMan{ # Really this just strips the . from the suffix local i s d ; for i in $(>) { switch $(i:S) { case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ; case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ; case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ; case .n : s = n ; case .man : s = 1 ; } d = man$(s) ; InstallInto $(d:R=$(<)) : $(i) ; } MODE on $(>:G=installed) = $(FILEMODE) ;}rule InstallShell{ InstallInto $(<) : $(>) ; MODE on $(>:G=installed) = $(SHELLMODE) ;}rule Lex{ LexMv $(<) : $(>) ; DEPENDS $(<) : $(>) ; MakeLocate $(<) : $(LOCATE_SOURCE) ; Clean clean : $(<) ;}rule Library{ LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ; Objects $(>) ;}rule LibraryFromObjects{ local _i _l _s ; # Add grist to file names _s = [ FGristFiles $(>) ] ; _l = $(<:S=$(SUFLIB)) ; # library depends on its member objects if $(KEEPOBJS) { DEPENDS obj : $(_s) ; } else { DEPENDS lib : $(_l) ; } # Set LOCATE for the library and its contents. The bound # value shows up as $(NEEDLIBS) on the Link actions. # For compatibility, we only do this if the library doesn't # already have a path. if ! $(_l:D) { MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ; } if $(NOARSCAN) { # If we can't scan the library to timestamp its contents, # we have to just make the library depend directly on the # on-disk object files. DEPENDS $(_l) : $(_s) ; } else { # If we can scan the library, we make the library depend # on its members and each member depend on the on-disk # object file. DEPENDS $(_l) : $(_l)($(_s:BS)) ; for _i in $(_s) { DEPENDS $(_l)($(_i:BS)) : $(_i) ; } } Clean clean : $(_l) ; if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; } Archive $(_l) : $(_s) ; if $(RANLIB) { Ranlib $(_l) ; } # If we can't scan the library, we have to leave the .o's around. if ! ( $(NOARSCAN) || $(KEEPOBJS) ) { RmTemps $(_l) : $(_s) ; }}rule Link{ MODE on $(<) = $(EXEMODE) ; Chmod $(<) ;}rule LinkLibraries{ # make library dependencies of target # set NEEDLIBS variable used by 'actions Main' local _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ; DEPENDS $(_t) : $(>:S=$(SUFLIB)) ; NEEDLIBS on $(_t) += $(>:S=$(SUFLIB)) ;}rule Main{ MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ; Objects $(>) ;}rule MainFromObjects{ local _s _t ; # Add grist to file names # Add suffix to exe _s = [ FGristFiles $(>) ] ; _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ; if $(_t) != $(<) { DEPENDS $(<) : $(_t) ; NOTFILE $(<) ; } # make compiled sources a dependency of target DEPENDS exe : $(_t) ; DEPENDS $(_t) : $(_s) ; MakeLocate $(_t) : $(LOCATE_TARGET) ; Clean clean : $(_t) ; Link $(_t) : $(_s) ;}rule MakeLocate{ if $(>) { LOCATE on $(<) = $(>) ; Depends $(<) : $(>[1]) ; MkDir $(>[1]) ; }}rule MkDir{ # If dir exists, don't update it # Do this even for $(DOT). NOUPDATE $(<) ; if $(<) != $(DOT) && ! $($(<)-mkdir) { local s ; # Cheesy gate to prevent multiple invocations on same dir # MkDir1 has the actions # Arrange for jam dirs $(<)-mkdir = true ; MkDir1 $(<) ; Depends dirs : $(<) ; # Recursively make parent directories. # $(<:P) = $(<)'s parent, & we recurse until root s = $(<:P) ; if $(NT) { switch $(s) { case *: : s = ; case *:\\ : s = ; } } if $(s) && $(s) != $(<) { Depends $(<) : $(s) ; MkDir $(s) ; } else if $(s) { NOTFILE $(s) ; } }}rule Object{ local h ; # locate object and search for source, if wanted Clean clean : $(<) ; MakeLocate $(<) : $(LOCATE_TARGET) ; SEARCH on $(>) = $(SEARCH_SOURCE) ; # Save HDRS for -I$(HDRS) on compile. # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers # in the .c file's directory, but generated .c files (from # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly # different from $(SEARCH_SOURCE). HDRS on $(<) = $(SEARCH_SOURCE) $(HDRS) $(SUBDIRHDRS) ; # handle #includes for source: Jam scans for headers with # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE) # with the scanned file as the target and the found headers # as the sources. HDRSEARCH is the value of SEARCH used for # the found header files. Finally, if jam must deal with # header files of the same name in different directories, # they can be distinguished with HDRGRIST. # $(h) is where cc first looks for #include "foo.h" files. # If the source file is in a distant directory, look there. # Else, look in "" (the current directory). if $(SEARCH_SOURCE) { h = $(SEARCH_SOURCE) ; } else { h = "" ; } HDRRULE on $(>) = HdrRule ; HDRSCAN on $(>) = $(HDRPATTERN) ; HDRSEARCH on $(>) = $(HDRS) $(SUBDIRHDRS) $(h) $(STDHDRS) ; HDRGRIST on $(>) = $(HDRGRIST) ; # if source is not .c, generate .c with specific rule switch $(>:S) { case .asm : As $(<) : $(>) ; case .c : Cc $(<) : $(>) ; case .C : C++ $(<) : $(>) ; case .cc : C++ $(<) : $(>) ; case .cpp : C++ $(<) : $(>) ; case .f : Fortran $(<) : $(>) ; case .l : Cc $(<) : $(<:S=.c) ; Lex $(<:S=.c) : $(>) ; case .s : As $(<) : $(>) ; case .y : Cc $(<) : $(<:S=.c) ; Yacc $(<:S=.c) : $(>) ; case * : UserObject $(<) : $(>) ; }}rule ObjectCcFlags{ CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;}rule ObjectC++Flags{ C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;}rule ObjectHdrs{ HDRS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;}rule Objects{ local _i ; for _i in [ FGristFiles $(<) ] { Object $(_i:S=$(SUFOBJ)) : $(_i) ; DEPENDS obj : $(_i:S=$(SUFOBJ)) ; }}rule RmTemps{ TEMPORARY $(>) ;}rule Setuid{ MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;}rule Shell{ DEPENDS shell : $(<) ; DEPENDS $(<) : $(>) ; SEARCH on $(>) = $(SEARCH_SOURCE) ; MODE on $(<) = $(SHELLMODE) ; Clean clean : $(<) ; Chmod $(<) ;}rule SubDir{ local _r _s ; # # SubDir TOP d1 [ ... ] # # This introduces a Jamfile that is part of a project tree # rooted at $(TOP). It (only once) includes the project-specific # rules file $(TOP)/Jamrules and then sets search & locate stuff. # # If the variable $(TOPRULES) is set (where TOP is the first arg # to SubDir), that file is included instead of $(TOP)/Jamrules. # # d1 ... are the directory elements that lead to this directory # from $(TOP). We construct the system dependent path from these # directory elements in order to set search&locate stuff. # if ! $($(<[1])) { if ! $(<[1]) { EXIT SubDir syntax error ; } $(<[1]) = [ FSubDir $(<[2-]) ] ; } # # If $(TOP)/Jamrules hasn't been included, do so. # if ! $($(<[1])-included) { # Gated entry. $(<[1])-included = TRUE ; # File is $(TOPRULES) or $(TOP)/Jamrules. _r = $($(<[1])RULES) ; if ! $(_r) { _r = $(JAMRULES:R=$($(<[1]))) ; } # Include it. include $(_r) ; } # Get path to current directory from root using SubDir. # Save dir tokens for other potential uses. _s = [ FDirName $(<[2-]) ] ; SUBDIR = $(_s:R=$($(<[1]))) ; SUBDIR_TOKENS = $(<[2-]) ; # Now set up SEARCH_SOURCE, LOCATE_TARGET, SOURCE_GRIST # These can be reset if needed. For example, if the source # directory should not hold object files, LOCATE_TARGET can # subsequently be redefined. SEARCH_SOURCE = $(SUBDIR) ; LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ; LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ; SOURCE_GRIST = [ FGrist $(<[2-]) ] ; # Reset per-directory ccflags, hdrs SUBDIRCCFLAGS = ; SUBDIRC++FLAGS = ; SUBDIRHDRS = ;}rule SubDirCcFlags{ SUBDIRCCFLAGS += $(<) ;}rule SubDirC++Flags{ SUBDIRC++FLAGS += $(<) ;}rule SubDirHdrs{ SUBDIRHDRS += $(<) ;}rule SubInclude{ local _s ; # That's # SubInclude TOP d1 [ d2 [ d3 [ d4 ] ] ] # # to include a subdirectory's Jamfile. if ! $($(<[1])) { EXIT Top level of source tree has not been set with $(<[1]) ; } _s = [ FDirName $(<[2-]) ] ; include $(JAMFILE:D=$(_s):R=$($(<[1]))) ;}rule Undefines{ UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;}rule UserObject{ EXIT "Unknown suffix on" $(>) "- see UserObject rule in Jamfile(5)." ;}rule Yacc{ local _h ; _h = $(<:BS=.h) ; # Some places don't have a yacc. MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ; if $(YACC) { DEPENDS $(<) $(_h) : $(>) ; Yacc1 $(<) $(_h) : $(>) ; YaccMv $(<) $(_h) : $(>) ; Clean clean : $(<) $(_h) ; } # make sure someone includes $(_h) else it will be # a deadly independent target INCLUDES $(<) : $(_h) ;}## Utility rules; no side effects on these#rule FGrist{ # Turn individual elements in $(<) into grist. local _g _i ; _g = $(<[1]) ; for _i in $(<[2-]) { _g = $(_g)!$(_i) ; } return $(_g) ;}rule FGristFiles { if ! $(SOURCE_GRIST) { return $(<) ; } else { return $(<:G=$(SOURCE_GRIST)) ; }}rule FGristSourceFiles{ # Produce source file name name with grist in it, # if SOURCE_GRIST is set. # Leave header files alone, because they have a global # visibility. if ! $(SOURCE_GRIST) { return $(<) ; } else { local _i _o ; for _i in $(<) { switch $(_i) { case *.h : _o += $(_i) ; case * : _o += $(_i:G=$(SOURCE_GRIST)) ; } } return $(_o) ; }}rule FConcat{ # Puts the variables together, removing spaces. local _t _r ; $(_r) = $(<[1]) ; for _t in $(<[2-]) { $(_r) = $(_r)$(_t) ; } return $(_r) ;}rule FSubDir{ local _i _d ; # If $(>) is the path to the current directory, compute the # path (using ../../ etc) back to that root directory. # Sets result in $(<) if ! $(<[1]) { _d = $(DOT) ; } else { _d = $(DOTDOT) ; for _i in $(<[2-]) { _d = $(_d:R=$(DOTDOT)) ; } } return $(_d) ;}rule FDirName{ local _s _i ; # Turn individual elements in $(<) into a usable path. if ! $(<) { _s = $(DOT) ; } else if $(VMS) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -