From 9a4ed64aabbb25b303c4d64ea3cb73cea82cb4f5 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 7 May 2014 13:06:05 +0200 Subject: [PATCH] configure: use `runstatedir` instead of /var/run in configure --- configure.ac | 8 +++++++- m4/args.m4 | 46 +++++++++++++++++++++++++++++++++++++++++----- redhat/lldpd.spec | 2 +- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 59bb3b7b..dc2e1db9 100644 --- a/configure.ac +++ b/configure.ac @@ -226,7 +226,13 @@ lldp_SYSTEMTAP lldp_ARG_ENABLE([privsep], [Privilege separation], [yes]) lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd]) lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd]) -lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd]) + +# Directories +dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway +if test "x$runstatedir" = x; then + AC_SUBST([runstatedir], ['${localstatedir}/run']) +fi +lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd]) # CDP/FDP/EDP/SONMP lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes]) diff --git a/m4/args.m4 b/m4/args.m4 index cf015d64..8e286faf 100644 --- a/m4/args.m4 +++ b/m4/args.m4 @@ -2,17 +2,53 @@ # lldp_ARG_WITH # +dnl lldp_AC_EXPAND(var) + +AC_DEFUN([lldp_AC_EXPAND], [ + dnl first expand prefix and exec_prefix if necessary + prefix_save=$prefix + exec_prefix_save=$exec_prefix + + dnl if no prefix given, then use /usr/local, the default prefix + if test "x$prefix" = "xNONE"; then + prefix="$ac_default_prefix" + fi + dnl if no exec_prefix given, then use prefix + if test "x$exec_prefix" = "xNONE"; then + exec_prefix=$prefix + fi + + full_var="$1" + dnl loop until it doesn't change anymore + while true; do + dnl echo DEBUG: full_var: $full_var + new_full_var="`eval echo $full_var`" + if test "x$new_full_var" = "x$full_var"; then break; fi + full_var=$new_full_var + done + + dnl clean up + full_var=$new_full_var + eval $2="$full_var" + + dnl restore prefix and exec_prefix + prefix=$prefix_save + exec_prefix=$exec_prefix_save +]) + dnl lldp_ARG_WITH(name, help1, default) AC_DEFUN([lldp_ARG_WITH],[ AC_ARG_WITH([$1], AS_HELP_STRING([--with-$1], [$2 @<:@default=$3@:>@]),[ - AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]), ["$withval"], [$2]) - AC_SUBST(AS_TR_CPP([$1]), [$withval])],[ - AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]), ["$3"], [$2]) - AC_SUBST(AS_TR_CPP([$1]), [$3]) - eval with_[]m4_translit([$1], [-+.], [___])="$3" + lldp_AC_EXPAND("$withval", expanded) + AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]), ["$expanded"], [$2]) + AC_SUBST(AS_TR_CPP([$1]), [$expanded])],[ + lldp_AC_EXPAND("$3", expanded) + AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]), ["$expanded"], [$2]) + AC_SUBST(AS_TR_CPP([$1]), [$expanded]) + eval with_[]m4_translit([$1], [-+.], [___])="$expanded" ])]) dnl lldp_ARG_ENABLE(name, help1, default) diff --git a/redhat/lldpd.spec b/redhat/lldpd.spec index 757bc7f7..06592aa9 100644 --- a/redhat/lldpd.spec +++ b/redhat/lldpd.spec @@ -130,7 +130,7 @@ This package is required to develop alternate clients for lldpd. --with-privsep-group=%lldpd_group \ --with-privsep-chroot=%lldpd_chroot \ --with-systemdsystemunitdir=no \ - --prefix=/usr --localstatedir=%lldpd_chroot --sysconfdir=/etc --libdir=%{_libdir} \ + --prefix=/usr --localstatedir=%{_localstatedir} --sysconfdir=/etc --libdir=%{_libdir} \ --docdir=%{_docdir}/lldpd [ -f /usr/include/net-snmp/agent/struct.h ] || touch src/struct.h -- 2.39.5