config BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
	bool
	# see src/basic/architecture.h
	default y if BR2_arc
	default y if BR2_aarch64 || BR2_aarch64_be
	default y if BR2_arm || BR2_armeb
	default y if BR2_i386 || BR2_x86_64
	default y if BR2_m68k
	default y if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
	default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
	default y if BR2_nios2
	default y if BR2_riscv
	default y if BR2_sh4 || BR2_sh4eb || BR2_sh4a || BR2_sh4aeb
	default y if BR2_sparc || BR2_sparc64
	default y if BR2_s390x

menuconfig BR2_PACKAGE_SYSTEMD
	bool "systemd"
	depends on BR2_INIT_SYSTEMD
	depends on BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
	depends on BR2_USE_MMU
	depends on !BR2_STATIC_LIBS # kmod
	depends on BR2_TOOLCHAIN_USES_GLIBC
	depends on BR2_TOOLCHAIN_HAS_SSP
	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
	depends on BR2_HOST_GCC_AT_LEAST_8 # host-systemd
	select BR2_PACKAGE_HAS_UDEV
	select BR2_PACKAGE_DBUS if !BR2_PACKAGE_DBUS_BROKER # runtime
	select BR2_PACKAGE_LIBCAP
	select BR2_PACKAGE_LIBXCRYPT
	select BR2_PACKAGE_UTIL_LINUX
	select BR2_PACKAGE_UTIL_LINUX_LIBS
	select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT
	select BR2_PACKAGE_UTIL_LINUX_AGETTY
	select BR2_PACKAGE_UTIL_LINUX_MOUNT
	select BR2_PACKAGE_UTIL_LINUX_FSCK
	select BR2_PACKAGE_UTIL_LINUX_SULOGIN
	select BR2_PACKAGE_KMOD
	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # kmod-tools
	select BR2_PACKAGE_KMOD_TOOLS
	select BR2_TARGET_TZ_INFO
	select BR2_NEEDS_HOST_UTF8_LOCALE
	select BR2_PACKAGE_HOST_SYSTEMD # for systemctl preset-all, during target-finalize
	help
	  systemd is a system and service manager for Linux,
	  compatible with SysV and LSB init scripts. systemd provides
	  aggressive parallelization capabilities, uses socket and
	  D-Bus activation for starting services, offers on-demand
	  starting of daemons, keeps track of processes using Linux
	  cgroups, supports snapshotting and restoring of the system
	  state, maintains mount and automount points and implements
	  an elaborate transactional dependency-based service control
	  logic.  It can work as a drop-in replacement for sysvinit.

	  Kernel versions below 4.15 ("recommended baseline") have
	  significant gaps in functionality and are not recommended
	  for use with this version of systemd.

	  Systemd requires a Linux kernel >= 3.15 with the following
	  options enabled:

	  - CONFIG_DEVTMPFS
	  - CONFIG_CGROUPS (it is OK to disable all controllers)
	  - CONFIG_INOTIFY_USER
	  - CONFIG_SIGNALFD
	  - CONFIG_TIMERFD
	  - CONFIG_EPOLL
	  - CONFIG_UNIX (it requires CONFIG_NET, but every other flag in
	    it is not necessary)
	  - CONFIG_SYSFS
	  - CONFIG_PROC_FS
	  - CONFIG_FHANDLE (libudev, mount and bind mount handling)

	  - CONFIG_NET_NS (Required for PrivateNetwork=, used in some
	    systemd units)

	  - CONFIG_USER_NS (Required for PrivateUsers=)

	  - CONFIG_AUTOFS_FS / CONFIG_AUTOFS4_FS
	  - CONFIG_TMPFS_POSIX_ACL
	  - CONFIG_TMPFS_XATTR

	  These options will be automatically enabled by Buildroot if
	  it is responsible for building the kernel. Otherwise, if you
	  are building your kernel outside of Buildroot, make sure
	  these options are enabled.

	  Systemd also provides udev, the userspace device daemon.

	  The selection of other packages will enable some features:

	  - acl package will add support for multi-seat.
	  - xz and/or l4 packages will add compression support in
	    journal and coredump.
	  - libcurl package will add support for systemd-journal-upload.
	  - libgcrypt package will add support for journal sealing and
	    DNSSEC verification in resolved.

	  Notice that systemd selects the fsck wrapper from util-linux
	  but no particular fsck.<fstype> is selected. You must choose
	  the appropriate ones (e.g. e2fsck, from the e2fsprogs
	  package) according to the system configuration.

	  https://freedesktop.org/wiki/Software/systemd/

