Skip to content

Commit 469af85

Browse files
committed
feat(Makefile): cargo wrapper for dracut-cpio build
If configured with --enable-dracut-cpio, call cargo to build the dracut-cpio release binary. Signed-off-by: David Disseldorp <[email protected]>
1 parent a230cb0 commit 469af85

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ ifeq ($(HAVE_SHFMT),yes)
102102
shfmt -w -s .
103103
endif
104104

105+
src/dracut-cpio/target/release/dracut-cpio: src/dracut-cpio/src/main.rs
106+
cargo --offline build --release --manifest-path src/dracut-cpio/Cargo.toml
107+
108+
dracut-cpio: src/dracut-cpio/target/release/dracut-cpio
109+
ln -fs $< $@
110+
111+
ifeq ($(enable_dracut_cpio),yes)
112+
all: dracut-cpio
113+
endif
114+
105115
doc: $(manpages) dracut.html
106116

107117
ifneq ($(enable_documentation),no)
@@ -196,6 +206,9 @@ endif
196206
if [ -f dracut-util ]; then \
197207
install -m 0755 dracut-util $(DESTDIR)$(pkglibdir)/dracut-util; \
198208
fi
209+
ifeq ($(enable_dracut_cpio),yes)
210+
install -m 0755 dracut-cpio $(DESTDIR)$(pkglibdir)/dracut-cpio
211+
endif
199212
mkdir -p $(DESTDIR)${prefix}/lib/kernel/install.d
200213
install -m 0755 install.d/50-dracut.install $(DESTDIR)${prefix}/lib/kernel/install.d/50-dracut.install
201214
install -m 0755 install.d/51-dracut-rescue.install $(DESTDIR)${prefix}/lib/kernel/install.d/51-dracut-rescue.install
@@ -222,6 +235,7 @@ clean:
222235
$(RM) dracut-util util/util $(UTIL_OBJECTS)
223236
$(RM) $(manpages) dracut.html
224237
$(RM) dracut.pc
238+
$(RM) dracut-cpio src/dracut-cpio/target/release/dracut-cpio*
225239
$(MAKE) -C test clean
226240

227241
dist: dracut-$(DRACUT_MAIN_VERSION).tar.xz

configure

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ echo \#buildapi-variable-no-builddir > /dev/null
66
prefix=/usr
77

88
enable_documentation=yes
9+
enable_dracut_cpio=no
910

1011
CC="${CC:-cc}"
1112
PKG_CONFIG="${PKG_CONFIG:-pkg-config}"
@@ -48,6 +49,7 @@ while (($# > 0)); do
4849
--infodir) read_arg infodir "$@" || shift ;;
4950
--systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift ;;
5051
--bashcompletiondir) read_arg bashcompletiondir "$@" || shift ;;
52+
--enable-dracut-cpio) enable_dracut_cpio=yes ;;
5153
*) echo "Ignoring unknown option '$1'" ;;
5254
esac
5355
shift
@@ -102,6 +104,15 @@ if test $found = no; then
102104
exit 1
103105
fi
104106

107+
if test "$enable_dracut_cpio" = "yes"; then
108+
cargo --version > /dev/null
109+
ret=$?
110+
if test $ret -ne 0; then
111+
echo "dracut couldn't find cargo for dracut-cpio build"
112+
exit 1
113+
fi
114+
fi
115+
105116
cat > Makefile.inc.$$ << EOF
106117
prefix ?= ${prefix}
107118
libdir ?= ${libdir:-${prefix}/lib}
@@ -110,6 +121,7 @@ sysconfdir ?= ${sysconfdir:-${prefix}/etc}
110121
sbindir ?= ${sbindir:-${prefix}/sbin}
111122
mandir ?= ${mandir:-${prefix}/share/man}
112123
enable_documentation ?= ${enable_documentation:-yes}
124+
enable_dracut_cpio ?= ${enable_dracut_cpio}
113125
bindir ?= ${bindir:-${prefix}/bin}
114126
KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ")
115127
KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ")

0 commit comments

Comments
 (0)