11ce78ce0SGustavo Pimentel# SPDX-License-Identifier: GPL-2.0 21ce78ce0SGustavo Pimentelinclude ../scripts/Makefile.include 31ce78ce0SGustavo Pimentel 41ce78ce0SGustavo Pimentelbindir ?= /usr/bin 51ce78ce0SGustavo Pimentel 61ce78ce0SGustavo Pimentelifeq ($(srctree),) 71ce78ce0SGustavo Pimentelsrctree := $(patsubst %/,%,$(dir $(CURDIR))) 81ce78ce0SGustavo Pimentelsrctree := $(patsubst %/,%,$(dir $(srctree))) 91ce78ce0SGustavo Pimentelendif 101ce78ce0SGustavo Pimentel 111ce78ce0SGustavo Pimentel# Do not use make's built-in rules 121ce78ce0SGustavo Pimentel# (this improves performance and avoids hard-to-debug behaviour); 131ce78ce0SGustavo PimentelMAKEFLAGS += -r 141ce78ce0SGustavo Pimentel 151ce78ce0SGustavo PimentelCFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include 161ce78ce0SGustavo Pimentel 17993d5fe3SKishon Vijay Abraham IALL_TARGETS := pcitest 181ce78ce0SGustavo PimentelALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) 191ce78ce0SGustavo Pimentel 20993d5fe3SKishon Vijay Abraham ISCRIPTS := pcitest.sh 21993d5fe3SKishon Vijay Abraham IALL_SCRIPTS := $(patsubst %,$(OUTPUT)%,$(SCRIPTS)) 22993d5fe3SKishon Vijay Abraham I 231ce78ce0SGustavo Pimentelall: $(ALL_PROGRAMS) 241ce78ce0SGustavo Pimentel 251ce78ce0SGustavo Pimentelexport srctree OUTPUT CC LD CFLAGS 261ce78ce0SGustavo Pimentelinclude $(srctree)/tools/build/Makefile.include 271ce78ce0SGustavo Pimentel 281ce78ce0SGustavo Pimentel# 291ce78ce0SGustavo Pimentel# We need the following to be outside of kernel tree 301ce78ce0SGustavo Pimentel# 311ce78ce0SGustavo Pimentel$(OUTPUT)include/linux/: ../../include/uapi/linux/ 321ce78ce0SGustavo Pimentel mkdir -p $(OUTPUT)include/linux/ 2>&1 || true 331ce78ce0SGustavo Pimentel ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@ 341ce78ce0SGustavo Pimentel 351ce78ce0SGustavo Pimentelprepare: $(OUTPUT)include/linux/ 361ce78ce0SGustavo Pimentel 371ce78ce0SGustavo PimentelPCITEST_IN := $(OUTPUT)pcitest-in.o 381ce78ce0SGustavo Pimentel$(PCITEST_IN): prepare FORCE 391ce78ce0SGustavo Pimentel $(Q)$(MAKE) $(build)=pcitest 401ce78ce0SGustavo Pimentel$(OUTPUT)pcitest: $(PCITEST_IN) 411ce78ce0SGustavo Pimentel $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ 421ce78ce0SGustavo Pimentel 431ce78ce0SGustavo Pimentelclean: 441ce78ce0SGustavo Pimentel rm -f $(ALL_PROGRAMS) 451ce78ce0SGustavo Pimentel rm -rf $(OUTPUT)include/ 461ce78ce0SGustavo Pimentel find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete 471ce78ce0SGustavo Pimentel 481ce78ce0SGustavo Pimentelinstall: $(ALL_PROGRAMS) 491ce78ce0SGustavo Pimentel install -d -m 755 $(DESTDIR)$(bindir); \ 501ce78ce0SGustavo Pimentel for program in $(ALL_PROGRAMS); do \ 511ce78ce0SGustavo Pimentel install $$program $(DESTDIR)$(bindir); \ 52993d5fe3SKishon Vijay Abraham I done; \ 53993d5fe3SKishon Vijay Abraham I for script in $(ALL_SCRIPTS); do \ 54993d5fe3SKishon Vijay Abraham I install $$script $(DESTDIR)$(bindir); \ 551ce78ce0SGustavo Pimentel done 561ce78ce0SGustavo Pimentel 571ce78ce0SGustavo PimentelFORCE: 581ce78ce0SGustavo Pimentel 591ce78ce0SGustavo Pimentel.PHONY: all install clean FORCE prepare 60