]>
Commit | Line | Data |
---|---|---|
103281f3 | 1 | #!/bin/bash |
103281f3 CW |
2 | |
3 | # We don't support srcdir != builddir | |
4 | echo \#buildapi-variable-no-builddir >/dev/null | |
5 | ||
6 | prefix=/usr | |
7 | ||
2692a422 CW |
8 | enable_documentation=yes |
9 | ||
62f27ee6 | 10 | CC="${CC:-cc}" |
699414f5 MAP |
11 | PKG_CONFIG="${PKG_CONFIG:-pkg-config}" |
12 | ||
103281f3 CW |
13 | # Little helper function for reading args from the commandline. |
14 | # it automatically handles -a b and -a=b variants, and returns 1 if | |
15 | # we need to shift $3. | |
16 | read_arg() { | |
17 | # $1 = arg name | |
18 | # $2 = arg value | |
19 | # $3 = arg parameter | |
20 | local rematch='^[^=]*=(.*)$' | |
21 | if [[ $2 =~ $rematch ]]; then | |
22 | read "$1" <<< "${BASH_REMATCH[1]}" | |
23 | else | |
24 | read "$1" <<< "$3" | |
25 | # There is no way to shift our callers args, so | |
26 | # return 1 to indicate they should do it instead. | |
27 | return 1 | |
28 | fi | |
1d4b3375 | 29 | return 0 |
103281f3 CW |
30 | } |
31 | ||
32 | while (($# > 0)); do | |
33 | case "${1%%=*}" in | |
34 | --prefix) read_arg prefix "$@" || shift;; | |
35 | --libdir) read_arg libdir "$@" || shift;; | |
36 | --datadir) read_arg datadir "$@" || shift;; | |
37 | --sysconfdir) read_arg sysconfdir "$@" || shift;; | |
38 | --sbindir) read_arg sbindir "$@" || shift;; | |
39 | --mandir) read_arg mandir "$@" || shift;; | |
2692a422 | 40 | --disable-documentation) enable_documentation=no;; |
1d4b3375 HH |
41 | --program-prefix) read_arg programprefix "$@" || shift;; |
42 | --exec-prefix) read_arg execprefix "$@" || shift;; | |
43 | --bindir) read_arg bindir "$@" || shift;; | |
44 | --includedir) read_arg includedir "$@" || shift;; | |
45 | --libexecdir) read_arg libexecdir "$@" || shift;; | |
46 | --localstatedir) read_arg localstatedir "$@" || shift;; | |
47 | --sharedstatedir) read_arg sharedstatedir "$@" || shift;; | |
48 | --infodir) read_arg infodir "$@" || shift;; | |
49 | --systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift;; | |
50 | --bashcompletiondir) read_arg bashcompletiondir "$@" || shift;; | |
103281f3 CW |
51 | *) echo "Ignoring unknown option '$1'";; |
52 | esac | |
53 | shift | |
54 | done | |
55 | ||
7bb80835 YW |
56 | if ! ${PKG_CONFIG} --exists --print-errors " libkmod >= 23 "; then |
57 | echo "dracut needs pkg-config and libkmod >= 23." >&2 | |
607fec3e HH |
58 | exit 1 |
59 | fi | |
60 | ||
62f27ee6 DTCD |
61 | cat <<EOF >conftest.c |
62 | #include <fts.h> | |
63 | int main() { | |
64 | return 0; | |
65 | } | |
66 | EOF | |
67 | ||
68 | ${CC} $CFLAGS $LDFLAGS conftest.c >/dev/null 2>&1 | |
69 | ret=$? | |
70 | rm -f conftest.c a.out | |
71 | ||
72 | # musl doesn't have fts.h included | |
73 | if test $ret -ne 0; then | |
74 | echo "dracut needs fts development files." >&2 | |
75 | exit 1 | |
76 | fi | |
77 | ||
78 | cat <<EOF >conftest.c | |
79 | #include <fts.h> | |
80 | int main(void) { | |
81 | fts_open(0, 0, 0); | |
82 | return 0; | |
83 | } | |
84 | EOF | |
85 | ||
86 | found=no | |
87 | for lib in "-lc" "-lfts"; do | |
88 | ${CC} $CFLAGS -Wl,$lib $LDFLAGS conftest.c >/dev/null 2>&1 | |
89 | ret=$? | |
90 | if test $ret -eq 0; then | |
91 | FTS_LIBS="$lib" | |
92 | found=yes | |
93 | break; | |
94 | fi | |
95 | done | |
96 | rm -f conftest.c a.out | |
97 | ||
98 | if test $found = no; then | |
99 | echo "dracut couldn't find usable fts library" >&2 | |
100 | exit 1 | |
101 | fi | |
102 | ||
1d4b3375 | 103 | cat > Makefile.inc.$$ <<EOF |
103281f3 CW |
104 | prefix ?= ${prefix} |
105 | libdir ?= ${libdir:-${prefix}/lib} | |
106 | datadir ?= ${datadir:-${prefix}/share} | |
107 | sysconfdir ?= ${sysconfdir:-${prefix}/etc} | |
108 | sbindir ?= ${sbindir:-${prefix}/sbin} | |
109 | mandir ?= ${mandir:-${prefix}/share/man} | |
1d4b3375 HH |
110 | enable_documentation ?= ${enable_documentation:-yes} |
111 | bindir ?= ${bindir:-${prefix}/bin} | |
2a0da60e HH |
112 | KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ") |
113 | KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ") | |
62f27ee6 | 114 | FTS_LIBS ?= ${FTS_LIBS} |
103281f3 | 115 | EOF |
1d4b3375 HH |
116 | |
117 | { | |
118 | [[ $programprefix ]] && echo "programprefix ?= ${programprefix}" | |
119 | [[ $execprefix ]] && echo "execprefix ?= ${execprefix}" | |
120 | [[ $includedir ]] && echo "includedir ?= ${includedir}" | |
121 | [[ $libexecdir ]] && echo "libexecdir ?= ${libexecdir}" | |
122 | [[ $localstatedir ]] && echo "localstatedir ?= ${localstatedir}" | |
123 | [[ $sharedstatedir ]] && echo "sharedstatedir ?= ${sharedstatedir}" | |
124 | [[ $infodir ]] && echo "infodir ?= ${infodir}" | |
125 | [[ $systemdsystemunitdir ]] && echo "systemdsystemunitdir ?= ${systemdsystemunitdir}" | |
126 | [[ $bashcompletiondir ]] && echo "bashcompletiondir ?= ${bashcompletiondir}" | |
127 | } >> Makefile.inc.$$ | |
128 | ||
129 | mv Makefile.inc.$$ Makefile.inc |