xref: /linux/tools/gpio/Makefile (revision b24413180f5600bcb3bb70fbed5cf186b60864bd)
1*b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
28674cea8SAndy Shevchenkoinclude ../scripts/Makefile.include
38674cea8SAndy Shevchenko
453499109SAndy Shevchenkobindir ?= /usr/bin
553499109SAndy Shevchenko
68674cea8SAndy Shevchenkoifeq ($(srctree),)
7e19b7ceeSUwe Kleine-Königsrctree := $(patsubst %/,%,$(dir $(CURDIR)))
88674cea8SAndy Shevchenkosrctree := $(patsubst %/,%,$(dir $(srctree)))
98674cea8SAndy Shevchenkoendif
108674cea8SAndy Shevchenko
118674cea8SAndy Shevchenko# Do not use make's built-in rules
128674cea8SAndy Shevchenko# (this improves performance and avoids hard-to-debug behaviour);
138674cea8SAndy ShevchenkoMAKEFLAGS += -r
148674cea8SAndy Shevchenko
156d591c46SLinus WalleijCC = $(CROSS_COMPILE)gcc
168674cea8SAndy ShevchenkoLD = $(CROSS_COMPILE)ld
178674cea8SAndy ShevchenkoCFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
186d591c46SLinus Walleij
198674cea8SAndy ShevchenkoALL_TARGETS := lsgpio gpio-hammer gpio-event-mon
208674cea8SAndy ShevchenkoALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
216d591c46SLinus Walleij
228674cea8SAndy Shevchenkoall: $(ALL_PROGRAMS)
236d591c46SLinus Walleij
248674cea8SAndy Shevchenkoexport srctree OUTPUT CC LD CFLAGS
258674cea8SAndy Shevchenkoinclude $(srctree)/tools/build/Makefile.include
266d591c46SLinus Walleij
278674cea8SAndy Shevchenko#
288674cea8SAndy Shevchenko# We need the following to be outside of kernel tree
298674cea8SAndy Shevchenko#
308674cea8SAndy Shevchenko$(OUTPUT)include/linux/gpio.h: ../../include/uapi/linux/gpio.h
318674cea8SAndy Shevchenko	mkdir -p $(OUTPUT)include/linux 2>&1 || true
328674cea8SAndy Shevchenko	ln -sf $(CURDIR)/../../include/uapi/linux/gpio.h $@
338674cea8SAndy Shevchenko
348674cea8SAndy Shevchenkoprepare: $(OUTPUT)include/linux/gpio.h
358674cea8SAndy Shevchenko
368674cea8SAndy Shevchenko#
378674cea8SAndy Shevchenko# lsgpio
388674cea8SAndy Shevchenko#
398674cea8SAndy ShevchenkoLSGPIO_IN := $(OUTPUT)lsgpio-in.o
408674cea8SAndy Shevchenko$(LSGPIO_IN): prepare FORCE
418674cea8SAndy Shevchenko	$(Q)$(MAKE) $(build)=lsgpio
428674cea8SAndy Shevchenko$(OUTPUT)lsgpio: $(LSGPIO_IN)
438674cea8SAndy Shevchenko	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
448674cea8SAndy Shevchenko
458674cea8SAndy Shevchenko#
468674cea8SAndy Shevchenko# gpio-hammer
478674cea8SAndy Shevchenko#
488674cea8SAndy ShevchenkoGPIO_HAMMER_IN := $(OUTPUT)gpio-hammer-in.o
498674cea8SAndy Shevchenko$(GPIO_HAMMER_IN): prepare FORCE
508674cea8SAndy Shevchenko	$(Q)$(MAKE) $(build)=gpio-hammer
518674cea8SAndy Shevchenko$(OUTPUT)gpio-hammer: $(GPIO_HAMMER_IN)
528674cea8SAndy Shevchenko	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
538674cea8SAndy Shevchenko
548674cea8SAndy Shevchenko#
558674cea8SAndy Shevchenko# gpio-event-mon
568674cea8SAndy Shevchenko#
578674cea8SAndy ShevchenkoGPIO_EVENT_MON_IN := $(OUTPUT)gpio-event-mon-in.o
588674cea8SAndy Shevchenko$(GPIO_EVENT_MON_IN): prepare FORCE
598674cea8SAndy Shevchenko	$(Q)$(MAKE) $(build)=gpio-event-mon
608674cea8SAndy Shevchenko$(OUTPUT)gpio-event-mon: $(GPIO_EVENT_MON_IN)
618674cea8SAndy Shevchenko	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
628674cea8SAndy Shevchenko
636d591c46SLinus Walleijclean:
648674cea8SAndy Shevchenko	rm -f $(ALL_PROGRAMS)
658674cea8SAndy Shevchenko	rm -f $(OUTPUT)include/linux/gpio.h
668674cea8SAndy Shevchenko	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
678674cea8SAndy Shevchenko
6853499109SAndy Shevchenkoinstall: $(ALL_PROGRAMS)
6953499109SAndy Shevchenko	install -d -m 755 $(DESTDIR)$(bindir);		\
7053499109SAndy Shevchenko	for program in $(ALL_PROGRAMS); do		\
7153499109SAndy Shevchenko		install $$program $(DESTDIR)$(bindir);	\
7253499109SAndy Shevchenko	done
7353499109SAndy Shevchenko
748674cea8SAndy ShevchenkoFORCE:
758674cea8SAndy Shevchenko
7653499109SAndy Shevchenko.PHONY: all install clean FORCE prepare
77