commit: e20993aae51de13bfc4028105aa7756771046c64
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 21 06:50:34 2021 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Oct 21 06:50:34 2021 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=e20993aa
build: flatten build a bit to avoid (most) recursive make
Provides a bit of a speed up.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
.gitignore | 3 +-
Makefile.am | 20 ++++-----
configure.ac | 5 +--
libsandbox/Makefile | 4 ++
libsandbox/{Makefile.am => local.mk} | 81 +++++++++++++++++++-----------------
libsbutil/Makefile | 4 ++
libsbutil/Makefile.am | 71 -------------------------------
libsbutil/local.mk | 65 +++++++++++++++++++++++++++++
src/Makefile | 4 ++
src/Makefile.am | 17 --------
src/local.mk | 15 +++++++
11 files changed, 148 insertions(+), 141 deletions(-)
diff --git a/.gitignore b/.gitignore
index 76d3d1a..04a0f20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,8 @@ a.out
.deps
.libs
.dirstamp
-Makefile
+/Makefile
+/tests/Makefile
Makefile.in
f
diff --git a/Makefile.am b/Makefile.am
index b0ea65f..c01f973 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,23 +2,19 @@ ACLOCAL_AMFLAGS = -I m4
MAKEFLAGS = --no-print-directory
AM_CPPFLAGS = $(SANDBOX_DEFINES)
-SUBDIRS = \
- libsbutil \
- libsandbox \
- src \
- tests
+SUBDIRS = tests
confdir = $(sysconfdir)
confddir = $(sysconfdir)/sandbox.d
+bin_PROGRAMS =
dist_conf_DATA = etc/sandbox.conf
confd_DATA = etc/sandbox.d/00default
dist_pkgdata_DATA = data/sandbox.bashrc
+lib_LTLIBRARIES =
noinst_LTLIBRARIES =
-libsandbox: libsbutil
-src: libsbutil
-tests: src
+CLEANFILES =
EXTRA_DIST = \
headers.h \
@@ -31,8 +27,6 @@ EXTRA_DIST = \
scripts/gen_symbol_header.awk \
scripts/gen_trace_header.awk
-DISTCLEANFILES = $(CLEANFILES)
-
ChangeLog:
touch ChangeLog
@@ -47,3 +41,9 @@ dist-hook:
touch "$(distdir)/ChangeLog" ; \
fi ; \
fi
+
+include libsandbox/local.mk
+include libsbutil/local.mk
+include src/local.mk
+
+DISTCLEANFILES = $(CLEANFILES)
diff --git a/configure.ac b/configure.ac
index dac7d9c..99c0d01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@ AC_DEFUN([SB_CHECK_SCHIZO],[dnl
], [
enable_schizo=yes
AS_VAR_APPEND([SB_SCHIZO_SETTINGS], " $1:$2")
- AS_VAR_APPEND([SB_SCHIZO_HEADERS], "
trace_syscalls_$1.h")
+ AS_VAR_APPEND([SB_SCHIZO_HEADERS], "
libsandbox/trace_syscalls_$1.h")
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([SB_SCHIZO_$1], 1, [Support for
$1/$2 is available])
], [
@@ -464,9 +464,6 @@ AC_CONFIG_FILES([src/sandbox.sh], [chmod +x src/sandbox.sh])
AC_CONFIG_FILES([
Makefile
etc/sandbox.d/00default
- libsandbox/Makefile
- libsbutil/Makefile
- src/Makefile
tests/atlocal
tests/Makefile
tests/package.m4
diff --git a/libsandbox/Makefile b/libsandbox/Makefile
new file mode 100644
index 0000000..ab08445
--- /dev/null
+++ b/libsandbox/Makefile
@@ -0,0 +1,4 @@
+# Helper for developers.
+all libsandbox: libsandbox/libsandbox.la ;
+clean: ; rm -f *.o *.l[ao] .libs/*
+%: ; $(MAKE) -C .. $@
diff --git a/libsandbox/Makefile.am b/libsandbox/local.mk
similarity index 52%
rename from libsandbox/Makefile.am
rename to libsandbox/local.mk
index ac9a548..9ddecb9 100644
--- a/libsandbox/Makefile.am
+++ b/libsandbox/local.mk
@@ -1,36 +1,38 @@
-AUTOMAKE_OPTIONS = foreign
+lib_LTLIBRARIES += %D%/libsandbox.la
-lib_LTLIBRARIES = libsandbox.la
-
-AM_CPPFLAGS = \
+%C%_libsandbox_la_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I%D% \
-I$(top_srcdir) \
+ -I$(top_srcdir)/%D% \
-I$(top_srcdir)/libsbutil \
- -I$(top_srcdir)/libsbutil/include \
- $(SANDBOX_DEFINES)
+ -I$(top_srcdir)/libsbutil/include
-libsandbox_la_CFLAGS = $(CFLAG_EXCEPTIONS)
+%C%_libsandbox_la_CFLAGS = $(CFLAG_EXCEPTIONS)
# Could use the following to libsandbox_la_LIBADD, but then libtool links it
# with --whole-archive, and libsandbox.so increase with a few KB in size:
-# $(top_builddir)/libsbutil/libsbutil.la
-libsandbox_la_LIBSBLIB = $(top_builddir)/libsbutil/.libs/libsbutil.a
-libsandbox_la_LIBADD = \
+# libsbutil/libsbutil.la
+libsbutil/.libs/libsbutil.a: libsbutil/libsbutil.la
+%C%_libsandbox_la_LIBSBLIB = libsbutil/.libs/libsbutil.a
+%C%_libsandbox_la_LIBADD = \
-lc $(LIBDL) \
- $(libsandbox_la_LIBSBLIB)
+ $(%C%_libsandbox_la_LIBSBLIB)
# Do not add -nostdlib or -nostartfiles, as then our constructor
# and destructor will not be executed ...
-libsandbox_la_LDFLAGS = \
+%C%_libsandbox_la_LDFLAGS = \
-no-undefined \
-avoid-version \
- $(LDFLAG_VER),libsandbox.map
-libsandbox_la_SOURCES = \
- libsandbox.h \
- libsandbox.c \
- lock.c \
- memory.c \
- trace.c \
- wrappers.h \
- wrappers.c \
- canonicalize.c
+ $(LDFLAG_VER),%D%/libsandbox.map
+%C%_libsandbox_la_SOURCES = \
+ %D%/headers.h \
+ %D%/libsandbox.h \
+ %D%/libsandbox.c \
+ %D%/lock.c \
+ %D%/memory.c \
+ %D%/trace.c \
+ %D%/wrappers.h \
+ %D%/wrappers.c \
+ %D%/canonicalize.c
install-exec-hook:
rm -f $(DESTDIR)$(libdir)/libsandbox.la
@@ -39,37 +41,37 @@ install-exec-hook:
uninstall-hook:
rm -f $(DESTDIR)$(libdir)/libsandbox.so
-libsandbox.c: libsandbox.map sb_nr.h
-trace.c: trace_syscalls.h sb_nr.h $(TRACE_FILES)
-wrappers.c: symbols.h
+%D%/libsandbox.c: %D%/libsandbox.map %D%/sb_nr.h
+%D%/trace.c: %D%/trace_syscalls.h %D%/sb_nr.h $(TRACE_FILES)
+%D%/wrappers.c: %D%/symbols.h
-TRACE_FILES = $(wildcard $(srcdir)/trace/*.[ch] $(srcdir)/trace/*/*.[ch])
+TRACE_FILES = $(wildcard $(top_srcdir)/%D%/trace/*.[ch]
$(top_srcdir)/%D%/trace/*/*.[ch])
SCRIPT_DIR = $(top_srcdir)/scripts
-SYMBOLS_FILE = $(srcdir)/symbols.h.in
+SYMBOLS_FILE = $(top_srcdir)/%D%/symbols.h.in
SYMBOLS_LIST = $(shell $(SED) -n '/^[^\#]/p' $(SYMBOLS_FILE))
-SYMBOLS_WRAPPERS = $(wildcard $(srcdir)/wrapper-funcs/*.[ch])
+SYMBOLS_WRAPPERS = $(wildcard $(top_srcdir)/%D%/wrapper-funcs/*.[ch])
GEN_VERSION_MAP_SCRIPT = $(SCRIPT_DIR)/gen_symbol_version_map.awk
GEN_HEADER_SCRIPT = $(SCRIPT_DIR)/gen_symbol_header.awk
GEN_TRACE_SCRIPT = $(SCRIPT_DIR)/gen_trace_header.awk
-SB_AWK = LC_ALL=C $(AWK) -v SYMBOLS_LIST="$(SYMBOLS_LIST)" -v
srcdir="$(srcdir)" -f
+SB_AWK = LC_ALL=C $(AWK) -v SYMBOLS_LIST="$(SYMBOLS_LIST)" -v
srcdir="$(top_srcdir)/%D%" -f
-libsandbox.map: $(SYMBOLS_FILE) $(GEN_VERSION_MAP_SCRIPT)
+%D%/libsandbox.map: $(SYMBOLS_FILE) $(GEN_VERSION_MAP_SCRIPT)
$(AM_V_GEN)$(READELF) -s $(LIBC_PATH) | $(SB_AWK)
$(GEN_VERSION_MAP_SCRIPT) > $@
-symbols.h: $(SYMBOLS_FILE) $(GEN_HEADER_SCRIPT)
+%D%/symbols.h: $(SYMBOLS_FILE) $(GEN_HEADER_SCRIPT)
$(AM_V_GEN)$(READELF) -s $(LIBC_PATH) | $(SB_AWK) $(GEN_HEADER_SCRIPT)
> $@
-SB_NR_FILE = $(srcdir)/sb_nr.h.in
-sb_nr.h: symbols.h $(SB_NR_FILE)
+SB_NR_FILE = %D%/sb_nr.h.in
+%D%/sb_nr.h: %D%/symbols.h $(SB_NR_FILE)
$(AM_V_GEN)$(EGREP) -h '^\#define SB_' $^ > $@
TRACE_MAKE_HEADER = \
$(SB_AWK) $(GEN_TRACE_SCRIPT) -v MODE=gen | \
$(COMPILE) -E -P -include $(top_srcdir)/headers.h - $$f | \
$(SB_AWK) $(GEN_TRACE_SCRIPT) -v syscall_prefix=$$t > $$header
-trace_syscalls.h: $(GEN_TRACE_SCRIPT) $(SB_SCHIZO_HEADERS)
+%D%/trace_syscalls.h: $(GEN_TRACE_SCRIPT) $(SB_SCHIZO_HEADERS)
if SB_SCHIZO
$(AM_V_GEN)touch $@
else
@@ -80,14 +82,17 @@ $(SB_SCHIZO_HEADERS): $(GEN_TRACE_SCRIPT)
$(AM_V_GEN)for pers in $(SB_SCHIZO_SETTINGS) ; do \
t=_$${pers%:*}; \
f=$${pers#*:}; \
- header="trace_syscalls$${t}.h"; \
+ header="%D%/trace_syscalls$${t}.h"; \
if [ "$$header" = "$@" ]; then \
$(TRACE_MAKE_HEADER) || exit $$?; \
break; \
fi; \
done
-EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) $(TRACE_FILES)
headers.h
+EXTRA_DIST += $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) $(TRACE_FILES)
-CLEANFILES = libsandbox.map sb_nr.h symbols.h trace_syscalls*.h
-DISTCLEANFILES = $(CLEANFILES)
+CLEANFILES += \
+ %D%/libsandbox.map \
+ %D%/sb_nr.h \
+ %D%/symbols.h \
+ %D%/trace_syscalls*.h
diff --git a/libsbutil/Makefile b/libsbutil/Makefile
new file mode 100644
index 0000000..608bccf
--- /dev/null
+++ b/libsbutil/Makefile
@@ -0,0 +1,4 @@
+# Helper for developers.
+all libsbutil: libsbutil/libsbutil.la ;
+clean: ; rm -f *.o *.l[ao] .libs/*
+%: ; $(MAKE) -C .. $@
diff --git a/libsbutil/Makefile.am b/libsbutil/Makefile.am
deleted file mode 100644
index 06de7d3..0000000
--- a/libsbutil/Makefile.am
+++ /dev/null
@@ -1,71 +0,0 @@
-AUTOMAKE_OPTIONS = foreign
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(srcdir)/include \
- $(SANDBOX_DEFINES)
-
-LOCAL_INCLUDES = $(top_srcdir)/localdecls.h
-
-noinst_LTLIBRARIES = libsbutil.la
-
-libsbutil_la_LDFLAGS = -no-undefined
-libsbutil_la_SOURCES = \
- sbutil.h \
- get_sandbox_conf.c \
- get_sandbox_confd.c \
- get_sandbox_lib.c \
- get_sandbox_rc.c \
- get_sandbox_log.c \
- get_tmp_dir.c \
- environment.c \
- sb_backtrace.c \
- sb_efuncs.c \
- sb_gdb.c \
- sb_method.c \
- sb_open.c \
- sb_read.c \
- sb_write.c \
- sb_write_fd.c \
- sb_close.c \
- sb_printf.c \
- sb_proc.c \
- sb_memory.c \
- include/rcscripts/rcutil.h \
- include/rcscripts/util/str_list.h \
- include/rcscripts/util/debug.h \
- src/debug.c \
- include/rcscripts/util/string.h \
- src/string.c \
- include/rcscripts/util/file.h \
- src/file.c \
- include/rcscripts/util/config.h \
- src/config.c \
- include/rcscripts/util/dynbuf.h \
- src/dynbuf.c \
- gnulib/areadlink.h \
- gnulib/areadlink-with-size.c \
- gnulib/bitrotate.c \
- gnulib/bitrotate.h \
- gnulib/canonicalize.c \
- gnulib/canonicalize.h \
- gnulib/careadlinkat.h \
- gnulib/dosname.h \
- gnulib/file-set.c \
- gnulib/file-set.h \
- gnulib/gl-inline.h \
- gnulib/glue.h \
- gnulib/hash.c \
- gnulib/hash.h \
- gnulib/hash-pjw.c \
- gnulib/hash-pjw.h \
- gnulib/hash-triple.c \
- gnulib/hash-triple.h \
- gnulib/pathmax.h \
- gnulib/same-inode.h \
- gnulib/xalloc.h \
- gnulib/xalloc-oversized.h \
- gnulib/xgetcwd.h \
- $(LOCAL_INCLUDES)
-
-EXTRA_DIST = headers.h
diff --git a/libsbutil/local.mk b/libsbutil/local.mk
new file mode 100644
index 0000000..d1a9ffd
--- /dev/null
+++ b/libsbutil/local.mk
@@ -0,0 +1,65 @@
+noinst_LTLIBRARIES += %D%/libsbutil.la
+
+%C%_libsbutil_la_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/%D% \
+ -I$(top_srcdir)/%D%/include
+%C%_libsbutil_la_LDFLAGS = -no-undefined
+%C%_libsbutil_la_SOURCES = \
+ %D%/sbutil.h \
+ %D%/get_sandbox_conf.c \
+ %D%/get_sandbox_confd.c \
+ %D%/get_sandbox_lib.c \
+ %D%/get_sandbox_rc.c \
+ %D%/get_sandbox_log.c \
+ %D%/get_tmp_dir.c \
+ %D%/environment.c \
+ %D%/headers.h \
+ %D%/sb_backtrace.c \
+ %D%/sb_efuncs.c \
+ %D%/sb_gdb.c \
+ %D%/sb_method.c \
+ %D%/sb_open.c \
+ %D%/sb_read.c \
+ %D%/sb_write.c \
+ %D%/sb_write_fd.c \
+ %D%/sb_close.c \
+ %D%/sb_printf.c \
+ %D%/sb_proc.c \
+ %D%/sb_memory.c \
+ %D%/include/rcscripts/rcutil.h \
+ %D%/include/rcscripts/util/str_list.h \
+ %D%/include/rcscripts/util/debug.h \
+ %D%/src/debug.c \
+ %D%/include/rcscripts/util/string.h \
+ %D%/src/string.c \
+ %D%/include/rcscripts/util/file.h \
+ %D%/src/file.c \
+ %D%/include/rcscripts/util/config.h \
+ %D%/src/config.c \
+ %D%/include/rcscripts/util/dynbuf.h \
+ %D%/src/dynbuf.c \
+ %D%/gnulib/areadlink.h \
+ %D%/gnulib/areadlink-with-size.c \
+ %D%/gnulib/bitrotate.c \
+ %D%/gnulib/bitrotate.h \
+ %D%/gnulib/canonicalize.c \
+ %D%/gnulib/canonicalize.h \
+ %D%/gnulib/careadlinkat.h \
+ %D%/gnulib/dosname.h \
+ %D%/gnulib/file-set.c \
+ %D%/gnulib/file-set.h \
+ %D%/gnulib/gl-inline.h \
+ %D%/gnulib/glue.h \
+ %D%/gnulib/hash.c \
+ %D%/gnulib/hash.h \
+ %D%/gnulib/hash-pjw.c \
+ %D%/gnulib/hash-pjw.h \
+ %D%/gnulib/hash-triple.c \
+ %D%/gnulib/hash-triple.h \
+ %D%/gnulib/pathmax.h \
+ %D%/gnulib/same-inode.h \
+ %D%/gnulib/xalloc.h \
+ %D%/gnulib/xalloc-oversized.h \
+ %D%/gnulib/xgetcwd.h
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..4b2bc35
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,4 @@
+# Helper for developers.
+all sandbox: src/sandbox ;
+clean: ; rm -f *.o *.l[ao] .libs/* sandbox
+%: ; $(MAKE) -C .. $@
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index e7aeb30..0000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-AUTOMAKE_OPTIONS = foreign
-
-bin_PROGRAMS = sandbox
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/libsbutil \
- -I$(top_srcdir)/libsbutil/include \
- $(SANDBOX_DEFINES)
-
-sandbox_LDADD = $(top_builddir)/libsbutil/libsbutil.la $(LIBDL)
-sandbox_SOURCES = \
- environ.c \
- namespaces.c \
- options.c \
- sandbox.h \
- sandbox.c
diff --git a/src/local.mk b/src/local.mk
new file mode 100644
index 0000000..1fe2b31
--- /dev/null
+++ b/src/local.mk
@@ -0,0 +1,15 @@
+bin_PROGRAMS += %D%/sandbox
+
+%C%_sandbox_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/libsbutil \
+ -I$(top_srcdir)/libsbutil/include
+
+%C%_sandbox_LDADD = libsbutil/libsbutil.la $(LIBDL)
+%C%_sandbox_SOURCES = \
+ %D%/environ.c \
+ %D%/namespaces.c \
+ %D%/options.c \
+ %D%/sandbox.h \
+ %D%/sandbox.c