1# SPDX-License-Identifier: GPL-2.0 2 3CFLAGS += -I../shared -I. -I../../include -I../../../lib -g -Og -Wall \ 4 -D_LGPL_SOURCE -fsanitize=address -fsanitize=undefined 5LDFLAGS += -fsanitize=address -fsanitize=undefined 6LDLIBS += -lpthread -lurcu 7LIBS := slab.o find_bit.o bitmap.o hweight.o vsprintf.o 8SHARED_OFILES = xarray-shared.o radix-tree.o idr.o linux.o $(LIBS) 9 10SHARED_DEPS = Makefile ../shared/shared.mk ../shared/*.h generated/map-shift.h \ 11 generated/bit-length.h generated/autoconf.h \ 12 ../../include/linux/*.h \ 13 ../../include/asm/*.h \ 14 ../../../include/linux/xarray.h \ 15 ../../../include/linux/maple_tree.h \ 16 ../../../include/linux/radix-tree.h \ 17 ../../../lib/radix-tree.h \ 18 ../../../include/linux/idr.h 19 20ifndef SHIFT 21 SHIFT=3 22endif 23 24ifeq ($(BUILD), 32) 25 CFLAGS += -m32 26 LDFLAGS += -m32 27LONG_BIT := 32 28endif 29 30ifndef LONG_BIT 31LONG_BIT := $(shell getconf LONG_BIT) 32endif 33 34%.o: ../shared/%.c 35 $(CC) -c $(CFLAGS) $< -o $@ 36 37vpath %.c ../../lib 38 39$(SHARED_OFILES): $(SHARED_DEPS) 40 41radix-tree.c: ../../../lib/radix-tree.c 42 sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@ 43 44idr.c: ../../../lib/idr.c 45 sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@ 46 47xarray-shared.o: ../shared/xarray-shared.c ../../../lib/xarray.c \ 48 ../../../lib/test_xarray.c 49 50maple-shared.o: ../shared/maple-shared.c ../../../lib/maple_tree.c \ 51 ../../../lib/test_maple_tree.c 52 53generated/autoconf.h: 54 @mkdir -p generated 55 cp ../shared/autoconf.h generated/autoconf.h 56 57generated/map-shift.h: 58 @mkdir -p generated 59 @if ! grep -qws $(SHIFT) generated/map-shift.h; then \ 60 echo "Generating $@"; \ 61 echo "#define XA_CHUNK_SHIFT $(SHIFT)" > \ 62 generated/map-shift.h; \ 63 fi 64 65generated/bit-length.h: FORCE 66 @mkdir -p generated 67 @if ! grep -qws CONFIG_$(LONG_BIT)BIT generated/bit-length.h; then \ 68 echo "Generating $@"; \ 69 echo "#define CONFIG_$(LONG_BIT)BIT 1" > $@; \ 70 fi 71 72FORCE: ; 73