1 # ################################################################
2 # Copyright (c) Meta Platforms, Inc. and affiliates.
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 # ################################################################
12 LINUX_ZSTDLIB := $(LINUX)/lib/zstd
14 CPPFLAGS += -I$(LINUX)/include -I$(LINUX_ZSTDLIB) -Iinclude -DNDEBUG -Wno-deprecated-declarations
15 # Don't poison the workspace, it currently doesn't work with static allocation and workspace reuse
16 CPPFLAGS += -DZSTD_ASAN_DONT_POISON_WORKSPACE
18 LINUX_ZSTD_MODULE := $(wildcard $(LINUX_ZSTDLIB)/*.c)
19 LINUX_ZSTD_COMMON := $(wildcard $(LINUX_ZSTDLIB)/common/*.c)
20 LINUX_ZSTD_COMPRESS := $(wildcard $(LINUX_ZSTDLIB)/compress/*.c)
21 LINUX_ZSTD_DECOMPRESS := $(wildcard $(LINUX_ZSTDLIB)/decompress/*.c $(LINUX_ZSTDLIB)/decompress/*.S)
22 LINUX_ZSTD_FILES := $(LINUX_ZSTD_MODULE) $(LINUX_ZSTD_COMMON) $(LINUX_ZSTD_COMPRESS) $(LINUX_ZSTD_DECOMPRESS)
23 LINUX_ZSTD_OBJECTS0 := $(LINUX_ZSTD_FILES:.c=.o)
24 LINUX_ZSTD_OBJECTS := $(LINUX_ZSTD_OBJECTS0:.S=.o)
27 $(COMPILE.S) $(OUTPUT_OPTION) $<
29 liblinuxzstd.a: $(LINUX_ZSTD_OBJECTS)
30 $(AR) $(ARFLAGS) $@ $^
32 test: test.c liblinuxzstd.a
33 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@
35 static_test: static_test.c
36 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@
38 run-test: test static_test
45 $(RM) -f $(LINUX_ZSTDLIB)/*.o
46 $(RM) -f $(LINUX_ZSTDLIB)/**/*.o