xref: /aosp_15_r20/external/zstd/contrib/linux-kernel/test/Makefile (revision 01826a4963a0d8a59bc3812d29bdf0fb76416722)
1*01826a49SYabin Cui# ################################################################
2*01826a49SYabin Cui# Copyright (c) Meta Platforms, Inc. and affiliates.
3*01826a49SYabin Cui# All rights reserved.
4*01826a49SYabin Cui#
5*01826a49SYabin Cui# This source code is licensed under both the BSD-style license (found in the
6*01826a49SYabin Cui# LICENSE file in the root directory of this source tree) and the GPLv2 (found
7*01826a49SYabin Cui# in the COPYING file in the root directory of this source tree).
8*01826a49SYabin Cui# You may select, at your option, one of the above-listed licenses.
9*01826a49SYabin Cui# ################################################################
10*01826a49SYabin Cui
11*01826a49SYabin CuiLINUX := ../linux
12*01826a49SYabin CuiLINUX_ZSTDLIB := $(LINUX)/lib/zstd
13*01826a49SYabin Cui
14*01826a49SYabin CuiCPPFLAGS += -I$(LINUX)/include -I$(LINUX_ZSTDLIB) -Iinclude -DNDEBUG -Wno-deprecated-declarations
15*01826a49SYabin Cui# Don't poison the workspace, it currently doesn't work with static allocation and workspace reuse
16*01826a49SYabin CuiCPPFLAGS += -DZSTD_ASAN_DONT_POISON_WORKSPACE
17*01826a49SYabin Cui
18*01826a49SYabin CuiLINUX_ZSTD_MODULE     := $(wildcard $(LINUX_ZSTDLIB)/*.c)
19*01826a49SYabin CuiLINUX_ZSTD_COMMON     := $(wildcard $(LINUX_ZSTDLIB)/common/*.c)
20*01826a49SYabin CuiLINUX_ZSTD_COMPRESS   := $(wildcard $(LINUX_ZSTDLIB)/compress/*.c)
21*01826a49SYabin CuiLINUX_ZSTD_DECOMPRESS := $(wildcard $(LINUX_ZSTDLIB)/decompress/*.c $(LINUX_ZSTDLIB)/decompress/*.S)
22*01826a49SYabin CuiLINUX_ZSTD_FILES      := $(LINUX_ZSTD_MODULE) $(LINUX_ZSTD_COMMON) $(LINUX_ZSTD_COMPRESS) $(LINUX_ZSTD_DECOMPRESS)
23*01826a49SYabin CuiLINUX_ZSTD_OBJECTS0   := $(LINUX_ZSTD_FILES:.c=.o)
24*01826a49SYabin CuiLINUX_ZSTD_OBJECTS    := $(LINUX_ZSTD_OBJECTS0:.S=.o)
25*01826a49SYabin Cui
26*01826a49SYabin Cui%.o: %.S
27*01826a49SYabin Cui	$(COMPILE.S) $(OUTPUT_OPTION) $<
28*01826a49SYabin Cui
29*01826a49SYabin Cuiliblinuxzstd.a: $(LINUX_ZSTD_OBJECTS)
30*01826a49SYabin Cui	$(AR) $(ARFLAGS) $@ $^
31*01826a49SYabin Cui
32*01826a49SYabin Cuitest: test.c liblinuxzstd.a
33*01826a49SYabin Cui	$(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@
34*01826a49SYabin Cui
35*01826a49SYabin Cuistatic_test: static_test.c
36*01826a49SYabin Cui	$(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@
37*01826a49SYabin Cui
38*01826a49SYabin Cuirun-test: test static_test
39*01826a49SYabin Cui	./macro-test.sh
40*01826a49SYabin Cui	./test
41*01826a49SYabin Cui	./static_test
42*01826a49SYabin Cui
43*01826a49SYabin Cui.PHONY:
44*01826a49SYabin Cuiclean:
45*01826a49SYabin Cui	$(RM) -f $(LINUX_ZSTDLIB)/*.o
46*01826a49SYabin Cui	$(RM) -f $(LINUX_ZSTDLIB)/**/*.o
47*01826a49SYabin Cui	$(RM) -f *.o *.a
48*01826a49SYabin Cui	$(RM) -f static_test
49*01826a49SYabin Cui	$(RM) -f test
50