if BR2_PACKAGE_SYSTEMD

config BR2_PACKAGE_PROVIDES_UDEV
	default "systemd"

config BR2_PACKAGE_SYSTEMD_BOOT
	bool "systemd-boot"
	depends on BR2_i386 || BR2_x86_64
	select BR2_PACKAGE_GNU_EFI
	select BR2_PACKAGE_SYSTEMD_EFI
	help
	  systemd-boot is a simple UEFI boot manager which executes
	  configured EFI images. The default entry is selected by a
	  configured pattern (glob) or an on-screen menu.

	  systemd-boot operates on the EFI System Partition (ESP)
	  only. Configuration file fragments, kernels, initrds, other
	  EFI images need to reside on the ESP. Linux kernels need to
	  be built with CONFIG_EFI_STUB to be able to be directly
	  executed as an EFI image.

	  See the Grub2 help text for details on preparing an EFI
	  capable disk image using systemd-boot: the instructions are
	  exactly the same, except that the systemd-boot configuration
	  files will be located in /loader/ inside the EFI partition.

	  https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/

config BR2_PACKAGE_SYSTEMD_INITRD
	bool "Services for booting from initrd"
	help
	  Install various services that are only useful if systemd is
	  run from an initrd.

config BR2_PACKAGE_SYSTEMD_KERNELINSTALL
	bool "install kernel-install and related files"
	help
	  kernel-install is used to install and remove kernel and
	  initramfs images to and from the boot loader partition.
	  The boot loader partition will usually be one of
	  /boot, /efi, or /boot/efi.

config BR2_PACKAGE_SYSTEMD_ANALYZE
	bool "systemd-analyze"
	help
	  systemd-analyze may be used to determine system boot-up
	  performance statistics and retrieve other state and tracing
	  information from the system and service manager, and to
	  verify the correctness of unit files.
	  It is also used to access special functions useful for
	  advanced system manager debugging.

config BR2_PACKAGE_SYSTEMD_BOOT_EFI_ARCH
	string
	default "ia32"  if BR2_i386
	default "x64"   if BR2_x86_64
	depends on BR2_PACKAGE_SYSTEMD_BOOT

config BR2_PACKAGE_SYSTEMD_EFI
	bool "enable EFI support"

config BR2_PACKAGE_SYSTEMD_JOURNAL_REMOTE
	bool "enable journal remote tools"
	select BR2_PACKAGE_LIBCURL
	select BR2_PACKAGE_LIBMICROHTTPD
	help
	  journal remote functionality adds three tools:

	  systemd-journal-gatewayd serves journal events over the
	  network.

	  systemd-journal-remote is a command to receive serialized
	  journal events and store them to journal files.

	  systemd-journal-upload will upload journal entries to the
	  URL specified with --url=.

	  https://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html
	  https://www.freedesktop.org/software/systemd/man/systemd-journal-remote.service.html
	  https://www.freedesktop.org/software/systemd/man/systemd-journal-upload.html

config BR2_PACKAGE_SYSTEMD_BACKLIGHT
	bool "enable backlight support"
	help
	  systemd-backlight is a service that restores the display
	  backlight brightness at early boot and saves it at shutdown.

	  https://www.freedesktop.org/software/systemd/man/systemd-backlight@.service.html

config BR2_PACKAGE_SYSTEMD_BINFMT
	bool "enable binfmt tool"
	help
	  systemd-binfmt is an early boot service that registers
	  additional binary formats for executables in the kernel.

	  http://www.freedesktop.org/software/systemd/man/systemd-binfmt.service.html

