1# ################################################################ 2# Copyright (c) 2015-2020, 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 11.PHONY: libzstd 12libzstd: 13 rm -rf linux 14 mkdir -p linux 15 mkdir -p linux/include/linux 16 mkdir -p linux/lib/zstd 17 ../freestanding_lib/freestanding.py \ 18 --source-lib ../../lib \ 19 --output-lib linux/lib/zstd \ 20 --xxhash '<linux/xxhash.h>' \ 21 --xxh64-state 'struct xxh64_state' \ 22 --xxh64-prefix 'xxh64' \ 23 --rewrite-include '<limits\.h>=<linux/limits.h>' \ 24 --rewrite-include '<stddef\.h>=<linux/types.h>' \ 25 -DZSTD_NO_INTRINSICS \ 26 -DZSTD_NO_UNUSED_FUNCTIONS \ 27 -DZSTD_LEGACY_SUPPORT=0 \ 28 -DZSTD_STATIC_LINKING_ONLY \ 29 -DFSE_STATIC_LINKING_ONLY \ 30 -DHUF_STATIC_LINKING_ONLY \ 31 -DXXH_STATIC_LINKING_ONLY \ 32 -DMEM_FORCE_MEMORY_ACCESS=0 \ 33 -D__GNUC__ \ 34 -DSTATIC_BMI2=0 \ 35 -DZSTD_ADDRESS_SANITIZER=0 \ 36 -DZSTD_MEMORY_SANITIZER=0 \ 37 -DZSTD_COMPRESS_HEAPMODE=1 \ 38 -UZSTD_NO_INLINE \ 39 -UNO_PREFETCH \ 40 -U__cplusplus \ 41 -UZSTD_DLL_EXPORT \ 42 -UZSTD_DLL_IMPORT \ 43 -U__ICCARM__ \ 44 -UZSTD_MULTITHREAD \ 45 -U_MSC_VER \ 46 -U_WIN32 \ 47 -RZSTDLIB_VISIBILITY= \ 48 -RZSTDERRORLIB_VISIBILITY= 49 cp linux_zstd.h linux/include/linux/zstd.h 50 cp zstd_compress_module.c linux/lib/zstd 51 cp zstd_decompress_module.c linux/lib/zstd 52 cp decompress_sources.h linux/lib/zstd 53 cp linux.mk linux/lib/zstd/Makefile 54 55LINUX ?= $(HOME)/repos/linux 56 57.PHONY: import 58import: libzstd 59 rm -f $(LINUX)/include/linux/zstd.h 60 rm -f $(LINUX)/include/linux/zstd_errors.h 61 rm -rf $(LINUX)/lib/zstd 62 cp linux/include/linux/zstd.h $(LINUX)/include/linux 63 cp -r linux/lib/zstd $(LINUX)/lib 64 65import-upstream: 66 rm -rf $(LINUX)/lib/zstd 67 mkdir $(LINUX)/lib/zstd 68 cp ../../lib/zstd.h $(LINUX)/lib/zstd 69 cp -r ../../lib/common $(LINUX)/lib/zstd 70 cp -r ../../lib/compress $(LINUX)/lib/zstd 71 cp -r ../../lib/decompress $(LINUX)/lib/zstd 72 rm $(LINUX)/lib/zstd/common/threading.* 73 rm $(LINUX)/lib/zstd/common/pool.* 74 rm $(LINUX)/lib/zstd/common/xxhash.* 75 rm $(LINUX)/lib/zstd/compress/zstdmt_* 76 77.PHONY: test 78test: libzstd 79 $(MAKE) -C test run-test CFLAGS="-O3 $(CFLAGS)" -j 80 81.PHONY: clean 82clean: 83 $(RM) -rf linux 84