home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume27 / jam / part01 next >
Text File  |  1993-11-14  |  57KB  |  2,345 lines

  1. Newsgroups: comp.sources.unix
  2. From: seiwald@vix.com (Christopher Seiwald)
  3. Subject: v27i081: jam - just another make, Part01/05
  4. Message-id: <1.753385306.22859@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: seiwald@vix.com (Christopher Seiwald)
  9. Posting-Number: Volume 27, Issue 81
  10. Archive-Name: jam/part01
  11.  
  12. Jam - make(1) redux
  13.  
  14. FEATURES
  15.  
  16.     Jam is a make-like program that supplants make's implicit rules
  17.     with a real language for defining dependencies and update
  18.     actions.   Its features include:
  19.  
  20.     o       Jam finds header file dependencies using regexp(3)
  21.         patterns.
  22.  
  23.     o       Jam has a real language, including conditionals and
  24.         list valued variables.
  25.  
  26.     o       A central Jambase defines the rules, which can be
  27.         customized for large products.
  28.  
  29.     o       Per directory Jamfiles are simple and are normally
  30.         system independent.
  31.  
  32.     o       Jam can build large systems without recursing.
  33.  
  34.     o        Jam never tries to store state in any funny files.
  35.  
  36.     o        Jam runs on UNIX and VMS, and is portable.
  37.  
  38. PORTING
  39.  
  40.     Build jam with make(1) on:
  41.  
  42.         BSDI        BSD/386 1.0
  43.         DEC 3000/500    OSF/1
  44.         DG AViiON       DGUX 5.4
  45.         HP 9000/700     HPUX 9.0
  46.         IBM RS/6000     AIX        *
  47.         SGI R4000       IRIX 5.0
  48.         Sequent 2000    PTX V2.1.0
  49.         Sun 3           SunOS4.0
  50.         Sun 4           Solaris 2    *+
  51.         Sun 4           SunOS4.1
  52.         VAX             Ultrix 4.2
  53.     
  54.         * requires editing Makefile
  55.         + only works with SUNSwpro CC (dirent confusion) 
  56.  
  57.     Build jam with @build.com on:
  58.  
  59.         VAX            VMS 5.4
  60.         DEC 3000/500    OPENVMS    *
  61.  
  62.         * requires editing build.com
  63.  
  64.     See the "Porting" file for info on more wildcat ports.
  65.  
  66. Comments to the author!
  67.  
  68.     Christopher Seiwald
  69.     Seiwald@vix.com
  70.     November, 1993
  71.  
  72. Submitted-by: seiwald@vix.com
  73. Archive-name: jam - make(1) redux/part01
  74.  
  75. #!/bin/sh
  76. # This is jam - make(1) redux, a shell archive (produced by shar 3.49)
  77. # To extract the files from this archive, save it to a file, remove
  78. # everything above the "!/bin/sh" line above, and type "sh file_name".
  79. #
  80. # made 11/15/1993 03:06 UTC by seiwald@vix.com
  81. # Source directory /usr/team/seiwald/jam
  82. #
  83. # existing files will NOT be overwritten unless -c is specified
  84. #
  85. # This shar contains:
  86. # length  mode       name
  87. # ------ ---------- ------------------------------------------
  88. #   1709 -r--r--r-- README
  89. #   6280 -r--r--r-- Jambase.5
  90. #  13472 -r--r--r-- jam.1
  91. #    619 -r--r--r-- Build.com
  92. #   3419 -r--r--r-- Examples
  93. #    320 -r--r--r-- Makefile
  94. #   2355 -r--r--r-- Porting
  95. #   9400 -r--r--r-- Jambase
  96. #   8788 -r--r--r-- Jambase.VMS
  97. #    532 -r--r--r-- Jamfile
  98. #  13686 -r--r--r-- compile.c
  99. #   1082 -r--r--r-- compile.h
  100. #    182 -r--r--r-- execcmd.h
  101. #    772 -r--r--r-- execunix.c
  102. #   1733 -r--r--r-- execvms.c
  103. #   8227 -r--r--r-- expand.c
  104. #    128 -r--r--r-- expand.h
  105. #    842 -r--r--r-- filesys.h
  106. #   6593 -r--r--r-- fileunix.c
  107. #   8453 -r--r--r-- filevms.c
  108. #   5071 -r--r--r-- hash.c
  109. #    311 -r--r--r-- hash.h
  110. #   2368 -r--r--r-- headers.c
  111. #    119 -r--r--r-- headers.h
  112. #   2752 -r--r--r-- lists.c
  113. #    427 -r--r--r-- lists.h
  114. #  14415 -r--r--r-- make.c
  115. #    131 -r--r--r-- make.h
  116. #   1671 -r--r--r-- newstr.c
  117. #    148 -r--r--r-- newstr.h
  118. #   1584 -r--r--r-- option.c
  119. #    428 -r--r--r-- option.h
  120. #    923 -r--r--r-- parse.c
  121. #    354 -r--r--r-- parse.h
  122. #     39 -r--r--r-- patchlevel.h
  123. #  31610 -r--r--r-- regexp.c
  124. #    728 -r--r--r-- regexp.h
  125. #   4141 -r--r--r-- rules.c
  126. #   4149 -r--r--r-- rules.h
  127. #   3568 -r--r--r-- scan.c
  128. #    312 -r--r--r-- scan.h
  129. #   1438 -r--r--r-- search.c
  130. #    129 -r--r--r-- search.h
  131. #   3402 -r--r--r-- timestamp.c
  132. #    137 -r--r--r-- timestamp.h
  133. #   4103 -r--r--r-- variable.c
  134. #    213 -r--r--r-- variable.h
  135. #   4003 -r--r--r-- jam.c
  136. #   3290 -r--r--r-- jam.h
  137. #  22556 -r--r--r-- jamgram.c
  138. #    680 -r--r--r-- jamgram.h
  139. #   5366 -r--r--r-- jamgram.y
  140. #   4795 -r--r--r-- jamgram.yy
  141. #    655 -r--r--r-- jamgramtab.h
  142. #   1301 -r--r--r-- yyacc
  143. #
  144. # ============= README ==============
  145. if test -f 'README' -a X"$1" != X"-c"; then
  146.     echo 'x - skipping README (File already exists)'
  147. else
  148. echo 'x - extracting README (Text)'
  149. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  150. XJam - make(1) redux
  151. X
  152. XFEATURES
  153. X
  154. X    Jam is a make-like program that supplants make's implicit rules
  155. X    with a real language for defining dependencies and update
  156. X    actions.   Its features include:
  157. X
  158. X    o       Jam finds header file dependencies using regexp(3)
  159. X        patterns.
  160. X
  161. X    o       Jam has a real language, including conditionals and
  162. X        list valued variables.
  163. X
  164. X    o       A central Jambase defines the rules, which can be
  165. X        customized for large products.
  166. X
  167. X    o       Per directory Jamfiles are simple and are normally
  168. X        system independent.
  169. X
  170. X    o       Jam can build large systems without recursing.
  171. X
  172. X    o        Jam never tries to store state in any funny files.
  173. X
  174. X    o        Jam runs on UNIX and VMS, and is portable.
  175. X
  176. XPORTING
  177. X
  178. X    Build jam with make(1) on:
  179. X
  180. X        BSDI        BSD/386 1.0
  181. X        DEC 3000/500    OSF/1
  182. X        DG AViiON       DGUX 5.4
  183. X        HP 9000/700     HPUX 9.0
  184. X        IBM RS/6000     AIX        *
  185. X        SGI R4000       IRIX 5.0
  186. X        Sequent 2000    PTX V2.1.0
  187. X        Sun 3           SunOS4.0
  188. X        Sun 4           Solaris 2    *+
  189. X        Sun 4           SunOS4.1
  190. X        VAX             Ultrix 4.2
  191. X    
  192. X        * requires editing Makefile
  193. X        + only works with SUNSwpro CC (dirent confusion) 
  194. X
  195. X    Build jam with @build.com on:
  196. X
  197. X        VAX            VMS 5.4
  198. X        DEC 3000/500    OPENVMS    *
  199. X
  200. X        * requires editing build.com
  201. X
  202. X    See the "Porting" file for info on more wildcat ports.
  203. X
  204. XOTHER FILES
  205. X
  206. X    Aside from source files, there is:
  207. X
  208. X    Build.com    VMS command script
  209. X    Examples    sample Jamfiles
  210. X    Makefile    a bootstrap makefile
  211. X    Porting        notes on porting jam
  212. X    Jambase.5    Jambase man page
  213. X    jam.1        jam man page
  214. X    yyacc        a yacc pre-preprocessor
  215. X
  216. XComments to the author!
  217. X
  218. XChristopher Seiwald
  219. XSeiwald@vix.com
  220. XNovember, 1993
  221. SHAR_EOF
  222. chmod 0444 README ||
  223. echo 'restore of README failed'
  224. Wc_c="`wc -c < 'README'`"
  225. test 1709 -eq "$Wc_c" ||
  226.     echo 'README: original size 1709, current size' "$Wc_c"
  227. fi
  228. # ============= Jambase.5 ==============
  229. if test -f 'Jambase.5' -a X"$1" != X"-c"; then
  230.     echo 'x - skipping Jambase.5 (File already exists)'
  231. else
  232. echo 'x - extracting Jambase.5 (Text)'
  233. sed 's/^X//' << 'SHAR_EOF' > 'Jambase.5' &&
  234. X.TH JAM 5 "30 August 1993"
  235. X.SH NAME
  236. XJambase \- 
  237. X.BR jam (1)
  238. Xboilerplate
  239. X.SH SYNOPSIS
  240. X.B /usr/share/lib/jam/Jambase
  241. X.br
  242. X.B Jamfile
  243. X.SH DESCRIPTION
  244. X.PP
  245. X.B Jambase
  246. Xcontains a set of
  247. X.B jam
  248. Xrule definitions that provide roughly
  249. X.BR make (1)-like
  250. Xfunctionality.
  251. X.B Jam
  252. Xreads
  253. X.BR Jambase ,
  254. Xwhich in turn includes the
  255. X.B Jamfile
  256. Xfrom the current directory.
  257. XThe rules defined and variables used for the 
  258. X.B Jamfile 
  259. Xare as follows:
  260. X.SS Rules
  261. X.PP
  262. X.IP "MAIN image : sources ;"
  263. X.IP
  264. XCompiles
  265. X.I sources
  266. Xand links them into
  267. X.IR image .
  268. X.I Image
  269. Xbecomes a dependency of 
  270. X.IR exe ,
  271. Xitself a dependency of
  272. X.IR all .
  273. X.IP "LIBS image : libraries ;"
  274. X.IP
  275. XAdds 
  276. X.I libraries
  277. Xas dependencies of
  278. X.I image
  279. Xand includes them during the linking.
  280. X.IP "SETUID image ;"
  281. X.IP
  282. XSets the setuid bit on
  283. X.I image
  284. Xafter linking.
  285. X.IP "UNDEFINES image : symbols ;"
  286. X.IP
  287. XTries to convice the loader that symbols need to be "undefined" for
  288. Xthe linking to work.
  289. X.IP "LIBRARY library : sources ;"
  290. X.IP
  291. XCompiles
  292. X.I sources
  293. Xand archives them into 
  294. X.IR library .
  295. XThe intermediate objects are deleted.
  296. X.I Library 
  297. Xbecomes a dependency of 
  298. X.IR lib ,
  299. Xitself a dependency of
  300. X.IR all .
  301. X.IP "OBJECT object : source ;"
  302. X.IP
  303. XCompiles a single source file
  304. X.I source
  305. Xinto
  306. X.IR object .
  307. XThis rule is used by
  308. X.B MAIN
  309. Xand 
  310. X.BR LIBRARY .
  311. XArranges for 
  312. X.I source
  313. Xto be scanned for header file includes when then become dependencies of
  314. X.IR object .
  315. XSuch dependencies are "soft": missing headers are not an error.
  316. X.IP
  317. XFor 
  318. X.IR source , 
  319. Xthe following suffixes are recognised:
  320. X.RS
  321. X.IP .c
  322. XC source file
  323. X.IP .l
  324. X.IR lex (1)
  325. Xsource file.
  326. XThe resuling lex.yy.c is renamed to be the same base as the
  327. X.IR source .
  328. X.IP .y
  329. X.IR yacc (1)
  330. Xsource file.  
  331. XThe resulting y.tab.c and y.tab.h are renamed to the same base as
  332. X.IR source .
  333. X.PP
  334. XAll other suffixes are passed to the rule
  335. X.IP
  336. XCCUSER object : source ;
  337. X.PP
  338. Xto be defined in the user's
  339. X.I Jamfile
  340. X(or elsewhere).
  341. X.RE
  342. X.IP "BULK directory : sources ;"
  343. X.IP
  344. XCopies
  345. X.I sources
  346. Xinto 
  347. X.IR directory .
  348. XAll targets become dependencies of
  349. X.IR files ,
  350. Xitself a dependency of
  351. X.IR all .
  352. X.IP "FILE target : source ;"
  353. X.IP
  354. XCopies 
  355. X.I source
  356. Xinto 
  357. X.IR target .
  358. X.I Target
  359. Xbecome a dependency of
  360. X.IR files ,
  361. Xitself a dependency of
  362. X.IR all .
  363. X.IP "SHELL image : source ;"
  364. X.IP
  365. XCopies 
  366. X.I source
  367. Xinto the executable 
  368. X.IR sh(1)
  369. Xscript
  370. X.IR image .
  371. X.I Image
  372. Xbecome a dependency of
  373. X.IR shell ,
  374. Xitself a dependency of
  375. X.IR all .
  376. X.IP "INSTALLBIN sources ; "
  377. X.IP
  378. XCopy
  379. X.I sources
  380. Xinto /usr/local/bin.
  381. XAll targets become dependencies of
  382. X.IR install .
  383. X.IP "INSTALLLIB sources ;"
  384. X.IP
  385. XCopy
  386. X.I sources
  387. Xinto /usr/local/lib.
  388. XAll targets become dependencies of
  389. X.IR install .
  390. X.IP "INSTALLMAN sources ;"
  391. X.IP
  392. XCopy
  393. X.I sources
  394. Xinto the appropriate subdirectory of /usr/local/man.
  395. XAll targets become dependencies of
  396. X.IR install .
  397. X.IP "RMTEMPS targets : sources ;"
  398. X.IP
  399. XMarks
  400. X.I sources
  401. Xas temporary with the
  402. X.I TEMPORARY 
  403. Xrule, and deletes
  404. X.I sources
  405. Xonce
  406. X.I targets
  407. Xare built.
  408. XMust be the last rule invoked on
  409. X.IR targets .
  410. XUsed internally by
  411. X.BR OBJECT .
  412. X.SS Variables
  413. X.PP
  414. XAR (default
  415. X.IR "ar ru" )
  416. X.IP
  417. XThe archiver used for
  418. X.BR LIBRARY .
  419. X.PP 
  420. XBINDIR (default
  421. X.IR "/usr/local/bin" )
  422. X.IP
  423. XThe install directory for 
  424. X.BR INSTALLBIN .
  425. X.PP 
  426. XCC (default
  427. X.IR cc )
  428. X.IP
  429. XC compiler used for
  430. X.BR OBJECT .
  431. X.PP 
  432. XCCFLAGS (no default)
  433. X.IP
  434. XFlags handed to the C compiler for
  435. X.BR OBJECT .
  436. XN.B. 
  437. X.I OPTIM
  438. Xis also handed to the C compiler.
  439. X.PP 
  440. XEXEMODE (default 
  441. X.IR 711 )
  442. X.IP
  443. XPermissions for executables linked with
  444. X.BR MAIN .
  445. X.PP 
  446. XFILEMODE (default
  447. X.IR 644 )
  448. X.IP
  449. XPermissions for files copied by
  450. X.B FILE 
  451. Xor
  452. X.BR BULK .
  453. X.PP
  454. XHDRPATTERN (default ^#[\\t ]*include[\\t ]*[<"](.*)[">].*$)
  455. X.IP
  456. XThe
  457. X.IR regexp (3)
  458. Xpattern for finding header file includes in source files.
  459. XThe 
  460. X.B OBJECT
  461. Xrule sets the 
  462. X.I Jam
  463. Xspecial variable
  464. X.I HDRSCAN
  465. Xto
  466. X.I $(HDRPATTERN)
  467. Xfor all of its sources.
  468. XThe found header files are made dependencies of the target to
  469. X.BR OBJECT .
  470. X.PP 
  471. XHDRS (no default)
  472. X.IP
  473. XDirectories to be scanned for header files and handed to the C
  474. Xcompiler with -I.  The
  475. X.B OBJECT
  476. Xrule sets
  477. X.I HDRS
  478. Xto 
  479. X.I $(HDRS)
  480. Xfor each of its sources.
  481. X.PP
  482. XLEX (default 
  483. X.IR lex  )
  484. X.IP
  485. XThe 
  486. X.IR lex (1)
  487. Xcommand and flags.
  488. X.PP 
  489. XLIBDIR (default 
  490. X.IR /usr/local/lib )
  491. X.IP
  492. XThe target directory for 
  493. X.BR INSTALLLIB .
  494. X.PP
  495. XLINK (default 
  496. X.IR cc )
  497. X.IP
  498. XThe linker.
  499. X.PP
  500. XLINKFLAGS (default 
  501. X.IR $(CCFLAGS) )
  502. X.IP
  503. XFlags handed to the linker.
  504. X.PP
  505. XLINKLIBS (no default)
  506. X.IP
  507. XLibraries to hand to the linker.
  508. XThese libraries are not dependencies of the target image.
  509. X.PP
  510. XLOCATE_TARGET (no default)
  511. X.IP
  512. XThe directory for object modules and other intermediate files generated by
  513. X.BR OBJECT .
  514. XThis works by setting the
  515. X.I Jam
  516. Xspecial variable
  517. X.I LOCATE 
  518. Xto the value of 
  519. X.I $(LOCATE_TARGET)
  520. Xfor each of 
  521. X.BR OBJECT 's 
  522. Xtargets.
  523. X.PP
  524. XMV (default 
  525. X.IR "mv -f" )
  526. X.IP
  527. XThe file rename command and options.
  528. X.PP
  529. XOPTIM (default 
  530. X.IR -O )
  531. X.IP
  532. XMore flags handed to the C compiler.
  533. X.PP
  534. XRANLIB (default 
  535. X.IR ranlib )
  536. X.IP
  537. XIf set, the command string to be invoked on each library after archiving.
  538. X.PP
  539. XRM (default 
  540. X.IR "rm -f" )
  541. X.IP
  542. XThe command and options to remove a file.
  543. X.PP
  544. XSEARCH_SOURCE (no default)
  545. X.IP
  546. XThe directory to find sources listed with
  547. X.BR MAIN ,
  548. X.BR LIBRARY ,
  549. X.BR OBJECT ,
  550. X.BR BULK ,
  551. X.BR FILE ,
  552. X.BR SHELL ,
  553. X.BR INSTALLBIN ,
  554. X.BR INSTALLLIB ,
  555. Xand
  556. X.BR INSTALLMAN
  557. Xrules.
  558. XThis works by setting the
  559. X.I Jam
  560. Xspecial variable
  561. X.I SEARCH 
  562. Xto the value of 
  563. X.I $(SEARCH_SOURCE)
  564. Xfor each of the rules' sources.
  565. X.PP
  566. XSHELLHEADER (default 
  567. X.IR "#!/bin/sh" )
  568. X.IP
  569. XA string inserted to the first line of every file created by the
  570. X.B SHELL
  571. Xrule.
  572. X.PP
  573. XSHELLMODE (default 
  574. X.IR 755 )
  575. X.IP
  576. XPermissions for files installed by
  577. X.BR SHELL .
  578. X.PP
  579. XSTDHDRS (default 
  580. X.IR /usr/include )
  581. X.IP
  582. XDirectories where headers can be found without resorting to using the
  583. X-I flag to the C compiler.
  584. X.PP
  585. XUNDEFFLAG (default 
  586. X.IR "\-u _" )
  587. X.IP
  588. XThe flag prefixed to each symbol for the
  589. X.B UNDEFINES 
  590. Xrule.
  591. X.PP
  592. XYACC (default 
  593. X.IR "yacc -d" )
  594. X.IP
  595. XThe 
  596. X.IR yacc (1)
  597. Xcommand and flags.
  598. X.PP
  599. XJAMFILE (default
  600. X.IR Jamfile )
  601. X.IP
  602. XThe user provided file listing the sources to be built.
  603. X
  604. X.SH BUGS
  605. X.PP
  606. XBecause libraries are passed unbound to the 
  607. X.B LINK 
  608. Xrule as
  609. X.IR $(NEEDLIBS) , 
  610. Xthey cannot be located with 
  611. X.IR $(LOCATE) , 
  612. Xbecause 
  613. X.I $(LOCATE)
  614. Xaffects only changes the bound file name.
  615. X.PP
  616. XThere's no 
  617. X.IR yacc (1)
  618. Xon VMS, so the guts of the rules are commented out.
  619. SHAR_EOF
  620. chmod 0444 Jambase.5 ||
  621. echo 'restore of Jambase.5 failed'
  622. Wc_c="`wc -c < 'Jambase.5'`"
  623. test 6280 -eq "$Wc_c" ||
  624.     echo 'Jambase.5: original size 6280, current size' "$Wc_c"
  625. fi
  626. # ============= jam.1 ==============
  627. if test -f 'jam.1' -a X"$1" != X"-c"; then
  628.     echo 'x - skipping jam.1 (File already exists)'
  629. else
  630. echo 'x - extracting jam.1 (Text)'
  631. sed 's/^X//' << 'SHAR_EOF' > 'jam.1' &&
  632. X.TH JAM 1 "30 August 1993"
  633. X.SH NAME
  634. Xjam \- 
  635. X.BR make (1)
  636. Xredux
  637. X
  638. X.SH SYNOPSIS
  639. X.B jam
  640. X[
  641. X.B \-n
  642. X] [
  643. X.BI \-d " debug"
  644. X] [
  645. X.BI \-f " Jambase"
  646. X] ... [
  647. X.BI \-t " target"
  648. X] ... [
  649. X.I target
  650. X] ...
  651. X
  652. X.SH DESCRIPTION
  653. X.PP
  654. X.B Jam
  655. Xrecursively builds target files from their source files, using a
  656. X.B Jambase
  657. Xto define rules and a
  658. X.B Jamfile
  659. Xto lists the targets and sources in terms of those rules.  Together
  660. Xthey define the dependency tree and the updating actions for all
  661. Xtargets:
  662. X.B jam
  663. Xdoes not rely on suffix-driven implicit rules or directory contents.
  664. XA default
  665. X.BR Jambase 
  666. Xis provided with
  667. X.BR jam ;
  668. Xthe user supplies the
  669. X.BR Jamfile .
  670. X.PP
  671. XSee
  672. X.BR Jambase (5)
  673. Xfor information on writing Jamfiles.
  674. XThis manual page describes the program which interprets
  675. X.BR Jambase .
  676. X
  677. X.SH OPTIONS
  678. X.PP
  679. X.B Jam
  680. Xsupports the following options:
  681. X.IP "-n"
  682. XDon't actually execute the updating actions, but do everything else.
  683. X.IP "-d<n>"
  684. XSet the debug level to <n>.  Interesting values are:
  685. X.PP
  686. X.RS
  687. X0 Emit only errors
  688. X.br
  689. X1 Emit update action tracing (default)
  690. X.br
  691. X2 Emit update commands
  692. X.br
  693. X3 Produce dependency information
  694. X.br
  695. X4 Show timestamps of bound files
  696. X.br
  697. X5 Show rule invocation
  698. X.br
  699. X6-9 debugging
  700. X.RE
  701. X.IP "-f<file>"
  702. XRead <file> instead of 
  703. X.BR Jambase .
  704. X.IP "-t<target>"
  705. XPretend <target> is new, regardless of its actual timestamp.
  706. X
  707. X.SH "THE JAM LANGUAGE"
  708. X.PP
  709. XThe
  710. X.B jam
  711. Xlanguage supports defining and using rules, setting variables, and flow
  712. Xof control structures.  The
  713. X.B Jambase
  714. Xand
  715. X.B Jamfile
  716. Xshare this common language.
  717. X.SS "Lexical Features"
  718. X.B Jam
  719. Xtreats its input files as whitespace separated tokens, with two
  720. Xexceptions: double quotes (") can enclose whitespace to embed it into a
  721. Xtoken, and everything between the matching curly braces ({}) in the 
  722. Xdefinition of a rule action is treated as a single string.
  723. XA backslash (\\) can escape a double quote.
  724. X.SS Targets
  725. XTargets and sources (collectively "targets") are files to be updated
  726. Xand the files used in updating those targets.  A target is simply a
  727. Xfilename, either rooted or relative to the directory of
  728. X.BR Jam 's
  729. Xinvocation.  The special syntax,
  730. X.IR "file(member)" ,
  731. Xrefers to an
  732. X.BR ar (1)
  733. Xlibrary member.
  734. XThe special syntax,
  735. X.IR "<grist>file" ,
  736. Xperturbs a file name to distinguish it from other files
  737. Xwith the same name.  The <grist> is stripped from the name during
  738. Xbinding (see below).
  739. X.SS Rules
  740. X.BR Jam 's
  741. Xbasic entity is called a rule, which is used to relate targets to their
  742. Xsources.  A rule is defined in two parts: the
  743. X.B jam
  744. Xstatements to execute when the rule is invoked (essentially a procedure
  745. Xcall), and the actions (shell commands) to execute in order to update
  746. Xthe targets of the rule.  A rule may have a procedure definition, actions,
  747. Xor both.
  748. X.PP
  749. XThe 
  750. X.B jam
  751. Xstatements for defining and invoking rules are as follows, where
  752. X<targets> and <sources> are lists of filenames, <statements> are 
  753. X.B jam
  754. Xstatements, and <string> is a shell script:
  755. X.IP 
  756. Xrule <rulename> { <statements> }
  757. X.IP
  758. Xactions [ modifiers ] <rulename> { <string> }
  759. X.IP
  760. X<rulename> <targets> [ : <sources> ] ;
  761. X.PP
  762. XThe first form defines a rule's procedure; the second defines the rule's
  763. Xupdating actions; the third invokes the rule.  Redefining a rule's
  764. Xprocedure or actions replaces the previous definition.
  765. X.PP
  766. XInvoking a rule executes the procedure for the rule (if any) and associates 
  767. Xany update actions for the targets.  More than one update action may be
  768. Xassociated with a target: they are executed in the order in which they
  769. Xare added.
  770. X.PP
  771. XIn both the rule's precedure definition and the rule's actions, the
  772. Xspecial variables $(<) and $(>) refer to the <targets> and <sources>
  773. Xgiven at rule invocation.  However, in the rule's actions $(<) and $(>)
  774. Xrefer to the <targets> and <sources> after they have been bound by the
  775. Xbinding phase (see below).
  776. X.B Jam
  777. Xissues a warning if $(<) or $(>) have elements not in the dependency tree.
  778. X.PP
  779. XThe following action modifiers are understood:
  780. X.IP "actions ignore"
  781. XThe return status of the shell commands is ignored.
  782. X.IP "actions piecemeal"
  783. XThe shell commands are repeatedly invoked with a subset of $(>)
  784. Xsmall enough to fit in a command buffer.
  785. X.IP "actions quietly"
  786. XThe action is not echoed to the standard output.
  787. X.IP "actions together"
  788. XThe $(>) from multiple instances of the same action on the same
  789. Xtarget are glommed together.
  790. X.IP "actions updated "
  791. X$(>) includes only targets marked for updating.
  792. X.SS "Builtin Rules"
  793. X.PP
  794. X.B Jam
  795. Xhas six builtin rules, none of which have updating actions:
  796. X.PP
  797. X.IP "DEPENDS <targets> : <sources>"
  798. X.br
  799. XMakes <sources> dependents of <targets>.
  800. X.IP "ECHO <args>"
  801. X.br
  802. XBlurts out the message <args> to stdout.
  803. X.IP "INCLUDES <targets> : <sources>"
  804. X.br
  805. XMakes <sources> dependents of anything of which <targets> is a dependent.
  806. X.IP "NOCARE <targets>"
  807. X.br
  808. XMarks <targets> as possibly being bogus (see binding, below).
  809. X.IP "NOTIME <targets>"
  810. X.br
  811. XMarks <targets> as not being files (see binding, below).
  812. X.IP "TEMPORARY <targets>"
  813. X.br
  814. XMarks <targets> as temporary (see binding, below).
  815. X.SS "Flow of Control"
  816. X.PP
  817. X.B Jam
  818. Xhas several simple flow of control statements:
  819. X.IP
  820. Xinclude <a> ;
  821. X.IP
  822. Xfor <a> in <args> { <statements> }
  823. X.IP
  824. Xswitch <a> { case <v1> : <statements> ; case <v2> : <statements> ; ... }
  825. X.IP
  826. Xif <cond> { <statements> } else { <statements> }
  827. X.PP
  828. XThe 
  829. X.B include 
  830. Xstatement includes the named file; the path is relative to
  831. Xthe directory from which
  832. X.B jam
  833. Xwas invoked.
  834. X.PP
  835. XThe 
  836. X.B for 
  837. Xloop executes <statements> for each value in <args>, setting the
  838. Xvariable <a> to the value.  <a> is not variable expanded.
  839. X.PP
  840. XThe 
  841. X.B switch 
  842. Xstatement executes zero or one of the enclosed <statements>,
  843. Xdepending on which value <a> matches.  The <v> values are not variable
  844. Xexpanded.  A <v> value of * matches anything, but there is no other
  845. Xwildcarding (sorry).
  846. X.PP
  847. XThe 
  848. X.B if 
  849. Xstatement does the obvious; the 
  850. X.B else 
  851. Xclause is optional.  
  852. X.I <cond>
  853. Xis built of:
  854. X.PP
  855. X.RS
  856. X<a>        true if <a> is a non-zero length string
  857. X.br
  858. X<a1> = <b1>    strings equal
  859. X.br
  860. X<a1> != <b1>    strings not equal
  861. X.br
  862. X<a1> < <b1>    string less than
  863. X.br
  864. X<a1> <= <b1>    string less than or equal to
  865. X.br
  866. X<a1> > <b1>    string greater than
  867. X.br
  868. X<a1> >= <b1>    string greater than or equal to
  869. X.PP
  870. X! <cond>        condition not true
  871. X.br
  872. X<cond> && <cond>    conjunction
  873. X.br
  874. X<cond> || <cond>    disjunction
  875. X.br
  876. X( <cond> )        grouping
  877. X.RE
  878. X.PP
  879. XIn comparisons, the arguments may (through variable expansion) be more
  880. Xthan one token, but only the first token takes part in the comparison.
  881. XIf through variable expansion the argument is zero tokens, a single
  882. Xtoken of a zero length string is used instead.
  883. X.SS Variables
  884. X.PP
  885. X.B Jam
  886. Xvariables are lists of strings, with zero or more elements.  An unset
  887. Xvariable is indistinguishable from a variable whose value is an empty
  888. Xlist.  Variables are either global or target specific.  
  889. XAll variables are referenced as $(VARIABLE).
  890. X.PP
  891. XA variable is set with:
  892. X.IP
  893. X<variable> = <values> ;
  894. X.IP
  895. X<variable> default = <values> ;
  896. X.IP
  897. X<variable> on <targets> = <values> ;
  898. X.PP
  899. XThe first form sets <variable> globally to the given <values>; 
  900. Xthe second form only sets the variable if it is unset; the
  901. Xthird form arranges for <variable> to take on the <values> only
  902. Xwhen binding and updating <targets>.
  903. X.PP
  904. XOn program startup,
  905. X.B jam
  906. Ximports the environment variable settings into
  907. X.B jam
  908. Xvariables.
  909. X.B Jam
  910. Xvariables are not re-exported.
  911. X.SS "Variable Expansion"
  912. X.PP
  913. XBefore executing a statement
  914. X.B jam
  915. Xperforms variable expansion on each token that is not a keyword or rule
  916. Xname. Such tokens with embedded variable references are replaced with
  917. Xzero or more tokens.  Variable references are of the form $(v) or
  918. X$(vm), where v is the variable name and m are optional modifiers.
  919. X.PP
  920. XVariable expansion in a rule's actions is similar to variable expansion
  921. Xin statements, except that the action string is tokenized at whitespace
  922. Xwithout regards for quoting.
  923. X.PP
  924. XThe result of a token after variable expansion is the product of the
  925. Xcomponents of the token, where each component is a literal substring or
  926. Xa list substituting a variable reference.  For example:
  927. X.PP
  928. X.RS
  929. X$(X)        -> a b c
  930. X.br
  931. Xt$(X)        -> ta tb tc
  932. X.br
  933. X$(X)z        -> az bz cz
  934. X.br
  935. X$(X)-$(X)    -> a-a a-b a-c b-a b-b b-c c-a c-b c-c
  936. X.RE
  937. X.PP
  938. XThe variable name and modifiers can themselves contain a variable
  939. Xreference, and this partakes of the product as well: 
  940. X.PP
  941. X.RS
  942. X$(X)        -> a b c
  943. X.br
  944. X$(Y)        -> 1 2
  945. X.br
  946. X$(Z)        -> X Y
  947. X.br
  948. X$($(z))        -> a b c 1 2
  949. X.RE
  950. X.PP
  951. XBecause of this product expansion, if any variable reference in a token
  952. Xis unset then the result of the expansion is an empty list.
  953. X.PP
  954. XModifiers to a variable are of two varieties: subelement selection and
  955. Xfilename editing.  They are:
  956. X.PP
  957. X.IP "[<n>]"
  958. XSelect only element number <n> (starting at 1).  If the variable contains
  959. Xfewer than <n> elements, the result is a zero element list.
  960. X.IP "[<n>-<m>]"
  961. XSelect only elements number <n> through <m>.
  962. X.IP "[<n>-]"
  963. XSelect only elements number <n> through the last.
  964. X.IP ":G=<grist>"
  965. XReplace the grist of the filename with <grist>.
  966. X.IP ":D=<path>"
  967. XReplace directory component of filename with <path>.
  968. X.IP ":B=<base>"
  969. XReplace base part of filename with <base>.
  970. X.IP ":S=<suf>"
  971. XReplace suffix of filename with <suf>.
  972. X.IP ":M=<mem>"
  973. XReplace archive member name with <mem>.
  974. X.IP ":R=<root>"
  975. XPrepend <root> to whole name, if not already rooted.
  976. X.IP ":<components>"
  977. XReplace all components not listed with an empty string; components
  978. Xis one or more of the string
  979. X.IR GDBSM .
  980. X
  981. X.SH OPERATION
  982. X.B Jam
  983. Xhas three phases of operation: parsing, binding, and updating.  
  984. X.SS Parsing
  985. X.PP
  986. X.B Jam
  987. Xparses the file
  988. X.BR Jambase ,
  989. Xwhich by default includes
  990. X.BR Jamfile .
  991. XThe results of parsing are: the dependency tree of targets; update
  992. Xactions associated with the targets; and variables set to specific
  993. Xvalues.
  994. X.PP
  995. X.SS Binding
  996. XAfter parsing,
  997. X.B jam
  998. Xrecursively decends the dependency tree, attempting to locate each
  999. Xtarget file and determine if it is in need of updating.  
  1000. X.PP
  1001. XBy default, a target is located at the actual path of the target,
  1002. Xrelative to the directory of
  1003. X.BR jam 's
  1004. Xinvocation.  If $(LOCATE) is set to a directory name,
  1005. X.B jam
  1006. Xlocates the target in that directory; else if $(SEARCH) is set to
  1007. Xa directory list,
  1008. X.B jam
  1009. Xfirst searches along the directory list for the target file.  If the
  1010. Xtarget name has a rooted directory component then $(SEARCH) and
  1011. X$(LOCATE) do not apply: the target is located at the actual path of the
  1012. Xtarget.  If a target is marked as not being a file (using the builtin
  1013. Xrule NOTIME), it is left unbound to a file name.
  1014. X.PP
  1015. XA target is marked for updating if either it cannot be found, it's
  1016. Xfilesystem modification time is older than any of its dependents, or if
  1017. Xany of its dependents are marked for updating.  If a target is missing,
  1018. Xno updating actions are associated with the target, and the target has
  1019. Xnot been marked with the builtin rule NOCARE,
  1020. X.B jam
  1021. Xemits a warning.  If a target is missing and it is marked as temporary
  1022. X(with the builtin rule TEMPORARY), then its parent's modification time
  1023. Xis used when comparing against dependents.  If a target is marked as
  1024. Xnot being a file (using the builtin rule NOTIME), it is marked for
  1025. Xupdating only if any of its dependents are marked for updating.
  1026. X.PP
  1027. XIf a target is a source file that includes header files,
  1028. X.B jam
  1029. Xinvokes the rule $(HDRRULE) on the target giving the (unbound) names of
  1030. Xthe headers file as sources.  A target is scanned for header file
  1031. Xdependencies if $(HDRSCAN) is set to an regexp(3) pattern with ()'s
  1032. Xsurrounding the include file name.
  1033. X.PP
  1034. XBetween binding and updating,
  1035. X.B jam
  1036. Xannounces the number of targets to be updated.
  1037. X.SS Updating
  1038. XAfter binding,
  1039. X.B jam
  1040. Xagain recursively decends the dependency tree, this time executing the
  1041. Xupdate actions for each target that was marked for update during the
  1042. Xbinding phase.  If a target's updating actions fail, then all targets
  1043. Xdependent on that target are skipped.
  1044. X
  1045. X.SH DIAGNOSTICS
  1046. X.PP
  1047. XIn addition to generic error messages, 
  1048. X.B jam
  1049. Xmay emit one of the following:
  1050. X.PP
  1051. Xwarning: unknown rule X
  1052. X.IP
  1053. XA rule was invoked which has never been defined with
  1054. Xthe "actions" or the "rule" statements.
  1055. X.PP
  1056. Xusing N temp target(s)
  1057. X.IP
  1058. XTargets marked as being temporary (but nonetheless present)
  1059. Xhave been found.
  1060. X.PP
  1061. Xupdating N target(s)
  1062. X.IP
  1063. XTargets are out of date and will be updated.
  1064. X.PP
  1065. Xcan't make N target(s)
  1066. X.IP
  1067. XDue to sources not being found, targets cannot be made.
  1068. X.PP
  1069. Xwarning: X depends on itself
  1070. X.IP
  1071. XSomehow a target depends either directly or through its dependents
  1072. Xback on itself.  This most frequently happens with header file
  1073. Xinclusions.
  1074. X.PP
  1075. Xdon't know how to make X
  1076. X.IP
  1077. XA needed target is not present and no actions are defined to create
  1078. Xthe target.
  1079. X.PP
  1080. XX skipped for lack of Y
  1081. X.IP
  1082. XA dependent failed to build, and thus a target cannot be built.
  1083. X.PP
  1084. Xwarning: using independent target X
  1085. X.IP
  1086. XA target that is not a dependent of any target being made is
  1087. Xbeing referenced with $(<) or $(>).  
  1088. X.PP
  1089. XX removed
  1090. X.IP
  1091. X.B Jam
  1092. Xremoved a partially built target after being interrupted.
  1093. X
  1094. X.SH FILES
  1095. X/usr/local/lib/Jambase
  1096. X
  1097. X.SH BUGS, LIMITATIONS
  1098. X.PP
  1099. XBecause the
  1100. X.B include
  1101. Xstatement works by pushing a new file in the input stream of the
  1102. Xscanner rather than recursively invoking the parser on the new file,
  1103. Xmultiple include statements in a rule's procedure causes the files
  1104. Xto be included in reverse order.
  1105. X.PP
  1106. XIn a rule's actions, only $(<) and $(>) refer to the bound file names:
  1107. Xall other variable references get the unbound names.  This mostly
  1108. Xaffects 
  1109. X.IR IILIBRARY .
  1110. XSee 
  1111. X.IR Jambase (5).
  1112. X.PP
  1113. XSearching for include files is slow.
  1114. X
  1115. X.SH SEE ALSO
  1116. X.IR Jambase (5)
  1117. SHAR_EOF
  1118. chmod 0444 jam.1 ||
  1119. echo 'restore of jam.1 failed'
  1120. Wc_c="`wc -c < 'jam.1'`"
  1121. test 13472 -eq "$Wc_c" ||
  1122.     echo 'jam.1: original size 13472, current size' "$Wc_c"
  1123. fi
  1124. # ============= Build.com ==============
  1125. if test -f 'Build.com' -a X"$1" != X"-c"; then
  1126.     echo 'x - skipping Build.com (File already exists)'
  1127. else
  1128. echo 'x - extracting Build.com (Text)'
  1129. sed 's/^X//' << 'SHAR_EOF' > 'Build.com' &&
  1130. X! Bootstrap build script for Jam
  1131. X! On OPENVMS you need the next line
  1132. X! $ cc := cc/stand=vaxc
  1133. X$ cc compile.c
  1134. X$ cc expand.c
  1135. X$ cc execvms.c
  1136. X$ cc filevms.c
  1137. X$ cc hash.c
  1138. X$ cc headers.c
  1139. X$ cc lists.c
  1140. X$ cc make.c
  1141. X$ cc newstr.c
  1142. X$ cc option.c
  1143. X$ cc parse.c
  1144. X$ cc regexp.c
  1145. X$ cc rules.c
  1146. X$ cc scan.c
  1147. X$ cc search.c
  1148. X$ cc timestamp.c
  1149. X$ cc variable.c
  1150. X$ cc jam.c
  1151. X$ cc jamgram.c
  1152. X$ link/exe=jam.exe compile.obj, execvms.obj, expand.obj, filevms.obj, -
  1153. X    hash.obj, headers.obj, lists.obj, make.obj, newstr.obj, option.obj, -
  1154. X    parse.obj, regexp.obj, rules.obj, scan.obj, search.obj, timestamp.obj, -
  1155. X    variable.obj, jam.obj, jamgram.obj
  1156. SHAR_EOF
  1157. chmod 0444 Build.com ||
  1158. echo 'restore of Build.com failed'
  1159. Wc_c="`wc -c < 'Build.com'`"
  1160. test 619 -eq "$Wc_c" ||
  1161.     echo 'Build.com: original size 619, current size' "$Wc_c"
  1162. fi
  1163. # ============= Examples ==============
  1164. if test -f 'Examples' -a X"$1" != X"-c"; then
  1165.     echo 'x - skipping Examples (File already exists)'
  1166. else
  1167. echo 'x - extracting Examples (Text)'
  1168. sed 's/^X//' << 'SHAR_EOF' > 'Examples' &&
  1169. XJamfile examples.
  1170. X
  1171. X(1) A no-frills compile from sources:
  1172. X
  1173. X    MAIN program : source1.c source2.c grammar.y ;
  1174. X
  1175. X(2) To build xterm (on SunOS):
  1176. X
  1177. X    X11R4 = /usr/local/X11R4 ;
  1178. X    HDRS = $(X11R4)/include ;
  1179. X    LINKFLAGS = -L $(X11R4)/lib ;
  1180. X    LINKLIBS = -lXaw -lXmu -lXt -lX11 -loldX -lcurses -ltermcap ;
  1181. X    BINDIR = $(X11R4)/bin ;
  1182. X    MANDIR = $(X11R4)/man ;
  1183. X
  1184. X    MAIN xterm : TekPrsTbl.c Tekproc.c VTPrsTbl.c button.c charproc.c
  1185. X        cursor.c data.c input.c main.c menu.c misc.c screen.c scrollbar.c
  1186. X        tabs.c util.c ;
  1187. X
  1188. X    INSTALLBIN xterm ;
  1189. X    INSTALLMAN xterm.man ;
  1190. X
  1191. X(3) If the variable settings above were put into a separate customization
  1192. X    file JAMX, this file could be shrunk to:
  1193. X
  1194. X    include /usr/local/lib/JAMX ;
  1195. X
  1196. X    MAIN xterm : TekPrsTbl.c Tekproc.c VTPrsTbl.c button.c charproc.c
  1197. X        cursor.c data.c input.c main.c menu.c misc.c screen.c scrollbar.c
  1198. X        tabs.c util.c ;
  1199. X
  1200. X    INSTALLBIN xterm ;
  1201. X    INSTALLMAN xterm.man ;
  1202. X
  1203. X
  1204. X(4) To build from source in another directory:
  1205. X
  1206. X    include /usr/local/lib/JAMX ;
  1207. X
  1208. X    SEARCH_SOURCE = /usr/local/X11R4/src/mit/clients/xterm ;
  1209. X
  1210. X    MAIN xterm : TekPrsTbl.c Tekproc.c VTPrsTbl.c button.c charproc.c
  1211. X        cursor.c data.c input.c main.c menu.c misc.c screen.c scrollbar.c
  1212. X        tabs.c util.c ;
  1213. X
  1214. X    INSTALLBIN xterm ;
  1215. X    INSTALLMAN xterm.man ;
  1216. X
  1217. X(5) Here's an example of defining your own CCUSER to handle source files
  1218. X    other than .c and .o.  Ideally, this would be put into a separate
  1219. X    customization file to be included by the Jamfile.
  1220. X
  1221. X    # CCUSER object : source ; 
  1222. X    # 
  1223. X    # The OBJECT rule, invoked by MAIN and LIBRARY to handle sources, 
  1224. X    # only knows about .c, .l, and .y.  For all other suffixes, it 
  1225. X    # calls CCUSER with the desired object and source name.  So this 
  1226. X    # version extends the known suffixes to include .s's.
  1227. X
  1228. X    rule CCUSER 
  1229. X    {
  1230. X        # switch on suffix
  1231. X
  1232. X        switch $(>:D=:B=)
  1233. X        {
  1234. X        case .s    : AS $(<) : $(>) ;
  1235. X        case *     : ECHO "unknown suffix on" $(>) ;
  1236. X        }
  1237. X    }
  1238. X
  1239. X    # AS object : source ;
  1240. X    #
  1241. X    # assemble .s source
  1242. X
  1243. X    rule AS # object : source ;
  1244. X    {
  1245. X        # Any rule that builds a target from some sources should
  1246. X        # relate the sources and targets with DEPENDS.
  1247. X
  1248. X        DEPENDS $(<) : $(>) ;
  1249. X    }
  1250. X
  1251. X    actions AS
  1252. X    {
  1253. X        # This is a shell script.
  1254. X
  1255. X        as -o $(<) $(>)
  1256. X    }
  1257. X
  1258. X    LIBRARY data.a : fast.s ;
  1259. X
  1260. X(6) Finally, hooks for building a larger system.  These rules should live
  1261. X    in a file included by the Jamfile.
  1262. X
  1263. X    # XXINCLUDE subdir - include a subdirectory's Jamfile
  1264. X    #
  1265. X    # This rule bridges the gap between system independent Jamfiles
  1266. X    # and the system dependent directory naming (this version for
  1267. X    # UNIX).  This rule simply includes another Jamfile, first
  1268. X    # figuring out where it is.
  1269. X    #
  1270. X    # This assumes BASE is set externally.
  1271. X
  1272. X    rule XXINCLUDE 
  1273. X    {
  1274. X        INCLUDE $(BASE)/$(<)/Jamfile ;
  1275. X    }
  1276. X
  1277. X    # XXSUBDIR subdir - set up variables for this subdirectory
  1278. X    #
  1279. X    # This rule is the invoked first in a Jamfile to arrange 
  1280. X    # variable settings for headers, source, etc.  We want
  1281. X    # objects and other intermediate files to live in the
  1282. X    # source directory, hence the similar settings for
  1283. X    # SEARCH_SOURCE and LOCATE_TARGET.
  1284. X
  1285. X    rule XXSUBDIR
  1286. X    {
  1287. X        LIBRARY = $(BASE)/lib/lib$(<).a ;
  1288. X        SEARCH_SOURCE = $(BASE)/$(<) ;
  1289. X        LOCATE_TARGET = $(BASE)/$(<) ;
  1290. X        HDRS = $(BASE)/hdr ;
  1291. X    }
  1292. X
  1293. X    The $(BASE)/Jamfile may look like:
  1294. X
  1295. X    XXINCLUDE compile ;
  1296. X    XXINCLUDE parser ;
  1297. X    XXINCLUDE mailer ;
  1298. X
  1299. X    While an individual $(BASE)/compile/Jamfile may be:
  1300. X
  1301. X    XXSUBDIR compile ;
  1302. X
  1303. X    LIBRARY $(LIBRARY) : com1.c com2.c comhash.c ;
  1304. X
  1305. X11/1/93
  1306. SHAR_EOF
  1307. chmod 0444 Examples ||
  1308. echo 'restore of Examples failed'
  1309. Wc_c="`wc -c < 'Examples'`"
  1310. test 3419 -eq "$Wc_c" ||
  1311.     echo 'Examples: original size 3419, current size' "$Wc_c"
  1312. fi
  1313. # ============= Makefile ==============
  1314. if test -f 'Makefile' -a X"$1" != X"-c"; then
  1315.     echo 'x - skipping Makefile (File already exists)'
  1316. else
  1317. echo 'x - extracting Makefile (Text)'
  1318. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  1319. X# Makefile for jam
  1320. X
  1321. X# Special flavors - uncomment appropriate lines
  1322. X
  1323. X# Solaris 2.0 seem not to have any identifying cpp symbol
  1324. X#CFLAGS = -Dsolaris
  1325. X
  1326. X# AIX needs -lbsd, and has no identifying cpp symbol
  1327. X#LINKLIBS = -lbsd
  1328. X#CFLAGS = -DAIX
  1329. X
  1330. Xinstall: jam0
  1331. X    jam0 -f Jambase install
  1332. X
  1333. Xjam0:
  1334. X    cc $(CFLAGS) *.c -o jam0 $(LINKLIBS)
  1335. SHAR_EOF
  1336. chmod 0444 Makefile ||
  1337. echo 'restore of Makefile failed'
  1338. Wc_c="`wc -c < 'Makefile'`"
  1339. test 320 -eq "$Wc_c" ||
  1340.     echo 'Makefile: original size 320, current size' "$Wc_c"
  1341. fi
  1342. # ============= Porting ==============
  1343. if test -f 'Porting' -a X"$1" != X"-c"; then
  1344.     echo 'x - skipping Porting (File already exists)'
  1345. else
  1346. echo 'x - extracting Porting (Text)'
  1347. sed 's/^X//' << 'SHAR_EOF' > 'Porting' &&
  1348. XNotes on porting Jam
  1349. X
  1350. X1) Working out system dependencies in the Jam code.
  1351. X
  1352. X    Jam's OS footprint is fairly small.  For OS independent work Jam
  1353. X    liberally uses standard libc functions like stdio, malloc, and
  1354. X    string.  The OS dependent interfaces are:
  1355. X
  1356. X    From filesys.h:
  1357. X
  1358. X        file_parse() - split a file name into dir/base/suffix/member
  1359. X        file_build() - build a filename given dir/base/suffix/member
  1360. X        file_dirscan() - scan a directory for files
  1361. X        file_archscan() - scan an archive for files
  1362. X        file_time() - get the timestamp of a file, if not already 
  1363. X              done by file_dirscan().
  1364. X
  1365. X    From execcmd.h:
  1366. X
  1367. X        execcmd() - execute a shell script
  1368. X
  1369. X    Porting to another UNIX platform rarely involves more than fixing 
  1370. X    file_dirscan() or, more likely, file_archscan() to work on the rogue
  1371. X    directory or archive structure.  Porting to another OS, such as NT,
  1372. X    DOS, etc, probably require a completely new implementation of 
  1373. X    fileunix.c and execunix.c.
  1374. X
  1375. X2) Defining OTHERSYMS in jam.h
  1376. X
  1377. X    So that the Jambase and Jamfile know their host, Jam defines $(OS)
  1378. X    to be something useful for each platform.  Make sure that there is
  1379. X    code in jam.h to generate a useful value for $(OS), and key it off 
  1380. X    the platform specific C-preprocessor symbol.   If the C-preprocessor 
  1381. X    doesn't itself defines such a symbol, add a define to the Makefile.
  1382. X
  1383. X3) Working out system dependencies in the Jambase
  1384. X
  1385. X    With the value of $(OS) available, the Jambase can be extended to
  1386. X    support special variables or rules for new platforms.  For ports to
  1387. X    non UNIX platforms, it might pay to make a new Jambase.xxx
  1388. X    altogether, a la Jambase.VMS.
  1389. X
  1390. X4) Yacc troubles
  1391. X
  1392. X    The generated files jamgram.y and jamgramtab.h are distributed for
  1393. X    places without a sufficiently working sh/awk/sed to run yyacc.
  1394. X
  1395. X    The generated files jamgram.h and jamgram.c are distributed for the 
  1396. X    poor souls without yacc.
  1397. X
  1398. X5) Known problematic systems:
  1399. X
  1400. X    - Solaris 2.0 sucks (still).  Jam only works with the SUNWspro cc,
  1401. X      because the ucb one has bogus headers for dirent.
  1402. X
  1403. X    - Pyramid has no malloc.h, memory.h
  1404. X
  1405. X    - Encore has no stdlib.h
  1406. X
  1407. X    - Bull DPX has sys/file.h problems
  1408. X
  1409. X6) Send the results back.
  1410. X
  1411. X    If you do porting work, the result can be integrated into future
  1412. X    releases if you send it back to the author's adress in the README.
  1413. SHAR_EOF
  1414. chmod 0444 Porting ||
  1415. echo 'restore of Porting failed'
  1416. Wc_c="`wc -c < 'Porting'`"
  1417. test 2355 -eq "$Wc_c" ||
  1418.     echo 'Porting: original size 2355, current size' "$Wc_c"
  1419. fi
  1420. # ============= Jambase ==============
  1421. if test -f 'Jambase' -a X"$1" != X"-c"; then
  1422.     echo 'x - skipping Jambase (File already exists)'
  1423. else
  1424. echo 'x - extracting Jambase (Text)'
  1425. sed 's/^X//' << 'SHAR_EOF' > 'Jambase' &&
  1426. X#
  1427. X# /+\
  1428. X# +\    Copyright 1993 Christopher Seiwald.
  1429. X# \+/
  1430. X#
  1431. X
  1432. X#
  1433. X# JAMBASE - jam ruleset providing make(1)-like functionality
  1434. X#
  1435. X
  1436. X# Rules defined by this file:
  1437. X#
  1438. X# MAIN image : source ;        link executable from compiled sources
  1439. X# LIBS image : libraries ;    bag libraries onto a MAIN
  1440. X# UNDEFINES image : symbols ;    save undef's for linking
  1441. X# SETUID image ;        mark an executable SETUID
  1442. X# LIBRARY lib : source ;    archive library from compiled sources
  1443. X# OBJECT objname : source ;    compile object from source
  1444. X# HDRRULE source : headers ;    handle #includes
  1445. X# CC obj.o : source.c ;        .c -> .o
  1446. X# LEX source.c : source.l ;    .l -> .c
  1447. X# YACC source.c : source.y ;     .y -> .c
  1448. X# YYACC source.y : source.yy ;     .yy -> .y
  1449. X# BULK dir : files ;        populate directory with many files
  1450. X# FILE dest : source ;        copy file
  1451. X# SHELL exe : source ;        install a shell executable
  1452. X# RMTEMPS target : sources ;    remove temp sources after target made
  1453. X# INSTALLBIN sources ;        install binaries
  1454. X# INSTALLLIB sources ;        install files
  1455. X# INSTALLMAN source ;        install man pages
  1456. X#
  1457. X
  1458. X# Brief review of the jam language:
  1459. X#
  1460. X# Statements:
  1461. X#    rule RULE - statements to process a rule
  1462. X#    actions RULE - system commands to carry out target update
  1463. X#
  1464. X# Modifiers on actions:
  1465. X#    together - multiple instances of same rule on target get executed
  1466. X#           once with their sources ($(>)) concatenated
  1467. X#    updated - refers to updated sources ($(>)) only
  1468. X#    ignore - ignore return status of command
  1469. X#    quietly - don't trace its execution unless verbose
  1470. X#    piecemeal - iterate command each time with a small subset of $(>)
  1471. X#
  1472. X# Special rules:
  1473. X#    DEPENDS - builds the dependency graph
  1474. X#    ECHO - blurt out targets on stdout
  1475. X#    INCLUDES - marks sources as headers for target (a codependency)
  1476. X#    NOCARE - don't panic if the target can't be built
  1477. X#    NOTIME - ignore the timestamp of the target (it's not a file)
  1478. X#    TEMPORARY - target need not be present if sources haven't changed
  1479. X#
  1480. X# Special variables set by jam:
  1481. X#    $(<) - targets of a rule (to the left of the :)
  1482. X#    $(>) - sources of a rule (to the right of the :)
  1483. X#    $(UNIX) - true on UNIX
  1484. X#    $(VMS) - true on VMS
  1485. X#    $(OS) - name of OS - varies wildly
  1486. X#
  1487. X# Special variables used by jam:
  1488. X#    SEARCH - where to find something (used during binding and actions)
  1489. X#    LOCATE - where to plop something not found with SEARCH
  1490. X#    HDRRULE - rule to call to handle include files
  1491. X#    HDRSCAN - egrep regex to extract include files
  1492. X#
  1493. X# Special targets:
  1494. X#    all - default if none given on command line
  1495. X
  1496. X# Initialize variables
  1497. X#
  1498. X# "default =" - set only if unset
  1499. X
  1500. XAR         default = ar ru ;
  1501. XBINDIR        default = /usr/local/bin ;
  1502. XCC         default = cc ;
  1503. XCCFLAGS     default = ;
  1504. XCHMOD         default = chmod ;
  1505. XEXEMODE     default = 711 ;
  1506. XFILEMODE     default = 644 ;
  1507. XHDRS         default = ;
  1508. XLEX        default = lex ;
  1509. XLIBDIR        default = /usr/local/lib ;
  1510. XLINK         default = $(CC) ;
  1511. XLINKFLAGS     default = $(CCFLAGS) ;
  1512. XLINKLIBS     default = ;
  1513. XMANDIR        default = /usr/local/man ;
  1514. XMV         default = mv -f ;
  1515. XOPTIM        default = -O ;
  1516. XRANLIB         default = ranlib ;
  1517. XRM         default = rm -f ;
  1518. XSHELLHEADER     default = "#!/bin/sh" ;
  1519. XSHELLMODE     default = 755 ;
  1520. XSTDHDRS     default = /usr/include ;
  1521. XUNDEFFLAG    default = "-u _" ;
  1522. XYACC         default = yacc -d ;
  1523. XJAMFILE        default = Jamfile ;
  1524. X
  1525. XHDRPATTERN = "^#[     ]*include[     ]*[<\"](.*)[\">].*$" ;
  1526. X
  1527. X#
  1528. X# OS specific variable settings
  1529. X#
  1530. X
  1531. Xswitch $(OS) 
  1532. X{
  1533. Xcase AIX : LINKLIBS = -lbsd ;
  1534. Xcase DGUX : RANLIB = ;
  1535. Xcase IRIX : RANLIB = ;
  1536. Xcase HPUX : RANLIB = ;
  1537. Xcase PTX : RANLIB = ;
  1538. Xcase SOLARIS : RANLIB = ;
  1539. X}
  1540. X
  1541. X#
  1542. X# Base dependencies - first for "bootstrap" kinds of rules
  1543. X#
  1544. X
  1545. XDEPENDS all : first shell files lib exe ;
  1546. XNOTIME all first shell files lib exe ;
  1547. X
  1548. X#
  1549. X# The rules
  1550. X#
  1551. X
  1552. Xrule MAIN 
  1553. X{
  1554. X    # make compiled sources a dependency of target
  1555. X
  1556. X    DEPENDS exe : $(<) ;
  1557. X    DEPENDS    $(<) : $(>:S=.o) ;
  1558. X    LOCATE on $(<) = $(LOCATE_TARGET) ;
  1559. X
  1560. X    LINK $(<) : $(>:S=.o) ;
  1561. X
  1562. X    # each object gets compiled from sources
  1563. X
  1564. X    for i in $(>) 
  1565. X    { 
  1566. X        OBJECT $(i:S=.o) : $(i) ;
  1567. X    }
  1568. X}
  1569. X
  1570. Xactions LINK 
  1571. X{
  1572. X    if $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS) 
  1573. X    then chmod $(EXEMODE) $(<) 
  1574. X    else $(RM) $(<); exit 1
  1575. X    fi
  1576. X}
  1577. X
  1578. Xrule LIBS 
  1579. X{
  1580. X    # make library dependencies of target
  1581. X    # set NEEDLIBS variable used by 'actions MAIN'
  1582. X
  1583. X    DEPENDS $(<) : $(>) ;
  1584. X    NEEDLIBS on $(<) = $(>) ;
  1585. X}
  1586. X
  1587. Xrule UNDEFINES
  1588. X{
  1589. X    UNDEFS on $(<) = $(UNDEFFLAG)$(>) ;
  1590. X}
  1591. X
  1592. Xrule SETUID
  1593. X{
  1594. X    EXEMODE on $(<) = 4711 ;
  1595. X}
  1596. X
  1597. Xrule LIBRARY 
  1598. X{
  1599. X    # library depends on its member objects
  1600. X
  1601. X    DEPENDS lib : $(<) ;
  1602. X    DEPENDS $(<) : $(<)($(>:BS=.o)) ;
  1603. X
  1604. X    # We wish we could locate the library and it's contents,
  1605. X    # but the reference to $(NEEDLIBS) in MAIN's actions
  1606. X    # get the unbound names.  Only $(<) and $(>) refer to
  1607. X    # bound file name in rule actions.  Sigh.
  1608. X    # 
  1609. X    # LOCATE on $(<) $(<)($(>:BS=.o)) = $(LOCATE_TARGET) ;
  1610. X
  1611. X    # each archive member object depends on real object
  1612. X    # each real object gets compiled from sources
  1613. X
  1614. X    for i in $(>) 
  1615. X    {
  1616. X        DEPENDS $(<)($(i:BS=.o)) : $(i:S=.o) ; 
  1617. X        OBJECT $(i:S=.o) : $(i) ;
  1618. X    }
  1619. X
  1620. X    # must call separate ARCHIVE rule so that 'updated' modifier
  1621. X    # on 'actions' refers to updated .o's.
  1622. X    # delete objects after archive is made
  1623. X
  1624. X    ARCHIVE $(<) : $(>:S=.o) ;
  1625. X    RMTEMPS $(<) : $(>:S=.o) ;
  1626. X
  1627. X    if $(RANLIB) { RANLIB $(<) ; }
  1628. X}
  1629. X
  1630. Xactions updated together piecemeal ARCHIVE 
  1631. X{
  1632. X    $(AR) $(<) $(>)
  1633. X}
  1634. X
  1635. Xactions together RANLIB
  1636. X{
  1637. X    $(RANLIB) $(<)
  1638. X}
  1639. X
  1640. Xrule OBJECT 
  1641. X{
  1642. X    # locate object and search for source, if wanted
  1643. X
  1644. X    LOCATE on $(<) = $(LOCATE_TARGET) ;
  1645. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  1646. X
  1647. X    # Save HDRS for -I$(HDRS) on compile.
  1648. X    # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers 
  1649. X    # in the .c file's directory, but generated .c files (from 
  1650. X    # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly 
  1651. X    # different from $(SEARCH_SOURCE).
  1652. X
  1653. X    HDRS on $(<) = $(HDRS) $(SEARCH_SOURCE) ;
  1654. X
  1655. X    # handle #includes for source: Jam scans for headers with
  1656. X    # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
  1657. X    # with the scanned file as the target and the found headers
  1658. X    # as the sources.  HDRSEARCH is just grist for HDRRULE.
  1659. X
  1660. X    HDRRULE on $(>) = HDRRULE ;
  1661. X    HDRSCAN on $(>) = $(HDRPATTERN) ;
  1662. X    HDRSEARCH on $(>) = $(HDRS) $(STDHDRS) $(SEARCH_SOURCE) ;
  1663. X
  1664. X    # if source is not .c, generate .c with specific rule
  1665. X
  1666. X    switch $(>:S)
  1667. X    {
  1668. X        case .c :     CC $(<) : $(>) ;
  1669. X        case .l :    CC $(<) : $(<:S=.c) ;
  1670. X            LEX $(<:S=.c) : $(>) ;
  1671. X        case .y :     CC $(<) : $(<:S=.c) ; 
  1672. X            YACC $(<:S=.c) : $(>) ;
  1673. X        case .yy :     CC $(<) : $(<:S=.c) ; 
  1674. X            YACC $(<:S=.c) : $(<:S=.y) ;
  1675. X            YYACC $(<:S=.y) : $(>) ;
  1676. X        case * :    CCUSER $(<) : $(>) ;
  1677. X    }
  1678. X}
  1679. X
  1680. Xrule HDRRULE
  1681. X{
  1682. X    # HDRRULE source : headers ;
  1683. X
  1684. X    # N.B.  This rule is called during binding, potentially after 
  1685. X    # the fate of many targets has been determined, and must be 
  1686. X    # used with caution: don't add dependencies to unrelated 
  1687. X    # targets, and don't set variables on $(<).
  1688. X
  1689. X    # Tell Jam that anything depending on $(<) also depends on $(>), 
  1690. X    # set SEARCH so Jam can find the headers, but then say we don't
  1691. X    # care if we can't actually find the headers (they may have been 
  1692. X    # within ifdefs), 
  1693. X
  1694. X    INCLUDES $(<) : $(>) ;
  1695. X    SEARCH on $(>) = $(HDRSEARCH) ;
  1696. X    NOCARE $(>) ;
  1697. X
  1698. X    # Propagate on $(<) to $(>)
  1699. X
  1700. X    HDRSEARCH on $(>) = $(HDRSEARCH) ;
  1701. X    HDRSCAN on $(>) = $(HDRSCAN) ;
  1702. X    HDRRULE on $(>) = $(HDRRULE) ;
  1703. X}
  1704. X
  1705. Xrule CC
  1706. X{
  1707. X    DEPENDS $(<) : $(>) ;
  1708. X    RELOCATE $(<) ;
  1709. X}
  1710. X
  1711. Xactions CC
  1712. X{
  1713. X    $(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) $(>)
  1714. X}
  1715. X
  1716. Xactions quietly ignore RELOCATE
  1717. X{
  1718. X    [ $(<) != $(<:D=) ] && $(MV) $(<:D=) $(<)
  1719. X}
  1720. X
  1721. Xrule LEX
  1722. X{
  1723. X    DEPENDS $(<) : $(>) ;
  1724. X    LOCATE on $(<) = $(LOCATE_TARGET) ;
  1725. X}
  1726. X
  1727. Xactions LEX
  1728. X{
  1729. X    $(LEX) $(>) && $(MV) lex.yy.c $(<)
  1730. X}
  1731. X
  1732. Xrule YACC 
  1733. X{
  1734. X    h = $(<:BS=.h) ;
  1735. X
  1736. X    DEPENDS $(<) $(h) : $(>) ;
  1737. X    YACC1 $(<) $(h) : $(>) ;
  1738. X    # make sure someone includes $(h) else it will be
  1739. X    # a deadly independent target
  1740. X    INCLUDES $(<) : $(h) ;
  1741. X    LOCATE on $(<) $(h) = $(LOCATE_TARGET) ;
  1742. X}
  1743. X
  1744. Xactions YACC1
  1745. X{
  1746. X    $(YACC) $(>) &&
  1747. X    {
  1748. X        $(MV) y.tab.c $(<[1])
  1749. X        $(MV) y.tab.h $(<[2])
  1750. X    }
  1751. X}
  1752. X
  1753. Xrule YYACC
  1754. X{
  1755. X    DEPENDS $(<) $(<:B)tab.h : $(>) ;
  1756. X    YYACC1 $(<) $(<:B)tab.h : $(>) ;
  1757. X    LOCATE on $(<) $(<:B)tab.h = $(LOCATE_TARGET) ;
  1758. X}
  1759. X
  1760. Xactions YYACC1
  1761. X{
  1762. X    sh yyacc $(>) $(<)
  1763. X}
  1764. X
  1765. Xrule BULK 
  1766. X{
  1767. X    for i in $(>) 
  1768. X    { 
  1769. X        FILE $(i:D=$(<)) : $(i) ; 
  1770. X    }
  1771. X}
  1772. X
  1773. Xrule FILE
  1774. X{
  1775. X    DEPENDS files : $(<) ;
  1776. X    DEPENDS $(<) : $(>) ;
  1777. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  1778. X}
  1779. X
  1780. Xactions FILE
  1781. X{
  1782. X    cp $(>) $(<) &&
  1783. X    chmod $(FILEMODE) $(<)
  1784. X}
  1785. X
  1786. Xrule SHELL
  1787. X{
  1788. X    DEPENDS shell : $(<) ;
  1789. X    DEPENDS $(<) : $(>) ;
  1790. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  1791. X}
  1792. X
  1793. Xactions SHELL
  1794. X{
  1795. X    ( 
  1796. X    echo "$(SHELLHEADER)"
  1797. X    sed '/^: /d;/^##/d' $(>)
  1798. X    ) > $(<)
  1799. X    chmod $(SHELLMODE) $(<)
  1800. X}
  1801. X
  1802. Xrule RMTEMPS
  1803. X{
  1804. X    TEMPORARY $(>) ;
  1805. X}
  1806. X
  1807. Xactions quietly updated piecemeal RMTEMPS
  1808. X{
  1809. X    $(RM) $(>)
  1810. X}
  1811. X
  1812. Xrule INSTALLBIN
  1813. X{
  1814. X    for i in $(<)
  1815. X    {
  1816. X        INSTALL $(i:D=$(BINDIR)) : $(i) ;
  1817. X        INSTALLMODE on $(i:D=$(BINDIR)) = $(EXEMODE) ;
  1818. X    }
  1819. X}
  1820. X
  1821. Xrule INSTALLLIB
  1822. X{
  1823. X    for i in $(<) 
  1824. X    {
  1825. X        INSTALL $(i:D=$(LIBDIR)) : $(i) ;
  1826. X        INSTALLMODE on $(i:D=$(LIBDIR)) = $(FILEMODE) ;
  1827. X    }
  1828. X}
  1829. X
  1830. Xrule INSTALLMAN
  1831. X{
  1832. X    # Really this just strips the . from the suffix
  1833. X
  1834. X    for i in $(<)
  1835. X    {
  1836. X        switch $(i:S)
  1837. X        {
  1838. X        case .1 : S = 1 ; case .2 : S = 2 ; case .3 : S = 3 ; 
  1839. X        case .4 : S = 4 ; case .5 : S = 5 ; case .6 : S = 6 ; 
  1840. X        case .7 : S = 7 ; case .8 : S = 8 ; case .l : S = l ; 
  1841. X        case .n : S = n ; case .man : S = 1 ;
  1842. X        }
  1843. X
  1844. X        D = $(i:D=$(MANDIR)/man$(S):S=.$(S)) ;
  1845. X
  1846. X        INSTALL $(D) : $(i) ;
  1847. X        INSTALLMODE on $(D) = $(FILEMODE) ;
  1848. X    }
  1849. X}
  1850. X
  1851. Xrule INSTALL
  1852. X{
  1853. X    DEPENDS install : $(<) ;
  1854. X    DEPENDS $(<) : $(>) ;
  1855. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  1856. X}
  1857. X
  1858. Xactions INSTALL
  1859. X{
  1860. X    [ -d "$(<:D)" ] || mkdir $(<:D)
  1861. X    cp $(>) $(<) &&
  1862. X    chmod $(INSTALLMODE) $(<) 
  1863. X}
  1864. X
  1865. X#
  1866. X# Now include the Jamfile.
  1867. X# 
  1868. X
  1869. Xinclude $(JAMFILE) ;
  1870. SHAR_EOF
  1871. chmod 0444 Jambase ||
  1872. echo 'restore of Jambase failed'
  1873. Wc_c="`wc -c < 'Jambase'`"
  1874. test 9400 -eq "$Wc_c" ||
  1875.     echo 'Jambase: original size 9400, current size' "$Wc_c"
  1876. fi
  1877. # ============= Jambase.VMS ==============
  1878. if test -f 'Jambase.VMS' -a X"$1" != X"-c"; then
  1879.     echo 'x - skipping Jambase.VMS (File already exists)'
  1880. else
  1881. echo 'x - extracting Jambase.VMS (Text)'
  1882. sed 's/^X//' << 'SHAR_EOF' > 'Jambase.VMS' &&
  1883. X#
  1884. X# /+\
  1885. X# +\    Copyright 1993 Christopher Seiwald.
  1886. X# \+/
  1887. X#
  1888. X
  1889. X#
  1890. X# JAMBASE - jam ruleset providing make(1)-like functionality
  1891. X#
  1892. X
  1893. X# Rules defined by this file:
  1894. X#
  1895. X# MAIN image : source ;        link executable from compiled sources
  1896. X# LIBS image : libraries ;    bag libraries onto a MAIN
  1897. X# UNDEFINES image : symbols ;    save undef's for linking
  1898. X# SETUID image ;        mark an executable SETUID
  1899. X# LIBRARY lib : source ;    archive library from compiled sources
  1900. X# OBJECT objname : source ;    compile object from source
  1901. X# HDRRULE source : headers ;    handle #includes
  1902. X# CC obj.obj : source.c ;        .c -> .o
  1903. X# LEX source.c : source.l ;    .l -> .c
  1904. X# YACC source.c : source.y ;     .y -> .c
  1905. X# YYACC source.y : source.yy ;     .yy -> .y
  1906. X# BULK dir : files ;        populate directory with many files
  1907. X# FILE dest : source ;        copy file
  1908. X# SHELL exe : source ;        install a shell executable
  1909. X# RMTEMPS target : sources ;    remove temp sources after target made
  1910. X# INSTALLBIN sources ;        install binaries
  1911. X# INSTALLLIB sources ;        install files
  1912. X# INSTALLMAN source ;        install man pages
  1913. X#
  1914. X
  1915. X# Brief review of the jam language:
  1916. X#
  1917. X# Statements:
  1918. X#    rule RULE - statements to process a rule
  1919. X#    actions RULE - system commands to carry out target update
  1920. X#
  1921. X# Modifiers on actions:
  1922. X#    together - multiple instances of same rule on target get executed
  1923. X#           once with their sources ($(>)) concatenated
  1924. X#    updated - refers to updated sources ($(>)) only
  1925. X#    ignore - ignore return status of command
  1926. X#    quietly - don't trace its execution unless verbose
  1927. X#    piecemeal - iterate command each time with a small subset of $(>)
  1928. X#
  1929. X# Special rules:
  1930. X#    DEPENDS - builds the dependency graph
  1931. X#    ECHO - blurt out targets on stdout
  1932. X#    INCLUDES - marks sources as headers for target (a codependency)
  1933. X#    NOCARE - don't panic if the target can't be built
  1934. X#    NOTIME - ignore the timestamp of the target (it's not a file)
  1935. X#    TEMPORARY - target need not be present if sources haven't changed
  1936. X#
  1937. X# Special variables set by jam:
  1938. X#    $(<) - targets of a rule (to the left of the :)
  1939. X#    $(>) - sources of a rule (to the right of the :)
  1940. X#    $(UNIX) - true on UNIX
  1941. X#    $(VMS) - true on VMS
  1942. X#    $(OS) - name of OS - varies wildly
  1943. X#
  1944. X# Special variables used by jam:
  1945. X#    SEARCH - where to find something (used during binding and actions)
  1946. X#    LOCATE - where to plop something not found with SEARCH
  1947. X#    HDRRULE - rule to call to handle include files
  1948. X#    HDRSCAN - egrep regex to extract include files
  1949. X#
  1950. X# Special targets:
  1951. X#    all - default if none given on command line
  1952. X
  1953. X# Initialize variables
  1954. X
  1955. XAS        default = as ;
  1956. XBINDIR        default = sys$system ;
  1957. XCC        default = cc ;
  1958. XCCFLAGS        default = ;
  1959. XEXEMODE        default = (w:e) ;
  1960. XFILEMODE    default = (w:r) ;
  1961. XHDRS        default = ;
  1962. XLEX        default = lex ;
  1963. XLIBDIR        default = sys$library ;
  1964. XLINK        default = link ;
  1965. XLINKFLAGS    default = ;
  1966. XLINKLIBS    default = ;
  1967. XMV        default = rename ;
  1968. XOPTIM        default = ;
  1969. XSHELLMODE    default = (w:er) ;
  1970. XSTDHDRS        default = "" decc$library_include ;
  1971. XYACC        default = yacc -d ;
  1972. XJAMFILE        default = Jamfile ;
  1973. X
  1974. XHDRPATTERN = "^#[     ]*include[     ]*[<\"](.*)[\">].*$" ;
  1975. X
  1976. X#
  1977. X# OS specific variable settings
  1978. X#
  1979. X
  1980. Xswitch $(OS) 
  1981. X{
  1982. Xcase OPENVMS : CCFLAGS default = /stand=vaxc ;
  1983. Xcase VMS     : LINKLIBS default = sys$library:vaxcrtl.olb/lib ;
  1984. X}
  1985. X
  1986. X#
  1987. X# Base dependencies - first for "bootstrap" kinds of rules
  1988. X#
  1989. X
  1990. XDEPENDS all : first shell files lib exe ;
  1991. XNOTIME all first shell files lib exe ;
  1992. X
  1993. X#
  1994. X# The rules
  1995. X#
  1996. X
  1997. Xrule MAIN 
  1998. X{
  1999. X    # make compiled sources a dependency of target
  2000. X
  2001. X    DEPENDS exe : $(<:S=.exe) ;
  2002. X    DEPENDS    $(<:S=.exe) : $(>:S=.obj) ;
  2003. X    LOCATE on $(<) = $(LOCATE_TARGET) ;
  2004. X
  2005. X    LINK $(<:S=.exe) : $(>:S=.obj) ;
  2006. X
  2007. X    # each object gets compiled from sources
  2008. X
  2009. X    for i in $(>) 
  2010. X    { 
  2011. X        OBJECT $(i:S=.obj) : $(i) ;
  2012. X    }
  2013. X}
  2014. X
  2015. Xactions LINK 
  2016. X{
  2017. X    $(LINK)/exe=$(<) $(LINKFLAGS) $(>[1]) ,$(>[2-]) ,$(NEEDLIBS)/lib ,$(LINKLIBS)
  2018. X    set file/prot=$(EXEMODE) $(<)
  2019. X}
  2020. X
  2021. Xrule LIBS 
  2022. X{
  2023. X    # make library dependencies of target
  2024. X    # set NEEDLIBS variable used by 'actions MAIN'
  2025. X
  2026. X    DEPENDS $(<:S=.exe) : $(>) ;
  2027. X    NEEDLIBS on $(<:S=.exe) = $(>) ;
  2028. X}
  2029. X
  2030. Xrule UNDEFINES
  2031. X{
  2032. X    # don't know this one
  2033. X}
  2034. X
  2035. Xrule SETUID
  2036. X{
  2037. X    ECHO "Can't set" $(<) "setuid on VMS." ;
  2038. X}
  2039. X
  2040. Xrule LIBRARY 
  2041. X{
  2042. X    # library depends on its member objects
  2043. X
  2044. X    DEPENDS lib : $(<) ;
  2045. X    DEPENDS $(<) : $(<)($(>:BS=.obj)) ;
  2046. X
  2047. X    # We wish we could locate the library and it's contents,
  2048. X    # but the reference to $(NEEDLIBS) in MAIN's actions
  2049. X    # get the unbound names.  Only $(<) and $(>) refer to
  2050. X    # bound file name in rule actions.  Sigh.
  2051. X    # 
  2052. X    # LOCATE on $(<) $(<)($(>:BS=.obj)) = $(LOCATE_TARGET) ;
  2053. X
  2054. X    # each archive member object depends on real object
  2055. X    # each real object gets compiled from sources
  2056. X
  2057. X    for i in $(>) 
  2058. X    {
  2059. X        DEPENDS $(<)($(i:BS=.obj)) : $(i:S=.obj) ; 
  2060. X        OBJECT $(i:S=.obj) : $(i) ;
  2061. X    }
  2062. X
  2063. X    # must call separate ARCHIVE rule so that 'updated' modifier
  2064. X    # on 'actions' refers to updated .obj's.
  2065. X
  2066. X    LIBCREATE $(<) ;
  2067. X    ARCHIVE $(<) : $(>:S=.obj) ;
  2068. X    RMTEMPS $(<) : $(>:S=.obj) ;
  2069. X}
  2070. X
  2071. Xactions together quietly LIBCREATE
  2072. X{
  2073. X       if f$search("$(<)") .eqs. "" then lib/create $(<)
  2074. X}
  2075. X
  2076. Xactions updated together piecemeal ARCHIVE 
  2077. X{
  2078. X    lib/replace $(<) $(>[1]) ,$(>[2-])
  2079. X}
  2080. X
  2081. Xrule OBJECT 
  2082. X{
  2083. X    # locate object and search for source, if wanted
  2084. X
  2085. X    LOCATE on $(<) = $(LOCATE_TARGET) ;
  2086. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  2087. X
  2088. X    # Save HDRS for -I$(HDRS) on compile.
  2089. X    # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers 
  2090. X    # in the .c file's directory, but generated .c files (from 
  2091. X    # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly 
  2092. X    # different from $(SEARCH_SOURCE).
  2093. X
  2094. X    HDRS on $(<) = $(HDRS) $(SEARCH_SOURCE) ;
  2095. X
  2096. X    # handle #includes for source: Jam scans for headers with
  2097. X    # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
  2098. X    # with the scanned file as the target and the found headers
  2099. X    # as the sources.  HDRSEARCH is just grist for HDRRULE.
  2100. X
  2101. X    HDRRULE on $(>) = HDRRULE ;
  2102. X    HDRSCAN on $(>) = $(HDRPATTERN) ;
  2103. X    HDRSEARCH on $(>) = $(HDRS) $(STDHDRS) $(SEARCH_SOURCE) ;
  2104. X
  2105. X    # if source is not .c, generate .c with specific rule
  2106. X
  2107. X    switch $(>:S)
  2108. X    {
  2109. X        case .c :     CC $(<) : $(>) ;
  2110. X        case .l :    CC $(<) : $(<:S=.c) ;
  2111. X            LEX $(<:S=.c) : $(>) ;
  2112. X        case .y :     CC $(<) : $(<:S=.c) ; 
  2113. X            YACC $(<:S=.c) : $(>) ;
  2114. X        case .yy :     CC $(<) : $(<:S=.c) ; 
  2115. X            YACC $(<:S=.c) : $(<:S=.y) ;
  2116. X            YYACC $(<:S=.y) : $(>) ;
  2117. X        case * :    CCUSER $(<) : $(>) ;
  2118. X    }
  2119. X}
  2120. X
  2121. Xrule CC
  2122. X{
  2123. X    if $(HDRS[1])
  2124. X    {
  2125. X        SLASHINC on $(<) = "/inc=(" $(HDRS[1]) ,$(HDRS[2-]) ")" ;
  2126. X    }
  2127. X    DEPENDS $(<) : $(>) ;
  2128. X}
  2129. X
  2130. Xactions CC
  2131. X{ 
  2132. X    cc/obj=$(<) $(CCFLAGS) $(OPTIM) $(SLASHINC) $(>) 
  2133. X}
  2134. X
  2135. Xrule HDRRULE
  2136. X{
  2137. X    # HDRRULE source : headers ;
  2138. X
  2139. X    # N.B.  This rule is called during binding, potentially after 
  2140. X    # the fate of many targets has been determined, and must be 
  2141. X    # used with caution: don't add dependencies to unrelated 
  2142. X    # targets, and don't set variables on $(<).
  2143. X
  2144. X    # Tell Jam that anything depending on $(<) also depends on $(>), 
  2145. X    # set SEARCH so Jam can find the headers, but then say we don't
  2146. X    # care if we can't actually find the headers (they may have been 
  2147. X    # within ifdefs), 
  2148. X
  2149. X    INCLUDES $(<) : $(>) ;
  2150. X    SEARCH on $(>) = $(HDRSEARCH) ;
  2151. X    NOCARE $(>) ;
  2152. X
  2153. X    # Propagate on $(<) to $(>)
  2154. X
  2155. X    HDRSEARCH on $(>) = $(HDRSEARCH) ;
  2156. X    HDRSCAN on $(>) = $(HDRSCAN) ;
  2157. X    HDRRULE on $(>) = $(HDRRULE) ;
  2158. X}
  2159. X
  2160. Xrule LEX
  2161. X{
  2162. X    DEPENDS $(<) : $(>) ;
  2163. X    LOCATE on $(<) = $(LOCATE_TARGET) ;
  2164. X}
  2165. X
  2166. Xactions LEX
  2167. X{
  2168. X    $(LEX) $(>) 
  2169. X    $(MV) lex.yy.c $(<)
  2170. X}
  2171. X
  2172. Xrule YACC 
  2173. X{
  2174. X    h = $(<:BS=.h) ;
  2175. X
  2176. X    # no yacc on VMS (yet)
  2177. X    # DEPENDS $(<) $(h) : $(>) ;
  2178. X    # YACC1 $(<) $(h) : $(>) ;
  2179. X    # make sure someone includes $(h) else it will be
  2180. X    # a deadly independent target
  2181. X    INCLUDES $(<) : $(h) ;
  2182. X    LOCATE on $(<) $(h) = $(LOCATE_TARGET) ;
  2183. X}    
  2184. X
  2185. Xactions YACC1
  2186. X{
  2187. X    $(YACC) $(>)
  2188. X    $(MV) y.tab.c $(<[1])
  2189. X    $(MV) y.tab.h $(<[2])
  2190. X}
  2191. X
  2192. Xrule YYACC
  2193. X{
  2194. X    # no yyacc on VMS (yet)
  2195. X    # DEPENDS $(<) $(<:B)tab.h : $(>) ;
  2196. X    # YYACC1 $(<) $(<:B)tab.h : $(>) ;
  2197. X    LOCATE on $(<) $(<:B)tab.h = $(LOCATE_TARGET) ;
  2198. X}
  2199. X
  2200. Xactions YYACC1
  2201. X{
  2202. X    ! sh yyacc $(>)
  2203. X}
  2204. X
  2205. Xrule BULK 
  2206. X{
  2207. X    for i in $(>) 
  2208. X    { 
  2209. X        FILE $(i:D=$(<)) : $(i) ; 
  2210. X    }
  2211. X}
  2212. X
  2213. Xrule FILE
  2214. X{
  2215. X    DEPENDS files : $(<) ;
  2216. X    DEPENDS $(<) : $(>) ;
  2217. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  2218. X}
  2219. X
  2220. Xactions FILE
  2221. X{
  2222. X    copy $(>) $(<)
  2223. X    set file/prot=$(FILEMODE) $(<)
  2224. X}
  2225. X
  2226. Xrule SHELL
  2227. X{
  2228. X    DEPENDS shell : $(<) ;
  2229. X    DEPENDS $(<) : $(>) ;
  2230. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  2231. X}
  2232. X
  2233. Xactions SHELL
  2234. X{
  2235. X    copy $(>) $(<)
  2236. X    set file/prot=$(SHELLMODE) $(<)
  2237. X}
  2238. X
  2239. Xrule RMTEMPS
  2240. X{
  2241. X    TEMPORARY $(>) ;
  2242. X}
  2243. X
  2244. Xactions quietly updated piecemeal RMTEMPS
  2245. X{
  2246. X    delete $(>[1]);* ,$(>[2-]);*
  2247. X}
  2248. X
  2249. Xrule INSTALLBIN
  2250. X{
  2251. X    for i in $(<)
  2252. X    {
  2253. X        INSTALL $(i:D=$(BINDIR)) : $(i) ;
  2254. X        INSTALLMODE on $(i:D=$(BINDIR)) = $(EXEMODE) ;
  2255. X    }
  2256. X}
  2257. X
  2258. Xrule INSTALLLIB
  2259. X{
  2260. X    for i in $(<) 
  2261. X    {
  2262. X        INSTALL $(i:D=$(LIBDIR)) : $(i) ;
  2263. X        INSTALLMODE on $(i:D=$(LIBDIR)) = $(FILEMODE) ;
  2264. X    }
  2265. X}
  2266. X
  2267. Xrule INSTALLMAN
  2268. X{
  2269. X    ECHO "can't install manual pages" $(<) "on VMS." ;
  2270. X}
  2271. X
  2272. Xrule INSTALL
  2273. X{
  2274. X    DEPENDS install : $(<) ;
  2275. X    DEPENDS $(<) : $(>) ;
  2276. X    SEARCH on $(>) = $(SEARCH_SOURCE) ;
  2277. X}
  2278. X
  2279. Xactions INSTALL
  2280. X{
  2281. X    copy $(>) $(<)
  2282. X    set file/prot=$(INSTALLMODE) $(<)
  2283. X}
  2284. X
  2285. X#
  2286. X# Now include the Jamfile.
  2287. X# 
  2288. X
  2289. Xinclude $(JAMFILE) ;
  2290. SHAR_EOF
  2291. chmod 0444 Jambase.VMS ||
  2292. echo 'restore of Jambase.VMS failed'
  2293. Wc_c="`wc -c < 'Jambase.VMS'`"
  2294. test 8788 -eq "$Wc_c" ||
  2295.     echo 'Jambase.VMS: original size 8788, current size' "$Wc_c"
  2296. fi
  2297. # ============= Jamfile ==============
  2298. if test -f 'Jamfile' -a X"$1" != X"-c"; then
  2299.     echo 'x - skipping Jamfile (File already exists)'
  2300. else
  2301. echo 'x - extracting Jamfile (Text)'
  2302. sed 's/^X//' << 'SHAR_EOF' > 'Jamfile' &&
  2303. X#
  2304. X# Jamfile for Jam
  2305. X#
  2306. X
  2307. Xif $(VMS)    
  2308. X{ 
  2309. X    JAMLIB = libjam.olb ; 
  2310. X    OSFILES = execvms.c filevms.c ; 
  2311. X}
  2312. X
  2313. Xif $(UNIX)    
  2314. X{ 
  2315. X    JAMLIB = libjam.a ; 
  2316. X    OSFILES = execunix.c fileunix.c ;
  2317. X
  2318. X    LIBDIR = /usr/local/lib/jam ;
  2319. X
  2320. X    INSTALLMAN jam.1 Jambase.5 ;
  2321. X    INSTALLBIN jam ;
  2322. X
  2323. X    INSTALLLIB Jambase ;
  2324. X
  2325. X}
  2326. X
  2327. XMAIN         jam : jam.c ;
  2328. XLIBS         jam : $(JAMLIB) ;
  2329. X
  2330. XLIBRARY         $(JAMLIB) : compile.c expand.c hash.c lists.c make.c 
  2331. X            newstr.c option.c parse.c rules.c scan.c search.c 
  2332. X            timestamp.c variable.c jamgram.yy headers.c regexp.c 
  2333. X            $(OSFILES) ;
  2334. X
  2335. SHAR_EOF
  2336. chmod 0444 Jamfile ||
  2337. echo 'restore of Jamfile failed'
  2338. Wc_c="`wc -c < 'Jamfile'`"
  2339. test 532 -eq "$Wc_c" ||
  2340.     echo 'Jamfile: original size 532, current size' "$Wc_c"
  2341. fi
  2342. true || echo 'restore of compile.c failed'
  2343. echo End of part 1, continue with part 2
  2344. exit 0
  2345.