Refactor: Move HAVE_DBUS and CONSOLE to configure script.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2015-06-22 15:12:20 +02:00
parent 36c59e77b4
commit 70af5d7f8d
3 changed files with 174 additions and 152 deletions
Vendored
+171 -149
View File
@@ -13,46 +13,49 @@
# Setup defaults if undefined
defaults()
{
heading=${heading:='"Finit v" VERSION'}
prefix=${prefix:="/usr"}
sysconfdir=${sysconfdir:="/etc"}
sbindir=${sbindir:="/sbin"}
libdir=${libdir:="/lib"}
pdir="finit/plugins"
plugindir=${plugindir:="$libdir/$pdir"}
# The initctl FIFO, should probably be in /run, not /dev
fifo=${fifo:="/dev/initctl"}
conf="finit.conf"
config=${config:="$sysconfdir/$conf"}
confdir=${confdir:="finit.d"}
rcsd=${rcsd:="$sysconfdir/$confdir"}
heading=${heading:='"Finit v" VERSION'}
prefix=${prefix:="/usr"}
sysconfdir=${sysconfdir:="/etc"}
sbindir=${sbindir:="/sbin"}
libdir=${libdir:="/lib"}
pdir="finit/plugins"
plugindir=${plugindir:="$libdir/$pdir"}
# The initctl FIFO, should probably be in /run, not /dev
fifo=${fifo:="/dev/initctl"}
conf="finit.conf"
config=${config:="$sysconfdir/$conf"}
confdir=${confdir:="finit.d"}
rcsd=${rcsd:="$sysconfdir/$confdir"}
console=${console:='_PATH_CONSOLE'}
defuser=${defuser:="root"}
defhost=${defhost:="noname"}
runlevel=${runlevel:=2}
debug=${debug:=0}
embedded=${embedded:=0}
remount=${remount:=0}
inetd=${inetd:=1}
verbose=${verbose:=1}
kernel_quiet=${kernel_quiet:=1}
static=${static:=0}
disable_plugins=${disable_plugins:=0}
debug=${debug:=0}
embedded=${embedded:=0}
dbus=${dbus:=0}
remount=${remount:=0}
inetd=${inetd:=1}
verbose=${verbose:=1}
kernel_quiet=${kernel_quiet:=1}
static=${static:=0}
disable_plugins=${disable_plugins:=0}
}
result()
{
echo
echo "Finit configuration"
echo "========================================================================"
echo "Heading : $heading"
echo "Install prefix : $prefix"
echo "System config dir : $sysconfdir"
echo "Super user bindir : $sbindir"
echo "Shared libs dir : $libdir"
echo "Plugins dir : $plugindir"
echo "FIFO : $fifo"
echo "Config file : $config"
echo "rcs.d/ directory : $rcsd"
echo
echo "Finit configuration"
echo "========================================================================"
echo "Heading : $heading"
echo "Install prefix : $prefix"
echo "System config dir : $sysconfdir"
echo "Super user bindir : $sbindir"
echo "Shared libs dir : $libdir"
echo "Plugins dir : $plugindir"
echo "FIFO : $fifo"
echo "Config file : $config"
echo "rcs.d/ directory : $rcsd"
echo "Default console : $console"
if [ x"$sysroot" != x"" ]; then
echo "Swap rootfs to : $sysroot"
fi
@@ -60,101 +63,108 @@ result()
echo "Default hostname : $defhost"
echo "Default runlevel : $runlevel"
if [ $debug -ne 0 ]; then
echo "Debug : ENABLED"
fi
if [ $debug -ne 0 ]; then
echo "Debug : ENABLED"
fi
if [ $embedded -ne 0 ]; then
echo "Embedded target : YES (BusyBox getty, and mdev instead of udev)"
fi
if [ $embedded -ne 0 ]; then
echo "Embedded target : YES (BusyBox getty, and mdev instead of udev)"
fi
if [ $dbus -ne 0 ]; then
echo "D-Bus : YES, remember to install dbus.so plugin as well!"
fi
if [ $remount -ne 0 ]; then
echo "Remount ROOT fs : YES, / will be remounted as read-write at bootstrap"
fi
echo "Remount ROOT fs : YES, / will be remounted as read-write at bootstrap"
fi
if [ x"$random" != x"" ]; then
echo "Random seed : $random"
fi
if [ $inetd -ne 0 ]; then
echo "Inetd : Built-in"
else
echo "Inetd : DISABLED"
fi
if [ $verbose -ne 1 ]; then
echo "Quiet Finit : YES"
if [ $inetd -ne 0 ]; then
echo "Inetd : Built-in"
else
echo "Quiet Finit : NO, verbose output (default)"
fi
echo "Inetd : DISABLED"
fi
if [ $kernel_quiet -eq 1 ]; then
echo "Kernel Quiet : YES, silent after inital boot (default)"
if [ $verbose -ne 1 ]; then
echo "Quiet Finit : YES"
else
echo "Kernel Quiet : NO"
fi
echo "Quiet Finit : NO, verbose output (default)"
fi
if [ $static -ne 0 ]; then
echo "Static Finit : YES"
fi
if [ $kernel_quiet -eq 1 ]; then
echo "Kernel Quiet : YES, silent after inital boot (default)"
else
echo "Kernel Quiet : NO"
fi
if [ $disable_plugins -eq 1 ]; then
echo "Plugins : DISABLED"
else
if [ x"$plugins" = x"" ]; then
echo "Plugins : ALL"
else
echo "Plugins : $plugins"
fi
fi
echo
if [ $static -ne 0 ]; then
echo "Static Finit : YES"
fi
if [ $disable_plugins -eq 1 ]; then
echo "Plugins : DISABLED"
else
if [ x"$plugins" = x"" ]; then
echo "Plugins : ALL"
else
echo "Plugins : $plugins"
fi
fi
echo
}
usage()
{
defaults
defaults
echo "Run this script to configure finit for your operating system."
echo
echo "Usage: $0 [ARG]"
echo
echo " --prefix=PREFIX Set installation prefix, default '$prefix'"
echo " --sysconfdir=CONF Set conf dir, default '$sysconfdir'"
echo " --sbindir=SBIN Set sbin dir, default '$sbindir'"
echo " --libdir=LIB Set lib dir, default '$libdir'"
echo " --plugindir=DIR Set plugin dir, default '\$libdir/$pdir'"
echo
echo " --with-fifo=FIFO FIFO for initctl plugin, default '$fifo'"
echo " --with-config=CONFIG Finit CONFIG file, default '\$sysconfdir/$conf'"
echo " --with-heading=GREET Display GREET instead of Finit version at boot"
echo " --with-randomseed=SEED Seed /dev/urandom from file SEED. On Debian/Ubuntu"
echo " systems, set this to /var/lib/urandom/random-seed"
echo " Default: none"
echo " --help This help text"
echo " --prefix=PREFIX Set installation prefix, default '$prefix'"
echo " --sysconfdir=CONF Set conf dir, default '$sysconfdir'"
echo " --sbindir=SBIN Set sbin dir, default '$sbindir'"
echo " --libdir=LIB Set lib dir, default '$libdir'"
echo " --plugindir=DIR Set plugin dir, default '\$libdir/$pdir'"
echo
echo " --with-fifo=FIFO FIFO for initctl plugin, default '$fifo'"
echo " --with-config=CONFIG Finit CONFIG file, default '\$sysconfdir/$conf'"
echo " --with-heading=GREET Display GREET instead of Finit version at boot"
echo " --with-randomseed=SEED Seed /dev/urandom from file SEED. On Debian/Ubuntu"
echo " systems, set this to /var/lib/urandom/random-seed"
echo " Default: none"
echo " --with-plugins=\"a b c\" Build plugins 'a', 'b' and 'c', either as dynamic .so"
echo " files, or as built-in if --enable-static is given,"
echo " defaults to all plugins. Exclude extension!"
echo " --with-rcsd=RCSD Finit RCSD directory, default '\$sysconfdir/$confdir'"
echo " defaults to all plugins. Exclude extension!"
echo " --with-rcsd=RCSD Finit RCSD directory, default '\$sysconfdir/$confdir'"
echo " --with-console=DEV Console to use, default: /dev/console"
echo " --with-sysroot=PATH Some distributions keep a different (writable) rootfs"
echo " that is used at runtime, usually /sysroot or /mnt"
echo " --with-username=USER User for 'startx' .conf option, default: root"
echo " --with-hostname=NAME Hostname, if /etc/hostname is missing, default: noname"
echo " --with-username=USER User for 'startx' .conf option, default: root"
echo " --with-hostname=NAME Hostname, if /etc/hostname is missing, default: noname"
echo " --with-runlevel=LEVEL Runlevel to switch to after bootstrap (S), default: 2"
echo
echo " --enable-embedded Embedded defaults, BusBox getty, mdev etc."
echo " --enable-embedded Embedded defaults, BusBox getty, mdev etc."
echo " --enable-dbus Enable D-Bus plugin. Note: install plugin as well!"
echo " --enable-rw-rootfs Remount / as read-write at bootstrap, not for embedded"
echo " --enable-debug Enable debug flags, '-O0, -g'"
echo " --enable-quiet Quiet mode, reduce screen output to absolute minimum"
echo " --enable-static Link statically. This disables a few features."
echo " --disable-inetd Disable inetd support if not needed."
echo " --disable-kernel-quiet Disable kernel cmdline quiet, default enabled."
echo " --disable-plugins Disable plugins"
echo " --enable-debug Enable debug flags, '-O0, -g'"
echo " --enable-quiet Quiet mode, reduce screen output to absolute minimum"
echo " --enable-static Link statically. This disables a few features."
echo " --disable-inetd Disable inetd support if not needed."
echo " --disable-kernel-quiet Disable kernel cmdline quiet, default enabled."
echo " --disable-plugins Disable plugins"
echo
echo "The build system also supports external CFLAGS, CPPFLAGS, LDFLAGS, LDLIBS,"
echo "and DESTDIR, useful for packaging or cross-compiling."
echo
echo "The build system also supports external CFLAGS, CPPFLAGS, LDFLAGS, LDLIBS,"
echo "and DESTDIR, useful for packaging or cross-compiling."
echo
echo "Example:"
echo " ./configure --enable-embedded --with-plugins=\"initctl tty\""
echo
echo " ./configure --enable-embedded --with-plugins=\"initctl tty\""
echo
echo "Report bugs to https://github.com/troglobit/finit/issues"
echo
@@ -170,24 +180,24 @@ while [ "$*" != "" ]; do
shift
case $opt in
prefix)
prefix="$arg"
prefix)
prefix="$arg"
;;
sysconfdir)
sysconfdir="$arg"
sysconfdir)
sysconfdir="$arg"
;;
sbindir)
sbindir="$arg"
sbindir)
sbindir="$arg"
;;
libdir)
libdir="$arg"
libdir)
libdir="$arg"
;;
plugindir)
plugindir="$arg"
plugindir)
plugindir="$arg"
;;
with-fifo)
@@ -198,13 +208,13 @@ while [ "$*" != "" ]; do
config="$arg"
;;
with-heading)
heading="\"$arg\""
;;
with-heading)
heading="\"$arg\""
;;
with-randomseed)
random="$arg"
;;
with-randomseed)
random="$arg"
;;
with-plugins)
plugins="$arg"
@@ -214,6 +224,10 @@ while [ "$*" != "" ]; do
rcsd="$arg"
;;
with-console)
console="\"$arg\""
;;
with-sysroot)
sysroot="$arg"
;;
@@ -231,11 +245,15 @@ while [ "$*" != "" ]; do
;;
enable-debug)
debug=1
debug=1
;;
enable-embedded)
embedded=1
embedded=1
;;
enable-dbus)
dbus=1
;;
enable-rw-rootfs)
@@ -243,24 +261,24 @@ while [ "$*" != "" ]; do
;;
enable-quiet)
verbose=0
verbose=0
;;
enable-static)
static=1
static=1
;;
disable-inetd)
inetd=0
inetd=0
;;
disable-kernel-quiet)
kernel_quiet=0
kernel_quiet=0
;;
disable-plugins)
disable_plugins=1
;;
disable-plugins)
disable_plugins=1
;;
help)
usage
@@ -290,38 +308,38 @@ echo "mandir = \$(prefix)/share/man/man8" >> config.mk
echo "FINIT_RCSD = $rcsd" >> config.mk
if [ $inetd -eq 0 ]; then
echo >> config.mk
echo "OBJS := \$(filter-out inetd.o, \$(OBJS))" >> config.mk
echo >> config.mk
echo "OBJS := \$(filter-out inetd.o, \$(OBJS))" >> config.mk
fi
echo >> config.mk
if [ $debug -eq 1 ]; then
echo "CPPFLAGS += -O0 -g" >> config.mk
echo "CPPFLAGS += -O0 -g" >> config.mk
else
echo "CPPFLAGS += -Os" >> config.mk
echo "CPPFLAGS += -Os" >> config.mk
fi
echo >> config.mk
if [ $static -ne 0 ]; then
echo "STATIC = 1" >> config.mk
echo "LDFLAGS += -static" >> config.mk
echo "CPPFLAGS += -DENABLE_STATIC" >> config.mk
echo "PLUGINS = \"\"" >> config.mk
if [ $disable_plugins -ne 1 ]; then
if [ x"$plugins" != x"" ]; then
echo "OBJS += \$(addsuffix .o, \$(addprefix plugins/, $plugins))" >> config.mk
else
echo "tmp += \$(wildcard plugins/*.c)" >> config.mk
echo "OBJS += \$(tmp:.c=.o)" >> config.mk
fi
fi
echo "STATIC = 1" >> config.mk
echo "LDFLAGS += -static" >> config.mk
echo "CPPFLAGS += -DENABLE_STATIC" >> config.mk
echo "PLUGINS = \"\"" >> config.mk
if [ $disable_plugins -ne 1 ]; then
if [ x"$plugins" != x"" ]; then
echo "OBJS += \$(addsuffix .o, \$(addprefix plugins/, $plugins))" >> config.mk
else
echo "tmp += \$(wildcard plugins/*.c)" >> config.mk
echo "OBJS += \$(tmp:.c=.o)" >> config.mk
fi
fi
else
echo "STATIC = 0" >> config.mk
echo "LDFLAGS += -rdynamic" >> config.mk
echo "LDLIBS += -ldl" >> config.mk
if [ x"$plugins" != x"" ]; then
echo "PLUGINS = \$(addsuffix .so, $plugins)" >> config.mk
fi
echo "STATIC = 0" >> config.mk
echo "LDFLAGS += -rdynamic" >> config.mk
echo "LDLIBS += -ldl" >> config.mk
if [ x"$plugins" != x"" ]; then
echo "PLUGINS = \$(addsuffix .so, $plugins)" >> config.mk
fi
fi
echo >> config.mk
@@ -334,24 +352,28 @@ echo "#define INIT_HEADING $heading" >> config.h
echo "#define VERBOSE_MODE $verbose" >> config.h
echo "#define KERNEL_QUIET $kernel_quiet" >> config.h
if [ $embedded -eq 1 ]; then
echo "#define EMBEDDED_SYSTEM 1" >> config.h
echo "#define EMBEDDED_SYSTEM 1" >> config.h
fi
if [ $remount -eq 1 ]; then
echo "#define REMOUNT_ROOTFS 1" >> config.h
echo "#define REMOUNT_ROOTFS 1" >> config.h
fi
if [ $dbus -eq 1 ]; then
echo "#define HAVE_DBUS 1" >> config.h
fi
if [ $inetd -eq 0 ]; then
echo "#define INETD_DISABLED" >> config.h
echo "#define INETD_DISABLED" >> config.h
fi
echo "#define FINIT_FIFO \"$fifo\"" >> config.h
echo "#define FINIT_CONF \"$config\"" >> config.h
echo "#define FINIT_RCSD \"$rcsd\"" >> config.h
echo "#define CONSOLE $console" >> config.h
if [ x"$sysroot" != x"" ]; then
echo "#define SYSROOT \"$sysroot\"" >> config.h
echo "#define SYSROOT \"$sysroot\"" >> config.h
fi
echo "#define PLUGIN_PATH \"$plugindir\"" >> config.h
if [ x"$random" != x"" ]; then
echo "#define RANDOMSEED \"$random\"" >> config.h
echo "#define RANDOMSEED \"$random\"" >> config.h
fi
echo "#define DEFUSER \"$defuser\"" >> config.h
echo "#define DEFHOST \"$defhost\"" >> config.h
-3
View File
@@ -38,18 +38,15 @@
/* Distribution specific configuration */
#if defined EMBEDDED_SYSTEM
# define CONSOLE _PATH_CONSOLE
# define SETUP_DEVFS "/sbin/mdev -s"
# define GETTY "/sbin/getty -L"
# define GETTY_BUSYBOX /* Tell tty.c about the getty argument order */
# define BAUDRATE 115200
#else /* Debian/Ubuntu based distributions */
# define CONSOLE "/dev/tty1"
# define SETUP_DEVFS "/sbin/udevd --daemon"
# define GETTY "/sbin/getty -8"
# define GETTY_AGETTY /* Tell tty.c about the getty argument order */
# define BAUDRATE 38400
# define HAVE_DBUS
#endif
/* If the user configures us to not know about any getty use the system
+3
View File
@@ -21,7 +21,10 @@
* THE SOFTWARE.
*/
#include <sys/types.h>
#include "../finit.h"
#include "../config.h"
#include "../helpers.h"
#include "../plugin.h"
#include "libite/lite.h"