2014-07-20 08:27:47 +00:00
|
|
|
# Config options
|
2015-01-10 21:00:15 +00:00
|
|
|
ENABLE_LTO ?= n
|
|
|
|
ENABLE_STRIP ?= n
|
2014-07-20 08:27:47 +00:00
|
|
|
|
2014-07-19 21:25:28 +00:00
|
|
|
# Binaries
|
2015-01-23 16:35:54 +00:00
|
|
|
RUSTC ?= rustc
|
|
|
|
CARGO ?= cargo
|
|
|
|
CC ?= gcc
|
|
|
|
RM := rm
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2014-11-29 21:32:33 +00:00
|
|
|
# Install directories
|
2015-01-23 16:35:54 +00:00
|
|
|
PREFIX ?= /usr/local
|
|
|
|
BINDIR ?= /bin
|
|
|
|
LIBDIR ?= /lib
|
2014-11-29 21:32:33 +00:00
|
|
|
|
|
|
|
# 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.
|
2015-01-10 21:00:15 +00:00
|
|
|
BASEDIR ?= $(shell pwd)
|
|
|
|
SRCDIR := $(BASEDIR)/src
|
|
|
|
BUILDDIR := $(BASEDIR)/build
|
|
|
|
TESTDIR := $(BASEDIR)/test
|
|
|
|
TEMPDIR := $(BASEDIR)/tmp
|
2014-11-29 21:32:33 +00:00
|
|
|
|
2014-07-19 21:25:28 +00:00
|
|
|
# Flags
|
2015-01-10 21:00:15 +00:00
|
|
|
RUSTCFLAGS := -O
|
|
|
|
RMFLAGS :=
|
|
|
|
|
|
|
|
RUSTCLIBFLAGS := $(RUSTCFLAGS) -L $(BUILDDIR)/
|
|
|
|
RUSTCTESTFLAGS := $(RUSTCFLAGS)
|
2014-07-20 08:27:47 +00:00
|
|
|
|
|
|
|
# Handle config setup
|
|
|
|
ifeq ($(ENABLE_LTO),y)
|
2015-04-29 23:24:20 +00:00
|
|
|
RUSTCBINFLAGS := $(RUSTCLIBFLAGS) -C lto
|
2014-07-20 08:27:47 +00:00
|
|
|
else
|
2015-01-10 21:00:15 +00:00
|
|
|
RUSTCBINFLAGS := $(RUSTCLIBFLAGS)
|
2014-07-20 08:27:47 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(ENABLE_STRIP),y)
|
2015-01-10 21:00:15 +00:00
|
|
|
ENABLE_STRIP :=
|
2014-07-20 08:27:47 +00:00
|
|
|
endif
|
2014-07-19 21:25:28 +00:00
|
|
|
|
2013-12-27 07:48:38 +00:00
|
|
|
# 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 \
|
2014-06-12 21:04:01 +00:00
|
|
|
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 \
|
2014-05-30 00:39:33 +00:00
|
|
|
factor \
|
2013-12-02 11:50:24 +00:00
|
|
|
false \
|
2014-06-19 00:56:53 +00:00
|
|
|
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 \
|
2015-07-05 18:52:31 +00:00
|
|
|
ln \
|
2014-01-01 23:32:21 +00:00
|
|
|
mkdir \
|
2014-06-14 14:43:39 +00:00
|
|
|
nl \
|
2014-10-18 21:17:33 +00:00
|
|
|
nproc \
|
2014-07-10 20:49:20 +00:00
|
|
|
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 \
|
2014-07-01 22:30:08 +00:00
|
|
|
split \
|
2014-02-05 19:46:28 +00:00
|
|
|
seq \
|
2014-07-10 01:19:59 +00:00
|
|
|
shuf \
|
2014-07-07 14:55:47 +00:00
|
|
|
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 \
|
2014-07-12 01:12:29 +00:00
|
|
|
test \
|
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 \
|
2014-07-20 03:19:38 +00:00
|
|
|
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 \
|
2014-06-12 21:27:37 +00:00
|
|
|
tail \
|
2014-06-15 20:41:23 +00:00
|
|
|
whoami
|
2013-12-02 11:50:24 +00:00
|
|
|
|
2014-02-08 03:35:03 +00:00
|
|
|
UNIX_PROGS := \
|
2014-06-16 15:37:03 +00:00
|
|
|
chroot \
|
2015-07-20 00:25:48 +00:00
|
|
|
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 \
|
2015-07-20 00:25:48 +00:00
|
|
|
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 \
|
2015-07-20 00:25:48 +00:00
|
|
|
touch \
|
2014-02-19 05:59:48 +00:00
|
|
|
tty \
|
2014-06-15 14:25:00 +00:00
|
|
|
uname \
|
2015-07-20 00:25:48 +00:00
|
|
|
unlink \
|
2014-04-02 00:13:07 +00:00
|
|
|
uptime \
|
2014-06-15 20:41:23 +00:00
|
|
|
users
|
2014-02-08 03:35:03 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-12-27 07:48:38 +00:00
|
|
|
BUILD ?= $(PROGS)
|
|
|
|
|
|
|
|
# Output names
|
|
|
|
EXES := \
|
2014-02-08 03:35:03 +00:00
|
|
|
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
|
2013-12-02 11:50:24 +00:00
|
|
|
|
2014-07-19 21:25:28 +00:00
|
|
|
CRATE_RLIBS :=
|
2014-05-28 11:43:37 +00:00
|
|
|
|
2014-06-13 02:14:56 +00:00
|
|
|
INSTALL ?= $(EXES)
|
|
|
|
|
|
|
|
INSTALLEES := \
|
2014-06-25 16:47:34 +00:00
|
|
|
$(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES) uutils))
|
2014-06-13 02:14:56 +00:00
|
|
|
|
2014-12-30 19:11:36 +00:00
|
|
|
# Shared library extension
|
|
|
|
SYSTEM := $(shell uname)
|
|
|
|
DYLIB_EXT :=
|
|
|
|
ifeq ($(SYSTEM),Linux)
|
2015-01-25 12:40:18 +00:00
|
|
|
DYLIB_EXT := so
|
2015-07-09 00:34:48 +00:00
|
|
|
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
|
2015-07-09 22:39:46 +00:00
|
|
|
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
|
|
|
|
|
2013-12-27 21:32:56 +00:00
|
|
|
# Programs with usable tests
|
|
|
|
TEST_PROGS := \
|
2015-05-29 03:25:13 +00:00
|
|
|
base64 \
|
2015-05-09 17:32:47 +00:00
|
|
|
basename \
|
2013-12-02 11:50:24 +00:00
|
|
|
cat \
|
2015-08-14 04:08:31 +00:00
|
|
|
cksum \
|
2014-10-13 20:26:14 +00:00
|
|
|
cp \
|
2015-07-31 04:14:58 +00:00
|
|
|
cut \
|
2015-05-07 04:04:41 +00:00
|
|
|
env \
|
2015-05-09 19:16:45 +00:00
|
|
|
dirname \
|
2015-05-09 19:17:01 +00:00
|
|
|
echo \
|
2015-04-30 18:23:12 +00:00
|
|
|
factor \
|
2015-05-09 19:17:16 +00:00
|
|
|
false \
|
2015-05-08 01:14:31 +00:00
|
|
|
fold \
|
2015-05-16 22:03:09 +00:00
|
|
|
hashsum \
|
2015-05-30 22:54:28 +00:00
|
|
|
head \
|
2015-07-05 18:52:31 +00:00
|
|
|
ln \
|
2014-01-05 22:22:04 +00:00
|
|
|
mkdir \
|
2014-10-19 17:39:27 +00:00
|
|
|
mv \
|
2014-06-14 14:43:39 +00:00
|
|
|
nl \
|
2015-05-07 20:51:55 +00:00
|
|
|
paste \
|
2015-05-30 07:34:23 +00:00
|
|
|
ptx \
|
2015-05-09 19:17:26 +00:00
|
|
|
pwd \
|
2015-05-12 21:09:41 +00:00
|
|
|
readlink \
|
2015-06-04 04:04:37 +00:00
|
|
|
realpath \
|
2015-05-15 23:14:42 +00:00
|
|
|
rm \
|
2014-02-05 19:46:28 +00:00
|
|
|
seq \
|
2014-07-07 14:55:47 +00:00
|
|
|
sort \
|
2015-05-09 17:32:30 +00:00
|
|
|
split \
|
2015-07-09 19:02:38 +00:00
|
|
|
stdbuf \
|
2015-08-14 04:08:31 +00:00
|
|
|
sum \
|
2015-06-07 02:33:56 +00:00
|
|
|
tac \
|
2014-10-21 05:04:17 +00:00
|
|
|
test \
|
2015-08-12 01:38:10 +00:00
|
|
|
touch \
|
2014-05-18 15:58:56 +00:00
|
|
|
tr \
|
2015-05-09 19:17:16 +00:00
|
|
|
true \
|
2014-02-04 06:54:57 +00:00
|
|
|
truncate \
|
2015-05-10 03:38:48 +00:00
|
|
|
tsort \
|
2015-05-16 00:11:54 +00:00
|
|
|
unlink \
|
2015-06-03 05:38:59 +00:00
|
|
|
unexpand \
|
|
|
|
wc
|
2013-12-02 11:50:24 +00:00
|
|
|
|
2013-12-27 21:32:56 +00:00
|
|
|
TEST ?= $(TEST_PROGS)
|
|
|
|
|
|
|
|
TESTS := \
|
|
|
|
$(filter $(TEST),$(filter-out $(DONT_TEST),$(filter $(BUILD),$(filter-out $(DONT_BUILD),$(TEST_PROGS)))))
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2015-04-25 22:22:56 +00:00
|
|
|
# figure out what dependencies we need based on which programs we're building
|
|
|
|
define DEP_INCLUDE
|
|
|
|
-include $(SRCDIR)/$(1)/deps.mk
|
|
|
|
endef
|
|
|
|
# we always depend on libc because common/util does
|
2015-05-21 02:45:43 +00:00
|
|
|
# we also depend on getopts since all utilities support command-line arguments
|
|
|
|
DEPLIBS := libc getopts
|
2015-04-25 22:22:56 +00:00
|
|
|
DEPPLUGS :=
|
|
|
|
# now, add in deps in src/utilname/deps.mk
|
2015-04-26 07:42:55 +00:00
|
|
|
# if we're testing, only consider the TESTS variable,
|
|
|
|
# otherwise consider the EXES variable
|
|
|
|
ifeq ($(MAKECMDGOALS),test)
|
|
|
|
$(foreach build,$(TESTS),$(eval $(call DEP_INCLUDE,$(build))))
|
|
|
|
else
|
|
|
|
$(foreach build,$(sort $(TESTS) $(EXES)),$(eval $(call DEP_INCLUDE,$(build))))
|
|
|
|
endif
|
2015-04-25 22:22:56 +00:00
|
|
|
# uniqify deps
|
|
|
|
DEPLIBS := $(sort $(DEPLIBS))
|
|
|
|
DEPPLUGS := $(sort $(DEPPLUGS))
|
|
|
|
# build --extern commandline for rustc
|
|
|
|
DEP_EXTERN := $(foreach lib,$(subst -,_,$(DEPLIBS)),--extern $(lib)=$(BUILDDIR)/lib$(lib).rlib)
|
|
|
|
DEP_EXTERN += $(foreach plug,$(subst -,_,$(DEPPLUGS)),--extern $(plug)=$(BUILDDIR)/lib$(plug).$(DYLIB_EXT))
|
|
|
|
|
2014-07-19 21:25:28 +00:00
|
|
|
# Setup for building crates
|
|
|
|
define BUILD_SETUP
|
2015-01-06 17:28:12 +00:00
|
|
|
X := $(shell $(RUSTC) --print file-names --crate-type rlib $(SRCDIR)/$(1)/$(1).rs)
|
2014-07-19 21:25:28 +00:00
|
|
|
$(1)_RLIB := $$(X)
|
|
|
|
CRATE_RLIBS += $$(X)
|
|
|
|
endef
|
|
|
|
$(foreach crate,$(EXES),$(eval $(call BUILD_SETUP,$(crate))))
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Utils stuff
|
2014-07-21 03:20:55 +00:00
|
|
|
EXES_PATHS := $(addprefix $(BUILDDIR)/,$(EXES))
|
|
|
|
RLIB_PATHS := $(addprefix $(BUILDDIR)/,$(CRATE_RLIBS))
|
2013-10-25 16:33:24 +00:00
|
|
|
command = sh -c '$(1)'
|
2015-04-25 22:22:56 +00:00
|
|
|
RESERVED_EXTERNS := --extern uufalse=$(BUILDDIR)/libfalse.rlib --extern uutrue=$(BUILDDIR)/libtrue.rlib --extern uutest=$(BUILDDIR)/libtest.rlib
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Main exe build rule
|
2013-10-23 15:09:40 +00:00
|
|
|
define EXE_BUILD
|
2014-07-21 03:20:55 +00:00
|
|
|
$(BUILDDIR)/gen/$(1).rs: $(BUILDDIR)/mkmain
|
|
|
|
$(BUILDDIR)/mkmain $(1) $$@
|
2014-06-20 21:31:55 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
$(BUILDDIR)/$(1): $(BUILDDIR)/gen/$(1).rs $(BUILDDIR)/$($(1)_RLIB) | $(BUILDDIR) deps
|
2015-04-25 22:22:56 +00:00
|
|
|
$(RUSTC) $(RUSTCBINFLAGS) $(RESERVED_EXTERNS) -o $$@ $$<
|
2014-07-21 03:20:55 +00:00
|
|
|
$(if $(ENABLE_STRIP),strip $$@,)
|
2013-10-23 15:09:40 +00:00
|
|
|
endef
|
|
|
|
|
2015-04-25 22:22:56 +00:00
|
|
|
# GRRR rust-crypto makes a crate called "crypto".
|
|
|
|
# This should NOT be allowed by crates.io. GRRRR.
|
|
|
|
define DEP_BUILD
|
|
|
|
DEP_$(1):
|
|
|
|
ifeq ($(1),crypto)
|
|
|
|
cd $(BASEDIR)/deps && $(CARGO) build --package rust-crypto --release
|
2015-07-20 00:25:48 +00:00
|
|
|
else ifeq ($(1),kernel32)
|
|
|
|
cd $(BASEDIR)/deps && $(CARGO) build --package kernel32-sys --release
|
|
|
|
else ifeq ($(1),advapi32)
|
|
|
|
cd $(BASEDIR)/deps && $(CARGO) build --package advapi32-sys --release
|
2015-04-25 22:22:56 +00:00
|
|
|
else
|
|
|
|
cd $(BASEDIR)/deps && $(CARGO) build --package $(1) --release
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2014-05-28 11:43:37 +00:00
|
|
|
define CRATE_BUILD
|
2014-07-21 03:20:55 +00:00
|
|
|
-include $(BUILDDIR)/$(1).d
|
2014-07-19 21:25:28 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
$(BUILDDIR)/$($(1)_RLIB): $(SRCDIR)/$(1)/$(1).rs | $(BUILDDIR) deps
|
2015-04-25 22:22:56 +00:00
|
|
|
$(RUSTC) $(RUSTCLIBFLAGS) $(DEP_EXTERN) --crate-type rlib --emit link,dep-info $$< --out-dir $(BUILDDIR)
|
2014-05-28 11:43:37 +00:00
|
|
|
endef
|
|
|
|
|
2014-06-22 20:27:43 +00:00
|
|
|
# Aliases build rule
|
|
|
|
ALIAS_SOURCE = $(firstword $(subst :, ,$(1)))
|
|
|
|
ALIAS_TARGET = $(word 2,$(subst :, ,$(1)))
|
|
|
|
define MAKE_ALIAS
|
2014-07-01 00:41:15 +00:00
|
|
|
|
|
|
|
ifneq ($(ALIAS_TARGET,$(1)),)
|
2014-07-21 03:20:55 +00:00
|
|
|
all: $(BUILDDIR)/$(call ALIAS_TARGET,$(1))
|
|
|
|
$(BUILDDIR)/$(call ALIAS_TARGET,$(1)): $(BUILDDIR)/$(call ALIAS_SOURCE,$(1))
|
|
|
|
$(call command,install $$@ $$<)
|
2014-07-01 00:41:15 +00:00
|
|
|
endif
|
|
|
|
|
2014-06-22 20:27:43 +00:00
|
|
|
endef
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Test exe built rules
|
2013-10-23 15:09:40 +00:00
|
|
|
define TEST_BUILD
|
2015-04-26 07:42:55 +00:00
|
|
|
test_$(1): $(BUILDDIR)/$(1) $(TEMPDIR)/$(1)/$(1)_test
|
|
|
|
$(call command,cp $(BUILDDIR)/$(1) $(TEMPDIR)/$(1) && cd $(TEMPDIR)/$(1) && $(TEMPDIR)/$(1)/$(1)_test)
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2014-07-21 17:08:19 +00:00
|
|
|
$(TEMPDIR)/$(1)/$(1)_test: $(TESTDIR)/$(1).rs | $(TEMPDIR)/$(1)
|
2015-04-25 22:22:56 +00:00
|
|
|
$(call command,$(RUSTC) $(RUSTCTESTFLAGS) $(DEP_EXTERN) --test -o $$@ $$<)
|
2014-07-21 17:08:19 +00:00
|
|
|
|
|
|
|
$(TEMPDIR)/$(1): | $(TEMPDIR)
|
|
|
|
$(call command,cp -r $(TESTDIR)/fixtures/$(1) $$@ || mkdir $$@)
|
2013-10-23 15:09:40 +00:00
|
|
|
endef
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Main rules
|
2014-07-21 03:20:55 +00:00
|
|
|
all: $(EXES_PATHS) $(BUILDDIR)/uutils
|
2014-05-28 11:43:37 +00:00
|
|
|
|
2014-07-19 21:25:28 +00:00
|
|
|
# Creating necessary rules for each targets
|
|
|
|
$(foreach crate,$(EXES),$(eval $(call CRATE_BUILD,$(crate))))
|
|
|
|
$(foreach exe,$(EXES),$(eval $(call EXE_BUILD,$(exe))))
|
|
|
|
$(foreach alias,$(ALIASES),$(eval $(call MAKE_ALIAS,$(alias))))
|
|
|
|
$(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test))))
|
2015-04-25 22:22:56 +00:00
|
|
|
$(foreach dep,$(sort $(DEPLIBS) $(DEPPLUGS)),$(eval $(call DEP_BUILD,$(dep))))
|
2014-07-19 21:25:28 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
-include $(BUILDDIR)/uutils.d
|
|
|
|
$(BUILDDIR)/uutils: $(SRCDIR)/uutils/uutils.rs $(BUILDDIR)/mkuutils $(RLIB_PATHS)
|
2014-09-02 07:38:46 +00:00
|
|
|
$(BUILDDIR)/mkuutils $(BUILDDIR)/gen/uutils.rs $(EXES)
|
2015-04-25 22:22:56 +00:00
|
|
|
$(RUSTC) $(RUSTCBINFLAGS) $(RESERVED_EXTERNS) --emit link,dep-info $(BUILDDIR)/gen/uutils.rs --out-dir $(BUILDDIR)
|
2014-07-21 03:20:55 +00:00
|
|
|
$(if $(ENABLE_STRIP),strip $@)
|
2014-12-30 19:11:36 +00:00
|
|
|
|
|
|
|
# Library for stdbuf
|
2015-02-01 21:08:54 +00:00
|
|
|
$(BUILDDIR)/libstdbuf.$(DYLIB_EXT): $(SRCDIR)/stdbuf/libstdbuf.rs $(SRCDIR)/stdbuf/libstdbuf.c $(SRCDIR)/stdbuf/libstdbuf.h | $(BUILDDIR)
|
2014-12-30 19:11:36 +00:00
|
|
|
cd $(SRCDIR)/stdbuf && \
|
|
|
|
$(RUSTC) libstdbuf.rs && \
|
2015-07-09 00:34:48 +00:00
|
|
|
$(CC) -c -Wall -Werror -fPIC libstdbuf.c && \
|
|
|
|
$(CC) $(DYLIB_FLAGS) -o libstdbuf.$(DYLIB_EXT) liblibstdbuf.a libstdbuf.o && \
|
2015-02-01 21:08:54 +00:00
|
|
|
mv *.$(DYLIB_EXT) $(BUILDDIR) && $(RM) *.o && $(RM) *.a
|
2014-12-30 19:11:36 +00:00
|
|
|
|
2015-02-01 21:08:54 +00:00
|
|
|
$(BUILDDIR)/stdbuf: $(BUILDDIR)/libstdbuf.$(DYLIB_EXT)
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2015-04-25 22:22:56 +00:00
|
|
|
deps: $(BUILDDIR) $(SRCDIR)/cksum/crc_table.rs $(addprefix DEP_,$(DEPLIBS) $(DEPPLUGS))
|
|
|
|
$(foreach lib,$(subst -,_,$(DEPLIBS)),$(shell cp $(BASEDIR)/deps/target/release/deps/lib$(lib)-*.rlib $(BUILDDIR)/lib$(lib).rlib))
|
|
|
|
$(foreach plug,$(subst -,_,$(DEPPLUGS)),$(shell cp $(BASEDIR)/deps/target/release/deps/lib$(plug)-*.$(DYLIB_EXT) $(BUILDDIR)/lib$(plug).$(DYLIB_EXT)))
|
2015-01-10 00:51:51 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
$(BUILDDIR)/mkmain: mkmain.rs | $(BUILDDIR)
|
2014-11-29 21:32:33 +00:00
|
|
|
$(RUSTC) $(RUSTCFLAGS) $< -o $@
|
2014-06-25 16:47:34 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
$(BUILDDIR)/mkuutils: mkuutils.rs | $(BUILDDIR)
|
2014-11-29 21:32:33 +00:00
|
|
|
$(RUSTC) $(RUSTCFLAGS) $< -o $@
|
2014-07-01 03:45:51 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
$(SRCDIR)/cksum/crc_table.rs: $(SRCDIR)/cksum/gen_table.rs
|
2015-01-10 21:00:15 +00:00
|
|
|
cd $(SRCDIR)/cksum && $(RUSTC) $(RUSTCBINFLAGS) gen_table.rs && ./gen_table && $(RM) gen_table
|
2014-07-11 06:38:18 +00:00
|
|
|
|
2015-04-29 23:24:20 +00:00
|
|
|
$(SRCDIR)/factor/prime_table.rs: $(SRCDIR)/factor/gen_table.rs
|
2015-05-08 04:06:17 +00:00
|
|
|
cd $(SRCDIR)/factor && $(RUSTC) $(RUSTCBINFLAGS) gen_table.rs && ./gen_table > $@ && $(RM) gen_table
|
2015-04-29 23:24:20 +00:00
|
|
|
|
2014-06-25 16:47:34 +00:00
|
|
|
crates:
|
|
|
|
echo $(EXES)
|
|
|
|
|
2014-07-21 17:08:19 +00:00
|
|
|
test: $(TEMPDIR) $(addprefix test_,$(TESTS))
|
|
|
|
$(RM) -rf $(TEMPDIR)
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2014-06-20 21:31:55 +00:00
|
|
|
clean:
|
2015-04-25 22:22:56 +00:00
|
|
|
$(RM) -rf $(BUILDDIR) $(TEMPDIR)
|
|
|
|
|
|
|
|
distclean: clean
|
2015-05-15 23:26:31 +00:00
|
|
|
cd $(BASEDIR)/deps && $(CARGO) clean && $(CARGO) update
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
$(BUILDDIR):
|
|
|
|
mkdir -p $(BUILDDIR)/gen
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2014-07-21 17:08:19 +00:00
|
|
|
$(TEMPDIR):
|
2015-01-09 13:19:53 +00:00
|
|
|
$(RM) -rf $(TEMPDIR)
|
2014-07-21 17:08:19 +00:00
|
|
|
mkdir $(TEMPDIR)
|
2013-10-22 13:31:51 +00:00
|
|
|
|
2014-07-21 03:20:55 +00:00
|
|
|
install: $(addprefix $(BUILDDIR)/,$(INSTALLEES))
|
2014-06-13 01:43:52 +00:00
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR)
|
2014-06-13 02:14:56 +00:00
|
|
|
for prog in $(INSTALLEES); do \
|
2014-07-21 03:20:55 +00:00
|
|
|
install $(BUILDDIR)/$$prog $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX)$$prog; \
|
2014-06-13 01:43:52 +00:00
|
|
|
done
|
2014-12-30 19:11:36 +00:00
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)$(LIBDIR)
|
|
|
|
for lib in $(LIBS); do \
|
|
|
|
install $(BUILDDIR)/$$lib $(DESTDIR)$(PREFIX)$(LIBDIR)/$$lib; \
|
|
|
|
done
|
2014-06-13 01:43:52 +00:00
|
|
|
|
2014-07-01 08:07:16 +00:00
|
|
|
# TODO: figure out if there is way for prefixes to work with the symlinks
|
2014-07-21 03:20:55 +00:00
|
|
|
install-multicall: $(BUILDDIR)/uutils
|
2014-07-01 08:07:16 +00:00
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR)
|
2014-07-21 03:20:55 +00:00
|
|
|
install $(BUILDDIR)/uutils $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX)uutils
|
2014-07-01 08:07:16 +00:00
|
|
|
cd $(DESTDIR)$(PREFIX)$(BINDIR)
|
|
|
|
for prog in $(INSTALLEES); do \
|
|
|
|
ln -s $(PROG_PREFIX)uutils $$prog; \
|
|
|
|
done
|
2015-01-23 16:35:54 +00:00
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)$(LIBDIR)
|
|
|
|
for lib in $(LIBS); do \
|
|
|
|
install $(BUILDDIR)/$$lib $(DESTDIR)$(PREFIX)$(LIBDIR)/$$lib; \
|
|
|
|
done
|
2014-07-01 08:07:16 +00:00
|
|
|
|
2014-06-13 01:43:52 +00:00
|
|
|
uninstall:
|
|
|
|
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS))
|
2014-12-30 19:11:36 +00:00
|
|
|
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(LIBDIR)/,$(LIBS))
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2014-07-01 08:07:16 +00:00
|
|
|
uninstall-multicall:
|
|
|
|
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils)
|
2015-01-23 16:35:54 +00:00
|
|
|
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(LIBDIR)/,$(LIBS))
|
2014-07-01 08:07:16 +00:00
|
|
|
|
2014-06-01 18:26:58 +00:00
|
|
|
# Test under the busybox testsuite
|
2014-07-21 03:20:55 +00:00
|
|
|
$(BUILDDIR)/busybox: $(BUILDDIR)/uutils
|
|
|
|
rm -f $(BUILDDIR)/busybox
|
|
|
|
ln -s $(BUILDDIR)/uutils $(BUILDDIR)/busybox
|
2014-06-01 18:26:58 +00:00
|
|
|
|
2014-06-09 02:03:38 +00:00
|
|
|
# This is a busybox-specific config file their test suite wants to parse.
|
2014-07-25 05:20:03 +00:00
|
|
|
$(BUILDDIR)/.config: $(BASEDIR)/.busybox-config $(BUILDDIR)/uutils
|
|
|
|
cp $< $@
|
2014-06-09 02:03:38 +00:00
|
|
|
|
2014-06-01 18:26:58 +00:00
|
|
|
ifeq ($(BUSYBOX_SRC),)
|
|
|
|
busytest:
|
|
|
|
@echo
|
|
|
|
@echo "To run \`busytest\` set BUSYBOX_SRC to the directory of the compiled busybox source code."
|
|
|
|
@echo "Optionally set RUNTEST_ARGS to arguments to pass to the busybox \`runtest\` program."
|
|
|
|
@echo
|
|
|
|
@false
|
|
|
|
else
|
2014-07-21 03:20:55 +00:00
|
|
|
busytest: $(BUILDDIR)/busybox $(BUILDDIR)/.config
|
|
|
|
(cd $(BUSYBOX_SRC)/testsuite && bindir=$(BUILDDIR) ./runtest $(RUNTEST_ARGS))
|
2014-06-01 18:26:58 +00:00
|
|
|
endif
|
|
|
|
|
2015-04-27 05:42:21 +00:00
|
|
|
# This rule will build each program, ignore all output, and return pass
|
|
|
|
# or fail depending on whether the build has errors.
|
|
|
|
build-check:
|
|
|
|
@for prog in $(sort $(PROGS)); do \
|
|
|
|
make BUILD="$$prog" >/dev/null 2>&1; status=$$?; \
|
|
|
|
if [ $$status -eq 0 ]; \
|
|
|
|
then printf "%-10s\t\033[1;32mpass\033[00;m\n" $$prog; \
|
|
|
|
else printf "%-10s\t\033[1;31mfail\033[00;m\n" $$prog; \
|
|
|
|
fi; \
|
|
|
|
done
|
|
|
|
|
2015-05-07 20:59:34 +00:00
|
|
|
# This rule will test each program, ignore all output, and return pass
|
|
|
|
# or fail depending on whether the test has errors.
|
|
|
|
test-check:
|
|
|
|
@for prog in $(sort $(TEST_PROGS)); do \
|
|
|
|
make TEST="$$prog" test >/dev/null 2>&1; status=$$?; \
|
|
|
|
if [ $$status -eq 0 ]; \
|
|
|
|
then printf "%-10s\t\033[1;32mpass\033[00;m\n" $$prog; \
|
|
|
|
else printf "%-10s\t\033[1;31mfail\033[00;m\n" $$prog; \
|
|
|
|
fi; \
|
|
|
|
done
|
|
|
|
|
2015-04-25 22:22:56 +00:00
|
|
|
.PHONY: $(TEMPDIR) all deps test distclean clean busytest install uninstall
|