2
# Makefile for MPI library
4
# ***** BEGIN LICENSE BLOCK *****
5
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
7
# The contents of this file are subject to the Mozilla Public License Version
8
# 1.1 (the "License"); you may not use this file except in compliance with
9
# the License. You may obtain a copy of the License at
10
# http://www.mozilla.org/MPL/
12
# Software distributed under the License is distributed on an "AS IS" basis,
13
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
# for the specific language governing rights and limitations under the
17
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
19
# The Initial Developer of the Original Code is
20
# Michael J. Fromberger <sting@linguist.dartmouth.edu>.
21
# Portions created by the Initial Developer are Copyright (C) 1998
22
# the Initial Developer. All Rights Reserved.
25
# Netscape Communications Corporation
26
# Richard C. Swift (swift@netscape.com)
27
# Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
29
# Alternatively, the contents of this file may be used under the terms of
30
# either the GNU General Public License Version 2 or later (the "GPL"), or
31
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32
# in which case the provisions of the GPL or the LGPL are applicable instead
33
# of those above. If you wish to allow use of your version of this file only
34
# under the terms of either the GPL or the LGPL, and not to allow others to
35
# use your version of this file under the terms of the MPL, indicate your
36
# decision by deleting the provisions above and replace them with the notice
37
# and other provisions required by the GPL or the LGPL. If you do not delete
38
# the provisions above, a recipient may use your version of this file under
39
# the terms of any one of the MPL, the GPL or the LGPL.
41
# ***** END LICENSE BLOCK *****
44
# $Id: Makefile,v 1.22.2.1 2006/03/03 04:17:49 nelson%bolyard.com Exp $
47
## Define CC to be the C compiler you wish to use. The GNU cc
48
## compiler (gcc) should work, at the very least
53
## Define PERL to point to your local Perl interpreter. It
54
## should be Perl 5.x, although it's conceivable that Perl 4
55
## might work ... I haven't tested it.
65
## Define LIBS to include any libraries you need to link against.
66
## If NO_TABLE is define, LIBS should include '-lm' or whatever is
67
## necessary to bring in the math library. Otherwise, it can be
68
## left alone, unless your system has other peculiar requirements.
70
LIBS=#-lmalloc#-lefence#-lm
73
## Define RANLIB to be the library header randomizer; you might not
74
## need this on some systems (just set it to 'echo' on these systems,
80
## This is the version string used for the documentation and
81
## building the distribution tarball. Don't mess with it unless
82
## you are releasing a new version
85
## ----------------------------------------------------------------------
86
## You probably don't need to change anything below this line...
90
## This is the list of source files that need to be packed into
91
## the distribution file
92
SRCS= mpi.c mpprime.c mplogic.c mp_gf2m.c mpmontg.c mpi-test.c primes.c \
94
utils/gcd.c utils/invmod.c utils/lap.c \
95
utils/ptab.pl utils/sieve.c utils/isprime.c\
96
utils/dec2hex.c utils/hex2dec.c utils/bbs_rand.c \
97
utils/bbsrand.c utils/prng.c utils/primegen.c \
98
utils/basecvt.c utils/makeprime.c\
99
utils/fact.c utils/exptmod.c utils/pi.c utils/metime.c \
100
utils/mpi.h utils/mpprime.h mulsqr.c \
101
make-test-arrays test-arrays.txt all-tests make-logtab \
102
types.pl stats timetest multest
104
## These are the header files that go into the distribution file
105
HDRS=mpi.h mpi-config.h utils/mpi.h utils/mpi-config.h mpprime.h mplogic.h mp_gf2m.h \
106
mp_gf2m-priv.h utils/bbs_rand.h tests/mpi.h tests/mpprime.h
108
## These are the documentation files that go into the distribution file
109
DOCS=README doc utils/README utils/PRIMES
111
## This is the list of tools built by 'make tools'
112
TOOLS=gcd invmod isprime lap dec2hex hex2dec primegen prng \
113
basecvt fact exptmod pi makeprime identest
115
LIBOBJS = mpprime.o mpmontg.o mplogic.o mp_gf2m.o mpi.o mpcpucache.o $(AS_OBJS)
116
LIBHDRS = mpi-config.h mpi-priv.h mpi.h
117
APPHDRS = mpi-config.h mpi.h mplogic.h mp_gf2m.h mpprime.h
121
@ echo "The following targets can be built with this Makefile:"
123
@ echo "libmpi.a - arithmetic and prime testing library"
124
@ echo "mpi-test - test driver (requires MP_IOFUNC)"
125
@ echo "tools - command line tools"
126
@ echo "doc - manual pages for tools"
127
@ echo "clean - clean up objects and such"
128
@ echo "distclean - get ready for distribution"
129
@ echo "dist - distribution tarball"
135
$(CC) $(CFLAGS) -E $< > $@
138
# $(CC) $(CFLAGS) -c $<
140
#---------------------------------------
142
$(LIBOBJS): $(LIBHDRS)
144
logtab.h: make-logtab
145
$(PERL) make-logtab > logtab.h
147
mpi.o: mpi.c logtab.h $(LIBHDRS)
149
mplogic.o: mplogic.c mpi-priv.h mplogic.h $(LIBHDRS)
151
mp_gf2m.o: mp_gf2m.c mpi-priv.h mp_gf2m.h mp_gf2m-priv.h $(LIBHDRS)
153
mpmontg.o: mpmontg.c mpi-priv.h mplogic.h mpprime.h $(LIBHDRS)
155
mpprime.o: mpprime.c mpi-priv.h mpprime.h mplogic.h primes.c $(LIBHDRS)
157
mpcpucache.o: mpcpucache.c $(LIBHDRS)
159
mpi_mips.o: mpi_mips.s
160
$(CC) -o $@ $(ASFLAGS) -c mpi_mips.s
162
mpi_sparc.o : montmulf.h
164
mpv_sparcv9.s: vis_64.il mpv_sparc.c
165
$(CC) -o $@ $(SOLARIS_FPU_FLAGS) -S vis_64.il mpv_sparc.c
167
mpv_sparcv8.s: vis_64.il mpv_sparc.c
168
$(CC) -o $@ $(SOLARIS_FPU_FLAGS) -S vis_32.il mpv_sparc.c
170
montmulfv8.o montmulfv9.o mpv_sparcv8.o mpv_sparcv9.o : %.o : %.s
171
$(CC) -o $@ $(SOLARIS_ASM_FLAGS) -c $<
173
# This rule is used to build the .s sources, which are then hand optimized.
174
#montmulfv8.s montmulfv9.s : montmulf%.s : montmulf%.il montmulf.c montmulf.h
175
# $(CC) -o $@ $(SOLARIS_ASM_FLAGS) -S montmulf$*.il montmulf.c
179
ar -cvr libmpi.a $(LIBOBJS)
186
#---------------------------------------
188
MPTESTOBJS = mptest1.o mptest2.o mptest3.o mptest3a.o mptest4.o mptest4a.o \
189
mptest4b.o mptest6.o mptest7.o mptest8.o mptest9.o mptestb.o
190
MPTESTS = $(MPTESTOBJS:.o=)
192
$(MPTESTOBJS): mptest%.o: tests/mptest-%.c $(LIBHDRS)
193
$(CC) $(CFLAGS) -o $@ -c $<
195
$(MPTESTS): mptest%: mptest%.o libmpi.a
196
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
198
tests: mptest1 mptest2 mptest3 mptest3a mptest4 mptest4a mptest4b mptest6 \
201
utests: mptest7 mptest8 mptest9
203
#---------------------------------------
205
EXTRAOBJS = bbsrand.o bbs_rand.o prng.o
206
UTILOBJS = primegen.o metime.o identest.o basecvt.o fact.o exptmod.o pi.o \
207
makeprime.o gcd.o invmod.o lap.o isprime.o \
209
UTILS = $(UTILOBJS:.o=)
211
$(UTILS): % : %.o libmpi.a
212
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
214
$(UTILOBJS) $(EXTRAOBJS): %.o : utils/%.c $(LIBHDRS)
215
$(CC) $(CFLAGS) -o $@ -c $<
217
prng: prng.o bbs_rand.o libmpi.a
218
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
220
bbsrand: bbsrand.o bbs_rand.o libmpi.a
221
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
223
utils: $(UTILS) prng bbsrand
225
#---------------------------------------
227
test-info.c: test-arrays.txt
228
$(PERL) make-test-arrays test-arrays.txt > test-info.c
230
mpi-test.o: mpi-test.c test-info.c $(LIBHDRS)
231
$(CC) $(CFLAGS) -o $@ -c $<
233
mpi-test: mpi-test.o libmpi.a
234
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
236
mdxptest.o: mdxptest.c $(LIBHDRS) mpi-priv.h
238
mdxptest: mdxptest.o libmpi.a
239
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
241
mulsqr.o: mulsqr.c logtab.h mpi.h mpi-config.h mpprime.h
242
$(CC) $(CFLAGS) -DMP_SQUARE=1 -o $@ -c mulsqr.c
244
mulsqr: mulsqr.o libmpi.a
245
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
247
#---------------------------------------
249
alltests: tests utests mpi-test
262
rm -f utils/*~ utils/.*~
265
rm -f $(TOOLS) $(UTILS)
268
rm -f mptest? mpi-test metime mulsqr karatsuba
269
rm -f mptest?a mptest?b
271
rm -f test-info.c logtab.h
275
dist: Makefile $(HDRS) $(SRCS) $(DOCS)
276
tar -cvf mpi-$(VERS).tar Makefile $(HDRS) $(SRCS) $(DOCS)
277
pgps -ab mpi-$(VERS).tar
278
chmod +r mpi-$(VERS).tar.asc
279
gzip -9 mpi-$(VERS).tar