X-Git-Url: https://mattmccutchen.net/bigint/bigint.git/blobdiff_plain/918d66f23e6b2528010db6f121e229f488fe3410..7f07d1d6bfa8629106c93c1d9641d2713460ac84:/Makefile diff --git a/Makefile b/Makefile index c99cf54..3018e98 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,47 @@ -# -# Matt McCutchen's Big Integer Library -# http://hashproduct.metaesthetics.net/bigint/ -# - # Mention default target. -all : +all: # Implicit rule to compile C++ files. Modify to your taste. -%.o : %.cc - g++ -c -O -Wall -Wextra -pedantic $< +%.o: %.cc + g++ -c -O2 -Wall -Wextra -pedantic $< # Components of the library. -library-objects = BigUnsigned.o BigInteger.o BigUnsignedInABase.o BigIntegerUtils.o -library-headers = NumberlikeArray.hh BigUnsigned.hh BigUnsignedInABase.hh BigInteger.hh BigIntegerLibrary.hh +library-objects = \ + BigUnsigned.o \ + BigInteger.o \ + BigIntegerAlgorithms.o \ + BigUnsignedInABase.o \ + BigIntegerUtils.o \ + +library-headers = \ + NumberlikeArray.hh \ + BigUnsigned.hh \ + BigInteger.hh \ + BigIntegerAlgorithms.hh \ + BigUnsignedInABase.hh \ + BigIntegerLibrary.hh \ # To ``make the library'', make all its objects using the implicit rule. -library : $(library-objects) +library: $(library-objects) + +# Conservatively assume that all the objects depend on all the headers. +$(library-objects): $(library-headers) -# Extra dependencies from `#include'. -BigUnsigned.o : NumberlikeArray.hh BigUnsigned.hh -BigInteger.o : NumberlikeArray.hh BigUnsigned.hh BigInteger.hh -BigUnsignedInABase.o : NumberlikeArray.hh BigUnsigned.hh BigUnsignedInABase.hh -BigIntegerUtils.o : NumberlikeArray.hh BigUnsigned.hh BigUnsignedInABase.hh BigInteger.hh +# TESTSUITE (NOTE: Currently expects a 32-bit system) +# Compiling the testsuite. +testsuite.o: $(library-headers) +testsuite: testsuite.o $(library-objects) + g++ $^ -o $@ +# Extract the expected output from the testsuite source. +testsuite.expected: testsuite.cc + nl -ba -p -s: $< | sed -nre 's,^ +([0-9]+):.*//([^ ]),Line \1: \2,p' >$@ +# Run the testsuite. +.PHONY: test +test: testsuite testsuite.expected + ./run-testsuite +testsuite-cleanfiles = \ + testsuite.o testsuite testsuite.expected \ + testsuite.out testsuite.err # The rules below build a program that uses the library. They are preset to # build ``sample'' from ``sample.cc''. You can change the name(s) of the @@ -38,11 +58,11 @@ $(program-objects) : $(library-headers) # How to link the program. The implicit rule covers individual objects. $(program) : $(program-objects) $(library-objects) - g++ $(program-objects) $(library-objects) -o $(program) + g++ $^ -o $@ # Delete all generated files we know about. clean : - rm -f $(library-objects) $(program-objects) $(program) + rm -f $(library-objects) $(testsuite-cleanfiles) $(program-objects) $(program) # I removed the *.tag dependency tracking system because it had few advantages # over manually entering all the dependencies. If there were a portable,