libxfs: separate out userspace only files
To make checking that libxfs is identical between the kernel and
userspace code bases, lift all the userspace-only libxfs files into
a "support" subdirectory and build them there. Also, move all the
"kernel equivalent" XFS header files (e.g. include/xfs_mount.h) into
the support directory as well. This provides a clean separation of
libxfs from both kernel-specific and userspace-specific code bases,
and allows us to easily identify dependencies that must be fulfilled
for the libxfs code to work in userspace.
To make this work effectively, we have to enable sub-directory build
awareness in automake and slightly tweak the build rules to enable
libxfs/support to be built using the libxfs/Makefile.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
diff --git a/configure.ac b/configure.ac
index ae17c68..3977ec7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,5 @@
AC_INIT([xfsprogs], [3.2.0-alpha2])
+AM_INIT_AUTOMAKE([subdir-objects])
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_MACRO_DIR([m4])
diff --git a/include/Makefile b/include/Makefile
index 70e43a0..937502e 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -21,14 +21,8 @@
QAHFILES = libxfs.h libxlog.h \
atomic.h bitops.h cache.h kmem.h list.h hlist.h parent.h radix-tree.h \
swab.h \
- xfs_arch.h \
- xfs_btree_trace.h \
- xfs_inode.h \
xfs_log_recover.h \
- xfs_metadump.h \
- xfs_mount.h \
- xfs_trace.h \
- xfs_trans.h
+ xfs_metadump.h
HFILES = handle.h jdm.h xqm.h xfs.h
HFILES += $(PKG_PLATFORM).h
diff --git a/include/buildrules b/include/buildrules
index dbd9e10..6fe0930 100644
--- a/include/buildrules
+++ b/include/buildrules
@@ -40,11 +40,11 @@
%.lo: %.c
@echo " [CC] $@"
- $(Q)$(LTCOMPILE) -c $<
+ $(Q)$(LTCOMPILE) -c $< -o $@
else
%.o: %.c
@echo " [CC] $@"
- $(Q)$(CC) $(CFLAGS) -c $<
+ $(Q)$(CC) $(CFLAGS) -c $< -o $@
endif
diff --git a/libxfs/Makefile b/libxfs/Makefile
index 51b98ec..95c33fc 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -15,14 +15,25 @@
xfs_types.h
# headers with build dependencies
-HFILES = xfs.h \
+SHFILES = xfs.h \
init.h \
crc32defs.h \
- crc32table.h \
- xfs_dir2_priv.h \
+ crc32table.h
+
+HFILES = $(addprefix support/, $(SHFILES)) \
+ xfs_dir2_priv.h
# headers installed in QA targets
-QAHFILES = xfs_alloc.h \
+SQAHFILES = libxfs_io.h \
+ xfs_arch.h \
+ xfs_btree_trace.h \
+ xfs_inode.h \
+ xfs_mount.h \
+ xfs_trace.h \
+ xfs_trans.h
+
+QAHFILES = $(addprefix support/, $(SQAHFILES)) \
+ xfs_alloc.h \
xfs_alloc_btree.h \
xfs_attr_leaf.h \
xfs_attr_sf.h \
@@ -46,11 +57,19 @@
xfs_shared.h \
xfs_trans_resv.h \
xfs_trans_space.h \
- libxfs_io.h
-CFILES = cache.c \
+# supporting C files
+SCFILES = cache.c \
crc32.c \
- init.c kmem.c logitem.c radix-tree.c rdwr.c trans.c util.c \
+ init.c \
+ kmem.c \
+ logitem.c \
+ radix-tree.c \
+ rdwr.c \
+ trans.c \
+ util.c
+
+CFILES = $(addprefix support/, $(SCFILES)) \
xfs_alloc.c \
xfs_alloc_btree.c \
xfs_attr.c \
@@ -78,10 +97,12 @@
xfs_symlink_remote.c \
xfs_trans_resv.c
-CFILES += $(PKG_PLATFORM).c
-PCFILES = darwin.c freebsd.c irix.c linux.c
-LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
-LSRCFILES += gen_crc32table.c
+CFILES += $(addprefix support/, $(PKG_PLATFORM).c)
+
+SPCFILES = darwin.c freebsd.c irix.c linux.c
+SLSRCFILES = $(shell echo $(SPCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
+SLSRCFILES += gen_crc32table.c
+LSRCFILES = $(addprefix support/, $(SLSRCFILES))
#
# Tracing flags:
@@ -92,39 +113,39 @@
#
#LCFLAGS +=
-FCFLAGS = -I.
+FCFLAGS = -I. -Isupport
LTLIBS = $(LIBPTHREAD) $(LIBRT)
# don't try linking xfs_repair with a debug libxfs.
DEBUG = -DNDEBUG
-LDIRT = gen_crc32table crc32table.h crc32selftest
+LDIRT = $(addprefix support/, gen_crc32table crc32table.h crc32selftest)
-default: xfs crc32selftest ltdepend $(LTLIBRARY)
+default: xfs support/crc32selftest ltdepend $(LTLIBRARY)
-crc32table.h: gen_crc32table.c
- @echo " [CC] gen_crc32table"
- $(Q) $(CC) $(CFLAGS) -o gen_crc32table $<
+# set up include/xfs header directory
+xfs: $(addsuffix -hdrs, $(PKGHFILES) $(QAHFILES))
+
+%-hdrs:
+ $(Q)$(LN_S) -f $(PWD)/libxfs/$* $(TOPDIR)/include/xfs/$(notdir $*)
+
+support/crc32table.h: support/gen_crc32table.c
+ @echo " [CC] support/gen_crc32table"
+ $(Q) $(CC) $(CFLAGS) -o support/gen_crc32table $<
@echo " [GENERATE] $@"
- $(Q) ./gen_crc32table > crc32table.h
+ $(Q) support/gen_crc32table > support/crc32table.h
# The selftest binary will return an error if it fails. This is made a
# dependency of the build process so that we refuse to build the tools on broken
# systems/architectures. Hence we make sure that xfsprogs will never use a
# busted CRC calculation at build time and hence avoid putting bad CRCs down on
# disk.
-crc32selftest: gen_crc32table.c crc32table.h crc32.c
+support/crc32selftest: $(addprefix support/, gen_crc32table.c crc32table.h crc32.c)
@echo " [TEST] CRC32"
- $(Q) $(CC) $(CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@
+ $(Q) $(CC) $(CFLAGS) -D CRC32_SELFTEST=1 support/crc32.c -o $@
$(Q) ./$@
-# set up include/xfs header directory
-xfs: $(addsuffix -hdrs, $(PKGHFILES) $(QAHFILES))
-
-%-hdrs:
- $(Q)$(LN_S) -f $(PWD)/libxfs/$* $(TOPDIR)/include/xfs/$*
-
include $(BUILDRULES)
install: default
diff --git a/libxfs/cache.c b/libxfs/support/cache.c
similarity index 100%
rename from libxfs/cache.c
rename to libxfs/support/cache.c
diff --git a/libxfs/crc32.c b/libxfs/support/crc32.c
similarity index 100%
rename from libxfs/crc32.c
rename to libxfs/support/crc32.c
diff --git a/libxfs/crc32defs.h b/libxfs/support/crc32defs.h
similarity index 100%
rename from libxfs/crc32defs.h
rename to libxfs/support/crc32defs.h
diff --git a/libxfs/darwin.c b/libxfs/support/darwin.c
similarity index 100%
rename from libxfs/darwin.c
rename to libxfs/support/darwin.c
diff --git a/libxfs/freebsd.c b/libxfs/support/freebsd.c
similarity index 100%
rename from libxfs/freebsd.c
rename to libxfs/support/freebsd.c
diff --git a/libxfs/gen_crc32table.c b/libxfs/support/gen_crc32table.c
similarity index 100%
rename from libxfs/gen_crc32table.c
rename to libxfs/support/gen_crc32table.c
diff --git a/libxfs/init.c b/libxfs/support/init.c
similarity index 100%
rename from libxfs/init.c
rename to libxfs/support/init.c
diff --git a/libxfs/init.h b/libxfs/support/init.h
similarity index 100%
rename from libxfs/init.h
rename to libxfs/support/init.h
diff --git a/libxfs/irix.c b/libxfs/support/irix.c
similarity index 100%
rename from libxfs/irix.c
rename to libxfs/support/irix.c
diff --git a/libxfs/kmem.c b/libxfs/support/kmem.c
similarity index 100%
rename from libxfs/kmem.c
rename to libxfs/support/kmem.c
diff --git a/libxfs/libxfs_io.h b/libxfs/support/libxfs_io.h
similarity index 100%
rename from libxfs/libxfs_io.h
rename to libxfs/support/libxfs_io.h
diff --git a/libxfs/linux.c b/libxfs/support/linux.c
similarity index 100%
rename from libxfs/linux.c
rename to libxfs/support/linux.c
diff --git a/libxfs/logitem.c b/libxfs/support/logitem.c
similarity index 100%
rename from libxfs/logitem.c
rename to libxfs/support/logitem.c
diff --git a/libxfs/radix-tree.c b/libxfs/support/radix-tree.c
similarity index 100%
rename from libxfs/radix-tree.c
rename to libxfs/support/radix-tree.c
diff --git a/libxfs/rdwr.c b/libxfs/support/rdwr.c
similarity index 100%
rename from libxfs/rdwr.c
rename to libxfs/support/rdwr.c
diff --git a/libxfs/trans.c b/libxfs/support/trans.c
similarity index 100%
rename from libxfs/trans.c
rename to libxfs/support/trans.c
diff --git a/libxfs/util.c b/libxfs/support/util.c
similarity index 100%
rename from libxfs/util.c
rename to libxfs/support/util.c
diff --git a/libxfs/xfs.h b/libxfs/support/xfs.h
similarity index 100%
rename from libxfs/xfs.h
rename to libxfs/support/xfs.h
diff --git a/include/xfs_arch.h b/libxfs/support/xfs_arch.h
similarity index 100%
rename from include/xfs_arch.h
rename to libxfs/support/xfs_arch.h
diff --git a/include/xfs_btree_trace.h b/libxfs/support/xfs_btree_trace.h
similarity index 100%
rename from include/xfs_btree_trace.h
rename to libxfs/support/xfs_btree_trace.h
diff --git a/include/xfs_inode.h b/libxfs/support/xfs_inode.h
similarity index 100%
rename from include/xfs_inode.h
rename to libxfs/support/xfs_inode.h
diff --git a/include/xfs_mount.h b/libxfs/support/xfs_mount.h
similarity index 100%
rename from include/xfs_mount.h
rename to libxfs/support/xfs_mount.h
diff --git a/include/xfs_trace.h b/libxfs/support/xfs_trace.h
similarity index 100%
rename from include/xfs_trace.h
rename to libxfs/support/xfs_trace.h
diff --git a/include/xfs_trans.h b/libxfs/support/xfs_trans.h
similarity index 100%
rename from include/xfs_trans.h
rename to libxfs/support/xfs_trans.h