Skip to content

Commit

Permalink
Fix out-of-tree build failures
Browse files Browse the repository at this point in the history
Resolve the incorrect use of srcdir and builddir references for
various files in the build system.  These have crept in over time
and went unnoticed because when building in the top level directory
srcdir and builddir are identical.

With this change it's again possible to build in a subdirectory.

    $ mkdir obj
    $ cd obj
    $ ../configure
    $ make

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #8921
  • Loading branch information
behlendorf committed Jun 21, 2019
1 parent da68988 commit 2d7daa3
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 72 deletions.
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ distclean-local::
-type f -print | xargs $(RM)

all-local:
-${top_srcdir}/scripts/zfs-tests.sh -c
@if test -f ${top_builddir}/scripts/zfs-tests.sh; then \
${top_builddir}/scripts/zfs-tests.sh -c; \
fi

dist-hook: gitrev
cp ${top_srcdir}/include/zfs_gitrev.h $(distdir)/include; \
Expand Down
57 changes: 2 additions & 55 deletions cmd/zed/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
SUBDIRS = zed.d

include $(top_srcdir)/config/Rules.am

DEFAULT_INCLUDES += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib/libspl/include

EXTRA_DIST = zed.d/README \
zed.d/history_event-zfs-list-cacher.sh.in

sbin_PROGRAMS = zed

ZED_SRC = \
Expand Down Expand Up @@ -47,55 +46,3 @@ zed_LDADD = \

zed_LDADD += -lrt
zed_LDFLAGS = -pthread

zedconfdir = $(sysconfdir)/zfs/zed.d

dist_zedconf_DATA = \
zed.d/zed-functions.sh \
zed.d/zed.rc

zedexecdir = $(zfsexecdir)/zed.d

dist_zedexec_SCRIPTS = \
zed.d/all-debug.sh \
zed.d/all-syslog.sh \
zed.d/data-notify.sh \
zed.d/generic-notify.sh \
zed.d/resilver_finish-notify.sh \
zed.d/scrub_finish-notify.sh \
zed.d/statechange-led.sh \
zed.d/statechange-notify.sh \
zed.d/vdev_clear-led.sh \
zed.d/vdev_attach-led.sh \
zed.d/pool_import-led.sh \
zed.d/resilver_finish-start-scrub.sh

nodist_zedexec_SCRIPTS = zed.d/history_event-zfs-list-cacher.sh

$(nodist_zedexec_SCRIPTS): %: %.in
-$(SED) -e 's,@bindir\@,$(bindir),g' \
-e 's,@runstatedir\@,$(runstatedir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
$< >'$@'

zedconfdefaults = \
all-syslog.sh \
data-notify.sh \
resilver_finish-notify.sh \
scrub_finish-notify.sh \
statechange-led.sh \
statechange-notify.sh \
vdev_clear-led.sh \
vdev_attach-led.sh \
pool_import-led.sh \
resilver_finish-start-scrub.sh

install-data-hook:
$(MKDIR_P) "$(DESTDIR)$(zedconfdir)"
for f in $(zedconfdefaults); do \
test -f "$(DESTDIR)$(zedconfdir)/$${f}" -o \
-L "$(DESTDIR)$(zedconfdir)/$${f}" || \
ln -s "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \
done
chmod 0600 "$(DESTDIR)$(zedconfdir)/zed.rc"
57 changes: 57 additions & 0 deletions cmd/zed/zed.d/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
include $(top_srcdir)/config/Rules.am

EXTRA_DIST = \
README \
history_event-zfs-list-cacher.sh.in

zedconfdir = $(sysconfdir)/zfs/zed.d

dist_zedconf_DATA = \
zed-functions.sh \
zed.rc

zedexecdir = $(zfsexecdir)/zed.d

dist_zedexec_SCRIPTS = \
all-debug.sh \
all-syslog.sh \
data-notify.sh \
generic-notify.sh \
resilver_finish-notify.sh \
scrub_finish-notify.sh \
statechange-led.sh \
statechange-notify.sh \
vdev_clear-led.sh \
vdev_attach-led.sh \
pool_import-led.sh \
resilver_finish-start-scrub.sh

nodist_zedexec_SCRIPTS = history_event-zfs-list-cacher.sh

$(nodist_zedexec_SCRIPTS): %: %.in
-$(SED) -e 's,@bindir\@,$(bindir),g' \
-e 's,@runstatedir\@,$(runstatedir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
$< >'$@'

zedconfdefaults = \
all-syslog.sh \
data-notify.sh \
resilver_finish-notify.sh \
scrub_finish-notify.sh \
statechange-led.sh \
statechange-notify.sh \
vdev_clear-led.sh \
vdev_attach-led.sh \
pool_import-led.sh \
resilver_finish-start-scrub.sh

