home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1933 < prev    next >
Internet Message Format  |  1990-12-28  |  10KB

  1. From: bothner@sevenlayer.cs.wisc.edu (Per Bothner)
  2. Newsgroups: alt.sources,sci.math.symbolic
  3. Subject: Improved Makefile for PRL Bignum package
  4. Message-ID: <11438@spool.cs.wisc.edu>
  5. Date: 10 Oct 90 23:40:45 GMT
  6.  
  7. This message contains a replement Makefile for the PRL bignum package.
  8. It also contains the file cpp-Makefile.
  9.  
  10. The Bignum package is from DEC's Paris Reserach Lab.
  11. You can receive it by sending a request to librarian@decprl.dec.com.
  12. It implements infinite-precision integer arithmetic.
  13. It contains portable C versions of the primitives, as well
  14. as tuned assembly language versions for selected machines.
  15.  
  16. The main advantage of my replacement Makefile is that it automatically
  17. selects the correct version of the primitives. It does this by
  18. having /lib/cpp process cpp-Makefile, and select the correct version
  19. depending on pre-defined cpp macros.
  20.  
  21. My Makefile also cleans up various other problems:
  22. * It doesn't recompile unless something is out of date.
  23. * Generally cleaner logic and fewer circular dependencies.
  24. * There is a 'clean' entry.
  25. * The default target is 'BigNum.a', not 'all'. (The latter compiles
  26. a number of test programs that are not used by BigNum *clients*.)
  27.  
  28. This Makefile has been tested on both Sony-News and DECstation 3100.
  29. The Bnn part of the library has been used to implement a generic
  30. (Lisp-like) arithmetic system written in C++. The latter (which I
  31. may make available soon) has in turn been used as part of the
  32. run-time system of two different experimental programming languages.
  33.  
  34. There are certainly some bugs/problems remaining, and I would
  35. appreciate hearing about them.
  36.  
  37. ==== Makefile ====
  38. MAKE=make
  39. LIB = BigNum.a
  40. CC = cc
  41. CPP=/lib/cpp -P
  42. TMPMAKE=tmp-Makefile
  43.  
  44. BigNum.a: $(TMPMAKE)
  45.     $(MAKE) -f $(TMPMAKE) $@
  46.  
  47. $(TMPMAKE): cpp-Makefile
  48.     $(CPP) cpp-Makefile >$(TMPMAKE)
  49. clean:
  50.     -rm -f ,* .,* *~ #*# .emacs_[0-9]* *.BAK *.CKP core a.out
  51.     -rm -f */,* */.,* */*~ */#*# */.emacs_[0-9]* */*.BAK */*.CKP
  52.     -rm -f o/*.o $(LIB) $(TMPMAKE)
  53. .DEFAULT: $(TMPMAKE)
  54.     $(MAKE) -f $(TMPMAKE) $@
  55. ==== cpp-Makefile ====
  56. /*  Added automatic version selection Mon Oct 1 1990 bothner@cs.wisc.edu */
  57. /*
  58.  *  Copyright     Digital Equipment Corporation & INRIA     1988, 1989
  59.  *  Last modified_on Tue Sep 25 14:52:15 GMT+2:00 1990 by herve 
  60.  *       modified_on Tue Apr 10 20:34:44 GMT+2:00 1990 by shand 
  61.  *       modified_on Thu Nov  2 14:23:14 GMT+1:00 1989 by gangnet 
  62.  *       modified_on Wed Jul  5 10:23:54 GMT+2:00 1989 by bertin 
  63.  */
  64.  
  65. #ifdef __GNUC__
  66. CC = gcc
  67. #else
  68. CC = cc
  69. #endif
  70. LIB = BigNum.a
  71. KERNH = h/BigNum.h 
  72. CFLAGS = -c `cat .Version` -I./h -O #-g -pg
  73. LKFLAGS = -O #-g
  74.  
  75. SENDMAIL=/usr/lib/sendmail
  76. SENDMAILFLAGS=
  77.  
  78. /* Use predefined pre-processor macros to select a version. */
  79. /* More machines should be added here. */
  80.  
  81. #if !defined(VERSION) && defined(vax)
  82. #define VERSION vax
  83. #endif
  84.  
  85. #if !defined(VERSION) && (defined(sun2) || defined(sun3))
  86. #define VERSION 68K
  87. #endif
  88.  
  89. #if !defined(VERSION) && (defined(MIPSEL) || defined(MIPSEB))
  90. #define VERSION mips
  91. #define MULT /* BnnMultiply is in KerN */
  92. #endif
  93.  
  94. #if !defined(VERSION) && defined(pyr)
  95. #define VERSION pyramid
  96. #endif
  97.  
  98. #if !defined(VERSION) && defined(NeXT)
  99. #define VERSION 68K
  100. #endif
  101.  
  102. #if !defined(VERSION) && defined(sony)
  103. /*#define VERSION 68K_mot -- Doesn't seen to work; /bin/as complains. */
  104. #define VERSION 68K /* Use gnu assembler */
  105. #ifndef AS
  106. #define AS gas
  107. #endif
  108. #endif
  109.  
  110. #if !defined(VERSION) && defined(ns32000)
  111. #define VERSION ns
  112. #endif
  113.  
  114. /* Select a default version. */
  115. #if !defined(VERSION)
  116. #define VERSION C32
  117. #endif
  118.  
  119. #ifndef AS
  120. #define AS as
  121. #endif
  122.  
  123. #ifndef MULT
  124. #define MULT o/bnMult.o
  125. #endif
  126.  
  127. OBJECT = o/KerN.o o/bnInit.o MULT o/bnDivide.o o/bnCmp.o o/bzf.o o/bz.o 
  128.  
  129. /* extra entries:
  130.  * all     - make all the stuff
  131.  * tidy    - cleanup directories
  132.  * scratch - start from scratch
  133.  */
  134.  
  135. /* build the BigNum library */
  136. $(LIB): $(OBJECT)
  137.     -rm -f $(LIB)
  138.     ar cr $(LIB) $(OBJECT)
  139.     ranlib $(LIB)
  140.  
  141. default:
  142.     @echo "Usage: make <version>"
  143.     @echo "see README for valid versions."
  144.     @sh -c 'exit 1'
  145.  
  146. all: testKerN bztest 
  147.     echo All is done !
  148.  
  149. tidy:
  150.     -rm -f ,* .,* *~ #*# .emacs_[0-9]* *.BAK *.CKP core a.out
  151.     -rm -f */,* */.,* */*~ */#*# */.emacs_[0-9]* */*.BAK */*.CKP
  152.  
  153. scratch:tidy 
  154.     cd o; rm -f *.o
  155.  
  156. o/KerN.o: VERSION
  157.  
  158. o/bn.o: c/bn.c
  159.     $(CC) -c $(CFLAGS) $(DFLAG) c/bn.c
  160.     mv bn.o o
  161.  
  162. C16: c/KerN.c
  163.     echo "-DDIGITon16BITS" >.Version
  164.     $(CC) $(CFLAGS) c/KerN.c
  165.     mv KerN.o o
  166.  
  167. C32: c/KerN.c
  168.     echo "-DDIGITon32BITS" >.Version
  169.     $(CC) $(CFLAGS) c/KerN.c
  170.     mv KerN.o o
  171.  
  172. 68K: s/68KerN.s
  173.     echo "-DDIGITon32BITS" >.Version
  174.     AS s/68KerN.s -o o/KerN.o
  175.  
  176. 68K_mot: s/68KerN_mot.s
  177.     echo "-DDIGITon32BITS" >.Version
  178.     AS s/68KerN_mot.s -o o/KerN.o
  179.  
  180. vax: s/vaxKerN.s
  181.     echo "-DDIGITon32BITS" >.Version
  182.     AS s/vaxKerN.s -o o/KerN.o
  183.  
  184. ns: s/nsKerN.s
  185.     echo "-DDIGITon32BITS" >.Version
  186.     AS s/nsKerN.s -o o/KerN.o
  187.  
  188. mips: s/mipsKerN.s
  189.     echo "-DDIGITon32BITS" >.Version
  190.     AS -w s/mipsKerN.s -o o/KerN.o
  191.  
  192. pyramid: s/pyramidKerN.s
  193.     echo "-DDIGITon32BITS" >.Version
  194.     AS s/pyramidKerN.s -o o/KerN.o
  195.  
  196. i960: s/i960KerN.s
  197.     echo "-DDIGITon32BITS" >.Version
  198.     AS s/i960KerN.s -o o/KerN.o
  199.  
  200. /* Construct VMS assembler from UNIX version */
  201.  
  202. s/vaxKerN.mar: s/vaxKerN.s
  203.     sed -f s/unix2vms.sed < s/vaxKerN.s > $@
  204.  
  205. /* Level N */
  206. o/bnInit.o: c/bn/bnInit.c $(KERNH)
  207.     $(CC) $(CFLAGS) c/bn/bnInit.c
  208.     mv bnInit.o o
  209.  
  210. o/bnMult.o: c/bn/bnMult.c $(KERNH)
  211.     $(CC) $(CFLAGS) c/bn/bnMult.c
  212.     mv bnMult.o o
  213.  
  214. o/bnDivide.o: c/bn/bnDivide.c $(KERNH)
  215.     $(CC) $(CFLAGS) c/bn/bnDivide.c
  216.     mv bnDivide.o o
  217.  
  218. o/bnCmp.o: c/bn/bnCmp.c $(KERNH)
  219.     $(CC) $(CFLAGS) c/bn/bnCmp.c
  220.     mv bnCmp.o o
  221.  
  222. /* Level Z */
  223. o/bz.o: c/bz.c h/BigZ.h $(KERNH)
  224.     $(CC) $(CFLAGS) c/bz.c
  225.     mv bz.o o
  226.  
  227. /* Some functions built with BigZ */
  228. o/bzf.o: c/bzf.c h/BigZ.h $(KERNH)
  229.     $(CC) $(CFLAGS) c/bzf.c
  230.     mv bzf.o o
  231.  
  232. /* Tests of KerN */
  233. testKerN: Makefile o/testKerN.o $(LIB)
  234.     $(CC) o/testKerN.o $(LIB) $(LKFLAGS) -o testKerN
  235.  
  236. o/testKerN.o: c/testKerN.c $(KERNH) h/BntoBnn.h
  237.     $(CC) $(CFLAGS) c/testKerN.c
  238.     mv testKerN.o o
  239.  
  240. /* Tests of BigZ */
  241. bztest: o/bztest.o $(LIB)
  242.     $(CC) o/bztest.o $(LIB) $(LKFLAGS) -o bztest
  243.  
  244. o/bztest.o: c/bztest.c h/BigZ.h $(KERNH)
  245.     $(CC) $(CFLAGS) c/bztest.c
  246.     mv bztest.o o
  247.  
  248. /* documentation */
  249. doc: doc/bn.ps doc/bnf.ps 
  250. docprl: doc/bnprl.ps
  251.  
  252. doc/bn.dvi: doc/bn.tex doc/bnbody.tex
  253.     cd doc;\
  254.     latex bn;\
  255.     makeindex bn;\
  256.     sed -e "s/\\item Bz/\\newpage \\Bz/g" < bn.ind > bn.index;\
  257.     mv bn.index bn.ind;\
  258.     latex bn;\
  259.     cd ..
  260.  
  261. doc/bn.ps: doc/bn.dvi
  262.     cd doc;\
  263.     dvips -o bn.ps bn;\
  264.     cd ..
  265.  
  266. doc/bnf.dvi: doc/bnf.tex
  267.     cd doc;\
  268.     latex bnf;\
  269.     cd ..
  270.  
  271. doc/bnf.ps: doc/bnf.dvi
  272.     cd doc;\
  273.     dvips -o bnf.ps bnf;\
  274.     cd ..
  275.  
  276. doc/bnprl.dvi: doc/bnprl.tex doc/bnbody.tex
  277.     cd doc;\
  278.     latex bnprl;\
  279.     makeindex bnprl;\
  280.     sed -e "s/\\item Bz/\\newpage \\Bz/g" < bnprl.ind > bnprl.index;\
  281.     mv bnprl.index bnprl.ind;\
  282.     latex bnprl;\
  283.     cd ..
  284.  
  285. doc/bnprl.ps: doc/bnprl.dvi
  286.     cd doc;\
  287.     dvips -o bnprl.ps bnprl;\
  288.     cd ..
  289.  
  290. /* build shell archives */
  291. shar: bignum01
  292.  
  293. PACKET_SIZE=90
  294.  
  295. /* If you modify the list of files in the package kit, don't forget */
  296. /* to update README. */
  297.  
  298. bignum01: README Makefile VMSmakefile\
  299.       doc/bn.tex doc/bnbody.tex doc/bnf.tex doc/intro\
  300.       c/KerN.c c/bn/bnInit.c c/bn/bnMult.c c/bn/bnDivide.c\
  301.       c/bn/bnCmp.c c/bz.c c/bzf.c \
  302.       c/bztest.c c/testKerN.c \
  303.       h/BigNum.h h/BigZ.h h/BntoBnn.h \
  304.       s/vaxKerN.s s/68KerN.s s/nsKerN.s s/68KerN_mot.s \
  305.       s/mipsKerN.s s/pyramidKerN.s s/vaxKerN.mar s/unix2vms.sed \
  306.       s/i960KerN.s \
  307.       o/EMPTY
  308.     makekit -s$(PACKET_SIZE)k -nbignum -t"Now do 'make'" \
  309.             README Makefile VMSmakefile\
  310.             doc doc/bn.tex doc/bnbody.tex doc/bnf.tex \
  311.                 doc/intro doc/makeidx.sty \
  312.             c c/KerN.c c/bz.c c/bzf.c c/bztest.c c/testKerN.c \
  313.             c/bn c/bn/bnInit.c c/bn/bnMult.c c/bn/bnDivide.c c/bn/bnCmp.c \
  314.             h h/BigNum.h h/BigZ.h h/BntoBnn.h \
  315.             s s/vaxKerN.s s/68KerN.s s/nsKerN.s s/68KerN_mot.s \
  316.               s/mipsKerN.s s/pyramidKerN.s s/vaxKerN.mar s/unix2vms.sed \
  317.               s/i960KerN.s \
  318.             o o/EMPTY
  319.  
  320. /* send shell archives */
  321. USER=nil
  322. FULLNAME=nil
  323. COPY=librarian@prl.dec.com
  324. mail: bignum01
  325.     @sh -c "if [ x$(USER) = xnil -o 'x$(FULLNAME)' = xnil ]; \
  326.         then echo must specify USER and FULLNAME; \
  327.              echo EG make USER=herve@prl FULLNAME="'\"'"J-C Herve, Digital PRL"'\"'" mail; exit 1; \
  328.              else :; fi"
  329.     @touch Recipients
  330.     @echo '' >> Recipients
  331.     @date >> Recipients
  332.     @echo "$(FULLNAME)" >> Recipients
  333.     @echo '<'"$(USER)"'>' >> Recipients
  334.     @echo "To: $(COPY)" >tosend
  335.     @echo "Subject: BIGNUM DAEMON" >>tosend
  336.     @echo "Madeleine and Monique, I have sent the package bignum to:" >>tosend
  337.     @echo >>tosend
  338.     @echo "    $(FULLNAME)" >>tosend
  339.     @echo "    $(USER)" >>tosend
  340.     @echo >>tosend
  341.     @echo "Thanks to register this address in your distribution list." >>tosend
  342.     @$(SENDMAIL) $(SENDMAILFLAGS) $(COPY) <tosend
  343.     echo To: $(USER) > sendmail_header
  344.     cp sendmail_header tosend
  345.     echo "Subject: BigNum package from Digital PRL" >>tosend
  346.     ls bignum[0-9][0-9] | sed -e "s/^bignum0*/    BigNum - Part /" > _flist1
  347.     ls bignum[0-9][0-9] | sed -e "s/^/    /" > _flist2
  348.     ls bignum[0-9][0-9] | sed -e "s/^/    \/bin\/sh /" > _flist3
  349.     ls bignum[0-9][0-9] | sed -e "s/^/    shar -u /" > _flist4
  350.     cc -E -Uvax -I. doc/intro >intro.tosend
  351.     sed \
  352.         -e "s/modified_on/modified_on/g" \
  353.         -e "/doc\/intro/d" \
  354.         -e "/.\/README/d" \
  355.         -e "s/NN/"`ls bignum?? | wc -l | sed -e "s/ //g"`"/g" \
  356.         -e "/^INCLUDE1/r _flist1" \
  357.         -e "/^INCLUDE2/r _flist2" \
  358.         -e "/^INCLUDE3/r _flist3" \
  359.         -e "/^INCLUDE4/r _flist4" \
  360.         -e "/^INCLUDE./d" \
  361.         <intro.tosend >>tosend
  362.     $(SENDMAIL) $(SENDMAILFLAGS) $(USER) <tosend
  363.     for i in `ls bignum[0-9][0-9]`; \
  364.         do cp sendmail_header tosend; \
  365.         echo $$i | sed -e "s/^bignum0*/Subject: BigNum - Part /" >>tosend; \
  366.         echo "# Remove all text above and including this line." >>tosend; \
  367.         sed -e "s/modified_on/modified_on/g" <$$i >>tosend; \
  368.         $(SENDMAIL) $(SENDMAILFLAGS) $(USER) <tosend; \
  369.         done
  370.     rm -f sendmail_header tosend _flist[1-9] bignum[0-9][0-9] intro.tosend
  371. --
  372.     --Per Bothner
  373. bothner@cs.wisc.edu Computer Sciences Dept, U. of Wisconsin-Madison
  374.