coreutils/Makefile

249 lines
4.2 KiB
Makefile
Raw Normal View History

# Config options
ENABLE_RELEASE ?= n
PROFILE ?= debug
MULTICALL ?= n
PROFILE_CMD :=
ifeq (${PROFILE},release)
PROFILE_CMD = --release
endif
# Binaries
2015-01-23 16:35:54 +00:00
CARGO ?= cargo
2013-10-23 15:09:40 +00:00
# Install directories
2015-01-23 16:35:54 +00:00
PREFIX ?= /usr/local
BINDIR ?= /bin
LIBDIR ?= /lib
INSTALLDIR=$(DESTDIR)$(PREFIX)
# This won't support any directory with spaces in its name, but you can just
# make a symlink without spaces that points to the directory.
BASEDIR ?= $(shell pwd)
BUILDDIR := $(BASEDIR)/target/${PROFILE}/
PKG_BUILDDIR := $(BUILDDIR)/deps/
# Possible programs
PROGS := \
2013-12-20 19:34:45 +00:00
base64 \
2014-01-07 00:54:02 +00:00
basename \
2013-12-02 11:50:24 +00:00
cat \
2014-10-26 03:27:45 +00:00
chmod \
2014-05-16 21:01:20 +00:00
cksum \
2014-05-16 17:43:17 +00:00
comm \
2014-05-17 17:01:17 +00:00
cp \
cut \
2013-12-03 09:29:32 +00:00
dirname \
2013-12-02 11:50:24 +00:00
echo \
env \
2014-07-25 22:34:45 +00:00
expand \
Implement expr. Implemented as follows: Usage: expr EXPRESSION or: expr OPTION --help display this help and exit --version output version information and exit Print the value of EXPRESSION to standard output. A blank line below separates increasing precedence groups. EXPRESSION may be: ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2 ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0 ARG1 < ARG2 ARG1 is less than ARG2 ARG1 <= ARG2 ARG1 is less than or equal to ARG2 ARG1 = ARG2 ARG1 is equal to ARG2 ARG1 != ARG2 ARG1 is unequal to ARG2 ARG1 >= ARG2 ARG1 is greater than or equal to ARG2 ARG1 > ARG2 ARG1 is greater than ARG2 ARG1 + ARG2 arithmetic sum of ARG1 and ARG2 ARG1 - ARG2 arithmetic difference of ARG1 and ARG2 ARG1 * ARG2 arithmetic product of ARG1 and ARG2 ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2 ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2 STRING : REGEXP [NOT IMPLEMENTED] anchored pattern match of REGEXP in STRING match STRING REGEXP [NOT IMPLEMENTED] same as STRING : REGEXP substr STRING POS LENGTH [NOT IMPLEMENTED] substring of STRING, POS counted from 1 index STRING CHARS [NOT IMPLEMENTED] index in STRING where any CHARS is found, or 0 length STRING [NOT IMPLEMENTED] length of STRING + TOKEN interpret TOKEN as a string, even if it is a keyword like 'match' or an operator like '/' ( EXPRESSION ) value of EXPRESSION Beware that many operators need to be escaped or quoted for shells. Comparisons are arithmetic if both ARGs are numbers, else lexicographical. Pattern matches return the string matched between \( and \) or null; if \( and \) are not used, they return the number of characters matched or 0. Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred. Environment variables: * EXPR_DEBUG_TOKENS=1 dump expression's tokens * EXPR_DEBUG_RPN=1 dump expression represented in reverse polish notation * EXPR_DEBUG_SYA_STEP=1 dump each parser step * EXPR_DEBUG_AST=1 dump expression represented abstract syntax tree
2015-10-09 09:31:25 +00:00
expr \
2014-05-30 00:39:33 +00:00
factor \
2013-12-02 11:50:24 +00:00
false \
fmt \
2014-03-27 01:34:58 +00:00
fold \
2014-06-22 14:28:51 +00:00
link \
2014-06-22 20:27:43 +00:00
hashsum \
ln \
mkdir \
2014-06-14 14:43:39 +00:00
nl \
2014-10-18 21:17:33 +00:00
nproc \
od \
2014-02-28 17:19:32 +00:00
paste \
2013-12-02 11:50:24 +00:00
printenv \
2015-01-27 15:37:07 +00:00
ptx \
2013-12-05 11:36:08 +00:00
pwd \
2014-12-23 11:27:21 +00:00
readlink \
2014-06-29 19:57:54 +00:00
realpath \
2014-06-29 19:59:25 +00:00
relpath \
2013-12-18 06:09:32 +00:00
rm \
2013-12-18 18:39:23 +00:00
rmdir \
2013-12-18 17:26:42 +00:00
sleep \
split \
2014-02-05 19:46:28 +00:00
seq \
2014-07-10 01:19:59 +00:00
shuf \
sort \
2014-05-28 00:57:33 +00:00
sum \
2014-06-26 06:05:31 +00:00
sync \
2014-02-27 18:59:51 +00:00
tac \
2013-12-23 17:12:26 +00:00
tee \
test_uu \
2014-05-18 15:17:04 +00:00
tr \
2013-12-02 11:50:24 +00:00
true \
2014-02-01 05:18:57 +00:00
truncate \
tsort \
2014-07-28 00:11:49 +00:00
unexpand \
2014-07-06 00:27:22 +00:00
uniq \
2013-12-02 11:50:24 +00:00
wc \
yes \
2014-01-03 03:09:59 +00:00
head \
tail \
2014-06-15 20:41:23 +00:00
whoami
2013-12-02 11:50:24 +00:00
UNIX_PROGS := \
2014-06-16 15:37:03 +00:00
chroot \
du \
2014-06-15 14:25:00 +00:00
groups \
2014-04-03 20:56:36 +00:00
hostid \
2014-06-04 05:28:22 +00:00
hostname \
2014-06-15 14:25:00 +00:00
id \
2014-04-03 13:59:58 +00:00
kill \
2014-02-24 21:24:01 +00:00
logname \
2014-06-22 12:39:46 +00:00
mkfifo \
mv \
2014-12-16 04:03:21 +00:00
nice \
2014-06-24 12:51:57 +00:00
nohup \
2014-12-30 19:11:36 +00:00
stdbuf \
2014-07-22 01:50:53 +00:00
timeout \
touch \
2014-02-19 05:59:48 +00:00
tty \
2014-06-15 14:25:00 +00:00
uname \
unlink \
2014-04-02 00:13:07 +00:00
uptime \
2014-06-15 20:41:23 +00:00
users
ifneq ($(OS),Windows_NT)
PROGS := $(PROGS) $(UNIX_PROGS)
endif
2014-06-22 20:27:43 +00:00
ALIASES := \
hashsum:md5sum \
hashsum:sha1sum \
hashsum:sha224sum \
hashsum:sha256sum \
hashsum:sha384sum \
hashsum:sha512sum
BUILD ?= $(PROGS)
# Programs with usable tests
TEST_PROGS := \
base64 \
basename \
cat \
cksum \
cp \
cut \
dirname \
echo \
env \
factor \
false \
fold \
hashsum \
head \
link \
ln \
mkdir \
mv \
nl \
paste \
ptx \
pwd \
readlink \
realpath \
rm \
rmdir \
seq \
sort \
split \
stdbuf \
sum \
tac \
test \
touch \
tr \
true \
truncate \
tsort \
unexpand \
unlink \
wc
TESTS := \
$(filter $(PROGS),$(filter-out $(DONT_TEST),$(filter $(BUILD),$(filter-out $(DONT_BUILD),$(TEST_PROGS)))))
TEST ?= $(TEST_PROGS)
# Output names
EXES := \
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
2013-12-02 11:50:24 +00:00
2014-06-13 02:14:56 +00:00
INSTALLEES := \
$(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES) uutils))
2014-06-13 02:14:56 +00:00
INSTALL ?= $(EXES)
2014-12-30 19:11:36 +00:00
# Shared library extension
SYSTEM := $(shell uname)
Implement expr. Implemented as follows: Usage: expr EXPRESSION or: expr OPTION --help display this help and exit --version output version information and exit Print the value of EXPRESSION to standard output. A blank line below separates increasing precedence groups. EXPRESSION may be: ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2 ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0 ARG1 < ARG2 ARG1 is less than ARG2 ARG1 <= ARG2 ARG1 is less than or equal to ARG2 ARG1 = ARG2 ARG1 is equal to ARG2 ARG1 != ARG2 ARG1 is unequal to ARG2 ARG1 >= ARG2 ARG1 is greater than or equal to ARG2 ARG1 > ARG2 ARG1 is greater than ARG2 ARG1 + ARG2 arithmetic sum of ARG1 and ARG2 ARG1 - ARG2 arithmetic difference of ARG1 and ARG2 ARG1 * ARG2 arithmetic product of ARG1 and ARG2 ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2 ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2 STRING : REGEXP [NOT IMPLEMENTED] anchored pattern match of REGEXP in STRING match STRING REGEXP [NOT IMPLEMENTED] same as STRING : REGEXP substr STRING POS LENGTH [NOT IMPLEMENTED] substring of STRING, POS counted from 1 index STRING CHARS [NOT IMPLEMENTED] index in STRING where any CHARS is found, or 0 length STRING [NOT IMPLEMENTED] length of STRING + TOKEN interpret TOKEN as a string, even if it is a keyword like 'match' or an operator like '/' ( EXPRESSION ) value of EXPRESSION Beware that many operators need to be escaped or quoted for shells. Comparisons are arithmetic if both ARGs are numbers, else lexicographical. Pattern matches return the string matched between \( and \) or null; if \( and \) are not used, they return the number of characters matched or 0. Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred. Environment variables: * EXPR_DEBUG_TOKENS=1 dump expression's tokens * EXPR_DEBUG_RPN=1 dump expression represented in reverse polish notation * EXPR_DEBUG_SYA_STEP=1 dump each parser step * EXPR_DEBUG_AST=1 dump expression represented abstract syntax tree
2015-10-09 09:31:25 +00:00
DYLIB_EXT :=
2014-12-30 19:11:36 +00:00
ifeq ($(SYSTEM),Linux)
2015-01-25 12:40:18 +00:00
DYLIB_EXT := so
DYLIB_FLAGS := -shared
2014-12-30 19:11:36 +00:00
endif
ifeq ($(SYSTEM),Darwin)
2015-01-25 12:40:18 +00:00
DYLIB_EXT := dylib
DYLIB_FLAGS := -dynamiclib -undefined dynamic_lookup
2014-12-30 19:11:36 +00:00
endif
# Libaries to install
LIBS :=
ifneq (,$(findstring stdbuf, $(INSTALLEES)))
2015-01-25 12:40:18 +00:00
LIBS += libstdbuf.$(DYLIB_EXT)
2014-12-30 19:11:36 +00:00
endif
all: build
crates:
echo "okay" $(EXES)
do_install = install ${1}
use_default := 1
$(foreach util,$(EXES),$(eval $(call BUILD_EXE,$(util))))
build-uutils:
${CARGO} build --features "${EXES}" ${PROFILE_CMD} --no-default-features
build: build-uutils $(addprefix build_exe_,$(EXES))
$(foreach util, ${EXES}, $(call build_pkg, ${util});)
2013-10-23 15:09:40 +00:00
$(foreach test,$(TESTS),$(eval $(call TEST_INTEGRATION,$(test))))
$(foreach test,$(TESTS),$(eval $(call TEST_UNIT,$(test))))
test: $(addprefix test_integration_,$(TESTS)) $(addprefix test_unit_,$(TESTS))
2014-06-20 21:31:55 +00:00
clean:
$(RM) -rf $(BUILDDIR)
distclean: clean
$(CARGO) clean && $(CARGO) update
# TODO: figure out if there is way for prefixes to work with the symlinks
install: build
PROFILE_CMD=--release
mkdir -p $(INSTALLDIR)$(BINDIR)
ifeq (${MULTICALL}, y)
install $(BUILDDIR)/uutils $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)uutils
cd $(INSTALLDIR)$(BINDIR)
$(foreach prog, $(INSTALLEES), ln -s $(PROG_PREFIX)uutils $$prog;)
else
$(foreach prog, $(INSTALLEES); \
install $(PKG_BUILDDIR)/$$prog $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)$$prog;)
endif
mkdir -p $(INSTALLDIR)$(LIBDIR)
$(foreach lib, $(LIBS), install $(BUILDDIR)/$$lib $(INSTALLDIR)$(LIBDIR)/$$lib;)
uninstall:
rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX),$(PROGS))
rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS))
uninstall-multicall:
rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils)
rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS))
.PHONY: $(TEMPDIR) all build test distclean clean busytest install uninstall