18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ciinclude ../scripts/Makefile.include 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_cibindir ?= /usr/bin 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci# This will work when gpio is built in tools env. where srctree 78c2ecf20Sopenharmony_ci# isn't set and when invoked from selftests build, where srctree 88c2ecf20Sopenharmony_ci# is set to ".". building_out_of_srctree is undefined for in srctree 98c2ecf20Sopenharmony_ci# builds 108c2ecf20Sopenharmony_ciifndef building_out_of_srctree 118c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR))) 128c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree))) 138c2ecf20Sopenharmony_ciendif 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci# Do not use make's built-in rules 168c2ecf20Sopenharmony_ci# (this improves performance and avoids hard-to-debug behaviour); 178c2ecf20Sopenharmony_ciMAKEFLAGS += -r 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cioverride CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciALL_TARGETS := lsgpio gpio-hammer gpio-event-mon gpio-watch 228c2ecf20Sopenharmony_ciALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciall: $(ALL_PROGRAMS) 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS 278c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci# 308c2ecf20Sopenharmony_ci# We need the following to be outside of kernel tree 318c2ecf20Sopenharmony_ci# 328c2ecf20Sopenharmony_ci$(OUTPUT)include/linux/gpio.h: ../../include/uapi/linux/gpio.h 338c2ecf20Sopenharmony_ci mkdir -p $(OUTPUT)include/linux 2>&1 || true 348c2ecf20Sopenharmony_ci ln -sf $(CURDIR)/../../include/uapi/linux/gpio.h $@ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciprepare: $(OUTPUT)include/linux/gpio.h 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciGPIO_UTILS_IN := $(OUTPUT)gpio-utils-in.o 398c2ecf20Sopenharmony_ci$(GPIO_UTILS_IN): prepare FORCE 408c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=gpio-utils 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci# 438c2ecf20Sopenharmony_ci# lsgpio 448c2ecf20Sopenharmony_ci# 458c2ecf20Sopenharmony_ciLSGPIO_IN := $(OUTPUT)lsgpio-in.o 468c2ecf20Sopenharmony_ci$(LSGPIO_IN): prepare FORCE $(OUTPUT)gpio-utils-in.o 478c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=lsgpio 488c2ecf20Sopenharmony_ci$(OUTPUT)lsgpio: $(LSGPIO_IN) 498c2ecf20Sopenharmony_ci $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci# 528c2ecf20Sopenharmony_ci# gpio-hammer 538c2ecf20Sopenharmony_ci# 548c2ecf20Sopenharmony_ciGPIO_HAMMER_IN := $(OUTPUT)gpio-hammer-in.o 558c2ecf20Sopenharmony_ci$(GPIO_HAMMER_IN): prepare FORCE $(OUTPUT)gpio-utils-in.o 568c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=gpio-hammer 578c2ecf20Sopenharmony_ci$(OUTPUT)gpio-hammer: $(GPIO_HAMMER_IN) 588c2ecf20Sopenharmony_ci $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci# 618c2ecf20Sopenharmony_ci# gpio-event-mon 628c2ecf20Sopenharmony_ci# 638c2ecf20Sopenharmony_ciGPIO_EVENT_MON_IN := $(OUTPUT)gpio-event-mon-in.o 648c2ecf20Sopenharmony_ci$(GPIO_EVENT_MON_IN): prepare FORCE $(OUTPUT)gpio-utils-in.o 658c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=gpio-event-mon 668c2ecf20Sopenharmony_ci$(OUTPUT)gpio-event-mon: $(GPIO_EVENT_MON_IN) 678c2ecf20Sopenharmony_ci $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci# 708c2ecf20Sopenharmony_ci# gpio-watch 718c2ecf20Sopenharmony_ci# 728c2ecf20Sopenharmony_ciGPIO_WATCH_IN := $(OUTPUT)gpio-watch-in.o 738c2ecf20Sopenharmony_ci$(GPIO_WATCH_IN): prepare FORCE 748c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=gpio-watch 758c2ecf20Sopenharmony_ci$(OUTPUT)gpio-watch: $(GPIO_WATCH_IN) 768c2ecf20Sopenharmony_ci $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciclean: 798c2ecf20Sopenharmony_ci rm -f $(ALL_PROGRAMS) 808c2ecf20Sopenharmony_ci rm -f $(OUTPUT)include/linux/gpio.h 818c2ecf20Sopenharmony_ci find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciinstall: $(ALL_PROGRAMS) 848c2ecf20Sopenharmony_ci install -d -m 755 $(DESTDIR)$(bindir); \ 858c2ecf20Sopenharmony_ci for program in $(ALL_PROGRAMS); do \ 868c2ecf20Sopenharmony_ci install $$program $(DESTDIR)$(bindir); \ 878c2ecf20Sopenharmony_ci done 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciFORCE: 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci.PHONY: all install clean FORCE prepare 92