132 lines · plain
1##2## Name: Makefile3## Purpose: Makefile for imath library and associated tools4## Author: M. J. Fromberger5##6## Copyright (C) 2002-2008 Michael J. Fromberger, All Rights Reserved.7##8## Permission is hereby granted, free of charge, to any person obtaining a copy9## of this software and associated documentation files (the "Software"), to10## deal in the Software without restriction, including without limitation the11## rights to use, copy, modify, merge, publish, distribute, sublicense, and/or12## sell copies of the Software, and to permit persons to whom the Software is13## furnished to do so, subject to the following conditions:14##15## The above copyright notice and this permission notice shall be included in16## all copies or substantial portions of the Software.17##18## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR19## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,20## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE21## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER22## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING23## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS24## IN THE SOFTWARE.25##26 27# --- begin configuration section ---28 29## Generic settings for systems with GCC (default)30## To build with debugging, add DEBUG=Y on the "make" command line.31ifeq ($(origin CC),default)32CC=gcc33endif34CFLAGS+=-pedantic -Wall -Werror -Wextra -Wno-unused-parameter \35 -I. -std=c99 $(DFLAGS$(DEBUG))36CSFLAGS=$(CFLAGS) -fPIC37#LIBS=38 39# These are needed to build the GMP compatibility tests.40export CC CFLAGS41 42DFLAGS=-O3 -funroll-loops -finline-functions43DFLAGSN=$(DFLAGS)44DFLAGSY=-g -DDEBUG=145 46# --- end of configuration section ---47 48TARGETS=bintest bug-swap imtest imtimer rtest49HDRS=imath.h imrat.h iprime.h imdrover.h rsamath.h gmp_compat.h50SRCS=$(HDRS:.h=.c) $(TARGETS:=.c)51OBJS=$(SRCS:.c=.o)52OTHER=LICENSE ChangeLog Makefile doc.md doc.md.in \53 tools/findthreshold.py tools/mkdoc.py .dockerignore54VPATH += examples tests55EXAMPLES=basecvt findprime imcalc input pi randprime rounding rsakey56 57.PHONY: all test clean distclean58.SUFFIXES: .so .md59 60.c.o:61 $(CC) $(CFLAGS) -c $<62 63.c.so:64 $(CC) $(CSFLAGS) -o $@ -c $<65 66all: objs examples test67 68objs: $(OBJS)69 70check: test gmp-compat-test71 @ echo "Completed running imath and gmp-compat unit tests"72 73test: imtest pi bug-swap doc.md74 @ echo ""75 @ echo "Running tests, you should not see any 'FAILED' lines here."76 @ echo "If you do, please see doc.txt for how to report a bug."77 @ echo ""78 (cd tests && ./test.sh)79 80gmp-compat-test: libimath.so81 @ echo "Running gmp-compat unit tests"82 @ echo "Printing progress after every 100,000 tests"83 make -C tests/gmp-compat-test TESTS="-p 100000 random.tests"84 85docker-test:86 if which docker ; \87 then \88 docker run --rm -it \89 "$(shell docker build -f tests/linux/Dockerfile -q .)" ; \90 fi91 92$(EXAMPLES):%: imath.o imrat.o iprime.o %.o93 $(CC) $(CFLAGS) -o $@ $^ $(LIBS)94 95$(TARGETS):%: imath.o %.o96 $(CC) $(CFLAGS) -o $@ $^ $(LIBS)97 98examples: $(EXAMPLES)99 100libimath.so: imath.so imrat.so gmp_compat.so101 $(CC) $(CFLAGS) -shared -o $@ $^102 103imtest: imtest.o imath.o imrat.o imdrover.o iprime.o104 105rtest: rtest.o imath.o rsamath.o106 107# Requires clang-format: https://clang.llvm.org/docs/ClangFormat.html108format-c:109 @ echo "Formatting C source files and headers ..."110 find . -type f -name '*.h' -o -name '*.c' -print0 | \111 xargs -0 clang-format --style=Google -i112 113# Requires yapf: pip install yapf114format-py:115 @ echo "Formatting Python source files ..."116 find . -type f -name '*.py' -print0 | \117 xargs -0 yapf --style=pep8 -i118 119# Format source files.120format: format-c format-py121 122# Generate documentation from header comments.123# This rule depends on the header files to ensure the docs get updated when the124# headers change.125doc.md: doc.md.in imath.h imrat.h tools/mkdoc.py126 tools/mkdoc.py $< $@127 128clean distclean:129 rm -f *.o *.so *.pyc *~ core gmon.out tests/*~ tests/gmon.out examples/*~130 make -C tests/gmp-compat-test clean131 rm -f $(TARGETS) $(EXAMPLES)132