Skip to content

Commit

Permalink
Support parallel build trees (VPATH builds)
Browse files Browse the repository at this point in the history
Build products from an out of tree build should be written
relative to the build directory.  Sources should be referred
to by their locations in the source directory.

This is accomplished by adding the 'src' and 'obj' variables
for the module Makefile.am, using relative paths to reference
source files, and by setting VPATH when source files are not
co-located with the Makefile.  This enables the following:

  $ mkdir build
  $ cd build
  $ ../configure \
    --with-spl=$HOME/src/git/spl/ \
    --with-spl-obj=$HOME/src/git/spl/build
  $ make -s

This change also has the advantage of resolving the following
warning which is generated by modern versions of automake.

  Makefile.am:00: warning: source file 'xxx' is in a subdirectory,
  Makefile.am:00: but option 'subdir-objects' is disabled

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes openzfs#1082
  • Loading branch information
FransUrbo authored and behlendorf committed Jul 17, 2015
1 parent 2a53e2d commit 47a4a6f
Show file tree
Hide file tree
Showing 42 changed files with 476 additions and 388 deletions.
11 changes: 5 additions & 6 deletions Makefile.am
@@ -1,9 +1,8 @@

ACLOCAL_AMFLAGS = -I config

include $(top_srcdir)/config/rpm.am
include $(top_srcdir)/config/deb.am
include $(top_srcdir)/config/tgz.am
include config/rpm.am
include config/deb.am
include config/tgz.am

SUBDIRS = include rpm
if CONFIG_USER
Expand Down Expand Up @@ -57,11 +56,11 @@ shellcheck:
fi

ctags:
$(RM) $(top_srcdir)/tags
$(RM) tags
find $(top_srcdir) -name .git -prune -o -name '*.[hc]' | xargs ctags

etags:
$(RM) $(top_srcdir)/TAGS
$(RM) TAGS
find $(top_srcdir) -name .pc -prune -o -name '*.[hc]' | xargs etags -a

tags: ctags etags
Expand Down
3 changes: 1 addition & 2 deletions cmd/arc_summary/Makefile.am
@@ -1,2 +1 @@
bin_SCRIPTS = arc_summary.py
EXTRA_DIST = $(bin_SCRIPTS)
dist_bin_SCRIPTS = arc_summary.py
3 changes: 1 addition & 2 deletions cmd/arcstat/Makefile.am
@@ -1,2 +1 @@
bin_SCRIPTS = arcstat.py
EXTRA_DIST = $(bin_SCRIPTS)
dist_bin_SCRIPTS = arcstat.py
3 changes: 1 addition & 2 deletions cmd/dbufstat/Makefile.am
@@ -1,2 +1 @@
bin_SCRIPTS = dbufstat.py
EXTRA_DIST = $(bin_SCRIPTS)
dist_bin_SCRIPTS = dbufstat.py
2 changes: 1 addition & 1 deletion cmd/mount_zfs/Makefile.am
Expand Up @@ -12,7 +12,7 @@ sbindir=$(mounthelperdir)
sbin_PROGRAMS = mount.zfs

mount_zfs_SOURCES = \
$(top_srcdir)/cmd/mount_zfs/mount_zfs.c
mount_zfs.c

mount_zfs_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
4 changes: 2 additions & 2 deletions cmd/zdb/Makefile.am
Expand Up @@ -7,8 +7,8 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = zdb

zdb_SOURCES = \
$(top_srcdir)/cmd/zdb/zdb.c \
$(top_srcdir)/cmd/zdb/zdb_il.c
zdb.c \
zdb_il.c

zdb_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
54 changes: 27 additions & 27 deletions cmd/zed/Makefile.am
Expand Up @@ -4,25 +4,25 @@ DEFAULT_INCLUDES += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib/libspl/include

EXTRA_DIST = $(top_srcdir)/cmd/zed/zed.d/README
EXTRA_DIST = zed.d/README

sbin_PROGRAMS = zed

