diff --git a/Makefile b/Makefile index 67dfafa..c5a2906 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,10 @@ CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L CFLAGS += -Iinclude/ # Tools useful on host and target -TOOLS = sunxi-fexc bin2fex fex2bin sunxi-bootinfo sunxi-fel -TOOLS += sunxi-nand-part +TOOLS = sunxi-fexc sunxi-bootinfo sunxi-fel sunxi-nand-part + +# Symlinks to sunxi-fexc +FEXC_LINKS = bin2fex fex2bin # Tools which are only useful on the target TARGET_TOOLS = sunxi-pio @@ -32,18 +34,40 @@ MISC_TOOLS = phoenix_info CROSS_COMPILE ?= arm-none-eabi- -.PHONY: all clean tools target-tools +DESTDIR ?= +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin + +.PHONY: all clean tools target-tools install install-tools install-target-tools all: tools target-tools -tools: $(TOOLS) +tools: $(TOOLS) $(FEXC_LINKS) target-tools: $(TARGET_TOOLS) misc: $(MISC_TOOLS) -clean: - @rm -vf $(TOOLS) $(TARGET_TOOLS) $(MISC_TOOLS) *.o *.elf *.sunxi *.bin *.nm *.orig +install: install-tools install-target-tools +install-tools: $(TOOLS) + install -d $(DESTDIR)$(BINDIR) + @set -ex ; for t in $^ ; do \ + install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \ + done + @set -ex ; for l in $(FEXC_LINKS) ; do \ + ln -nfs sunxi-fexc $(DESTDIR)$(BINDIR)/$$l ; \ + done + +install-target-tools: $(TARGET_TOOLS) + install -d $(DESTDIR)$(BINDIR) + @set -ex ; for t in $^ ; do \ + install -m0755 $$t $(DESTDIR)$(BINDIR)/$$t ; \ + done + + +clean: + @rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS) + @rm -vf *.o *.elf *.sunxi *.bin *.nm *.orig $(TOOLS) $(TARGET_TOOLS): Makefile common.h @@ -122,6 +146,6 @@ sunxi-meminfo: meminfo.c $(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^ .gitignore: Makefile - @for x in $(TOOLS) $(TARGET_TOOLS) '*.o' '*.swp'; do \ + @for x in $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) '*.o' '*.swp'; do \ echo "$$x"; \ done > $@