xref: /freebsd/sys/contrib/openzfs/scripts/dkms.mkconf (revision 5b56413d04e608379c9a306373554a8e4d321bc0)
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  --disable-dependency-tracking
30  --prefix=/usr
31  --with-config=kernel
32  --with-linux=\$(
33    if [ -e "\${kernel_source_dir/%build/source}" ]
34    then
35      echo "\${kernel_source_dir/%build/source}"
36    else
37      echo "\${kernel_source_dir}"
38    fi
39  )
40  --with-linux-obj="\${kernel_source_dir}"
41  \$(
42    [[ -n \"\${ICP_ROOT}\" ]] && \\
43    {
44      echo --with-qat=\"\${ICP_ROOT}\"
45    }
46  )
47  \$(
48    [[ -r \${PACKAGE_CONFIG} ]] \\
49    && source \${PACKAGE_CONFIG} \\
50    && shopt -q -s extglob \\
51    && \\
52    {
53      if [[ \${ZFS_DKMS_ENABLE_DEBUG,,} == @(y|yes) ]]
54      then
55        echo --enable-debug
56      fi
57      if [[ \${ZFS_DKMS_ENABLE_DEBUGINFO,,} == @(y|yes) ]]
58      then
59        echo --enable-debuginfo
60      fi
61    }
62  )
63"
64POST_BUILD="scripts/dkms.postbuild
65  -n \${PACKAGE_NAME}
66  -v \${PACKAGE_VERSION}
67  -a \${arch}
68  -k \${kernelver}
69  -t \${dkms_tree}
70"
71AUTOINSTALL="yes"
72MAKE[0]="make"
73STRIP[0]="\$(
74  [[ -r \${PACKAGE_CONFIG} ]] \\
75  && source \${PACKAGE_CONFIG} \\
76  && shopt -q -s extglob \\
77  && [[ \${ZFS_DKMS_DISABLE_STRIP,,} == @(y|yes) ]] \\
78  && echo -n no
79)"
80STRIP[1]="\${STRIP[0]}"
81BUILT_MODULE_NAME[0]="zfs"
82BUILT_MODULE_LOCATION[0]="module/"
83DEST_MODULE_LOCATION[0]="/extra"
84BUILT_MODULE_NAME[1]="spl"
85BUILT_MODULE_LOCATION[1]="module/"
86DEST_MODULE_LOCATION[1]="/extra"
87EOF
88