home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3.4.17 [SPARC, PA-RISC] / nextstep33_risc.iso / NextLibrary / TeX / tex / src / dvips / vmcms / mkdvips.exec < prev    next >
Encoding:
Text File  |  1992-11-14  |  17.1 KB  |  522 lines

  1. /* MKDVIPS exec: a make-like utility for DVIPS on VM/CMS.         */
  2. /* This is version 2.0 as of 10 Nov. 1992.                        */
  3. /* Written by Jim Hafner (hafner@almaden.ibm.com).                */
  4. /*                                                                */
  5. /* Command is:                                                    */
  6. /*     mkdvips options                                            */
  7. /* where options includes any or all of the following keywords:   */
  8. /*     DVIPS HEADERS AFM2TFM CLEAN ALL ?                          */
  9. /* The '?" option displays this header.  Any of the first three   */
  10. /* will cause only that part of the installation/compilation to   */
  11. /* be done.  'CLEAN' removes all the TEXT and LOAD MAP files      */
  12. /* after everthing is complete.  Finally, 'ALL' is equivalent to  */
  13. /* specifying the first four options together.                    */
  14. /*                                                                */
  15. /* There are more comments in the exec itself that might be of    */
  16. /* interest to installers.                                        */
  17.  
  18. /* END OF HEADER (this line must be preceded by a blank line) */
  19.  
  20. /*
  21.  * This is part of the VM/CMS distribution of Rokicki's DVIPS program.
  22.  * Installers may need to customize this exec extensively, though we
  23.  * have tried to make it as generic as possible.
  24.  *
  25.  * You are welcome to modify this exec in any way you choose.
  26.  *
  27.  * ************* SITE DEPENDENCIES************************************
  28.  * This EXEC is designed for the C/370 compiler.  It surely NOT work
  29.  * without revision with other compilers like Waterloo C.  Changes
  30.  * will probably be required in the sections where the compiler
  31.  * environments are set up, in the 'compile' procedure, in the 'makemod'
  32.  * procedure, in the system dependent defines (SYSDEFS) and in
  33.  * the compiler option flags (OPT).
  34.  * ****** End of SITE DEPENDENCIES************************************
  35.  *
  36.  *  11/10/92.  Significantly revised to make it easier to maintain
  37.  *  and update with new source files and to be a little snazzier.
  38.  *  -- Any new .c files should be added to the SRC list.
  39.  *  -- Any new .pro (target) files should be added to the HEADERS list.
  40.  *
  41.  *  -- Now, all source files are compiled by scanning a list and calling
  42.  *     a procedure for each name in the list. Similarly for header files.
  43.  *     Also, we get return codes from each call to CC and CMOD so that
  44.  *     we can exit early if there are any problems.
  45.  *
  46.  *  -- We've also rearranged the DEFS a little more logically.  There is
  47.  *     one DEF for each of the system independent stuff like 'specials'
  48.  *     (all the TeX installation dependencies) and one for ALL the
  49.  *     system dependent stuff.
  50.  *
  51.  *  -- There are some places in this code that are site dependent.  We
  52.  *     have tried to label them with SITE DEPENDENCIES, to help you
  53.  *     find them and adjust them for your system.
  54.  *
  55.  *  -- For fun, we added some command line options to this exec to allow
  56.  *     users to compile only DVIPS, only AFM2TFM, only the header files,
  57.  *     all of them or combinations.  In this way, if parts of the
  58.  *     installation work OK, you don't need to repeat the successes
  59.  *     for the other parts OR have to hack at this exec to comment out
  60.  *     the irrelevant parts.
  61.  *     The recognized command line keywords are
  62.  *        DVIPS HEADERS AFM2TFM CLEAN ALL ?
  63.  *     Specifying no keywords is the same as DVIPS HEADERS AFM2TFM.
  64.  *     Specifying CLEAN removes all the * TEXT  and * MAP files and
  65.  *     can be used with any other keywords.
  66.  *     Specifying ALL does all four operations.
  67.  *     Specifying ? calls the help utility.
  68.  *
  69.  *  -- To get even more fancy, this exec now tries to simulate the
  70.  *     Unix 'make' utility.  It compares the time stamp of the TEXT
  71.  *     files with that of the C file and ALL H files and only calls
  72.  *     the compiler if TEXT is older.  We hope the algorithms are
  73.  *     robust enough and will make recompiling and tweaking easier.
  74.  *     (We only do this with the compile operation, not with the
  75.  *     CMOD or SQUEEZE operations for simplicity.)
  76.  *     See the comments below on 'SITE DEPENDENCIES -- H FILES' for
  77.  *     more information.
  78.  *
  79.  * THANKS:
  80.  *   We gratefully acknowledge the help, suggestions and testing done by
  81.  *   all the others who have contributed to the VM/CMS port.  Most
  82.  *   notably, are Ronald Kappert (R.Kappert@uci.kun.nl), Alessio
  83.  *   Guglielmi (ALESSIO@IPISNSIB.BITNET) and Michel Goossens
  84.  *   (goossens@cernvm.cern.ch).
  85.  */
  86.  
  87. address 'COMMAND'
  88.  
  89. /* initialize the booleans for command line selections */
  90. dodvips = 0 ; doheaders = 0 ; doafm2tfm = 0 ; doclean = 0 ;
  91.  
  92.  
  93. /* ************* SITE DEPENDENCIES -- H FILES ***********************
  94.    we are going to search for the newest of all the H files around.
  95.    so we can use that date to compare against TEXT files for a need
  96.    to recompile.   We default to '*' in case you have the DVIPS
  97.    H files on two separate disks (e.g., you keep the originals on
  98.    your B-disk and only the ones you change on your A-disk as I
  99.    do when I'm testing or having to make lots of changes.  This
  100.    default will perhaps mean very extensive searching for newest
  101.    H file.  If you have all your DVIPS H files on one disk to stay,
  102.    then you can change the default to that disk letter.
  103.    ****** End of SITE DEPENDENCIES -- H FILES ***********************/
  104. HfileMode = '*'
  105.  
  106. /* We grab the command line: */
  107. parse upper arg args
  108. if 'WORDS'(args) == 0 then do
  109.       dodvips = 1 ;
  110.       doheaders = 1 ;
  111.       doafm2tfm = 1 ;
  112.       end ;
  113. else do i = 1 to 'WORDS'(args)
  114. select ;
  115.    when 'WORD'(args,i) == "ALL" then do
  116.       dodvips = 1 ;
  117.       doheaders = 1 ;
  118.       doafm2tfm = 1 ;
  119.       doclean = 1 ;
  120.       end ;
  121.    when 'WORD'(args,i) == "DVIPS" then do
  122.       dodvips = 1 ;
  123.       end ;
  124.    when 'WORD'(args,i) == "HEADERS" then do
  125.       doheaders = 1 ;
  126.       end ;
  127.    when 'WORD'(args,i) == "AFM2TFM" then do
  128.       doafm2tfm = 1 ;
  129.       end ;
  130.    when 'WORD'(args,i) == "CLEAN" then do
  131.       doclean = 1 ;
  132.       end ;
  133.    when 'WORD'(args,i) == "?" then do
  134.       call show_header ;
  135.       end ;
  136.    otherwise do
  137. say "Command option "'WORD'(args,i)" not recognized and will be ignored."
  138.       end ;
  139.    end ;
  140. end i
  141.  
  142. /* check that there is still something to do */
  143. if dodvips + doheaders + doafm2tfm + doclean == 0 then do
  144.    say "You didn't specify (correctly) any legitimate keyword." ;
  145.    say "Please try again." ;
  146.    exit ;
  147.    end ;
  148.  
  149.  
  150. /*
  151.  * If you DON'T want EMTEX specials, define the following.
  152.  * EMTEX = " "
  153.  */
  154. EMTEX = "DEF(EMTEX)"
  155.  
  156. /*
  157.  * If you DON'T want TPIC specials, define the following.
  158.  * TPIC = " "
  159.  */
  160. TPIC = "DEF(TPIC)"
  161.  
  162. /*
  163.  * the default paper format, if other than letter. Not sure about syntax.
  164.  * DEFPFMT = 'DEFPFMT=\"a4\"'
  165.  * (This flag no longer needed.)
  166. */
  167. /* DEFPFMT = ' ' */
  168.  
  169. /*
  170.  * set the default resolution with the command below, appropriately.
  171. */
  172. DEFRES = "DEF(DEFRES=300)"
  173.  
  174. /*
  175.  * set this if you want DVIPS's debugging capability
  176.  */
  177. DEBUG = "DEF(DEBUG)"
  178.  
  179. /* Collect all the TeX/dvips installation dependencies together */
  180. TEXDEFS = EMTEX TPIC DEFRES DEBUG
  181.  
  182. /*
  183.  * Next we build up the PATHS, these are all null of course, but
  184.  * they are needed in 5.472+ since paths.h doesn't predefine them
  185.  * anymore
  186. */
  187. TFMPATH = 'TFMPATH=\" \" '
  188. PKPATH = 'PKPATH=\" \" '
  189. VFPATH = 'VFPATH=\" \" '
  190. FIGPATH = 'FIGPATH=\" \" '
  191. HEADERPATH = 'HEADERPATH=\" \" '
  192. CONFIGPATH = 'CONFIGPATH=\" \" '
  193. PATHS = "DEF("TFMPATH", "PKPATH", "VFPATH", "FIGPATH", "HEADERPATH",
  194.    "CONFIGPATH")"
  195.  
  196. /* Add a default configuration file */
  197. CONFIGFILE = 'DEF(CONFIGFILE=\"CONFIG.PS\")'
  198.  
  199.  
  200. /*
  201.  * ************* SITE DEPENDENCIES************************************
  202.  * These are for system dependent DEFs.
  203.  * You must use VMCMS for this operating system.
  204.  * You must use SYSV and IGNORE_CWD for C/370 (don't know about
  205.  * Waterloo C).
  206. */
  207. SYSDEFS = "DEF(VMCMS, SYSV, IGNORE_CWD)"
  208.  
  209. /*
  210.  * Use OPT for compiler instructions.
  211.  * For C/370, FLAG(W) suppresses the warnings with RC>=4;
  212.  * OPT can include tags for optimizing the code or LONGNAME if you have
  213.  * version 2.1 or later, e.g.,
  214.  *  OPT = "FLAG(W) LONGNAME INLINE OPTIMIZE(2)"
  215.  */
  216. OPT = "FLAG(W)"
  217. /******** End of SITE DEPENDENCIES ************************************/
  218.  
  219. CFLAGS = SYSDEFS OPT TEXDEFS PATHS CONFIGFILE
  220.  
  221. /*
  222.  * Here is a list of all the source files that need to be compiled.
  223.  * All .c files that are part of DVIPS itself should be listed here.
  224.  * Do NOT include SQUEEZE or AFM2TFM!
  225.  */
  226.  
  227. SRC = "dospecial.c dviinput.c fontdef.c loadfont.c dvips.c tfmload.c" ,
  228.     "download.c prescan.c scanpage.c skippage.c output.c scalewidth.c",
  229.     "dosection.c dopage.c resident.c search.c unpack.c drawPS.c",
  230.     "header.c makefont.c repack.c virtualfont.c dpicheck.c finclude.c",
  231.     "flib.c color.c papersiz.c pprescan.c bbox.c emspecial.c"
  232.  
  233. /*
  234.  * Here is the list of all the TARGET prologue files that need to
  235.  * be generated.  This should include TEXC even though TEXC.LPRO
  236.  * is built during the running of this exec.
  237.  */
  238.  
  239. HEADERS = "tex texc texps special finclude color crop"
  240.  
  241.  
  242. /*
  243.  * Here we build the listof object files and load files from SRC.
  244.  * we don't need OBJ list of *.text files so we comment out that
  245.  * part of the code, in case it might be needed at a later time.
  246.  */
  247. OBJ = "" ; CMODOBJ = ""
  248.  
  249. do i = 1 to 'WORDS'(SRC)
  250.    fullfilename = 'STRIP'('WORD'(SRC,i))
  251.    filename = 'STRIP'('STRIP'(fullfilename,T,'c'),T,'.')
  252.    upper filename
  253. /* OBJ = OBJ filename".text" */
  254.    if "DVIPS" ^= 'STRIP'(filename) then  /* we don't include DVIPS! */
  255.       CMODOBJ = CMODOBJ filename ;
  256.    end i
  257.  
  258. /*
  259.  * Now we get the time stamp for the most recent H file.  See the
  260.  * comments above (near the line about 'HfileMode' for more information.
  261.  * 'checkHfiles' computes the time stamp for the most recent H file,
  262.  * on the assumption that if one of these is newer than any TEXT file,
  263.  * then we will need to recompile everything.
  264.  */
  265. call checkHfiles
  266. /*
  267.  * now that all the flags are set, we invoke the compiler on every
  268.  * .c file and then do the final linking for the DVIPS.MODULE,
  269.  * provided we were requested to do so at the beginning.
  270.  * We do this by parsing the words in the string CMODOBJ.
  271.  */
  272.  
  273. /*
  274.  *************** SITE DEPENDENCIES************************************
  275.  * Now we finally access all the necessary disks and libraries.
  276.  * YOU WILL NEED TO CUSTOMIZE THIS FOR YOUR SITE, PARTICULARLY THE 'GIME'
  277.  * LINES TO ACCESS THE C/370 PROGRAMS.
  278.  * (Commented commands are optional (I think).
  279.  */
  280. 'EXEC GIME PRODUCT 387'
  281. /* now reset libraries, saving the current library state also */
  282.  
  283. call resetLibs
  284.  
  285. /* 'SET CMSTYPE HT' */
  286. 'FILEDEF EDC DISK EDCLINK LOADLIB *(PERM'
  287. /* 'NUCXDROP EDCXV'
  288.    'NUCXDROP EDCX24' */
  289. 'NUCXLOAD EDCXV EDCXV EDC(SYSTEM'
  290. 'NUCXLOAD EDCX24 EDCX24 EDC(SYSTEM'
  291. /* 'SET CMSTYPE RT' */
  292. /******* End of SITE DEPENDENCIES*************************************/
  293.  
  294. if dodvips == 1 then do
  295.    call compile dvips  ;   /* we have to do this separate since it's
  296.                               not part of CMODOBJ */
  297.    do i = 1 to 'WORDS'(CMODOBJ)
  298.       filename = 'WORD'(CMODOBJ,i) ;
  299.       call compile filename ;
  300.       end i ;
  301.    call makemod dvips CMODOBJ /* Link Time, if compiling worked OK */
  302. end /* dodvips */
  303.  
  304. /* build the SQUEEZE MODULE */
  305. if doheaders == 1 then do
  306.    call compile squeeze  ;
  307.    call makemod squeeze  ;
  308. /*
  309.  * Time to build the header files.
  310.  * First we build TEXC.LPRO and then run the list of headers
  311.  */
  312.    say "EXEC TEXC TEX.LPRO TEXC.LPRO" ;
  313.        "EXEC TEXC TEX.LPRO TEXC.LPRO" ;
  314.    do i = 1 to 'WORDS'(HEADERS)
  315.        filename = 'STRIP'(WORD(HEADERS,i)) ;
  316.        call dosqueeze filename ;
  317.        end i
  318. end /* doheaders */
  319.  
  320. /* Time to build the AFM2TFM program */
  321. if doafm2tfm == 1 then do
  322.    call compile afm2tfm ;
  323.    call makemod afm2tfm ;
  324. end /* doafm2tfm */
  325.  
  326. /*
  327.  * If we got this far, (and did something) then everything went
  328.  * well and we can quit.
  329.  */
  330.  
  331. if dodvips + doheaders + doafm2tfm > 0 then do
  332.    say " " ;
  333.    say "If you didn't get any compiler errors, then";
  334.    say "I've completed creating all the necessary files and modules." ;
  335.    say "You should check that the EXEC's supplied with the package run" ;
  336.    say "correctly on your machine." ;
  337. end
  338.  
  339. if doclean == 1 then do
  340.    say "Will now clean up * TEXT and LOAD MAP files as requested."
  341.    "ERASE * TEXT" ;
  342.    "ERASE LOAD MAP" ;
  343.    end ;
  344.  
  345. /* restore original library settings before exiting */
  346. call restoreLibs ;
  347. exit 0
  348.  
  349. /* here are the procedures that we use */
  350.  
  351. compile:
  352.    arg filename
  353. /* do a check to see if this needs to be recompiled (i.e., if time stamp
  354.    on C file or any H file is newer than existing TEXT file */
  355.    do_newer = checknewer(filename)
  356.    if do_newer = 1 then do
  357.       say " "
  358.       say "EXEC CC "filename" ("CFLAGS ;
  359.           "EXEC CC "filename" ("CFLAGS ;
  360.       ccrc = rc
  361.       if ccrc > 4  then do  /* exit if compiler complained too much */
  362.          say "Compiler failed on file "filename"." ;
  363.          call restoreLibs ; /* restore original libraries before exit */
  364.          exit(ccrc) ;
  365.          end ;
  366.       end ;
  367.    return ;
  368.  
  369.  
  370. makemod: procedure
  371.    arg modname objects
  372.    say " "
  373.    say "EXEC CMOD "modname objects ;
  374.        "EXEC CMOD "modname objects ;
  375. /* check return code from CMOD and exit if not zero */
  376.    cmodrc = rc ;
  377.    if cmodrc ^= 0 then do
  378.       say " " ;
  379.       say "LOAD and/or GENMOD failed generating the "modname" MODULE." ;
  380.       say "Quiting until you can resolve the problems." ;
  381.       call restoreLibs ; /* restore original libraries before exit */
  382.       exit(cmodrc) ;
  383.       end ;
  384.     return ;
  385.  
  386. dosqueeze: procedure
  387.     arg filename
  388.     say " "
  389.     say "SQUEEZE "filename".LPRO "filename".PRO" ;
  390.         "SQUEEZE "filename".LPRO "filename".PRO" ;
  391.     return ;
  392.  
  393. checknewer:
  394.     upper arg filename
  395.     do_newer = 0
  396. /* get time stamp for C file */
  397.     call getTimeStamp filename 'C'
  398.     c_date = file_date
  399.     c_time = file_time
  400. /* get time stamp for TEXT file */
  401.     call getTimeStamp filename 'TEXT'
  402.     text_date = file_date
  403.     text_time = file_time
  404. /* check time stamp of C file against time stamp of TEXT file */
  405.     if c_date > text_date then do_newer = 1
  406.     else if ( c_date = text_date & c_time > text_time ) then do_newer = 1
  407. /* check time stamp of all H files against time stamp of TEXT file */
  408.     if h_date > text_date then do_newer = 1
  409.     else if ( h_date = text_date & h_time > text_time ) then do_newer = 1
  410. /* return value 1 if C or H is newer */
  411.     return do_newer
  412.  
  413. getTimeStamp: procedure expose file_date file_time
  414.    arg fn ft
  415.    'STATE' fn ft '*'
  416.    if  rc ^= 0 then
  417.       if ( ft = 'TEXT' ) then do
  418.         file_date = 0
  419.         file_time = 0
  420.         return
  421.         end
  422.       else do
  423.         file_date = 999999
  424.         file_time = 999999
  425.         return
  426.       end
  427.    'MAKEBUF'
  428.    'LISTFILE' fn ft '* (NOHEADER DATE STACK'
  429.    pull fn ft fm . . . . file_date file_time .
  430.    parse var file_date file_month'/'file_day'/'file_year
  431.    parse var file_time file_hour':'file_minute':'file_second
  432.    if file_month < 10 then file_month = '0'||file_month
  433.    file_date = file_year||file_month||file_day
  434.    file_time = file_hour||file_minute||file_second
  435.    'DROPBUF'
  436.    return
  437.  
  438.  
  439. checkHfiles: procedure expose h_date h_time HfileMode
  440.    maxH_date = 0
  441.    maxH_time = 0
  442.    'MAKEBUF'
  443. /***************** SITE DEPENDENCIES -- H FILES ************************
  444.    We search ALL H files everywhere since it could be that the
  445.    files in the DVIPS package live on different disks.  We
  446.    hope this is still fast enough, particularly since it is
  447.    only called once.  Besides, it is unlikely that the H files
  448.    for other NON-DVIPS programs will get changed during the compiling
  449.    and building of DVIPS
  450.  *
  451.    If you have all your H files for DVIPS on a single disk (even
  452.    the ones you might have a need to edit) then you can change
  453.    the value of HfileMode at the beginning of this exec.
  454.  ********* End of SITE DEPENDENCIES -- H FILES ************************/
  455.    'LISTFILE * H' HfileMode '(NOHEADER DATE STACK'
  456.    if rc ^= 0 then do
  457.       say "Couldn't find any H files!  Are the right disks accessed?"
  458.       say "I'll exit until you can figure this out."
  459.       exit 200
  460.       end
  461.    cnt=queued()
  462.    do i = 1 to cnt
  463.    pull fn ft fm . . . . f_date f_time .
  464.    parse var f_date f_month'/'f_day'/'f_year
  465.    parse var f_time f_hour':'f_minute':'f_second
  466.    if f_month < 10 then f_month='0'||f_month
  467.    f_date = f_year||f_month||f_day
  468.    f_time = f_hour||f_minute||f_second
  469.    if f_date > maxH_date then do
  470.       maxH_date = f_date
  471.       maxH_time = f_time
  472.       end
  473.    else if ( f_date = maxH_date & f_time > maxH_time ) then do
  474.       maxH_date = f_date
  475.       maxH_time = f_time
  476.       end
  477.    end
  478.    'DROPBUF'
  479.    h_date = maxH_date
  480.    h_time = maxH_time
  481.    return
  482.  
  483.  
  484. Savelibs: procedure
  485.    arg library
  486.    'MAKEBUF';
  487.    tmplibs = ''
  488.    'QUERY' library '(STACK'
  489.    do i = 1 to queued()
  490.      pull Mode Eq_sign Tmptmplibs
  491.      if Tmptmplibs = 'NONE' then tmplibs = ''
  492.         else tmplibs = tmplibs Tmptmplibs
  493.    end;
  494.    'DROPBUF';
  495.    return tmplibs  ;
  496.  
  497. resetLibs:
  498.    /* get current status of library settings */
  499.    Txtlibs=Savelibs(TXTLIB)
  500.    Loadlibs=Savelibs(LOADLIB)
  501.    /* Establish environment for compiler */
  502.    'GLOBAL TXTLIB IBMLIB EDCBASE'
  503.    'GLOBAL LOADLIB EDCLINK'
  504.    return ;
  505.  
  506. restoreLibs:
  507.    'GLOBAL TXTLIB' Txtlibs
  508.    'GLOBAL LOADLIB' Loadlibs
  509.    return ;
  510.  
  511. show_header:
  512.    index=1
  513.    line=Sourceline(index)
  514.    Do While Substr(line,1,2)="/*"
  515.       parse var line '/*' middle '*/'
  516.       Say middle
  517.       index=index+1
  518.       line=Sourceline(index)
  519.       End
  520.    Exit
  521.  
  522.