]> git.ipfire.org Git - thirdparty/dracut.git/blame - configure
test(ISCSI): make test-30 use the test dracut modules
[thirdparty/dracut.git] / configure
CommitLineData
103281f3 1#!/bin/bash
103281f3
CW
2
3# We don't support srcdir != builddir
9a52c3fd 4echo \#buildapi-variable-no-builddir > /dev/null
103281f3
CW
5
6prefix=/usr
7
2692a422 8enable_documentation=yes
51d21c6b 9enable_dracut_cpio=no
2692a422 10
62f27ee6 11CC="${CC:-cc}"
699414f5
MAP
12PKG_CONFIG="${PKG_CONFIG:-pkg-config}"
13
103281f3
CW
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.
17read_arg() {
18 # $1 = arg name
19 # $2 = arg value
20 # $3 = arg parameter
21 local rematch='^[^=]*=(.*)$'
22 if [[ $2 =~ $rematch ]]; then
f4053eb0 23 read -r "$1" <<< "${BASH_REMATCH[1]}"
103281f3 24 else
f4053eb0 25 read -r "$1" <<< "$3"
103281f3
CW
26 # There is no way to shift our callers args, so
27 # return 1 to indicate they should do it instead.
28 return 1
29 fi
1d4b3375 30 return 0
103281f3
CW
31}
32
33while (($# > 0)); do
34 case "${1%%=*}" in
9a52c3fd
HH
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 ;;
51d21c6b 52 --enable-dracut-cpio) enable_dracut_cpio=yes ;;
9a52c3fd 53 *) echo "Ignoring unknown option '$1'" ;;
103281f3
CW
54 esac
55 shift
56done
57
7bb80835
YW
58if ! ${PKG_CONFIG} --exists --print-errors " libkmod >= 23 "; then
59 echo "dracut needs pkg-config and libkmod >= 23." >&2
607fec3e
HH
60 exit 1
61fi
62
9a52c3fd 63cat << EOF > conftest.c
62f27ee6
DTCD
64#include <fts.h>
65int main() {
66 return 0;
67}
68EOF
69
f4053eb0 70# shellcheck disable=SC2086
9a52c3fd 71${CC} $CFLAGS $LDFLAGS conftest.c > /dev/null 2>&1
62f27ee6
DTCD
72ret=$?
73rm -f conftest.c a.out
74
75# musl doesn't have fts.h included
76if test $ret -ne 0; then
9a52c3fd
HH
77 echo "dracut needs fts development files." >&2
78 exit 1
62f27ee6
DTCD
79fi
80
9a52c3fd 81cat << EOF > conftest.c
62f27ee6
DTCD
82#include <fts.h>
83int main(void) {
84 fts_open(0, 0, 0);
85 return 0;
86}
87EOF
88
89found=no
90for lib in "-lc" "-lfts"; do
9a52c3fd
HH
91 # shellcheck disable=SC2086
92 ${CC} $CFLAGS $LDFLAGS conftest.c -Wl,$lib > /dev/null 2>&1
93 ret=$?
94 if test $ret -eq 0; then
95 FTS_LIBS="$lib"
96 found=yes
97 break
98 fi
62f27ee6
DTCD
99done
100rm -f conftest.c a.out
101
102if test $found = no; then
9a52c3fd
HH
103 echo "dracut couldn't find usable fts library" >&2
104 exit 1
62f27ee6
DTCD
105fi
106
0ef40d88
SS
107cat << EOF > conftest.c
108#include <stdio.h>
109#include <unistd.h>
110#include <sys/syscall.h>
111
112#ifndef SYS_gettid
113#error "SYS_gettid unavailable on this system"
114#endif
115
116#define gettid() ((pid_t) syscall(SYS_gettid))
117
118int main(void) {
119 return getpid() == gettid() ? 0 : -1;
120}
121EOF
122
123# shellcheck disable=SC2086
124${CC} $CFLAGS $LDFLAGS conftest.c > /dev/null 2>&1
125ret=$?
126rm -f conftest.c a.out
127
128if test $ret -ne 0; then
129 echo "dracut needs SYS_gettid support." >&2
130 exit 1
131fi
132
51d21c6b
DD
133if test "$enable_dracut_cpio" = "yes"; then
134 cargo --version > /dev/null
135 ret=$?
136 if test $ret -ne 0; then
137 echo "dracut couldn't find cargo for dracut-cpio build"
138 exit 1
139 fi
140fi
141
9a52c3fd 142cat > Makefile.inc.$$ << EOF
103281f3
CW
143prefix ?= ${prefix}
144libdir ?= ${libdir:-${prefix}/lib}
145datadir ?= ${datadir:-${prefix}/share}
146sysconfdir ?= ${sysconfdir:-${prefix}/etc}
147sbindir ?= ${sbindir:-${prefix}/sbin}
148mandir ?= ${mandir:-${prefix}/share/man}
1d4b3375 149enable_documentation ?= ${enable_documentation:-yes}
51d21c6b 150enable_dracut_cpio ?= ${enable_dracut_cpio}
1d4b3375 151bindir ?= ${bindir:-${prefix}/bin}
2a0da60e
HH
152KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ")
153KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ")
62f27ee6 154FTS_LIBS ?= ${FTS_LIBS}
103281f3 155EOF
1d4b3375
HH
156
157{
158 [[ $programprefix ]] && echo "programprefix ?= ${programprefix}"
159 [[ $execprefix ]] && echo "execprefix ?= ${execprefix}"
160 [[ $includedir ]] && echo "includedir ?= ${includedir}"
161 [[ $libexecdir ]] && echo "libexecdir ?= ${libexecdir}"
162 [[ $localstatedir ]] && echo "localstatedir ?= ${localstatedir}"
163 [[ $sharedstatedir ]] && echo "sharedstatedir ?= ${sharedstatedir}"
164 [[ $infodir ]] && echo "infodir ?= ${infodir}"
165 [[ $systemdsystemunitdir ]] && echo "systemdsystemunitdir ?= ${systemdsystemunitdir}"
166 [[ $bashcompletiondir ]] && echo "bashcompletiondir ?= ${bashcompletiondir}"
167} >> Makefile.inc.$$
168
169mv Makefile.inc.$$ Makefile.inc