xref: /linux/tools/gpio/Makefile (revision e19b7cee020441dd690613d223aed7abb0bcda81)
18674cea8SAndy Shevchenkoinclude ../scripts/Makefile.include
28674cea8SAndy Shevchenko
353499109SAndy Shevchenkobindir ?= /usr/bin
453499109SAndy Shevchenko
58674cea8SAndy Shevchenkoifeq ($(srctree),)
6*e19b7ceeSUwe Kleine-Königsrctree := $(patsubst %/,%,$(dir $(CURDIR)))
78674cea8SAndy Shevchenkosrctree := $(patsubst %/,%,$(dir $(srctree)))
88674cea8SAndy Shevchenkoendif
98674cea8SAndy Shevchenko
108674cea8SAndy Shevchenko# Do not use make's built-in rules
118674cea8SAndy Shevchenko# (this improves performance and avoids hard-to-debug behaviour);
128674cea8SAndy ShevchenkoMAKEFLAGS += -r
138674cea8SAndy Shevchenko
146d591c46SLinus WalleijCC = $(CROSS_COMPILE)gcc
158674cea8SAndy ShevchenkoLD = $(CROSS_COMPILE)ld
168674cea8SAndy ShevchenkoCFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
176d591c46SLinus Walleij
188674cea8SAndy ShevchenkoALL_TARGETS := lsgpio gpio-hammer gpio-event-mon
198674cea8SAndy ShevchenkoALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
206d591c46SLinus Walleij
218674cea8SAndy Shevchenkoall: $(ALL_PROGRAMS)
226d591c46SLinus Walleij
238674cea8SAndy Shevchenkoexport srctree OUTPUT CC LD CFLAGS
248674cea8SAndy Shevchenkoinclude $(srctree)/tools/build/Makefile.include
256d591c46SLinus Walleij
268674cea8SAndy Shevchenko#
278674cea8SAndy Shevchenko# We need the following to be outside of kernel tree
288674cea8SAndy Shevchenko#
298674cea8SAndy Shevchenko$(OUTPUT)include/linux/gpio.h: ../../include/uapi/linux/gpio.h
308674cea8SAndy Shevchenko	mkdir -p $(OUTPUT)include/linux 2>&1 || true
318674cea8SAndy Shevchenko	ln -sf $(CURDIR)/../../include/uapi/linux/gpio.h $@
328674cea8SAndy Shevchenko
338674cea8SAndy Shevchenkoprepare: $(OUTPUT)include/linux/gpio.h
348674cea8SAndy Shevchenko
358674cea8SAndy Shevchenko#
368674cea8SAndy Shevchenko# lsgpio
378674cea8SAndy Shevchenko#
388674cea8SAndy ShevchenkoLSGPIO_IN := $(OUTPUT)lsgpio-in.o
398674cea8SAndy Shevchenko$(LSGPIO_IN): prepare FORCE
408674cea8SAndy Shevchenko	$(Q)$(MAKE) $(build)=lsgpio
418674cea8SAndy Shevchenko$(OUTPUT)lsgpio: $(LSGPIO_IN)
428674cea8SAndy Shevchenko	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
438674cea8SAndy Shevchenko
448674cea8SAndy Shevchenko#
458674cea8SAndy Shevchenko# gpio-hammer
468674cea8SAndy Shevchenko#
478674cea8SAndy ShevchenkoGPIO_HAMMER_IN := $(OUTPUT)gpio-hammer-in.o
488674cea8SAndy Shevchenko$(GPIO_HAMMER_IN): prepare FORCE
498674cea8SAndy Shevchenko	$(Q)$(MAKE) $(build)=gpio-hammer
508674cea8SAndy Shevchenko$(OUTPUT)gpio-hammer: $(GPIO_HAMMER_IN)
518674cea8SAndy Shevchenko	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
528674cea8SAndy Shevchenko
538674cea8SAndy Shevchenko#
548674cea8SAndy Shevchenko# gpio-event-mon
558674cea8SAndy Shevchenko#
568674cea8SAndy ShevchenkoGPIO_EVENT_MON_IN := $(OUTPUT)gpio-event-mon-in.o
578674cea8SAndy Shevchenko$(GPIO_EVENT_MON_IN): prepare FORCE
588674cea8SAndy Shevchenko	$(Q)$(MAKE) $(build)=gpio-event-mon
598674cea8SAndy Shevchenko$(OUTPUT)gpio-event-mon: $(GPIO_EVENT_MON_IN)
608674cea8SAndy Shevchenko	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
618674cea8SAndy Shevchenko
626d591c46SLinus Walleijclean:
638674cea8SAndy Shevchenko	rm -f $(ALL_PROGRAMS)
648674cea8SAndy Shevchenko	rm -f $(OUTPUT)include/linux/gpio.h
658674cea8SAndy Shevchenko	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
668674cea8SAndy Shevchenko
6753499109SAndy Shevchenkoinstall: $(ALL_PROGRAMS)
6853499109SAndy Shevchenko	install -d -m 755 $(DESTDIR)$(bindir);		\
6953499109SAndy Shevchenko	for program in $(ALL_PROGRAMS); do		\
7053499109SAndy Shevchenko		install $$program $(DESTDIR)$(bindir);	\
7153499109SAndy Shevchenko	done
7253499109SAndy Shevchenko
738674cea8SAndy ShevchenkoFORCE:
748674cea8SAndy Shevchenko
7553499109SAndy Shevchenko.PHONY: all install clean FORCE prepare
76