52 lines · plain
1# SPDX-License-Identifier: GPL-2.02# Makefile for USB tools3include ../scripts/Makefile.include4 5bindir ?= /usr/bin6 7ifeq ($(srctree),)8srctree := $(patsubst %/,%,$(dir $(CURDIR)))9srctree := $(patsubst %/,%,$(dir $(srctree)))10endif11 12# Do not use make's built-in rules13# (this improves performance and avoids hard-to-debug behaviour);14MAKEFLAGS += -r15 16override CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include17override LDFLAGS += -lpthread18 19ALL_TARGETS := testusb ffs-test20ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))21 22all: $(ALL_PROGRAMS)23 24export srctree OUTPUT CC LD CFLAGS25include $(srctree)/tools/build/Makefile.include26 27TESTUSB_IN := $(OUTPUT)testusb-in.o28$(TESTUSB_IN): FORCE29 $(Q)$(MAKE) $(build)=testusb30$(OUTPUT)testusb: $(TESTUSB_IN)31 $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)32 33FFS_TEST_IN := $(OUTPUT)ffs-test-in.o34$(FFS_TEST_IN): FORCE35 $(Q)$(MAKE) $(build)=ffs-test36$(OUTPUT)ffs-test: $(FFS_TEST_IN)37 $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)38 39clean:40 rm -f $(ALL_PROGRAMS)41 find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete42 43install: $(ALL_PROGRAMS)44 install -d -m 755 $(DESTDIR)$(bindir); \45 for program in $(ALL_PROGRAMS); do \46 install $$program $(DESTDIR)$(bindir); \47 done48 49FORCE:50 51.PHONY: all install clean FORCE prepare52