config BR2_PACKAGE_SYSTEMD_COREDUMP
	bool "enable coredump hook"
	help
	  systemd-coredump can be used as a helper binary by the
	  kernel when a user space program receives a fatal signal and
	  dumps core.

	  https://www.freedesktop.org/software/systemd/man/systemd-coredump.html

config BR2_PACKAGE_SYSTEMD_PSTORE
	bool "enable pstore support"
	default y
	help
	  When this features is enabled, additional tools and services
	  are built to support archiving contents of the persistent
	  storage filesystem.

	  https://www.freedesktop.org/software/systemd/man/systemd-pstore.html

config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
	bool "enable firstboot support"
	help
	  systemd-firstboot initializes the most basic system settings
	  interactively on the first boot.

	  https://www.freedesktop.org/software/systemd/man/systemd-firstboot.html

config BR2_PACKAGE_SYSTEMD_HIBERNATE
	bool "enable hibernation support"
	select BR2_PACKAGE_SYSTEMD_INITRD
	help
	  When this features is enabled, additional tools and services
	  are built to support suspending and resuming the system.

	  https://www.freedesktop.org/software/systemd/man/systemd-sleep.html

config BR2_PACKAGE_SYSTEMD_HOMED
	bool "enable home daemon"
	depends on BR2_TOOLCHAIN_HAS_THREADS # cryptsetup -> lvm2
	depends on BR2_USE_MMU # cryptsetup -> lvm2
	depends on !BR2_STATIC_LIBS # cryptsetup -> lvm2
	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # cryptsetup -> json-c
	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_12 # fscrypt_key
	select BR2_PACKAGE_CRYPTSETUP
	select BR2_PACKAGE_OPENSSL
	select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
	select BR2_PACKAGE_UTIL_LINUX_LIBFDISK
	help
	  systemd-homed is a system service that may be used to create,
	  remove, change or inspect home directories.

	  https://www.freedesktop.org/software/systemd/man/systemd-homed.service.html

comment "homed support needs a toolchain w/ threads, dynamic library, kernel headers >= 4.12"
	depends on BR2_USE_MMU
	depends on BR2_TOOLCHAIN_HAS_SYNC_4
	depends on !BR2_TOOLCHAIN_HAS_THREADS || \
		BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_12

config BR2_PACKAGE_SYSTEMD_HOSTNAMED
	bool "enable hostname daemon"
	default y
	help
	  systemd-hostnamed is a system service that may be used as a
	  mechanism to change the system's hostname.

	  https://www.freedesktop.org/software/systemd/man/systemd-hostnamed.service.html

config BR2_PACKAGE_SYSTEMD_HWDB
	bool "enable hwdb installation"
	default y
	help
	  Enables hardware database installation to /usr/lib/udev/hwdb.d

	  Disabling this option improves first boot time (or every boot
	  time in case of initramfs images) and saves several MB space.

	  https://www.freedesktop.org/software/systemd/man/hwdb.html

config BR2_PACKAGE_SYSTEMD_IMPORTD
	bool "enable import daemon"
	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
	select BR2_PACKAGE_LIBCURL
	select BR2_PACKAGE_LIBGCRYPT
	select BR2_PACKAGE_XZ
	select BR2_PACKAGE_ZLIB
	help
	  systemd-importd is a system service that manages virtual
	  machine and container images for systemd-machined and
	  machinectl.

	  https://www.freedesktop.org/software/systemd/man/machinectl.html#Image%20Transfer%20Commands

config BR2_PACKAGE_SYSTEMD_CATALOGDB
	bool "enable journal catalog database installation"
	depends on BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW # conflicting tmpfiles magic
	help
	  Build and install the journal catalog database.

	  catalog files are used to provide extended and potentially
	  localized messages for the journal.

	  The original catalog files will be built into a DB at
	  /usr/share/factory/var/lib/systemd/catalog/database.

	  https://www.freedesktop.org/wiki/Software/systemd/catalog/

