mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Add the ability to install coreutils (resolves #216)
This commit is contained in:
parent
4dbd224e4c
commit
0bb67fe13a
1 changed files with 31 additions and 9 deletions
40
Makefile
40
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
|
||||||
|
@ -84,11 +87,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 +99,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 +114,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 +136,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: $(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
|
endif
|
||||||
|
|
||||||
# Test under the busybox testsuite
|
# Test under the busybox testsuite
|
||||||
|
@ -163,4 +185,4 @@ busytest: build/busybox build/.config
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: all test clean busytest
|
.PHONY: all test clean busytest install uninstall
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue