1 # Mention default target.
4 # Implicit rule to compile C++ files. Modify to your taste.
6 g++ -c -O2 -Wall -Wextra -pedantic $<
8 # Components of the library.
12 BigIntegerAlgorithms.o \
13 BigUnsignedInABase.o \
20 BigIntegerAlgorithms.hh \
21 BigUnsignedInABase.hh \
22 BigIntegerLibrary.hh \
24 # To ``make the library'', make all its objects using the implicit rule.
25 library: $(library-objects)
27 # Conservatively assume that all the objects depend on all the headers.
28 $(library-objects): $(library-headers)
31 # Compiling the testsuite.
32 testsuite.o: $(library-headers)
33 testsuite: testsuite.o $(library-objects)
35 # Extract the expected output from the testsuite source.
36 testsuite.expected: testsuite.cc
37 sed -nre 's,^.*//,,p' $< >$@
40 test: testsuite testsuite.expected
41 ./testsuite >testsuite.out
42 @if diff -u testsuite.expected testsuite.out; then\
43 echo 'All tests passed.';\
45 echo >&2 'At least one test failed!'; exit 1;\
48 # The rules below build a program that uses the library. They are preset to
49 # build ``sample'' from ``sample.cc''. You can change the name(s) of the
50 # source file(s) and program file to build your own program, or you can write
53 # Components of the program.
55 program-objects = sample.o
57 # Conservatively assume all the program source files depend on all the library
58 # headers. You can change this if it is not the case.
59 $(program-objects) : $(library-headers)
61 # How to link the program. The implicit rule covers individual objects.
62 $(program) : $(program-objects) $(library-objects)
65 # Delete all generated files we know about.
67 rm -f $(library-objects) $(program-objects) $(program)
69 # I removed the *.tag dependency tracking system because it had few advantages
70 # over manually entering all the dependencies. If there were a portable,
71 # reliable dependency tracking system, I'd use it, but I know of no such;
72 # cons and depcomp are almost good enough.
74 # Come back and define default target.
75 all : library $(program)