Skip to content

Commit

Permalink
Merge pull request #2427 from facebook/example_compile
Browse files Browse the repository at this point in the history
streamlined example recipe
  • Loading branch information
Cyan4973 authored Dec 16, 2020
2 parents 6899855 + ecffa77 commit d387772
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ automated_benchmarking:
.PHONY: benchmarking
benchmarking: automated_benchmarking

## examples: build all examples in `/examples` directory
## examples: build all examples in `examples/` directory
.PHONY: examples
examples: lib
CPPFLAGS=-I../lib LDFLAGS=-L../lib $(MAKE) -C examples/ all
$(MAKE) -C examples all

## manual: generate API documentation in html format
.PHONY: manual
Expand Down
53 changes: 28 additions & 25 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,63 @@
# You may select, at your option, one of the above-listed licenses.
# ################################################################

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

CPPFLAGS += -I../lib
LIB = ../lib/libzstd.a

.PHONY: default all clean test

.PHONY: default
default: all

.PHONY: all
all: simple_compression simple_decompression \
multiple_simple_compression\
dictionary_compression dictionary_decompression \
streaming_compression streaming_decompression \
multiple_streaming_compression streaming_memory_usage

$(LIB) :
$(MAKE) -C ../lib libzstd.a
$(MAKE) -C $(LIBDIR) libzstd.a

simple_compression.o: common.h
simple_compression : $(LIB)

simple_compression : simple_compression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
simple_decompression.o: common.h
simple_decompression : $(LIB)

simple_decompression : simple_decompression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
multiple_simple_compression.o: common.h
multiple_simple_compression : $(LIB)

multiple_simple_compression : multiple_simple_compression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
dictionary_compression.o: common.h
dictionary_compression : $(LIB)

dictionary_compression : dictionary_compression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
dictionary_decompression.o: common.h
dictionary_decompression : $(LIB)

dictionary_decompression : dictionary_decompression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
streaming_compression.o: common.h
streaming_compression : $(LIB)

streaming_compression : streaming_compression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
multiple_streaming_compression.o: common.h
multiple_streaming_compression : $(LIB)

multiple_streaming_compression : multiple_streaming_compression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
streaming_decompression.o: common.h
streaming_decompression : $(LIB)

streaming_decompression : streaming_decompression.c common.h $(LIB)
$(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
streaming_memory_usage.o: common.h
streaming_memory_usage : $(LIB)

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

.PHONY:clean
clean:
@rm -f core *.o tmp* result* *.zst \
@$(RM) core *.o tmp* result* *.zst \
simple_compression simple_decompression \
multiple_simple_compression \
dictionary_compression dictionary_decompression \
streaming_compression streaming_decompression \
multiple_streaming_compression streaming_memory_usage
@echo Cleaning completed

.PHONY:test
test: all
cp README.md tmp
cp Makefile tmp2
Expand Down

0 comments on commit d387772

Please sign in to comment.