diff --git a/Makefile.am b/Makefile.am index e3124c9b..ebe505ca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,105 +1,11 @@ ACLOCAL_AMFLAGS = -I m4 -sbin_PROGRAMS = finit initctl reboot -finit_SOURCES = api.c \ - cond.c cond-w.c cond.h \ - client.c \ - conf.c conf.h \ - exec.c finit.c finit.h \ - getty.c \ - helpers.c helpers.h \ - mdadm.c mount.c pid.c \ - plugin.c plugin.h private.h \ - service.c service.h \ - sig.c sig.h \ - sm.c sm.h \ - svc.c svc.h \ - tty.c tty.h \ - util.c util.h \ - utmp-api.c utmp-api.h -pkginclude_HEADERS = cond.h finit.h helpers.h inetd.h plugin.h svc.h -if INETD -finit_SOURCES += inetd.c inetd.h -endif -if WATCHDOGD -finit_SOURCES += watchdog.c watchdog.h -endif - -finit_CFLAGS = -W -Wall -Wextra -std=gnu99 $(lite_CFLAGS) $(uev_CFLAGS) -finit_LDADD = $(lite_LIBS) $(uev_LIBS) -if STATIC -finit_LDADD += plugins/libplug.la -else -finit_LDADD += -ldl -endif - -initctl_SOURCES = initctl.c svc.c svc.h helpers.c helpers.h cond.c cond.h \ - util.c util.h utmp-api.c utmp-api.h -initctl_CFLAGS = $(lite_CFLAGS) -initctl_LDADD = $(lite_LIBS) - -reboot_SOURCES = reboot.c util.c util.h - -INIT_LNKS = telinit init -REBOOT_LNKS = shutdown halt poweroff suspend -SUBDIRS = plugins +SUBDIRS = plugins src doc_DATA = README.md LICENSE finit.conf EXTRA_DIST = README.md LICENSE ChangeLog.md finit.conf -AM_CPPFLAGS = -U_FORTIFY_SOURCE -AM_CPPFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_GNU_SOURCE -D_DEFAULT_SOURCE - -if STATIC -AM_CPPFLAGS += -DENABLE_STATIC -AM_LDFLAGS = -static-libtool-libs -else -AM_CPPFLAGS += -DPLUGIN_PATH=\"$(pkglibdir)\" -AM_LDFLAGS = -export-dynamic -endif # Compat hook -install-dev: install-pkgincludeHEADERS - -# Hook in install to add finit and reboot symlink(s) -install-exec-hook: - @for file in $(INIT_LNKS); do \ - lnk=$(DESTDIR)$(sbindir)/$$file; \ - if [ -e $$lnk ]; then \ - echo "Skipping $$lnk exists already."; \ - else \ - $(LN_S) finit $$lnk; \ - fi; \ - done - @if [ -L $(DESTDIR)$(sbindir)/reboot ]; then \ - echo "Non-finit reboot, skipping install."; \ - else \ - for file in $(REBOOT_LNKS); do \ - link=$(DESTDIR)$(sbindir)/$$file; \ - if [ -e $$link ]; then \ - echo "$$link exists, skipping.";\ - else \ - $(LN_S) reboot $$link; \ - fi; \ - done; \ - fi - -uninstall-hook: - @for file in $(INIT_LNKS); do \ - lnk=`readlink $(DESTDIR)$(sbindir)/$$file`; \ - if [ "$$lnk" != "finit" ]; then \ - echo "Skipping non-finit $$file."; \ - continue; \ - fi; \ - $(RM) $(DESTDIR)$(sbindir)/$$file; \ - done - @if [ -L $(DESTDIR)$(sbindir)/reboot ]; then \ - echo "Non-finit reboot, skipping uninstall."; \ - else \ - for file in $(REBOOT_LNKS); do \ - if [ "`readlink $$file`" != "reboot" ]; \ - then continue; \ - fi; \ - $(RM) $(DESTDIR)$(sbindir)/$$file; \ - done; \ - fi +install-dev: + @make -C src install-pkgincludeHEADERS # Target to run when building a release release: dist diff --git a/configure.ac b/configure.ac index be981838..e8317b3e 100644 --- a/configure.ac +++ b/configure.ac @@ -2,9 +2,9 @@ AC_INIT(Finit, 3.0-rc2, https://github.com/troglobit/finit/issues, finit, http:/ AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz subdir-objects]) AM_SILENT_RULES([yes]) -AC_CONFIG_SRCDIR([finit.c]) +AC_CONFIG_SRCDIR([src/finit.c]) AC_CONFIG_HEADER([config.h]) -AC_CONFIG_FILES([Makefile plugins/Makefile]) +AC_CONFIG_FILES([Makefile plugins/Makefile src/Makefile]) # Older versions of autoconf (<2.58) do not have AC_CONFIG_MACRO_DIR() #m4_include([m4/plugin.m4]) diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 616ee071..275b6b39 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1,6 +1,6 @@ AM_LDFLAGS = -module -avoid-version -shared AM_CFLAGS = -W -Wall -Wextra -std=gnu99 -AM_CPPFLAGS = -U_FORTIFY_SOURCE +AM_CPPFLAGS = -I../src -U_FORTIFY_SOURCE AM_CPPFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_GNU_SOURCE -D_DEFAULT_SOURCE AM_CPPFLAGS += $(lite_CFLAGS) diff --git a/plugins/alsa-utils.c b/plugins/alsa-utils.c index ff583c80..2f1d4c0e 100644 --- a/plugins/alsa-utils.c +++ b/plugins/alsa-utils.c @@ -22,9 +22,9 @@ */ #include -#include "../finit.h" -#include "../helpers.h" -#include "../plugin.h" +#include "finit.h" +#include "helpers.h" +#include "plugin.h" #define ALSACTL "/usr/sbin/alsactl" diff --git a/plugins/bootmisc.c b/plugins/bootmisc.c index c60c2d6c..4305c658 100644 --- a/plugins/bootmisc.c +++ b/plugins/bootmisc.c @@ -26,11 +26,11 @@ #include #include -#include "../config.h" -#include "../finit.h" -#include "../helpers.h" -#include "../plugin.h" -#include "../utmp-api.h" +#include "config.h" +#include "finit.h" +#include "helpers.h" +#include "plugin.h" +#include "utmp-api.h" static int is_tmpfs(char *path) { diff --git a/plugins/chargen.c b/plugins/chargen.c index bea15a02..f99594bb 100644 --- a/plugins/chargen.c +++ b/plugins/chargen.c @@ -25,7 +25,7 @@ #include /* STDIN_FILENO */ #include -#include "../plugin.h" +#include "plugin.h" #define NAME "chargen" #define PATTERN "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " diff --git a/plugins/daytime.c b/plugins/daytime.c index 929c9c1f..b0a3a1de 100644 --- a/plugins/daytime.c +++ b/plugins/daytime.c @@ -26,7 +26,7 @@ #include /* STDIN_FILENO */ #include -#include "../plugin.h" +#include "plugin.h" #define NAME "daytime" diff --git a/plugins/dbus.c b/plugins/dbus.c index 8b95bbb5..2bf6b320 100644 --- a/plugins/dbus.c +++ b/plugins/dbus.c @@ -24,10 +24,10 @@ #include #include -#include "../finit.h" -#include "../config.h" -#include "../helpers.h" -#include "../plugin.h" +#include "finit.h" +#include "config.h" +#include "helpers.h" +#include "plugin.h" static void setup(void *UNUSED(arg)) { diff --git a/plugins/discard.c b/plugins/discard.c index beb386ad..04b8f9d1 100644 --- a/plugins/discard.c +++ b/plugins/discard.c @@ -25,7 +25,7 @@ #include /* STDIN_FILENO */ #include -#include "../plugin.h" +#include "plugin.h" static int cb(int UNUSED(type)) { diff --git a/plugins/echo.c b/plugins/echo.c index 0c6c5dcd..5019a0ad 100644 --- a/plugins/echo.c +++ b/plugins/echo.c @@ -25,7 +25,7 @@ #include /* STDIN_FILENO */ #include -#include "../plugin.h" +#include "plugin.h" #define NAME "echo" diff --git a/plugins/hwclock.c b/plugins/hwclock.c index 75a93a32..6cda556f 100644 --- a/plugins/hwclock.c +++ b/plugins/hwclock.c @@ -23,9 +23,9 @@ #include -#include "../finit.h" -#include "../helpers.h" -#include "../plugin.h" +#include "finit.h" +#include "helpers.h" +#include "plugin.h" static void save(void *UNUSED(arg)) { diff --git a/plugins/initctl.c b/plugins/initctl.c index d1d5f81d..a25fc159 100644 --- a/plugins/initctl.c +++ b/plugins/initctl.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "../config.h" /* Generated by configure script */ +#include "config.h" /* Generated by configure script */ #include #include /* O_RDONLY et al */ @@ -32,12 +32,12 @@ #include #include -#include "../finit.h" -#include "../conf.h" -#include "../helpers.h" -#include "../plugin.h" -#include "../sig.h" -#include "../service.h" +#include "finit.h" +#include "conf.h" +#include "helpers.h" +#include "plugin.h" +#include "sig.h" +#include "service.h" static void parse(void *arg, int fd, int events); static void setup(void *arg); diff --git a/plugins/lost.c b/plugins/lost.c index e2a2a3f6..83970dc5 100644 --- a/plugins/lost.c +++ b/plugins/lost.c @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -#include "../finit.h" -#include "../svc.h" -#include "../plugin.h" +#include "finit.h" +#include "svc.h" +#include "plugin.h" static void lost_pid(void *arg) { diff --git a/plugins/netlink.c b/plugins/netlink.c index d5b4ce34..18466335 100644 --- a/plugins/netlink.c +++ b/plugins/netlink.c @@ -25,10 +25,10 @@ #include #include -#include "../finit.h" -#include "../cond.h" -#include "../helpers.h" -#include "../plugin.h" +#include "finit.h" +#include "cond.h" +#include "helpers.h" +#include "plugin.h" static int nlmsg_validate(struct nlmsghdr *nh, size_t len) { diff --git a/plugins/pidfile.c b/plugins/pidfile.c index 7bd0c8d0..2c880ba1 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -26,11 +26,11 @@ #include -#include "../finit.h" -#include "../cond.h" -#include "../helpers.h" -#include "../plugin.h" -#include "../service.h" +#include "finit.h" +#include "cond.h" +#include "helpers.h" +#include "plugin.h" +#include "service.h" struct context { int fd; diff --git a/plugins/procps.c b/plugins/procps.c index 5159f4aa..1cb5fe4e 100644 --- a/plugins/procps.c +++ b/plugins/procps.c @@ -23,7 +23,7 @@ #include #include -#include "../plugin.h" +#include "plugin.h" static void setup(void *UNUSED(arg)) { diff --git a/plugins/resolvconf.c b/plugins/resolvconf.c index b7d80257..86cd263d 100644 --- a/plugins/resolvconf.c +++ b/plugins/resolvconf.c @@ -23,9 +23,9 @@ #include -#include "../finit.h" -#include "../helpers.h" -#include "../plugin.h" +#include "finit.h" +#include "helpers.h" +#include "plugin.h" /* * No need to clean up files in /etc/resolvconf/run/interface/ diff --git a/plugins/time.c b/plugins/time.c index a1048187..6c088bee 100644 --- a/plugins/time.c +++ b/plugins/time.c @@ -26,7 +26,7 @@ #include /* STDIN_FILENO */ #include -#include "../plugin.h" +#include "plugin.h" #define NAME "time" diff --git a/plugins/tty.c b/plugins/tty.c index 734706d2..18c61c65 100644 --- a/plugins/tty.c +++ b/plugins/tty.c @@ -29,10 +29,10 @@ #include #include -#include "../finit.h" -#include "../helpers.h" -#include "../plugin.h" -#include "../tty.h" +#include "finit.h" +#include "helpers.h" +#include "plugin.h" +#include "tty.h" static void watcher(void *arg, int fd, int events); diff --git a/plugins/urandom.c b/plugins/urandom.c index 149005c1..bd54f9a0 100644 --- a/plugins/urandom.c +++ b/plugins/urandom.c @@ -27,10 +27,10 @@ #include #include -#include "../config.h" -#include "../finit.h" -#include "../helpers.h" -#include "../plugin.h" +#include "config.h" +#include "finit.h" +#include "helpers.h" +#include "plugin.h" static void setup(void *UNUSED(arg)) { diff --git a/plugins/x11-common.c b/plugins/x11-common.c index b096a345..def411ce 100644 --- a/plugins/x11-common.c +++ b/plugins/x11-common.c @@ -26,9 +26,9 @@ #include #include -#include "../finit.h" -#include "../helpers.h" -#include "../plugin.h" +#include "finit.h" +#include "helpers.h" +#include "plugin.h" static void setup(void *UNUSED(arg)) { diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 00000000..30fda3c1 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,95 @@ +AM_CPPFLAGS = -U_FORTIFY_SOURCE +AM_CPPFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_GNU_SOURCE -D_DEFAULT_SOURCE +if STATIC +AM_CPPFLAGS += -DENABLE_STATIC +AM_LDFLAGS = -static-libtool-libs +else +AM_CPPFLAGS += -DPLUGIN_PATH=\"$(pkglibdir)\" +AM_LDFLAGS = -export-dynamic +endif + +sbin_PROGRAMS = finit initctl reboot +finit_SOURCES = api.c \ + cond.c cond-w.c cond.h \ + client.c \ + conf.c conf.h \ + exec.c finit.c finit.h \ + getty.c \ + helpers.c helpers.h \ + mdadm.c mount.c pid.c \ + plugin.c plugin.h private.h \ + service.c service.h \ + sig.c sig.h \ + sm.c sm.h \ + svc.c svc.h \ + tty.c tty.h \ + util.c util.h \ + utmp-api.c utmp-api.h +pkginclude_HEADERS = cond.h finit.h helpers.h inetd.h plugin.h svc.h +if INETD +finit_SOURCES += inetd.c inetd.h +endif +if WATCHDOGD +finit_SOURCES += watchdog.c watchdog.h +endif + +finit_CFLAGS = -W -Wall -Wextra -std=gnu99 $(lite_CFLAGS) $(uev_CFLAGS) +finit_LDADD = $(lite_LIBS) $(uev_LIBS) +if STATIC +finit_LDADD += plugins/libplug.la +else +finit_LDADD += -ldl +endif + +initctl_SOURCES = initctl.c svc.c svc.h helpers.c helpers.h cond.c cond.h \ + util.c util.h utmp-api.c utmp-api.h +initctl_CFLAGS = $(lite_CFLAGS) +initctl_LDADD = $(lite_LIBS) + +reboot_SOURCES = reboot.c util.c util.h + +INIT_LNKS = telinit init +REBOOT_LNKS = shutdown halt poweroff suspend + +# Hook in install to add finit and reboot symlink(s) +install-exec-hook: + @for file in $(INIT_LNKS); do \ + lnk=$(DESTDIR)$(sbindir)/$$file; \ + if [ -e $$lnk ]; then \ + echo "Skipping $$lnk exists already."; \ + else \ + $(LN_S) finit $$lnk; \ + fi; \ + done + @if [ -L $(DESTDIR)$(sbindir)/reboot ]; then \ + echo "Non-finit reboot, skipping install."; \ + else \ + for file in $(REBOOT_LNKS); do \ + link=$(DESTDIR)$(sbindir)/$$file; \ + if [ -e $$link ]; then \ + echo "$$link exists, skipping.";\ + else \ + $(LN_S) reboot $$link; \ + fi; \ + done; \ + fi + +uninstall-hook: + @for file in $(INIT_LNKS); do \ + lnk=`readlink $(DESTDIR)$(sbindir)/$$file`; \ + if [ "$$lnk" != "finit" ]; then \ + echo "Skipping non-finit $$file."; \ + continue; \ + fi; \ + $(RM) $(DESTDIR)$(sbindir)/$$file; \ + done + @if [ -L $(DESTDIR)$(sbindir)/reboot ]; then \ + echo "Non-finit reboot, skipping uninstall."; \ + else \ + for file in $(REBOOT_LNKS); do \ + if [ "`readlink $$file`" != "reboot" ]; \ + then continue; \ + fi; \ + $(RM) $(DESTDIR)$(sbindir)/$$file; \ + done; \ + fi diff --git a/api.c b/src/api.c similarity index 100% rename from api.c rename to src/api.c diff --git a/client.c b/src/client.c similarity index 100% rename from client.c rename to src/client.c diff --git a/cond-w.c b/src/cond-w.c similarity index 100% rename from cond-w.c rename to src/cond-w.c diff --git a/cond.c b/src/cond.c similarity index 100% rename from cond.c rename to src/cond.c diff --git a/cond.h b/src/cond.h similarity index 100% rename from cond.h rename to src/cond.h diff --git a/conf.c b/src/conf.c similarity index 100% rename from conf.c rename to src/conf.c diff --git a/conf.h b/src/conf.h similarity index 100% rename from conf.h rename to src/conf.h diff --git a/exec.c b/src/exec.c similarity index 100% rename from exec.c rename to src/exec.c diff --git a/finit.c b/src/finit.c similarity index 100% rename from finit.c rename to src/finit.c diff --git a/finit.h b/src/finit.h similarity index 100% rename from finit.h rename to src/finit.h diff --git a/getty.c b/src/getty.c similarity index 100% rename from getty.c rename to src/getty.c diff --git a/helpers.c b/src/helpers.c similarity index 100% rename from helpers.c rename to src/helpers.c diff --git a/helpers.h b/src/helpers.h similarity index 100% rename from helpers.h rename to src/helpers.h diff --git a/inetd.c b/src/inetd.c similarity index 100% rename from inetd.c rename to src/inetd.c diff --git a/inetd.h b/src/inetd.h similarity index 100% rename from inetd.h rename to src/inetd.h diff --git a/initctl.c b/src/initctl.c similarity index 100% rename from initctl.c rename to src/initctl.c diff --git a/mdadm.c b/src/mdadm.c similarity index 100% rename from mdadm.c rename to src/mdadm.c diff --git a/mount.c b/src/mount.c similarity index 100% rename from mount.c rename to src/mount.c diff --git a/pid.c b/src/pid.c similarity index 100% rename from pid.c rename to src/pid.c diff --git a/plugin.c b/src/plugin.c similarity index 100% rename from plugin.c rename to src/plugin.c diff --git a/plugin.h b/src/plugin.h similarity index 100% rename from plugin.h rename to src/plugin.h diff --git a/private.h b/src/private.h similarity index 100% rename from private.h rename to src/private.h diff --git a/reboot.c b/src/reboot.c similarity index 100% rename from reboot.c rename to src/reboot.c diff --git a/service.c b/src/service.c similarity index 100% rename from service.c rename to src/service.c diff --git a/service.h b/src/service.h similarity index 100% rename from service.h rename to src/service.h diff --git a/sig.c b/src/sig.c similarity index 100% rename from sig.c rename to src/sig.c diff --git a/sig.h b/src/sig.h similarity index 100% rename from sig.h rename to src/sig.h diff --git a/sm.c b/src/sm.c similarity index 100% rename from sm.c rename to src/sm.c diff --git a/sm.h b/src/sm.h similarity index 100% rename from sm.h rename to src/sm.h diff --git a/svc.c b/src/svc.c similarity index 100% rename from svc.c rename to src/svc.c diff --git a/svc.h b/src/svc.h similarity index 100% rename from svc.h rename to src/svc.h diff --git a/tty.c b/src/tty.c similarity index 100% rename from tty.c rename to src/tty.c diff --git a/tty.h b/src/tty.h similarity index 100% rename from tty.h rename to src/tty.h diff --git a/util.c b/src/util.c similarity index 100% rename from util.c rename to src/util.c diff --git a/util.h b/src/util.h similarity index 100% rename from util.h rename to src/util.h diff --git a/utmp-api.c b/src/utmp-api.c similarity index 100% rename from utmp-api.c rename to src/utmp-api.c diff --git a/utmp-api.h b/src/utmp-api.h similarity index 100% rename from utmp-api.h rename to src/utmp-api.h diff --git a/watchdog.c b/src/watchdog.c similarity index 100% rename from watchdog.c rename to src/watchdog.c diff --git a/watchdog.h b/src/watchdog.h similarity index 100% rename from watchdog.h rename to src/watchdog.h