config BR2_PACKAGE_SYSTEMD_LOCALED
	bool "enable locale daemon"
	help
	  systemd-localed is a system service that may be used as
	  mechanism to change the system locale settings, as well as
	  the console key mapping and default X11 key mapping.

	  https://www.freedesktop.org/software/systemd/man/systemd-localed.service.html

config BR2_PACKAGE_SYSTEMD_LOGIND
	bool "enable login daemon"
	help
	  systemd-logind is a system service that manages user logins.

	  https://www.freedesktop.org/software/systemd/man/systemd-logind.service.html

config BR2_PACKAGE_SYSTEMD_MACHINED
	bool "enable machine daemon"
	help
	  systemd-machined is a system service that keeps track of
	  virtual machines and containers, and processes belonging to
	  them.

	  https://www.freedesktop.org/software/systemd/man/systemd-machined.service.html

config BR2_PACKAGE_SYSTEMD_NSRESOURCED
	bool "enable nsresourced"
	help
	  systemd-nsresourced is a system service that permits
	  transient delegation of a a UID/GID range to a user
	  namespace allocated by a client, via a Varlink IPC API.

	  https://www.freedesktop.org/software/systemd/man/systemd-nsresourced.service.html

config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
	bool "enable myhostname NSS plugin"
	default y
	help
	  nss-myhostname is a plug-in module for the GNU Name Service
	  Switch (NSS) functionality of the GNU C Library (glibc),
	  primarily providing hostname resolution for the locally
	  configured system hostname as returned by gethostname(2).

	  https://www.freedesktop.org/software/systemd/man/nss-myhostname.html

config BR2_PACKAGE_SYSTEMD_NETWORKD
	bool "enable network manager"
	default y
	help
	  systemd-networkd is a system service that manages networks.
	  It detects and configures network devices as they appear, as
	  well as creating virtual network devices.

	  This simple network configuration solution is an alternative
	  to dhcpcd or ISC dhcp.

	  https://www.freedesktop.org/software/systemd/man/systemd-networkd.html

config BR2_PACKAGE_SYSTEMD_OOMD
	bool "enable out-of-memory killer"
	help
	  systemd-oomd is a system service that uses cgroups-v2 and
	  pressure stall information (PSI) to monitor and take action
	  on processes before an OOM occurs in kernel space.

	  https://www.freedesktop.org/software/systemd/man/systemd-oomd.html

config BR2_PACKAGE_SYSTEMD_POLKIT
	bool "enable polkit support"
	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # polkit -> c++17
	depends on BR2_TOOLCHAIN_HAS_THREADS # polkit
	depends on BR2_USE_WCHAR # libglib2
	depends on !BR2_OPTIMIZE_FAST # polkit -> duktape
	select BR2_PACKAGE_POLKIT
	help
	  If enabled, systemd is built with polkit support and policy
	  files for its services are generated and installed. It is
	  useful for allowing unprivileged processes to speak to
	  systemd's many privileged processes.

	  https://wiki.freedesktop.org/www/Software/polkit/

comment "polkit support needs a toolchain with threads, wchar, gcc >= 7"
	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_GCC_AT_LEAST_7 || \
		!BR2_TOOLCHAIN_HAS_THREADS

comment "polkit support can't be built with Optimize for fast"
	depends on BR2_OPTIMIZE_FAST

config BR2_PACKAGE_SYSTEMD_PORTABLED
	bool "enable portable services"
	help
	  Portable services are systemd services that can be dynamically
	  attached and detached from the system.

	  These services must come with their own root directory which
	  they are bound to through an automatically generated drop-in.

	  They also have restrictions applied by the host system in the
	  form of profiles.

	  This functionality is provided by the system service
	  systemd-portabled along with the corresponding CLI
	  portablectl.

	  https://systemd.io/PORTABLE_SERVICES/

