xref: /freebsd/sys/contrib/openzfs/scripts/dkms.mkconf (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1#!/bin/sh
2
3PROG=$0
4
5pkgcfg=/etc/sysconfig/zfs
6
7while getopts "n:v:c:f:" opt; do
8	case $opt in
9		n) pkgname=$OPTARG  ;;
10		v) pkgver=$OPTARG   ;;
11		c) pkgcfg=$OPTARG   ;;
12		f) filename=$OPTARG ;;
13    *) err=1            ;;
14	esac
15done
16
17if [ -z "${pkgname}" ] || [ -z "${pkgver}" ] || [ -z "${filename}" ] ||
18    [ -n "${err}" ]; then
19	echo "Usage: $PROG -n <pkgname> -v <pkgver> -c <pkgcfg> -f <filename>"
20	exit 1
21fi
22
23exec cat >"${filename}" <<EOF
24PACKAGE_NAME="${pkgname}"
25PACKAGE_VERSION="${pkgver}"
26PACKAGE_CONFIG="${pkgcfg}"
27NO_WEAK_MODULES="yes"
28PRE_BUILD="configure
29  --prefix=/usr
30  --with-config=kernel
31  --with-linux=\$(
32    if [ -e "\${kernel_source_dir/%build/source}" ]
33    then
34      echo "\${kernel_source_dir/%build/source}"
35    else
36      echo "\${kernel_source_dir}"
37    fi
38  )
39  --with-linux-obj="\${kernel_source_dir}"
40  \$(
41    [[ -n \"\${ICP_ROOT}\" ]] && \\
42    {
43      echo --with-qat=\"\${ICP_ROOT}\"
44    }
45  )
46  \$(
47    [[ -r \${PACKAGE_CONFIG} ]] \\
48    && source \${PACKAGE_CONFIG} \\
49    && shopt -q -s extglob \\
50    && \\
51    {
52      if [[ \${ZFS_DKMS_ENABLE_DEBUG,,} == @(y|yes) ]]
53      then
54        echo --enable-debug
55      fi
56      if [[ \${ZFS_DKMS_ENABLE_DEBUGINFO,,} == @(y|yes) ]]
57      then
58        echo --enable-debuginfo
59      fi
60    }
61  )
62"
63POST_BUILD="scripts/dkms.postbuild
64  -n \${PACKAGE_NAME}
65  -v \${PACKAGE_VERSION}
66  -a \${arch}
67  -k \${kernelver}
68  -t \${dkms_tree}
69"
70AUTOINSTALL="yes"
71MAKE[0]="make"
72STRIP[0]="\$(
73  [[ -r \${PACKAGE_CONFIG} ]] \\
74  && source \${PACKAGE_CONFIG} \\
75  && shopt -q -s extglob \\
76  && [[ \${ZFS_DKMS_DISABLE_STRIP,,} == @(y|yes) ]] \\
77  && echo -n no
78)"
79STRIP[1]="\${STRIP[0]}"
80BUILT_MODULE_NAME[0]="zfs"
81BUILT_MODULE_LOCATION[0]="module/"
82DEST_MODULE_LOCATION[0]="/extra"
83BUILT_MODULE_NAME[1]="spl"
84BUILT_MODULE_LOCATION[1]="module/"
85DEST_MODULE_LOCATION[1]="/extra"
86EOF
87