From 43147845209873b0776bd75d363913fe25611f49 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 10 Jan 2008 16:35:59 +0000 Subject: Allow for OS and SUBOS folders so we can introduce NetBSD scripts whilst keeping BSD for all BSD's. --- src/.mk | 0 src/Makefile | 4 +- src/cc.mk | 27 -------- src/depend.mk | 11 ---- src/hidden-visibility.h | 26 -------- src/includes/hidden-visibility.h | 26 ++++++++ src/includes/rc-misc.h | 129 +++++++++++++++++++++++++++++++++++++++ src/includes/strlist.h | 48 +++++++++++++++ src/lib.mk | 65 -------------------- src/libeinfo/Makefile | 16 ++--- src/librc/Makefile | 10 +-- src/ncurses.mk | 3 - src/os.mk | 24 -------- src/pam.mk | 6 -- src/prog.mk | 19 ------ src/rc-misc.h | 129 --------------------------------------- src/rc/Makefile | 21 +++---- src/strlist.h | 48 --------------- src/termcap.mk | 3 - 19 files changed, 228 insertions(+), 387 deletions(-) delete mode 100644 src/.mk delete mode 100644 src/cc.mk delete mode 100644 src/depend.mk delete mode 100644 src/hidden-visibility.h create mode 100644 src/includes/hidden-visibility.h create mode 100644 src/includes/rc-misc.h create mode 100644 src/includes/strlist.h delete mode 100644 src/lib.mk delete mode 100644 src/ncurses.mk delete mode 100644 src/os.mk delete mode 100644 src/pam.mk delete mode 100644 src/prog.mk delete mode 100644 src/rc-misc.h delete mode 100644 src/strlist.h delete mode 100644 src/termcap.mk (limited to 'src') diff --git a/src/.mk b/src/.mk deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Makefile b/src/Makefile index 19922620..36a3b8e1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,5 +2,5 @@ SUBDIR= libeinfo librc rc -TOPDIR= .. -include ${TOPDIR}/subdir.mk +MK= ../mk +include ${MK}/subdir.mk diff --git a/src/cc.mk b/src/cc.mk deleted file mode 100644 index 18eae7ee..00000000 --- a/src/cc.mk +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2008 Roy Marples - -# Setup some good default CFLAGS - -CFLAGS?= -O2 -pipe -CSTD?= c99 - -# 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=${CSTD} \ - -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} - diff --git a/src/depend.mk b/src/depend.mk deleted file mode 100644 index a4d717ae..00000000 --- a/src/depend.mk +++ /dev/null @@ -1,11 +0,0 @@ -# This only works for make implementations that always include a .depend if -# it exists. Only GNU make does not do this. - -# Copyright 2008 Roy Marples - -CLEANFILES+= .depend - -.depend: ${SRCS} - ${CC} ${CFLAGS} -MM ${SRCS} > .depend - -depend: .depend diff --git a/src/hidden-visibility.h b/src/hidden-visibility.h deleted file mode 100644 index bc7e338a..00000000 --- a/src/hidden-visibility.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Written by Mike Frysinger - * Placed in the Public Domain - */ - -#ifndef _HIDDEN_VISIBILITY_H_ -#define _HIDDEN_VISIBILITY_H_ - -#if defined(__ELF__) && defined(__GNUC__) -# define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name) -# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name) -# define __hidden_asmname2(prefix, name) #prefix name -# define __hidden_proto(name, internal) \ - extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \ - __attribute__ ((visibility ("hidden"))); -# define __hidden_ver(local, internal, name) \ - extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \ - extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local)))) -# define hidden_proto(name) __hidden_proto(name, __RC_##name) -# define hidden_def(name) __hidden_ver(__RC_##name, name, name); -#else -# define hidden_proto(name) -# define hidden_def(name) -#endif - -#endif diff --git a/src/includes/hidden-visibility.h b/src/includes/hidden-visibility.h new file mode 100644 index 00000000..bc7e338a --- /dev/null +++ b/src/includes/hidden-visibility.h @@ -0,0 +1,26 @@ +/* + * Written by Mike Frysinger + * Placed in the Public Domain + */ + +#ifndef _HIDDEN_VISIBILITY_H_ +#define _HIDDEN_VISIBILITY_H_ + +#if defined(__ELF__) && defined(__GNUC__) +# define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name) +# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name) +# define __hidden_asmname2(prefix, name) #prefix name +# define __hidden_proto(name, internal) \ + extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \ + __attribute__ ((visibility ("hidden"))); +# define __hidden_ver(local, internal, name) \ + extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \ + extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local)))) +# define hidden_proto(name) __hidden_proto(name, __RC_##name) +# define hidden_def(name) __hidden_ver(__RC_##name, name, name); +#else +# define hidden_proto(name) +# define hidden_def(name) +#endif + +#endif diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h new file mode 100644 index 00000000..b7208e67 --- /dev/null +++ b/src/includes/rc-misc.h @@ -0,0 +1,129 @@ +/* + rc-misc.h + This is private to us and not for user consumption + */ + +/* + * Copyright 2007 Roy Marples + * All rights reserved + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __RC_MISC_H__ +#define __RC_MISC_H__ + +#include +#include +#include +#include + +#ifndef LIB +# define LIB "lib" +#endif + +#define RC_LEVEL_BOOT "boot" +#define RC_LEVEL_DEFAULT "default" + +#define RC_LIBDIR "/" 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_KSOFTLEVEL RC_SVCDIR "/ksoftlevel" +#define RC_STARTING RC_SVCDIR "/rc.starting" +#define RC_STOPPING RC_SVCDIR "/rc.stopping" + +#define RC_SVCDIR_STARTING RC_SVCDIR "/starting" +#define RC_SVCDIR_INACTIVE RC_SVCDIR "/inactive" +#define RC_SVCDIR_STARTED RC_SVCDIR "/started" +#define RC_SVCDIR_COLDPLUGGED RC_SVCDIR "/coldplugged" + +#define RC_PLUGINDIR RC_LIBDIR "/plugins" + +#define ERRX fprintf (stderr, "out of memory\n"); exit (1) + +static inline void *xmalloc (size_t size) +{ + void *value = malloc (size); + + if (value) + return (value); + + ERRX; +} + +static inline void *xrealloc (void *ptr, size_t size) +{ + void *value = realloc (ptr, size); + + if (value) + return (value); + + ERRX; +} + +static inline char *xstrdup (const char *str) +{ + char *value; + + if (! str) + return (NULL); + + value = strdup (str); + + if (value) + return (value); + + ERRX; +} + +#undef ERRX + +static inline bool exists (const char *pathname) +{ + struct stat buf; + + return (stat (pathname, &buf) == 0); +} + +char *rc_conf_value (const char *var); +bool rc_conf_yesno (const char *var); +char **env_filter (void); +char **env_config (void); + +/* basename_c never modifies the argument. As such, if there is a trailing + * slash then an empty string is returned. */ +static inline const char *basename_c (const char *path) { + const char *slash = strrchr (path, '/'); + + if (slash) + return (++slash); + return (path); +} + +#endif diff --git a/src/includes/strlist.h b/src/includes/strlist.h new file mode 100644 index 00000000..3abe44ff --- /dev/null +++ b/src/includes/strlist.h @@ -0,0 +1,48 @@ +/* + strlist.h + String list macros for making char ** arrays + Based on a previous implementation by Martin Schlemmer + */ + +/* + * Copyright 2007 Roy Marples + * All rights reserved + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __STRLIST_H__ +#define __STRLIST_H__ + +/* FIXME: We should replace the macro with an rc_strlist_foreach + function, but I'm unsure how to go about this. */ + +/* Step through each entry in the string list, setting '_pos' to the + beginning of the entry. '_counter' is used by the macro as index, + but should not be used by code as index (or if really needed, then + it should usually by +1 from what you expect, and should only be + used in the scope of the macro) */ +#define STRLIST_FOREACH(_list, _pos, _counter) \ + if ((_list) && _list[0] && ! (_counter = 0)) \ + while ((_pos = _list[_counter++])) + +#endif /* __STRLIST_H__ */ diff --git a/src/lib.mk b/src/lib.mk deleted file mode 100644 index e7759173..00000000 --- a/src/lib.mk +++ /dev/null @@ -1,65 +0,0 @@ -# rules to build a library -# based on FreeBSD's bsd.lib.mk - -# Copyright 2008 Roy Marples - -LIBNAME?= lib - -SHLIB_NAME= lib${LIB}.so.${SHLIB_MAJOR} -SHLIB_LINK= lib${LIB}.so -SHLIBDIR?= /${LIBNAME} -SONAME?= ${SHLIB_NAME} - -OBJS+= ${SRCS:.c=.o} -SOBJS+= ${OBJS:.o=.So} -_LIBS= lib${LIB}.a ${SHLIB_NAME} - -ECHO?= echo -AR?= ar -RANLIB?= ranlib -INSTALL?= install - -PICFLAG?= -fPIC - -INCDIR?= /usr/include -INCMODE?= 0444 - -LIBDIR?= /usr/${LIBNAME} -LIBMODE?= 0444 - -.SUFFIXES: .So - -.c.So: - ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c $< -o $@ - -all: depend ${_LIBS} - -lib${LIB}.a: ${OBJS} ${STATICOBJS} - @${ECHO} building static library $@ - ${AR} rc $@ $^ - ${RANLIB} $@ - -${SHLIB_NAME}: ${VERSION_MAP} -LDFLAGS+= -Wl,--version-script=${VERSION_MAP} - -${SHLIB_NAME}: ${SOBJS} - @${ECHO} building shared library $@ - @rm -f $@ ${SHLIB_LINK} - @ln -fs $@ ${SHLIB_LINK} - ${CC} ${LDFLAGS} -shared -Wl,-x \ - -o $@ -Wl,-soname,${SONAME} \ - ${SOBJS} ${LDADD} - -install: all - ${INSTALL} -d ${DESTDIR}${LIBDIR} - ${INSTALL} -m ${LIBMODE} lib${LIB}.a ${DESTDIR}${LIBDIR} - ${INSTALL} -d ${DESTDIR}${SHLIBDIR} - ${INSTALL} -m ${LIBMODE} ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} - ln -fs ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}/${SHLIB_LINK} - ${INSTALL} -d ${DESTDIR}${INCDIR} - for x in ${INCS}; do ${INSTALL} -m ${INCMODE} $$x ${DESTDIR}${INCDIR}; done - -clean: - rm -f ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} ${CLEANFILES} - -include ${TOPDIR}/depend.mk diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile index da12ef78..7ef84abb 100644 --- a/src/libeinfo/Makefile +++ b/src/libeinfo/Makefile @@ -1,16 +1,16 @@ -TOPDIR= .. -include ${TOPDIR}/os.mk +MK= ../../mk +include ${MK}/os.mk LIB= einfo -SHLIB_MAJOR= 1 +SHLIB_MAJOR= 1 SRCS= libeinfo.c INCS= einfo.h -VERSION_MAP= einfo.map +VERSION_MAP= einfo.map SHLIBDIR= /${LIBNAME} -CFLAGS+= -I${TOPDIR} +CFLAGS+= -I../includes -include ${TOPDIR}/cc.mk -include ${TOPDIR}/lib.mk -include ${TOPDIR}/${TERMCAP}.mk +include ${MK}/cc.mk +include ${MK}/lib.mk +include ${MK}/${TERMCAP}.mk diff --git a/src/librc/Makefile b/src/librc/Makefile index 095988b8..888155b8 100644 --- a/src/librc/Makefile +++ b/src/librc/Makefile @@ -1,5 +1,5 @@ -TOPDIR= .. -include ${TOPDIR}/os.mk +MK= ../../mk +include ${MK}/os.mk LIB= rc SHLIB_MAJOR= 1 @@ -11,9 +11,9 @@ VERSION_MAP= rc.map CFLAGS+= -DLIB=\"${LIBNAME}\" LDADD+= ${LIBKVM} -CFLAGS+= -I${TOPDIR} +CFLAGS+= -I../includes SHLIBDIR= /${LIBNAME} -include ${TOPDIR}/cc.mk -include ${TOPDIR}/lib.mk +include ${MK}/cc.mk +include ${MK}/lib.mk diff --git a/src/ncurses.mk b/src/ncurses.mk deleted file mode 100644 index 66573d61..00000000 --- a/src/ncurses.mk +++ /dev/null @@ -1,3 +0,0 @@ -LIBTERMCAP?= -lncurses -CFLAGS+= -DHAVE_TERMCAP -LDADD+= ${LIBTERMCAP} diff --git a/src/os.mk b/src/os.mk deleted file mode 100644 index a4bef109..00000000 --- a/src/os.mk +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2008 Roy Marples - -# Generic definitions - -_OS_SH= u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac -_OS!= ${_OS_SH} -OS?= ${_OS}$(shell ${_OS_SH}) - -_LIBNAME_SH= l=`readlink /lib`; case "$$l" in /lib64|lib64) echo "lib64";; *) echo "lib";; esac -_LIBNAME!= ${_LIBNAME_SH} -LIBNAME?= ${_LIBNAME}$(shell ${_LIBNAME_SH}) -RC_LIB= /$(LIB)/rc - -_DEF_SH= case `uname -s` in Linux) echo "-D_XOPEN_SOURCE=600 -D_BSD_SOURCE";; *) echo;; esac -_DEF!= ${_DEF_SH} -CFLAGS+= ${_DEF}$(shell ${_DEF_SH}) - -_LIBDL_SH= case `uname -s` in Linux) echo "-Wl,-Bdynamic -ldl";; *) echo;; esac -_LIBDL!= ${_LIBDL_SH} -LIBDL?= ${_LIBDL}$(shell ${_LIBDL_SH}) - -_LIBKVM_SH= case `uname -s` in *BSD) echo "-lkvm";; *) echo;; esac -_LIBKVM!= ${_LIBKVM_SH} -LIBKVM?= ${_LIBKVM}$(shell ${_LIBKVM_SH}) diff --git a/src/pam.mk b/src/pam.mk deleted file mode 100644 index 7d0f2ca0..00000000 --- a/src/pam.mk +++ /dev/null @@ -1,6 +0,0 @@ -LIBPAM?= -lpam -CFLAGS+= -DHAVE_PAM -LDADD+= ${LIBPAM} - -PAMDIR?= /etc/pam.d -PAMMODE?= 0644 diff --git a/src/prog.mk b/src/prog.mk deleted file mode 100644 index 5da7e75f..00000000 --- a/src/prog.mk +++ /dev/null @@ -1,19 +0,0 @@ -# rules to build a library -# based on FreeBSD's bsd.prog.mk - -# Copyright 2008 Roy Marples - -BINDIR?= /sbin -OBJS+= ${SRCS:.c=.o} - -INSTALL?= install - -all: depend ${PROG} - -${PROG}: ${SCRIPTS} ${OBJS} - ${CC} ${CFLAGS} ${LDFLAGS} ${PROGLDFLAGS} -o $@ ${OBJS} ${LDADD} - -clean: - rm -f ${OBJS} ${PROG} ${CLEANFILES} - -include ${TOPDIR}/depend.mk diff --git a/src/rc-misc.h b/src/rc-misc.h deleted file mode 100644 index b7208e67..00000000 --- a/src/rc-misc.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - rc-misc.h - This is private to us and not for user consumption - */ - -/* - * Copyright 2007 Roy Marples - * All rights reserved - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __RC_MISC_H__ -#define __RC_MISC_H__ - -#include -#include -#include -#include - -#ifndef LIB -# define LIB "lib" -#endif - -#define RC_LEVEL_BOOT "boot" -#define RC_LEVEL_DEFAULT "default" - -#define RC_LIBDIR "/" 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_KSOFTLEVEL RC_SVCDIR "/ksoftlevel" -#define RC_STARTING RC_SVCDIR "/rc.starting" -#define RC_STOPPING RC_SVCDIR "/rc.stopping" - -#define RC_SVCDIR_STARTING RC_SVCDIR "/starting" -#define RC_SVCDIR_INACTIVE RC_SVCDIR "/inactive" -#define RC_SVCDIR_STARTED RC_SVCDIR "/started" -#define RC_SVCDIR_COLDPLUGGED RC_SVCDIR "/coldplugged" - -#define RC_PLUGINDIR RC_LIBDIR "/plugins" - -#define ERRX fprintf (stderr, "out of memory\n"); exit (1) - -static inline void *xmalloc (size_t size) -{ - void *value = malloc (size); - - if (value) - return (value); - - ERRX; -} - -static inline void *xrealloc (void *ptr, size_t size) -{ - void *value = realloc (ptr, size); - - if (value) - return (value); - - ERRX; -} - -static inline char *xstrdup (const char *str) -{ - char *value; - - if (! str) - return (NULL); - - value = strdup (str); - - if (value) - return (value); - - ERRX; -} - -#undef ERRX - -static inline bool exists (const char *pathname) -{ - struct stat buf; - - return (stat (pathname, &buf) == 0); -} - -char *rc_conf_value (const char *var); -bool rc_conf_yesno (const char *var); -char **env_filter (void); -char **env_config (void); - -/* basename_c never modifies the argument. As such, if there is a trailing - * slash then an empty string is returned. */ -static inline const char *basename_c (const char *path) { - const char *slash = strrchr (path, '/'); - - if (slash) - return (++slash); - return (path); -} - -#endif diff --git a/src/rc/Makefile b/src/rc/Makefile index b6ae45a2..e804ec98 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -5,11 +5,9 @@ SRCS= checkpath.c fstabinfo.c mountinfo.c rc.c rc-depend.c \ CLEANFILES= version.h -TOPDIR= .. - -LDFLAGS+= -L${TOPDIR}/librc -L${TOPDIR}/libeinfo +LDFLAGS+= -L../librc -L../libeinfo LDADD+= -lutil -lrc -leinfo -CFLAGS+= -I${TOPDIR} -I${TOPDIR}/librc -I${TOPDIR}/libeinfo +CFLAGS+= -I../includes -I../librc -I../libeinfo BINDIR?= /sbin @@ -32,18 +30,19 @@ RC_SBINLINKS= mark_service_starting mark_service_started \ mark_service_coldplugged mark_service_failed \ rc-abort -include ${TOPDIR}/os.mk +MK= ../../mk +include ${MK}/os.mk CFLAGS+= -DLIB=\"${LIBNAME}\" -include ${TOPDIR}/cc.mk -include ${TOPDIR}/prog.mk +include ${MK}/cc.mk +include ${MK}/prog.mk -include ${TOPDIR}/${TERMCAP}.mk +include ${MK}/${TERMCAP}.mk LDADD+= ${LIBDL} ${LIBKVM} -include ${TOPDIR}/${PAM}.mk +include ${MK}/${PAM}.mk ${SRCS}: version.h version.h: - sed -n -e 's/^VERSION =[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1\"/p' ../../Makefile > 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 @@ -54,7 +53,7 @@ install: all ${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 ${BINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done + 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 diff --git a/src/strlist.h b/src/strlist.h deleted file mode 100644 index 3abe44ff..00000000 --- a/src/strlist.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - strlist.h - String list macros for making char ** arrays - Based on a previous implementation by Martin Schlemmer - */ - -/* - * Copyright 2007 Roy Marples - * All rights reserved - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __STRLIST_H__ -#define __STRLIST_H__ - -/* FIXME: We should replace the macro with an rc_strlist_foreach - function, but I'm unsure how to go about this. */ - -/* Step through each entry in the string list, setting '_pos' to the - beginning of the entry. '_counter' is used by the macro as index, - but should not be used by code as index (or if really needed, then - it should usually by +1 from what you expect, and should only be - used in the scope of the macro) */ -#define STRLIST_FOREACH(_list, _pos, _counter) \ - if ((_list) && _list[0] && ! (_counter = 0)) \ - while ((_pos = _list[_counter++])) - -#endif /* __STRLIST_H__ */ diff --git a/src/termcap.mk b/src/termcap.mk deleted file mode 100644 index 62a251ac..00000000 --- a/src/termcap.mk +++ /dev/null @@ -1,3 +0,0 @@ -LIBTERMCAP?= -ltermcap -CFLAGS+= -DHAVE_TERMCAP -LDADD+= ${LIBTERMCAP} -- cgit v1.2.3