install-data-hook:
$(MKDIR_P) "$(DESTDIR)$(zedconfdir)"
for f in $(zedconfdefaults); do \
test -f "$(DESTDIR)$(zedconfdir)/$${f}" -o \
-L "$(DESTDIR)$(zedconfdir)/$${f}" || \
ln -s "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \
done
chmod 0600 "$(DESTDIR)$(zedconfdir)/zed.rc"
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ AC_CONFIG_FILES([
cmd/dbufstat/Makefile
cmd/arc_summary/Makefile
cmd/zed/Makefile
cmd/zed/zed.d/Makefile
cmd/raidz_test/Makefile
cmd/zgenhostid/Makefile
contrib/Makefile
Expand Down
21 changes: 13 additions & 8 deletions contrib/initramfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ EXTRA_DIST = \
$(top_srcdir)/contrib/initramfs/README.initramfs.markdown

install-initrdSCRIPTS: $(EXTRA_DIST)
for d in conf.d conf-hooks.d hooks scripts scripts/local-top; do \
$(MKDIR_P) $(DESTDIR)$(initrddir)/$$d; \
cp $(top_srcdir)/contrib/initramfs/$$d/zfs \
$(DESTDIR)$(initrddir)/$$d/; \
for d in conf.d conf-hooks.d scripts/local-top; do \
$(MKDIR_P) $(DESTDIR)$(initrddir)/$$d; \
cp $(top_srcdir)/contrib/initramfs/$$d/zfs \
$(DESTDIR)$(initrddir)/$$d/; \
done
if [ -f etc/init.d/zfs ]; then \
$(MKDIR_P) $(DESTDIR)$(DEFAULT_INITCONF_DIR); \
cp $(top_srcdir)/etc/init.d/zfs \
$(DESTDIR)$(DEFAULT_INITCONF_DIR)/; \
for d in hooks scripts; do \
$(MKDIR_P) $(DESTDIR)$(initrddir)/$$d; \
cp $(top_builddir)/contrib/initramfs/$$d/zfs \
$(DESTDIR)$(initrddir)/$$d/; \
done
if [ -f $(top_builddir)/etc/init.d/zfs ]; then \
$(MKDIR_P) $(DESTDIR)$(DEFAULT_INITCONF_DIR); \
cp $(top_builddir)/etc/init.d/zfs \
$(DESTDIR)$(DEFAULT_INITCONF_DIR)/; \
fi
2 changes: 1 addition & 1 deletion contrib/pyzfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ all-local:
# files are later created by manually loading the Python modules.
#
install-exec-local:
$(PYTHON) $(srcdir)/setup.py install \
$(PYTHON) $(builddir)/setup.py install \
--prefix $(prefix) \
--root $(DESTDIR)/ \
--install-lib $(pythonsitedir) \
Expand Down
5 changes: 3 additions & 2 deletions module/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ modules_uninstall:

distdir:
list='$(subdir-m)'; for subdir in $$list; do \
(cd @top_srcdir@/module && find $$subdir -name '*.c' -o -name '*.h' -o -name '*.S' |\
xargs cp --parents -t $$distdir); \
(cd @top_srcdir@/module && find $$subdir \
-name '*.c' -o -name '*.h' -o -name '*.S' | \
xargs cp --parents -t @abs_top_builddir@/module/$$distdir); \
done

distclean maintainer-clean: clean
Expand Down
5 changes: 3 additions & 2 deletions scripts/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ all-local:
-e '\|^export SBIN_DIR=|s|$$|@abs_top_builddir@/bin|' \
-e '\|^export ZTS_DIR=|s|$$|@abs_top_srcdir@/tests|' \
-e '\|^export SCRIPT_DIR=|s|$$|@abs_top_srcdir@/scripts|' \
common.sh.in >common.sh
$(abs_top_srcdir)/scripts/common.sh.in >common.sh
-echo "$$EXTRA_ENVIRONMENT" >>common.sh

clean-local:
Expand All @@ -71,4 +71,5 @@ install-data-hook:
-e '\|^export SBIN_DIR=|s|$$|@sbindir@|' \
-e '\|^export ZTS_DIR=|s|$$|@datadir@/@PACKAGE@|' \
-e '\|^export SCRIPT_DIR=|s|$$|@datadir@/@PACKAGE@|' \
common.sh.in >$(DESTDIR)$(datadir)/@PACKAGE@/common.sh
$(abs_top_srcdir)/scripts/common.sh.in \
>$(DESTDIR)$(datadir)/@PACKAGE@/common.sh
5 changes: 4 additions & 1 deletion tests/runfiles/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
pkgdatadir = $(datadir)/@PACKAGE@/runfiles
dist_pkgdata_DATA = *.run
dist_pkgdata_DATA = \
linux.run \
longevity.run \
perf-regression.run
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/checksum/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(top_srcdir)/config/Rules.am

AM_CPPFLAGS += -I$(top_srcdir)/include
LDADD = $(top_srcdir)/lib/libicp/libicp.la
LDADD = $(top_builddir)/lib/libicp/libicp.la

AUTOMAKE_OPTIONS = subdir-objects

Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/hkdf/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include $(top_srcdir)/config/Rules.am

AM_CPPFLAGS += -I$(top_srcdir)/include
AM_CPPFLAGS += -I$(top_srcdir)/lib/libspl/include
LDADD = $(top_srcdir)/lib/libzpool/libzpool.la
LDADD = $(top_builddir)/lib/libzpool/libzpool.la

AUTOMAKE_OPTIONS = subdir-objects

Expand Down

0 comments on commit 2d7daa3

Please sign in to comment.