Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. .PHONY: libzstd
  11. libzstd:
  12. rm -rf linux
  13. mkdir -p linux
  14. mkdir -p linux/include/linux
  15. mkdir -p linux/lib/zstd
  16. ../freestanding_lib/freestanding.py \
  17. --source-lib ../../lib \
  18. --output-lib linux/lib/zstd \
  19. --xxhash '<linux/xxhash.h>' \
  20. --xxh64-state 'struct xxh64_state' \
  21. --xxh64-prefix 'xxh64' \
  22. --rewrite-include '<limits\.h>=<linux/limits.h>' \
  23. --rewrite-include '<stddef\.h>=<linux/types.h>' \
  24. --rewrite-include '"\.\./zstd.h"=<linux/zstd.h>' \
  25. --rewrite-include '"(\.\./)?zstd_errors.h"=<linux/zstd_errors.h>' \
  26. --sed 's,/\*\*\*,/* *,g' \
  27. --sed 's,/\*\*,/*,g' \
  28. -DZSTD_NO_INTRINSICS \
  29. -DZSTD_NO_UNUSED_FUNCTIONS \
  30. -DZSTD_LEGACY_SUPPORT=0 \
  31. -DZSTD_STATIC_LINKING_ONLY \
  32. -DFSE_STATIC_LINKING_ONLY \
  33. -DHUF_STATIC_LINKING_ONLY \
  34. -DXXH_STATIC_LINKING_ONLY \
  35. -DMEM_FORCE_MEMORY_ACCESS=0 \
  36. -D__GNUC__ \
  37. -D__linux__=1 \
  38. -DSTATIC_BMI2=0 \
  39. -DZSTD_ADDRESS_SANITIZER=0 \
  40. -DZSTD_MEMORY_SANITIZER=0 \
  41. -DZSTD_DATAFLOW_SANITIZER=0 \
  42. -DZSTD_COMPRESS_HEAPMODE=1 \
  43. -UNO_PREFETCH \
  44. -U__cplusplus \
  45. -UZSTD_DLL_EXPORT \
  46. -UZSTD_DLL_IMPORT \
  47. -U__ICCARM__ \
  48. -UZSTD_MULTITHREAD \
  49. -U_MSC_VER \
  50. -U_WIN32 \
  51. -RZSTDLIB_VISIBILITY= \
  52. -RZSTDERRORLIB_VISIBILITY= \
  53. -RZSTD_FALLTHROUGH=fallthrough \
  54. -DZSTD_HAVE_WEAK_SYMBOLS=0 \
  55. -DZSTD_TRACE=0 \
  56. -DZSTD_NO_TRACE \
  57. -DZSTD_LINUX_KERNEL
  58. mv linux/lib/zstd/zstd.h linux/include/linux/zstd_lib.h
  59. mv linux/lib/zstd/zstd_errors.h linux/include/linux/
  60. cp linux_zstd.h linux/include/linux/zstd.h
  61. cp zstd_compress_module.c linux/lib/zstd
  62. cp zstd_decompress_module.c linux/lib/zstd
  63. cp decompress_sources.h linux/lib/zstd
  64. cp linux.mk linux/lib/zstd/Makefile
  65. LINUX ?= $(HOME)/repos/linux
  66. .PHONY: import
  67. import: libzstd
  68. rm -f $(LINUX)/include/linux/zstd.h
  69. rm -f $(LINUX)/include/linux/zstd_errors.h
  70. rm -rf $(LINUX)/lib/zstd
  71. cp linux/include/linux/zstd.h $(LINUX)/include/linux
  72. cp linux/include/linux/zstd_lib.h $(LINUX)/include/linux
  73. cp linux/include/linux/zstd_errors.h $(LINUX)/include/linux
  74. cp -r linux/lib/zstd $(LINUX)/lib
  75. import-upstream:
  76. rm -rf $(LINUX)/lib/zstd
  77. mkdir $(LINUX)/lib/zstd
  78. cp ../../lib/zstd.h $(LINUX)/include/linux/zstd_lib.h
  79. cp -r ../../lib/common $(LINUX)/lib/zstd
  80. cp -r ../../lib/compress $(LINUX)/lib/zstd
  81. cp -r ../../lib/decompress $(LINUX)/lib/zstd
  82. mv $(LINUX)/lib/zstd/zstd_errors.h $(LINUX)/include/linux
  83. rm $(LINUX)/lib/zstd/common/threading.*
  84. rm $(LINUX)/lib/zstd/common/pool.*
  85. rm $(LINUX)/lib/zstd/common/xxhash.*
  86. rm $(LINUX)/lib/zstd/compress/zstdmt_*
  87. DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
  88. -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
  89. -Wstrict-prototypes -Wundef -Wpointer-arith \
  90. -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
  91. -Wredundant-decls -Wmissing-prototypes -Wc++-compat \
  92. -Wimplicit-fallthrough
  93. .PHONY: test
  94. test: libzstd
  95. $(MAKE) -C test run-test CFLAGS="-O3 $(CFLAGS) $(DEBUGFLAGS) -Werror" -j
  96. .PHONY: clean
  97. clean:
  98. $(RM) -rf linux test/test test/static_test