diff options
author | Brian Behlendorf <[email protected]> | 2010-08-26 11:22:58 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2010-08-31 13:41:27 -0700 |
commit | c9c0d073da561bcbefbdf09c87fc75b227415619 (patch) | |
tree | 7daee55ae61526107f421de48171573fa5a15d28 /cmd | |
parent | 40b84e7aec6392187722e61e5a4a853b530bf60f (diff) |
Add build system
Add autoconf style build infrastructure to the ZFS tree. This
includes autogen.sh, configure.ac, m4 macros, some scripts/*,
and makefiles for all the core ZFS components.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/Makefile.am | 1 | ||||
-rw-r--r-- | cmd/zdb/Makefile.am | 31 | ||||
-rw-r--r-- | cmd/zfs/Makefile.am | 32 | ||||
-rw-r--r-- | cmd/zinject/Makefile.am | 34 | ||||
-rw-r--r-- | cmd/zpool/Makefile.am | 34 | ||||
-rw-r--r-- | cmd/zpool_id/Makefile.am | 1 | ||||
-rwxr-xr-x | cmd/zpool_id/zpool_id | 60 | ||||
-rw-r--r-- | cmd/zpool_layout/Makefile.am | 1 | ||||
-rwxr-xr-x | cmd/zpool_layout/zpool_layout | 127 | ||||
-rw-r--r-- | cmd/ztest/Makefile.am | 34 |
10 files changed, 355 insertions, 0 deletions
diff --git a/cmd/Makefile.am b/cmd/Makefile.am new file mode 100644 index 000000000..954f8565c --- /dev/null +++ b/cmd/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = zfs zpool zpool_id zpool_layout zdb zinject ztest diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am new file mode 100644 index 000000000..6f0b0cb87 --- /dev/null +++ b/cmd/zdb/Makefile.am @@ -0,0 +1,31 @@ +include $(top_srcdir)/config/Rules.am + +DEFAULT_INCLUDES += \ + -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ + -I${top_srcdir}/lib/libzpool/include \ + -I${top_srcdir}/lib/libnvpair/include \ + -I${top_srcdir}/lib/libzfs/include \ + -I${top_srcdir}/module/zfs/include \ + -I${top_srcdir}/module/zcommon/include \ + -I${top_srcdir}/module/nvpair/include \ + -I${top_srcdir}/module/avl/include \ + -I${top_srcdir}/module/unicode/include + +sbin_PROGRAMS = zdb + +zdb_SOURCES = \ + ${top_srcdir}/cmd/zdb/zdb.c \ + ${top_srcdir}/cmd/zdb/zdb_il.c + +zdb_LDADD = \ + $(top_builddir)/lib/libspl/libspl.la \ + $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ + $(top_builddir)/lib/libnvpair/libnvpair.la \ + $(top_builddir)/lib/libunicode/libunicode.la \ + $(top_builddir)/lib/libuutil/libuutil.la \ + $(top_builddir)/lib/libzpool/libzpool.la \ + $(top_builddir)/lib/libzfs/libzfs.la + +zdb_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID) diff --git a/cmd/zfs/Makefile.am b/cmd/zfs/Makefile.am new file mode 100644 index 000000000..4d66e37a2 --- /dev/null +++ b/cmd/zfs/Makefile.am @@ -0,0 +1,32 @@ +include $(top_srcdir)/config/Rules.am + +DEFAULT_INCLUDES += \ + -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ + -I${top_srcdir}/lib/libuutil/include \ + -I${top_srcdir}/lib/libzfs/include \ + -I${top_srcdir}/lib/libnvpair/include \ + -I${top_srcdir}/module/zcommon/include \ + -I${top_srcdir}/module/nvpair/include \ + -I${top_srcdir}/module/avl/include \ + -I${top_srcdir}/module/unicode/include + +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_LDADD = \ + $(top_builddir)/lib/libspl/libspl.la \ + $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ + $(top_builddir)/lib/libnvpair/libnvpair.la \ + $(top_builddir)/lib/libunicode/libunicode.la \ + $(top_builddir)/lib/libuutil/libuutil.la \ + $(top_builddir)/lib/libzpool/libzpool.la \ + $(top_builddir)/lib/libzfs/libzfs.la + +zfs_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID) diff --git a/cmd/zinject/Makefile.am b/cmd/zinject/Makefile.am new file mode 100644 index 000000000..7166ed9b4 --- /dev/null +++ b/cmd/zinject/Makefile.am @@ -0,0 +1,34 @@ +include $(top_srcdir)/config/Rules.am + +DEFAULT_INCLUDES += \ + -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ + -I${top_srcdir}/lib/libzpool/include \ + -I${top_srcdir}/lib/libuutil/include \ + -I${top_srcdir}/lib/libzfs/include \ + -I${top_srcdir}/lib/libnvpair/include \ + -I${top_srcdir}/module/zfs \ + -I${top_srcdir}/module/zfs/include \ + -I${top_srcdir}/module/zcommon/include \ + -I${top_srcdir}/module/nvpair/include \ + -I${top_srcdir}/module/avl/include \ + -I${top_srcdir}/module/unicode/include + +sbin_PROGRAMS = zinject + +zinject_SOURCES = \ + ${top_srcdir}/cmd/zinject/translate.c \ + ${top_srcdir}/cmd/zinject/zinject.c \ + ${top_srcdir}/cmd/zinject/zinject.h + +zinject_LDADD = \ + $(top_builddir)/lib/libspl/libspl.la \ + $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ + $(top_builddir)/lib/libnvpair/libnvpair.la \ + $(top_builddir)/lib/libunicode/libunicode.la \ + $(top_builddir)/lib/libuutil/libuutil.la \ + $(top_builddir)/lib/libzpool/libzpool.la \ + $(top_builddir)/lib/libzfs/libzfs.la + +zinject_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID) diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am new file mode 100644 index 000000000..ec9757bd6 --- /dev/null +++ b/cmd/zpool/Makefile.am @@ -0,0 +1,34 @@ +include $(top_srcdir)/config/Rules.am + +DEFAULT_INCLUDES += \ + -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ + -I${top_srcdir}/lib/libuutil/include \ + -I${top_srcdir}/lib/libzfs/include \ + -I${top_srcdir}/lib/libnvpair/include \ + -I${top_srcdir}/module/zcommon/include \ + -I${top_srcdir}/module/zfs/include \ + -I${top_srcdir}/module/nvpair/include \ + -I${top_srcdir}/module/avl/include \ + -I${top_srcdir}/module/unicode/include + +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_LDADD = \ + $(top_builddir)/lib/libspl/libspl.la \ + $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ + $(top_builddir)/lib/libnvpair/libnvpair.la \ + $(top_builddir)/lib/libunicode/libunicode.la \ + $(top_builddir)/lib/libuutil/libuutil.la \ + $(top_builddir)/lib/libzpool/libzpool.la \ + $(top_builddir)/lib/libzfs/libzfs.la + +zpool_LDFLAGS = -pthread -lm $(ZLIB) -lrt $(LIBUUID) $(LIBBLKID) diff --git a/cmd/zpool_id/Makefile.am b/cmd/zpool_id/Makefile.am new file mode 100644 index 000000000..023e1ab59 --- /dev/null +++ b/cmd/zpool_id/Makefile.am @@ -0,0 +1 @@ +dist_bin_SCRIPTS = zpool_id diff --git a/cmd/zpool_id/zpool_id b/cmd/zpool_id/zpool_id new file mode 100755 index 000000000..c3637847a --- /dev/null +++ b/cmd/zpool_id/zpool_id @@ -0,0 +1,60 @@ +#!/bin/bash + +CONFIG=${CONFIG:-/etc/zfs/zdev.conf} +PATH_ID=${PATH_ID:-/lib/udev/path_id} +AWK=${AWK:-/bin/awk} + +die() { + echo "Error: $*" + exit 1 +} + +usage() { + cat << EOF +Usage: zpool_id [h] [-c configfile] <devpath> + -c Alternate config file [default /etc/zfs/zdev.conf] + -d Use path_id from device as the mapping key + -h Show this message +EOF + exit 1 +} + +while getopts 'c:d:h' OPTION; do + case ${OPTION} in + c) + CONFIG=${OPTARG} + ;; + d) + DEVICE=${OPTARG} + ;; + h) + usage + ;; + esac +done + +# Check that a device was requested +[ -z ${DEVICE} ] && usage + +# Check for the existence of a configuration file +[ ! -f ${CONFIG} ] && die "Missing config file: ${CONFIG}" + +# Use udev's path_id to generate a unique persistent key +eval `${PATH_ID} ${DEVICE}` +[ -z ${ID_PATH} ] && die "Missing ID_PATH for ${DEVICE}" + +# Use the persistent key to lookup the zpool device id in the +# configuration file which is of the format <device id> <key>. +# Lines starting with #'s are treated as comments and ignored. +# Exact matches are required, wild cards are not supported, +# and only the first match is returned. +ID_ZPOOL=`${AWK} "/${ID_PATH}\>/ && !/^#/ { print \\$1; exit }" ${CONFIG}` +[ -z ${ID_ZPOOL} ] && die "Missing ID_ZPOOL for ID_PATH: ${ID_PATH}" + +if [ ${ID_ZPOOL} ]; then + echo "ID_PATH=${ID_PATH}" + echo "ID_ZPOOL=${ID_ZPOOL}" + echo "ID_ZPOOL_PATH=disk/zpool/${ID_ZPOOL}" +fi + +exit 0 diff --git a/cmd/zpool_layout/Makefile.am b/cmd/zpool_layout/Makefile.am new file mode 100644 index 000000000..b17e6a362 --- /dev/null +++ b/cmd/zpool_layout/Makefile.am @@ -0,0 +1 @@ +dist_bin_SCRIPTS = zpool_layout diff --git a/cmd/zpool_layout/zpool_layout b/cmd/zpool_layout/zpool_layout new file mode 100755 index 000000000..19cd12807 --- /dev/null +++ b/cmd/zpool_layout/zpool_layout @@ -0,0 +1,127 @@ +#!/bin/bash +# +# Set BUSES and PORTS to match the topology of your system. As each +# port is enumerated it will be assigned the next channel name. The +# current script enumerates each port on a bus before moving on to +# enumerate the next bus. +# +# Every distribution, version of udev, and type of attached storage +# seems to result in slightly different formatting of the by-path +# name. For this reason you may need to adjust the parsing below +# to suit your needs. This is one of the reasons to use a custom +# /etc/zfs/zdev.conf file, it allows the by-path naming convertion +# to change and still keep the simple <channel><rank> naming. +# +CONFIG=${CONFIG:-/etc/zfs/zdev.conf} +BUSES=( 01 02 03 ) +PORTS=( 4 0 ) +CHANNELS=( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ) +TRIGGER= + +usage() { + cat << EOF +Usage: zpool_layout [-th] [-c file] [-b buses] [-p ports] [-n channels] + -c Alternate config file [default=/etc/zfs/zdev.conf] + -b Enumerate buses [default="01 02 03"] + -p Enumerate ports [default="4 0"] + -n Channel names [default="A..Z"] + -t Trigger and wait for udev to settle [default=no] + -h Show this message +EOF + exit 0 +} + +while getopts 'c:b:p:n:th' OPTION; do + case ${OPTION} in + c) + CONFIG=${OPTARG} + ;; + b) + BUSES=(${OPTARG}) + ;; + p) + PORTS=(${OPTARG}) + ;; + n) + CHANNELS=(${OPTARG}) + ;; + t) + TRIGGER=1 + ;; + h) + usage + ;; + esac +done + +# Save stdout as fd #8, then redirect stdout to the config file. +exec 8>&1 +exec >${CONFIG} +pushd /dev/disk/by-path >/dev/null + +# Generate comment header. +echo "#" +echo "# Custom /dev/disk/by-path to /dev/disk/zpool mapping, " +echo "# based of the following physical cable layout." +echo "#" + +# Generate host port layout table for comment header. +echo "# ------------------ Host Port Layout ---------------------" +echo -n "# " +for (( i=0; i<${#BUSES[*]}; i++ )); do + printf "%-8d" ${BUSES[$i]} +done +echo + +for (( i=0, k=0; i<${#PORTS[*]}; i++ )); do + printf "# Port %-2d " ${PORTS[$i]} + + for (( j=0; j<${#BUSES[*]}; j++, k++ )); do + let k=$j*${#PORTS[*]}+$i + printf "%-8s" ${CHANNELS[$k]} + done + echo +done +echo "#" + +# Generate channel/disk layout table for comment header. +echo "# ----------------- Channel/Disk Layout -------------------" +echo "# Channel Disks" +for (( i=0, k=0; i<${#BUSES[*]}; i++ )); do + for (( j=0; j<${#PORTS[*]}; j++, k++ )); do + printf "# %-9s" ${CHANNELS[$k]} + ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \ + cut -f7 -d'-' | sort -u -n | tr '\n' ',' + echo + done +done +echo "#" + +# Generate mapping from <channel><rank> to by-path name. +TMP_FILE=`mktemp` +AWK=${AWK:-/bin/awk} + +for (( i=0, k=0; i<${#BUSES[*]}; i++ )); do + for (( j=0; j<${#PORTS[*]}; j++, k++ )); do + ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \ + grep -v part | sort -n -k7 -t'-'>${TMP_FILE} + + echo + echo -n "# Channel ${CHANNELS[$k]}, " + echo "Bus ${BUSES[$i]}, Port ${PORTS[$j]}" + ${AWK} -F '-' -v ch="${CHANNELS[$k]}" \ + '{print ch$7 "\t" $0 }' ${TMP_FILE} + done +done + +# Restore stdout from fd #8 and close fd #8. +exec 1>&8 8>&- +rm -f ${TMP_FILE} +popd >/dev/null + +if [ ${TRIGGER} ]; then + udevadm trigger + udevadm settle +fi + +exit 0 diff --git a/cmd/ztest/Makefile.am b/cmd/ztest/Makefile.am new file mode 100644 index 000000000..804efccca --- /dev/null +++ b/cmd/ztest/Makefile.am @@ -0,0 +1,34 @@ +include $(top_srcdir)/config/Rules.am + +AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) + +DEFAULT_INCLUDES += \ + -I${top_srcdir}/lib/libspl/include \ + -I${top_srcdir}/lib/libefi/include \ + -I${top_srcdir}/lib/libzpool/include \ + -I${top_srcdir}/lib/libuutil/include \ + -I${top_srcdir}/lib/libzfs/include \ + -I${top_srcdir}/lib/libnvpair/include \ + -I${top_srcdir}/module/zfs \ + -I${top_srcdir}/module/zfs/include \ + -I${top_srcdir}/module/zcommon/include \ + -I${top_srcdir}/module/nvpair/include \ + -I${top_srcdir}/module/avl/include \ + -I${top_srcdir}/module/unicode/include + +sbin_PROGRAMS = ztest + +ztest_SOURCES = \ + ${top_srcdir}/cmd/ztest/ztest.c + +ztest_LDADD = \ + $(top_builddir)/lib/libspl/libspl.la \ + $(top_builddir)/lib/libavl/libavl.la \ + $(top_builddir)/lib/libefi/libefi.la \ + $(top_builddir)/lib/libnvpair/libnvpair.la \ + $(top_builddir)/lib/libunicode/libunicode.la \ + $(top_builddir)/lib/libuutil/libuutil.la \ + $(top_builddir)/lib/libzpool/libzpool.la \ + $(top_builddir)/lib/libzfs/libzfs.la + +ztest_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID) |