bothner@sevenlayer.cs.wisc.edu (Per Bothner) (10/11/90)
This message contains a replement Makefile for the PRL bignum package. It also contains the file cpp-Makefile. The Bignum package is from DEC's Paris Reserach Lab. You can receive it by sending a request to librarian@decprl.dec.com. It implements infinite-precision integer arithmetic. It contains portable C versions of the primitives, as well as tuned assembly language versions for selected machines. The main advantage of my replacement Makefile is that it automatically selects the correct version of the primitives. It does this by having /lib/cpp process cpp-Makefile, and select the correct version depending on pre-defined cpp macros. My Makefile also cleans up various other problems: * It doesn't recompile unless something is out of date. * Generally cleaner logic and fewer circular dependencies. * There is a 'clean' entry. * The default target is 'BigNum.a', not 'all'. (The latter compiles a number of test programs that are not used by BigNum *clients*.) This Makefile has been tested on both Sony-News and DECstation 3100. The Bnn part of the library has been used to implement a generic (Lisp-like) arithmetic system written in C++. The latter (which I may make available soon) has in turn been used as part of the run-time system of two different experimental programming languages. There are certainly some bugs/problems remaining, and I would appreciate hearing about them. ==== Makefile ==== MAKE=make LIB = BigNum.a CC = cc CPP=/lib/cpp -P TMPMAKE=tmp-Makefile BigNum.a: $(TMPMAKE) $(MAKE) -f $(TMPMAKE) $@ $(TMPMAKE): cpp-Makefile $(CPP) cpp-Makefile >$(TMPMAKE) clean: -rm -f ,* .,* *~ #*# .emacs_[0-9]* *.BAK *.CKP core a.out -rm -f */,* */.,* */*~ */#*# */.emacs_[0-9]* */*.BAK */*.CKP -rm -f o/*.o $(LIB) $(TMPMAKE) .DEFAULT: $(TMPMAKE) $(MAKE) -f $(TMPMAKE) $@ ==== cpp-Makefile ==== /* Added automatic version selection Mon Oct 1 1990 bothner@cs.wisc.edu */ /* * Copyright Digital Equipment Corporation & INRIA 1988, 1989 * Last modified_on Tue Sep 25 14:52:15 GMT+2:00 1990 by herve * modified_on Tue Apr 10 20:34:44 GMT+2:00 1990 by shand * modified_on Thu Nov 2 14:23:14 GMT+1:00 1989 by gangnet * modified_on Wed Jul 5 10:23:54 GMT+2:00 1989 by bertin */ #ifdef __GNUC__ CC = gcc #else CC = cc #endif LIB = BigNum.a KERNH = h/BigNum.h CFLAGS = -c `cat .Version` -I./h -O #-g -pg LKFLAGS = -O #-g SENDMAIL=/usr/lib/sendmail SENDMAILFLAGS= /* Use predefined pre-processor macros to select a version. */ /* More machines should be added here. */ #if !defined(VERSION) && defined(vax) #define VERSION vax #endif #if !defined(VERSION) && (defined(sun2) || defined(sun3)) #define VERSION 68K #endif #if !defined(VERSION) && (defined(MIPSEL) || defined(MIPSEB)) #define VERSION mips #define MULT /* BnnMultiply is in KerN */ #endif #if !defined(VERSION) && defined(pyr) #define VERSION pyramid #endif #if !defined(VERSION) && defined(NeXT) #define VERSION 68K #endif #if !defined(VERSION) && defined(sony) /*#define VERSION 68K_mot -- Doesn't seen to work; /bin/as complains. */ #define VERSION 68K /* Use gnu assembler */ #ifndef AS #define AS gas #endif #endif #if !defined(VERSION) && defined(ns32000) #define VERSION ns #endif /* Select a default version. */ #if !defined(VERSION) #define VERSION C32 #endif #ifndef AS #define AS as #endif #ifndef MULT #define MULT o/bnMult.o #endif OBJECT = o/KerN.o o/bnInit.o MULT o/bnDivide.o o/bnCmp.o o/bzf.o o/bz.o /* extra entries: * all - make all the stuff * tidy - cleanup directories * scratch - start from scratch */ /* build the BigNum library */ $(LIB): $(OBJECT) -rm -f $(LIB) ar cr $(LIB) $(OBJECT) ranlib $(LIB) default: @echo "Usage: make <version>" @echo "see README for valid versions." @sh -c 'exit 1' all: testKerN bztest echo All is done ! tidy: -rm -f ,* .,* *~ #*# .emacs_[0-9]* *.BAK *.CKP core a.out -rm -f */,* */.,* */*~ */#*# */.emacs_[0-9]* */*.BAK */*.CKP scratch:tidy cd o; rm -f *.o o/KerN.o: VERSION o/bn.o: c/bn.c $(CC) -c $(CFLAGS) $(DFLAG) c/bn.c mv bn.o o C16: c/KerN.c echo "-DDIGITon16BITS" >.Version $(CC) $(CFLAGS) c/KerN.c mv KerN.o o C32: c/KerN.c echo "-DDIGITon32BITS" >.Version $(CC) $(CFLAGS) c/KerN.c mv KerN.o o 68K: s/68KerN.s echo "-DDIGITon32BITS" >.Version AS s/68KerN.s -o o/KerN.o 68K_mot: s/68KerN_mot.s echo "-DDIGITon32BITS" >.Version AS s/68KerN_mot.s -o o/KerN.o vax: s/vaxKerN.s echo "-DDIGITon32BITS" >.Version AS s/vaxKerN.s -o o/KerN.o ns: s/nsKerN.s echo "-DDIGITon32BITS" >.Version AS s/nsKerN.s -o o/KerN.o mips: s/mipsKerN.s echo "-DDIGITon32BITS" >.Version AS -w s/mipsKerN.s -o o/KerN.o pyramid: s/pyramidKerN.s echo "-DDIGITon32BITS" >.Version AS s/pyramidKerN.s -o o/KerN.o i960: s/i960KerN.s echo "-DDIGITon32BITS" >.Version AS s/i960KerN.s -o o/KerN.o /* Construct VMS assembler from UNIX version */ s/vaxKerN.mar: s/vaxKerN.s sed -f s/unix2vms.sed < s/vaxKerN.s > $@ /* Level N */ o/bnInit.o: c/bn/bnInit.c $(KERNH) $(CC) $(CFLAGS) c/bn/bnInit.c mv bnInit.o o o/bnMult.o: c/bn/bnMult.c $(KERNH) $(CC) $(CFLAGS) c/bn/bnMult.c mv bnMult.o o o/bnDivide.o: c/bn/bnDivide.c $(KERNH) $(CC) $(CFLAGS) c/bn/bnDivide.c mv bnDivide.o o o/bnCmp.o: c/bn/bnCmp.c $(KERNH) $(CC) $(CFLAGS) c/bn/bnCmp.c mv bnCmp.o o /* Level Z */ o/bz.o: c/bz.c h/BigZ.h $(KERNH) $(CC) $(CFLAGS) c/bz.c mv bz.o o /* Some functions built with BigZ */ o/bzf.o: c/bzf.c h/BigZ.h $(KERNH) $(CC) $(CFLAGS) c/bzf.c mv bzf.o o /* Tests of KerN */ testKerN: Makefile o/testKerN.o $(LIB) $(CC) o/testKerN.o $(LIB) $(LKFLAGS) -o testKerN o/testKerN.o: c/testKerN.c $(KERNH) h/BntoBnn.h $(CC) $(CFLAGS) c/testKerN.c mv testKerN.o o /* Tests of BigZ */ bztest: o/bztest.o $(LIB) $(CC) o/bztest.o $(LIB) $(LKFLAGS) -o bztest o/bztest.o: c/bztest.c h/BigZ.h $(KERNH) $(CC) $(CFLAGS) c/bztest.c mv bztest.o o /* documentation */ doc: doc/bn.ps doc/bnf.ps docprl: doc/bnprl.ps doc/bn.dvi: doc/bn.tex doc/bnbody.tex cd doc;\ latex bn;\ makeindex bn;\ sed -e "s/\\item Bz/\\newpage \\Bz/g" < bn.ind > bn.index;\ mv bn.index bn.ind;\ latex bn;\ cd .. doc/bn.ps: doc/bn.dvi cd doc;\ dvips -o bn.ps bn;\ cd .. doc/bnf.dvi: doc/bnf.tex cd doc;\ latex bnf;\ cd .. doc/bnf.ps: doc/bnf.dvi cd doc;\ dvips -o bnf.ps bnf;\ cd .. doc/bnprl.dvi: doc/bnprl.tex doc/bnbody.tex cd doc;\ latex bnprl;\ makeindex bnprl;\ sed -e "s/\\item Bz/\\newpage \\Bz/g" < bnprl.ind > bnprl.index;\ mv bnprl.index bnprl.ind;\ latex bnprl;\ cd .. doc/bnprl.ps: doc/bnprl.dvi cd doc;\ dvips -o bnprl.ps bnprl;\ cd .. /* build shell archives */ shar: bignum01 PACKET_SIZE=90 /* If you modify the list of files in the package kit, don't forget */ /* to update README. */ bignum01: README Makefile VMSmakefile\ doc/bn.tex doc/bnbody.tex doc/bnf.tex doc/intro\ c/KerN.c c/bn/bnInit.c c/bn/bnMult.c c/bn/bnDivide.c\ c/bn/bnCmp.c c/bz.c c/bzf.c \ c/bztest.c c/testKerN.c \ h/BigNum.h h/BigZ.h h/BntoBnn.h \ s/vaxKerN.s s/68KerN.s s/nsKerN.s s/68KerN_mot.s \ s/mipsKerN.s s/pyramidKerN.s s/vaxKerN.mar s/unix2vms.sed \ s/i960KerN.s \ o/EMPTY makekit -s$(PACKET_SIZE)k -nbignum -t"Now do 'make'" \ README Makefile VMSmakefile\ doc doc/bn.tex doc/bnbody.tex doc/bnf.tex \ doc/intro doc/makeidx.sty \ c c/KerN.c c/bz.c c/bzf.c c/bztest.c c/testKerN.c \ c/bn c/bn/bnInit.c c/bn/bnMult.c c/bn/bnDivide.c c/bn/bnCmp.c \ h h/BigNum.h h/BigZ.h h/BntoBnn.h \ s s/vaxKerN.s s/68KerN.s s/nsKerN.s s/68KerN_mot.s \ s/mipsKerN.s s/pyramidKerN.s s/vaxKerN.mar s/unix2vms.sed \ s/i960KerN.s \ o o/EMPTY /* send shell archives */ USER=nil FULLNAME=nil COPY=librarian@prl.dec.com mail: bignum01 @sh -c "if [ x$(USER) = xnil -o 'x$(FULLNAME)' = xnil ]; \ then echo must specify USER and FULLNAME; \ echo EG make USER=herve@prl FULLNAME="'\"'"J-C Herve, Digital PRL"'\"'" mail; exit 1; \ else :; fi" @touch Recipients @echo '' >> Recipients @date >> Recipients @echo "$(FULLNAME)" >> Recipients @echo '<'"$(USER)"'>' >> Recipients @echo "To: $(COPY)" >tosend @echo "Subject: BIGNUM DAEMON" >>tosend @echo "Madeleine and Monique, I have sent the package bignum to:" >>tosend @echo >>tosend @echo " $(FULLNAME)" >>tosend @echo " $(USER)" >>tosend @echo >>tosend @echo "Thanks to register this address in your distribution list." >>tosend @$(SENDMAIL) $(SENDMAILFLAGS) $(COPY) <tosend echo To: $(USER) > sendmail_header cp sendmail_header tosend echo "Subject: BigNum package from Digital PRL" >>tosend ls bignum[0-9][0-9] | sed -e "s/^bignum0*/ BigNum - Part /" > _flist1 ls bignum[0-9][0-9] | sed -e "s/^/ /" > _flist2 ls bignum[0-9][0-9] | sed -e "s/^/ \/bin\/sh /" > _flist3 ls bignum[0-9][0-9] | sed -e "s/^/ shar -u /" > _flist4 cc -E -Uvax -I. doc/intro >intro.tosend sed \ -e "s/modified_on/modified_on/g" \ -e "/doc\/intro/d" \ -e "/.\/README/d" \ -e "s/NN/"`ls bignum?? | wc -l | sed -e "s/ //g"`"/g" \ -e "/^INCLUDE1/r _flist1" \ -e "/^INCLUDE2/r _flist2" \ -e "/^INCLUDE3/r _flist3" \ -e "/^INCLUDE4/r _flist4" \ -e "/^INCLUDE./d" \ <intro.tosend >>tosend $(SENDMAIL) $(SENDMAILFLAGS) $(USER) <tosend for i in `ls bignum[0-9][0-9]`; \ do cp sendmail_header tosend; \ echo $$i | sed -e "s/^bignum0*/Subject: BigNum - Part /" >>tosend; \ echo "# Remove all text above and including this line." >>tosend; \ sed -e "s/modified_on/modified_on/g" <$$i >>tosend; \ $(SENDMAIL) $(SENDMAILFLAGS) $(USER) <tosend; \ done rm -f sendmail_header tosend _flist[1-9] bignum[0-9][0-9] intro.tosend -- --Per Bothner bothner@cs.wisc.edu Computer Sciences Dept, U. of Wisconsin-Madison