From a77230a6e873cc745e9f55eb73bac70a9b6ca7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:18:13 +0200 Subject: [PATCH 01/10] Proper install support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use quotes to support spaces and such. Use -- to support dashes. And most important: Use DESTDIR to support installing into a staging directory. This is useful for packaging and verifying the install. Signed-off-by: Mattias Andrée --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index de0fff3..f7c3f8d 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,9 @@ INSTALL = $(PREFIX)/bin/exa $(INSTALL): # BSD and OSX don't have -D to create leading directories - install -dm755 $(PREFIX)/bin/ $(PREFIX)/share/man/man1/ - install -sm755 target/release/exa $(PREFIX)/bin/ - install -m644 contrib/man/*.1 $(PREFIX)/share/man/man1/ + install -dm755 -- "$(PREFIX)/bin/" "$(DESTDIR)$(PREFIX)/share/man/man1/" + install -sm755 -- target/release/exa "$(DESTDIR)$(PREFIX)/bin/" + install -m644 -- contrib/man/*.1 "$(DESTDIR)$(PREFIX)/share/man/man1/" install: build $(INSTALL) From 54ed5f675621debcd72e7d70e1ecfc348f5cfe6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:38:47 +0200 Subject: [PATCH 02/10] Work around a bug in cargo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f7c3f8d..d7b560b 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,21 @@ BUILD = target/release/exa $(BUILD): @which rustc > /dev/null || { echo "exa requires Rust to compile. For installation instructions, please visit http://rust-lang.org/"; exit 1; } - cargo build --release + if test -n "$$(echo "$$CC" | cut -d \ -f 1)"; then \ + env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release; \ + else\ + env -u CC cargo build --release; \ + fi build: $(BUILD) build-no-git: @which rustc > /dev/null || { echo "exa requires Rust to compile. For installation instructions, please visit http://rust-lang.org/"; exit 1; } - cargo build --release --no-default-features + if test -n "$$(echo "$$CC" | cut -d \ -f 1)"; then \ + env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release --no-default-features; \ + else\ + env -u CC cargo build --release --no-default-features; \ + fi INSTALL = $(PREFIX)/bin/exa From bbdcd526962a3b709f1804468d3728d989726e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:40:04 +0200 Subject: [PATCH 03/10] Do not look for rustc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You need cargo, not rustc, and cargo requires rustc, so checking for rustc is incorrect. And the user will know that she needs cargo when the command cannot be find, so why look for it and add extra dependenices just for that. Signed-off-by: Mattias Andrée --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index d7b560b..f96748c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ PREFIX ?= /usr/local BUILD = target/release/exa $(BUILD): - @which rustc > /dev/null || { echo "exa requires Rust to compile. For installation instructions, please visit http://rust-lang.org/"; exit 1; } if test -n "$$(echo "$$CC" | cut -d \ -f 1)"; then \ env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release; \ else\ @@ -13,7 +12,6 @@ $(BUILD): build: $(BUILD) build-no-git: - @which rustc > /dev/null || { echo "exa requires Rust to compile. For installation instructions, please visit http://rust-lang.org/"; exit 1; } if test -n "$$(echo "$$CC" | cut -d \ -f 1)"; then \ env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release --no-default-features; \ else\ From 05451b7db877c62ec2bfbd8243aeaa69a7c7d88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:48:07 +0200 Subject: [PATCH 04/10] Fix install rule and add uninstall rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f96748c..d6f584c 100644 --- a/Makefile +++ b/Makefile @@ -18,14 +18,16 @@ build-no-git: env -u CC cargo build --release --no-default-features; \ fi -INSTALL = $(PREFIX)/bin/exa - -$(INSTALL): +install: target/release/exa # BSD and OSX don't have -D to create leading directories install -dm755 -- "$(PREFIX)/bin/" "$(DESTDIR)$(PREFIX)/share/man/man1/" install -sm755 -- target/release/exa "$(DESTDIR)$(PREFIX)/bin/" - install -m644 -- contrib/man/*.1 "$(DESTDIR)$(PREFIX)/share/man/man1/" + install -m644 -- contrib/man/exa.1 "$(DESTDIR)$(PREFIX)/share/man/man1/" -install: build $(INSTALL) +uninstall: + -rm -- "$(DESTDIR)$(PREFIX)/share/man/man1/exa.1" + -rmdir -- "$(DESTDIR)$(PREFIX)/share/man/man1" + -rm -- "$(DESTDIR)$(PREFIX)/bin/exa" + -rmdir -- "$(DESTDIR)$(PREFIX)/bin" -.PHONY: install +.PHONY: install uninstall From f30c75c224eacceced56f789ff3e4cf2ad4df42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:50:08 +0200 Subject: [PATCH 05/10] Add clean rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d6f584c..751db11 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,7 @@ uninstall: -rm -- "$(DESTDIR)$(PREFIX)/bin/exa" -rmdir -- "$(DESTDIR)$(PREFIX)/bin" -.PHONY: install uninstall +clean: + -rm -rf target + +.PHONY: install uninstall clean From 3d966e818443bd1ddae92cb2422d75e67ee7b535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:51:10 +0200 Subject: [PATCH 06/10] Use = and not ?= for PREFIX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 751db11..7d6e04f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PREFIX ?= /usr/local +PREFIX = /usr/local BUILD = target/release/exa From d894a3a475596f21f24e7275c7734203f7970717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:55:56 +0200 Subject: [PATCH 07/10] Improve build rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 7d6e04f..220aa54 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,18 @@ PREFIX = /usr/local -BUILD = target/release/exa +CARGOFLAGS = --no-default-features -$(BUILD): +all: target/release/exa + +build: CARGOFLAGS= +build: all +build-no-git: all + +target/release/exa: if test -n "$$(echo "$$CC" | cut -d \ -f 1)"; then \ - env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release; \ + env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release $(CARGOFLAGS); \ else\ - env -u CC cargo build --release; \ - fi - -build: $(BUILD) - -build-no-git: - if test -n "$$(echo "$$CC" | cut -d \ -f 1)"; then \ - env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release --no-default-features; \ - else\ - env -u CC cargo build --release --no-default-features; \ + env -u CC cargo build --release $(CARGOFLAGS); \ fi install: target/release/exa @@ -33,4 +30,4 @@ uninstall: clean: -rm -rf target -.PHONY: install uninstall clean +.PHONY: all build build-no-git install uninstall clean From 1099dad9d0c56526f865deeb296f4b09e05e0407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 13:58:45 +0200 Subject: [PATCH 08/10] Add a missed DESTDIR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 220aa54..2539719 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ target/release/exa: install: target/release/exa # BSD and OSX don't have -D to create leading directories - install -dm755 -- "$(PREFIX)/bin/" "$(DESTDIR)$(PREFIX)/share/man/man1/" + install -dm755 -- "$(DESTDIR)$(PREFIX)/bin/" "$(DESTDIR)$(PREFIX)/share/man/man1/" install -sm755 -- target/release/exa "$(DESTDIR)$(PREFIX)/bin/" install -m644 -- contrib/man/exa.1 "$(DESTDIR)$(PREFIX)/share/man/man1/" From f9208f9af88cbd3352b695a170fd7489a44688e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Mon, 4 Jul 2016 19:02:22 +0200 Subject: [PATCH 09/10] Don't strip binaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let the package manager do it. You don't want to force stripping, the symbols are useful for debugging. Signed-off-by: Mattias Andrée --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2539719..8a50b24 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ target/release/exa: install: target/release/exa # BSD and OSX don't have -D to create leading directories install -dm755 -- "$(DESTDIR)$(PREFIX)/bin/" "$(DESTDIR)$(PREFIX)/share/man/man1/" - install -sm755 -- target/release/exa "$(DESTDIR)$(PREFIX)/bin/" + install -m755 -- target/release/exa "$(DESTDIR)$(PREFIX)/bin/" install -m644 -- contrib/man/exa.1 "$(DESTDIR)$(PREFIX)/share/man/man1/" uninstall: From 079c36b9f510d274dd02c5320950a72d4b1ca430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Tue, 5 Jul 2016 00:55:48 +0200 Subject: [PATCH 10/10] Rebulid when the source has been updated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You could use src/*.rs src/*/*.rs src/*/*/*.rs, but explicit listing is prefered. Ideally, you should be separate object files that are rebuilt only when necessary, and then build the final binary from those. But have not looked at how to compile rust code so I don't know how to do that, and since there are no header files that is also probably suboptimal. Signed-off-by: Mattias Andrée --- Makefile | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8a50b24..ad317ae 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,33 @@ +SRC = \ + src/info/sources.rs \ + src/info/mod.rs \ + src/info/filetype.rs \ + src/bin/main.rs \ + src/term.rs \ + src/exa.rs \ + src/output/grid_details.rs \ + src/output/tree.rs \ + src/output/colours.rs \ + src/output/grid.rs \ + src/output/cell.rs \ + src/output/mod.rs \ + src/output/details.rs \ + src/output/lines.rs \ + src/output/column.rs \ + src/fs/file.rs \ + src/fs/fields.rs \ + src/fs/mod.rs \ + src/fs/dir.rs \ + src/fs/feature/xattr.rs \ + src/fs/feature/git.rs \ + src/fs/feature/mod.rs \ + src/options/misfire.rs \ + src/options/filter.rs \ + src/options/dir_action.rs \ + src/options/view.rs \ + src/options/mod.rs \ + src/options/help.rs + PREFIX = /usr/local CARGOFLAGS = --no-default-features @@ -8,7 +38,7 @@ build: CARGOFLAGS= build: all build-no-git: all -target/release/exa: +target/release/exa: $(SRC) if test -n "$$(echo "$$CC" | cut -d \ -f 1)"; then \ env CC="$$(echo "$$CC" | cut -d \ -f 1)" cargo build --release $(CARGOFLAGS); \ else\