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 I 221ce78ce0SGustavo Pimentelall: $(ALL_PROGRAMS) 231ce78ce0SGustavo Pimentel 241ce78ce0SGustavo Pimentelexport srctree OUTPUT CC LD CFLAGS 251ce78ce0SGustavo Pimentelinclude $(srctree)/tools/build/Makefile.include 261ce78ce0SGustavo Pimentel 271ce78ce0SGustavo Pimentel# 281ce78ce0SGustavo Pimentel# We need the following to be outside of kernel tree 291ce78ce0SGustavo Pimentel# 301ce78ce0SGustavo Pimentel$(OUTPUT)include/linux/: ../../include/uapi/linux/ 311ce78ce0SGustavo Pimentel mkdir -p $(OUTPUT)include/linux/ 2>&1 || true 321ce78ce0SGustavo Pimentel ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@ 331ce78ce0SGustavo Pimentel 341ce78ce0SGustavo Pimentelprepare: $(OUTPUT)include/linux/ 351ce78ce0SGustavo Pimentel 361ce78ce0SGustavo PimentelPCITEST_IN := $(OUTPUT)pcitest-in.o 371ce78ce0SGustavo Pimentel$(PCITEST_IN): prepare FORCE 381ce78ce0SGustavo Pimentel $(Q)$(MAKE) $(build)=pcitest 391ce78ce0SGustavo Pimentel$(OUTPUT)pcitest: $(PCITEST_IN) 401ce78ce0SGustavo Pimentel $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ 411ce78ce0SGustavo Pimentel 421ce78ce0SGustavo Pimentelclean: 431ce78ce0SGustavo Pimentel rm -f $(ALL_PROGRAMS) 441ce78ce0SGustavo Pimentel rm -rf $(OUTPUT)include/ 45*5c816641SMasahiro Yamada find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete 461ce78ce0SGustavo Pimentel 471ce78ce0SGustavo Pimentelinstall: $(ALL_PROGRAMS) 481ce78ce0SGustavo Pimentel install -d -m 755 $(DESTDIR)$(bindir); \ 49af336630SAndy Shevchenko for program in $(ALL_PROGRAMS); do \ 501ce78ce0SGustavo Pimentel install $$program $(DESTDIR)$(bindir); \ 51993d5fe3SKishon Vijay Abraham I done; \ 52af336630SAndy Shevchenko for script in $(SCRIPTS); do \ 53993d5fe3SKishon Vijay Abraham I install $$script $(DESTDIR)$(bindir); \ 541ce78ce0SGustavo Pimentel done 551ce78ce0SGustavo Pimentel 561ce78ce0SGustavo PimentelFORCE: 571ce78ce0SGustavo Pimentel 581ce78ce0SGustavo Pimentel.PHONY: all install clean FORCE prepare 59