Andy Shevchenko | 8674cea | 2016-06-19 23:41:11 +0300 | [diff] [blame^] | 1 | include ../scripts/Makefile.include |
| 2 | |
| 3 | ifeq ($(srctree),) |
| 4 | srctree := $(patsubst %/,%,$(dir $(shell pwd))) |
| 5 | srctree := $(patsubst %/,%,$(dir $(srctree))) |
| 6 | endif |
| 7 | |
| 8 | # Do not use make's built-in rules |
| 9 | # (this improves performance and avoids hard-to-debug behaviour); |
| 10 | MAKEFLAGS += -r |
| 11 | |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 12 | CC = $(CROSS_COMPILE)gcc |
Andy Shevchenko | 8674cea | 2016-06-19 23:41:11 +0300 | [diff] [blame^] | 13 | LD = $(CROSS_COMPILE)ld |
| 14 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 15 | |
Andy Shevchenko | 8674cea | 2016-06-19 23:41:11 +0300 | [diff] [blame^] | 16 | ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon |
| 17 | ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 18 | |
Andy Shevchenko | 8674cea | 2016-06-19 23:41:11 +0300 | [diff] [blame^] | 19 | all: $(ALL_PROGRAMS) |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 20 | |
Andy Shevchenko | 8674cea | 2016-06-19 23:41:11 +0300 | [diff] [blame^] | 21 | export srctree OUTPUT CC LD CFLAGS |
| 22 | include $(srctree)/tools/build/Makefile.include |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 23 | |
Andy Shevchenko | 8674cea | 2016-06-19 23:41:11 +0300 | [diff] [blame^] | 24 | # |
| 25 | # We need the following to be outside of kernel tree |
| 26 | # |
| 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 $@ |
| 30 | |
| 31 | prepare: $(OUTPUT)include/linux/gpio.h |
| 32 | |
| 33 | # |
| 34 | # lsgpio |
| 35 | # |
| 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 $@ |
| 41 | |
| 42 | # |
| 43 | # gpio-hammer |
| 44 | # |
| 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 $@ |
| 50 | |
| 51 | # |
| 52 | # gpio-event-mon |
| 53 | # |
| 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 $@ |
| 59 | |
Linus Walleij | 6d591c4 | 2015-10-21 15:45:54 +0200 | [diff] [blame] | 60 | clean: |
Andy Shevchenko | 8674cea | 2016-06-19 23:41:11 +0300 | [diff] [blame^] | 61 | rm -f $(ALL_PROGRAMS) |
| 62 | rm -f $(OUTPUT)include/linux/gpio.h |
| 63 | find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete |
| 64 | |
| 65 | FORCE: |
| 66 | |
| 67 | .PHONY: all clean FORCE prepare |