From 0bb67fe13a04fc008a36b0442e5a2a4d4455b60b Mon Sep 17 00:00:00 2001 From: Arcterus Date: Thu, 12 Jun 2014 18:43:52 -0700 Subject: [PATCH 1/3] Add the ability to install coreutils (resolves #216) --- Makefile | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8ef8504e8..e51a8a0d9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ include common.mk +PREFIX ?= /usr/local +BINDIR ?= /bin + SRC_DIR=$(shell pwd) # Possible programs @@ -84,11 +87,11 @@ command = sh -c '$(1)' # Main exe build rule define EXE_BUILD ifeq ($(wildcard $(1)/Makefile),) -build/$(1): $(1)/$(1).rs +build/$(1): $(1)/$(1).rs | build $(call command,$(RUSTC) $(RUSTCFLAGS) -o build/$(1) $(1)/$(1).rs) clean_$(1): else -build/$(1): $(1)/$(1).rs +build/$(1): $(1)/$(1).rs | build cd $(1) && make clean_$(1): cd $(1) && make clean @@ -96,13 +99,13 @@ endif endef define CRATE_BUILD -build/$(2): $(1)/$(1).rs +build/$(2): $(1)/$(1).rs | build $(call command,$(RUSTC) $(RUSTCFLAGS) --crate-type rlib $(1)/$(1).rs --out-dir build) endef # Test exe built rules define TEST_BUILD -test_$(1): tmp/$(1)_test build build/$(1) +test_$(1): tmp/$(1)_test build/$(1) $(call command,tmp/$(1)_test) tmp/$(1)_test: $(1)/test.rs @@ -111,9 +114,9 @@ endef # Main rules ifneq ($(MULTICALL), 1) -all: build $(EXES_PATHS) +all: $(EXES_PATHS) else -all: build build/uutils +all: build/uutils build/uutils: uutils/uutils.rs $(addprefix build/, $(foreach crate,$(CRATES),$(shell $(RUSTC) --crate-type rlib --crate-file-name $(crate)/$(crate).rs))) $(RUSTC) $(RUSTCFLAGS) -L build/ uutils/uutils.rs -o $@ @@ -133,10 +136,29 @@ tmp: mkdir tmp # Creating necessary rules for each targets -$(foreach exe,$(EXES),$(eval $(call EXE_BUILD,$(exe)))) -$(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test)))) ifeq ($(MULTICALL), 1) $(foreach crate,$(CRATES),$(eval $(call CRATE_BUILD,$(crate),$(shell $(RUSTC) --crate-type rlib --crate-file-name --out-dir build $(crate)/$(crate).rs)))) +else +$(foreach exe,$(EXES),$(eval $(call EXE_BUILD,$(exe)))) +endif +$(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test)))) + +ifeq ($(MULTICALL), 1) +install: build/uutils + mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR) + install build/uutils $(DESTDIR)$(PREFIX)$(BINDIR)/uutils + +uninstall: + rm -f $(DESTDIR)$(PREFIX)$(BINDIR)/uutils +else +install: $(EXES_PATHS) + mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR) + for prog in $(EXES); do \ + install build/$$prog $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX)$$prog; \ + done + +uninstall: + rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS)) endif # Test under the busybox testsuite @@ -163,4 +185,4 @@ busytest: build/busybox build/.config endif endif -.PHONY: all test clean busytest +.PHONY: all test clean busytest install uninstall From 986d7cba79b638be7da1a964707f3cc4c675fe33 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Thu, 12 Jun 2014 19:14:56 -0700 Subject: [PATCH 2/3] Add some installation instructions --- Makefile | 9 +++++++-- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e51a8a0d9..3a0a9f437 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,11 @@ EXES := \ CRATES := \ $(sort $(filter $(EXES), $(filter-out md5sum true false, $(EXES)))) +INSTALL ?= $(EXES) + +INSTALLEES := \ + $(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES))) + # Programs with usable tests TEST_PROGS := \ cat \ @@ -151,9 +156,9 @@ install: build/uutils uninstall: rm -f $(DESTDIR)$(PREFIX)$(BINDIR)/uutils else -install: $(EXES_PATHS) +install: $(addprefix build/,$(INSTALLEES)) mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR) - for prog in $(EXES); do \ + for prog in $(INSTALLEES); do \ install build/$$prog $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX)$$prog; \ done diff --git a/README.md b/README.md index 4abdbfb52..7b780f7fe 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,45 @@ To build only a few of the available utilities: make BUILD='UTILITY_1 UTILITY_2' ``` +To build the multicall binary (_i.e._ BusyBox-like binary): +``` +make MULTICALL=1 +``` + +Installation Instructions +------------------------- + +To install all available utilities: +``` +make install +``` + +To install all but a few of the available utilities: +``` +make DONT_INSTALL='UTILITY_1 UTILITY_2' install +``` + +To install only a few of the available utilities: +``` +make INSTALL='UTILITY_1 UTILITY_2' install +``` + +To install the multicall binary: +``` +make MULTICALL=1 install +``` + +To install every program (other than the multicall binary) with a prefix: +``` +make PROG_PREFIX=PREFIX_GOES_HERE install +``` + +Uninstallation Instructions +--------------------------- + +Do the same command as in the Installation Instructions above, but replace +```install``` with ```uninstall```. + Test Instructions ----------------- @@ -76,6 +115,7 @@ To do - chown - chroot - copy +- cp (not much done) - cp-hash - csplit - cut From 18fda74885dbe4081702d8ca0ddc5f8b5e4f8121 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Thu, 12 Jun 2014 19:49:00 -0700 Subject: [PATCH 3/3] Clarify uninstallation instructions --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b780f7fe..0ebe47eea 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,20 @@ make PROG_PREFIX=PREFIX_GOES_HERE install Uninstallation Instructions --------------------------- -Do the same command as in the Installation Instructions above, but replace -```install``` with ```uninstall```. +To uninstall all utilities: +``` +make uninstall +``` + +To uninstall the multicall binary: +``` +make MULTICALL=1 uninstall +``` + +To uninstall every program (other than the multicall binary) with a set prefix: +``` +make PROG_PREFIX=PREFIX_GOES_HERE uninstall +``` Test Instructions -----------------