Add more clearly visible section headers to testsuite.cc.
[bigint/bigint.git] / Makefile
CommitLineData
918d66f2 1# Mention default target.
0afe80d5 2all:
918d66f2
MM
3
4# Implicit rule to compile C++ files. Modify to your taste.
0afe80d5 5%.o: %.cc
ef2b7c59 6 g++ -c -O2 -Wall -Wextra -pedantic $<
e67d6049 7
918d66f2 8# Components of the library.
0afe80d5
MM
9library-objects = \
10 BigUnsigned.o \
11 BigInteger.o \
12 BigIntegerAlgorithms.o \
13 BigUnsignedInABase.o \
14 BigIntegerUtils.o \
15
16library-headers = \
17 NumberlikeArray.hh \
18 BigUnsigned.hh \
19 BigInteger.hh \
20 BigIntegerAlgorithms.hh \
21 BigUnsignedInABase.hh \
22 BigIntegerLibrary.hh \
918d66f2
MM
23
24# To ``make the library'', make all its objects using the implicit rule.
0afe80d5
MM
25library: $(library-objects)
26
27# Conservatively assume that all the objects depend on all the headers.
28$(library-objects): $(library-headers)
918d66f2 29
e6866cd0 30# TESTSUITE (NOTE: Currently expects a 32-bit system)
0afe80d5
MM
31# Compiling the testsuite.
32testsuite.o: $(library-headers)
33testsuite: testsuite.o $(library-objects)
34 g++ $^ -o $@
35# Extract the expected output from the testsuite source.
36testsuite.expected: testsuite.cc
e6866cd0 37 nl -ba -p -s: $< | sed -nre 's,^ +([0-9]+):.*//([^ ]),Line \1: \2,p' >$@
0afe80d5
MM
38# Run the testsuite.
39.PHONY: test
40test: testsuite testsuite.expected
706f6a7e 41 ./run-testsuite
e67d6049 42
918d66f2
MM
43# The rules below build a program that uses the library. They are preset to
44# build ``sample'' from ``sample.cc''. You can change the name(s) of the
45# source file(s) and program file to build your own program, or you can write
46# your own Makefile.
a8b42b68 47
918d66f2
MM
48# Components of the program.
49program = sample
50program-objects = sample.o
e67d6049 51
918d66f2
MM
52# Conservatively assume all the program source files depend on all the library
53# headers. You can change this if it is not the case.
54$(program-objects) : $(library-headers)
e67d6049 55
918d66f2
MM
56# How to link the program. The implicit rule covers individual objects.
57$(program) : $(program-objects) $(library-objects)
0afe80d5 58 g++ $^ -o $@
918d66f2
MM
59
60# Delete all generated files we know about.
05780f4b 61clean :
918d66f2 62 rm -f $(library-objects) $(program-objects) $(program)
e67d6049 63
918d66f2
MM
64# I removed the *.tag dependency tracking system because it had few advantages
65# over manually entering all the dependencies. If there were a portable,
66# reliable dependency tracking system, I'd use it, but I know of no such;
67# cons and depcomp are almost good enough.
68
69# Come back and define default target.
70all : library $(program)