1# 2# Makefile for MPI library 3 4# This Source Code Form is subject to the terms of the Mozilla Public 5# License, v. 2.0. If a copy of the MPL was not distributed with this 6# file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 8## Define CC to be the C compiler you wish to use. The GNU cc 9## compiler (gcc) should work, at the very least 10#CC=cc 11#CC=gcc 12 13## 14## Define PERL to point to your local Perl interpreter. It 15## should be Perl 5.x, although it's conceivable that Perl 4 16## might work ... I haven't tested it. 17## 18#PERL=/usr/bin/perl 19#PERL=perl 20 21include target.mk 22 23CFLAGS+= $(XCFLAGS) 24 25## 26## Define LIBS to include any libraries you need to link against. 27## If NO_TABLE is define, LIBS should include '-lm' or whatever is 28## necessary to bring in the math library. Otherwise, it can be 29## left alone, unless your system has other peculiar requirements. 30## 31LIBS=#-lmalloc#-lefence#-lm 32 33## 34## Define RANLIB to be the library header randomizer; you might not 35## need this on some systems (just set it to 'echo' on these systems, 36## such as IRIX) 37## 38RANLIB=echo 39 40## 41## This is the version string used for the documentation and 42## building the distribution tarball. Don't mess with it unless 43## you are releasing a new version 44VERS=1.7p6 45 46## ---------------------------------------------------------------------- 47## You probably don't need to change anything below this line... 48## 49 50## 51## This is the list of source files that need to be packed into 52## the distribution file 53SRCS= mpi.c mpprime.c mplogic.c mp_gf2m.c mpmontg.c mpi-test.c primes.c \ 54 mpcpucache.c tests/ \ 55 utils/gcd.c utils/invmod.c utils/lap.c \ 56 utils/ptab.pl utils/sieve.c utils/isprime.c\ 57 utils/dec2hex.c utils/hex2dec.c utils/bbs_rand.c \ 58 utils/bbsrand.c utils/prng.c utils/primegen.c \ 59 utils/basecvt.c utils/makeprime.c\ 60 utils/fact.c utils/exptmod.c utils/pi.c utils/metime.c \ 61 utils/mpi.h utils/mpprime.h mulsqr.c \ 62 make-test-arrays test-arrays.txt all-tests make-logtab \ 63 types.pl stats timetest multest 64 65## These are the header files that go into the distribution file 66HDRS=mpi.h mpi-config.h utils/mpi.h utils/mpi-config.h mpprime.h mplogic.h mp_gf2m.h \ 67 mp_gf2m-priv.h utils/bbs_rand.h tests/mpi.h tests/mpprime.h 68 69## These are the documentation files that go into the distribution file 70DOCS=README doc utils/README utils/PRIMES 71 72## This is the list of tools built by 'make tools' 73TOOLS=gcd invmod isprime lap dec2hex hex2dec primegen prng \ 74 basecvt fact exptmod pi makeprime identest 75 76LIBOBJS = mpprime.o mpmontg.o mplogic.o mp_gf2m.o mpi.o mpcpucache.o $(AS_OBJS) 77LIBHDRS = mpi-config.h mpi-priv.h mpi.h 78APPHDRS = mpi-config.h mpi.h mplogic.h mp_gf2m.h mpprime.h 79 80help: 81 @ echo "" 82 @ echo "The following targets can be built with this Makefile:" 83 @ echo "" 84 @ echo "libmpi.a - arithmetic and prime testing library" 85 @ echo "mpi-test - test driver (requires MP_IOFUNC)" 86 @ echo "tools - command line tools" 87 @ echo "doc - manual pages for tools" 88 @ echo "clean - clean up objects and such" 89 @ echo "distclean - get ready for distribution" 90 @ echo "dist - distribution tarball" 91 @ echo "" 92 93.SUFFIXES: .c .o .i 94 95.c.i: 96 $(CC) $(CFLAGS) -E $< > $@ 97 98#.c.o: $*.h $*.c 99# $(CC) $(CFLAGS) -c $< 100 101#--------------------------------------- 102 103$(LIBOBJS): $(LIBHDRS) 104 105logtab.h: make-logtab 106 $(PERL) make-logtab > logtab.h 107 108mpi.o: mpi.c logtab.h $(LIBHDRS) 109 110mplogic.o: mplogic.c mpi-priv.h mplogic.h $(LIBHDRS) 111 112mp_gf2m.o: mp_gf2m.c mpi-priv.h mp_gf2m.h mp_gf2m-priv.h $(LIBHDRS) 113 114mpmontg.o: mpmontg.c mpi-priv.h mplogic.h mpprime.h $(LIBHDRS) 115 116mpprime.o: mpprime.c mpi-priv.h mpprime.h mplogic.h primes.c $(LIBHDRS) 117 118mpcpucache.o: mpcpucache.c $(LIBHDRS) 119 120mpi_mips.o: mpi_mips.s 121 $(CC) -o $@ $(ASFLAGS) -c mpi_mips.s 122 123mpi_sparc.o : montmulf.h 124 125mpv_sparcv9.s: vis_64.il mpv_sparc.c 126 $(CC) -o $@ $(SOLARIS_FPU_FLAGS) -S vis_64.il mpv_sparc.c 127 128mpv_sparcv8.s: vis_64.il mpv_sparc.c 129 $(CC) -o $@ $(SOLARIS_FPU_FLAGS) -S vis_32.il mpv_sparc.c 130 131montmulfv8.o montmulfv9.o mpv_sparcv8.o mpv_sparcv9.o : %.o : %.s 132 $(CC) -o $@ $(SOLARIS_ASM_FLAGS) -c $< 133 134mpi_arm.o: mpi_arm.c $(LIBHDRS) 135 136# This rule is used to build the .s sources, which are then hand optimized. 137#montmulfv8.s montmulfv9.s : montmulf%.s : montmulf%.il montmulf.c montmulf.h 138# $(CC) -o $@ $(SOLARIS_ASM_FLAGS) -S montmulf$*.il montmulf.c 139 140 141libmpi.a: $(LIBOBJS) 142 ar -cvr libmpi.a $(LIBOBJS) 143 $(RANLIB) libmpi.a 144 145lib libs: libmpi.a 146 147mpi.i: mpi.h 148 149#--------------------------------------- 150 151MPTESTOBJS = mptest1.o mptest2.o mptest3.o mptest3a.o mptest4.o mptest4a.o \ 152 mptest4b.o mptest6.o mptest7.o mptest8.o mptest9.o mptestb.o 153MPTESTS = $(MPTESTOBJS:.o=) 154 155$(MPTESTOBJS): mptest%.o: tests/mptest-%.c $(LIBHDRS) 156 $(CC) $(CFLAGS) -o $@ -c $< 157 158$(MPTESTS): mptest%: mptest%.o libmpi.a 159 $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 160 161tests: mptest1 mptest2 mptest3 mptest3a mptest4 mptest4a mptest4b mptest6 \ 162 mptestb bbsrand 163 164utests: mptest7 mptest8 mptest9 165 166#--------------------------------------- 167 168EXTRAOBJS = bbsrand.o bbs_rand.o prng.o 169UTILOBJS = primegen.o metime.o identest.o basecvt.o fact.o exptmod.o pi.o \ 170 makeprime.o gcd.o invmod.o lap.o isprime.o \ 171 dec2hex.o hex2dec.o 172UTILS = $(UTILOBJS:.o=) 173 174$(UTILS): % : %.o libmpi.a 175 $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 176 177$(UTILOBJS) $(EXTRAOBJS): %.o : utils/%.c $(LIBHDRS) 178 $(CC) $(CFLAGS) -o $@ -c $< 179 180prng: prng.o bbs_rand.o libmpi.a 181 $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 182 183bbsrand: bbsrand.o bbs_rand.o libmpi.a 184 $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 185 186utils: $(UTILS) prng bbsrand 187 188#--------------------------------------- 189 190test-info.c: test-arrays.txt 191 $(PERL) make-test-arrays test-arrays.txt > test-info.c 192 193mpi-test.o: mpi-test.c test-info.c $(LIBHDRS) 194 $(CC) $(CFLAGS) -o $@ -c $< 195 196mpi-test: mpi-test.o libmpi.a 197 $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 198 199mdxptest.o: mdxptest.c $(LIBHDRS) mpi-priv.h 200 201mdxptest: mdxptest.o libmpi.a 202 $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 203 204mulsqr.o: mulsqr.c logtab.h mpi.h mpi-config.h mpprime.h 205 $(CC) $(CFLAGS) -DMP_SQUARE=1 -o $@ -c mulsqr.c 206 207mulsqr: mulsqr.o libmpi.a 208 $(CC) $(CFLAGS) -o $@ $^ $(LIBS) 209 210#--------------------------------------- 211 212alltests: tests utests mpi-test 213 214tools: $(TOOLS) 215 216doc: 217 (cd doc; ./build) 218 219clean: 220 rm -f *.o *.a *.i 221 rm -f core 222 rm -f *~ .*~ 223 rm -f utils/*.o 224 rm -f utils/core 225 rm -f utils/*~ utils/.*~ 226 227clobber: clean 228 rm -f $(TOOLS) $(UTILS) 229 230distclean: clean 231 rm -f mptest? mpi-test metime mulsqr karatsuba 232 rm -f mptest?a mptest?b 233 rm -f utils/mptest? 234 rm -f test-info.c logtab.h 235 rm -f libmpi.a 236 rm -f $(TOOLS) 237 238dist: Makefile $(HDRS) $(SRCS) $(DOCS) 239 tar -cvf mpi-$(VERS).tar Makefile $(HDRS) $(SRCS) $(DOCS) 240 pgps -ab mpi-$(VERS).tar 241 chmod +r mpi-$(VERS).tar.asc 242 gzip -9 mpi-$(VERS).tar 243 244# END 245