Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # SPDX-License-Identifier: GPL-2.0
  2. include ../scripts/Makefile.include
  3. bindir ?= /usr/bin
  4. ifeq ($(srctree),)
  5. srctree := $(patsubst %/,%,$(dir $(CURDIR)))
  6. srctree := $(patsubst %/,%,$(dir $(srctree)))
  7. endif
  8. # Do not use make's built-in rules
  9. # (this improves performance and avoids hard-to-debug behaviour);
  10. MAKEFLAGS += -r
  11. CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
  12. ALL_TARGETS := pcitest
  13. ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
  14. SCRIPTS := pcitest.sh
  15. all: $(ALL_PROGRAMS)
  16. export srctree OUTPUT CC LD CFLAGS
  17. include $(srctree)/tools/build/Makefile.include
  18. #
  19. # We need the following to be outside of kernel tree
  20. #
  21. $(OUTPUT)include/linux/: ../../include/uapi/linux/
  22. mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
  23. ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@
  24. prepare: $(OUTPUT)include/linux/
  25. PCITEST_IN := $(OUTPUT)pcitest-in.o
  26. $(PCITEST_IN): prepare FORCE
  27. $(Q)$(MAKE) $(build)=pcitest
  28. $(OUTPUT)pcitest: $(PCITEST_IN)
  29. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  30. clean:
  31. rm -f $(ALL_PROGRAMS)
  32. rm -rf $(OUTPUT)include/
  33. find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
  34. install: $(ALL_PROGRAMS)
  35. install -d -m 755 $(DESTDIR)$(bindir); \
  36. for program in $(ALL_PROGRAMS); do \
  37. install $$program $(DESTDIR)$(bindir); \
  38. done; \
  39. for script in $(SCRIPTS); do \
  40. install $$script $(DESTDIR)$(bindir); \
  41. done
  42. FORCE:
  43. .PHONY: all install clean FORCE prepare