Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
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 := spidev_test spidev_fdx
0018 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
0019 
0020 all: $(ALL_PROGRAMS)
0021 
0022 export srctree OUTPUT CC LD CFLAGS
0023 include $(srctree)/tools/build/Makefile.include
0024 
0025 #
0026 # We need the following to be outside of kernel tree
0027 #
0028 $(OUTPUT)include/linux/spi: ../../include/uapi/linux/spi
0029         mkdir -p $(OUTPUT)include/linux/spi 2>&1 || true
0030         ln -sf $(CURDIR)/../../include/uapi/linux/spi/spidev.h $@
0031         ln -sf $(CURDIR)/../../include/uapi/linux/spi/spi.h $@
0032 
0033 prepare: $(OUTPUT)include/linux/spi
0034 
0035 #
0036 # spidev_test
0037 #
0038 SPIDEV_TEST_IN := $(OUTPUT)spidev_test-in.o
0039 $(SPIDEV_TEST_IN): prepare FORCE
0040         $(Q)$(MAKE) $(build)=spidev_test
0041 $(OUTPUT)spidev_test: $(SPIDEV_TEST_IN)
0042         $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
0043 
0044 #
0045 # spidev_fdx
0046 #
0047 SPIDEV_FDX_IN := $(OUTPUT)spidev_fdx-in.o
0048 $(SPIDEV_FDX_IN): prepare FORCE
0049         $(Q)$(MAKE) $(build)=spidev_fdx
0050 $(OUTPUT)spidev_fdx: $(SPIDEV_FDX_IN)
0051         $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
0052 
0053 clean:
0054         rm -f $(ALL_PROGRAMS)
0055         rm -rf $(OUTPUT)include/
0056         find $(or $(OUTPUT),.) -name '*.o' -delete
0057         find $(or $(OUTPUT),.) -name '\.*.o.d' -delete
0058         find $(or $(OUTPUT),.) -name '\.*.o.cmd' -delete
0059 
0060 install: $(ALL_PROGRAMS)
0061         install -d -m 755 $(DESTDIR)$(bindir);          \
0062         for program in $(ALL_PROGRAMS); do              \
0063                 install $$program $(DESTDIR)$(bindir);  \
0064         done
0065 
0066 FORCE:
0067 
0068 .PHONY: all install clean FORCE prepare