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 override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
0016 
0017 ALL_TARGETS := counter_example
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/counter.h: ../../include/uapi/linux/counter.h
0029         mkdir -p $(OUTPUT)include/linux 2>&1 || true
0030         ln -sf $(CURDIR)/../../include/uapi/linux/counter.h $@
0031 
0032 prepare: $(OUTPUT)include/linux/counter.h
0033 
0034 COUNTER_EXAMPLE := $(OUTPUT)counter_example.o
0035 $(COUNTER_EXAMPLE): prepare FORCE
0036         $(Q)$(MAKE) $(build)=counter_example
0037 $(OUTPUT)counter_example: $(COUNTER_EXAMPLE)
0038         $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
0039 
0040 clean:
0041         rm -f $(ALL_PROGRAMS)
0042         rm -rf $(OUTPUT)include/linux/counter.h
0043         find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
0044 
0045 install: $(ALL_PROGRAMS)
0046         install -d -m 755 $(DESTDIR)$(bindir);          \
0047         for program in $(ALL_PROGRAMS); do              \
0048                 install $$program $(DESTDIR)$(bindir);  \
0049         done
0050 
0051 FORCE:
0052 
0053 .PHONY: all install clean FORCE prepare