1 include ../scripts/Makefile.include
4 srctree := $(patsubst %/,%,$(dir $(shell pwd)))
5 srctree := $(patsubst %/,%,$(dir $(srctree)))
8 # Do not use make's built-in rules
9 # (this improves performance and avoids hard-to-debug behaviour);
12 CC = $(CROSS_COMPILE)gcc
13 LD = $(CROSS_COMPILE)ld
14 CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
16 ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon
17 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
21 export srctree OUTPUT CC LD CFLAGS
22 include $(srctree)/tools/build/Makefile.include
25 # We need the following to be outside of kernel tree
27 $(OUTPUT)include/linux/gpio.h: ../../include/uapi/linux/gpio.h
28 mkdir -p $(OUTPUT)include/linux 2>&1 || true
29 ln -sf $(CURDIR)/../../include/uapi/linux/gpio.h $@
31 prepare: $(OUTPUT)include/linux/gpio.h
36 LSGPIO_IN := $(OUTPUT)lsgpio-in.o
37 $(LSGPIO_IN): prepare FORCE
38 $(Q)$(MAKE) $(build)=lsgpio
39 $(OUTPUT)lsgpio: $(LSGPIO_IN)
40 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
45 GPIO_HAMMER_IN := $(OUTPUT)gpio-hammer-in.o
46 $(GPIO_HAMMER_IN): prepare FORCE
47 $(Q)$(MAKE) $(build)=gpio-hammer
48 $(OUTPUT)gpio-hammer: $(GPIO_HAMMER_IN)
49 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
54 GPIO_EVENT_MON_IN := $(OUTPUT)gpio-event-mon-in.o
55 $(GPIO_EVENT_MON_IN): prepare FORCE
56 $(Q)$(MAKE) $(build)=gpio-event-mon
57 $(OUTPUT)gpio-event-mon: $(GPIO_EVENT_MON_IN)
58 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
62 rm -f $(OUTPUT)include/linux/gpio.h
63 find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
67 .PHONY: all clean FORCE prepare