mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #228 from Arcterus/install-target
Add the ability to install coreutils (resolves #216)
This commit is contained in:
commit
361d64d077
2 changed files with 88 additions and 9 deletions
45
Makefile
45
Makefile
|
@ -1,5 +1,8 @@
|
||||||
include common.mk
|
include common.mk
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BINDIR ?= /bin
|
||||||
|
|
||||||
SRC_DIR=$(shell pwd)
|
SRC_DIR=$(shell pwd)
|
||||||
|
|
||||||
# Possible programs
|
# Possible programs
|
||||||
|
@ -64,6 +67,11 @@ EXES := \
|
||||||
CRATES := \
|
CRATES := \
|
||||||
$(sort $(filter $(EXES), $(filter-out md5sum true false, $(EXES))))
|
$(sort $(filter $(EXES), $(filter-out md5sum true false, $(EXES))))
|
||||||
|
|
||||||
|
INSTALL ?= $(EXES)
|
||||||
|
|
||||||
|
INSTALLEES := \
|
||||||
|
$(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES)))
|
||||||
|
|
||||||
# Programs with usable tests
|
# Programs with usable tests
|
||||||
TEST_PROGS := \
|
TEST_PROGS := \
|
||||||
cat \
|
cat \
|
||||||
|
@ -84,11 +92,11 @@ command = sh -c '$(1)'
|
||||||
# Main exe build rule
|
# Main exe build rule
|
||||||
define EXE_BUILD
|
define EXE_BUILD
|
||||||
ifeq ($(wildcard $(1)/Makefile),)
|
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)
|
$(call command,$(RUSTC) $(RUSTCFLAGS) -o build/$(1) $(1)/$(1).rs)
|
||||||
clean_$(1):
|
clean_$(1):
|
||||||
else
|
else
|
||||||
build/$(1): $(1)/$(1).rs
|
build/$(1): $(1)/$(1).rs | build
|
||||||
cd $(1) && make
|
cd $(1) && make
|
||||||
clean_$(1):
|
clean_$(1):
|
||||||
cd $(1) && make clean
|
cd $(1) && make clean
|
||||||
|
@ -96,13 +104,13 @@ endif
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define CRATE_BUILD
|
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)
|
$(call command,$(RUSTC) $(RUSTCFLAGS) --crate-type rlib $(1)/$(1).rs --out-dir build)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# Test exe built rules
|
# Test exe built rules
|
||||||
define TEST_BUILD
|
define TEST_BUILD
|
||||||
test_$(1): tmp/$(1)_test build build/$(1)
|
test_$(1): tmp/$(1)_test build/$(1)
|
||||||
$(call command,tmp/$(1)_test)
|
$(call command,tmp/$(1)_test)
|
||||||
|
|
||||||
tmp/$(1)_test: $(1)/test.rs
|
tmp/$(1)_test: $(1)/test.rs
|
||||||
|
@ -111,9 +119,9 @@ endef
|
||||||
|
|
||||||
# Main rules
|
# Main rules
|
||||||
ifneq ($(MULTICALL), 1)
|
ifneq ($(MULTICALL), 1)
|
||||||
all: build $(EXES_PATHS)
|
all: $(EXES_PATHS)
|
||||||
else
|
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)))
|
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 $@
|
$(RUSTC) $(RUSTCFLAGS) -L build/ uutils/uutils.rs -o $@
|
||||||
|
@ -133,10 +141,29 @@ tmp:
|
||||||
mkdir tmp
|
mkdir tmp
|
||||||
|
|
||||||
# Creating necessary rules for each targets
|
# 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)
|
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))))
|
$(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: $(addprefix build/,$(INSTALLEES))
|
||||||
|
mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR)
|
||||||
|
for prog in $(INSTALLEES); do \
|
||||||
|
install build/$$prog $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX)$$prog; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Test under the busybox testsuite
|
# Test under the busybox testsuite
|
||||||
|
@ -163,4 +190,4 @@ busytest: build/busybox build/.config
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: all test clean busytest
|
.PHONY: all test clean busytest install uninstall
|
||||||
|
|
52
README.md
52
README.md
|
@ -34,6 +34,57 @@ To build only a few of the available utilities:
|
||||||
make BUILD='UTILITY_1 UTILITY_2'
|
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
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
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
|
Test Instructions
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
@ -76,6 +127,7 @@ To do
|
||||||
- chown
|
- chown
|
||||||
- chroot
|
- chroot
|
||||||
- copy
|
- copy
|
||||||
|
- cp (not much done)
|
||||||
- cp-hash
|
- cp-hash
|
||||||
- csplit
|
- csplit
|
||||||
- cut
|
- cut
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue