xref: /kernel/linux/linux-5.10/tools/usb/Makefile (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci# Makefile for USB tools
38c2ecf20Sopenharmony_ciinclude ../scripts/Makefile.include
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_cibindir ?= /usr/bin
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciifeq ($(srctree),)
88c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR)))
98c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
108c2ecf20Sopenharmony_ciendif
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci# Do not use make's built-in rules
138c2ecf20Sopenharmony_ci# (this improves performance and avoids hard-to-debug behaviour);
148c2ecf20Sopenharmony_ciMAKEFLAGS += -r
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cioverride CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include
178c2ecf20Sopenharmony_cioverride LDFLAGS += -lpthread
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciALL_TARGETS := testusb ffs-test
208c2ecf20Sopenharmony_ciALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciall: $(ALL_PROGRAMS)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS
258c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciTESTUSB_IN := $(OUTPUT)testusb-in.o
288c2ecf20Sopenharmony_ci$(TESTUSB_IN): FORCE
298c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=testusb
308c2ecf20Sopenharmony_ci$(OUTPUT)testusb: $(TESTUSB_IN)
318c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciFFS_TEST_IN := $(OUTPUT)ffs-test-in.o
348c2ecf20Sopenharmony_ci$(FFS_TEST_IN): FORCE
358c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=ffs-test
368c2ecf20Sopenharmony_ci$(OUTPUT)ffs-test: $(FFS_TEST_IN)
378c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciclean:
408c2ecf20Sopenharmony_ci	rm -f $(ALL_PROGRAMS)
418c2ecf20Sopenharmony_ci	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciinstall: $(ALL_PROGRAMS)
448c2ecf20Sopenharmony_ci	install -d -m 755 $(DESTDIR)$(bindir);		\
458c2ecf20Sopenharmony_ci	for program in $(ALL_PROGRAMS); do		\
468c2ecf20Sopenharmony_ci		install $$program $(DESTDIR)$(bindir);	\
478c2ecf20Sopenharmony_ci	done
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciFORCE:
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci.PHONY: all install clean FORCE prepare
52