Skip to content

Commit

Permalink
build: Allow for Linux distribution and feature selection
Browse files Browse the repository at this point in the history
Prepare for supporting multiple Linux distributions by making all
features conditional and defining configurable options for feature
selection.

Provide the ability to enable all features for a particular Linux
distribution, and attempt to autodetect the distribution on which the
package is being built.

Signed-off-by: Michael Brown <[email protected]>
  • Loading branch information
mcb30 committed Jun 30, 2021
1 parent 322f457 commit 3e3526c
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
69 changes: 69 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,76 @@
# Configure autoconf
#
AC_INIT([sanbootable], [0.1], [[email protected]])
AC_CONFIG_SRCDIR([src/initramfs/iscsi.initramfs])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign subdir-objects tar-ustar])

# Define distribution selections
#
AC_ARG_ENABLE([ubuntu],
AS_HELP_STRING([--enable-ubuntu],
[enable all Ubuntu features]))

# Define individual feature selections
#
AC_ARG_ENABLE([finalrd],
AS_HELP_STRING([--disable-finalrd],
[disable finalrd hook]))
AC_ARG_ENABLE([grub-initrd-fallback],
AS_HELP_STRING([--disable-grub-initrd-fallback],
[disable GRUB initrd fallback hook]))
AC_ARG_ENABLE([initramfs],
AS_HELP_STRING([--disable-initramfs],
[disable initramfs hook]))

# Determine current distribution if none explicitly specified
#
AS_IF([test "x$enable_ubuntu" = "x"], [
AS_IF([test -e /etc/lsb-release], [source /etc/lsb-release])
AS_IF(AS_EXECUTABLE_P([/usr/bin/lsb_release]),
[DISTRIB_ID=$(/usr/bin/lsb_release -s -i)])
AS_IF([test "x$DISTRIB_ID" = "xUbuntu"], [default_ubuntu=yes])
])

# Test for individual distribution selections
#
AS_IF([test "x$enable_ubuntu" = "x"],
[enable_ubuntu=$default_ubuntu])

# Disable all features by default
#
default_finalrd=no
default_grub_initrd_fallback=no
default_initramfs=no

# Set feature defaults per distribution
#
AS_IF([test "x$enable_ubuntu" = "xyes"], [
default_finalrd=yes
default_grub_initrd_fallback=yes
default_initramfs=yes
])

# Test for individual feature selections
#
AS_IF([test "x$enable_finalrd" = "x"],
[enable_finalrd=$default_finalrd])
AS_IF([test "x$enable_grub_initrd_fallback" = "x"],
[enable_grub_initrd_fallback=$default_grub_initrd_fallback])
AS_IF([test "x$enable_initramfs" = "x"],
[enable_initramfs=$default_initramfs])

# Define automake conditionals
#
AM_CONDITIONAL([FINALRD],
[test "x$enable_finalrd" = "xyes"])
AM_CONDITIONAL([GRUBINITRDFALLBACK],
[test "x$enable_grub_initrd_fallback" = "xyes"])
AM_CONDITIONAL([INITRAMFS],
[test "x$enable_initramfs" = "xyes"])

# Generate output files
#
AC_CONFIG_FILES([
Makefile
src/Makefile
Expand Down
3 changes: 3 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

export DH_VERBOSE=1

override_dh_auto_configure:
dh_auto_configure -- --enable-ubuntu

override_dh_strip_nondeterminism:

override_dh_update_autotools_config:
Expand Down
4 changes: 4 additions & 0 deletions src/finalrd/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if FINALRD

finalrddir = @datadir@/finalrd

dist_finalrd_SCRIPTS = open-iscsi-sanbootable.finalrd

endif
4 changes: 4 additions & 0 deletions src/grub-initrd-fallback/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if GRUBINITRDFALLBACK

grubinitrdfallbackdir = @prefix@/lib/systemd/system/grub-initrd-fallback.service.d

dist_bin_SCRIPTS = initrdfail-sanbootable

dist_grubinitrdfallback_DATA = initrdfail-sanbootable.conf

endif
4 changes: 4 additions & 0 deletions src/initramfs/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if INITRAMFS

iscsiconfdir = @sysconfdir@/iscsi

dist_iscsiconf_SCRIPTS = iscsi.initramfs

endif

0 comments on commit 3e3526c

Please sign in to comment.