1 1.1 christos # ################################################################ 2 1.1 christos # Copyright (c) Meta Platforms, Inc. and affiliates. 3 1.1 christos # All rights reserved. 4 1.1 christos # 5 1.1 christos # This source code is licensed under both the BSD-style license (found in the 6 1.1 christos # LICENSE file in the root directory of this source tree) and the GPLv2 (found 7 1.1 christos # in the COPYING file in the root directory of this source tree). 8 1.1 christos # You may select, at your option, one of the above-listed licenses. 9 1.1 christos # ################################################################ 10 1.1 christos 11 1.1 christos .PHONY: libzstd 12 1.1 christos libzstd: 13 1.1 christos rm -rf linux 14 1.1 christos mkdir -p linux 15 1.1 christos mkdir -p linux/include/linux 16 1.1 christos mkdir -p linux/lib/zstd 17 1.1 christos ../freestanding_lib/freestanding.py \ 18 1.1 christos --source-lib ../../lib \ 19 1.1 christos --output-lib linux/lib/zstd \ 20 1.1 christos --xxhash '<linux/xxhash.h>' \ 21 1.1 christos --xxh64-state 'struct xxh64_state' \ 22 1.1 christos --xxh64-prefix 'xxh64' \ 23 1.1 christos --rewrite-include '<limits\.h>=<linux/limits.h>' \ 24 1.1 christos --rewrite-include '<stddef\.h>=<linux/types.h>' \ 25 1.1 christos --rewrite-include '"\.\./zstd.h"=<linux/zstd.h>' \ 26 1.1 christos --rewrite-include '"(\.\./)?zstd_errors.h"=<linux/zstd_errors.h>' \ 27 1.1 christos --sed 's,/\*\*\*,/* *,g' \ 28 1.1 christos --sed 's,/\*\*,/*,g' \ 29 1.1 christos --spdx \ 30 1.1 christos -DZSTD_NO_INTRINSICS \ 31 1.1 christos -DZSTD_NO_UNUSED_FUNCTIONS \ 32 1.1 christos -DZSTD_LEGACY_SUPPORT=0 \ 33 1.1 christos -DZSTD_STATIC_LINKING_ONLY \ 34 1.1 christos -DFSE_STATIC_LINKING_ONLY \ 35 1.1 christos -DXXH_STATIC_LINKING_ONLY \ 36 1.1 christos -D__GNUC__ \ 37 1.1 christos -D__linux__=1 \ 38 1.1 christos -DSTATIC_BMI2=0 \ 39 1.1 christos -DZSTD_ADDRESS_SANITIZER=0 \ 40 1.1 christos -DZSTD_MEMORY_SANITIZER=0 \ 41 1.1 christos -DZSTD_DATAFLOW_SANITIZER=0 \ 42 1.1 christos -DZSTD_COMPRESS_HEAPMODE=1 \ 43 1.1 christos -UNO_PREFETCH \ 44 1.1 christos -U__cplusplus \ 45 1.1 christos -UZSTD_DLL_EXPORT \ 46 1.1 christos -UZSTD_DLL_IMPORT \ 47 1.1 christos -U__ICCARM__ \ 48 1.1 christos -UZSTD_MULTITHREAD \ 49 1.1 christos -U_MSC_VER \ 50 1.1 christos -U_WIN32 \ 51 1.1 christos -RZSTDLIB_VISIBLE= \ 52 1.1 christos -RZSTDERRORLIB_VISIBLE= \ 53 1.1 christos -RZSTD_FALLTHROUGH=fallthrough \ 54 1.1 christos -DZSTD_HAVE_WEAK_SYMBOLS=0 \ 55 1.1 christos -DZSTD_TRACE=0 \ 56 1.1 christos -DZSTD_NO_TRACE \ 57 1.1 christos -DZSTD_DISABLE_ASM \ 58 1.1 christos -DZSTD_LINUX_KERNEL 59 1.1 christos rm linux/lib/zstd/decompress/huf_decompress_amd64.S 60 1.1 christos mv linux/lib/zstd/zstd.h linux/include/linux/zstd_lib.h 61 1.1 christos mv linux/lib/zstd/zstd_errors.h linux/include/linux/ 62 1.1 christos cp linux_zstd.h linux/include/linux/zstd.h 63 1.1 christos cp zstd_common_module.c linux/lib/zstd 64 1.1 christos cp zstd_compress_module.c linux/lib/zstd 65 1.1 christos cp zstd_decompress_module.c linux/lib/zstd 66 1.1 christos cp decompress_sources.h linux/lib/zstd 67 1.1 christos cp linux.mk linux/lib/zstd/Makefile 68 1.1 christos 69 1.1 christos LINUX ?= $(HOME)/repos/linux 70 1.1 christos 71 1.1 christos .PHONY: import 72 1.1 christos import: libzstd 73 1.1 christos rm -f $(LINUX)/include/linux/zstd.h 74 1.1 christos rm -f $(LINUX)/include/linux/zstd_errors.h 75 1.1 christos rm -rf $(LINUX)/lib/zstd 76 1.1 christos cp linux/include/linux/zstd.h $(LINUX)/include/linux 77 1.1 christos cp linux/include/linux/zstd_lib.h $(LINUX)/include/linux 78 1.1 christos cp linux/include/linux/zstd_errors.h $(LINUX)/include/linux 79 1.1 christos cp -r linux/lib/zstd $(LINUX)/lib 80 1.1 christos 81 1.1 christos import-upstream: 82 1.1 christos rm -rf $(LINUX)/lib/zstd 83 1.1 christos mkdir $(LINUX)/lib/zstd 84 1.1 christos cp ../../lib/zstd.h $(LINUX)/include/linux/zstd_lib.h 85 1.1 christos cp -r ../../lib/common $(LINUX)/lib/zstd 86 1.1 christos cp -r ../../lib/compress $(LINUX)/lib/zstd 87 1.1 christos cp -r ../../lib/decompress $(LINUX)/lib/zstd 88 1.1 christos mv $(LINUX)/lib/zstd/zstd_errors.h $(LINUX)/include/linux 89 1.1 christos rm $(LINUX)/lib/zstd/common/threading.* 90 1.1 christos rm $(LINUX)/lib/zstd/common/pool.* 91 1.1 christos rm $(LINUX)/lib/zstd/common/xxhash.* 92 1.1 christos rm $(LINUX)/lib/zstd/compress/zstdmt_* 93 1.1 christos 94 1.1 christos DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ 95 1.1 christos -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \ 96 1.1 christos -Wstrict-prototypes -Wundef -Wpointer-arith \ 97 1.1 christos -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ 98 1.1 christos -Wredundant-decls -Wmissing-prototypes -Wc++-compat \ 99 1.1 christos -Wimplicit-fallthrough 100 1.1 christos 101 1.1 christos .PHONY: test 102 1.1 christos test: libzstd 103 1.1 christos $(MAKE) -C test run-test CFLAGS="-O3 $(CFLAGS) $(DEBUGFLAGS) -Werror" -j 104 1.1 christos 105 1.1 christos .PHONY: clean 106 1.1 christos clean: 107 1.1 christos $(RM) -rf linux 108 1.1 christos $(MAKE) -C test clean 109