Style updates.

This commit is contained in:
Roy Marples 2008-01-09 11:44:43 +00:00
parent 666be0faa0
commit 06634f6309
9 changed files with 64 additions and 62 deletions

View File

@ -3,4 +3,4 @@
SUBDIR= libeinfo librc rc SUBDIR= libeinfo librc rc
TOPDIR= .. TOPDIR= ..
include $(TOPDIR)/subdir.mk include ${TOPDIR}/subdir.mk

View File

@ -1,26 +1,27 @@
# Copyright 2008 Roy Marples # Copyright 2008 Roy Marples <roy@marples.name>
# Setup some good default CFLAGS # Setup some good default CFLAGS
CFLAGS ?= -O2 -pipe CFLAGS?= -O2 -pipe
CSTD?= c99
# GNU Make way of detecting gcc flags we can use # 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; \ check_gcc=$(shell if ${CC} $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "$(1)"; else echo "$(2)"; fi) then echo "$(1)"; else echo "$(2)"; fi)
# pmake check for extra cflags # pmake check for extra cflags
WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \ 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; \ if ${CC} $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo -n "$$x "; fi \ then echo -n "$$x "; fi \
done done
# Loads of nice flags to ensure our code is good # Loads of nice flags to ensure our code is good
CFLAGS += -pedantic -std=c99 \ CFLAGS+= -pedantic -std=${CSTD} \
-Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \ -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
-Wbad-function-cast -Wnested-externs -Wcomment -Winline \ -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \ -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
$(call check_gcc, -Wdeclaration-after-statement) \ $(call check_gcc, -Wdeclaration-after-statement) \
$(call check_gcc, -Wsequence-point) \ $(call check_gcc, -Wsequence-point) \
$(call check_gcc, -Wextra) $(WEXTRA) $(call check_gcc, -Wextra) ${WEXTRA}

View File

@ -1,10 +1,11 @@
# This only works for make implementations that always include a .depend if # This only works for make implementations that always include a .depend if
# it exists. Only GNU make does not do this. # it exists. Only GNU make does not do this.
.depend: ${SCRIPTS} ${SRCS} # Copyright 2008 Roy Marples <roy@marples.name>
$(CC) $(CFLAGS) -MM ${SRCS} > .depend
CLEANFILES+= .depend
.depend: ${SRCS}
${CC} ${CFLAGS} -MM ${SRCS} > .depend
depend: .depend depend: .depend
clean-depend:
rm -f .depend

View File

@ -59,7 +59,7 @@ install: all
${INSTALL} -d ${DESTDIR}${INCDIR} ${INSTALL} -d ${DESTDIR}${INCDIR}
for x in ${INCS}; do ${INSTALL} -m ${INCMODE} $$x ${DESTDIR}${INCDIR}; done for x in ${INCS}; do ${INSTALL} -m ${INCMODE} $$x ${DESTDIR}${INCDIR}; done
clean: clean-depend clean:
rm -f ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} rm -f ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} ${CLEANFILES}
include $(TOPDIR)/depend.mk include ${TOPDIR}/depend.mk

View File

@ -1,5 +1,5 @@
TOPDIR= .. TOPDIR= ..
include $(TOPDIR)/os.mk include ${TOPDIR}/os.mk
LIB= einfo LIB= einfo
SHLIB_MAJOR= 1 SHLIB_MAJOR= 1
@ -9,8 +9,8 @@ VERSION_MAP= einfo.map
SHLIBDIR= /${LIBNAME} SHLIBDIR= /${LIBNAME}
CFLAGS+= -I$(TOPDIR) CFLAGS+= -I${TOPDIR}
include $(TOPDIR)/cc.mk include ${TOPDIR}/cc.mk
include $(TOPDIR)/lib.mk include ${TOPDIR}/lib.mk
include $(TOPDIR)/$(TERMCAP).mk include ${TOPDIR}/${TERMCAP}.mk

View File

@ -1,5 +1,5 @@
TOPDIR= .. TOPDIR= ..
include $(TOPDIR)/os.mk include ${TOPDIR}/os.mk
LIB= rc LIB= rc
SHLIB_MAJOR= 1 SHLIB_MAJOR= 1
@ -11,9 +11,9 @@ VERSION_MAP= rc.map
CFLAGS+= -DLIB=\"${LIBNAME}\" CFLAGS+= -DLIB=\"${LIBNAME}\"
LDADD+= ${LIBKVM} LDADD+= ${LIBKVM}
CFLAGS+= -I$(TOPDIR) CFLAGS+= -I${TOPDIR}
SHLIBDIR= /${LIBNAME} SHLIBDIR= /${LIBNAME}
include $(TOPDIR)/cc.mk include ${TOPDIR}/cc.mk
include $(TOPDIR)/lib.mk include ${TOPDIR}/lib.mk

View File

@ -3,22 +3,22 @@
# Generic definitions # Generic definitions
_OS_SH= u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac _OS_SH= u=`uname -s`; case "$${u}" in *BSD|DragonFly) echo "BSD";; *) echo "$${u}";; esac
_OS!= $(_OS_SH) _OS!= ${_OS_SH}
OS?= $(_OS)$(shell $(_OS_SH)) OS?= ${_OS}$(shell ${_OS_SH})
_LIBNAME_SH= l=`readlink /lib`; case "$$l" in /lib64|lib64) echo "lib64";; *) echo "lib";; esac _LIBNAME_SH= l=`readlink /lib`; case "$$l" in /lib64|lib64) echo "lib64";; *) echo "lib";; esac
_LIBNAME!= $(_LIBNAME_SH) _LIBNAME!= ${_LIBNAME_SH}
LIBNAME?= $(_LIBNAME)$(shell $(_LIBNAME_SH)) LIBNAME?= ${_LIBNAME}$(shell ${_LIBNAME_SH})
RC_LIB= /$(LIB)/rc RC_LIB= /$(LIB)/rc
_DEF_SH= case `uname -s` in Linux) echo "-D_XOPEN_SOURCE=600 -D_BSD_SOURCE";; *) echo;; esac _DEF_SH= case `uname -s` in Linux) echo "-D_XOPEN_SOURCE=600 -D_BSD_SOURCE";; *) echo;; esac
_DEF!= $(_DEF_SH) _DEF!= ${_DEF_SH}
CFLAGS+= $(_DEF)$(shell $(_DEF_SH)) CFLAGS+= ${_DEF}$(shell ${_DEF_SH})
_LIBDL_SH= case `uname -s` in Linux) echo "-Wl,-Bdynamic -ldl";; *) echo;; esac _LIBDL_SH= case `uname -s` in Linux) echo "-Wl,-Bdynamic -ldl";; *) echo;; esac
_LIBDL!= $(_LIBDL_SH) _LIBDL!= ${_LIBDL_SH}
LIBDL?= $(_LIBDL)$(shell $(_LIBDL_SH)) LIBDL?= ${_LIBDL}$(shell ${_LIBDL_SH})
_LIBKVM_SH= case `uname -s` in *BSD) echo "-lkvm";; *) echo;; esac _LIBKVM_SH= case `uname -s` in *BSD) echo "-lkvm";; *) echo;; esac
_LIBKVM!= $(_LIBKVM_SH) _LIBKVM!= ${_LIBKVM_SH}
LIBKVM?= $(_LIBKVM)$(shell $(_LIBKVM_SH)) LIBKVM?= ${_LIBKVM}$(shell ${_LIBKVM_SH})

View File

@ -13,7 +13,7 @@ all: depend ${PROG}
${PROG}: ${SCRIPTS} ${OBJS} ${PROG}: ${SCRIPTS} ${OBJS}
${CC} ${CFLAGS} ${LDFLAGS} ${PROGLDFLAGS} -o $@ ${OBJS} ${LDADD} ${CC} ${CFLAGS} ${LDFLAGS} ${PROGLDFLAGS} -o $@ ${OBJS} ${LDADD}
clean: clean-depend clean:
rm -f ${OBJS} ${PROG} ${CLEANFILES} rm -f ${OBJS} ${PROG} ${CLEANFILES}
include $(TOPDIR)/depend.mk include ${TOPDIR}/depend.mk

View File

@ -3,18 +3,17 @@ SRCS= checkpath.c fstabinfo.c mountinfo.c rc.c rc-depend.c \
rc-logger.c rc-misc.c rc-plugin.c rc-status.c rc-update.c \ rc-logger.c rc-misc.c rc-plugin.c rc-status.c rc-update.c \
runscript.c start-stop-daemon.c runscript.c start-stop-daemon.c
SCRIPTS= version.h
CLEANFILES= version.h CLEANFILES= version.h
TOPDIR= .. TOPDIR= ..
LDFLAGS+= -L$(TOPDIR)/librc -L$(TOPDIR)/libeinfo LDFLAGS+= -L${TOPDIR}/librc -L${TOPDIR}/libeinfo
LDADD+= -lutil -lrc -leinfo LDADD+= -lutil -lrc -leinfo
CFLAGS+= -I$(TOPDIR) -I$(TOPDIR)/librc -I$(TOPDIR)/libeinfo CFLAGS+= -I${TOPDIR} -I${TOPDIR}/librc -I${TOPDIR}/libeinfo
BINDIR?= /sbin BINDIR?= /sbin
LINKDIR= $(LIBNAME)/$(PROG) LINKDIR= ${LIBNAME}/${PROG}
BINLINKS= rc-status BINLINKS= rc-status
SBINLINKS= rc-update runscript start-stop-daemon SBINLINKS= rc-update runscript start-stop-daemon
RC_BINLINKS= einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \ RC_BINLINKS= einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
@ -33,15 +32,16 @@ RC_SBINLINKS= mark_service_starting mark_service_started \
mark_service_coldplugged mark_service_failed \ mark_service_coldplugged mark_service_failed \
rc-abort rc-abort
include $(TOPDIR)/os.mk include ${TOPDIR}/os.mk
CFLAGS+= -DLIB=\"$(LIBNAME)\" CFLAGS+= -DLIB=\"${LIBNAME}\"
include $(TOPDIR)/cc.mk include ${TOPDIR}/cc.mk
include $(TOPDIR)/prog.mk include ${TOPDIR}/prog.mk
include $(TOPDIR)/$(TERMCAP).mk include ${TOPDIR}/${TERMCAP}.mk
LDADD+= ${LIBDL} ${LIBKVM} LDADD+= ${LIBDL} ${LIBKVM}
include $(TOPDIR)/$(PAM).mk include ${TOPDIR}/${PAM}.mk
${SRCS}: version.h
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 \ if test -n "${BRANDING}"; then \
@ -52,14 +52,14 @@ install: all
${INSTALL} -d ${DESTDIR}${BINDIR} ${INSTALL} -d ${DESTDIR}${BINDIR}
${INSTALL} ${PROG} ${DESTDIR}${BINDIR} ${INSTALL} ${PROG} ${DESTDIR}${BINDIR}
${INSTALL} -d ${DESTDIR}/bin ${INSTALL} -d ${DESTDIR}/bin
for x in $(BINLINKS); do ln -fs ${BINDIR}/${PROG} $(DESTDIR)/bin/$$x; done for x in ${BINLINKS}; do ln -fs ${BINDIR}/${PROG} ${DESTDIR}/bin/$$x; done
${INSTALL} -d ${DESTDIR}/bin ${INSTALL} -d ${DESTDIR}/bin
for x in $(SBINLINKS); do ln -fs ${BINDIR}/${PROG} $(DESTDIR)${BINDIR}/$$x; done for x in ${SBINLINKS}; do ln -fs ${BINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done
$(INSTALL) -d $(DESTDIR)/$(LIBNAME)/$(PROG)/bin ${INSTALL} -d ${DESTDIR}/${LIBNAME}/${PROG}/bin
for x in $(RC_BINLINKS); do ln -fs ${BINDIR}/${PROG} $(DESTDIR)/$(LIBNAME)/$(PROG)/bin/$$x; done for x in $(RC_BINLINKS); do ln -fs ${BINDIR}/${PROG} $(DESTDIR)/${LIBNAME}/${PROG}/bin/$$x; done
$(INSTALL) -d $(DESTDIR)/$(LIBNAME)/$(PROG)/sbin ${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 ${RC_SBINLINKS}; do ln -fs ${BINDIR}/${PROG} ${DESTDIR}/${LIBNAME}/${PROG}/sbin/$$x; done
if test "$(PAM)" = pam; then \ if test "${PAM}" = pam; then \
${INSTALL} -d ${DESTDIR}${PAMDIR}; \ ${INSTALL} -d ${DESTDIR}${PAMDIR}; \
${INSTALL} -m ${PAMMODE} start-stop-daemon.pam $(DESTDIR)${PAMDIR}/start-stop-daemon; \ ${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \
fi fi