config BR2_PACKAGE_SYSTEMD_QUOTACHECK
	bool "enable quotacheck tools"
	help
	  systemd-quotacheck is a service responsible for file system
	  quota checks. It is run once at boot after all necessary
	  file systems are mounted. It is pulled in only if at least
	  one file system has quotas enabled.

	  https://www.freedesktop.org/software/systemd/man/systemd-quotacheck.service.html

config BR2_PACKAGE_SYSTEMD_RANDOMSEED
	bool "enable random-seed support"
	help
	  systemd-random-seed is a service that restores the random
	  seed of the system at early boot and saves it at
	  shutdown. Saving/restoring the random seed across boots
	  increases the amount of available entropy early at boot.

	  https://www.freedesktop.org/software/systemd/man/systemd-random-seed.service.html

config BR2_PACKAGE_SYSTEMD_REPART
	bool "enable repart support"
	select BR2_PACKAGE_OPENSSL
	select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
	select BR2_PACKAGE_UTIL_LINUX_LIBFDISK
	help
	  systemd-repart grows and adds partitions to a partition table,
	  based on the configuration files described in repart.d.

	  https://www.freedesktop.org/software/systemd/man/systemd-repart.html

config BR2_PACKAGE_SYSTEMD_RESOLVED
	bool "enable resolve daemon"
	default y
	help
	  systemd-resolved is a system service that provides network
	  name resolution to local applications. It implements a
	  caching and validating DNS/DNSSEC stub resolver, as well as
	  an LLMNR resolver and responder.

	  https://www.freedesktop.org/software/systemd/man/systemd-resolved.html

config BR2_PACKAGE_SYSTEMD_RFKILL
	bool "enable rfkill tools"
	help
	  systemd-rfkill is a service that restores the RF kill switch
	  state at early boot and saves it at shutdown.

	  https://www.freedesktop.org/software/systemd/man/systemd-rfkill.service.html

config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
	bool "enable SMACK support"
	select BR2_PACKAGE_ATTR
	select BR2_PACKAGE_SMACK
	help
	  Enable support for SMACK, the Simple Mandatory Access
	  Control Kernel, a minimal approach to Access Control
	  implemented as a kernel LSM.

	  This feature requires a kernel >= 3.8.

	  When this feature is enabled, Systemd mounts smackfs and
	  manages security labels for sockets.

config BR2_PACKAGE_SYSTEMD_SYSEXT
	bool "enable sysext support"
	help
	  systemd-sysext activates/deactivates system extension
	  images.

	  System extension images may – dynamically at runtime —
	  extend the /usr/ and /opt/ directory hierarchies with
	  additional files.

	  This is particularly useful on immutable system images where
	  a /usr/ and/or /opt/ hierarchy residing on a read-only file
	  system shall be extended temporarily at runtime without
	  making any persistent modifications.

	  https://www.freedesktop.org/software/systemd/man/systemd-sysext.html

config BR2_PACKAGE_SYSTEMD_MOUNTFSD
	bool "enable mountfsd support"
	help
	  systemd-mountfsd is a system service that dissects disk
	  images, and returns mount file descriptors for the file
	  systems contained therein to clients, via a Varlink IPC
	  API.

	  https://www.freedesktop.org/software/systemd/man/systemd-mountfsd.service.html

config BR2_PACKAGE_SYSTEMD_SYSUPDATE
	bool "enable sysupdate support"
	select BR2_PACKAGE_OPENSSL
	select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
	select BR2_PACKAGE_UTIL_LINUX_LIBFDISK
	help
	  systemd-sysupdate atomically updates the host OS, container
	  images, portable service images or other sources, based on
	  the transfer configuration files described in sysupdate.d.

	  Note that the bootloader must be configured specifically to
	  support the A/B update mechanism defined by sysupdate. Only
	  systemd-boot does this out of the box.

	  https://www.freedesktop.org/software/systemd/man/systemd-sysupdate.html

