18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciCFLAGS += -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address \
48c2ecf20Sopenharmony_ci	  -fsanitize=undefined
58c2ecf20Sopenharmony_ciLDFLAGS += -fsanitize=address -fsanitize=undefined
68c2ecf20Sopenharmony_ciLDLIBS+= -lpthread -lurcu
78c2ecf20Sopenharmony_ciTARGETS = main idr-test multiorder xarray
88c2ecf20Sopenharmony_ciCORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o find_bit.o bitmap.o
98c2ecf20Sopenharmony_ciOFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
108c2ecf20Sopenharmony_ci	 regression4.o tag_check.o multiorder.o idr-test.o iteration_check.o \
118c2ecf20Sopenharmony_ci	 iteration_check_2.o benchmark.o
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciifndef SHIFT
148c2ecf20Sopenharmony_ci	SHIFT=3
158c2ecf20Sopenharmony_ciendif
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciifeq ($(BUILD), 32)
188c2ecf20Sopenharmony_ci	CFLAGS += -m32
198c2ecf20Sopenharmony_ci	LDFLAGS += -m32
208c2ecf20Sopenharmony_ciendif
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_citargets: generated/map-shift.h $(TARGETS)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cimain:	$(OFILES)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciidr-test.o: ../../../lib/test_ida.c
278c2ecf20Sopenharmony_ciidr-test: idr-test.o $(CORE_OFILES)
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cixarray: $(CORE_OFILES)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cimultiorder: multiorder.o $(CORE_OFILES)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciclean:
348c2ecf20Sopenharmony_ci	$(RM) $(TARGETS) *.o radix-tree.c idr.c generated/map-shift.h
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_civpath %.c ../../lib
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci$(OFILES): Makefile *.h */*.h generated/map-shift.h \
398c2ecf20Sopenharmony_ci	../../include/linux/*.h \
408c2ecf20Sopenharmony_ci	../../include/asm/*.h \
418c2ecf20Sopenharmony_ci	../../../include/linux/xarray.h \
428c2ecf20Sopenharmony_ci	../../../include/linux/radix-tree.h \
438c2ecf20Sopenharmony_ci	../../../include/linux/idr.h
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciradix-tree.c: ../../../lib/radix-tree.c
468c2ecf20Sopenharmony_ci	sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciidr.c: ../../../lib/idr.c
498c2ecf20Sopenharmony_ci	sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cixarray.o: ../../../lib/xarray.c ../../../lib/test_xarray.c
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cigenerated/map-shift.h:
548c2ecf20Sopenharmony_ci	@if ! grep -qws $(SHIFT) generated/map-shift.h; then		\
558c2ecf20Sopenharmony_ci		echo "#define XA_CHUNK_SHIFT $(SHIFT)" >		\
568c2ecf20Sopenharmony_ci				generated/map-shift.h;			\
578c2ecf20Sopenharmony_ci	fi
58