xref: /openbmc/linux/tools/usb/Makefile (revision 5c816641)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
24f22ce70SDavidlohr Bueso# Makefile for USB tools
39ca325ffSHeikki Krogerusinclude ../scripts/Makefile.include
44f22ce70SDavidlohr Bueso
59ca325ffSHeikki Krogerusbindir ?= /usr/bin
64f22ce70SDavidlohr Bueso
79ca325ffSHeikki Krogerusifeq ($(srctree),)
89ca325ffSHeikki Krogerussrctree := $(patsubst %/,%,$(dir $(CURDIR)))
99ca325ffSHeikki Krogerussrctree := $(patsubst %/,%,$(dir $(srctree)))
109ca325ffSHeikki Krogerusendif
119ca325ffSHeikki Krogerus
129ca325ffSHeikki Krogerus# Do not use make's built-in rules
139ca325ffSHeikki Krogerus# (this improves performance and avoids hard-to-debug behaviour);
149ca325ffSHeikki KrogerusMAKEFLAGS += -r
159ca325ffSHeikki Krogerus
169ca325ffSHeikki Krogerusoverride CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include
179ca325ffSHeikki Krogerusoverride LDFLAGS += -lpthread
189ca325ffSHeikki Krogerus
199ca325ffSHeikki KrogerusALL_TARGETS := testusb ffs-test
209ca325ffSHeikki KrogerusALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
219ca325ffSHeikki Krogerus
229ca325ffSHeikki Krogerusall: $(ALL_PROGRAMS)
239ca325ffSHeikki Krogerus
249ca325ffSHeikki Krogerusexport srctree OUTPUT CC LD CFLAGS
259ca325ffSHeikki Krogerusinclude $(srctree)/tools/build/Makefile.include
269ca325ffSHeikki Krogerus
279ca325ffSHeikki KrogerusTESTUSB_IN := $(OUTPUT)testusb-in.o
289ca325ffSHeikki Krogerus$(TESTUSB_IN): FORCE
299ca325ffSHeikki Krogerus	$(Q)$(MAKE) $(build)=testusb
309ca325ffSHeikki Krogerus$(OUTPUT)testusb: $(TESTUSB_IN)
319ca325ffSHeikki Krogerus	$(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
329ca325ffSHeikki Krogerus
339ca325ffSHeikki KrogerusFFS_TEST_IN := $(OUTPUT)ffs-test-in.o
349ca325ffSHeikki Krogerus$(FFS_TEST_IN): FORCE
359ca325ffSHeikki Krogerus	$(Q)$(MAKE) $(build)=ffs-test
369ca325ffSHeikki Krogerus$(OUTPUT)ffs-test: $(FFS_TEST_IN)
379ca325ffSHeikki Krogerus	$(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
384f22ce70SDavidlohr Bueso
394f22ce70SDavidlohr Buesoclean:
409ca325ffSHeikki Krogerus	rm -f $(ALL_PROGRAMS)
41*5c816641SMasahiro Yamada	find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete
429ca325ffSHeikki Krogerus
439ca325ffSHeikki Krogerusinstall: $(ALL_PROGRAMS)
449ca325ffSHeikki Krogerus	install -d -m 755 $(DESTDIR)$(bindir);		\
459ca325ffSHeikki Krogerus	for program in $(ALL_PROGRAMS); do		\
469ca325ffSHeikki Krogerus		install $$program $(DESTDIR)$(bindir);	\
479ca325ffSHeikki Krogerus	done
489ca325ffSHeikki Krogerus
499ca325ffSHeikki KrogerusFORCE:
509ca325ffSHeikki Krogerus
519ca325ffSHeikki Krogerus.PHONY: all install clean FORCE prepare
52