xref: /openbmc/linux/tools/pci/Makefile (revision 1ce78ce0)
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
171ce78ce0SGustavo PimentelALL_TARGETS := pcitest pcitest.sh
181ce78ce0SGustavo PimentelALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
191ce78ce0SGustavo Pimentel
201ce78ce0SGustavo Pimentelall: $(ALL_PROGRAMS)
211ce78ce0SGustavo Pimentel
221ce78ce0SGustavo Pimentelexport srctree OUTPUT CC LD CFLAGS
231ce78ce0SGustavo Pimentelinclude $(srctree)/tools/build/Makefile.include
241ce78ce0SGustavo Pimentel
251ce78ce0SGustavo Pimentel#
261ce78ce0SGustavo Pimentel# We need the following to be outside of kernel tree
271ce78ce0SGustavo Pimentel#
281ce78ce0SGustavo Pimentel$(OUTPUT)include/linux/: ../../include/uapi/linux/
291ce78ce0SGustavo Pimentel	mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
301ce78ce0SGustavo Pimentel	ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@
311ce78ce0SGustavo Pimentel
321ce78ce0SGustavo Pimentelprepare: $(OUTPUT)include/linux/
331ce78ce0SGustavo Pimentel
341ce78ce0SGustavo PimentelPCITEST_IN := $(OUTPUT)pcitest-in.o
351ce78ce0SGustavo Pimentel$(PCITEST_IN): prepare FORCE
361ce78ce0SGustavo Pimentel	$(Q)$(MAKE) $(build)=pcitest
371ce78ce0SGustavo Pimentel$(OUTPUT)pcitest: $(PCITEST_IN)
381ce78ce0SGustavo Pimentel	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
391ce78ce0SGustavo Pimentel
401ce78ce0SGustavo Pimentelclean:
411ce78ce0SGustavo Pimentel	rm -f $(ALL_PROGRAMS)
421ce78ce0SGustavo Pimentel	rm -rf $(OUTPUT)include/
431ce78ce0SGustavo Pimentel	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
441ce78ce0SGustavo Pimentel
451ce78ce0SGustavo Pimentelinstall: $(ALL_PROGRAMS)
461ce78ce0SGustavo Pimentel	install -d -m 755 $(DESTDIR)$(bindir);		\
471ce78ce0SGustavo Pimentel	for program in $(ALL_PROGRAMS); do		\
481ce78ce0SGustavo Pimentel		install $$program $(DESTDIR)$(bindir);	\
491ce78ce0SGustavo Pimentel	done
501ce78ce0SGustavo Pimentel
511ce78ce0SGustavo PimentelFORCE:
521ce78ce0SGustavo Pimentel
531ce78ce0SGustavo Pimentel.PHONY: all install clean FORCE prepare
54