Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 include ../scripts/Makefile.include
0003 
0004 bindir ?= /usr/bin
0005 
0006 ifeq ($(srctree),)
0007 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
0008 srctree := $(patsubst %/,%,$(dir $(srctree)))
0009 endif
0010 
0011 # Do not use make's built-in rules
0012 # (this improves performance and avoids hard-to-debug behaviour);
0013 MAKEFLAGS += -r
0014 
0015 CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
0016 
0017 ALL_TARGETS := pcitest
0018 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
0019 
0020 SCRIPTS := pcitest.sh
0021 
0022 all: $(ALL_PROGRAMS)
0023 
0024 export srctree OUTPUT CC LD CFLAGS
0025 include $(srctree)/tools/build/Makefile.include
0026 
0027 #
0028 # We need the following to be outside of kernel tree
0029 #
0030 $(OUTPUT)include/linux/: ../../include/uapi/linux/
0031         mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
0032         ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@
0033 
0034 prepare: $(OUTPUT)include/linux/
0035 
0036 PCITEST_IN := $(OUTPUT)pcitest-in.o
0037 $(PCITEST_IN): prepare FORCE
0038         $(Q)$(MAKE) $(build)=pcitest
0039 $(OUTPUT)pcitest: $(PCITEST_IN)
0040         $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
0041 
0042 clean:
0043         rm -f $(ALL_PROGRAMS)
0044         rm -rf $(OUTPUT)include/
0045         find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
0046 
0047 install: $(ALL_PROGRAMS)
0048         install -d -m 755 $(DESTDIR)$(bindir);          \
0049         for program in $(ALL_PROGRAMS); do              \
0050                 install $$program $(DESTDIR)$(bindir);  \
0051         done;                                           \
0052         for script in $(SCRIPTS); do                    \
0053                 install $$script $(DESTDIR)$(bindir);   \
0054         done
0055 
0056 FORCE:
0057 
0058 .PHONY: all install clean FORCE prepare