|
From: Jiri J. <jja...@re...> - 2014-09-23 09:46:06
|
Signed-off-by: Jiri Jaburek <jja...@re...>
---
audit-test/rules.mk | 11 +++++++++--
audit-test/utils/run.bash | 16 ++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/audit-test/rules.mk b/audit-test/rules.mk
index fd18e0f..16410b5 100644
--- a/audit-test/rules.mk
+++ b/audit-test/rules.mk
@@ -51,8 +51,8 @@ LINK_SO = $(CC) $(LDFLAGS) -shared -o $@ $^ $(LOADLIBES) $(LDLIBS)
export MACHINE
# If MODE isn't set explicitly, the default for the machine is used
-export NATIVE = $(strip $(shell file /bin/bash | awk -F'[ -]' '{print $$3}'))
-export MODE ?= $(NATIVE)
+NATIVE = $(strip $(shell file /bin/bash | awk -F'[ -]' '{print $$3}'))
+export MODE ?= $(NATIVE)
ifneq ($(MODE), $(NATIVE))
ifeq ($(MODE), 32)
ifneq (,$(findstring $(MACHINE), $(Z64)))
@@ -314,3 +314,10 @@ subdirs_quiet:
@for x in $(SUB_DIRS); do \
$(MAKE) --no-print-directory -C $$x $(MAKECMDGOALS) || exit $$?; \
done
+
+##########################################################################
+# Various helper rules
+##########################################################################
+
+export-%:
+ @[ '$($*)' ] && echo 'export $*=$($*)' || true
diff --git a/audit-test/utils/run.bash b/audit-test/utils/run.bash
index a258988..451b5e6 100755
--- a/audit-test/utils/run.bash
+++ b/audit-test/utils/run.bash
@@ -31,6 +31,21 @@
# usage information can be retrieved with "./run.bash --help"
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
+
+# read certain variables from the make system
+# - these variables are normally exported by 'make run', but not by manual
+# ./run.bash, so read them (in either case) manually here
+if [[ -f Makefile ]]; then
+ eval "$(MAKELEVEL= make --no-print-directory -f Makefile \
+ export-TOPDIR export-MACHINE export-MODE export-DISTRO \
+ export-LSM_SELINUX)"
+ # convert TOPDIR to absolute path
+ [ "$TOPDIR" ] && TOPDIR=$(cd "$TOPDIR"; pwd)
+else
+ echo "Unable to find Makefile in $PWD, some variables might be empty." >&2
+fi
+
+# fallback, primarily read from Makefile
if [[ -z $TOPDIR ]]; then
TOPDIR=$(
while [[ ! $PWD -ef / ]]; do
@@ -41,6 +56,7 @@ if [[ -z $TOPDIR ]]; then
) || { echo "Can't find TOPDIR, where is rules.mk?" >&2; exit 1; }
export TOPDIR
fi
+
PATH=$TOPDIR/utils:$TOPDIR/utils/bin:$PATH
source functions.bash || exit 2
--
1.8.3.1
|