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 11LINUX := ../linux 12LINUX_ZSTDLIB := $(LINUX)/lib/zstd 13 14CPPFLAGS += -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 16CPPFLAGS += -DZSTD_ASAN_DONT_POISON_WORKSPACE 17 18LINUX_ZSTD_MODULE := $(wildcard $(LINUX_ZSTDLIB)/*.c) 19LINUX_ZSTD_COMMON := $(wildcard $(LINUX_ZSTDLIB)/common/*.c) 20LINUX_ZSTD_COMPRESS := $(wildcard $(LINUX_ZSTDLIB)/compress/*.c) 21LINUX_ZSTD_DECOMPRESS := $(wildcard $(LINUX_ZSTDLIB)/decompress/*.c $(LINUX_ZSTDLIB)/decompress/*.S) 22LINUX_ZSTD_FILES := $(LINUX_ZSTD_MODULE) $(LINUX_ZSTD_COMMON) $(LINUX_ZSTD_COMPRESS) $(LINUX_ZSTD_DECOMPRESS) 23LINUX_ZSTD_OBJECTS0 := $(LINUX_ZSTD_FILES:.c=.o) 24LINUX_ZSTD_OBJECTS := $(LINUX_ZSTD_OBJECTS0:.S=.o) 25 26%.o: %.S 27 $(COMPILE.S) $(OUTPUT_OPTION) $< 28 29liblinuxzstd.a: $(LINUX_ZSTD_OBJECTS) 30 $(AR) $(ARFLAGS) $@ $^ 31 32test: test.c liblinuxzstd.a 33 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@ 34 35static_test: static_test.c 36 $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@ 37 38run-test: test static_test 39 ./macro-test.sh 40 ./test 41 ./static_test 42 43.PHONY: 44clean: 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