Commit | Line | Data |
---|---|---|
918d66f2 | 1 | # Mention default target. |
0afe80d5 | 2 | all: |
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 |
9 | library-objects = \ |
10 | BigUnsigned.o \ | |
11 | BigInteger.o \ | |
12 | BigIntegerAlgorithms.o \ | |
13 | BigUnsignedInABase.o \ | |
14 | BigIntegerUtils.o \ | |
15 | ||
16 | library-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 |
25 | library: $(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. |
32 | testsuite.o: $(library-headers) | |
33 | testsuite: testsuite.o $(library-objects) | |
34 | g++ $^ -o $@ | |
35 | # Extract the expected output from the testsuite source. | |
36 | testsuite.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 | |
40 | test: testsuite testsuite.expected | |
706f6a7e | 41 | ./run-testsuite |
7f07d1d6 MM |
42 | testsuite-cleanfiles = \ |
43 | testsuite.o testsuite testsuite.expected \ | |
44 | testsuite.out testsuite.err | |
e67d6049 | 45 | |
918d66f2 MM |
46 | # The rules below build a program that uses the library. They are preset to |
47 | # build ``sample'' from ``sample.cc''. You can change the name(s) of the | |
48 | # source file(s) and program file to build your own program, or you can write | |
49 | # your own Makefile. | |
a8b42b68 | 50 | |
918d66f2 MM |
51 | # Components of the program. |
52 | program = sample | |
53 | program-objects = sample.o | |
e67d6049 | 54 | |
918d66f2 MM |
55 | # Conservatively assume all the program source files depend on all the library |
56 | # headers. You can change this if it is not the case. | |
57 | $(program-objects) : $(library-headers) | |
e67d6049 | 58 | |
918d66f2 MM |
59 | # How to link the program. The implicit rule covers individual objects. |
60 | $(program) : $(program-objects) $(library-objects) | |
0afe80d5 | 61 | g++ $^ -o $@ |
918d66f2 MM |
62 | |
63 | # Delete all generated files we know about. | |
05780f4b | 64 | clean : |
7f07d1d6 | 65 | rm -f $(library-objects) $(testsuite-cleanfiles) $(program-objects) $(program) |
e67d6049 | 66 | |
918d66f2 MM |
67 | # I removed the *.tag dependency tracking system because it had few advantages |
68 | # over manually entering all the dependencies. If there were a portable, | |
69 | # reliable dependency tracking system, I'd use it, but I know of no such; | |
70 | # cons and depcomp are almost good enough. | |
71 | ||
72 | # Come back and define default target. | |
73 | all : library $(program) |