home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / crypl200.zip / BNLIB / MAKEFILE.IN < prev    next >
Text File  |  1996-01-28  |  6KB  |  169 lines

  1. #
  2. # This code is pretty well tested, but not optimizing it will have
  3. # a *major* effect on speed, so its optimzation flags are separate
  4. # from the rest of the release.
  5. #
  6. # For the SPARC v8, at least, gcc produces a *much* faster library than
  7. # the SunPro C compiler.  On a 50 MHz TI TMS390Z50 SuperSPARC:
  8. #  14.5 vs.   47.2 ms per  256-bit modular exponentiation.
  9. #  77.4 vs.  317.8 ms per  512-bit modular exponentiation.
  10. # 249.0 vs. 1031.5 ms per 1024-bit modular exponentiation
  11. #
  12. CC=@CC@
  13. CFLAGS=@CFLAGS@ @CPPFLAGS@ @WARN@ @TUNE@ @DEFS@ $(DEFINE)
  14. srcdir=@srcdir@
  15. VPATH=@srcdir@
  16.  
  17. # Extra object files (e.g. assembly routines)
  18. OBJS_EXT=
  19. # Extra definitions (e.g. -DBNINCLUDE=lbnfoo.h)
  20. DEFINE=
  21.  
  22. SHELL = /bin/sh
  23. .SUFFIXES:
  24. .SUFFIXES: .c .h .o
  25.  
  26. LD      =$(CC)
  27. LDFLAGS    =@LDFLAGS@
  28. LIBS_EXT=@LIBS@
  29. RANLIB=@RANLIB@
  30.  
  31. # If you plug in a machine-specific assembly file, change this list
  32. # of files here.
  33. OBJS    = bn00.o lbn00.o bn.o lbnmem.o sieve.o prime.o \
  34.       bnprint.o legal.o jacobi.o germain.o
  35.  
  36. BNLIB    = libbn.a 
  37.  
  38. all: $(BNLIB) bntest germtest
  39.  
  40. check: bntest
  41.     ./bntest
  42.  
  43. bntest: bntest00.o $(BNLIB)
  44.     $(LD) $(LDFLAGS) -o $@ bntest00.o $(BNLIB) $(LIBS_EXT)
  45.  
  46. germtest: germtest.o $(BNLIB)
  47.     $(LD) $(LDFLAGS) -o $@ germtest.o $(BNLIB) $(LIBS_EXT)
  48.  
  49. $(BNLIB): $(OBJS)
  50.     $(AR) r $@ $?
  51.     $(RANLIB) $@
  52.  
  53. # Here we get tricky... if we're compiling with GCC, then we actually do
  54. # a link, but with the -r flag (produce relocatable output) and with
  55. # -lgcc *only*.  This is so that the result can be linked cleanly with
  56. # code compiled with another cc, which doesn't know about -lgcc.
  57. # Presumably the lbnXX.o file, which has by fast the most math in it,
  58. # will have a call to every interesting support-library function.
  59.  
  60. lbn00.o: $(srcdir)/lbn00.c $(HDRS) config.h
  61.     $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ @GCCMAGIC1@ lbn00.c @GCCMAGIC2@
  62.  
  63. lbn16.o: $(srcdir)/lbn16.c $(HDRS) config.h
  64.     $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ @GCCMAGIC1@ lbn16.c @GCCMAGIC2@
  65.  
  66. lbn32.o: $(srcdir)/lbn32.c $(HDRS) config.h
  67.     $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ @GCCMAGIC1@ lbn32.c @GCCMAGIC2@
  68.  
  69. lbn64.o: $(srcdir)/lbn64.c $(HDRS) config.h
  70.     $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ @GCCMAGIC1@ lbn64.c @GCCMAGIC2@
  71.  
  72. # The default .o rule.
  73. .c.o: config.h
  74.     $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ -c $<
  75.  
  76. # Extra, non-obvious dependencies.  The BigNum library can be compiled
  77. # in three word sizes, and the *00.c files #include the right .c files
  78. # based on <limits.h>, which means that a single compilation will
  79. # only use a subset of these files.  Duplicated here in case someone
  80. # regenerates dependencies with cc -M and they get lost.
  81.  
  82. lbn00.o: lbn16.c lbn32.c lbn64.c lbn16.h lbn32.h lbn64.h 
  83. bn00.o: bn16.c bn32.c bn64.c bn16.h bn32.h bn64.h \
  84.   bninit16.c bninit32.c bninit64.c
  85. bntest00.o: bntest16.c bntest32.c bntest64.c lbn16.h lbn32.h lbn64.h
  86.  
  87. # Actual build commented out to prevent confusion by people without autoconf
  88. # Do it manually for now.
  89. configure: configure.in
  90. #    autoconf
  91.  
  92. # Example programs in the test subdirectory.
  93. progs: $(U_DIR)/libbn.a
  94.     @(echo Compiling test drivers for bn)
  95.     cd test; make
  96.  
  97. clean:
  98.     @$(RM) -f *.o *32.[ch] *64.[ch]
  99.  
  100. BNSOURCES = lbn32.c lbn32.h bn32.c bn32.h bninit32.c bntest32.c \
  101.     lbn64.c lbn64.h bn64.c bn64.h bninit64.c bntest64.c
  102.  
  103. # An explicit target that can be made before distribution for
  104. # machines that don't have sed.
  105. bnsources: $(BNSOURCES)
  106.  
  107. # The 16-bit versions of the code are the master versions; all else is
  108. # generated from them.  This fiddling about makes them unwriteable
  109. # to discourage improper edits.
  110.  
  111. # (You didn't know that suffix rules didn't have to begin with a
  112. # period, did you?)
  113. .SUFFIXES: 16.c 16.h 32.c 32.h 64.c 64.h
  114. 16.c32.c:
  115.     @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@
  116.     sed -e s/32/64/g -e s/16/32/g $< > $@
  117.     @chmod a-w $@
  118.  
  119. 16.h32.h:
  120.     @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@
  121.     sed -e s/32/64/g -e s/16/32/g $< > $@
  122.     @chmod a-w $@
  123.  
  124. 16.c64.c:
  125.     @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@
  126.     sed -e s/32/128/g -e s/16/64/g $< > $@
  127.     @chmod a-w $@
  128.  
  129. 16.h64.h:
  130.     @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@
  131.     sed -e s/32/128/g -e s/16/64/g $< > $@
  132.     @chmod a-w $@
  133.  
  134. ### Dependencies
  135. bn.o: bn.c bn.h
  136. bn00.o: bn00.c bnsize00.h lbn.h bn16.c bn32.c bn64.c lbn16.c lbn32.h \
  137.   lbn64.h lbnmem.h bn16.h bn32.h bn64.h bn.h kludge.h bninit16.c \
  138.   bninit32.c bninit64.c
  139. bn16.o: bn16.c lbn.h lbn16.h lbnmem.h bn16.h bn.h kludge.h
  140. bn32.o: bn32.c lbn.h lbn32.h lbnmem.h bn32.h bn.h kludge.h
  141. bn64.o: bn64.c lbn.h lbn64.h lbnmem.h bn64.h bn.h kludge.h
  142. bn68000.o: bn68000.c lbn.h lbn68000.h bn16.h bn32.h
  143. bn8086.o: bn8086.c lbn.h bn64.h lbn8086.h bn32.h
  144. bninit16.o: bninit16.c bn.h bn16.h
  145. bninit32.o: bninit32.c bn.h bn32.h
  146. bninit64.o: bninit64.c bn.h bn64.h
  147. bnprint.o: bnprint.c bn.h bnprint.h kludge.h
  148. bntest00.o: bntest00.c bnsize00.h lbn.h bntest16.c bntest32.c \
  149.   bntest64.c cputime.h lbn16.h lbn32.h lbn64.h kludge.h
  150. bntest16.o: bntest16.c cputime.h lbn16.h lbn.h kludge.h
  151. bntest32.o: bntest32.c cputime.h lbn32.h lbn.h kludge.h
  152. bntest64.o: bntest64.c cputime.h lbn64.h lbn.h kludge.h
  153. germain.o: germain.c bn.h germain.h jacobi.h lbnmem.h sieve.h kludge.h
  154. germtest.o: germtest.c bn.h germain.h sieve.h cputime.h bnprint.h
  155. jacobi.o: jacobi.c bn.h jacobi.h
  156. lbn00.o: lbn00.c bnsize00.h lbn.h lbn16.c lbn16.h lbn32.c lbn32.h \
  157.   lbn64.c lbn64.h lbnmem.h legal.h kludge.h
  158. lbn16.o: lbn16.c lbn.h lbn16.h lbnmem.h legal.h kludge.h
  159. lbn32.o: lbn32.c lbn.h lbn32.h lbnmem.h legal.h kludge.h
  160. lbn64.o: lbn64.c lbn.h lbn64.h lbnmem.h legal.h kludge.h
  161. lbn68000.o: lbn68000.c lbn.h lbn68000.h
  162. lbn68020.o: lbn68020.c lbn.h lbn68020.h
  163. lbnmem.o: lbnmem.c lbn.h lbnmem.h kludge.h
  164. lbnppc.o: lbnppc.c lbnppc.h ppcasm.h
  165. legal.o: legal.c legal.h
  166. prime.o: prime.c bn.h lbnmem.h prime.h sieve.h kludge.h
  167. sieve.o: sieve.c bn.h sieve.h kludge.h
  168. sizetest.c: bnsize00.h
  169.