Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # ################################################################
  2. # Copyright (c) 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. LINUX := ../linux
  11. LINUX_ZSTDLIB := $(LINUX)/lib/zstd
  12. CPPFLAGS += -I$(LINUX)/include -I$(LINUX_ZSTDLIB) -Iinclude -DNDEBUG -Wno-deprecated-declarations
  13. # Don't poison the workspace, it currently doesn't work with static allocation and workspace reuse
  14. CPPFLAGS += -DZSTD_ASAN_DONT_POISON_WORKSPACE
  15. LINUX_ZSTD_MODULE := $(wildcard $(LINUX_ZSTDLIB)/*.c)
  16. LINUX_ZSTD_COMMON := $(wildcard $(LINUX_ZSTDLIB)/common/*.c)
  17. LINUX_ZSTD_COMPRESS := $(wildcard $(LINUX_ZSTDLIB)/compress/*.c)
  18. LINUX_ZSTD_DECOMPRESS := $(wildcard $(LINUX_ZSTDLIB)/decompress/*.c $(LINUX_ZSTDLIB)/decompress/*.S)
  19. LINUX_ZSTD_FILES := $(LINUX_ZSTD_MODULE) $(LINUX_ZSTD_COMMON) $(LINUX_ZSTD_COMPRESS) $(LINUX_ZSTD_DECOMPRESS)
  20. LINUX_ZSTD_OBJECTS0 := $(LINUX_ZSTD_FILES:.c=.o)
  21. LINUX_ZSTD_OBJECTS := $(LINUX_ZSTD_OBJECTS0:.S=.o)
  22. %.o: %.S
  23. $(CC) -c $(CPPFLAGS) $(CFLAGS) $^ -o $@
  24. liblinuxzstd.a: $(LINUX_ZSTD_OBJECTS)
  25. $(AR) $(ARFLAGS) $@ $^
  26. test: test.c liblinuxzstd.a
  27. $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@
  28. static_test: static_test.c
  29. $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@
  30. run-test: test static_test
  31. ./macro-test.sh
  32. ./test
  33. ./static_test
  34. .PHONY:
  35. clean:
  36. $(RM) -f $(LINUX_ZSTDLIB)/*.o
  37. $(RM) -f $(LINUX_ZSTDLIB)/**/*.o
  38. $(RM) -f *.o *.a
  39. $(RM) -f test