3 # We don't support srcdir != builddir
4 echo \
#buildapi-variable-no-builddir > /dev/null
8 enable_documentation
=yes
12 PKG_CONFIG
="${PKG_CONFIG:-pkg-config}"
14 # Little helper function for reading args from the commandline.
15 # it automatically handles -a b and -a=b variants, and returns 1 if
16 # we need to shift $3.
21 local rematch
='^[^=]*=(.*)$'
22 if [[ $2 =~
$rematch ]]; then
23 read -r "$1" <<< "${BASH_REMATCH[1]}"
26 # There is no way to shift our callers args, so
27 # return 1 to indicate they should do it instead.
35 --prefix) read_arg prefix
"$@" ||
shift ;;
36 --libdir) read_arg libdir
"$@" ||
shift ;;
37 --datadir) read_arg datadir
"$@" ||
shift ;;
38 --sysconfdir) read_arg sysconfdir
"$@" ||
shift ;;
39 --sbindir) read_arg sbindir
"$@" ||
shift ;;
40 --mandir) read_arg mandir
"$@" ||
shift ;;
41 --disable-documentation) enable_documentation
=no
;;
42 --program-prefix) read_arg programprefix
"$@" ||
shift ;;
43 --exec-prefix) read_arg execprefix
"$@" ||
shift ;;
44 --bindir) read_arg bindir
"$@" ||
shift ;;
45 --includedir) read_arg includedir
"$@" ||
shift ;;
46 --libexecdir) read_arg libexecdir
"$@" ||
shift ;;
47 --localstatedir) read_arg localstatedir
"$@" ||
shift ;;
48 --sharedstatedir) read_arg sharedstatedir
"$@" ||
shift ;;
49 --infodir) read_arg infodir
"$@" ||
shift ;;
50 --systemdsystemunitdir) read_arg systemdsystemunitdir
"$@" ||
shift ;;
51 --bashcompletiondir) read_arg bashcompletiondir
"$@" ||
shift ;;
52 --enable-dracut-cpio) enable_dracut_cpio
=yes ;;
53 *) echo "Ignoring unknown option '$1'" ;;
58 if ! ${PKG_CONFIG} --exists --print-errors " libkmod >= 23 "; then
59 echo "dracut needs pkg-config and libkmod >= 23." >&2
63 if ! command -v "${CC}" > /dev
/null
; then
64 echo "dracut needs a C compiler (${CC} not found)." >&2
68 cat << EOF > conftest.c
75 # shellcheck disable=SC2086
76 ${CC} $CFLAGS $LDFLAGS conftest.c
> /dev
/null
2>&1
78 rm -f conftest.c a.out
80 # musl doesn't have fts.h included
81 if test $ret -ne 0; then
82 echo "dracut needs fts development files." >&2
86 cat << EOF > conftest.c
95 for lib
in "-lc" "-lfts"; do
96 # shellcheck disable=SC2086
97 ${CC} $CFLAGS $LDFLAGS conftest.c
-Wl,$lib > /dev
/null
2>&1
99 if test $ret -eq 0; then
105 rm -f conftest.c a.out
107 if test $found = no
; then
108 echo "dracut couldn't find usable fts library" >&2
112 cat << EOF > conftest.c
115 #include <sys/syscall.h>
118 #error "SYS_gettid unavailable on this system"
121 #define gettid() ((pid_t) syscall(SYS_gettid))
124 return getpid() == gettid() ? 0 : -1;
128 # shellcheck disable=SC2086
129 ${CC} $CFLAGS $LDFLAGS conftest.c
> /dev
/null
2>&1
131 rm -f conftest.c a.out
133 if test $ret -ne 0; then
134 echo "dracut needs SYS_gettid support." >&2
138 if test "$enable_dracut_cpio" = "yes"; then
139 cargo
--version > /dev
/null
141 if test $ret -ne 0; then
142 echo "dracut couldn't find cargo for dracut-cpio build"
147 cat > Makefile.inc.$$
<< EOF
149 libdir ?= ${libdir:-${prefix}/lib}
150 datadir ?= ${datadir:-${prefix}/share}
151 sysconfdir ?= ${sysconfdir:-${prefix}/etc}
152 sbindir ?= ${sbindir:-${prefix}/sbin}
153 mandir ?= ${mandir:-${prefix}/share/man}
154 enable_documentation ?= ${enable_documentation:-yes}
155 enable_dracut_cpio ?= ${enable_dracut_cpio}
156 bindir ?= ${bindir:-${prefix}/bin}
157 KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ")
158 KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ")
159 FTS_LIBS ?= ${FTS_LIBS}
163 [[ $programprefix ]] && echo "programprefix ?= ${programprefix}"
164 [[ $execprefix ]] && echo "execprefix ?= ${execprefix}"
165 [[ $includedir ]] && echo "includedir ?= ${includedir}"
166 [[ $libexecdir ]] && echo "libexecdir ?= ${libexecdir}"
167 [[ $localstatedir ]] && echo "localstatedir ?= ${localstatedir}"
168 [[ $sharedstatedir ]] && echo "sharedstatedir ?= ${sharedstatedir}"
169 [[ $infodir ]] && echo "infodir ?= ${infodir}"
170 [[ $systemdsystemunitdir ]] && echo "systemdsystemunitdir ?= ${systemdsystemunitdir}"
171 [[ $bashcompletiondir ]] && echo "bashcompletiondir ?= ${bashcompletiondir}"
174 mv Makefile.inc.$$ Makefile.inc