aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-02-28 11:08:49 +0000
committerRoy Marples <roy@marples.name>2008-02-28 11:08:49 +0000
commitf092045650faad778d25d000d80b3128664d2e2a (patch)
tree89188e92a4d01423ee59e33e5eaf5355fa14d103 /src
parentaabf3976db5ffb41f8f8bbd47f5015b4158e095a (diff)
Support the use of PREFIX and PKG_PREFIX.
Diffstat (limited to 'src')
-rw-r--r--src/includes/rc-misc.h25
-rw-r--r--src/libeinfo/Makefile2
-rw-r--r--src/librc/Makefile2
-rw-r--r--src/librc/librc-depend.c8
-rw-r--r--src/librc/librc.c12
-rw-r--r--src/rc/Makefile23
6 files changed, 45 insertions, 27 deletions
diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h
index f80684b0..4ba0f839 100644
--- a/src/includes/rc-misc.h
+++ b/src/includes/rc-misc.h
@@ -38,21 +38,30 @@
#include <string.h>
#ifndef LIB
-# define LIB "lib"
+# define LIB "lib"
+#endif
+
+#ifndef PREFIX
+# define PREFIX ""
#endif
#define RC_LEVEL_BOOT "boot"
#define RC_LEVEL_DEFAULT "default"
-#define RC_LIBDIR "/" LIB "/rc"
+#define RC_LIBDIR PREFIX "/" LIB "/rc"
#define RC_SVCDIR RC_LIBDIR "/init.d"
#define RC_DEPTREE RC_SVCDIR "/deptree"
-#define RC_RUNLEVELDIR "/etc/runlevels"
-#define RC_INITDIR "/etc/init.d"
-#define RC_CONFDIR "/etc/conf.d"
-
-#define RC_INITDIR_LOCAL "/usr/local/etc/init.d"
-#define RC_CONFDIR_LOCAL "/usr/local/etc/conf.d"
+#define RC_RUNLEVELDIR PREFIX "/etc/runlevels"
+#define RC_INITDIR PREFIX "/etc/init.d"
+#define RC_CONFDIR PREFIX "/etc/conf.d"
+
+/* PKG_PREFIX is where packages are installed if different from the base OS
+ * On Gentoo this is normally unset, on FreeBSD /usr/local and on NetBSD
+ * /usr/pkg. */
+#ifdef PKG_PREFIX
+# define RC_PKG_INITDIR PKG_PREFIX "/etc/init.d"
+# define RC_PKG_CONFDIR PKG_PREFIX "/usr/local/etc/conf.d"
+#endif
#define RC_KSOFTLEVEL RC_SVCDIR "/ksoftlevel"
#define RC_STARTING RC_SVCDIR "/rc.starting"
diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile
index bf3a0f61..b40266f5 100644
--- a/src/libeinfo/Makefile
+++ b/src/libeinfo/Makefile
@@ -7,8 +7,6 @@ SRCS= libeinfo.c
INCS= einfo.h
VERSION_MAP= einfo.map
-SHLIBDIR= /${LIBNAME}
-
CFLAGS+= -I../includes
include ${MK}/cc.mk
diff --git a/src/librc/Makefile b/src/librc/Makefile
index 888155b8..880a56e7 100644
--- a/src/librc/Makefile
+++ b/src/librc/Makefile
@@ -13,7 +13,5 @@ LDADD+= ${LIBKVM}
CFLAGS+= -I../includes
-SHLIBDIR= /${LIBNAME}
-
include ${MK}/cc.mk
include ${MK}/lib.mk
diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index cf978d63..1ab2b604 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -696,8 +696,12 @@ bool rc_deptree_update_needed (void)
if (! existss (RC_DEPTREE) ||
! rc_newer_than (RC_DEPTREE, RC_INITDIR) ||
! rc_newer_than (RC_DEPTREE, RC_CONFDIR) ||
- ! rc_newer_than (RC_DEPTREE, RC_INITDIR_LOCAL) ||
- ! rc_newer_than (RC_DEPTREE, RC_CONFDIR_LOCAL) ||
+#ifdef RC_PKG_INITDIR
+ ! rc_newer_than (RC_DEPTREE, RC_PKG_INITDIR) ||
+#endif
+#ifdef RC_PKG_CONFDIR
+ ! rc_newer_than (RC_DEPTREE, RC_PKG_CONFDIR) ||
+#endif
! rc_newer_than (RC_DEPTREE, "/etc/rc.conf"))
return (true);
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 12d31348..552e083d 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -328,11 +328,13 @@ char *rc_service_resolve (const char *service)
snprintf (buffer, sizeof (buffer), RC_INITDIR "/%s", service);
/* So we don't exist in /etc/init.d - check /usr/local/etc/init.d */
+#ifdef RC_PKG_INITDIR
if (stat (buffer, &buf) != 0) {
- snprintf (buffer, sizeof (buffer), RC_INITDIR_LOCAL "/%s", service);
+ snprintf (buffer, sizeof (buffer), RC_PKG_INITDIR "/%s", service);
if (stat (buffer, &buf) != 0)
return (NULL);
}
+#endif
return (xstrdup (buffer));
}
@@ -781,12 +783,18 @@ char **rc_services_in_runlevel (const char *runlevel)
if (! runlevel) {
int i;
- char **local = ls_dir (RC_INITDIR_LOCAL, LS_INITD);
+#ifdef RC_PKG_INITDIR
+ char **local = ls_dir (RC_PKG_INITDIR, LS_INITD);
+#endif
list = ls_dir (RC_INITDIR, LS_INITD);
+
+#ifdef RC_PKG_INITDIR
STRLIST_FOREACH (local, dir, i)
rc_strlist_addsortu (&list, dir);
rc_strlist_free (local);
+#endif
+
return (list);
}
diff --git a/src/rc/Makefile b/src/rc/Makefile
index d87e728b..fea22214 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -6,9 +6,10 @@ SRCS= checkpath.c fstabinfo.c mountinfo.c \
CLEANFILES= version.h
-BINDIR?= /sbin
+BINDIR= ${PREFIX}/bin
+SBINDIR= ${PREFIX}/sbin
+LINKDIR= ${PREFIX}/${LIBNAME}/${PROG}
-LINKDIR= ${LIBNAME}/${PROG}
BINLINKS= rc-status
SBINLINKS= rc-update runscript start-stop-daemon
RC_BINLINKS= einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
@@ -50,16 +51,16 @@ version.h:
fi
install: all
+ ${INSTALL} -d ${DESTDIR}${SBINDIR}
+ ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR}
${INSTALL} -d ${DESTDIR}${BINDIR}
- ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}
- ${INSTALL} -d ${DESTDIR}/bin
- for x in ${BINLINKS}; do ln -fs ${BINDIR}/${PROG} ${DESTDIR}/bin/$$x; done
- ${INSTALL} -d ${DESTDIR}/bin
- for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${BINDIR}/$$x; done
- ${INSTALL} -d ${DESTDIR}/${LIBNAME}/${PROG}/bin
- for x in $(RC_BINLINKS); do ln -fs ${BINDIR}/${PROG} $(DESTDIR)/${LIBNAME}/${PROG}/bin/$$x; done
- ${INSTALL} -d ${DESTDIR}/${LIBNAME}/${PROG}/sbin
- for x in ${RC_SBINLINKS}; do ln -fs ${BINDIR}/${PROG} ${DESTDIR}/${LIBNAME}/${PROG}/sbin/$$x; done
+ for x in ${BINLINKS}; do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done
+ ${INSTALL} -d ${DESTDIR}${SBINDIR}
+ for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${SBINDIR}/$$x; done
+ ${INSTALL} -d ${DESTDIR}${LINKDIR}/bin
+ for x in $(RC_BINLINKS); do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/bin/$$x; done
+ ${INSTALL} -d ${DESTDIR}${LINKDIR}/sbin
+ for x in ${RC_SBINLINKS}; do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/sbin/$$x; done
if test "${MKPAM}" = pam; then \
${INSTALL} -d ${DESTDIR}${PAMDIR}; \
${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \