blob: 1b128e551b2e428d0cb5cbb3c862be0e9d7d2963 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Davidlohr Bueso4f22ce72011-02-06 14:13:37 -03002# Makefile for USB tools
Heikki Krogerus9ca325f2020-08-19 10:17:33 +03003include ../scripts/Makefile.include
Davidlohr Bueso4f22ce72011-02-06 14:13:37 -03004
Heikki Krogerus9ca325f2020-08-19 10:17:33 +03005bindir ?= /usr/bin
Davidlohr Bueso4f22ce72011-02-06 14:13:37 -03006
Heikki Krogerus9ca325f2020-08-19 10:17:33 +03007ifeq ($(srctree),)
8srctree := $(patsubst %/,%,$(dir $(CURDIR)))
9srctree := $(patsubst %/,%,$(dir $(srctree)))
10endif
11
12# Do not use make's built-in rules
13# (this improves performance and avoids hard-to-debug behaviour);
14MAKEFLAGS += -r
15
16override CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include
17override LDFLAGS += -lpthread
18
19ALL_TARGETS := testusb ffs-test
20ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
21
22all: $(ALL_PROGRAMS)
23
24export srctree OUTPUT CC LD CFLAGS
25include $(srctree)/tools/build/Makefile.include
26
27TESTUSB_IN := $(OUTPUT)testusb-in.o
28$(TESTUSB_IN): FORCE
29 $(Q)$(MAKE) $(build)=testusb
30$(OUTPUT)testusb: $(TESTUSB_IN)
31 $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
32
33FFS_TEST_IN := $(OUTPUT)ffs-test-in.o
34$(FFS_TEST_IN): FORCE
35 $(Q)$(MAKE) $(build)=ffs-test
36$(OUTPUT)ffs-test: $(FFS_TEST_IN)
37 $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
Davidlohr Bueso4f22ce72011-02-06 14:13:37 -030038
39clean:
Heikki Krogerus9ca325f2020-08-19 10:17:33 +030040 rm -f $(ALL_PROGRAMS)
41 find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete
42
43install: $(ALL_PROGRAMS)
44 install -d -m 755 $(DESTDIR)$(bindir); \
45 for program in $(ALL_PROGRAMS); do \
46 install $$program $(DESTDIR)$(bindir); \
47 done
48
49FORCE:
50
51.PHONY: all install clean FORCE prepare