shared.mk 2.3 KB

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