shared.mk 2.1 KB

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