Add the missing changes from the recent Makefile updates

This commit is contained in:
Roy Marples 2008-01-05 20:43:32 +00:00
parent c92be49041
commit e6c9bdf2a3
17 changed files with 78 additions and 262 deletions

6
README
View File

@ -8,7 +8,7 @@ Yup, that simple. Works with GNU make, FreeBSD make and pmake. Should work
with every other make too. with every other make too.
You may wish to tweak the installation with the below arguments You may wish to tweak the installation with the below arguments
BIN_LDFLAGS=-static PROGLDFLAGS=-static
LIB=lib64 LIB=lib64
DESTDIR=/tmp/openrc-image DESTDIR=/tmp/openrc-image
PAM=pam PAM=pam
@ -16,7 +16,7 @@ TERMCAP=ncurses
TERMCAP=termcap TERMCAP=termcap
We don't support building a static OpenRC with PAM. 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 You can also brand OpenRC if you so wish like so
BRANDING=\"Gentoo/$(uname -s)\" 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
/etc/rc.shutdown /etc/rc.shutdown
/etc/conf.d/* /etc/conf.d/*
/etc/inittab
rc and rc.shutdown are the hooks from the BSD init into OpenRC. 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 devd.conf is modified from FreeBSD to call /etc/rc.devd which is a generic
hook into OpenRC. hook into OpenRC.
inittab is the same, but for SysVInit as used by most Linux distrubtions. 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 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 by default then you may wish to backup the above listed files, remove them
and then install so that the OS hooks into OpenRC. and then install so that the OS hooks into OpenRC.

View File

@ -22,19 +22,19 @@ CONTENTS = $(_CONTENTS)$(shell $(_CONTENTS_SH))
_+_ ?= + _+_ ?= +
ECHODIR ?= true ECHODIR ?= true
_SUBDIR = @${_+_}for x in ${SUBDIR}; do \ _SUBDIR = @${_+_}for x in ${SUBDIR}; do \
if test -d $$x; then \ if test -d $$x; then \
${ECHODIR} "===> ${DIRPRFX}$$x ($@)"; \ ${ECHODIR} "===> ${DIRPRFX}$$x ($@)"; \
cd $$x; \ cd $$x; \
${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \ ${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \
cd ..; \ cd ..; \
fi; \ fi; \
if test -d $$x.${OS}; then \ if test -d $$x.${OS}; then \
${ECHODIR} "===> ${DIRPRFX}$$x.${OS} ($@)"; \ ${ECHODIR} "===> ${DIRPRFX}$$x.${OS} ($@)"; \
cd $$x.${OS}; \ cd $$x.${OS}; \
${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \ ${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \
cd ..; \ cd ..; \
fi; \ fi; \
done done
all: all:
$(_SUBDIR) $(_SUBDIR)

View File

@ -1,188 +1,6 @@
# Copyright 2007-2008 Roy Marples # Copyright 2007-2008 Roy Marples
# We should strive to keep this Makefile working with the default make SUBDIR= libeinfo librc rc
# 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.
CC ?= gcc TOPDIR= ..
AR ?= ar include $(TOPDIR)/subdir.mk
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

View File

@ -50,10 +50,7 @@ const char libeinfo_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include <unistd.h> #include <unistd.h>
#include "einfo.h" #include "einfo.h"
#include "rc.h" #include "../hidden-visibility.h"
#include "rc-misc.h"
#include "hidden-visibility.h"
hidden_proto(ecolor) hidden_proto(ecolor)
hidden_proto(ebegin) hidden_proto(ebegin)
hidden_proto(ebeginv) hidden_proto(ebeginv)
@ -415,19 +412,20 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f)
ee += strlen (ecolors[i].name); ee += strlen (ecolors[i].name);
if (ee && *ee == '=') { if (ee && *ee == '=') {
char *d = strdup (ee + 1);
if (d) {
char *end = strchr (d, ':');
if (end)
*end = '\0';
char *d = xstrdup (ee + 1); c = atoi(d);
char *end = strchr (d, ':');
if (end)
*end = '\0';
c = atoi(d); end = strchr (d, ';');
if (end && *++end == '0')
end = strchr (d, ';'); bold = _me;
if (end && *++end == '0')
bold = _me;
free (d); free (d);
}
} }
} }
strlcpy (tmp, tgoto (bold, 0, 0), sizeof (tmp)); strlcpy (tmp, tgoto (bold, 0, 0), sizeof (tmp));

View File

@ -34,10 +34,10 @@
#define _IN_LIBRC #define _IN_LIBRC
#include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <dirent.h> #include <dirent.h>
@ -65,10 +65,10 @@
#include "librc-depend.h" #include "librc-depend.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "strlist.h" #include "../strlist.h"
#include "hidden-visibility.h" #include "../hidden-visibility.h"
#define librc_hidden_proto(x) hidden_proto(x) #define librc_hidden_proto(x) hidden_proto(x)
#define librc_hidden_def(x) hidden_def(x) #define librc_hidden_def(x) hidden_def(x)

View File

@ -35,6 +35,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h>
#ifndef LIB #ifndef LIB
# define LIB "lib" # define LIB "lib"

View File

@ -43,8 +43,8 @@
#include <unistd.h> #include <unistd.h>
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc-misc.h" #include "../rc-misc.h"
static const char *applet; static const char *applet;

View File

@ -65,10 +65,10 @@
#endif #endif
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "strlist.h" #include "../strlist.h"
#ifdef HAVE_GETMNTENT #ifdef HAVE_GETMNTENT
static struct mntent *getmntfile (const char *file) static struct mntent *getmntfile (const char *file)

View File

@ -50,10 +50,10 @@
#include <regex.h> #include <regex.h>
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "strlist.h" #include "../strlist.h"
static const char *applet; static const char *applet;

View File

@ -40,10 +40,10 @@
#include <string.h> #include <string.h>
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "strlist.h" #include "../strlist.h"
static const char *applet; static const char *applet;

View File

@ -48,9 +48,9 @@
# include <libutil.h> # include <libutil.h>
#endif #endif
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc-logger.h" #include "rc-logger.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "rc.h" #include "rc.h"
#define LOGFILE RC_SVCDIR "/rc.log" #define LOGFILE RC_SVCDIR "/rc.log"

View File

@ -41,11 +41,11 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "rc-plugin.h" #include "rc-plugin.h"
#include "strlist.h" #include "../strlist.h"
#define RC_PLUGIN_HOOK "rc_plugin_hook" #define RC_PLUGIN_HOOK "rc_plugin_hook"

View File

@ -36,10 +36,10 @@
#include <unistd.h> #include <unistd.h>
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "strlist.h" #include "../strlist.h"
static const char *applet; static const char *applet;

View File

@ -39,10 +39,10 @@
#include <unistd.h> #include <unistd.h>
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "strlist.h" #include "../strlist.h"
static const char *applet = NULL; static const char *applet = NULL;

View File

@ -59,12 +59,12 @@ const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include <unistd.h> #include <unistd.h>
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-logger.h" #include "rc-logger.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "rc-plugin.h" #include "rc-plugin.h"
#include "strlist.h" #include "../strlist.h"
#include "version.h" #include "version.h"
@ -1063,14 +1063,13 @@ int main (int argc, char **argv)
run_script (INITEARLYSH); run_script (INITEARLYSH);
uname (&uts); 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 #ifdef BRANDING
BRANDING BRANDING
#else #else
"" ""
#endif #endif
"\n\n", , ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE),
ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE),
ecolor (ECOLOR_NORMAL)); ecolor (ECOLOR_NORMAL));
if (! rc_yesno (getenv ("EINFO_QUIET")) && if (! rc_yesno (getenv ("EINFO_QUIET")) &&

View File

@ -54,11 +54,11 @@
#endif #endif
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "rc-plugin.h" #include "rc-plugin.h"
#include "strlist.h" #include "../strlist.h"
#define SELINUX_LIB RC_LIBDIR "/runscript_selinux.so" #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) { if ((softlevel = xstrdup (getenv ("RC_SOFTLEVEL"))) == NULL) {
/* Ensure our environment is pure /* Ensure our environment is pure
Also, add our configuration to it */ Also, add our configuration to it */
char *p;
env = env_filter (); env = env_filter ();
tmplist = env_config ();
rc_strlist_join (&env, tmplist);
rc_strlist_free (tmplist);
tmplist = NULL;
if (env) { if (env) {
char *p;
#ifdef __linux__ #ifdef __linux__
/* clearenv isn't portable, but there's no harm in using it /* clearenv isn't portable, but there's no harm in using it
@ -1108,12 +1104,16 @@ int runscript (int argc, char **argv)
} }
tmp = NULL; tmp = NULL;
#endif #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 (); softlevel = rc_runlevel_get ();
} }

View File

@ -68,10 +68,10 @@ static struct pam_conv conv = { NULL, NULL};
#endif #endif
#include "builtins.h" #include "builtins.h"
#include "einfo.h" #include "../libeinfo/einfo.h"
#include "rc.h" #include "rc.h"
#include "rc-misc.h" #include "../rc-misc.h"
#include "strlist.h" #include "../strlist.h"
typedef struct schedulelist typedef struct schedulelist
{ {