|
8 | 8 | # You may select, at your option, one of the above-listed licenses.
|
9 | 9 | # ################################################################
|
10 | 10 |
|
11 |
| -# This Makefile presumes libzstd is installed, using `sudo make install` |
| 11 | +LIBDIR =../lib |
| 12 | +CPPFLAGS += -I$(LIBDIR) |
| 13 | +LIB = $(LIBDIR)/libzstd.a |
12 | 14 |
|
13 |
| -CPPFLAGS += -I../lib |
14 |
| -LIB = ../lib/libzstd.a |
15 |
| - |
16 |
| -.PHONY: default all clean test |
17 | 15 |
|
| 16 | +.PHONY: default |
18 | 17 | default: all
|
19 | 18 |
|
| 19 | +.PHONY: all |
20 | 20 | all: simple_compression simple_decompression \
|
21 | 21 | multiple_simple_compression\
|
22 | 22 | dictionary_compression dictionary_decompression \
|
23 | 23 | streaming_compression streaming_decompression \
|
24 | 24 | multiple_streaming_compression streaming_memory_usage
|
25 | 25 |
|
26 | 26 | $(LIB) :
|
27 |
| - $(MAKE) -C ../lib libzstd.a |
| 27 | + $(MAKE) -C $(LIBDIR) libzstd.a |
| 28 | + |
| 29 | +simple_compression.o: common.h |
| 30 | +simple_compression : $(LIB) |
28 | 31 |
|
29 |
| -simple_compression : simple_compression.c common.h $(LIB) |
30 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 32 | +simple_decompression.o: common.h |
| 33 | +simple_decompression : $(LIB) |
31 | 34 |
|
32 |
| -simple_decompression : simple_decompression.c common.h $(LIB) |
33 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 35 | +multiple_simple_compression.o: common.h |
| 36 | +multiple_simple_compression : $(LIB) |
34 | 37 |
|
35 |
| -multiple_simple_compression : multiple_simple_compression.c common.h $(LIB) |
36 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 38 | +dictionary_compression.o: common.h |
| 39 | +dictionary_compression : $(LIB) |
37 | 40 |
|
38 |
| -dictionary_compression : dictionary_compression.c common.h $(LIB) |
39 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 41 | +dictionary_decompression.o: common.h |
| 42 | +dictionary_decompression : $(LIB) |
40 | 43 |
|
41 |
| -dictionary_decompression : dictionary_decompression.c common.h $(LIB) |
42 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 44 | +streaming_compression.o: common.h |
| 45 | +streaming_compression : $(LIB) |
43 | 46 |
|
44 |
| -streaming_compression : streaming_compression.c common.h $(LIB) |
45 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 47 | +multiple_streaming_compression.o: common.h |
| 48 | +multiple_streaming_compression : $(LIB) |
46 | 49 |
|
47 |
| -multiple_streaming_compression : multiple_streaming_compression.c common.h $(LIB) |
48 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 50 | +streaming_decompression.o: common.h |
| 51 | +streaming_decompression : $(LIB) |
49 | 52 |
|
50 |
| -streaming_decompression : streaming_decompression.c common.h $(LIB) |
51 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
| 53 | +streaming_memory_usage.o: common.h |
| 54 | +streaming_memory_usage : $(LIB) |
52 | 55 |
|
53 |
| -streaming_memory_usage : streaming_memory_usage.c $(LIB) |
54 |
| - $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ |
55 | 56 |
|
| 57 | +.PHONY:clean |
56 | 58 | clean:
|
57 |
| - @rm -f core *.o tmp* result* *.zst \ |
| 59 | + @$(RM) core *.o tmp* result* *.zst \ |
58 | 60 | simple_compression simple_decompression \
|
59 | 61 | multiple_simple_compression \
|
60 | 62 | dictionary_compression dictionary_decompression \
|
61 | 63 | streaming_compression streaming_decompression \
|
62 | 64 | multiple_streaming_compression streaming_memory_usage
|
63 | 65 | @echo Cleaning completed
|
64 | 66 |
|
| 67 | +.PHONY:test |
65 | 68 | test: all
|
66 | 69 | cp README.md tmp
|
67 | 70 | cp Makefile tmp2
|
|
0 commit comments