Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # ################################################################
  2. # Copyright (c) 2016-2021, Yann Collet, Facebook, Inc.
  3. # All rights reserved.
  4. #
  5. # This source code is licensed under both the BSD-style license (found in the
  6. # LICENSE file in the root directory of this source tree) and the GPLv2 (found
  7. # in the COPYING file in the root directory of this source tree).
  8. # You may select, at your option, one of the above-listed licenses.
  9. # ################################################################
  10. ZSTD ?= zstd # note: requires zstd installation on local system
  11. UNAME?= $(shell uname)
  12. ifeq ($(UNAME), SunOS)
  13. DIFF ?= gdiff
  14. else
  15. DIFF ?= diff
  16. endif
  17. HARNESS_FILES=*.c
  18. MULTITHREAD_LDFLAGS = -pthread
  19. DEBUGFLAGS= -g -DZSTD_DEBUG=1
  20. CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
  21. -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR)
  22. CFLAGS ?= -O2
  23. CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
  24. -Wstrict-aliasing=1 -Wswitch-enum \
  25. -Wredundant-decls -Wstrict-prototypes -Wundef \
  26. -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
  27. -std=c99
  28. CFLAGS += $(DEBUGFLAGS)
  29. CFLAGS += $(MOREFLAGS)
  30. FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MULTITHREAD_LDFLAGS)
  31. harness: $(HARNESS_FILES)
  32. $(CC) $(FLAGS) $^ -o $@
  33. clean:
  34. @$(RM) harness *.o
  35. @$(RM) -rf harness.dSYM # MacOS specific
  36. test: harness
  37. #
  38. # Testing single-file decompression with educational decoder
  39. #
  40. @$(ZSTD) -f README.md -o tmp.zst
  41. @./harness tmp.zst tmp
  42. @$(DIFF) -s tmp README.md
  43. @$(RM) tmp*
  44. #
  45. # Testing dictionary decompression with education decoder
  46. #
  47. # note : files are presented multiple for training, to reach minimum threshold
  48. @$(ZSTD) --train harness.c zstd_decompress.c zstd_decompress.h README.md \
  49. harness.c zstd_decompress.c zstd_decompress.h README.md \
  50. harness.c zstd_decompress.c zstd_decompress.h README.md \
  51. -o dictionary
  52. @$(ZSTD) -f README.md -D dictionary -o tmp.zst
  53. @./harness tmp.zst tmp dictionary
  54. @$(DIFF) -s tmp README.md
  55. @$(RM) tmp* dictionary