at commit 8980bc57

1 # SPDX-License-Identifier: GPL-2.0
2 include ../../scripts/Makefile.arch
3
4 CFLAGS += -I../shared -I. -I../../include -I../../arch/$(SRCARCH)/include \
5 -I../../../lib -g -Og -Wall \
6 -D_LGPL_SOURCE -fsanitize=address -fsanitize=undefined
7 CFLAGS += $(EXTRA_CFLAGS)
8 LDFLAGS += -fsanitize=address -fsanitize=undefined
9 LDLIBS += -lpthread -lurcu
10 LIBS := slab.o find_bit.o bitmap.o hweight.o vsprintf.o
11 SHARED_OFILES = xarray-shared.o radix-tree.o idr.o linux.o $(LIBS)
12
13 SHARED_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
26 ifndef SHIFT
27 SHIFT=3
28 endif
29
30 ifeq ($(BUILD), 32)
31 CFLAGS += -m32
32 LDFLAGS += -m32
33 LONG_BIT := 32
34 endif
35
36 ifndef LONG_BIT
37 LONG_BIT := $(shell getconf LONG_BIT)
38 endif
39
40 %.o: ../shared/%.c
41 $(CC) -c $(CFLAGS) $< -o $@
42
43 vpath %.c ../../lib
44
45 $(SHARED_OFILES): $(SHARED_DEPS)
46
47 radix-tree.c: ../../../lib/radix-tree.c
48 sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@
49
50 idr.c: ../../../lib/idr.c
51 sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@
52
53 xarray-shared.o: ../shared/xarray-shared.c ../../../lib/xarray.c \
54 ../../../lib/test_xarray.c
55
56 maple-shared.o: ../shared/maple-shared.c ../../../lib/maple_tree.c \
57 ../../../lib/test_maple_tree.c
58
59 generated/autoconf.h:
60 @mkdir -p generated
61 cp ../shared/autoconf.h generated/autoconf.h
62
63 generated/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
71 generated/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
79 FORCE: ;