forked from creachadair/imath
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
133 lines (108 loc) · 4.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
##
## Name: Makefile
## Purpose: Makefile for imath library and associated tools
## Author: M. J. Fromberger <http://spinning-yarns.org/michael/>
##
## Copyright (C) 2002-2008 Michael J. Fromberger, All Rights Reserved.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to
## deal in the Software without restriction, including without limitation the
## rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
## sell copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
## IN THE SOFTWARE.
##
# --- begin configuration section ---
## Generic settings for systems with GCC (default)
## To build with debugging, add DEBUG=Y on the "make" command line.
##
## If building under MacOS 10.1.x, use CC=cc instead.
##
CC=clang
CFLAGS+=-ansi -pedantic -Wall \
-I. $(DFLAGS$(DEBUG)) $(SIZEFLAGS$(USELLONG))
LIBFLAGS=-dynamiclib
LIBS=$(DLIBS$(DEBUG))
DFLAGS=-g -O3 -march=native -flto -fsanitize=address -fsanitize=undefined # -finline-functions
#DFLAGS=-g -O3 -march=native -flto -funroll-loops # -finline-functions
DFLAGSN=$(DFLAGS)
DFLAGSY=-g -DDEBUG=1
#DLIBS=
#DLIBSY=-lefence
SIZEFLAGS = -std=c99
SIZEFLAGSN = -std=c99
SIZEFLAGSY = $(SIZEFLAGS)
# --- end of configuration section ---
VERS=1.20
REGRESSIONS=bug-swap
TARGETS=imtest imtimer pi bintest $(REGRESSIONS)
HDRS=imath.h imrat.h iprime.h imdrover.h rsamath.h gmp_compat.h
SRCS=$(HDRS:.h=.c) $(TARGETS:=.c)
OBJS=$(SRCS:.c=.o)
OTHER=LICENSE ChangeLog Makefile doc.txt findsizes.py \
findthreshold.py imath-test.scm imath.py
VPATH += examples
EXAMPLES=basecvt findprime randprime imcalc input rounding rsakey
.PHONY: all test clean distclean dist
.c.o:
$(CC) $(CFLAGS) -c $<
all: objs examples test
objs: $(OBJS)
check: test gmp-compat-test
@ echo "Completed running imath and gmp-compat unit tests"
test: imtest pi bug-swap
@ echo ""
@ echo "Running tests, you should not see any 'FAILED' lines here."
@ echo "If you do, please see doc.txt for how to report a bug."
@ echo ""
(cd tests && ./test.sh)
gmp-compat-test: libimath.so
@ echo "Running gmp-compat unit tests"
@ echo "Printing progress after every 100,000 tests"
make -C tests/gmp-compat-test TESTS="-p 100000 random.tests"
$(EXAMPLES):%: imath.o imrat.o iprime.o %.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
$(REGRESSIONS):%: imath.o %.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
examples: $(EXAMPLES)
libimath.so: imath.o imrat.o gmp_compat.o
$(CC) $(CFLAGS) $(LIBFLAGS) -o $@ $^
imtest: imtest.o imath.o imrat.o imdrover.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
imtimer: imath.c imtimer.c
$(CC) $(CFLAGS) -D_GNU_SOURCE -DIMATH_TEST -o $@ $^ $(LIBS)
pi: pi.o imath.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
rtest: rtest.o imath.o rsamath.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
bintest: imath.o bintest.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
clean:
rm -f *.o *.pyc *~ core gmon.out tests/*~ tests/gmon.out examples/*~
make -C tests/gmp-compat-test clean
distclean: clean
rm -f $(TARGETS) imath-$(VERS).tar imath-$(VERS).tar.gz
rm -f $(EXAMPLES)
rm -f libimath.so
dist: distclean
@ echo "Packing files for distribution"
@ tar -cf imtemp.tar --exclude .svn \
$(HDRS) $(SRCS) $(OTHER) tests examples
@ mkdir imath-$(VERS)
@ (cd imath-$(VERS) && tar -xf ../imtemp.tar)
@ rm -f imtemp.tar
@ tar -cvf imath-$(VERS).tar imath-$(VERS)
@ echo "Compressing distribution file: " imath-$(VERS).tar
@ gzip -9v imath-$(VERS).tar
@ rm -rf imath-$(VERS)