Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: configure: add --with-runstatedir option #136

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 47 additions & 32 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([no])])
AM_INIT_AUTOMAKE(1.11.1 foreign TESTS_OPTION)
AM_PROG_CC_C_O

# expand_path_option $path_variable_name $default
expand_path_option() {
# The first argument is the variable *name* (not value)
ac_path_varname="$1"

# Get the original value of the variable
ac_path_value=$(eval echo "\${${ac_path_varname}}")

# Expand any literal variable expressions in the value so that we don't
# end up with something like '${prefix}' in #defines etc.
#
# Autoconf deliberately leaves values unexpanded to allow overriding
# the configure script choices in make commands (for example,
# "make exec_prefix=/foo install"). No longer being able to do this seems
# like no great loss.
eval ac_path_value=$(eval echo "${ac_path_value}")

# Use (expanded) default if necessary
AS_IF([test x"${ac_path_value}" = x""],
[eval ac_path_value=$(eval echo "$2")])

# Require a full path
AS_CASE(["$ac_path_value"],
[/*], [eval ${ac_path_varname}="$ac_path_value"],
[*], [AC_MSG_ERROR([$ac_path_varname value "$ac_path_value" is not a full path])]
)
}

PKG_CHECK_MODULES(glib, [glib-2.0])
PKG_CHECK_MODULES(libxml, [libxml-2.0])

Expand Down Expand Up @@ -298,42 +326,29 @@ case $exec_prefix in
prefix) exec_prefix=$prefix;;
esac

dnl Expand autoconf variables so that we dont end up with '${prefix}'
dnl in #defines and python scripts
dnl NOTE: Autoconf deliberately leaves them unexpanded to allow
dnl make exec_prefix=/foo install
dnl No longer being able to do this seems like no great loss to me...

eval prefix="`eval echo ${prefix}`"
eval exec_prefix="`eval echo ${exec_prefix}`"
eval bindir="`eval echo ${bindir}`"
eval sbindir="`eval echo ${sbindir}`"
eval libexecdir="`eval echo ${libexecdir}`"
eval datadir="`eval echo ${datadir}`"
eval sysconfdir="`eval echo ${sysconfdir}`"
eval sharedstatedir="`eval echo ${sharedstatedir}`"
eval localstatedir="`eval echo ${localstatedir}`"
eval libdir="`eval echo ${libdir}`"
eval includedir="`eval echo ${includedir}`"
eval oldincludedir="`eval echo ${oldincludedir}`"
eval infodir="`eval echo ${infodir}`"
eval mandir="`eval echo ${mandir}`"

if [ test "x${runstatedir}" = "x" ]; then
if [ test "x${sbd_runstatedir}" = "x" ]; then
runstatedir="${localstatedir}/run"
else
runstatedir="${sbd_runstatedir}"
fi
fi
eval runstatedir="$(eval echo ${runstatedir})"
dnl Expand values of autoconf-provided directory options
expand_path_option prefix
expand_path_option exec_prefix
expand_path_option bindir
expand_path_option sbindir
expand_path_option libexecdir
expand_path_option datadir
expand_path_option sysconfdir
expand_path_option sharedstatedir
expand_path_option localstatedir
expand_path_option libdir
expand_path_option includedir
expand_path_option oldincludedir
expand_path_option infodir
expand_path_option mandir

AS_IF([test x"${runstatedir}" = x""], [runstatedir="${sbd_runstatedir}"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't think of this when reviewing the change in pacemaker but that could actually be further optimized
with expand_path_option having a longer list of parameters at the end where it takes the first !="".
might loose portability though as I didn't find M4sh macros that expand into a loop and shift is a bashism ...
anyway maybe something to note down for next iteration ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it'd make expand_path_option() a little complicated/messy ... runstatedir seems kind of treated as a special case here about how the values might come from different sources ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said if M4sh had something like AS_WHILE and some abstraction for shift the change would be insignificant and having various sources with an order doesn't sound if it might not be useful for other things on the longer run.

expand_path_option runstatedir "${localstatedir}/run"
AC_SUBST(runstatedir)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see the expand_path_option thing Ken has just done in pacemaker?
We should as well consider if we want it synced with .../tests/configure.ac - better of course pull straight so that the copy isn't needed - had some issue i don't recall in detail for which this was a quick hack that persisted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see the expand_path_option thing Ken has just done in pacemaker?

Alright, noticed it. We can add the same as well.

We should as well consider if we want it synced with .../tests/configure.ac - better of course pull straight so that the copy isn't needed - had some issue i don't recall in detail for which this was a quick hack that persisted.

OK, will add commits to get this synced with that one when everything is fine.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep - will look over it after this PR and try to remember ... in the worst case we can still simply sync ...

AC_SUBST(LIBADD_DL) dnl extra flags for dynamic linking libraries

if test x"${CONFIGDIR}" = x""; then
CONFIGDIR="${sysconfdir}/sysconfig"
fi
expand_path_option CONFIGDIR "${sysconfdir}/sysconfig"
AC_SUBST(CONFIGDIR)

if test x"${SBD_WATCHDOG_TIMEOUT_DEFAULT}" = x""; then
Expand Down