Commit 0f691878 authored by Ian Campbell's avatar Ian Campbell Committed by Siarhei Siamashka
Browse files

Makefile: Add an install rule



Allow for separate installation of tools and target-tools, to aid in packaging.

By default everything the tools are installed into /usr/local/bin but this can
be overridden using PREFIX= or BINDIR= on the make invocation.

To enable this it was necessary to split fex2bin and bin2fex out from $(TOOLS)
into $(FEXC_LINKS), because install(1) does not seem to have a mode which
preserves symlinks so it needs to be done separately.

Supports DESTDIR to allow for convenient installation into a staging dir for
distro packaging convenience.
Signed-off-by: default avatarIan Campbell <ijc@hellion.org.uk>
Acked-by: default avatarPeter Korsgaard <peter@korsgaard.com>
parent bf4ec9a0
......@@ -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 > $@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment