]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - tools/gpio/Makefile
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-kernels.git] / tools / gpio / Makefile
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
8674cea8
AS
2include ../scripts/Makefile.include
3
53499109
AS
4bindir ?= /usr/bin
5
8674cea8 6ifeq ($(srctree),)
e19b7cee 7srctree := $(patsubst %/,%,$(dir $(CURDIR)))
8674cea8
AS
8srctree := $(patsubst %/,%,$(dir $(srctree)))
9endif
10
11# Do not use make's built-in rules
12# (this improves performance and avoids hard-to-debug behaviour);
13MAKEFLAGS += -r
14
6d591c46 15CC = $(CROSS_COMPILE)gcc
8674cea8
AS
16LD = $(CROSS_COMPILE)ld
17CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
18
19ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon
20ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
21
22all: $(ALL_PROGRAMS)
6d591c46 23
8674cea8
AS
24export srctree OUTPUT CC LD CFLAGS
25include $(srctree)/tools/build/Makefile.include
6d591c46 26
8674cea8
AS
27#
28# We need the following to be outside of kernel tree
29#
30$(OUTPUT)include/linux/gpio.h: ../../include/uapi/linux/gpio.h
31 mkdir -p $(OUTPUT)include/linux 2>&1 || true
32 ln -sf $(CURDIR)/../../include/uapi/linux/gpio.h $@
6d591c46 33
8674cea8
AS
34prepare: $(OUTPUT)include/linux/gpio.h
35
36#
37# lsgpio
38#
39LSGPIO_IN := $(OUTPUT)lsgpio-in.o
40$(LSGPIO_IN): prepare FORCE
41 $(Q)$(MAKE) $(build)=lsgpio
42$(OUTPUT)lsgpio: $(LSGPIO_IN)
43 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
44
45#
46# gpio-hammer
47#
48GPIO_HAMMER_IN := $(OUTPUT)gpio-hammer-in.o
49$(GPIO_HAMMER_IN): prepare FORCE
50 $(Q)$(MAKE) $(build)=gpio-hammer
51$(OUTPUT)gpio-hammer: $(GPIO_HAMMER_IN)
52 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
53
54#
55# gpio-event-mon
56#
57GPIO_EVENT_MON_IN := $(OUTPUT)gpio-event-mon-in.o
58$(GPIO_EVENT_MON_IN): prepare FORCE
59 $(Q)$(MAKE) $(build)=gpio-event-mon
60$(OUTPUT)gpio-event-mon: $(GPIO_EVENT_MON_IN)
61 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
6d591c46 62
6d591c46 63clean:
8674cea8
AS
64 rm -f $(ALL_PROGRAMS)
65 rm -f $(OUTPUT)include/linux/gpio.h
66 find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
67
53499109
AS
68install: $(ALL_PROGRAMS)
69 install -d -m 755 $(DESTDIR)$(bindir); \
70 for program in $(ALL_PROGRAMS); do \
71 install $$program $(DESTDIR)$(bindir); \
72 done
73
8674cea8
AS
74FORCE:
75
53499109 76.PHONY: all install clean FORCE prepare