1 # ################################################################ 2 # Copyright (c) Meta Platforms, Inc. and affiliates. 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 LINUX := ../linux 12 LINUX_ZSTDLIB := $(LINUX)/lib/zstd 13 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 17 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) 25 26 %.o: %.S 27 $(COMPILE.S) $(OUTPUT_OPTION) $< 28 29 liblinuxzstd.a: $(LINUX_ZSTD_OBJECTS) 30 $(AR) $(ARFLAGS) $@ $^ 31 32 test: test.c liblinuxzstd.a 33 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@ 34 35 static_test: static_test.c 36 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@ 37 38 run-test: test static_test 39 ./macro-test.sh 40 ./test 41 ./static_test 42 43 .PHONY: 44 clean: 45 $(RM) -f $(LINUX_ZSTDLIB)/*.o 46 $(RM) -f $(LINUX_ZSTDLIB)/**/*.o 47 $(RM) -f *.o *.a 48 $(RM) -f static_test 49 $(RM) -f test 50