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.
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.

View File

@ -34,7 +34,7 @@ _SUBDIR = @${_+_}for x in ${SUBDIR}; do \
${MAKE} $@ DIRPRFX=${DIRPRFX}$$x/ || exit $$?; \
cd ..; \
fi; \
done
done
all:
$(_SUBDIR)

View File

@ -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

View File

@ -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,8 +412,8 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f)
ee += strlen (ecolors[i].name);
if (ee && *ee == '=') {
char *d = xstrdup (ee + 1);
char *d = strdup (ee + 1);
if (d) {
char *end = strchr (d, ':');
if (end)
*end = '\0';
@ -430,6 +427,7 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f)
free (d);
}
}
}
strlcpy (tmp, tgoto (bold, 0, 0), sizeof (tmp));
strlcat (tmp, tgoto (_af, 0, c & 0x07), sizeof (tmp));
} else

View File

@ -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)

View File

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

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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"

View File

@ -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"

View File

@ -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;

View File

@ -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;

View File

@ -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")) &&

View File

@ -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,11 +1104,15 @@ int runscript (int argc, char **argv)
}
tmp = NULL;
#endif
}
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 ();
}

View File

@ -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
{