xref: /kernel/linux/linux-5.10/tools/pci/Makefile (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ciinclude ../scripts/Makefile.include
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_cibindir ?= /usr/bin
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciifeq ($(srctree),)
78c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR)))
88c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
98c2ecf20Sopenharmony_ciendif
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci# Do not use make's built-in rules
128c2ecf20Sopenharmony_ci# (this improves performance and avoids hard-to-debug behaviour);
138c2ecf20Sopenharmony_ciMAKEFLAGS += -r
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciCFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciALL_TARGETS := pcitest
188c2ecf20Sopenharmony_ciALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciSCRIPTS := pcitest.sh
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciall: $(ALL_PROGRAMS)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS
258c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#
288c2ecf20Sopenharmony_ci# We need the following to be outside of kernel tree
298c2ecf20Sopenharmony_ci#
308c2ecf20Sopenharmony_ci$(OUTPUT)include/linux/: ../../include/uapi/linux/
318c2ecf20Sopenharmony_ci	mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
328c2ecf20Sopenharmony_ci	ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciprepare: $(OUTPUT)include/linux/
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciPCITEST_IN := $(OUTPUT)pcitest-in.o
378c2ecf20Sopenharmony_ci$(PCITEST_IN): prepare FORCE
388c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=pcitest
398c2ecf20Sopenharmony_ci$(OUTPUT)pcitest: $(PCITEST_IN)
408c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciclean:
438c2ecf20Sopenharmony_ci	rm -f $(ALL_PROGRAMS)
448c2ecf20Sopenharmony_ci	rm -rf $(OUTPUT)include/
458c2ecf20Sopenharmony_ci	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ciinstall: $(ALL_PROGRAMS)
488c2ecf20Sopenharmony_ci	install -d -m 755 $(DESTDIR)$(bindir);		\
498c2ecf20Sopenharmony_ci	for program in $(ALL_PROGRAMS); do		\
508c2ecf20Sopenharmony_ci		install $$program $(DESTDIR)$(bindir);	\
518c2ecf20Sopenharmony_ci	done;						\
528c2ecf20Sopenharmony_ci	for script in $(SCRIPTS); do			\
538c2ecf20Sopenharmony_ci		install $$script $(DESTDIR)$(bindir);	\
548c2ecf20Sopenharmony_ci	done
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ciFORCE:
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci.PHONY: all install clean FORCE prepare
59