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