config BR2_PACKAGE_SYSTEMD_SYSUSERS
	bool "enable sysusers support"
	help
	  systemd-sysusers creates system users and groups, based on
	  the file format and location specified in sysusers.d(5).

	  https://www.freedesktop.org/software/systemd/man/systemd-sysusers.html

config BR2_PACKAGE_SYSTEMD_TIMEDATED
	bool "enable timedate daemon"
	default y
	help
	  systemd-timedated is a system service that may be used as a
	  mechanism to change the system clock and timezone, as well
	  as to enable/disable NTP time synchronization.

	  https://www.freedesktop.org/software/systemd/man/systemd-timedated.service.html

config BR2_PACKAGE_SYSTEMD_TIMESYNCD
	bool "enable timesync daemon"
	default y
	help
	  systemd-timesyncd is a service that may be used to
	  synchronize the local system clock with a Network Time
	  Protocol server.

	  This simple NTP solution is an alternative to sntp/ntpd from
	  the ntp package.

	  https://www.freedesktop.org/software/systemd/man/systemd-timesyncd.html

config BR2_PACKAGE_SYSTEMD_USERDB
	bool "enable userdb daemon"
	help
	  systemd-userdbd is a system service that multiplexes
	  user/group lookups to all local services that provide JSON
	  user/group record definitions to the system. In addition it
	  synthesizes JSON user/group records from classic UNIX/glibc
	  NSS user/group records in order to provide full backwards
	  compatibility.

	  https://www.freedesktop.org/software/systemd/man/systemd-userdbd.service.html

config BR2_PACKAGE_SYSTEMD_UTMP
	bool "enable utmp support"
	help
	  systemd-update-utmp-runlevel.service is a service that writes
	  SysV runlevel changes to utmp and wtmp, as well as the audit
	  logs, as they occur.  systemd-update-utmp.service does the
	  same for system reboots and shutdown requests.

	  https://www.freedesktop.org/software/systemd/man/systemd-update-utmp.service.html

	  Utmp keeps track of what users do on the system (where they
	  logged from, on which terminal, ...) along with a general
	  status of the system (list of reboots, current uptime, current
	  number of users logged in).

	  You should only enable this if your system will have actual
	  users who log in.

	  https://man7.org/linux/man-pages/man5/utmp.5.html

config BR2_PACKAGE_SYSTEMD_VCONSOLE
	bool "enable vconsole tool"
	default y
	select BR2_PACKAGE_KBD if BR2_PACKAGE_SYSTEMD_VCONSOLE_DEFAULT_KEYMAP != ""
	help
	  systemd-vconsole-setup is an early boot service that
	  configures the virtual console font and console keymap.

	  https://www.freedesktop.org/software/systemd/man/systemd-vconsole-setup.service.html

config BR2_PACKAGE_SYSTEMD_VCONSOLE_DEFAULT_KEYMAP
	string "default keymap"
	default "us"
	depends on BR2_PACKAGE_SYSTEMD_VCONSOLE
	help
	  Default keymap for the system. Leave empty to not set a
	  default keymap.

# See for which architectures QEMU_MACHINE_TYPE is defined in
# src/vmspawn/vmspawn-util.h
config BR2_PACKAGE_SYSTEMD_VMSPAWN_ARCH_SUPPORTS
	bool
	default y if BR2_aarch64 || BR2_aarch64_be
	default y if BR2_arm || BR2_armeb
	default y if BR2_i386
	default y if BR2_mips || BR2_mips64 || BR2_mipsel || BR2_mips64el
	default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
	default y if BR2_riscv
	default y if BR2_s390x
	default y if BR2_x86_64

config BR2_PACKAGE_SYSTEMD_VMSPAWN
	bool "enable vmspawn"
	depends on BR2_PACKAGE_SYSTEMD_VMSPAWN_ARCH_SUPPORTS
	help
	  systemd-vmspawn may be used to start a virtual machine
	  from an OS image. In many ways it is similar to
	  systemd-nspawn, but launches a full virtual machine
	  instead of using namespaces.

	  https://www.freedesktop.org/software/systemd/man/systemd-vmspawn.html

endif
