Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # SPDX-License-Identifier: GPL-2.0
  2. include ../scripts/Makefile.include
  3. bindir ?= /usr/bin
  4. # This will work when dma is built in tools env. where srctree
  5. # isn't set and when invoked from selftests build, where srctree
  6. # is set to ".". building_out_of_srctree is undefined for in srctree
  7. # builds
  8. ifndef building_out_of_srctree
  9. srctree := $(patsubst %/,%,$(dir $(CURDIR)))
  10. srctree := $(patsubst %/,%,$(dir $(srctree)))
  11. endif
  12. # Do not use make's built-in rules
  13. # (this improves performance and avoids hard-to-debug behaviour);
  14. MAKEFLAGS += -r
  15. override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
  16. ALL_TARGETS := dma_map_benchmark
  17. ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
  18. all: $(ALL_PROGRAMS)
  19. export srctree OUTPUT CC LD CFLAGS
  20. include $(srctree)/tools/build/Makefile.include
  21. #
  22. # We need the following to be outside of kernel tree
  23. #
  24. $(OUTPUT)include/linux/map_benchmark.h: ../../include/uapi/linux/map_benchmark.h
  25. mkdir -p $(OUTPUT)include/linux 2>&1 || true
  26. ln -sf $(CURDIR)/../../include/uapi/linux/map_benchmark.h $@
  27. prepare: $(OUTPUT)include/linux/map_benchmark.h
  28. FORCE:
  29. DMA_MAP_BENCHMARK = dma_map_benchmark
  30. $(DMA_MAP_BENCHMARK): prepare FORCE
  31. $(CC) $(CFLAGS) $(DMA_MAP_BENCHMARK).c -o $(DMA_MAP_BENCHMARK)
  32. clean:
  33. rm -f $(ALL_PROGRAMS)
  34. rm -rf $(OUTPUT)include
  35. find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.cmd' -delete
  36. install: $(ALL_PROGRAMS)
  37. install -d -m 755 $(DESTDIR)$(bindir); \
  38. for program in $(ALL_PROGRAMS); do \
  39. install $$program $(DESTDIR)$(bindir); \
  40. done
  41. .PHONY: all install clean prepare FORCE