Skip to content

Commit 9ca325f

Browse files
Heikki Krogerusgregkh
authored andcommitted
tools: usb: move to tools buildsystem
Converting the Makefile to use the new tools buildsystem. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> [fixes builds with O=...] Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20200819071733.60028-1-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ab565f7 commit 9ca325f

2 files changed

Lines changed: 47 additions & 8 deletions

File tree

‎tools/usb/Build‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
testusb-y += testusb.o
2+
ffs-test-y += ffs-test.o

‎tools/usb/Makefile‎

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,51 @@
11
# SPDX-License-Identifier: GPL-2.0
22
# Makefile for USB tools
3+
include ../scripts/Makefile.include
34

4-
PTHREAD_LIBS = -lpthread
5-
WARNINGS = -Wall -Wextra
6-
CFLAGS = $(WARNINGS) -g -I../include
7-
LDFLAGS = $(PTHREAD_LIBS)
5+
bindir ?= /usr/bin
86

9-
all: testusb ffs-test
10-
%: %.c
11-
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
7+
ifeq ($(srctree),)
8+
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
9+
srctree := $(patsubst %/,%,$(dir $(srctree)))
10+
endif
11+
12+
# Do not use make's built-in rules
13+
# (this improves performance and avoids hard-to-debug behaviour);
14+
MAKEFLAGS += -r
15+
16+
override CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include
17+
override LDFLAGS += -lpthread
18+
19+
ALL_TARGETS := testusb ffs-test
20+
ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
21+
22+
all: $(ALL_PROGRAMS)
23+
24+
export srctree OUTPUT CC LD CFLAGS
25+
include $(srctree)/tools/build/Makefile.include
26+
27+
TESTUSB_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+
33+
FFS_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)
1238

1339
clean:
14-
$(RM) testusb ffs-test
40+
rm -f $(ALL_PROGRAMS)
41+
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete
42+
43+
install: $(ALL_PROGRAMS)
44+
install -d -m 755 $(DESTDIR)$(bindir); \
45+
for program in $(ALL_PROGRAMS); do \
46+
install $$program $(DESTDIR)$(bindir); \
47+
done
48+
49+
FORCE:
50+
51+
.PHONY: all install clean FORCE prepare

0 commit comments

Comments
 (0)