Skip to content

Commit

Permalink
feat(Makefile): cargo wrapper for dracut-cpio build
Browse files Browse the repository at this point in the history
If configured with --enable-dracut-cpio, call cargo to build the
dracut-cpio release binary.

Signed-off-by: David Disseldorp <ddiss@suse.de>
  • Loading branch information
ddiss authored and haraldh committed Nov 24, 2021
1 parent a9c6704 commit 51d21c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Makefile
Expand Up @@ -102,6 +102,16 @@ ifeq ($(HAVE_SHFMT),yes)
shfmt -w -s .
endif

src/dracut-cpio/target/release/dracut-cpio: src/dracut-cpio/src/main.rs
cargo --offline build --release --manifest-path src/dracut-cpio/Cargo.toml

dracut-cpio: src/dracut-cpio/target/release/dracut-cpio
ln -fs $< $@

ifeq ($(enable_dracut_cpio),yes)
all: dracut-cpio
endif

doc: $(manpages) dracut.html

ifneq ($(enable_documentation),no)
Expand Down Expand Up @@ -196,6 +206,9 @@ endif
if [ -f dracut-util ]; then \
install -m 0755 dracut-util $(DESTDIR)$(pkglibdir)/dracut-util; \
fi
ifeq ($(enable_dracut_cpio),yes)
install -m 0755 dracut-cpio $(DESTDIR)$(pkglibdir)/dracut-cpio
endif
mkdir -p $(DESTDIR)${prefix}/lib/kernel/install.d
install -m 0755 install.d/50-dracut.install $(DESTDIR)${prefix}/lib/kernel/install.d/50-dracut.install
install -m 0755 install.d/51-dracut-rescue.install $(DESTDIR)${prefix}/lib/kernel/install.d/51-dracut-rescue.install
Expand All @@ -222,6 +235,7 @@ clean:
$(RM) dracut-util util/util $(UTIL_OBJECTS)
$(RM) $(manpages) dracut.html
$(RM) dracut.pc
$(RM) dracut-cpio src/dracut-cpio/target/release/dracut-cpio*
$(MAKE) -C test clean

dist: dracut-$(DRACUT_MAIN_VERSION).tar.xz
Expand Down
12 changes: 12 additions & 0 deletions configure
Expand Up @@ -6,6 +6,7 @@ echo \#buildapi-variable-no-builddir > /dev/null
prefix=/usr

enable_documentation=yes
enable_dracut_cpio=no

CC="${CC:-cc}"
PKG_CONFIG="${PKG_CONFIG:-pkg-config}"
Expand Down Expand Up @@ -48,6 +49,7 @@ while (($# > 0)); do
--infodir) read_arg infodir "$@" || shift ;;
--systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift ;;
--bashcompletiondir) read_arg bashcompletiondir "$@" || shift ;;
--enable-dracut-cpio) enable_dracut_cpio=yes ;;
*) echo "Ignoring unknown option '$1'" ;;
esac
shift
Expand Down Expand Up @@ -102,6 +104,15 @@ if test $found = no; then
exit 1
fi

if test "$enable_dracut_cpio" = "yes"; then
cargo --version > /dev/null
ret=$?
if test $ret -ne 0; then
echo "dracut couldn't find cargo for dracut-cpio build"
exit 1
fi
fi

cat > Makefile.inc.$$ << EOF
prefix ?= ${prefix}
libdir ?= ${libdir:-${prefix}/lib}
Expand All @@ -110,6 +121,7 @@ sysconfdir ?= ${sysconfdir:-${prefix}/etc}
sbindir ?= ${sbindir:-${prefix}/sbin}
mandir ?= ${mandir:-${prefix}/share/man}
enable_documentation ?= ${enable_documentation:-yes}
enable_dracut_cpio ?= ${enable_dracut_cpio}
bindir ?= ${bindir:-${prefix}/bin}
KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ")
KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ")
Expand Down

0 comments on commit 51d21c6

Please sign in to comment.