Whamcloud - gitweb
LU-15644 llog: don't replace llog error with -ENOTDIR
[fs/lustre-release.git] / lustre-dkms_pre-build.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # This file is part of Lustre, http://www.lustre.org/
6 #
7 # lustre-dkms_pre-build.sh
8 #
9 # Script run before dkms build
10 #
11
12 #
13 # $1 : $module
14 # $2 : $module_version
15 # $3 : $kernelver
16 # $4 : $kernel_source_dir
17 # $5 : $arch
18 # $6 : $source_tree
19 # $7 : $dkms_tree
20 # $8 : $kmoddir [lustre-client either 'extra|updates']
21
22 case $1 in
23     lustre-client)
24         SERVER="--disable-server --enable-client"
25         ksrc="$(dirname $4)/source"
26         KERNEL_STUFF="--with-linux=$(realpath $ksrc) --with-linux-obj=$(realpath $4)"
27         name=$1
28         kmoddir=$8
29         flavor=$(echo $3 | tr '-' '\n' | tail -1)
30         if [ -f /usr/src/kfabric/${flavor}/Module.symvers ]; then
31                 KERNEL_STUFF="${KERNEL_STUFF} --with-kfi=/usr/src/kfabric/${flavor}"
32         elif [ -f /usr/src/kfabric/default/Module.symvers ]; then
33                 KERNEL_STUFF="${KERNEL_STUFF} --with-kfi=/usr/src/kfabric/default"
34         fi
35         O2IBPATH=""
36         if [ -d /usr/src/ofa_kernel/${flavor} ]; then
37                 O2IBPATH=/usr/src/ofa_kernel/${flavor}
38         elif [ -d /usr/src/ofa_kernel/default ]; then
39                 O2IBPATH=/usr/src/ofa_kernel/default
40         fi
41         if [ -n ${O2IBPATH} ]; then
42                 KERNEL_STUFF="${KERNEL_STUFF} --with-o2ib=${O2IBPATH}"
43         fi
44         if [ -n ${kmoddir} ]; then
45                 KERNEL_STUFF="${KERNEL_STUFF} --with-kmp-moddir=${kmoddir}/${name}"
46         fi
47         sh ./autogen.sh
48         ;;
49
50     lustre-zfs|lustre-all)
51         LDISKFS=""
52         if [ "$1" == "lustre-zfs" ]; then
53             LDISKFS="--disable-ldiskfs"
54         fi
55
56         # ZFS and SPL are version locked
57         ZFS_VERSION=$(dkms status -m zfs -k $3 -a $5 2>/dev/null |
58                       sed -e 's:zfs/::g' -e 's:,.*::g' | cut -d: -f1 |
59                       sort -V | head -n1)
60         if [ -z $ZFS_VERSION ] ; then
61                 echo "zfs-dkms package must already be installed and built under DKMS control"
62                 exit 1
63         fi
64
65         SERVER="--enable-server $LDISKFS \
66                 --with-linux=$4 --with-linux-obj=$4 \
67                 --with-spl=$(realpath $7/spl/${ZFS_VERSION}/source) \
68                 --with-spl-obj=$(realpath $7/spl/kernel-$3-$5) \
69                 --with-zfs=$(realpath $7/zfs/${ZFS_VERSION}/source) \
70                 --with-zfs-obj=$(realpath $7/zfs/kernel-$3-$5)"
71
72         KERNEL_STUFF="--with-linux=$4 --with-linux-obj=$4"
73         ;;
74
75     lustre-ldiskfs)
76         SERVER="--enable-server --without-zfs --without-spl \
77                 --with-linux=$4 --with-linux-obj=$4"
78
79         KERNEL_STUFF="--with-linux=$4 --with-linux-obj=$4"
80         ;;
81 esac
82
83 PACKAGE_CONFIG="/etc/sysconfig/lustre"
84 DKMS_CONFIG_OPTS=$(
85     [[ -r ${PACKAGE_CONFIG} ]] \
86     && source ${PACKAGE_CONFIG} \
87     && shopt -q -s extglob \
88     && \
89     {
90         if [[ -n ${LUSTRE_DKMS_DISABLE_CDEBUG} ]] ; then
91                 [[ ${LUSTRE_DKMS_DISABLE_CDEBUG,,} == @(y|yes) ]] &&
92                         echo --disable-libcfs-cdebug ||
93                         echo --enable-libcfs-cdebug
94         fi
95         if [[ -n ${LUSTRE_DKMS_DISABLE_TRACE} ]] ; then
96                 [[ ${LUSTRE_DKMS_DISABLE_TRACE,,} == @(y|yes) ]] &&
97                         echo --disable-libcfs-trace ||
98                         echo --enable-libcfs-trace
99         fi
100         if [[ -n ${LUSTRE_DKMS_DISABLE_ASSERT} ]] ; then
101                 [[ ${LUSTRE_DKMS_DISABLE_ASSERT,,} == @(y|yes) ]] &&
102                         echo --disable-libcfs-assert ||
103                         echo --enable-libcfs-assert
104         fi
105         if [[ -n ${LUSTRE_DKMS_ENABLE_GSS} ]] ; then
106                 [[ ${LUSTRE_DKMS_ENABLE_GSS,,} == @(y|yes) ]] &&
107                         echo --enable-gss ||
108                         echo --disable-gss
109         fi
110         if [[ -n ${LUSTRE_DKMS_ENABLE_GSS_KEYRING} ]] ; then
111                 [[ ${LUSTRE_DKMS_ENABLE_GSS_KEYRING,,} == @(y|yes) ]] &&
112                         echo --enable-gss-keyring ||
113                         echo --disable-gss-keyring
114         fi
115         if [[ -n ${LUSTRE_DKMS_ENABLE_CRYPTO} ]] ; then
116                 [[ ${LUSTRE_DKMS_ENABLE_CRYPTO,,} == @(y|yes) ]] &&
117                         echo --enable-crypto ||
118                         echo --disable-crypto
119         fi
120         if [[ -n ${LUSTRE_DKMS_ENABLE_IOKIT} ]] ; then
121                 [[ ${LUSTRE_DKMS_ENABLE_IOKIT,,} == @(y|yes) ]] &&
122                         echo --enable-iokit ||
123                         echo --disable-iokit
124         fi
125         [[ -n ${LUSTRE_DKMS_CONFIGURE_EXTRA} ]] &&
126                 echo ${LUSTRE_DKMS_CONFIGURE_EXTRA}
127     }
128 )
129
130 echo "${DKMS_CONFIG_OPTS} " | grep -E -q -- '--disable-gss[^-]|--enable-gss[^-]'
131 if [ $? != 0 ] ; then
132         # User did not force, guess for rpm distros
133         rpm -qa | grep krb5-devel >/dev/null
134         [[ $? == 0 ]] && GSS="--enable-gss" || GSS="--disable-gss"
135 fi
136
137 # run a configure pass to clean "--enable-dist" only effect and also to
138 # ensure local/on-target environment to be taken into account for
139 # dkms.mkconf script customizations and before next build/MAKE step
140 ./configure --prefix=/usr --enable-modules --disable-iokit \
141         --disable-doc --disable-utils --disable-tests --disable-maintainer-mode \
142         $KERNEL_STUFF $GSS $SERVER $DKMS_CONFIG_OPTS \
143         --disable-manpages --disable-mpitests
144
145 if [ $? != 0 ] ; then
146         echo "configure error, check $7/$1/$2/build/config.log"
147         exit 1
148 fi