zed_SOURCES = \
$(top_srcdir)/cmd/zed/zed.c \
$(top_srcdir)/cmd/zed/zed.h \
$(top_srcdir)/cmd/zed/zed_conf.c \
$(top_srcdir)/cmd/zed/zed_conf.h \
$(top_srcdir)/cmd/zed/zed_event.c \
$(top_srcdir)/cmd/zed/zed_event.h \
$(top_srcdir)/cmd/zed/zed_exec.c \
$(top_srcdir)/cmd/zed/zed_exec.h \
$(top_srcdir)/cmd/zed/zed_file.c \
$(top_srcdir)/cmd/zed/zed_file.h \
$(top_srcdir)/cmd/zed/zed_log.c \
$(top_srcdir)/cmd/zed/zed_log.h \
$(top_srcdir)/cmd/zed/zed_strings.c \
$(top_srcdir)/cmd/zed/zed_strings.h
zed.c \
zed.h \
zed_conf.c \
zed_conf.h \
zed_event.c \
zed_event.h \
zed_exec.c \
zed_exec.h \
zed_file.c \
zed_file.h \
zed_log.c \
zed_log.h \
zed_strings.c \
zed_strings.h

zed_LDADD = \
$(top_builddir)/lib/libavl/libavl.la \
Expand All @@ -35,22 +35,22 @@ zed_LDADD = \
zedconfdir = $(sysconfdir)/zfs/zed.d

dist_zedconf_DATA = \
$(top_srcdir)/cmd/zed/zed.d/zed-functions.sh \
$(top_srcdir)/cmd/zed/zed.d/zed.rc
zed.d/zed-functions.sh \
zed.d/zed.rc

zedexecdir = $(libexecdir)/zfs/zed.d

dist_zedexec_SCRIPTS = \
$(top_srcdir)/cmd/zed/zed.d/all-debug.sh \
$(top_srcdir)/cmd/zed/zed.d/all-syslog.sh \
$(top_srcdir)/cmd/zed/zed.d/checksum-notify.sh \
$(top_srcdir)/cmd/zed/zed.d/checksum-spare.sh \
$(top_srcdir)/cmd/zed/zed.d/data-notify.sh \
$(top_srcdir)/cmd/zed/zed.d/generic-notify.sh \
$(top_srcdir)/cmd/zed/zed.d/io-notify.sh \
$(top_srcdir)/cmd/zed/zed.d/io-spare.sh \
$(top_srcdir)/cmd/zed/zed.d/resilver.finish-notify.sh \
$(top_srcdir)/cmd/zed/zed.d/scrub.finish-notify.sh
zed.d/all-debug.sh \
zed.d/all-syslog.sh \
zed.d/checksum-notify.sh \
zed.d/checksum-spare.sh \
zed.d/data-notify.sh \
zed.d/generic-notify.sh \
zed.d/io-notify.sh \
zed.d/io-spare.sh \
zed.d/resilver.finish-notify.sh \
zed.d/scrub.finish-notify.sh

zedconfdefaults = \
all-syslog.sh \
Expand Down
8 changes: 4 additions & 4 deletions cmd/zfs/Makefile.am
Expand Up @@ -7,10 +7,10 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = zfs

zfs_SOURCES = \
$(top_srcdir)/cmd/zfs/zfs_iter.c \
$(top_srcdir)/cmd/zfs/zfs_iter.h \
$(top_srcdir)/cmd/zfs/zfs_main.c \
$(top_srcdir)/cmd/zfs/zfs_util.h
zfs_iter.c \
zfs_iter.h \
zfs_main.c \
zfs_util.h

zfs_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
2 changes: 1 addition & 1 deletion cmd/zhack/Makefile.am
Expand Up @@ -7,7 +7,7 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = zhack

zhack_SOURCES = \
$(top_srcdir)/cmd/zhack/zhack.c
zhack.c

zhack_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
6 changes: 3 additions & 3 deletions cmd/zinject/Makefile.am
Expand Up @@ -7,9 +7,9 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = zinject

zinject_SOURCES = \
$(top_srcdir)/cmd/zinject/translate.c \
$(top_srcdir)/cmd/zinject/zinject.c \
$(top_srcdir)/cmd/zinject/zinject.h
translate.c \
zinject.c \
zinject.h

zinject_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
7 changes: 3 additions & 4 deletions cmd/zpios/Makefile.am
Expand Up @@ -6,7 +6,6 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = zpios

zpios_SOURCES = \
$(top_srcdir)/cmd/zpios/zpios_main.c \
$(top_srcdir)/cmd/zpios/zpios_util.c \
$(top_srcdir)/cmd/zpios/zpios.h

