SED_SERVICEEXISTS= -e 's:@SERVICEEXISTS@:${SERVICEEXISTS}:g'
SED_SERVICECMD= -e 's:@SERVICECMD@:${SERVICECMD}:g'
SED_SERVICESTATUS= -e 's:@SERVICESTATUS@:${SERVICESTATUS}:g'
+SED_STATUSARG= -e 's:@STATUSARG@:${STATUSARG}:g'
SED_SCRIPT= -e 's:@SCRIPT@:${SCRIPT}:g'
SED_SYS= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
.SUFFIXES: .in
-.in:
+.in: Makefile config.mk
${SED} ${SED_RUNDIR} ${SED_DBDIR} ${SED_LIBDIR} ${SED_HOOKDIR} \
${SED_SYS} ${SED_SCRIPT} ${SED_DATADIR} \
${SED_SERVICEEXISTS} ${SED_SERVICECMD} ${SED_SERVICESTATUS} \
+ ${SED_STATUSARG} \
$< > $@
all: config.h ${PROG} ${SCRIPTS} ${MAN5} ${MAN8}
dev:
cd dev && ${MAKE}
-.c.o:
+.c.o: Makefile config.mk
${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
CLEANFILES+= dhcpcd-embedded.h dhcpcd-embedded.c
DEVS=
EMBEDDED=
POLL=
+STATUSARG=
for x do
opt=${x%%=*}
--serviceexists) SERVICEEXISTS=$var;;
--servicecmd) SERVICECMD=$var;;
--servicestatus) SERVICESTATUS=$var;;
+ --statusarg) STATUSARG=$var;;
--infodir|--includedir) ;; # ignore autotools
--disable-maintainer-mode|--disable-dependency-tracking) ;;
--disable-silent-rules) ;;
-e 's:\$:\\\\\$\$:g' \
)
echo "SERVICESTATUS= $SERVICESTATUS" >>config.mk
+if [ -z "$STATUSARG" ]; then
+ case "$OS" in
+ freebsd*) STATUSARG="onestatus";;
+ esac
+fi
+echo "STATUSARG= $STATUSARG" >>config.mk
HOOKS=
if ! $HOOKSET; then
echo " DATADIR = $DATADIR"
echo " HOOKSCRIPTS = $HOOKS"
echo " EGHOOKSCRIPTS = $EGHOOKS"
+echo " STATUSARG = $STATUSARG"
echo
rm -f dhcpcd tests/test
# Detect the running init system.
# As systemd and OpenRC can be installed on top of legacy init
# systems we try to detect them first.
- _service_status=
+ local status="@STATUSARG@"
+ : ${status:=status}
if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
_service_exists="/bin/systemctl --quiet is-enabled \$1.service"
_service_status="/bin/systemctl --quiet is-active \$1.service"
elif [ -x /sbin/service ]; then
_service_exists="/sbin/service \$1 >/dev/null 2>&1"
_service_cmd="/sbin/service \$1 \$2"
+ elif [ -x /usr/sbin/service ]; then
+ _service_exists="/usr/sbin/service \$1 $status >/dev/null 2>&1"
+ _service_cmd="/usr/sbin/service \$1 \$2"
elif [ -x /bin/sv ]; then
_service_exists="/bin/sv status \1 >/dev/null 2>&1"
_service_cmd="/bin/sv \$1 \$2"
elif [ -e /etc/slackware-version -a -d /etc/rc.d ]; then
_service_exists="[ -x /etc/rc.d/rc.\$1 ]"
_service_cmd="/etc/rc.d/rc.\$1 \$2"
- _service_status="/etc/rc.d/rc.\$1 status 1>/dev/null 2>&1"
+ _service_status="/etc/rc.d/rc.\$1 status >/dev/null 2>&1"
else
for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
if [ -d $x ]; then
_service_exists="[ -x $x/\$1 ]"
_service_cmd="$x/\$1 \$2"
+ _service_status="$x/\$1 $status >/dev/null 2>&1"
break
fi
done
if [ -e /etc/arch-release ]; then
_service_status="[ -e /var/run/daemons/\$1 ]"
elif [ "$x" = "/etc/rc.d" -a -e /etc/rc.d/rc.subr ]; then
- _service_status="$x/\$1 check 1>/dev/null 2>&1"
+ _service_status="$x/\$1 check >/dev/null 2>&1"
fi
fi