Skip to content

Commit d387772

Browse files
authored
Merge pull request #2427 from facebook/example_compile
streamlined example recipe
2 parents 6899855 + ecffa77 commit d387772

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ automated_benchmarking:
101101
.PHONY: benchmarking
102102
benchmarking: automated_benchmarking
103103

104-
## examples: build all examples in `/examples` directory
104+
## examples: build all examples in `examples/` directory
105105
.PHONY: examples
106106
examples: lib
107-
CPPFLAGS=-I../lib LDFLAGS=-L../lib $(MAKE) -C examples/ all
107+
$(MAKE) -C examples all
108108

109109
## manual: generate API documentation in html format
110110
.PHONY: manual

examples/Makefile

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,63 @@
88
# You may select, at your option, one of the above-listed licenses.
99
# ################################################################
1010

11-
# This Makefile presumes libzstd is installed, using `sudo make install`
11+
LIBDIR =../lib
12+
CPPFLAGS += -I$(LIBDIR)
13+
LIB = $(LIBDIR)/libzstd.a
1214

13-
CPPFLAGS += -I../lib
14-
LIB = ../lib/libzstd.a
15-
16-
.PHONY: default all clean test
1715

16+
.PHONY: default
1817
default: all
1918

19+
.PHONY: all
2020
all: simple_compression simple_decompression \
2121
multiple_simple_compression\
2222
dictionary_compression dictionary_decompression \
2323
streaming_compression streaming_decompression \
2424
multiple_streaming_compression streaming_memory_usage
2525

2626
$(LIB) :
27-
$(MAKE) -C ../lib libzstd.a
27+
$(MAKE) -C $(LIBDIR) libzstd.a
28+
29+
simple_compression.o: common.h
30+
simple_compression : $(LIB)
2831

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)
3134

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)
3437

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)
3740

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)
4043

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)
4346

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)
4649

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)
4952

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)
5255

53-
streaming_memory_usage : streaming_memory_usage.c $(LIB)
54-
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
5556

57+
.PHONY:clean
5658
clean:
57-
@rm -f core *.o tmp* result* *.zst \
59+
@$(RM) core *.o tmp* result* *.zst \
5860
simple_compression simple_decompression \
5961
multiple_simple_compression \
6062
dictionary_compression dictionary_decompression \
6163
streaming_compression streaming_decompression \
6264
multiple_streaming_compression streaming_memory_usage
6365
@echo Cleaning completed
6466

67+
.PHONY:test
6568
test: all
6669
cp README.md tmp
6770
cp Makefile tmp2

0 commit comments

Comments
 (0)