zpios_main.c \
zpios_util.c \
zpios.h
10 changes: 5 additions & 5 deletions cmd/zpool/Makefile.am
Expand Up @@ -7,11 +7,11 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = zpool

zpool_SOURCES = \
$(top_srcdir)/cmd/zpool/zpool_iter.c \
$(top_srcdir)/cmd/zpool/zpool_main.c \
$(top_srcdir)/cmd/zpool/zpool_util.c \
$(top_srcdir)/cmd/zpool/zpool_util.h \
$(top_srcdir)/cmd/zpool/zpool_vdev.c
zpool_iter.c \
zpool_main.c \
zpool_util.c \
zpool_util.h \
zpool_vdev.c

zpool_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
2 changes: 1 addition & 1 deletion cmd/zstreamdump/Makefile.am
Expand Up @@ -7,7 +7,7 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = zstreamdump

zstreamdump_SOURCES = \
$(top_srcdir)/cmd/zstreamdump/zstreamdump.c
zstreamdump.c

zstreamdump_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
2 changes: 1 addition & 1 deletion cmd/ztest/Makefile.am
Expand Up @@ -9,7 +9,7 @@ DEFAULT_INCLUDES += \
sbin_PROGRAMS = ztest

ztest_SOURCES = \
$(top_srcdir)/cmd/ztest/ztest.c
ztest.c

ztest_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
Expand Down
2 changes: 1 addition & 1 deletion cmd/zvol_id/Makefile.am
Expand Up @@ -11,4 +11,4 @@ DEFAULT_INCLUDES += \
udev_PROGRAMS = zvol_id

zvol_id_SOURCES = \
$(top_srcdir)/cmd/zvol_id/zvol_id_main.c
zvol_id_main.c
2 changes: 2 additions & 0 deletions config/kernel.m4
Expand Up @@ -338,6 +338,8 @@ AC_DEFUN([ZFS_AC_SPL], [
splbuild="${splsrc}/${LINUX_VERSION}"
], [ test -e "${splsrc}/spl_config.h" ], [
splbuild="${splsrc}"
], [ find -L "${splsrc}" -name spl_config.h 2> /dev/null | grep -wq spl_config.h ], [
splbuild=$(find -L "${splsrc}" -name spl_config.h | sed 's,/spl_config.h,,')
], [
splbuild="[Not found]"
])
Expand Down
2 changes: 1 addition & 1 deletion config/rpm.am
Expand Up @@ -51,7 +51,7 @@ rpm-local:
mkdir -p $(rpmbuild)/SPECS && \
cp ${RPM_SPEC_DIR}/$(rpmspec) $(rpmbuild)/SPECS && \
mkdir -p $(rpmbuild)/SOURCES && \
cp scripts/kmodtool $(rpmbuild)/SOURCES && \
cp $(top_srcdir)/scripts/kmodtool $(rpmbuild)/SOURCES && \
cp $(distdir).tar.gz $(rpmbuild)/SOURCES)

srpm-common: dist
Expand Down
12 changes: 6 additions & 6 deletions contrib/dracut/90zfs/Makefile.am
@@ -1,10 +1,10 @@
pkgdracutdir = $(dracutdir)/modules.d/90zfs
pkgdracut_SCRIPTS = \
$(top_srcdir)/contrib/dracut/90zfs/export-zfs.sh \
$(top_srcdir)/contrib/dracut/90zfs/module-setup.sh \
$(top_srcdir)/contrib/dracut/90zfs/mount-zfs.sh \
$(top_srcdir)/contrib/dracut/90zfs/parse-zfs.sh \
$(top_srcdir)/contrib/dracut/90zfs/zfs-lib.sh
export-zfs.sh \
module-setup.sh \
mount-zfs.sh \
parse-zfs.sh \
zfs-lib.sh

EXTRA_DIST = \
$(top_srcdir)/contrib/dracut/90zfs/export-zfs.sh.in \
Expand All @@ -19,7 +19,7 @@ $(pkgdracut_SCRIPTS):
-e 's,@udevdir\@,$(udevdir),g' \
-e 's,@udevruledir\@,$(udevruledir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
'$@.in' >'$@'
"$(top_srcdir)/contrib/dracut/90zfs/$@.in" >'$@'

