summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-05 20:43:32 +0000
committerRoy Marples <roy@marples.name>2008-01-05 20:43:32 +0000
commite6c9bdf2a30d84e35b783146ebe36314b4269ffb (patch)
treef9a3d84e4e70ae56a8d6b56d30fa4425cea1154c
parentc92be49041a7b56f651a93e71e15e94bc8727489 (diff)
downloadopenrc-e6c9bdf2a30d84e35b783146ebe36314b4269ffb.tar.gz
openrc-e6c9bdf2a30d84e35b783146ebe36314b4269ffb.tar.bz2
openrc-e6c9bdf2a30d84e35b783146ebe36314b4269ffb.tar.xz
Add the missing changes from the recent Makefile updates
-rw-r--r--README6
-rw-r--r--default.mk26
-rw-r--r--src/Makefile188
-rw-r--r--src/libeinfo/libeinfo.c26
-rw-r--r--src/librc/librc.h8
-rw-r--r--src/rc-misc.h1
-rw-r--r--src/rc/checkpath.c4
-rw-r--r--src/rc/fstabinfo.c6
-rw-r--r--src/rc/mountinfo.c6
-rw-r--r--src/rc/rc-depend.c6
-rw-r--r--src/rc/rc-logger.c4
-rw-r--r--src/rc/rc-plugin.c6
-rw-r--r--src/rc/rc-status.c6
-rw-r--r--src/rc/rc-update.c6
-rw-r--r--src/rc/rc.c11
-rw-r--r--src/rc/runscript.c24
-rw-r--r--src/rc/start-stop-daemon.c6
17 files changed, 78 insertions, 262 deletions
diff --git a/README b/README
index ee5556f..8159e5c 100644
--- a/README
+++ b/README
@@ -8,7 +8,7 @@ Yup, that simple. Works with GNU make, FreeBSD make and pmake. Should work
with every other make too.
You may wish to tweak the installation with the below arguments
-BIN_LDFLAGS=-static
+PROGLDFLAGS=-static
LIB=lib64
DESTDIR=/tmp/openrc-image
PAM=pam
@@ -16,7 +16,7 @@ TERMCAP=ncurses
TERMCAP=termcap
We don't support building a static OpenRC with PAM.
-You may need to use BIN_LDFLAGS=-Wl,-Bstatic on glibc instead of just -static.
+You may need to use PROGLDFLAGS=-Wl,-Bstatic on glibc instead of just -static.
You can also brand OpenRC if you so wish like so
BRANDING=\"Gentoo/$(uname -s)\"
@@ -26,12 +26,12 @@ If any of the following files exist then we do not overwrite them
/etc/rc
/etc/rc.shutdown
/etc/conf.d/*
-/etc/inittab
rc and rc.shutdown are the hooks from the BSD init into OpenRC.
devd.conf is modified from FreeBSD to call /etc/rc.devd which is a generic
hook into OpenRC.
inittab is the same, but for SysVInit as used by most Linux distrubtions.
+This can be found in the support folder.
Obviously, if you're installing this onto a system that does not use OpenRC
by default then you may wish to backup the above listed files, remove them
and then install so that the OS hooks into OpenRC.
diff --git a/default.mk b/default.mk
index 8f32e94..580648c 100644
--- a/default.mk
+++ b/default.mk
@@ -22,19 +22,19 @@ CONTENTS = $(_CONTENTS)$(shell $(_CONTENTS_SH))
_+_ ?= +
ECHODIR ?= true
_SUBDIR = @${_+_}for x in ${SUBDIR}; do \
- if test -d $$x; then \
- ${ECHODIR} "===> ${DIRPRFX}$$x ($@)"; \
- cd $$x; \
- ${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \
- cd ..; \
- fi; \
- if test -d $$x.${OS}; then \
- ${ECHODIR} "===> ${DIRPRFX}$$x.${OS} ($@)"; \
- cd $$x.${OS}; \
- ${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \
- cd ..; \
- fi; \
- done
+ if test -d $$x; then \
+ ${ECHODIR} "===> ${DIRPRFX}$$x ($@)"; \
+ cd $$x; \
+ ${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \
+ cd ..; \
+ fi; \
+ if test -d $$x.${OS}; then \
+ ${ECHODIR} "===> ${DIRPRFX}$$x.${OS} ($@)"; \
+ cd $$x.${OS}; \
+ ${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \
+ cd ..; \
+ fi; \
+done
all:
$(_SUBDIR)
diff --git a/src/Makefile b/src/Makefile
index dee2d00..f843a81 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,188 +1,6 @@
# Copyright 2007-2008 Roy Marples
-# We should strive to keep this Makefile working with the default make
-# shipped with the OS's we support. Mainly because I'm lazy and just want
-# to type make instead of gmake, but also so that other distros can pick
-# it up and not rely on GNU Make.
+SUBDIR= libeinfo librc rc
-CC ?= gcc
-AR ?= ar
-RANLIB ?= ranlib
-CFLAGS += -O2 -pipe
-LDFLAGS += -L.
-PICFLAG = -fPIC
-
-# GNU Make way of detecting gcc flags we can use
-check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
- then echo "$(1)"; else echo "$(2)"; fi)
-
-# pmake check for extra cflags
-WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
- if $(CC) $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
- then echo -n "$$x "; fi \
- done
-
-# Loads of nice flags to ensure our code is good
-CFLAGS += -pedantic -std=c99 \
- -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
- -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
- -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
- -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
- $(call check_gcc, -Wdeclaration-after-statement) \
- $(call check_gcc, -Wsequence-point) \
- $(call check_gcc, -Wextra) $(WEXTRA)
-
-# For debugging. -Werror is pointless due to ISO C issues with dlsym
-#CFLAGS += -ggdb
-
-# Set PAM = pam for pam support
-PAM =
-
-# Set TERMCAP = termcap for termcap support
-TERMCAP =
-
-LIBEINFOSOVER = 1
-LIBEINFOSO = libeinfo.so.$(LIBRCSOVER)
-LIBEINFOOBJS= libeinfo.o
-LDLIBS_LIBEINFO =
-
-LIBRCSOVER = 1
-LIBRCSO = librc.so.$(LIBRCSOVER)
-LIBRCOBJS = librc.o librc-depend.o librc-daemon.o librc-misc.o librc-strlist.o
-LDLIBS_LIBRC =
-
-RCOBJS = checkpath.o fstabinfo.o mountinfo.o \
- rc-depend.o rc-logger.o rc-misc.o rc-plugin.o rc-status.o \
- rc-update.o \
- runscript.o start-stop-daemon.o rc.o
-LDLIBS_RC = -leinfo -lrc -lutil
-
-LIB_TARGETS = $(LIBEINFOSO) $(LIBRCSO)
-ULIB_TARGETS = libeinfo.a librc.a
-SBIN_TARGETS = rc
-SYS_WHITELIST = env_whitelist
-
-TARGET = $(LIB_TARGETS) $(ULIB_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS)
-
-RC_BINLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
- eindent eoutdent esyslog eval_ecolors \
- veinfo vewarn vebegin veend vewend veindent veoutdent \
- service_starting service_started \
- service_stopping service_stopped \
- service_inactive service_wasinactive \
- service_coldplugged service_started_daemon \
- checkpath fstabinfo mountinfo rc-depend \
- service_get_value service_set_value get_options save_options \
- shell_var
-RC_SBINLINKS = mark_service_starting mark_service_started \
- mark_service_stopping mark_service_stopped \
- mark_service_inactive mark_service_wasinactive \
- mark_service_coldplugged mark_service_failed \
- rc-abort
-BINLINKS = rc-status
-SBINLINKS = rc-update runscript start-stop-daemon
-ALL_LINKS = $(BINLINKS) $(SBINLINKS) $(RC_BINLINKS) $(RC_SBINLINKS)
-
-CPPFLAGS += -DLIB=\"$(LIB)\"
-
-# IMPORTANT!!!
-# Ensure that we don't ship with a .svn directory to avoid RPATH security
-# issues. However, this does ease development a little
-LDFLAGS += -Wl,-rpath .
-
-# Load an optional Makefiles - the order is important
-TOPDIR = ..
-include $(TOPDIR)/default.mk
-include Makefile.$(TERMCAP)
-include Makefile.$(OS)
-include Makefile.$(PAM)
-
-all: .depend $(TARGET)
-
-version.h:
- sed -n -e 's/^VERSION =[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1\"/p' ../Makefile > version.h
- if test -n "${BRANDING}"; then \
- echo "#define BRANDING \"${BRANDING}\"" >> version.h; \
- fi
-
-.SUFFIXES: .lo
-.c.lo:
- $(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) -c $< -o $@
-.o.a:
- $(AR) rc $@.tmp $^
- $(RANLIB) $@.tmp
- mv $@.tmp $@
-
-LIBEINFOOBJS_SO = $(LIBEINFOOBJS:.o=.lo)
-$(LIBEINFOOBJS): CPPFLAGS += $(CPPFLAGS_LIBEINFO)
-$(LIBEINFOOBJS_SO): CPPFLAGS += $(CPPFLAGS_LIBEINFO)
-$(LIBEINFOSO): einfo.map $(LIBEINFOOBJS_SO)
- $(CC) $(LDFLAGS) $(PICFLAG) -shared \
- -Wl,-soname,$(LIBEINFOSO) \
- -Wl,-version-script einfo.map \
- -o $(LIBEINFOSO) $(LIBEINFOOBJS_SO) $(LDLIBS_LIBEINFO)
- ln -sf $(LIBEINFOSO) libeinfo.so
-libeinfo.a: $(LIBEINFOOBJS)
-
-LIBRCOBJS_SO = $(LIBRCOBJS:.o=.lo)
-$(LIBRCSO): rc.map $(LIBRCOBJS_SO)
- $(CC) $(LDFLAGS) $(PICFLAG) -shared \
- -Wl,-soname,$(LIBRCSO) \
- -Wl,-version-script rc.map \
- -o $(LIBRCSO) $(LIBRCOBJS_SO) $(LDLIBS_LIBRC)
- ln -sf $(LIBRCSO) librc.so
-librc.a: $(LIBRCOBJS)
-
-$(RCOBJS): version.h
-$(RCOBJS): CPPFLAGS += $(CPPFLAGS_SSD)
-rc: $(RCOBJS)
-rc: LDLIBS += $(LDLIBS_RC) $(LIBEINFOSO) $(LIBRCSO)
-rc: LDFLAGS += $(BIN_LDFLAGS)
-
-$(ALL_LINKS): rc
- ln -sf rc $@
-links: $(ALL_LINKS)
-
-install:: $(TARGET)
- install -d $(DESTDIR)/$(LIB)
- install -m 0444 $(LIB_TARGETS) $(DESTDIR)/$(LIB)
- install -d $(DESTDIR)/usr/$(LIB)
- install -m 0444 $(ULIB_TARGETS) $(DESTDIR)/usr/$(LIB)
- ln -sf /$(LIB)/$(LIBEINFOSO) $(DESTDIR)/usr/$(LIB)/libeinfo.so
- ln -sf /$(LIB)/$(LIBRCSO) $(DESTDIR)/usr/$(LIB)/librc.so
- install -d $(DESTDIR)/usr/include
- install -m 0444 einfo.h rc.h $(DESTDIR)/usr/include
- install -d $(DESTDIR)/bin
- install -d $(DESTDIR)/sbin
- install -m 0555 $(SBIN_TARGETS) $(DESTDIR)/sbin
- install -d $(DESTDIR)/$(RC_LIB)/conf.d
- install -m 0444 $(SYS_WHITELIST) $(DESTDIR)/$(RC_LIB)/conf.d
- install -d $(DESTDIR)/$(RC_LIB)/bin
- install -d $(DESTDIR)/$(RC_LIB)/sbin
- for x in $(BINLINKS); do ln -sf /sbin/rc $(DESTDIR)/bin/$$x; done
- for x in $(SBINLINKS); do ln -sf rc $(DESTDIR)/sbin/$$x; done
- for x in $(RC_BINLINKS); do ln -sf /sbin/rc $(DESTDIR)/$(RC_LIB)/bin/$$x; done
- for x in $(RC_SBINLINKS); do ln -sf /sbin/rc $(DESTDIR)/$(RC_LIB)/sbin/$$x; done
- if test "$(PAM)" = "pam"; then \
- install -d $(DESTDIR)/etc/pam.d; \
- install -m 0644 start-stop-daemon.pam $(DESTDIR)/etc/pam.d/start-stop-daemon; \
- fi
-
-clean-links:
- rm -f $(ALL_LINKS)
-clean:: clean-links
- echo > .depend
- touch -r Makefile .depend
- rm -f $(TARGET) version.h
- rm -f *.lo *.o *~ *.core *.so *.a
-
-check:
- $(MAKE) -C test $@
-
-include .depend
-_DEPS != ls *.c *.h
-.depend: version.h $(_DEPS)$(wildcard *.c *.h)
- $(CC) $(CPPFLAGS) -MM *.c > .depend
-
-depend::
- $(CC) $(CPPFLAGS) -MM *.c > .depend
+TOPDIR= ..
+include $(TOPDIR)/subdir.mk
diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c
index d80af9c..14f254e 100644
--- a/src/libeinfo/libeinfo.c
+++ b/src/libeinfo/libeinfo.c
@@ -50,10 +50,7 @@ const char libeinfo_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include <unistd.h>
#include "einfo.h"
-#include "rc.h"
-#include "rc-misc.h"
-
-#include "hidden-visibility.h"
+#include "../hidden-visibility.h"
hidden_proto(ecolor)
hidden_proto(ebegin)
hidden_proto(ebeginv)
@@ -415,19 +412,20 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f)
ee += strlen (ecolors[i].name);
if (ee && *ee == '=') {
+ char *d = strdup (ee + 1);
+ if (d) {
+ char *end = strchr (d, ':');
+ if (end)
+ *end = '\0';
- char *d = xstrdup (ee + 1);
- char *end = strchr (d, ':');
- if (end)
- *end = '\0';
+ c = atoi(d);
- c = atoi(d);
-
- end = strchr (d, ';');
- if (end && *++end == '0')
- bold = _me;
+ end = strchr (d, ';');
+ if (end && *++end == '0')
+ bold = _me;
- free (d);
+ free (d);
+ }
}
}
strlcpy (tmp, tgoto (bold, 0, 0), sizeof (tmp));
diff --git a/src/librc/librc.h b/src/librc/librc.h
index cf61217..32b5000 100644
--- a/src/librc/librc.h
+++ b/src/librc/librc.h
@@ -34,10 +34,10 @@
#define _IN_LIBRC
+#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
@@ -65,10 +65,10 @@
#include "librc-depend.h"
#include "rc.h"
-#include "rc-misc.h"
-#include "strlist.h"
+#include "../rc-misc.h"
+#include "../strlist.h"
-#include "hidden-visibility.h"
+#include "../hidden-visibility.h"
#define librc_hidden_proto(x) hidden_proto(x)
#define librc_hidden_def(x) hidden_def(x)
diff --git a/src/rc-misc.h b/src/rc-misc.h
index 70ddd97..c9f699e 100644
--- a/src/rc-misc.h
+++ b/src/rc-misc.h
@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <stdbool.h>
+#include <string.h>
#ifndef LIB
# define LIB "lib"
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index 612a076..a4d3da1 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -43,8 +43,8 @@
#include <unistd.h>
#include "builtins.h"
-#include "einfo.h"
-#include "rc-misc.h"
+#include "../libeinfo/einfo.h"
+#include "../rc-misc.h"
static const char *applet;
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index 5f8e469..04f0384 100644
--- a/src/rc/fstabinfo.c
+++ b/src/rc/fstabinfo.c
@@ -65,10 +65,10 @@
#endif
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
-#include "strlist.h"
+#include "../rc-misc.h"
+#include "../strlist.h"
#ifdef HAVE_GETMNTENT
static struct mntent *getmntfile (const char *file)
diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 05ce8dd..155e860 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -50,10 +50,10 @@
#include <regex.h>
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
-#include "strlist.h"
+#include "../rc-misc.h"
+#include "../strlist.h"
static const char *applet;
diff --git a/src/rc/rc-depend.c b/src/rc/rc-depend.c
index c5e9e66..da99a5c 100644
--- a/src/rc/rc-depend.c
+++ b/src/rc/rc-depend.c
@@ -40,10 +40,10 @@
#include <string.h>
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
-#include "strlist.h"
+#include "../rc-misc.h"
+#include "../strlist.h"
static const char *applet;
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 675a4d2..133026a 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -48,9 +48,9 @@
# include <libutil.h>
#endif
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc-logger.h"
-#include "rc-misc.h"
+#include "../rc-misc.h"
#include "rc.h"
#define LOGFILE RC_SVCDIR "/rc.log"
diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c
index 613f049..3f59544 100644
--- a/src/rc/rc-plugin.c
+++ b/src/rc/rc-plugin.c
@@ -41,11 +41,11 @@
#include <string.h>
#include <unistd.h>
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
+#include "../rc-misc.h"
#include "rc-plugin.h"
-#include "strlist.h"
+#include "../strlist.h"
#define RC_PLUGIN_HOOK "rc_plugin_hook"
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 155192f..1b943cf 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -36,10 +36,10 @@
#include <unistd.h>
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
-#include "strlist.h"
+#include "../rc-misc.h"
+#include "../strlist.h"
static const char *applet;
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index 4f07503..bbf23af 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -39,10 +39,10 @@
#include <unistd.h>
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
-#include "strlist.h"
+#include "../rc-misc.h"
+#include "../strlist.h"
static const char *applet = NULL;
diff --git a/src/rc/rc.c b/src/rc/rc.c
index a33b6dc..cbb9a15 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -59,12 +59,12 @@ const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include <unistd.h>
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
#include "rc-logger.h"
-#include "rc-misc.h"
+#include "../rc-misc.h"
#include "rc-plugin.h"
-#include "strlist.h"
+#include "../strlist.h"
#include "version.h"
@@ -1063,14 +1063,13 @@ int main (int argc, char **argv)
run_script (INITEARLYSH);
uname (&uts);
- printf ("\n %sOpenRC %s" VERSION "%s is starting up %s",
+ printf ("\n %sOpenRC %s" VERSION "%s is starting up %s\n\n",
#ifdef BRANDING
BRANDING
#else
""
#endif
- "\n\n",
- ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE),
+ , ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE),
ecolor (ECOLOR_NORMAL));
if (! rc_yesno (getenv ("EINFO_QUIET")) &&
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 1385bb0..615b411 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -54,11 +54,11 @@
#endif
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
+#include "../rc-misc.h"
#include "rc-plugin.h"
-#include "strlist.h"
+#include "../strlist.h"
#define SELINUX_LIB RC_LIBDIR "/runscript_selinux.so"
@@ -1080,14 +1080,10 @@ int runscript (int argc, char **argv)
if ((softlevel = xstrdup (getenv ("RC_SOFTLEVEL"))) == NULL) {
/* Ensure our environment is pure
Also, add our configuration to it */
+ char *p;
env = env_filter ();
- tmplist = env_config ();
- rc_strlist_join (&env, tmplist);
- rc_strlist_free (tmplist);
- tmplist = NULL;
if (env) {
- char *p;
#ifdef __linux__
/* clearenv isn't portable, but there's no harm in using it
@@ -1108,12 +1104,16 @@ int runscript (int argc, char **argv)
}
tmp = NULL;
#endif
-
- STRLIST_FOREACH (env, p, i)
- putenv (p);
- /* We don't free our list as that would be null in environ */
}
+ tmplist = env_config ();
+ rc_strlist_join (&env, tmplist);
+ rc_strlist_free (tmplist);
+ tmplist = NULL;
+ STRLIST_FOREACH (env, p, i)
+ putenv (p);
+ /* We don't free our list as that would be null in environ */
+
softlevel = rc_runlevel_get ();
}
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index bf03dbe..bfd9202 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -68,10 +68,10 @@ static struct pam_conv conv = { NULL, NULL};
#endif
#include "builtins.h"
-#include "einfo.h"
+#include "../libeinfo/einfo.h"
#include "rc.h"
-#include "rc-misc.h"
-#include "strlist.h"
+#include "../rc-misc.h"
+#include "../strlist.h"
typedef struct schedulelist
{