home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2091 / Makefile < prev   
Encoding:
Makefile  |  1990-12-28  |  11.9 KB  |  418 lines

  1. #    Copyright 1985, 1986, 1987, 1988, 1989, 1990 Chris Lewis
  2. #        All Rights Reserved
  3. #
  4. #    This makefile requires System V compatible "make".  *Not* V7
  5. #    vanilla BSD or Ultrix or Sun.  Most modern systems will have
  6. #    a copy of the SV one somewhere (eg: .../s5bin/make).
  7. #
  8. #    Permission to copy and further distribute is freely given provided
  9. #    this copyright notice remains intact and that this software is not
  10. #    sold for profit.
  11. #
  12. #    Project:    Generic Troff drivers
  13. #    Module:        Makefile
  14. #    Author:     Chris Lewis
  15. #    Specs:        Makefile for Generic Troff drivers
  16. #    Note:        This is a System V Makefile, so you may
  17. #            have some problems making a few of the items.
  18. #
  19. #ident  "@(#)Makefile: 2.2 Copyright 90/08/10 15:22:08 Chris Lewis"
  20.  
  21. #    Use s5make on Ultrix and Sun!
  22.  
  23. #    Set to where you want the user-interfaces to go
  24. BINDIR    = /usr/lbin
  25. #BINDIR    = /usr/tmp/bin
  26.  
  27. #    Testing type (default postscript (ps)):
  28. #    Use lj for laserjet.
  29. TTYPE    = ps
  30.  
  31. #    Libraries for Troff2 internals, created if it doesn't exist.
  32. #    This *must* be a directory all by itself with no other stuff
  33. #    in it.
  34. LIBDIR    = /usr/lib/troff2
  35. #LIBDIR = /usr/tmp/troff2
  36.  
  37. #    Directory for Laserjet fonts.
  38. LJF    = $(LIBDIR)/lib/lj
  39.  
  40. #    nroff/troff macro directory for tmac.t2.
  41. T2DIR    = /usr/lib/tmac
  42.  
  43. #    Where your real macros are
  44. RTMACDIR = /usr/lib/tmac
  45. #RTMACDIR = /usr/tmp/tmac
  46.  
  47. #    upper level man directory, with subdirectories man1, man2 etc.
  48. MANDIR    = /usr/man/l_man
  49. #MANDIR    = /usr/tmp/man
  50.  
  51. #    Change this at your peril - your troff *must* support -F!
  52. #    (font width files (ft??) are placed under FONTDIR/<width>/ft??)
  53. #    (see lib/psrofflib.S)
  54. FONTDIR    = /usr/lib/font
  55. #FONTDIR = /usr/tmp/font
  56.  
  57. #    Comment this out if you don't have shared libraries ala 386/ix
  58. LIBFLAGS = -lc_s
  59.  
  60. #    Bourne shell.  *All* Bourne shells with the exception of extremely
  61. #    braindamaged ones (such as Ultrix or vanilla BSD) will work fine.
  62. #    Ultrix/Dynix may need the ... s5bin/sh one.  Korn or bash
  63. #    *should* work just fine, but I've never tested 'em.
  64. #
  65. #    This is also here for make, but if you have SHELL defined in your
  66. #    *own* environment, you can't trust this to work anyways.
  67. #
  68. SHELL    =    /bin/sh
  69.  
  70. #    Try "make testbug"  If make stops, uncomment IGNORESH and
  71. #    try "make testbug" again.  If it still stops, complain to your
  72. #    vendor - your shell is BADLY broken.
  73. #IGNORESH = set +e ;
  74.  
  75. #    How to ensure that shell scripts use the *right* shell.
  76. #    "#! /bin/sh" may work for you.  ": /bin/sh" may work for you.
  77. #
  78. #    Frankly, none of this crap is necessary on a sane O/S.
  79. #    (Even Xenix gets this right for crying out loud!  But *noooo*
  80. #    Not Ultrix or Sun or Dynix BSD universe....)
  81. #
  82. #    ": /usr/bin/sh5" works for Ultrix.
  83. #    Do not use $(SHELL) in this line because if your environment has
  84. #    SHELL defined, it may *override* the above SHELL definition.
  85. #
  86. #    If you have to get a "#" into STARTSHELL, the Makefile won't
  87. #    like it.  In that case, if you have a System V compatible echo
  88. #    (one that understands \nnn), use:
  89. #    STARTSHELL = "`echo '\043! <your shell here>'`"
  90. #    If you don't have a System V compatible echo (eg: Ultrix or
  91. #    pure BSD), use this instead:
  92. #    STARTSHELL = `cat STARTSHELL`
  93. #    then create a file called STARTSHELL with the right stuff
  94. #    in it.  Eg: echo "#! <your shell here>" > STARTSHELL
  95. #
  96. #    System V usually:
  97. STARTSHELL = : /bin/sh
  98. #    System V echo compliance, but needs #!: (Xenix?)
  99. #STARTSHELL = `echo '\043! /bin/sh'`
  100. #    Pure BSD (ala Ultrix) echo "#! /bin/sh" > STARTSHELL" first.
  101. #STARTSHELL = `cat STARTSHELL`
  102.  
  103. #    Whether you need "cc -c"'d font width tables for troff.
  104. COMPILE    =
  105.  
  106. #    Compile flags needed to compile things on your machine.
  107. #    Usually just -O
  108. #
  109. #    PROFBUG is for 386/ix 1.0.6 mcrt making a mistake on argument
  110. #    vector on entry to main.  Only troff2.c has the additional parts
  111. #    to make profiling work on 386ix.  You'd normally want just -p
  112. #    and/or -g.
  113. #
  114. #CCFLAGS = -p -g -DPROFBUG
  115. #    Chris's wierd, not yet quite working NULL dereference checker
  116. #CCFLAGS    = -O -Ya,`pwd/t` -g -DNULLCHECK
  117. #    Chris's other wierd, but working, NULL dereference checker.
  118. #CCFLAGS    = -O `pwd`/ifile
  119. CCFLAGS = -O
  120.  
  121. #    If you're using gcc or something else, change this:
  122. CC    = cc
  123.  
  124. #    Do not comment any of the following out.  If you aren't going
  125. #    to use TeX PK fonts with HP Laserjet output, just NEVER execute
  126. #    makebuildljfonts.
  127. #
  128. #    If you have Rick Richardson's sfp2pk, set it's full path here:
  129. #    Only of interest for LJ/buildfonts.  If you don't have sfp2pk,
  130. #    leave this alone, the code won't try to run it.
  131. SFP2PK    = /usr4/public/bin/sfp2pk
  132. #    If you have TeX fonts onboard, list the directories that
  133. #    contain them.  Only of interest for LJ/buildfonts.
  134. #    You can always set this to "/", it'll just take a long time, but
  135. #    it will find ALL PK's on your system.
  136. PKFONTS    = /usr/lib/font/devjet /usr5/texfonts/fonts
  137. #    Where you want to build fonts, set this to the name of the
  138. #    directory where you want to make them.  Caution: this could be
  139. #    enormous...  (5000+ blocks)
  140. NEWFONTS = /tmp/newfonts
  141.  
  142. #    Dinna touch from here on
  143.  
  144. .SUFFIXES: .S .S~
  145.  
  146. .S~:
  147.     @rm -f $@
  148.     $(GET) -p $(GFLAGS) $< | ./sedscript > $@
  149.     @chmod 444 $@
  150.  
  151. .S~.S:
  152.     @rm -f $@
  153.     $(GET) -p $(GFLAGS) $< > $@
  154.     @chmod 444 $@
  155.  
  156. .S:
  157.     rm -f $@
  158.     ./sedscript < $@.S > $@
  159.     @chmod 444 $@
  160.  
  161. #    Main stuff:
  162.  
  163. MAIN    = troff2.o opt.o utils.o t2conf.o cattab.o debug.o
  164.  
  165. #    Drivers:
  166.  
  167. BACKENDS = lj.o pk.o pkc.o ps.o dt.o
  168.  
  169. #    Creation of sedscript for parameterization.
  170.  
  171. SEDSCRIPT =    "sed -e 's;%%LIBDIR%%;$(LIBDIR);g' \
  172.              -e 's;%%LJF%%;$(LJF);g' \
  173.              -e 's;%%STARTSHELL%%;'\"$(STARTSHELL)\"';g' \
  174.              -e 's;%%COMPILE%%;$(COMPILE);g' \
  175.              -e 's;%%FONTDIR%%;$(FONTDIR);g' \
  176.              -e 's;%%MANDIR%%;$(MANDIR);g' \
  177.              -e 's;%%CCFLAGS%%;$(CCFLAGS);' \
  178.              -e 's;%%CC%%;$(CC);' \
  179.              -e 's;%%LIBFLAGS%%;$(LIBFLAGS);' \
  180.              -e 's;%%SFP2PK%%;$(SFP2PK);' \
  181.              -e 's;%%PKFONTS%%;$(PKFONTS);' \
  182.              -e 's;%%NEWFONTS%%;$(NEWFONTS);' \
  183.              -e 's^%%IGNORESH%%^$(IGNORESH)^' \
  184.              -e 's;%%RTMACDIR%%;$(RTMACDIR);g'"
  185.  
  186. DEFINES    = '-DLIBDIR="$(LIBDIR)/lib"' '-DFONTDIR="$(FONTDIR)"'\
  187.     '-DLJF="$(LJF)"' $(CCFLAGS)
  188. CFLAGS    = $(DEFINES)
  189.  
  190.  
  191. all:    troff2ps subst.done makeincl psroff README TROUBLE LASERFONTS submakes
  192.  
  193. subst.done:    sedscript
  194.     rm -f psroff makeincl
  195.     touch subst.done
  196.  
  197. submakes:
  198.     cd adapters ; $(MAKE) all
  199.     cd lib ; $(MAKE) all
  200.     cd man ; $(MAKE) all
  201.     cd utils ; $(MAKE) all
  202.     cd widths ; $(MAKE) all
  203.     cd tests ; $(MAKE) all
  204.  
  205. psroff:    psroff.S sedscript
  206.     @echo "Extracting $@ with variable substitutions"
  207.     @rm -f $(@) ; ./sedscript < $@.S > T ; chmod 555 T ; mv T $@
  208.  
  209. makeincl:    makeincl.S sedscript
  210.     @echo "Extracting $@ with variable substitutions"
  211.     @rm -f $(@) ; ./sedscript < $@.S > T ; chmod 555 T ; mv T $@
  212.  
  213. audit:    audit.S sedscript
  214.     @echo "Extracting $@ with variable substitutions"
  215.     @rm -f $(@) ; ./sedscript < $@.S > T ; chmod 555 T ; mv T $@
  216.  
  217. unpackljfonts:
  218.     @ $(IGNORESH) find . -name '*.UU' -print | \
  219.     while read i ; \
  220.     do \
  221.         ft=`echo $$i | sed -e 's/.UU//'` ; \
  222.         if [ -s $$ft ] ; \
  223.         then \
  224.         echo "Removing $$i" ; \
  225.         rm -f $$i ; \
  226.         else \
  227.         rm -f $$ft ; \
  228.         echo "uudecoding $$i -> $$ft" ; \
  229.         uudecode < $$i ; \
  230.         if [ ! -s $$ft ] ; \
  231.         then \
  232.             echo "Whoops - uudecode failed on $$i - bad path?" ; \
  233.             exit 1 ; \
  234.         else \
  235.             rm $$i ; \
  236.         fi ; \
  237.         fi ; \
  238.     done
  239.  
  240. buildljfonts:    unpackljfonts
  241.     make troff2ps makeincl
  242.     cd lib ; make lj.fonts lj.lib
  243.     cd utils ; make buildfonts
  244.  
  245. installljfonts:
  246.     test -d $(LIBDIR) || mkdir $(LIBDIR)
  247.     test -d $(LIBDIR)/lib || mkdir $(LIBDIR)/lib
  248.     test -d $(LIBDIR)/lib/lj || mkdir $(LIBDIR)/lib/lj
  249.     $(IGNORESH) files=`echo fonts.lj/*.pk` ; \
  250.     if [ "$$files" != 'fonts.lj/*.pk' ] ; \
  251.     then \
  252.         cp fonts.lj/*.pk $(LJF) ; \
  253.     fi
  254.     $(IGNORESH) files=`echo fonts.lj/*.sfp` ; \
  255.     if [ "$$files" != 'fonts.lj/*.sfp' ] ; \
  256.     then \
  257.         cp fonts.lj/*.sfp $(LJF) ; \
  258.     fi
  259.     $(IGNORESH) test -z "$(PKFONTS)" -o ! -d "$(NEWFONTS)" \
  260.         || cp $(NEWFONTS)/* $(LJF)
  261.  
  262. register:
  263.     make troff2ps makeincl
  264.     cd lib ; make lj.fonts lj.lib
  265.     cd widths ; make ljwidths widths
  266.     @echo "Now su to root and type 'make installwidths'"
  267.  
  268. installwidths:    makeincl
  269.     cd widths; $(MAKE) installwidths
  270.  
  271. install:    makeincl
  272.     test -d $(BINDIR) || mkdir $(BINDIR)
  273.     test -d $(MANDIR) || mkdir $(MANDIR)
  274.     test -d $(LIBDIR) || mkdir $(LIBDIR)
  275.     test -d $(LIBDIR)/adapters || mkdir $(LIBDIR)/adapters
  276.     test -d $(LIBDIR)/lib || mkdir $(LIBDIR)/lib
  277.     test -d $(RTMACDIR) || mkdir $(RTMACDIR)
  278.     test -d $(FONTDIR) || mkdir $(FONTDIR)
  279.     rm -f $(BINDIR)/psroff.old
  280.     -cp $(BINDIR)/psroff $(BINDIR)/psroff.old
  281.     cp psroff $(BINDIR)/psroff
  282.     rm -f $(LIBDIR)/troff2ps.old
  283.     -cp $(LIBDIR)/troff2ps $(LIBDIR)/troff2ps.old
  284.     cp troff2ps $(LIBDIR)/troff2ps
  285.     cd lib ; $(MAKE) install
  286.     cd adapters ; $(MAKE) install
  287.     cd man ; $(MAKE) install
  288.     cd utils ; $(MAKE) install
  289.     cd widths; $(MAKE) install
  290.  
  291. troff2ps:    $(MAIN) $(BACKENDS)
  292.     $(CC) $(CFLAGS) -o troff2ps $(MAIN) $(BACKENDS) $(LIBFLAGS)
  293.  
  294. #    The following is commented out because make has a bug in that
  295. #    even if you don't want to make lint, it insists on making
  296. #    the .c's from the SCCS files.  Dumb stupid....
  297. #lint:    $(MAIN:.o=.c) $(BACKENDS:.o=.c)
  298. #    lint -p $(CFLAGS) $(MAIN:.o=.c) $(BACKENDS:.o=.c) > output.lint
  299.  
  300. #    Drivers include dependencies - add to this list if you're adding
  301. #    drivers.
  302. t2conf.o:    defs.h ps.h lj.h dt.h
  303. ps.o:    defs.h ps.h
  304. dt.o:    defs.h dt.h
  305. lj.o:    defs.h lj.h pkc.h pk.h
  306.  
  307. pk.o:    defs.h pk.h pkc.h
  308. pkc.o:    defs.h pk.h pkc.h
  309. cattab.o:    defs.h pk.h
  310. debug.o:    defs.h pk.h
  311.  
  312. troff2.o utils.o opt.o: defs.h
  313.  
  314. sedscript:    Makefile
  315.     rm -f sedscript ; echo $(SEDSCRIPT) > T ; chmod 755 T ; mv T sedscript
  316.  
  317. clean:    makeincl
  318.     rm -f core *.o troff2ps psroff diagnostics audit
  319.     rm -fr mon.out output.lint TEST*
  320.     rm -fr FONTS
  321.     cd adapters ; $(MAKE) clean
  322.     cd man ; $(MAKE) clean
  323.     cd utils ; $(MAKE) clean
  324.     cd lib ; $(MAKE) clean
  325.     cd widths ; $(MAKE) clean
  326.     cd tests ; $(MAKE) clean
  327.     rm -f sedscript makeincl subst.done */subst.done
  328.  
  329. #    Yes, this is a little wierd, but in this way I can figure
  330. #    out what you are...
  331. TEST:    Makefile defs.h tests/testtab.m makeincl
  332.     cd lib ; make
  333.     rm -f TEST1 TEST2
  334.     PATH=.:$(LIBDIR):$$PATH \
  335.         troff2ps -V | sed -e 's/^.*- \(.*\)/.ds 2v "\1/' > TEST1
  336.     echo ".ds 2d \"`date`" >> TEST1
  337.     echo ".sp" > TEST2
  338.     echo ".ps 10" >> TEST2
  339.     echo ".vs 12p" >> TEST2
  340.     echo ".ad 1" >> TEST2
  341.     echo "DEFS.H DEFINITIONS:" >> TEST2
  342.     sed -n -e '/Edit no more/q' \
  343.         -e '/T2VERSION/d' \
  344.         -e '/LIBDIR/d' \
  345.         -e 's/[     ]*\/\*.*//' \
  346.         -e '/^.define[     ]*\([^     ]*\)[     ]*\(.*\)$$/s//define \1=\2;/' \
  347.         -e 's/=;/;/' \
  348.         -e 's/^define //p' \
  349.         -e '/^.undef[     ]*\([^     ]*\).*/s//!\1;/p' \
  350.         defs.h >> TEST2
  351.     #echo ".br" >> TEST2
  352.     echo "MAKEFILE DEFINITIONS:" >> TEST2
  353.     echo "LIBDIR = $(LIBDIR);" >> TEST2
  354.     echo "LJF = $(LJF);" >> TEST2
  355.     echo "STARTSHELL = $(STARTSHELL); " >> TEST2
  356.     echo "SHELL = $(SHELL); " >> TEST2
  357.     echo "COMPILE = $(COMPILE);" >> TEST2
  358.     echo "FONTDIR = $(FONTDIR);" >> TEST2
  359.     echo "MANDIR = $(MANDIR);" >> TEST2
  360.     echo "CCFLAGS = $(CCFLAGS);" >> TEST2
  361.     echo "CC = $(CC);" >> TEST2
  362.     echo "LIBFLAGS = $(LIBFLAGS);" >> TEST2
  363.     echo "RTMACDIR = $(RTMACDIR);" >> TEST2
  364.     echo "PKFONTS = $(PKFONTS);" >> TEST2
  365.     echo "NEWFONTS = $(NEWFONTS);" >> TEST2
  366.     echo "IGNORESH = $(IGNORESH);" >> TEST2
  367.     echo "SFP2PK = $(SFP2PK)." >> TEST2
  368.     echo "TTYPE = $(TTYPE)." >> TEST2
  369.     @echo "Don't worry if the uname/grep fails"
  370.     -grep '^trofftype' lib/psrofflib >> TEST2
  371.     echo "Uname results:" >> TEST2
  372.     -uname -a >> TEST2
  373.     cat TEST1 tests/testtab.m TEST2 > TEST
  374.     rm -f TEST1 TEST2
  375.  
  376. test:    TEST
  377.     tbl TEST | PATH=.:$(LIBDIR):$$PATH psroff -T$(TTYPE)
  378.  
  379. check:    audit sedscript makeincl
  380.     cd lib ; $(MAKE)
  381.     ./audit
  382.  
  383. checkinstall:    audit sedscript makeincl
  384.     cd lib ; $(MAKE)
  385.     ./audit install
  386.  
  387. #    This is how I build a release - don't even try running this...!
  388. buildrelease:    clean unpackljfonts
  389.     $(IGNORESH) t=`find . -name 'p.*' -print`; \
  390.     if [ -n "$$t" ] ; \
  391.     then \
  392.         echo "files still out: $$t" ; \
  393.         exit 1 ; \
  394.     fi
  395.     make buildfinal
  396.  
  397. buildfinal:
  398.     make troff2ps makeincl
  399.     cd lib ; make lj.fonts lj.lib
  400.     cd utils ; make tmaps buildSfonts
  401.     cd utils ; make keepbuiltfonts
  402.     make test
  403.     make clean
  404.     t/cleantree
  405.     t/mkmanifest
  406.     t/mkkits
  407.     t/cleantree
  408.  
  409. #    Impossible file, we hope....
  410. WF    = /cowsnovskibumsteinpastafazoola/bdkdkdk
  411. testbug:
  412.     @ $(IGNORESH) if [ -r $(WF) ] ; \
  413.     then \
  414.         echo "Bizarre - are you sure you have $(WF)?" ; \
  415.     else \
  416.         echo "IGNORESH set correctly" ; \
  417.     fi
  418.