distclean-local::
-$(RM) $(pkgdracut_SCRIPTS)
2 changes: 1 addition & 1 deletion etc/init.d/Makefile.am
Expand Up @@ -36,7 +36,7 @@ $(init_SCRIPTS) $(initconf_SCRIPTS) $(initcommon_SCRIPTS): $(EXTRA_DIST)
-e 's,@runstatedir\@,$(runstatedir),g' \
-e "s,@SHELL\@,$$SHELL,g" \
-e "s,@NFS_SRV\@,$$NFS_SRV,g" \
'$@.in' >'$@'; \
"$(top_srcdir)/etc/init.d/$@.in" >'$@'; \
[ '$@' = 'zfs-functions' -o '$@' = 'zfs' ] || \
chmod +x '$@')

Expand Down
4 changes: 2 additions & 2 deletions etc/modules-load.d/Makefile.am
@@ -1,13 +1,13 @@
modulesload_DATA = \
$(top_srcdir)/etc/modules-load.d/zfs.conf
zfs.conf

EXTRA_DIST = \
$(top_srcdir)/etc/modules-load.d/zfs.conf.in

$(modulesload_DATA):
-$(SED) \
-e '' \
'$@.in' >'$@'
"$(top_srcdir)/etc/modules-load.d/$@.in" >'$@'

distclean-local::
-$(RM) $(modulesload_DATA)
19 changes: 10 additions & 9 deletions etc/systemd/system/Makefile.am
@@ -1,12 +1,13 @@
systemdpreset_DATA = \
$(top_srcdir)/etc/systemd/system/50-zfs.preset
50-zfs.preset

systemdunit_DATA = \
$(top_srcdir)/etc/systemd/system/zed.service \
$(top_srcdir)/etc/systemd/system/zfs-import-cache.service \
$(top_srcdir)/etc/systemd/system/zfs-import-scan.service \
$(top_srcdir)/etc/systemd/system/zfs-mount.service \
$(top_srcdir)/etc/systemd/system/zfs-share.service \
$(top_srcdir)/etc/systemd/system/zfs.target
zed.service \
zfs-import-cache.service \
zfs-import-scan.service \
zfs-mount.service \
zfs-share.service \
zfs.target

EXTRA_DIST = \
$(top_srcdir)/etc/systemd/system/zed.service.in \
Expand All @@ -22,14 +23,14 @@ $(systemdunit_DATA):
-e 's,@runstatedir\@,$(runstatedir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
'$@.in' >'$@'
"$(top_srcdir)/etc/systemd/system/$@.in" >'$@'

$(systemdpreset_DATA):
-$(SED) -e 's,@bindir\@,$(bindir),g' \
-e 's,@runstatedir\@,$(runstatedir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
'$@.in' >'$@'
"$(top_srcdir)/etc/systemd/system/$@.in" >'$@'

distclean-local::
-$(RM) $(systemdunit_DATA) $(systemdpreset_DATA)
14 changes: 12 additions & 2 deletions lib/libavl/Makefile.am
@@ -1,5 +1,7 @@
include $(top_srcdir)/config/Rules.am

VPATH = $(top_srcdir)/module/avl/

AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)

DEFAULT_INCLUDES += \
Expand All @@ -8,5 +10,13 @@ DEFAULT_INCLUDES += \

noinst_LTLIBRARIES = libavl.la

libavl_la_SOURCES = \
$(top_srcdir)/module/avl/avl.c
USER_C =

KERNEL_C = \
avl.c

nodist_libavl_la_SOURCES = \
$(USER_C) \
$(KERNEL_C)

EXTRA_DIST = $(USER_C)
12 changes: 10 additions & 2 deletions lib/libefi/Makefile.am
Expand Up @@ -8,7 +8,15 @@ DEFAULT_INCLUDES += \

noinst_LTLIBRARIES = libefi.la

libefi_la_SOURCES = \
$(top_srcdir)/lib/libefi/rdwr_efi.c
USER_C = \
rdwr_efi.c

KERNEL_C =

nodist_libefi_la_SOURCES = \
$(USER_C) \
$(KERNEL_C)

libefi_la_LIBADD = $(LIBUUID) $(ZLIB)

EXTRA_DIST = $(USER_C)

0 comments on commit 47a4a6f

Please sign in to comment.