Makefile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 pcitest.sh
  13. ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
  14. all: $(ALL_PROGRAMS)
  15. export srctree OUTPUT CC LD CFLAGS
  16. include $(srctree)/tools/build/Makefile.include
  17. #
  18. # We need the following to be outside of kernel tree
  19. #
  20. $(OUTPUT)include/linux/: ../../include/uapi/linux/
  21. mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
  22. ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@
  23. prepare: $(OUTPUT)include/linux/
  24. PCITEST_IN := $(OUTPUT)pcitest-in.o
  25. $(PCITEST_IN): prepare FORCE
  26. $(Q)$(MAKE) $(build)=pcitest
  27. $(OUTPUT)pcitest: $(PCITEST_IN)
  28. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  29. clean:
  30. rm -f $(ALL_PROGRAMS)
  31. rm -rf $(OUTPUT)include/
  32. find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
  33. install: $(ALL_PROGRAMS)
  34. install -d -m 755 $(DESTDIR)$(bindir); \
  35. for program in $(ALL_PROGRAMS); do \
  36. install $$program $(DESTDIR)$(bindir); \
  37. done
  38. FORCE:
  39. .PHONY: all install clean FORCE prepare