Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/configure.ac b/configure.ac
index 400b79c055..35bd04870e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,2164 +1,2184 @@
dnl
dnl autoconf for Pacemaker
dnl
dnl Copyright 2009-2023 the Pacemaker project contributors
dnl
dnl The version control history for this file may have further details.
dnl
dnl This source code is licensed under the GNU General Public License version 2
dnl or later (GPLv2+) WITHOUT ANY WARRANTY.
-dnl ===============================================
-dnl Bootstrap
-dnl ===============================================
+
+dnl ==============================================
+dnl Bootstrap autotools
+dnl ==============================================
+
+# Require a minimum version of autoconf itself
AC_PREREQ(2.64)
dnl AC_CONFIG_MACRO_DIR is deprecated as of autoconf 2.70 (2020-12-08).
dnl Once we can require that version, we can simplify this, and no longer
dnl need ACLOCAL_AMFLAGS in Makefile.am.
m4_ifdef([AC_CONFIG_MACRO_DIRS],
[AC_CONFIG_MACRO_DIRS([m4])],
[AC_CONFIG_MACRO_DIR([m4])])
-AC_DEFUN([AC_DATAROOTDIR_CHECKED])
-
-dnl Suggested structure:
-dnl information on the package
-dnl checks for programs
-dnl checks for libraries
-dnl checks for header files
-dnl checks for types
-dnl checks for structures
-dnl checks for compiler characteristics
-dnl checks for library functions
-dnl checks for system services
-
m4_include([m4/version.m4])
AC_INIT([pacemaker], VERSION_NUMBER, [users@clusterlabs.org], [pacemaker],
PCMK_URL)
-PCMK_FEATURES=""
-
LT_CONFIG_LTDL_DIR([libltdl])
AC_CONFIG_AUX_DIR([libltdl/config])
-AC_CANONICAL_HOST
dnl Where #defines that autoconf makes (e.g. HAVE_whatever) go
dnl
-dnl Internal header: include/config.h
-dnl - Contains ALL defines
+dnl include/config.h
+dnl - Internal API
+dnl - Contains all defines
dnl - include/config.h.in is generated automatically by autoheader
-dnl - NOT to be included in any header files except crm_internal.h
+dnl - Not to be included in any header files except crm_internal.h
dnl (which is also not to be included in any other header files)
dnl
-dnl External header: include/crm_config.h
-dnl - Contains a subset of defines checked here
-dnl - Manually edit include/crm_config.h.in to have configure include
-dnl new defines
+dnl include/crm_config.h
+dnl - External API
+dnl - Contains a subset of defines
+dnl - include/crm_config.h.in is manually edited to select the subset
dnl - Should not include HAVE_* defines
dnl - Safe to include anywhere
AC_CONFIG_HEADERS([include/config.h include/crm_config.h])
dnl 1.13: minimum automake version required
dnl foreign: don't require GNU-standard top-level files
dnl tar-ustar: use (older) POSIX variant of generated tar rather than v7
dnl subdir-objects: keep .o's with their .c's (no-op in 2.0+)
AM_INIT_AUTOMAKE([1.13 foreign tar-ustar subdir-objects])
dnl Require minimum version of pkg-config
PKG_PROG_PKG_CONFIG(0.27)
AS_IF([test x"${PKG_CONFIG}" != x""], [],
[AC_MSG_FAILURE([Could not find required build tool pkg-config (0.27 or later)])])
PKG_INSTALLDIR
PKG_NOARCH_INSTALLDIR
-dnl Example 2.4. Silent Custom Rule to Generate a File
-dnl %-bar.pc: %.pc
-dnl $(AM_V_GEN)$(LN_S) $(notdir $^) $@
-
-CC_IN_CONFIGURE=yes
-export CC_IN_CONFIGURE
-
-LDD=ldd
-dnl ========================================================================
-dnl Compiler characteristics
-dnl ========================================================================
+dnl ==============================================
+dnl Compiler checks and helpers
+dnl ==============================================
dnl A particular compiler can be forced by setting the CC environment variable
AC_PROG_CC
+dnl C++ is needed only to run maintainer utilities, not to build
+AC_PROG_CXX
+
dnl Use at least C99 if possible (automatic for autoconf >= 2.70)
m4_version_prereq([2.70], [:], [AC_PROG_CC_STDC])
-dnl C++ is not needed for build, just maintainer utilities
-AC_PROG_CXX
+# cc_supports_flag <compiler-flag>
+# Return success if the C compiler supports the given flag
+cc_supports_flag() {
+ local CFLAGS="-Werror $@"
+ AC_MSG_CHECKING([whether $CC supports $@])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
+ [RC=0; AC_MSG_RESULT([yes])],
+ [RC=1; AC_MSG_RESULT([no])])
+ return $RC
+}
+
+# cc_temp_flags <compiler-flags>
+# Use the given flags for subsequent C compilation. These can be reverted to
+# what was used previously with cc_restore_flags. This allows certain tests to
+# use specific flags without affecting anything else.
+cc_temp_flags() {
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$*"
+}
+
+# cc_restore_flags
+# Restore C compiler flags to what they were before the last cc_temp_flags
+# call.
+cc_restore_flags() {
+ CFLAGS=$ac_save_CFLAGS
+}
+
+# Check for fatal warning support
+AS_IF([test $enable_fatal_warnings -ne $DISABLED dnl
+ && test x"$GCC" = x"yes" && cc_supports_flag -Werror],
+ [WERROR="-Werror"],
+ [
+ WERROR=""
+ AS_CASE([$enable_fatal_warnings],
+ [$REQUIRED], [AC_MSG_ERROR([Compiler does not support fatal warnings])],
+ [$OPTIONAL], [enable_fatal_warnings=$DISABLED])
+ ])
dnl We use md5.c from gnulib, which has its own m4 macros. Per its docs:
dnl "The macro gl_EARLY must be called as soon as possible after verifying that
dnl the C compiler is working. ... The core part of the gnulib checks are done
dnl by the macro gl_INIT." In addition, prevent gnulib from introducing OpenSSL
dnl as a dependency.
gl_EARLY
gl_SET_CRYPTO_CHECK_DEFAULT([no])
gl_INIT
-# --enable-new-dtags: Use RUNPATH instead of RPATH.
-# It is necessary to have this done before libtool does linker detection.
+AC_CHECK_SIZEOF(long)
+
+
+dnl ==============================================
+dnl Linker checks
+dnl ==============================================
+
+# Check whether linker supports --enable-new-dtags to use RUNPATH instead of
+# RPATH. It is necessary to do this before libtool does linker detection.
# See also: https://github.com/kronosnet/kronosnet/issues/107
AX_CHECK_LINK_FLAG([-Wl,--enable-new-dtags],
[AM_LDFLAGS=-Wl,--enable-new-dtags],
[AC_MSG_ERROR(["Linker support for --enable-new-dtags is required"])])
AC_SUBST([AM_LDFLAGS])
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
LT_INIT([dlopen])
LDFLAGS="$saved_LDFLAGS"
LTDL_INIT([convenience])
-AC_TYPE_SIZE_T
-AC_CHECK_SIZEOF(char)
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(long long)
-
-dnl ===============================================
-dnl Helpers
-dnl ===============================================
-# latest_schema_version $schema_dir
-#
-# Use git if available to list managed RNGs, in case there are leftover schema
-# files from an earlier build of a different version. Otherwise, check all RNGs.
-latest_schema_version() {
- local files=$(git ls-files "$1"/*.rng 2>/dev/null)
- AS_IF([test x"$files" = x""], [files=$(ls -1 "$1"/*.rng)])
- echo "$files" | sed -n -e 's/^.*-\([[0-9]][[0-9.]]*\).rng$/\1/p' dnl
- | sort -V | tail -1
-}
-
-cc_supports_flag() {
- local CFLAGS="-Werror $@"
- AC_MSG_CHECKING([whether $CC supports $@])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
- [RC=0; AC_MSG_RESULT([yes])],
- [RC=1; AC_MSG_RESULT([no])])
- return $RC
-}
-
-# Some tests need to use their own CFLAGS
-
-cc_temp_flags() {
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$*"
-}
-cc_restore_flags() {
- CFLAGS=$ac_save_CFLAGS
-}
-
-# 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")])
+dnl ==============================================
+dnl Define configure options
+dnl ==============================================
- # 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])]
- )
-}
-
-# yes_no_try $user_response $default
+# yes_no_try <user-response> <default>
+# Map a yes/no/try user selection to $REQUIRED for yes, $DISABLED for no, and
+# $OPTIONAL for try.
DISABLED=0
REQUIRED=1
OPTIONAL=2
yes_no_try() {
local value
AS_IF([test x"$1" = x""], [value="$2"], [value="$1"])
AS_CASE(["`echo "$value" | tr '[A-Z]' '[a-z]'`"],
[0|no|false|disable], [return $DISABLED],
[1|yes|true|enable], [return $REQUIRED],
[try|check], [return $OPTIONAL]
)
AC_MSG_ERROR([Invalid option value "$value"])
}
-check_systemdsystemunitdir() {
- AC_MSG_CHECKING([which system unit file directory to use])
- PKG_CHECK_VAR([systemdsystemunitdir], [systemd], [systemdsystemunitdir])
- AC_MSG_RESULT([${systemdsystemunitdir}])
- test x"$systemdsystemunitdir" != x""
- return $?
-}
-
#
-# Fix the defaults of certain built-in variables so they can be used in our
-# custom argument defaults
+# Fix the defaults of certain built-in variables so they can be used in the
+# defaults for our custom arguments
#
AC_MSG_NOTICE([Sanitizing prefix: ${prefix}])
AS_IF([test x"$prefix" = x"NONE"],
[
prefix=/usr
dnl Fix default variables - "prefix" variable if not specified
AS_IF([test x"$localstatedir" = x"\${prefix}/var"],
[localstatedir="/var"])
AS_IF([test x"$sysconfdir" = x"\${prefix}/etc"],
[sysconfdir="/etc"])
])
AC_MSG_NOTICE([Sanitizing exec_prefix: ${exec_prefix}])
AS_CASE([$exec_prefix],
[prefix|NONE], [exec_prefix=$prefix])
AC_MSG_NOTICE([Sanitizing libdir: ${libdir}])
AS_CASE([$libdir],
[prefix|NONE], [
AC_MSG_CHECKING([which lib directory to use])
for aDir in lib64 lib
do
trydir="${exec_prefix}/${aDir}"
AS_IF([test -d ${trydir}],
[
libdir=${trydir}
break
])
done
AC_MSG_RESULT([$libdir])
])
-dnl ===============================================
-dnl Configure Options
-dnl ===============================================
+# Start a list of optional features this build supports
+PCMK_FEATURES=""
-dnl Actual library checks come later, but pkg-config can be used here to grab
-dnl external values to use as defaults for configure options
+dnl This section should include only the definition of configure script
+dnl options and determining their values. Processing should be done later when
+dnl possible, other than what's needed to determine values and defaults.
dnl Per the autoconf docs, --enable-*/--disable-* options should control
dnl features inherent to Pacemaker, while --with-*/--without-* options should
dnl control the use of external software. However, --enable-*/--disable-* may
dnl implicitly require additional external dependencies, and
dnl --with-*/--without-* may implicitly enable or disable features, so the
dnl line is blurry.
dnl
dnl We also use --with-* options for custom file, directory, and path
dnl locations, since autoconf does not provide an option type for those.
dnl --enable-* options: build process
AC_ARG_ENABLE([quiet],
[AS_HELP_STRING([--enable-quiet],
[suppress make output unless there is an error @<:@no@:>@])]
)
yes_no_try "$enable_quiet" "no"
enable_quiet=$?
AC_ARG_ENABLE([fatal-warnings],
[AS_HELP_STRING([--enable-fatal-warnings],
[enable pedantic and fatal warnings for gcc @<:@try@:>@])],
)
yes_no_try "$enable_fatal_warnings" "try"
enable_fatal_warnings=$?
AC_ARG_ENABLE([hardening],
[AS_HELP_STRING([--enable-hardening],
[harden the resulting executables/libraries @<:@try@:>@])]
)
yes_no_try "$enable_hardening" "try"
enable_hardening=$?
dnl --enable-* options: features
AC_ARG_ENABLE([systemd],
[AS_HELP_STRING([--enable-systemd],
[enable support for managing resources via systemd @<:@try@:>@])]
)
yes_no_try "$enable_systemd" "try"
enable_systemd=$?
AC_ARG_ENABLE([upstart],
[AS_HELP_STRING([--enable-upstart],
[enable support for managing resources via Upstart (deprecated) @<:@try@:>@])]
)
yes_no_try "$enable_upstart" "try"
enable_upstart=$?
dnl --enable-* options: features inherent to Pacemaker
AC_ARG_ENABLE([compat-2.0],
[AS_HELP_STRING([--enable-compat-2.0], m4_normalize([
preserve certain output as it was in 2.0; this option will be
available only for the lifetime of the 2.1 series @<:@no@:>@]))]
)
yes_no_try "$enable_compat_2_0" "no"
enable_compat_2_0=$?
-AS_IF([test $enable_compat_2_0 -ne $DISABLED],
- [
- AC_DEFINE_UNQUOTED([PCMK__COMPAT_2_0], [1],
- [Keep certain output compatible with 2.0 release series])
- PCMK_FEATURES="$PCMK_FEATURES compat-2.0"
- ]
-)
# Add an option to create symlinks at the pre-2.0.0 daemon name locations, so
# that users and tools can continue to invoke those names directly (e.g., for
# meta-data). This option will be removed in a future release.
AC_ARG_ENABLE([legacy-links],
[AS_HELP_STRING([--enable-legacy-links],
[add symlinks for old daemon names (deprecated) @<:@no@:>@])]
)
yes_no_try "$enable_legacy_links" "no"
enable_legacy_links=$?
-AM_CONDITIONAL([BUILD_LEGACY_LINKS], [test $enable_legacy_links -ne $DISABLED])
# AM_GNU_GETTEXT calls AM_NLS which defines the nls option, but it defaults
# to enabled. We override the definition of AM_NLS to flip the default and mark
# it as experimental in the help text.
AC_DEFUN([AM_NLS],
[AC_MSG_CHECKING([whether NLS is requested])
AC_ARG_ENABLE([nls],
[AS_HELP_STRING([--enable-nls],
[use Native Language Support (experimental)])],
USE_NLS=$enableval, USE_NLS=no)
AC_MSG_RESULT([$USE_NLS])
AC_SUBST([USE_NLS])]
)
-
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.18])
-AS_IF([test x"$enable_nls" = x"yes"], [PCMK_FEATURES="$PCMK_FEATURES nls"])
-
dnl --with-* options: external software support, and custom locations
dnl This argument is defined via an M4 macro so default can be a variable
AC_DEFUN([VERSION_ARG],
[AC_ARG_WITH([version],
[AS_HELP_STRING([--with-version=VERSION],
[override package version @<:@$1@:>@])],
[ PACEMAKER_VERSION="$withval" ],
[ PACEMAKER_VERSION="$PACKAGE_VERSION" ])]
)
VERSION_ARG(VERSION_NUMBER)
-# Redefine PACKAGE_VERSION and VERSION according to PACEMAKER_VERSION in case
-# the user used --with-version. Unfortunately, this can only affect the
-# substitution variables and later uses in this file, not the config.h
-# constants, so we have to be careful to use only PACEMAKER_VERSION in C code.
-PACKAGE_VERSION=$PACEMAKER_VERSION
-VERSION=$PACEMAKER_VERSION
-
-# Detect highest API schema version
-API_VERSION=$(latest_schema_version "xml/api")
-AC_DEFINE_UNQUOTED([PCMK__API_VERSION], ["$API_VERSION"],
- [Highest API schema version])
-
-# Detect highest CIB schema version
-CIB_VERSION=$(latest_schema_version "xml")
-AC_SUBST(CIB_VERSION)
-
-# Re-run configure at next make if any RNG changes, to re-detect highest
-AC_SUBST([CONFIG_STATUS_DEPENDENCIES],
- [$(echo '$(wildcard $(top_srcdir)/xml/api/*.rng)')])
-
CRM_DAEMON_USER=""
AC_ARG_WITH([daemon-user],
[AS_HELP_STRING([--with-daemon-user=USER],
[user to run unprivileged Pacemaker daemons as (advanced option: changing this may break other cluster components unless similarly configured) @<:@hacluster@:>@])],
[ CRM_DAEMON_USER="$withval" ]
)
CRM_DAEMON_GROUP=""
AC_ARG_WITH([daemon-group],
[AS_HELP_STRING([--with-daemon-group=GROUP],
[group to run unprivileged Pacemaker daemons as (advanced option: changing this may break other cluster components unless similarly configured) @<:@haclient@:>@])],
[ CRM_DAEMON_GROUP="$withval" ]
)
BUG_URL=""
AC_ARG_WITH([bug-url],
[AS_HELP_STRING([--with-bug-url=DIR], m4_normalize([
address where users should submit bug reports
@<:@https://bugs.clusterlabs.org/enter_bug.cgi?product=Pacemaker@:>@]))],
[ BUG_URL="$withval" ]
)
+AS_IF([test x"${BUG_URL}" = x""],
+ [BUG_URL="https://bugs.clusterlabs.org/enter_bug.cgi?product=Pacemaker"])
dnl --with-* options: features
AC_ARG_WITH([cibsecrets],
[AS_HELP_STRING([--with-cibsecrets],
[support separate file for CIB secrets @<:@no@:>@])]
)
yes_no_try "$with_cibsecrets" "no"
with_cibsecrets=$?
AC_ARG_WITH([gnutls],
[AS_HELP_STRING([--with-gnutls],
[support Pacemaker Remote and remote-tls-port using GnuTLS @<:@try@:>@])]
)
yes_no_try "$with_gnutls" "try"
with_gnutls=$?
PCMK_GNUTLS_PRIORITIES="NORMAL"
AC_ARG_WITH([gnutls-priorities],
[AS_HELP_STRING([--with-gnutls-priorities],
[default GnuTLS cipher priorities @<:@NORMAL@:>@])],
[ test x"$withval" = x"no" || PCMK_GNUTLS_PRIORITIES="$withval" ]
)
AC_ARG_WITH([concurrent-fencing-default],
[AS_HELP_STRING([--with-concurrent-fencing-default],
[default value for concurrent-fencing cluster option @<:@false@:>@])],
)
AS_CASE([$with_concurrent_fencing_default],
[""], [with_concurrent_fencing_default="false"],
[false], [],
[true], [PCMK_FEATURES="$PCMK_FEATURES default-concurrent-fencing"],
[AC_MSG_ERROR([Invalid value "$with_concurrent_fencing_default" for --with-concurrent-fencing-default])]
)
-AC_DEFINE_UNQUOTED([PCMK__CONCURRENT_FENCING_DEFAULT],
- ["$with_concurrent_fencing_default"],
- [Default value for concurrent-fencing cluster option])
AC_ARG_WITH([sbd-sync-default],
[AS_HELP_STRING([--with-sbd-sync-default], m4_normalize([
default value used by sbd if SBD_SYNC_RESOURCE_STARTUP
environment variable is not set @<:@false@:>@]))],
)
AS_CASE([$with_sbd_sync_default],
[""], [with_sbd_sync_default=false],
[false], [],
[true], [PCMK_FEATURES="$PCMK_FEATURES default-sbd-sync"],
[AC_MSG_ERROR([Invalid value "$with_sbd_sync_default" for --with-sbd-sync-default])]
)
-AC_DEFINE_UNQUOTED([PCMK__SBD_SYNC_DEFAULT],
- [$with_sbd_sync_default],
- [Default value for SBD_SYNC_RESOURCE_STARTUP environment variable])
AC_ARG_WITH([resource-stickiness-default],
[AS_HELP_STRING([--with-resource-stickiness-default],
[If positive, value to add to new CIBs as explicit resource default for resource-stickiness @<:@0@:>@])],
)
errmsg="Invalid value \"$with_resource_stickiness_default\" for --with-resource-stickiness-default"
AS_CASE([$with_resource_stickiness_default],
[0|""], [with_resource_stickiness_default="0"],
[*[[!0-9]]*], [AC_MSG_ERROR([$errmsg])],
[PCMK_FEATURES="$PCMK_FEATURES default-resource-stickiness"]
)
-AC_DEFINE_UNQUOTED([PCMK__RESOURCE_STICKINESS_DEFAULT],
- [$with_resource_stickiness_default],
- [Default value for resource-stickiness resource meta-attribute])
AC_ARG_WITH([corosync],
[AS_HELP_STRING([--with-corosync],
[support the Corosync messaging and membership layer @<:@try@:>@])]
)
yes_no_try "$with_corosync" "try"
with_corosync=$?
-dnl Get default from corosync if possible.
+dnl Get default from Corosync if possible
PKG_CHECK_VAR([PCMK__COROSYNC_CONF], [corosync], [corosysconfdir],
[PCMK__COROSYNC_CONF="$PCMK__COROSYNC_CONF/corosync.conf"],
[PCMK__COROSYNC_CONF="${sysconfdir}/corosync/corosync.conf"])
AC_ARG_WITH([corosync-conf],
[AS_HELP_STRING([--with-corosync-conf], m4_normalize([
location of Corosync configuration file
@<:@value from Corosync package if available otherwise
SYSCONFDIR/corosync/corosync.conf@:>@]))],
[ PCMK__COROSYNC_CONF="$withval" ]
)
AC_ARG_WITH([nagios],
[AS_HELP_STRING([--with-nagios], [support nagios resources (deprecated)])]
)
yes_no_try "$with_nagios" "try"
with_nagios=$?
dnl --with-* options: directory locations
AC_ARG_WITH([nagios-plugin-dir],
[AS_HELP_STRING([--with-nagios-plugin-dir=DIR],
[directory for nagios plugins (deprecated) @<:@LIBEXECDIR/nagios/plugins@:>@])],
[ NAGIOS_PLUGIN_DIR="$withval" ]
)
AC_ARG_WITH([nagios-metadata-dir],
[AS_HELP_STRING([--with-nagios-metadata-dir=DIR],
[directory for nagios plugins metadata (deprecated) @<:@DATADIR/nagios/plugins-metadata@:>@])],
[ NAGIOS_METADATA_DIR="$withval" ]
)
INITDIR=""
AC_ARG_WITH([initdir],
[AS_HELP_STRING([--with-initdir=DIR],
[directory for init (rc) scripts])],
[ INITDIR="$withval" ]
)
systemdsystemunitdir="${systemdsystemunitdir-}"
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
[directory for systemd unit files (advanced option: must match what systemd uses)])],
[ systemdsystemunitdir="$withval" ]
)
CONFIGDIR=""
AC_ARG_WITH([configdir],
[AS_HELP_STRING([--with-configdir=DIR],
[directory for Pacemaker configuration file @<:@SYSCONFDIR/sysconfig@:>@])],
[ CONFIGDIR="$withval" ]
)
dnl --runstatedir is available as of autoconf 2.70 (2020-12-08). When users
dnl have an older version, they can use our --with-runstatedir.
pcmk_runstatedir=""
AC_ARG_WITH([runstatedir],
[AS_HELP_STRING([--with-runstatedir=DIR],
[modifiable per-process data @<:@LOCALSTATEDIR/run@:>@ (ignored if --runstatedir is available)])],
[ pcmk_runstatedir="$withval" ]
)
CRM_LOG_DIR=""
AC_ARG_WITH([logdir],
[AS_HELP_STRING([--with-logdir=DIR],
[directory for Pacemaker log file @<:@LOCALSTATEDIR/log/pacemaker@:>@])],
[ CRM_LOG_DIR="$withval" ]
)
CRM_BUNDLE_DIR=""
AC_ARG_WITH([bundledir],
[AS_HELP_STRING([--with-bundledir=DIR],
[directory for Pacemaker bundle logs @<:@LOCALSTATEDIR/log/pacemaker/bundles@:>@])],
[ CRM_BUNDLE_DIR="$withval" ]
)
dnl Get default from resource-agents if possible. Otherwise, the default uses
dnl /usr/lib rather than libdir because it's determined by the OCF project and
dnl not Pacemaker. Even if a user wants to install Pacemaker to /usr/local or
dnl such, the OCF agents will be expected in their usual location. However, we
dnl do give the user the option to override it.
PKG_CHECK_VAR([OCF_ROOT_DIR], [resource-agents], [ocfrootdir], [],
[OCF_ROOT_DIR="/usr/lib/ocf"])
AC_ARG_WITH([ocfdir],
[AS_HELP_STRING([--with-ocfdir=DIR], m4_normalize([
OCF resource agent root directory (advanced option: changing this
may break other cluster components unless similarly configured)
@<:@value from resource-agents package if available otherwise
/usr/lib/ocf@:>@]))],
[ OCF_ROOT_DIR="$withval" ]
)
-AC_SUBST(OCF_ROOT_DIR)
-AC_DEFINE_UNQUOTED([OCF_ROOT_DIR], ["$OCF_ROOT_DIR"],
- [OCF root directory for resource agents and libraries])
+dnl Get default from resource-agents if possible
PKG_CHECK_VAR([OCF_RA_PATH], [resource-agents], [ocfrapath], [],
[OCF_RA_PATH="$OCF_ROOT_DIR/resource.d"])
AC_ARG_WITH([ocfrapath],
[AS_HELP_STRING([--with-ocfrapath=DIR], m4_normalize([
OCF resource agent directories (colon-separated) to search
@<:@value from resource-agents package if available otherwise
OCFDIR/resource.d@:>@]))],
[ OCF_RA_PATH="$withval" ]
)
-AC_SUBST(OCF_RA_PATH)
OCF_RA_INSTALL_DIR="$OCF_ROOT_DIR/resource.d"
AC_ARG_WITH([ocfrainstalldir],
[AS_HELP_STRING([--with-ocfrainstalldir=DIR], m4_normalize([
OCF installation directory for Pacemakers resource agents
@<:@OCFDIR/resource.d@:>@]))],
[ OCF_RA_INSTALL_DIR="$withval" ]
)
-AC_SUBST(OCF_RA_INSTALL_DIR)
dnl Get default from fence-agents if available
PKG_CHECK_VAR([FA_PREFIX], [fence-agents], [prefix],
[PCMK__FENCE_BINDIR="${FA_PREFIX}/sbin"],
[PCMK__FENCE_BINDIR="$sbindir"])
AC_ARG_WITH([fence-bindir],
[AS_HELP_STRING([--with-fence-bindir=DIR], m4_normalize([
directory for executable fence agents @<:@value from fence-agents
package if available otherwise SBINDIR@:>@]))],
[ PCMK__FENCE_BINDIR="$withval" ]
)
-AC_SUBST(PCMK__FENCE_BINDIR)
dnl --with-* options: non-production testing
AC_ARG_WITH([profiling],
[AS_HELP_STRING([--with-profiling],
[disable optimizations, for effective profiling @<:@no@:>@])]
)
yes_no_try "$with_profiling" "no"
with_profiling=$?
AC_ARG_WITH([coverage],
[AS_HELP_STRING([--with-coverage],
[disable optimizations, for effective profiling and coverage testing @<:@no@:>@])]
)
yes_no_try "$with_coverage" "no"
with_coverage=$?
AC_ARG_WITH([sanitizers],
[AS_HELP_STRING([--with-sanitizers=...,...],
[enable SANitizer build, do *NOT* use for production. Only ASAN/UBSAN/TSAN are currently supported])],
[ SANITIZERS="$withval" ],
[ SANITIZERS="" ])
dnl Environment variable options
AC_ARG_VAR([CFLAGS_HARDENED_LIB], [extra C compiler flags for hardened libraries])
AC_ARG_VAR([LDFLAGS_HARDENED_LIB], [extra linker flags for hardened libraries])
AC_ARG_VAR([CFLAGS_HARDENED_EXE], [extra C compiler flags for hardened executables])
AC_ARG_VAR([LDFLAGS_HARDENED_EXE], [extra linker flags for hardened executables])
-dnl ===============================================
-dnl General Processing
-dnl ===============================================
+dnl ==============================================
+dnl Locate essential tools
+dnl ==============================================
-AC_DEFINE_UNQUOTED(PACEMAKER_VERSION, "$VERSION",
- [Version number of this Pacemaker build])
+PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
+export PATH
-PACKAGE_SERIES=`echo $VERSION | awk -F. '{ print $1"."$2 }'`
-AC_SUBST(PACKAGE_SERIES)
+dnl Pacemaker's executable python scripts will invoke the python specified by
+dnl configure's PYTHON variable. If not specified, AM_PATH_PYTHON will check a
+dnl built-in list with (unversioned) "python" having precedence. To configure
+dnl Pacemaker to use a specific python interpreter version, define PYTHON
+dnl when calling configure, for example: ./configure PYTHON=/usr/bin/python3.6
+
+dnl If PYTHON was specified, ensure it is an absolute path
+AS_IF([test x"${PYTHON}" != x""], [AC_PATH_PROG([PYTHON], [$PYTHON])])
+
+dnl Require a minimum Python version
+AM_PATH_PYTHON([3.4])
AC_PROG_LN_S
AC_PROG_MKDIR_P
-# Check for fatal warning support
-AS_IF([test $enable_fatal_warnings -ne $DISABLED && test x"$GCC" = x"yes" && cc_supports_flag -Werror],
- [WERROR="-Werror"],
+AC_PATH_PROG([GIT], [git], [false])
+
+dnl Bash is needed for building man pages and running regression tests.
+dnl BASH is already an environment variable, so use something else.
+AC_PATH_PROG([BASH_PATH], [bash])
+AS_IF([test x"${BASH_PATH}" != x""], [],
+ [AC_MSG_FAILURE([Could not find required build tool bash])])
+
+AC_PATH_PROGS(VALGRIND_BIN, valgrind, /usr/bin/valgrind)
+AC_DEFINE_UNQUOTED(VALGRIND_BIN, "$VALGRIND_BIN", Valgrind command)
+
+
+dnl ==============================================
+dnl Package and schema versioning
+dnl ==============================================
+
+# Redefine PACKAGE_VERSION and VERSION according to PACEMAKER_VERSION in case
+# the user used --with-version. Unfortunately, this can only affect the
+# substitution variables and later uses in this file, not the config.h
+# constants, so we have to be careful to use only PACEMAKER_VERSION in C code.
+PACKAGE_VERSION=$PACEMAKER_VERSION
+VERSION=$PACEMAKER_VERSION
+
+AC_DEFINE_UNQUOTED(PACEMAKER_VERSION, "$VERSION",
+ [Version number of this Pacemaker build])
+
+AC_MSG_CHECKING([build version])
+AS_IF([test "$GIT" != "false" && test -d .git],
[
- WERROR=""
- AS_CASE([$enable_fatal_warnings],
- [$REQUIRED], [AC_MSG_ERROR([Compiler does not support fatal warnings])],
- [$OPTIONAL], [
- AC_MSG_NOTICE([Compiler does not support fatal warnings])
- enable_fatal_warnings=$DISABLED
- ])
+ BUILD_VERSION=`"$GIT" log --pretty="format:%h" -n 1`
+ AC_MSG_RESULT([$BUILD_VERSION (git hash)])
+ ],
+ [
+ # The current directory name make a reasonable default
+ # Most generated archives will include the hash or tag
+ BASE=`basename $PWD`
+ BUILD_VERSION=`echo $BASE | sed s:.*[[Pp]]acemaker-::`
+ AC_MSG_RESULT([$BUILD_VERSION (directory name)])
])
+AC_DEFINE_UNQUOTED(BUILD_VERSION, "$BUILD_VERSION", Build version)
+AC_SUBST(BUILD_VERSION)
+
+# latest_schema_version <schema_dir>
+# Determine highest RNG version in the given schema directory. Use git if
+# available to list managed RNGs, in case there are leftover schema files from
+# an earlier build of a different version. Otherwise, check all RNGs.
+latest_schema_version() {
+ local files=$(git ls-files "$1"/*.rng 2>/dev/null)
+ AS_IF([test x"$files" = x""], [files=$(ls -1 "$1"/*.rng)])
+ echo "$files" | sed -n -e 's/^.*-\([[0-9]][[0-9.]]*\).rng$/\1/p' dnl
+ | sort -V | tail -1
+}
+
+# Detect highest API schema version
+API_VERSION=$(latest_schema_version "xml/api")
+AC_DEFINE_UNQUOTED([PCMK__API_VERSION], ["$API_VERSION"],
+ [Highest API schema version])
+
+# Detect highest CIB schema version
+CIB_VERSION=$(latest_schema_version "xml")
+AC_SUBST(CIB_VERSION)
+
+# Add the schemas to the files that cause automake to re-run configure at next
+# make, so we re-detect the highest version
+AC_SUBST([CONFIG_STATUS_DEPENDENCIES],
+ [$(echo '$(wildcard $(top_srcdir)/xml/api/*.rng)')])
+
+
+dnl ==============================================
+dnl Process simple options
+dnl ==============================================
+
+AS_IF([test $enable_compat_2_0 -ne $DISABLED],
+ [
+ AC_DEFINE_UNQUOTED([PCMK__COMPAT_2_0], [1],
+ [Keep certain output compatible with 2.0 release series])
+ PCMK_FEATURES="$PCMK_FEATURES compat-2.0"
+ ]
+)
+
+AM_CONDITIONAL([BUILD_LEGACY_LINKS], [test $enable_legacy_links -ne $DISABLED])
+
+AS_IF([test x"$enable_nls" = x"yes"], [PCMK_FEATURES="$PCMK_FEATURES nls"])
+
+AC_DEFINE_UNQUOTED([PCMK__CONCURRENT_FENCING_DEFAULT],
+ ["$with_concurrent_fencing_default"],
+ [Default value for concurrent-fencing cluster option])
+
+AC_DEFINE_UNQUOTED([PCMK__SBD_SYNC_DEFAULT],
+ [$with_sbd_sync_default],
+ [Default value for SBD_SYNC_RESOURCE_STARTUP environment variable])
+
+AC_DEFINE_UNQUOTED([PCMK__RESOURCE_STICKINESS_DEFAULT],
+ [$with_resource_stickiness_default],
+ [Default value for resource-stickiness resource meta-attribute])
+
+AC_SUBST(OCF_ROOT_DIR)
+AC_DEFINE_UNQUOTED([OCF_ROOT_DIR], ["$OCF_ROOT_DIR"],
+ [OCF root directory for resource agents and libraries])
+
+AC_SUBST(OCF_RA_PATH)
+AC_SUBST(OCF_RA_INSTALL_DIR)
+AC_SUBST(PCMK__FENCE_BINDIR)
+
+AS_IF([test x"${PCMK_GNUTLS_PRIORITIES}" != x""], [],
+ [AC_MSG_ERROR([--with-gnutls-priorities value must not be empty])])
+AC_DEFINE_UNQUOTED([PCMK_GNUTLS_PRIORITIES], ["$PCMK_GNUTLS_PRIORITIES"],
+ [GnuTLS cipher priorities])
+AC_SUBST(PCMK_GNUTLS_PRIORITIES)
+
+AC_SUBST(BUG_URL)
+AC_DEFINE_UNQUOTED([PCMK__BUG_URL], ["$BUG_URL"],
+ [Where bugs should be reported])
+
+
+dnl ==============================================
+dnl Process file paths
+dnl ==============================================
+
+# expand_path_option <path-variable-name> [<default>]
+# Given the name of a file path variable, expand any variable references
+# inside it, use the specified default if it is not specified, and ensure it
+# is a full path.
+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])]
+ )
+}
AC_MSG_NOTICE([Sanitizing INITDIR: ${INITDIR}])
AS_CASE([$INITDIR],
[prefix], [INITDIR=$prefix],
[""], [
AC_MSG_CHECKING([which init (rc) directory to use])
for initdir in /etc/init.d /etc/rc.d/init.d /sbin/init.d \
/usr/local/etc/rc.d /etc/rc.d
do
AS_IF([test -d $initdir],
[
INITDIR=$initdir
break
])
done
AC_MSG_RESULT([$INITDIR])
])
AC_SUBST(INITDIR)
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 datarootdir
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
-dnl Home-grown variables
+AC_DEFUN([AC_DATAROOTDIR_CHECKED])
+
+dnl Expand values of custom directory options
expand_path_option localedir "${datadir}/locale"
-AC_DEFINE_UNQUOTED([PCMK__LOCALE_DIR],["$localedir"], [Base directory for message catalogs])
+AC_DEFINE_UNQUOTED([PCMK__LOCALE_DIR],["$localedir"],
+ [Base directory for message catalogs])
AS_IF([test x"${runstatedir}" = x""], [runstatedir="${pcmk_runstatedir}"])
expand_path_option runstatedir "${localstatedir}/run"
AC_DEFINE_UNQUOTED([PCMK_RUN_DIR], ["$runstatedir"],
[Location for modifiable per-process data])
AC_SUBST(runstatedir)
expand_path_option INITDIR
AC_DEFINE_UNQUOTED([PCMK__LSB_INIT_DIR], ["$INITDIR"],
[Location for LSB init scripts])
expand_path_option docdir "${datadir}/doc/${PACKAGE}-${VERSION}"
AC_SUBST(docdir)
expand_path_option CONFIGDIR "${sysconfdir}/sysconfig"
AC_SUBST(CONFIGDIR)
expand_path_option PCMK__COROSYNC_CONF "${sysconfdir}/corosync/corosync.conf"
AC_SUBST(PCMK__COROSYNC_CONF)
expand_path_option CRM_LOG_DIR "${localstatedir}/log/pacemaker"
AC_DEFINE_UNQUOTED(CRM_LOG_DIR,"$CRM_LOG_DIR", Location for Pacemaker log file)
AC_SUBST(CRM_LOG_DIR)
expand_path_option CRM_BUNDLE_DIR "${localstatedir}/log/pacemaker/bundles"
AC_DEFINE_UNQUOTED(CRM_BUNDLE_DIR,"$CRM_BUNDLE_DIR", Location for Pacemaker bundle logs)
AC_SUBST(CRM_BUNDLE_DIR)
expand_path_option PCMK__FENCE_BINDIR
AC_DEFINE_UNQUOTED(PCMK__FENCE_BINDIR,"$PCMK__FENCE_BINDIR",
[Location for executable fence agents])
expand_path_option OCF_RA_PATH
AC_DEFINE_UNQUOTED([OCF_RA_PATH], ["$OCF_RA_PATH"],
[OCF directories to search for resource agents ])
-AS_IF([test x"${PCMK_GNUTLS_PRIORITIES}" != x""], [],
- [AC_MSG_ERROR([--with-gnutls-priorities value must not be empty])])
-AC_DEFINE_UNQUOTED([PCMK_GNUTLS_PRIORITIES], ["$PCMK_GNUTLS_PRIORITIES"],
- [GnuTLS cipher priorities])
-AC_SUBST(PCMK_GNUTLS_PRIORITIES)
-
-AS_IF([test x"${BUG_URL}" = x""],
- [BUG_URL="https://bugs.clusterlabs.org/enter_bug.cgi?product=Pacemaker"])
-AC_SUBST(BUG_URL)
-AC_DEFINE_UNQUOTED([PCMK__BUG_URL], ["$BUG_URL"],
- [Where bugs should be reported])
-
+# Warn about any directories that don't exist (which may be OK)
for j in prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir \
sharedstatedir localstatedir libdir includedir oldincludedir infodir \
mandir INITDIR docdir CONFIGDIR localedir
do
dirname=`eval echo '${'${j}'}'`
AS_IF([test ! -d "$dirname"],
[AC_MSG_WARN([$j directory ($dirname) does not exist (yet)])])
done
+dnl ===============================================
+dnl General Processing
+dnl ===============================================
+
us_auth=
AC_CHECK_HEADER([sys/socket.h], [
AC_CHECK_DECL([SO_PEERCRED], [
# Linux
AC_CHECK_TYPE([struct ucred], [
us_auth=peercred_ucred;
AC_DEFINE([HAVE_UCRED], [1],
[Define if Unix socket auth method is
getsockopt(s, SO_PEERCRED, &ucred, ...)])
], [
# OpenBSD
AC_CHECK_TYPE([struct sockpeercred], [
us_auth=localpeercred_sockepeercred;
AC_DEFINE([HAVE_SOCKPEERCRED], [1],
[Define if Unix socket auth method is
getsockopt(s, SO_PEERCRED, &sockpeercred, ...)])
], [], [[#include <sys/socket.h>]])
], [[#define _GNU_SOURCE
#include <sys/socket.h>]])
], [], [[#include <sys/socket.h>]])
])
AS_IF([test -z "${us_auth}"], [
# FreeBSD
AC_CHECK_DECL([getpeereid], [
us_auth=getpeereid;
AC_DEFINE([HAVE_GETPEEREID], [1],
[Define if Unix socket auth method is
getpeereid(s, &uid, &gid)])
], [
# Solaris/OpenIndiana
AC_CHECK_DECL([getpeerucred], [
us_auth=getpeerucred;
AC_DEFINE([HAVE_GETPEERUCRED], [1],
[Define if Unix socket auth method is
getpeercred(s, &ucred)])
], [
AC_MSG_FAILURE([No way to authenticate a Unix socket peer])
], [[#include <ucred.h>]])
])
])
dnl OS-based decision-making is poor autotools practice; feature-based
dnl mechanisms are strongly preferred. Keep this section to a bare minimum;
dnl regard as a "necessary evil".
+
+dnl Set host_os and host_cpu
+AC_CANONICAL_HOST
+
INIT_EXT=""
PROCFS=0
dnl Solaris and some *BSD versions support procfs but not files we need
AS_CASE(["$host_os"],
[*bsd*], [INIT_EXT=".sh"],
[*linux*], [PROCFS=1],
[darwin*], [
LIBS="$LIBS -L${prefix}/lib"
CFLAGS="$CFLAGS -I${prefix}/include"
])
AC_SUBST(INIT_EXT)
AM_CONDITIONAL([SUPPORT_PROCFS], [test $PROCFS -eq 1])
AC_DEFINE_UNQUOTED([HAVE_LINUX_PROCFS], [$PROCFS],
[Define to 1 if procfs is supported])
AS_CASE(["$host_cpu"],
[ppc64|powerpc64], [
AS_CASE([$CFLAGS],
[*powerpc64*], [],
[*], [AS_IF([test x"$GCC" = x"yes"], [CFLAGS="$CFLAGS -m64"])
])
])
-dnl ===============================================
-dnl Program Paths
-dnl ===============================================
-PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
-export PATH
-
-dnl Pacemaker's executable python scripts will invoke the python specified by
-dnl configure's PYTHON variable. If not specified, AM_PATH_PYTHON will check a
-dnl built-in list with (unversioned) "python" having precedence. To configure
-dnl Pacemaker to use a specific python interpreter version, define PYTHON
-dnl when calling configure, for example: ./configure PYTHON=/usr/bin/python3.6
-
-dnl Ensure PYTHON is an absolute path
-AS_IF([test x"${PYTHON}" != x""], [AC_PATH_PROG([PYTHON], [$PYTHON])])
-
-dnl Require a minimum Python version
-AM_PATH_PYTHON([3.4])
+dnl ==============================================
+dnl Documentation build dependencies and checks
+dnl ==============================================
AC_PATH_PROGS([ASCIIDOC_CONV], [asciidoc asciidoctor])
AC_PATH_PROG([HELP2MAN], [help2man])
AC_PATH_PROG([SPHINX], [sphinx-build])
AC_PATH_PROG([INKSCAPE], [inkscape])
AC_PATH_PROG([XSLTPROC], [xsltproc])
AC_PATH_PROG([XMLCATALOG], [xmlcatalog])
-dnl Bash is needed for building man pages and running regression tests.
-dnl BASH is already an environment variable, so use something else.
-AC_PATH_PROG([BASH_PATH], [bash])
-AS_IF([test x"${BASH_PATH}" != x""], [],
- [AC_MSG_FAILURE([Could not find required build tool bash])])
-
-AC_PATH_PROGS(VALGRIND_BIN, valgrind, /usr/bin/valgrind)
-AC_DEFINE_UNQUOTED(VALGRIND_BIN, "$VALGRIND_BIN", Valgrind command)
-
AM_CONDITIONAL(BUILD_HELP, test x"${HELP2MAN}" != x"")
AS_IF([test x"${HELP2MAN}" != x""],
[PCMK_FEATURES="$PCMK_FEATURES generated-manpages"])
MANPAGE_XSLT=""
AS_IF([test x"${XSLTPROC}" != x""],
[
AC_MSG_CHECKING([for DocBook-to-manpage transform])
# first try to figure out correct template using xmlcatalog query,
# resort to extensive (semi-deterministic) file search if that fails
DOCBOOK_XSL_URI='http://docbook.sourceforge.net/release/xsl/current'
DOCBOOK_XSL_PATH='manpages/docbook.xsl'
MANPAGE_XSLT=$(${XMLCATALOG} "" ${DOCBOOK_XSL_URI}/${DOCBOOK_XSL_PATH} \
| sed -n 's|^file://||p;q')
AS_IF([test x"${MANPAGE_XSLT}" = x""],
[
DIRS=$(find "${datadir}" -name $(basename $(dirname ${DOCBOOK_XSL_PATH})) \
-type d 2>/dev/null | LC_ALL=C sort)
XSLT=$(basename ${DOCBOOK_XSL_PATH})
for d in ${DIRS}
do
AS_IF([test -f "${d}/${XSLT}"],
[
MANPAGE_XSLT="${d}/${XSLT}"
break
])
done
])
])
AC_MSG_RESULT([$MANPAGE_XSLT])
AC_SUBST(MANPAGE_XSLT)
AM_CONDITIONAL(BUILD_XML_HELP, test x"${MANPAGE_XSLT}" != x"")
AS_IF([test x"${MANPAGE_XSLT}" != x""],
[PCMK_FEATURES="$PCMK_FEATURES agent-manpages"])
AM_CONDITIONAL([IS_ASCIIDOC], [echo "${ASCIIDOC_CONV}" | grep -Eq 'asciidoc$'])
AM_CONDITIONAL([BUILD_ASCIIDOC], [test "x${ASCIIDOC_CONV}" != x])
AS_IF([test x"${ASCIIDOC_CONV}" != x""],
[PCMK_FEATURES="$PCMK_FEATURES ascii-docs"])
AM_CONDITIONAL([BUILD_SPHINX_DOCS],
[test x"${SPHINX}" != x"" && test x"${INKSCAPE}" != x""])
AM_COND_IF([BUILD_SPHINX_DOCS], [PCMK_FEATURES="$PCMK_FEATURES books"])
dnl Pacemaker's shell scripts (and thus man page builders) rely on GNU getopt
AC_MSG_CHECKING([for GNU-compatible getopt])
IFS_orig=$IFS
IFS=:
for PATH_DIR in $PATH
do
IFS=$IFS_orig
GETOPT_PATH="${PATH_DIR}/getopt"
AS_IF([test -f "$GETOPT_PATH" && test -x "$GETOPT_PATH"],
[
$GETOPT_PATH -T >/dev/null 2>/dev/null
AS_IF([test $? -eq 4], [break])
])
GETOPT_PATH=""
done
IFS=$IFS_orig
AS_IF([test -n "$GETOPT_PATH"], [AC_MSG_RESULT([$GETOPT_PATH])],
[
AC_MSG_RESULT([no])
AC_MSG_ERROR([Could not find required build tool GNU-compatible getopt])
])
AC_SUBST([GETOPT_PATH])
+
dnl ========================================================================
dnl checks for library functions to replace them
dnl
dnl NoSuchFunctionName:
dnl is a dummy function which no system supplies. It is here to make
dnl the system compile semi-correctly on OpenBSD which doesn't know
dnl how to create an empty archive
dnl
dnl scandir: Only on BSD.
dnl System-V systems may have it, but hidden and/or deprecated.
dnl A replacement function is supplied for it.
dnl
dnl strerror: returns a string that corresponds to an errno.
dnl A replacement function is supplied for it.
dnl
dnl strnlen: is a gnu function similar to strlen, but safer.
dnl We wrote a tolerably-fast replacement function for it.
dnl
dnl strndup: is a gnu function similar to strdup, but safer.
dnl We wrote a tolerably-fast replacement function for it.
AC_REPLACE_FUNCS(alphasort NoSuchFunctionName scandir strerror strchrnul strnlen strndup)
dnl ===============================================
dnl Libraries
dnl ===============================================
AC_CHECK_LIB(socket, socket) dnl -lsocket
AC_CHECK_LIB(c, dlopen) dnl if dlopen is in libc...
AC_CHECK_LIB(dl, dlopen) dnl -ldl (for Linux)
AC_CHECK_LIB(rt, sched_getscheduler) dnl -lrt (for Tru64)
AC_CHECK_LIB(gnugetopt, getopt_long) dnl -lgnugetopt ( if available )
AC_CHECK_LIB(pam, pam_start) dnl -lpam (if available)
PKG_CHECK_MODULES([UUID], [uuid],
[CPPFLAGS="${CPPFLAGS} ${UUID_CFLAGS}"
LIBS="${LIBS} ${UUID_LIBS}"])
AC_CHECK_FUNCS([sched_setscheduler])
AS_IF([test x"$ac_cv_func_sched_setscheduler" != x"yes"],
[PC_LIBS_RT=""],
[PC_LIBS_RT="-lrt"])
AC_SUBST(PC_LIBS_RT)
# Require minimum glib version
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.42.0],
[CPPFLAGS="${CPPFLAGS} ${GLIB_CFLAGS}"
LIBS="${LIBS} ${GLIB_LIBS}"])
# Check whether high-resolution sleep function is available
AC_CHECK_FUNCS([nanosleep usleep])
#
# Where is dlopen?
#
AS_IF([test x"$ac_cv_lib_c_dlopen" = x"yes"],
[LIBADD_DL=""],
[test x"$ac_cv_lib_dl_dlopen" = x"yes"],
[LIBADD_DL=-ldl],
[LIBADD_DL=${lt_cv_dlopen_libs}])
PKG_CHECK_MODULES(LIBXML2, [libxml-2.0],
[CPPFLAGS="${CPPFLAGS} ${LIBXML2_CFLAGS}"
LIBS="${LIBS} ${LIBXML2_LIBS}"])
REQUIRE_LIB([xslt], [xsltApplyStylesheet])
+AC_MSG_CHECKING([whether __progname and __progname_full are available])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *__progname, *__progname_full;]],
+ [[__progname = "foo";
+ __progname_full = "foo bar";]])],
+ [
+ have_progname="yes"
+ AC_DEFINE(HAVE_PROGNAME, 1,
+ [Define to 1 if processes can change their name])
+ ],
+ [have_progname="no"])
+AC_MSG_RESULT([$have_progname])
+
dnl ========================================================================
dnl Headers
dnl ========================================================================
# Some distributions insert #warnings into deprecated headers. If we will
# enable fatal warnings for the build, then enable them for the header checks
# as well, otherwise the build could fail even though the header check
# succeeds. (We should probably be doing this in more places.)
cc_temp_flags "$CFLAGS $WERROR"
# Optional headers (inclusion of these should be conditional in C code)
AC_CHECK_HEADERS([linux/swab.h])
AC_CHECK_HEADERS([stddef.h])
AC_CHECK_HEADERS([sys/signalfd.h])
AC_CHECK_HEADERS([uuid/uuid.h])
AC_CHECK_HEADERS([security/pam_appl.h pam/pam_appl.h])
# Required headers
REQUIRE_HEADER([arpa/inet.h])
REQUIRE_HEADER([ctype.h])
REQUIRE_HEADER([dirent.h])
REQUIRE_HEADER([errno.h])
REQUIRE_HEADER([glib.h])
REQUIRE_HEADER([grp.h])
REQUIRE_HEADER([limits.h])
REQUIRE_HEADER([netdb.h])
REQUIRE_HEADER([netinet/in.h])
REQUIRE_HEADER([netinet/ip.h], [
#include <sys/types.h>
#include <netinet/in.h>
])
REQUIRE_HEADER([pwd.h])
REQUIRE_HEADER([signal.h])
REQUIRE_HEADER([stdio.h])
REQUIRE_HEADER([stdlib.h])
REQUIRE_HEADER([string.h])
REQUIRE_HEADER([strings.h])
REQUIRE_HEADER([sys/ioctl.h])
REQUIRE_HEADER([sys/param.h])
REQUIRE_HEADER([sys/reboot.h])
REQUIRE_HEADER([sys/resource.h])
REQUIRE_HEADER([sys/socket.h])
REQUIRE_HEADER([sys/stat.h])
REQUIRE_HEADER([sys/time.h])
REQUIRE_HEADER([sys/types.h])
REQUIRE_HEADER([sys/utsname.h])
REQUIRE_HEADER([sys/wait.h])
REQUIRE_HEADER([time.h])
REQUIRE_HEADER([unistd.h])
REQUIRE_HEADER([libxml/xpath.h])
REQUIRE_HEADER([libxslt/xslt.h])
cc_restore_flags
-AC_CHECK_FUNCS([uuid_unparse], [],
- [AC_MSG_FAILURE([Could not find required C function uuid_unparse()])])
-
-AC_CACHE_CHECK([whether __progname and __progname_full are available],
- [pf_cv_var_progname],
- [AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[extern char *__progname, *__progname_full;]],
- [[__progname = "foo"; __progname_full = "foo bar";]])],
- [pf_cv_var_progname="yes"],
- [pf_cv_var_progname="no"]
- )]
- )
-AS_IF([test x"$pf_cv_var_progname" = x"yes"],
- [AC_DEFINE(HAVE_PROGNAME,1,[Define to 1 if processes can change their name])])
-
dnl ========================================================================
dnl Generic declarations
dnl ========================================================================
AC_CHECK_DECLS([CLOCK_MONOTONIC], [PCMK_FEATURES="$PCMK_FEATURES monotonic"], [], [[
#include <time.h>
]])
dnl ========================================================================
dnl Unit test declarations
dnl ========================================================================
AC_CHECK_DECLS([assert_float_equal], [], [], [[
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
]])
cc_temp_flags "$CFLAGS -Wl,--wrap=uname"
WRAPPABLE_UNAME="no"
AC_MSG_CHECKING([if uname() can be wrapped])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/utsname.h>
int __wrap_uname(struct utsname *buf) {
return 100;
}
int main(int argc, char **argv) {
struct utsname x;
return uname(&x) == 100 ? 0 : 1;
}
]])],
[ WRAPPABLE_UNAME="yes" ], [ WRAPPABLE_UNAME="no"])
AC_MSG_RESULT([$WRAPPABLE_UNAME])
AM_CONDITIONAL([WRAPPABLE_UNAME], [test x"$WRAPPABLE_UNAME" = x"yes"])
cc_restore_flags
dnl ========================================================================
dnl Structures
dnl ========================================================================
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[[#include <time.h>]])
AC_CHECK_MEMBER([struct dirent.d_type],
AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE,1,[Define this if struct dirent has d_type]),,
[#include <dirent.h>])
dnl ========================================================================
dnl Functions
dnl ========================================================================
REQUIRE_FUNC([getopt])
REQUIRE_FUNC([setenv])
REQUIRE_FUNC([unsetenv])
+REQUIRE_FUNC([uuid_unparse])
REQUIRE_FUNC([vasprintf])
-AC_CACHE_CHECK(whether sscanf supports %m,
- pf_cv_var_sscanf,
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <stdio.h>
-const char *s = "some-command-line-arg";
-int main(int argc, char **argv) {
-char *name = NULL;
-int n = sscanf(s, "%ms", &name);
-return n == 1 ? 0 : 1;
-}
-]])],
- pf_cv_var_sscanf="yes", pf_cv_var_sscanf="no", pf_cv_var_sscanf="no"))
-
-AS_IF([test x"$pf_cv_var_sscanf" = x"yes"],
+AC_CHECK_FUNCS([fopen64])
+AM_CONDITIONAL([WRAPPABLE_FOPEN64], [test x"$ac_cv_func_fopen64" = x"yes"])
+
+AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
+ const char *s = "some-command-line-arg";
+ char *name = NULL;
+ int n = sscanf(s, "%ms", &name);
+ return n != 1;
+ ]])],
+ [have_sscanf_m="yes"],
+ [have_sscanf_m="no"],
+ [have_sscanf_m="no"])
+AS_IF([test x"$have_sscanf_m" = x"yes"],
[AC_DEFINE([HAVE_SSCANF_M], [1],
[Define to 1 if sscanf %m modifier is available])])
dnl ========================================================================
dnl bzip2
dnl ========================================================================
REQUIRE_HEADER([bzlib.h])
REQUIRE_LIB([bz2], [BZ2_bzBuffToBuffCompress])
dnl ========================================================================
dnl sighandler_t is missing from Illumos, Solaris11 systems
dnl ========================================================================
AC_MSG_CHECKING([for sighandler_t])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[sighandler_t *f;]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_SIGHANDLER_T], [1],
[Define to 1 if sighandler_t is available])
],
[AC_MSG_RESULT([no])])
dnl ========================================================================
dnl ncurses
dnl ========================================================================
dnl
dnl A few OSes (e.g. Linux) deliver a default "ncurses" alongside "curses".
dnl Many non-Linux deliver "curses"; sites may add "ncurses".
dnl
dnl However, the source-code recommendation for both is to #include "curses.h"
dnl (i.e. "ncurses" still wants the include to be simple, no-'n', "curses.h").
dnl
dnl ncurses takes precedence.
dnl
AC_CHECK_HEADERS([curses.h curses/curses.h ncurses.h ncurses/ncurses.h])
dnl Although n-library is preferred, only look for it if the n-header was found.
CURSESLIBS=''
PC_NAME_CURSES=""
PC_LIBS_CURSES=""
AS_IF([test x"$ac_cv_header_ncurses_h" = x"yes"], [
AC_CHECK_LIB(ncurses, printw,
[AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)])
CURSESLIBS=`$PKG_CONFIG --libs ncurses` || CURSESLIBS='-lncurses'
PC_NAME_CURSES="ncurses"
])
AS_IF([test x"$ac_cv_header_ncurses_ncurses_h" = x"yes"], [
AC_CHECK_LIB(ncurses, printw,
[AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)])
CURSESLIBS=`$PKG_CONFIG --libs ncurses` || CURSESLIBS='-lncurses'
PC_NAME_CURSES="ncurses"
])
dnl Only look for non-n-library if there was no n-library.
AS_IF([test x"$CURSESLIBS" = x"" && test x"$ac_cv_header_curses_h" = x"yes"], [
AC_CHECK_LIB(curses, printw,
[CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)])
PC_LIBS_CURSES="$CURSESLIBS"
])
dnl Only look for non-n-library if there was no n-library.
AS_IF([test x"$CURSESLIBS" = x"" && test x"$ac_cv_header_curses_curses_h" = x"yes"], [
AC_CHECK_LIB(curses, printw,
[CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)])
PC_LIBS_CURSES="$CURSESLIBS"
])
AS_IF([test x"$CURSESLIBS" != x""],
[PCMK_FEATURES="$PCMK_FEATURES ncurses"])
dnl Check for printw() prototype compatibility
AS_IF([test x"$CURSESLIBS" != x"" && cc_supports_flag -Wcast-qual], [
ac_save_LIBS=$LIBS
LIBS="$CURSESLIBS"
# avoid broken test because of hardened build environment in Fedora 23+
# - https://fedoraproject.org/wiki/Changes/Harden_All_Packages
# - https://bugzilla.redhat.com/1297985
AS_IF([cc_supports_flag -fPIC],
[cc_temp_flags "-Wcast-qual $WERROR -fPIC"],
[cc_temp_flags "-Wcast-qual $WERROR"])
AC_MSG_CHECKING([whether curses library is compatible])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([
#if defined(HAVE_NCURSES_H)
# include <ncurses.h>
#elif defined(HAVE_NCURSES_NCURSES_H)
# include <ncurses/ncurses.h>
#elif defined(HAVE_CURSES_H)
# include <curses.h>
#endif
],
[printw((const char *)"Test");]
)],
[AC_MSG_RESULT([yes])],
[
AC_MSG_RESULT([no])
AC_MSG_WARN(m4_normalize([Disabling curses because the printw()
function of your (n)curses library is old.
If you wish to enable curses, update to a
newer version (ncurses 5.4 or later is
recommended, available from
https://invisible-island.net/ncurses/)
]))
AC_DEFINE([HAVE_INCOMPATIBLE_PRINTW], [1],
[Define to 1 if curses library has incompatible printw()])
]
)
LIBS=$ac_save_LIBS
cc_restore_flags
])
AC_SUBST(CURSESLIBS)
AC_SUBST(PC_NAME_CURSES)
AC_SUBST(PC_LIBS_CURSES)
dnl ========================================================================
dnl Profiling and GProf
dnl ========================================================================
CFLAGS_ORIG="$CFLAGS"
AS_IF([test $with_coverage -ne $DISABLED],
[
with_profiling=$REQUIRED
PCMK_FEATURES="$PCMK_FEATURES coverage"
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
dnl During linking, make sure to specify -lgcov or -coverage
]
)
AS_IF([test $with_profiling -ne $DISABLED],
[
with_profiling=$REQUIRED
PCMK_FEATURES="$PCMK_FEATURES profile"
dnl Disable various compiler optimizations
CFLAGS="$CFLAGS -fno-omit-frame-pointer -fno-inline -fno-builtin"
dnl CFLAGS="$CFLAGS -fno-inline-functions"
dnl CFLAGS="$CFLAGS -fno-default-inline"
dnl CFLAGS="$CFLAGS -fno-inline-functions-called-once"
dnl CFLAGS="$CFLAGS -fno-optimize-sibling-calls"
dnl Turn off optimization so tools can get accurate line numbers
CFLAGS=`echo $CFLAGS | sed \
-e 's/-O.\ //g' \
-e 's/-Wp,-D_FORTIFY_SOURCE=.\ //g' \
-e 's/-D_FORTIFY_SOURCE=.\ //g'`
CFLAGS="$CFLAGS -O0 -g3 -gdwarf-2"
AC_MSG_NOTICE([CFLAGS before adding profiling options: $CFLAGS_ORIG])
AC_MSG_NOTICE([CFLAGS after: $CFLAGS])
]
)
AC_DEFINE_UNQUOTED([SUPPORT_PROFILING], [$with_profiling], [Support profiling])
AM_CONDITIONAL([BUILD_PROFILING], [test "$with_profiling" = "$REQUIRED"])
dnl ========================================================================
dnl Cluster infrastructure - LibQB
dnl ========================================================================
PKG_CHECK_MODULES(libqb, libqb >= 0.17)
CPPFLAGS="$libqb_CFLAGS $CPPFLAGS"
LIBS="$libqb_LIBS $LIBS"
dnl libqb 2.0.5+ (2022-03)
AC_CHECK_FUNCS([qb_ipcc_connect_async])
dnl libqb 2.0.2+ (2020-10)
AC_CHECK_FUNCS([qb_ipcc_auth_get])
dnl libqb 2.0.0+ (2020-05)
CHECK_ENUM_VALUE([qb/qblog.h],[qb_log_conf],[QB_LOG_CONF_MAX_LINE_LEN])
CHECK_ENUM_VALUE([qb/qblog.h],[qb_log_conf],[QB_LOG_CONF_ELLIPSIS])
dnl Support Linux-HA fence agents if available
AS_IF([test x"$cross_compiling" != x"yes"],
[CPPFLAGS="$CPPFLAGS -I${prefix}/include/heartbeat"])
AC_CHECK_HEADERS([stonith/stonith.h],
[
AC_CHECK_LIB([pils], [PILLoadPlugin])
AC_CHECK_LIB([plumb], [G_main_add_IPC_Channel])
PCMK_FEATURES="$PCMK_FEATURES lha"
])
AM_CONDITIONAL([BUILD_LHA_SUPPORT], [test x"$ac_cv_header_stonith_stonith_h" = x"yes"])
dnl ===============================================
dnl Variables needed for substitution
dnl ===============================================
CRM_SCHEMA_DIRECTORY="${datadir}/pacemaker"
AC_DEFINE_UNQUOTED(CRM_SCHEMA_DIRECTORY,"$CRM_SCHEMA_DIRECTORY", Location for the Pacemaker Relax-NG Schema)
AC_SUBST(CRM_SCHEMA_DIRECTORY)
CRM_CORE_DIR="${localstatedir}/lib/pacemaker/cores"
AC_DEFINE_UNQUOTED([CRM_CORE_DIR], ["$CRM_CORE_DIR"],
[Directory Pacemaker daemons should change to (without systemd, core files will go here)])
AC_SUBST(CRM_CORE_DIR)
AS_IF([test x"${CRM_DAEMON_USER}" = x""],
[CRM_DAEMON_USER="hacluster"])
AC_DEFINE_UNQUOTED(CRM_DAEMON_USER,"$CRM_DAEMON_USER", User to run Pacemaker daemons as)
AC_SUBST(CRM_DAEMON_USER)
AS_IF([test x"${CRM_DAEMON_GROUP}" = x""],
[CRM_DAEMON_GROUP="haclient"])
AC_DEFINE_UNQUOTED(CRM_DAEMON_GROUP,"$CRM_DAEMON_GROUP", Group to run Pacemaker daemons as)
AC_SUBST(CRM_DAEMON_GROUP)
CRM_PACEMAKER_DIR=${localstatedir}/lib/pacemaker
AC_DEFINE_UNQUOTED(CRM_PACEMAKER_DIR,"$CRM_PACEMAKER_DIR", Location to store directory produced by Pacemaker daemons)
AC_SUBST(CRM_PACEMAKER_DIR)
CRM_BLACKBOX_DIR=${localstatedir}/lib/pacemaker/blackbox
AC_DEFINE_UNQUOTED(CRM_BLACKBOX_DIR,"$CRM_BLACKBOX_DIR", Where to keep blackbox dumps)
AC_SUBST(CRM_BLACKBOX_DIR)
PE_STATE_DIR="${localstatedir}/lib/pacemaker/pengine"
AC_DEFINE_UNQUOTED(PE_STATE_DIR,"$PE_STATE_DIR", Where to keep scheduler outputs)
AC_SUBST(PE_STATE_DIR)
CRM_CONFIG_DIR="${localstatedir}/lib/pacemaker/cib"
AC_DEFINE_UNQUOTED(CRM_CONFIG_DIR,"$CRM_CONFIG_DIR", Where to keep configuration files)
AC_SUBST(CRM_CONFIG_DIR)
CRM_DAEMON_DIR="${libexecdir}/pacemaker"
AC_DEFINE_UNQUOTED(CRM_DAEMON_DIR,"$CRM_DAEMON_DIR", Location for Pacemaker daemons)
AC_SUBST(CRM_DAEMON_DIR)
CRM_STATE_DIR="${runstatedir}/crm"
AC_DEFINE_UNQUOTED([CRM_STATE_DIR], ["$CRM_STATE_DIR"],
[Where to keep state files and sockets])
AC_SUBST(CRM_STATE_DIR)
CRM_RSCTMP_DIR="${runstatedir}/resource-agents"
AC_DEFINE_UNQUOTED(CRM_RSCTMP_DIR,"$CRM_RSCTMP_DIR", Where resource agents should keep state files)
AC_SUBST(CRM_RSCTMP_DIR)
PACEMAKER_CONFIG_DIR="${sysconfdir}/pacemaker"
AC_DEFINE_UNQUOTED(PACEMAKER_CONFIG_DIR,"$PACEMAKER_CONFIG_DIR", Where to keep configuration files like authkey)
AC_SUBST(PACEMAKER_CONFIG_DIR)
AC_DEFINE_UNQUOTED(SBIN_DIR,"$sbindir",[Location for system binaries])
-AC_PATH_PROGS(GIT, git false)
-
-AC_MSG_CHECKING([build version])
-BUILD_VERSION=$Format:%h$
-AS_IF([test $BUILD_VERSION != ":%h$"],
- [AC_MSG_RESULT([$BUILD_VERSION (archive hash)])],
- [test -x $GIT && test -d .git],
- [
- BUILD_VERSION=`$GIT log --pretty="format:%h" -n 1`
- AC_MSG_RESULT([$BUILD_VERSION (git hash)])
- ],
- [
- # The current directory name make a reasonable default
- # Most generated archives will include the hash or tag
- BASE=`basename $PWD`
- BUILD_VERSION=`echo $BASE | sed s:.*[[Pp]]acemaker-::`
- AC_MSG_RESULT([$BUILD_VERSION (directory name)])
- ])
-
-AC_DEFINE_UNQUOTED(BUILD_VERSION, "$BUILD_VERSION", Build version)
-AC_SUBST(BUILD_VERSION)
-
HAVE_dbus=1
PKG_CHECK_MODULES([DBUS], [dbus-1],
[CPPFLAGS="${CPPFLAGS} ${DBUS_CFLAGS}"],
[HAVE_dbus=0])
AC_DEFINE_UNQUOTED(HAVE_DBUS, $HAVE_dbus, Support dbus)
AM_CONDITIONAL(BUILD_DBUS, test $HAVE_dbus = 1)
dnl libdbus 1.5.12+ (2012-03) / 1.6.0+ (2012-06)
AC_CHECK_TYPES([DBusBasicValue],,,[[#include <dbus/dbus.h>]])
AS_IF([test $HAVE_dbus = 0],
[PC_NAME_DBUS=""],
[PC_NAME_DBUS="dbus-1"])
AC_SUBST(PC_NAME_DBUS)
+check_systemdsystemunitdir() {
+ AC_MSG_CHECKING([which system unit file directory to use])
+ PKG_CHECK_VAR([systemdsystemunitdir], [systemd], [systemdsystemunitdir])
+ AC_MSG_RESULT([${systemdsystemunitdir}])
+ test x"$systemdsystemunitdir" != x""
+ return $?
+}
+
AS_CASE([$enable_systemd],
[$REQUIRED], [
AS_IF([test $HAVE_dbus = 0],
[AC_MSG_FAILURE([Cannot support systemd resources without DBus])])
AS_IF([test "$ac_cv_have_decl_CLOCK_MONOTONIC" = "no"],
[AC_MSG_FAILURE([Cannot support systemd resources without monotonic clock])])
AS_IF([check_systemdsystemunitdir], [],
[AC_MSG_FAILURE([Cannot support systemd resources without systemdsystemunitdir])])
],
[$OPTIONAL], [
AS_IF([test $HAVE_dbus = 0 \
|| test x"$ac_cv_have_decl_CLOCK_MONOTONIC" = x"no"],
[enable_systemd=$DISABLED],
[
AC_MSG_CHECKING([for systemd version (using dbus-send)])
ret=$({ dbus-send --system --print-reply \
--dest=org.freedesktop.systemd1 \
/org/freedesktop/systemd1 \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.systemd1.Manager \
string:Version 2>/dev/null \
|| echo "version unavailable"; } | tail -n1)
# sanitize output a bit (interested just in value, not type),
# ret is intentionally unenquoted so as to normalize whitespace
ret=$(echo ${ret} | cut -d' ' -f2-)
AC_MSG_RESULT([${ret}])
AS_IF([test x"$ret" != x"unavailable" \
|| systemctl --version 2>/dev/null | grep -q systemd],
[
AS_IF([check_systemdsystemunitdir],
[enable_systemd=$REQUIRED],
[enable_systemd=$DISABLED])
],
[enable_systemd=$DISABLED]
)
])
],
)
AC_MSG_CHECKING([whether to enable support for managing resources via systemd])
AS_IF([test $enable_systemd -eq $DISABLED], [AC_MSG_RESULT([no])],
[
AC_MSG_RESULT([yes])
PCMK_FEATURES="$PCMK_FEATURES systemd"
]
)
AC_SUBST([systemdsystemunitdir])
AC_DEFINE_UNQUOTED([SUPPORT_SYSTEMD], [$enable_systemd],
[Support systemd resources])
AM_CONDITIONAL([BUILD_SYSTEMD], [test $enable_systemd = $REQUIRED])
AC_SUBST(SUPPORT_SYSTEMD)
AS_CASE([$enable_upstart],
[$REQUIRED], [
AS_IF([test $HAVE_dbus = 0],
[AC_MSG_FAILURE([Cannot support Upstart resources without DBus])])
],
[$OPTIONAL], [
AS_IF([test $HAVE_dbus = 0], [enable_upstart=$DISABLED],
[
AC_MSG_CHECKING([for Upstart version (using dbus-send)])
ret=$({ dbus-send --system --print-reply \
--dest=com.ubuntu.Upstart \
/com/ubuntu/Upstart org.freedesktop.DBus.Properties.Get \
string:com.ubuntu.Upstart0_6 string:version 2>/dev/null \
|| echo "version unavailable"; } | tail -n1)
# sanitize output a bit (interested just in value, not type),
# ret is intentionally unenquoted so as to normalize whitespace
ret=$(echo ${ret} | cut -d' ' -f2-)
AC_MSG_RESULT([${ret}])
AS_IF([test x"$ret" != x"unavailable" \
|| initctl --version 2>/dev/null | grep -q upstart],
[enable_upstart=$REQUIRED],
[enable_upstart=$DISABLED]
)
])
],
)
AC_MSG_CHECKING([whether to enable support for managing resources via Upstart])
AS_IF([test $enable_upstart -eq $DISABLED], [AC_MSG_RESULT([no])],
[
AC_MSG_RESULT([yes])
PCMK_FEATURES="$PCMK_FEATURES upstart"
]
)
AC_DEFINE_UNQUOTED([SUPPORT_UPSTART], [$enable_upstart],
[Support Upstart resources])
AM_CONDITIONAL([BUILD_UPSTART], [test $enable_upstart -eq $REQUIRED])
AC_SUBST(SUPPORT_UPSTART)
AS_CASE([$with_nagios],
[$REQUIRED], [
AS_IF([test x"$ac_cv_have_decl_CLOCK_MONOTONIC" = x"no"],
[AC_MSG_FAILURE([Cannot support nagios resources without monotonic clock])])
],
[$OPTIONAL], [
AS_IF([test x"$ac_cv_have_decl_CLOCK_MONOTONIC" = x"no"],
[with_nagios=$DISABLED], [with_nagios=$REQUIRED])
]
)
AS_IF([test $with_nagios -eq $REQUIRED], [PCMK_FEATURES="$PCMK_FEATURES nagios"])
AC_DEFINE_UNQUOTED([SUPPORT_NAGIOS], [$with_nagios], [Support nagios plugins])
AM_CONDITIONAL([BUILD_NAGIOS], [test $with_nagios -eq $REQUIRED])
AS_IF([test x"$NAGIOS_PLUGIN_DIR" = x""],
[NAGIOS_PLUGIN_DIR="${libexecdir}/nagios/plugins"])
AC_DEFINE_UNQUOTED(NAGIOS_PLUGIN_DIR, "$NAGIOS_PLUGIN_DIR", Directory for nagios plugins)
AC_SUBST(NAGIOS_PLUGIN_DIR)
AS_IF([test x"$NAGIOS_METADATA_DIR" = x""],
[NAGIOS_METADATA_DIR="${datadir}/nagios/plugins-metadata"])
AC_DEFINE_UNQUOTED(NAGIOS_METADATA_DIR, "$NAGIOS_METADATA_DIR", Directory for nagios plugins metadata)
AC_SUBST(NAGIOS_METADATA_DIR)
STACKS=""
CLUSTERLIBS=""
PC_NAME_CLUSTER=""
dnl ========================================================================
dnl Cluster stack - Corosync
dnl ========================================================================
COROSYNC_LIBS=""
AS_CASE([$with_corosync],
[$REQUIRED], [
# These will be fatal if unavailable
PKG_CHECK_MODULES([cpg], [libcpg])
PKG_CHECK_MODULES([cfg], [libcfg])
PKG_CHECK_MODULES([cmap], [libcmap])
PKG_CHECK_MODULES([quorum], [libquorum])
PKG_CHECK_MODULES([libcorosync_common], [libcorosync_common])
]
[$OPTIONAL], [
PKG_CHECK_MODULES([cpg], [libcpg], [], [with_corosync=$DISABLED])
PKG_CHECK_MODULES([cfg], [libcfg], [], [with_corosync=$DISABLED])
PKG_CHECK_MODULES([cmap], [libcmap], [], [with_corosync=$DISABLED])
PKG_CHECK_MODULES([quorum], [libquorum], [], [with_corosync=$DISABLED])
PKG_CHECK_MODULES([libcorosync_common], [libcorosync_common], [], [with_corosync=$DISABLED])
AS_IF([test $with_corosync -ne $DISABLED], [with_corosync=$REQUIRED])
]
)
AS_IF([test $with_corosync -ne $DISABLED],
[
AC_MSG_CHECKING([for Corosync 2 or later])
AC_MSG_RESULT([yes])
CFLAGS="$CFLAGS $libqb_CFLAGS $cpg_CFLAGS $cfg_CFLAGS $cmap_CFLAGS $quorum_CFLAGS $libcorosync_common_CFLAGS"
CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags-only-I corosync`"
COROSYNC_LIBS="$COROSYNC_LIBS $cpg_LIBS $cfg_LIBS $cmap_LIBS $quorum_LIBS $libcorosync_common_LIBS"
CLUSTERLIBS="$CLUSTERLIBS $COROSYNC_LIBS"
PC_NAME_CLUSTER="$PC_CLUSTER_NAME libcfg libcmap libcorosync_common libcpg libquorum"
STACKS="$STACKS corosync-ge-2"
dnl Shutdown tracking added (back) to corosync Jan 2021
saved_LIBS="$LIBS"
LIBS="$LIBS $COROSYNC_LIBS"
AC_CHECK_FUNCS([corosync_cfg_trackstart])
LIBS="$saved_LIBS"
]
)
AC_DEFINE_UNQUOTED([SUPPORT_COROSYNC], [$with_corosync],
[Support the Corosync messaging and membership layer])
AM_CONDITIONAL([BUILD_CS_SUPPORT], [test $with_corosync -eq $REQUIRED])
AC_SUBST([SUPPORT_COROSYNC])
dnl
dnl Cluster stack - Sanity
dnl
AS_IF([test x"$STACKS" != x""], [AC_MSG_NOTICE([Supported stacks:${STACKS}])],
[AC_MSG_FAILURE([At least one cluster stack must be supported])])
PCMK_FEATURES="${PCMK_FEATURES}${STACKS}"
AC_SUBST(CLUSTERLIBS)
AC_SUBST(PC_NAME_CLUSTER)
dnl ========================================================================
dnl CIB secrets
dnl ========================================================================
AS_IF([test $with_cibsecrets -ne $DISABLED],
[
with_cibsecrets=$REQUIRED
PCMK_FEATURES="$PCMK_FEATURES cibsecrets"
LRM_CIBSECRETS_DIR="${localstatedir}/lib/pacemaker/lrm/secrets"
AC_DEFINE_UNQUOTED([LRM_CIBSECRETS_DIR], ["$LRM_CIBSECRETS_DIR"],
[Location for CIB secrets])
AC_SUBST([LRM_CIBSECRETS_DIR])
]
)
AC_DEFINE_UNQUOTED([SUPPORT_CIBSECRETS], [$with_cibsecrets], [Support CIB secrets])
AM_CONDITIONAL([BUILD_CIBSECRETS], [test $with_cibsecrets -eq $REQUIRED])
dnl ========================================================================
dnl GnuTLS
dnl ========================================================================
dnl Require GnuTLS >=2.12.0 (2011-03) for Pacemaker Remote support
PC_NAME_GNUTLS=""
AS_CASE([$with_gnutls],
[$REQUIRED], [
REQUIRE_LIB([gnutls], [gnutls_sec_param_to_pk_bits])
REQUIRE_HEADER([gnutls/gnutls.h])
],
[$OPTIONAL], [
AC_CHECK_LIB([gnutls], [gnutls_sec_param_to_pk_bits],
[], [with_gnutls=$DISABLED])
AC_CHECK_HEADERS([gnutls/gnutls.h], [], [with_gnutls=$DISABLED])
]
)
AS_IF([test $with_gnutls -ne $DISABLED],
[
PC_NAME_GNUTLS="gnutls"
PCMK_FEATURES="$PCMK_FEATURES remote"
]
)
AC_SUBST([PC_NAME_GNUTLS])
AM_CONDITIONAL([BUILD_REMOTE], [test $with_gnutls -ne $DISABLED])
# --- ASAN/UBSAN/TSAN (see man gcc) ---
# when using SANitizers, we need to pass the -fsanitize..
# to both CFLAGS and LDFLAGS. The CFLAGS/LDFLAGS must be
# specified as first in the list or there will be runtime
# issues (for example user has to LD_PRELOAD asan for it to work
# properly).
AS_IF([test -n "${SANITIZERS}"], [
SANITIZERS=$(echo $SANITIZERS | sed -e 's/,/ /g')
for SANITIZER in $SANITIZERS
do
AS_CASE([$SANITIZER],
[asan|ASAN], [
SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=address"
SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=address -lasan"
PCMK_FEATURES="$PCMK_FEATURES asan"
REQUIRE_LIB([asan],[main])
],
[ubsan|UBSAN], [
SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=undefined"
SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=undefined -lubsan"
PCMK_FEATURES="$PCMK_FEATURES ubsan"
REQUIRE_LIB([ubsan],[main])
],
[tsan|TSAN], [
SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=thread"
SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=thread -ltsan"
PCMK_FEATURES="$PCMK_FEATURES tsan"
REQUIRE_LIB([tsan],[main])
])
done
])
dnl ========================================================================
dnl Compiler flags
dnl ========================================================================
dnl Make sure that CFLAGS is not exported. If the user did
dnl not have CFLAGS in their environment then this should have
dnl no effect. However if CFLAGS was exported from the user's
dnl environment, then the new CFLAGS will also be exported
dnl to sub processes.
AS_IF([export | fgrep " CFLAGS=" > /dev/null],
[
SAVED_CFLAGS="$CFLAGS"
unset CFLAGS
CFLAGS="$SAVED_CFLAGS"
unset SAVED_CFLAGS
])
CC_EXTRAS=""
AS_IF([test x"$GCC" != x"yes"], [CFLAGS="$CFLAGS -g"], [
CFLAGS="$CFLAGS -ggdb"
dnl When we don't have diagnostic push / pull, we can't explicitly disable
dnl checking for nonliteral formats in the places where they occur on purpose
dnl thus we disable nonliteral format checking globally as we are aborting
dnl on warnings.
dnl what makes the things really ugly is that nonliteral format checking is
dnl obviously available as an extra switch in very modern gcc but for older
dnl gcc this is part of -Wformat=2
dnl so if we have push/pull we can enable -Wformat=2 -Wformat-nonliteral
dnl if we don't have push/pull but -Wformat-nonliteral we can enable -Wformat=2
dnl otherwise none of both
gcc_diagnostic_push_pull=no
cc_temp_flags "$CFLAGS $WERROR"
AC_MSG_CHECKING([for gcc diagnostic push / pull])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#pragma GCC diagnostic push
#pragma GCC diagnostic pop
]])],
[
AC_MSG_RESULT([yes])
gcc_diagnostic_push_pull=yes
], AC_MSG_RESULT([no]))
cc_restore_flags
AS_IF([cc_supports_flag "-Wformat-nonliteral"],
[gcc_format_nonliteral=yes],
[gcc_format_nonliteral=no])
# We had to eliminate -Wnested-externs because of libtool changes
# Make sure to order options so that the former stand for prerequisites
# of the latter (e.g., -Wformat-nonliteral requires -Wformat).
EXTRA_FLAGS="-fgnu89-inline"
EXTRA_FLAGS="$EXTRA_FLAGS -Wall"
EXTRA_FLAGS="$EXTRA_FLAGS -Waggregate-return"
EXTRA_FLAGS="$EXTRA_FLAGS -Wbad-function-cast"
EXTRA_FLAGS="$EXTRA_FLAGS -Wcast-align"
EXTRA_FLAGS="$EXTRA_FLAGS -Wdeclaration-after-statement"
EXTRA_FLAGS="$EXTRA_FLAGS -Wendif-labels"
EXTRA_FLAGS="$EXTRA_FLAGS -Wfloat-equal"
EXTRA_FLAGS="$EXTRA_FLAGS -Wformat-security"
EXTRA_FLAGS="$EXTRA_FLAGS -Wimplicit-fallthrough"
EXTRA_FLAGS="$EXTRA_FLAGS -Wmissing-prototypes"
EXTRA_FLAGS="$EXTRA_FLAGS -Wmissing-declarations"
EXTRA_FLAGS="$EXTRA_FLAGS -Wnested-externs"
EXTRA_FLAGS="$EXTRA_FLAGS -Wno-long-long"
EXTRA_FLAGS="$EXTRA_FLAGS -Wno-strict-aliasing"
EXTRA_FLAGS="$EXTRA_FLAGS -Wpointer-arith"
EXTRA_FLAGS="$EXTRA_FLAGS -Wstrict-prototypes"
EXTRA_FLAGS="$EXTRA_FLAGS -Wwrite-strings"
EXTRA_FLAGS="$EXTRA_FLAGS -Wunused-but-set-variable"
EXTRA_FLAGS="$EXTRA_FLAGS -Wunsigned-char"
AS_IF([test x"$gcc_diagnostic_push_pull" = x"yes"],
[
AC_DEFINE([HAVE_FORMAT_NONLITERAL], [],
[gcc can complain about nonliterals in format])
EXTRA_FLAGS="$EXTRA_FLAGS -Wformat=2 -Wformat-nonliteral"
],
[test x"$gcc_format_nonliteral" = x"yes"],
[EXTRA_FLAGS="$EXTRA_FLAGS -Wformat=2"])
# Additional warnings it might be nice to enable one day
# -Wshadow
# -Wunreachable-code
for j in $EXTRA_FLAGS
do
AS_IF([cc_supports_flag $CC_EXTRAS $j], [CC_EXTRAS="$CC_EXTRAS $j"])
done
AC_MSG_NOTICE([Using additional gcc flags: ${CC_EXTRAS}])
])
dnl
dnl Hardening flags
dnl
dnl The prime control of whether to apply (targeted) hardening build flags and
dnl which ones is --{enable,disable}-hardening option passed to ./configure:
dnl
dnl --enable-hardening=try (default):
dnl depending on whether any of CFLAGS_HARDENED_EXE, LDFLAGS_HARDENED_EXE,
dnl CFLAGS_HARDENED_LIB or LDFLAGS_HARDENED_LIB environment variables
dnl (see below) is set and non-null, all these custom flags (even if not
dnl set) are used as are, otherwise the best effort is made to offer
dnl reasonably strong hardening in several categories (RELRO, PIE,
dnl "bind now", stack protector) according to what the selected toolchain
dnl can offer
dnl
dnl --enable-hardening:
dnl same effect as --enable-hardening=try when the environment variables
dnl in question are suppressed
dnl
dnl --disable-hardening:
dnl do not apply any targeted hardening measures at all
dnl
dnl The user-injected environment variables that regulate the hardening in
dnl default case are as follows:
dnl
dnl * CFLAGS_HARDENED_EXE, LDFLAGS_HARDENED_EXE
dnl compiler and linker flags (respectively) for daemon programs
dnl (pacemakerd, pacemaker-attrd, pacemaker-controld, pacemaker-execd,
dnl pacemaker-based, pacemaker-fenced, pacemaker-remoted,
dnl pacemaker-schedulerd)
dnl
dnl * CFLAGS_HARDENED_LIB, LDFLAGS_HARDENED_LIB
dnl compiler and linker flags (respectively) for libraries linked
dnl with the daemon programs
dnl
dnl Note that these are purposedly targeted variables (addressing particular
dnl targets all over the scattered Makefiles) and have no effect outside of
dnl the predestined scope (e.g., CLI utilities). For a global reach,
dnl use CFLAGS, LDFLAGS, etc. as usual.
dnl
dnl For guidance on the suitable flags consult, for instance:
dnl https://fedoraproject.org/wiki/Changes/Harden_All_Packages#Detailed_Harden_Flags_Description
dnl https://owasp.org/index.php/C-Based_Toolchain_Hardening#GCC.2FBinutils
dnl
AS_IF([test $enable_hardening -eq $OPTIONAL],
[
AS_IF([test "$(env | grep -Ec '^(C|LD)FLAGS_HARDENED_(EXE|LIB)=.')" = 0],
[enable_hardening=$REQUIRED],
[AC_MSG_NOTICE([Hardening: using custom flags from environment])]
)
],
[
unset CFLAGS_HARDENED_EXE
unset CFLAGS_HARDENED_LIB
unset LDFLAGS_HARDENED_EXE
unset LDFLAGS_HARDENED_LIB
]
)
AS_CASE([$enable_hardening],
[$DISABLED], [AC_MSG_NOTICE([Hardening: explicitly disabled])],
[$REQUIRED], [
CFLAGS_HARDENED_EXE=
CFLAGS_HARDENED_LIB=
LDFLAGS_HARDENED_EXE=
LDFLAGS_HARDENED_LIB=
relro=0
pie=0
bindnow=0
stackprot="none"
# daemons incl. libs: partial RELRO
flag="-Wl,-z,relro"
CC_CHECK_LDFLAGS(["${flag}"],
[
LDFLAGS_HARDENED_EXE="${LDFLAGS_HARDENED_EXE} ${flag}"
LDFLAGS_HARDENED_LIB="${LDFLAGS_HARDENED_LIB} ${flag}"
relro=1
])
# daemons: PIE for both CFLAGS and LDFLAGS
AS_IF([cc_supports_flag -fPIE],
[
flag="-pie"
CC_CHECK_LDFLAGS(["${flag}"],
[
CFLAGS_HARDENED_EXE="${CFLAGS_HARDENED_EXE} -fPIE"
LDFLAGS_HARDENED_EXE="${LDFLAGS_HARDENED_EXE} ${flag}"
pie=1
])
]
)
# daemons incl. libs: full RELRO if sensible + as-needed linking
# so as to possibly mitigate startup performance
# hit caused by excessive linking with unneeded
# libraries
AS_IF([test "${relro}" = 1 && test "${pie}" = 1],
[
flag="-Wl,-z,now"
CC_CHECK_LDFLAGS(["${flag}"],
[
LDFLAGS_HARDENED_EXE="${LDFLAGS_HARDENED_EXE} ${flag}"
LDFLAGS_HARDENED_LIB="${LDFLAGS_HARDENED_LIB} ${flag}"
bindnow=1
])
]
)
AS_IF([test "${bindnow}" = 1],
[
flag="-Wl,--as-needed"
CC_CHECK_LDFLAGS(["${flag}"],
[
LDFLAGS_HARDENED_EXE="${LDFLAGS_HARDENED_EXE} ${flag}"
LDFLAGS_HARDENED_LIB="${LDFLAGS_HARDENED_LIB} ${flag}"
])
])
# universal: prefer strong > all > default stack protector if possible
flag=
AS_IF([cc_supports_flag -fstack-protector-strong],
[
flag="-fstack-protector-strong"
stackprot="strong"
],
[cc_supports_flag -fstack-protector-all],
[
flag="-fstack-protector-all"
stackprot="all"
],
[cc_supports_flag -fstack-protector],
[
flag="-fstack-protector"
stackprot="default"
]
)
AS_IF([test -n "${flag}"], [CC_EXTRAS="${CC_EXTRAS} ${flag}"])
# universal: enable stack clash protection if possible
AS_IF([cc_supports_flag -fstack-clash-protection],
[
CC_EXTRAS="${CC_EXTRAS} -fstack-clash-protection"
AS_IF([test "${stackprot}" = "none"],
[stackprot="clash-only"],
[stackprot="${stackprot}+clash"]
)
]
)
# Log a summary
AS_IF([test "${relro}" = 1 || test "${pie}" = 1 || test x"${stackprot}" != x"none"],
[AC_MSG_NOTICE(m4_normalize([Hardening:
relro=${relro}
pie=${pie}
bindnow=${bindnow}
stackprot=${stackprot}]))
],
[AC_MSG_WARN([Hardening: no suitable features in the toolchain detected])]
)
],
)
CFLAGS="$SANITIZERS_CFLAGS $CFLAGS $CC_EXTRAS"
LDFLAGS="$SANITIZERS_LDFLAGS $LDFLAGS"
CFLAGS_HARDENED_EXE="$SANITIZERS_CFLAGS $CFLAGS_HARDENED_EXE"
LDFLAGS_HARDENED_EXE="$SANITIZERS_LDFLAGS $LDFLAGS_HARDENED_EXE"
NON_FATAL_CFLAGS="$CFLAGS"
AC_SUBST(NON_FATAL_CFLAGS)
dnl
dnl We reset CFLAGS to include our warnings *after* all function
dnl checking goes on, so that our warning flags don't keep the
dnl AC_*FUNCS() calls above from working. In particular, -Werror will
dnl *always* cause us troubles if we set it before here.
dnl
dnl
AS_IF([test $enable_fatal_warnings -ne $DISABLED], [
AC_MSG_NOTICE([Enabling fatal compiler warnings])
CFLAGS="$CFLAGS $WERROR"
])
AC_SUBST(CFLAGS)
dnl This is useful for use in Makefiles that need to remove one specific flag
CFLAGS_COPY="$CFLAGS"
AC_SUBST(CFLAGS_COPY)
AC_SUBST(LIBADD_DL) dnl extra flags for dynamic linking libraries
AC_SUBST(LOCALE)
dnl Options for cleaning up the compiler output
AS_IF([test $enable_quiet -ne $DISABLED],
[
AC_MSG_NOTICE([Suppressing make details])
QUIET_LIBTOOL_OPTS="--silent"
QUIET_MAKE_OPTS="-s" # POSIX compliant
],
[
QUIET_LIBTOOL_OPTS=""
QUIET_MAKE_OPTS=""
]
)
dnl Put the above variables to use
LIBTOOL="${LIBTOOL} --tag=CC \$(QUIET_LIBTOOL_OPTS)"
MAKEFLAGS="${MAKEFLAGS} ${QUIET_MAKE_OPTS}"
# Make features list available (sorted alphabetically, without leading space)
PCMK_FEATURES=`echo "$PCMK_FEATURES" | sed -e 's/^ //' -e 's/ /\n/g' | sort | xargs`
AC_DEFINE_UNQUOTED(CRM_FEATURES, "$PCMK_FEATURES", Set of enabled features)
AC_SUBST(PCMK_FEATURES)
AC_SUBST(CC)
AC_SUBST(MAKEFLAGS)
AC_SUBST(LIBTOOL)
AC_SUBST(QUIET_LIBTOOL_OPTS)
dnl Files we output that need to be executable
CONFIG_FILES_EXEC([agents/ocf/ClusterMon],
[agents/ocf/Dummy],
[agents/ocf/HealthCPU],
[agents/ocf/HealthIOWait],
[agents/ocf/HealthSMART],
[agents/ocf/Stateful],
[agents/ocf/SysInfo],
[agents/ocf/attribute],
[agents/ocf/controld],
[agents/ocf/ifspeed],
[agents/ocf/o2cb],
[agents/ocf/ping],
[agents/ocf/remote],
[agents/stonith/fence_legacy],
[agents/stonith/fence_watchdog],
[cts/cluster_test],
[cts/cts],
[cts/cts-attrd],
[cts/cts-cli],
[cts/cts-exec],
[cts/cts-fencing],
[cts/cts-lab],
[cts/cts-log-watcher],
[cts/cts-regression],
[cts/cts-scheduler],
[cts/benchmark/clubench],
[cts/support/LSBDummy],
[cts/support/cts-support],
[cts/support/fence_dummy],
[cts/support/pacemaker-cts-dummyd],
[doc/abi-check],
[maint/bumplibs],
[tools/cluster-clean],
[tools/cluster-helper],
[tools/cluster-init],
[tools/crm_failcount],
[tools/crm_master],
[tools/crm_report],
[tools/crm_standby],
[tools/cibsecret],
[tools/pcmk_simtimes])
dnl Other files we output
AC_CONFIG_FILES(Makefile \
agents/Makefile \
agents/alerts/Makefile \
agents/ocf/Makefile \
agents/stonith/Makefile \
cts/Makefile \
cts/benchmark/Makefile \
cts/scheduler/Makefile \
cts/scheduler/dot/Makefile \
cts/scheduler/exp/Makefile \
cts/scheduler/scores/Makefile \
cts/scheduler/stderr/Makefile \
cts/scheduler/summary/Makefile \
cts/scheduler/xml/Makefile \
cts/support/Makefile \
cts/support/pacemaker-cts-dummyd@.service \
daemons/Makefile \
daemons/attrd/Makefile \
daemons/based/Makefile \
daemons/controld/Makefile \
daemons/execd/Makefile \
daemons/execd/pacemaker_remote \
daemons/execd/pacemaker_remote.service \
daemons/fenced/Makefile \
daemons/pacemakerd/Makefile \
daemons/pacemakerd/pacemaker.combined.upstart \
daemons/pacemakerd/pacemaker.service \
daemons/pacemakerd/pacemaker.upstart \
daemons/schedulerd/Makefile \
devel/Makefile \
doc/Doxyfile \
doc/Makefile \
doc/sphinx/Makefile \
etc/Makefile \
etc/init.d/pacemaker \
etc/logrotate.d/pacemaker \
etc/sysconfig/pacemaker \
include/Makefile \
include/crm/Makefile \
include/crm/cib/Makefile \
include/crm/common/Makefile \
include/crm/cluster/Makefile \
include/crm/fencing/Makefile \
include/crm/pengine/Makefile \
include/pcmki/Makefile \
lib/Makefile \
lib/cib/Makefile \
lib/cluster/Makefile \
lib/common/Makefile \
lib/common/tests/Makefile \
lib/common/tests/acl/Makefile \
lib/common/tests/actions/Makefile \
lib/common/tests/agents/Makefile \
lib/common/tests/cmdline/Makefile \
lib/common/tests/flags/Makefile \
lib/common/tests/health/Makefile \
lib/common/tests/io/Makefile \
lib/common/tests/iso8601/Makefile \
lib/common/tests/lists/Makefile \
lib/common/tests/nvpair/Makefile \
lib/common/tests/options/Makefile \
lib/common/tests/output/Makefile \
lib/common/tests/procfs/Makefile \
lib/common/tests/results/Makefile \
lib/common/tests/scores/Makefile \
lib/common/tests/strings/Makefile \
lib/common/tests/utils/Makefile \
lib/common/tests/xml/Makefile \
lib/common/tests/xpath/Makefile \
lib/fencing/Makefile \
lib/gnu/Makefile \
lib/libpacemaker.pc \
lib/lrmd/Makefile \
lib/pacemaker/Makefile \
lib/pacemaker.pc \
lib/pacemaker-cib.pc \
lib/pacemaker-cluster.pc \
lib/pacemaker-fencing.pc \
lib/pacemaker-lrmd.pc \
lib/pacemaker-service.pc \
lib/pacemaker-pe_rules.pc \
lib/pacemaker-pe_status.pc \
lib/pengine/Makefile \
lib/pengine/tests/Makefile \
lib/pengine/tests/native/Makefile \
lib/pengine/tests/rules/Makefile \
lib/pengine/tests/status/Makefile \
lib/pengine/tests/unpack/Makefile \
lib/pengine/tests/utils/Makefile \
lib/services/Makefile \
maint/Makefile \
po/Makefile.in \
python/Makefile \
python/setup.py \
python/pacemaker/Makefile \
python/pacemaker/_cts/Makefile \
python/pacemaker/_cts/tests/Makefile \
python/pacemaker/buildoptions.py \
python/tests/Makefile \
replace/Makefile \
rpm/Makefile \
tests/Makefile \
tools/Makefile \
tools/crm_mon.service \
tools/crm_mon.upstart \
tools/report.collector \
tools/report.common \
xml/Makefile \
xml/pacemaker-schemas.pc \
)
dnl Now process the entire list of files added by previous
dnl calls to AC_CONFIG_FILES()
AC_OUTPUT()
dnl *****************
dnl Configure summary
dnl *****************
AC_MSG_NOTICE([])
AC_MSG_NOTICE([$PACKAGE configuration:])
AC_MSG_NOTICE([ Version = ${VERSION} (Build: $BUILD_VERSION)])
AC_MSG_NOTICE([ Features = ${PCMK_FEATURES}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Prefix = ${prefix}])
AC_MSG_NOTICE([ Executables = ${sbindir}])
AC_MSG_NOTICE([ Man pages = ${mandir}])
AC_MSG_NOTICE([ Libraries = ${libdir}])
AC_MSG_NOTICE([ Header files = ${includedir}])
AC_MSG_NOTICE([ Arch-independent files = ${datadir}])
AC_MSG_NOTICE([ State information = ${localstatedir}])
AC_MSG_NOTICE([ System configuration = ${sysconfdir}])
AC_MSG_NOTICE([ OCF agents = ${OCF_ROOT_DIR}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ HA group name = ${CRM_DAEMON_GROUP}])
AC_MSG_NOTICE([ HA user name = ${CRM_DAEMON_USER}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ CFLAGS = ${CFLAGS}])
AC_MSG_NOTICE([ CFLAGS_HARDENED_EXE = ${CFLAGS_HARDENED_EXE}])
AC_MSG_NOTICE([ CFLAGS_HARDENED_LIB = ${CFLAGS_HARDENED_LIB}])
AC_MSG_NOTICE([ LDFLAGS_HARDENED_EXE = ${LDFLAGS_HARDENED_EXE}])
AC_MSG_NOTICE([ LDFLAGS_HARDENED_LIB = ${LDFLAGS_HARDENED_LIB}])
AC_MSG_NOTICE([ Libraries = ${LIBS}])
AC_MSG_NOTICE([ Stack Libraries = ${CLUSTERLIBS}])
AC_MSG_NOTICE([ Unix socket auth method = ${us_auth}])
diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am
index c4ade5c67a..e144172a09 100644
--- a/doc/sphinx/Makefile.am
+++ b/doc/sphinx/Makefile.am
@@ -1,198 +1,200 @@
#
# Copyright 2003-2023 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
include $(top_srcdir)/mk/common.mk
# Define release-related variables
include $(top_srcdir)/mk/release.mk
# Things you might want to override on the command line
# Books to generate
BOOKS ?= Clusters_from_Scratch \
Pacemaker_Administration \
Pacemaker_Development \
Pacemaker_Explained \
Pacemaker_Python_API \
Pacemaker_Remote
# Output formats to generate. Possible values:
# html (multiple HTML files)
# dirhtml (HTML files named index.html in multiple directories)
# singlehtml (a single large HTML file)
# text
# pdf
# epub
# latex
# linkcheck (not actually a format; check validity of external links)
#
# The results will end up in <book>/_build/<format>
BOOK_FORMATS ?= singlehtml
# Set to "a4paper" or "letterpaper" if building latex format
PAPER ?= letterpaper
# Additional options for sphinx-build
SPHINXFLAGS ?=
# toplevel rsync destination for www targets (without trailing slash)
RSYNC_DEST ?= root@www.clusterlabs.org:/var/www/html
# End of useful overrides
# Example scheduler transition graphs
# @TODO The original CIB XML for these is long lost. Ideally, we would recreate
# something similar and keep those here instead of the DOTs (or use a couple of
# scheduler regression test inputs instead), then regenerate the SVG
# equivalents using crm_simulate and dot when making a release.
DOTS = $(wildcard shared/images/*.dot)
# Vector sources for generated PNGs (including SVG equivalents of DOTS, created
# manually using dot)
SVGS = $(wildcard shared/images/pcmk-*.svg) $(DOTS:%.dot=%.svg)
# PNG images generated from SVGS
#
# These will not be accessible in a VPATH build, which will generate warnings
# when building the documentation, but the make will still succeed. It is
# nontrivial to get them working for VPATH builds and not worth the effort.
PNGS_GENERATED = $(SVGS:%.svg=%.png)
# Original PNG image sources
PNGS_Clusters_from_Scratch = $(wildcard Clusters_from_Scratch/images/*.png)
PNGS_Pacemaker_Explained = $(wildcard Pacemaker_Explained/images/*.png)
PNGS_Pacemaker_Remote = $(wildcard Pacemaker_Remote/images/*.png)
STATIC_FILES = $(wildcard _static/*.css)
EXTRA_DIST = $(wildcard */*.rst) $(DOTS) $(SVGS) \
$(PNGS_Clusters_from_Scratch) \
$(PNGS_Pacemaker_Explained) \
$(PNGS_Pacemaker_Remote) \
$(wildcard Pacemaker_Python_API/_templates/*rst) \
$(STATIC_FILES) \
conf.py.in
# recursive, preserve symlinks/permissions/times, verbose, compress,
# don't cross filesystems, sparse, show progress
RSYNC_OPTS = -rlptvzxS --progress
+PACKAGE_SERIES=$(shell echo "$VERSION" | awk -F. '{ print $1"."$2 }'`)
+
BOOK_RSYNC_DEST = $(RSYNC_DEST)/$(PACKAGE)/doc/$(PACKAGE_SERIES)
BOOK = none
DEPS_intro = shared/pacemaker-intro.rst $(PNGS_GENERATED)
DEPS_Clusters_from_Scratch = $(DEPS_intro) $(PNGS_Clusters_from_Scratch)
DEPS_Pacemaker_Administration = $(DEPS_intro)
DEPS_Pacemaker_Development =
DEPS_Pacemaker_Explained = $(DEPS_intro) $(PNGS_Pacemaker_Explained)
DEPS_Pacemaker_Python_API = ../../python
DEPS_Pacemaker_Remote = $(PNGS_Pacemaker_Remote)
if BUILD_SPHINX_DOCS
INKSCAPE_CMD = $(INKSCAPE) --export-dpi=90 -C
# Pattern rule to generate PNGs from SVGs
# (--export-png works with Inkscape <1.0, --export-filename with >=1.0;
# create the destination directory in case this is a VPATH build)
%.png: %.svg
$(AM_V_at)-$(MKDIR_P) "$(shell dirname "$@")"
$(AM_V_GEN) { \
$(INKSCAPE_CMD) --export-png="$@" "$<" 2>/dev/null \
|| $(INKSCAPE_CMD) --export-filename="$@" "$<"; \
} $(PCMK_quiet)
# Create a book's Sphinx configuration.
# Create the book directory in case this is a VPATH build.
$(BOOKS:%=%/conf.py): conf.py.in
$(AM_V_at)-$(MKDIR_P) "$(@:%/conf.py=%)"
$(AM_V_GEN)sed \
-e 's/%VERSION%/$(VERSION)/g' \
-e 's/%BOOK_ID%/$(@:%/conf.py=%)/g' \
-e 's/%BOOK_TITLE%/$(subst _, ,$(@:%/conf.py=%))/g' \
-e 's#%SRC_DIR%#$(abs_srcdir)#g' \
-e 's#%ABS_TOP_SRCDIR%#$(abs_top_srcdir)#g' \
$(<) > "$@"
$(BOOK)/_build: $(STATIC_FILES) $(BOOK)/conf.py $(DEPS_$(BOOK)) $(wildcard $(srcdir)/$(BOOK)/*.rst)
@echo 'Building "$(subst _, ,$(BOOK))" because of $?' $(PCMK_quiet)
$(AM_V_at)rm -rf "$@"
$(AM_V_BOOK)for format in $(BOOK_FORMATS); do \
echo -e "\n * Building $$format" $(PCMK_quiet); \
doctrees="doctrees"; \
real_format="$$format"; \
case "$$format" in \
pdf) real_format="latex" ;; \
gettext) doctrees="gettext-doctrees" ;; \
esac; \
$(SPHINX) -b "$$real_format" -d "$@/$$doctrees" \
-c "$(builddir)/$(BOOK)" \
-D latex_elements.papersize=$(PAPER) \
$(SPHINXFLAGS) \
"$(srcdir)/$(BOOK)" "$@/$$format" \
$(PCMK_quiet); \
if [ "$$format" = "pdf" ]; then \
$(MAKE) $(AM_MAKEFLAGS) -C "$@/$$format" \
all-pdf; \
fi; \
done
endif
build-$(PACKAGE_SERIES).txt: all
$(AM_V_GEN)echo "Generated on `date --utc` from version $(TAG)" > "$@"
.PHONY: books-upload
books-upload: all build-$(PACKAGE_SERIES).txt
if BUILD_SPHINX_DOCS
@echo "Uploading $(PACKAGE_SERIES) documentation set"
@for book in $(BOOKS); do \
echo " * $$book"; \
rsync $(RSYNC_OPTS) $(BOOK_FORMATS:%=$$book/_build/%) \
"$(BOOK_RSYNC_DEST)/$$book/"; \
done
@rsync $(RSYNC_OPTS) "$(builddir)/build-$(PACKAGE_SERIES).txt" \
"$(RSYNC_DEST)/$(PACKAGE)/doc"
all-local:
@for book in $(BOOKS); do \
$(MAKE) $(AM_MAKEFLAGS) BOOK=$$book \
PAPER="$(PAPER)" SPHINXFLAGS="$(SPHINXFLAGS)" \
BOOK_FORMATS="$(BOOK_FORMATS)" $$book/_build; \
done
install-data-local: all-local
$(AM_V_at)for book in $(BOOKS); do \
for format in $(BOOK_FORMATS); do \
formatdir="$$book/_build/$$format"; \
for f in `find "$$formatdir" -print`; do \
dname="`echo $$f | sed s:_build/::`"; \
dloc="$(DESTDIR)/$(docdir)/$$dname"; \
if [ -d "$$f" ]; then \
$(INSTALL) -d -m 755 "$$dloc"; \
else \
$(INSTALL_DATA) "$$f" "$$dloc"; \
fi \
done; \
done; \
done
uninstall-local:
$(AM_V_at)for book in $(BOOKS); do \
rm -rf "$(DESTDIR)/$(docdir)/$$book"; \
done
endif
clean-local:
$(AM_V_at)-rm -rf \
$(BOOKS:%="$(builddir)/%/_build") \
$(BOOKS:%="$(builddir)/%/conf.py") \
$(BOOKS:%="$(builddir)/%/generated") \
$(PNGS_GENERATED)
diff --git a/include/Makefile.am b/include/Makefile.am
index dfd7085d7b..ffc25068ae 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,40 +1,40 @@
#
-# Copyright 2003-2019 the Pacemaker project contributors
+# Copyright 2003-2023 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
MAINTAINERCLEANFILES = Makefile.in config.h.in
noinst_HEADERS = config.h \
crm_internal.h \
doxygen.h \
pacemaker.h \
pacemaker-internal.h \
portability.h \
gettext.h
pkginclude_HEADERS = crm_config.h
SUBDIRS = crm pcmki
# gettext.h is supplied by the gettext project
GETTEXT_H ?= $(datadir)/gettext/gettext.h
update-gettext:
@if [ ! -e "$(GETTEXT_H)" ]; then \
echo "$(GETTEXT_H) not found"; \
else \
cp "$(GETTEXT_H)" gettext.h; \
- git diff --quiet gettext.h 2>/dev/null; \
+ "$(GIT)" diff --quiet gettext.h 2>/dev/null; \
if [ $$? -eq 0 ]; then \
echo "No update needed"; \
else \
- git add gettext.h; \
+ "$(GIT)" add gettext.h; \
echo 'Review changes then run:'; \
echo 'git commit -m "Low: NLS: update gettext.h from upstream"'; \
fi \
fi
diff --git a/lib/common/mock.c b/lib/common/mock.c
index 2bd833466f..6f837adc0d 100644
--- a/lib/common/mock.c
+++ b/lib/common/mock.c
@@ -1,427 +1,451 @@
/*
- * Copyright 2021-2022 the Pacemaker project contributors
+ * Copyright 2021-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
+#include <crm_internal.h>
+
#include <errno.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <grp.h>
#include <cmocka.h>
#include "mock_private.h"
/* This file is only used when running "make check". It is built into
* libcrmcommon_test.a, not into libcrmcommon.so. It is used to support
* constructing mock versions of library functions for unit testing.
*
* HOW TO ADD A MOCKED FUNCTION:
*
* - In this file, declare a bool pcmk__mock_X variable, and define a __wrap_X
* function with the same prototype as the actual function that performs the
* desired behavior if pcmk__mock_X is true and calls __real_X otherwise.
* You can use cmocka's mock_type() and mock_ptr_type() to pass extra
* information to the mocked function (see existing examples for details).
*
* - In mock_private.h, add declarations for extern bool pcmk__mock_X and the
* __real_X and __wrap_X function prototypes.
*
* - In mk/tap.mk, add the function name to the WRAPPED variable.
*
* HOW TO USE A MOCKED FUNCTION:
*
* - #include "mock_private.h" in your test file.
*
* - Write your test cases using pcmk__mock_X and cmocka's will_return() as
* needed per the comments for the mocked function below. See existing test
* cases for examples.
*/
// LCOV_EXCL_START
/* calloc()
*
* If pcmk__mock_calloc is set to true, later calls to calloc() will return
* NULL and must be preceded by:
*
* expect_*(__wrap_calloc, nmemb[, ...]);
* expect_*(__wrap_calloc, size[, ...]);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*/
bool pcmk__mock_calloc = false;
void *
__wrap_calloc(size_t nmemb, size_t size)
{
if (!pcmk__mock_calloc) {
return __real_calloc(nmemb, size);
}
check_expected(nmemb);
check_expected(size);
return NULL;
}
/* getenv()
*
* If pcmk__mock_getenv is set to true, later calls to getenv() must be preceded
* by:
*
* expect_*(__wrap_getenv, name[, ...]);
* will_return(__wrap_getenv, return_value);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*/
bool pcmk__mock_getenv = false;
char *
__wrap_getenv(const char *name)
{
if (!pcmk__mock_getenv) {
return __real_getenv(name);
}
check_expected_ptr(name);
return mock_ptr_type(char *);
}
/* setenv()
*
* If pcmk__mock_setenv is set to true, later calls to setenv() must be preceded
* by:
*
* expect_*(__wrap_setenv, name[, ...]);
* expect_*(__wrap_setenv, value[, ...]);
* expect_*(__wrap_setenv, overwrite[, ...]);
* will_return(__wrap_setenv, errno_to_set);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*
* The mocked function will return 0 if errno_to_set is 0, and -1 otherwise.
*/
bool pcmk__mock_setenv = false;
int
__wrap_setenv(const char *name, const char *value, int overwrite)
{
if (!pcmk__mock_setenv) {
return __real_setenv(name, value, overwrite);
}
check_expected_ptr(name);
check_expected_ptr(value);
check_expected(overwrite);
errno = mock_type(int);
return (errno == 0)? 0 : -1;
}
/* unsetenv()
*
* If pcmk__mock_unsetenv is set to true, later calls to unsetenv() must be
* preceded by:
*
* expect_*(__wrap_unsetenv, name[, ...]);
* will_return(__wrap_setenv, errno_to_set);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*
* The mocked function will return 0 if errno_to_set is 0, and -1 otherwise.
*/
bool pcmk__mock_unsetenv = false;
int
__wrap_unsetenv(const char *name)
{
if (!pcmk__mock_unsetenv) {
return __real_unsetenv(name);
}
check_expected_ptr(name);
errno = mock_type(int);
return (errno == 0)? 0 : -1;
}
/* getpid()
*
* If pcmk__mock_getpid is set to true, later calls to getpid() must be preceded
* by:
*
* will_return(__wrap_getpid, return_value);
*/
bool pcmk__mock_getpid = false;
pid_t
__wrap_getpid(void)
{
return pcmk__mock_getpid? mock_type(pid_t) : __real_getpid();
}
/* setgrent(), getgrent() and endgrent()
*
* If pcmk__mock_grent is set to true, getgrent() will behave as if the only
* groups on the system are:
*
* - grp0 (user0, user1)
* - grp1 (user1)
* - grp2 (user2, user1)
*/
bool pcmk__mock_grent = false;
// Index of group that will be returned next from getgrent()
static int group_idx = 0;
// Data used for testing
static const char* grp0_members[] = {
"user0", "user1", NULL
};
static const char* grp1_members[] = {
"user1", NULL
};
static const char* grp2_members[] = {
"user2", "user1", NULL
};
/* An array of "groups" (a struct from grp.h)
*
* The members of the groups are initalized here to some testing data, casting
* away the consts to make the compiler happy and simplify initialization. We
* never actually change these variables during the test!
*
* string literal = const char* (cannot be changed b/c ? )
* vs. char* (it's getting casted to this)
*/
static const int NUM_GROUPS = 3;
static struct group groups[] = {
{(char*)"grp0", (char*)"", 0, (char**)grp0_members},
{(char*)"grp1", (char*)"", 1, (char**)grp1_members},
{(char*)"grp2", (char*)"", 2, (char**)grp2_members},
};
// This function resets the group_idx to 0.
void
__wrap_setgrent(void) {
if (pcmk__mock_grent) {
group_idx = 0;
} else {
__real_setgrent();
}
}
/* This function returns the next group entry in the list of groups, or
* NULL if there aren't any left.
* group_idx is a global variable which keeps track of where you are in the list
*/
struct group *
__wrap_getgrent(void) {
if (pcmk__mock_grent) {
if (group_idx >= NUM_GROUPS) {
return NULL;
}
return &groups[group_idx++];
} else {
return __real_getgrent();
}
}
void
__wrap_endgrent(void) {
if (!pcmk__mock_grent) {
__real_endgrent();
}
}
/* fopen()
*
* If pcmk__mock_fopen is set to true, later calls to fopen() must be
* preceded by:
*
* expect_*(__wrap_fopen, pathname[, ...]);
* expect_*(__wrap_fopen, mode[, ...]);
* will_return(__wrap_fopen, errno_to_set);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
+ *
+ * This has two mocked functions, since fopen() is sometimes actually fopen64().
*/
bool pcmk__mock_fopen = false;
FILE *
__wrap_fopen(const char *pathname, const char *mode)
{
if (pcmk__mock_fopen) {
check_expected_ptr(pathname);
check_expected_ptr(mode);
errno = mock_type(int);
if (errno != 0) {
return NULL;
} else {
return __real_fopen(pathname, mode);
}
} else {
return __real_fopen(pathname, mode);
}
}
+#ifdef HAVE_FOPEN64
+FILE *
+__wrap_fopen64(const char *pathname, const char *mode)
+{
+ if (pcmk__mock_fopen) {
+ check_expected_ptr(pathname);
+ check_expected_ptr(mode);
+ errno = mock_type(int);
+
+ if (errno != 0) {
+ return NULL;
+ } else {
+ return __real_fopen64(pathname, mode);
+ }
+
+ } else {
+ return __real_fopen64(pathname, mode);
+ }
+}
+#endif
/* getpwnam_r()
*
* If pcmk__mock_getpwnam_r is set to true, later calls to getpwnam_r() must be
* preceded by:
*
* expect_*(__wrap_getpwnam_r, name[, ...]);
* expect_*(__wrap_getpwnam_r, pwd[, ...]);
* expect_*(__wrap_getpwnam_r, buf[, ...]);
* expect_*(__wrap_getpwnam_r, buflen[, ...]);
* expect_*(__wrap_getpwnam_r, result[, ...]);
* will_return(__wrap_getpwnam_r, return_value);
* will_return(__wrap_getpwnam_r, ptr_to_result_struct);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*/
bool pcmk__mock_getpwnam_r = false;
int
__wrap_getpwnam_r(const char *name, struct passwd *pwd, char *buf,
size_t buflen, struct passwd **result)
{
if (pcmk__mock_getpwnam_r) {
int retval = mock_type(int);
check_expected_ptr(name);
check_expected_ptr(pwd);
check_expected_ptr(buf);
check_expected(buflen);
check_expected_ptr(result);
*result = mock_ptr_type(struct passwd *);
return retval;
} else {
return __real_getpwnam_r(name, pwd, buf, buflen, result);
}
}
/*
* If pcmk__mock_readlink is set to true, later calls to readlink() must be
* preceded by:
*
* expect_*(__wrap_readlink, path[, ...]);
* expect_*(__wrap_readlink, buf[, ...]);
* expect_*(__wrap_readlink, bufsize[, ...]);
* will_return(__wrap_readlink, errno_to_set);
* will_return(__wrap_readlink, link_contents);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*
* The mocked function will return 0 if errno_to_set is 0, and -1 otherwise.
*/
bool pcmk__mock_readlink = false;
ssize_t
__wrap_readlink(const char *restrict path, char *restrict buf,
size_t bufsize)
{
if (pcmk__mock_readlink) {
const char *contents = NULL;
check_expected_ptr(path);
check_expected_ptr(buf);
check_expected(bufsize);
errno = mock_type(int);
contents = mock_ptr_type(const char *);
if (errno == 0) {
strncpy(buf, contents, bufsize - 1);
return strlen(contents);
}
return -1;
} else {
return __real_readlink(path, buf, bufsize);
}
}
/* strdup()
*
* If pcmk__mock_strdup is set to true, later calls to strdup() will return
* NULL and must be preceded by:
*
* expect_*(__wrap_strdup, s[, ...]);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*/
bool pcmk__mock_strdup = false;
char *
__wrap_strdup(const char *s)
{
if (!pcmk__mock_strdup) {
return __real_strdup(s);
}
check_expected_ptr(s);
return NULL;
}
/* uname()
*
* If pcmk__mock_uname is set to true, later calls to uname() must be preceded
* by:
*
* expect_*(__wrap_uname, buf[, ...]);
* will_return(__wrap_uname, return_value);
* will_return(__wrap_uname, node_name_for_buf_parameter_to_uname);
*
* expect_* functions: https://api.cmocka.org/group__cmocka__param.html
*/
bool pcmk__mock_uname = false;
int
__wrap_uname(struct utsname *buf)
{
if (pcmk__mock_uname) {
int retval = 0;
char *result = NULL;
check_expected_ptr(buf);
retval = mock_type(int);
result = mock_ptr_type(char *);
if (result != NULL) {
strcpy(buf->nodename, result);
}
return retval;
} else {
return __real_uname(buf);
}
}
// LCOV_EXCL_STOP
diff --git a/lib/common/mock_private.h b/lib/common/mock_private.h
index 45207c4eaa..b0e0ed2769 100644
--- a/lib/common/mock_private.h
+++ b/lib/common/mock_private.h
@@ -1,77 +1,81 @@
/*
- * Copyright 2021-2022 the Pacemaker project contributors
+ * Copyright 2021-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef MOCK_PRIVATE__H
# define MOCK_PRIVATE__H
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <grp.h>
/* This header is for the sole use of libcrmcommon_test and unit tests */
extern bool pcmk__mock_calloc;
void *__real_calloc(size_t nmemb, size_t size);
void *__wrap_calloc(size_t nmemb, size_t size);
extern bool pcmk__mock_fopen;
FILE *__real_fopen(const char *pathname, const char *mode);
FILE *__wrap_fopen(const char *pathname, const char *mode);
+#ifdef HAVE_FOPEN64
+FILE *__real_fopen64(const char *pathname, const char *mode);
+FILE *__wrap_fopen64(const char *pathname, const char *mode);
+#endif
extern bool pcmk__mock_getenv;
char *__real_getenv(const char *name);
char *__wrap_getenv(const char *name);
extern bool pcmk__mock_setenv;
int __real_setenv(const char *name, const char *value, int overwrite);
int __wrap_setenv(const char *name, const char *value, int overwrite);
extern bool pcmk__mock_unsetenv;
int __real_unsetenv(const char *name);
int __wrap_unsetenv(const char *name);
extern bool pcmk__mock_getpid;
pid_t __real_getpid(void);
pid_t __wrap_getpid(void);
extern bool pcmk__mock_grent;
void __real_setgrent(void);
void __wrap_setgrent(void);
struct group * __wrap_getgrent(void);
struct group * __real_getgrent(void);
void __wrap_endgrent(void);
void __real_endgrent(void);
extern bool pcmk__mock_getpwnam_r;
int __real_getpwnam_r(const char *name, struct passwd *pwd,
char *buf, size_t buflen, struct passwd **result);
int __wrap_getpwnam_r(const char *name, struct passwd *pwd,
char *buf, size_t buflen, struct passwd **result);
extern bool pcmk__mock_readlink;
ssize_t __real_readlink(const char *restrict path, char *restrict buf,
size_t bufsize);
ssize_t __wrap_readlink(const char *restrict path, char *restrict buf,
size_t bufsize);
extern bool pcmk__mock_strdup;
char *__real_strdup(const char *s);
char *__wrap_strdup(const char *s);
extern bool pcmk__mock_uname;
int __real_uname(struct utsname *buf);
int __wrap_uname(struct utsname *buf);
#endif // MOCK_PRIVATE__H
diff --git a/lib/common/tests/output/pcmk__output_new_test.c b/lib/common/tests/output/pcmk__output_new_test.c
index de4268cf66..a05d9a715f 100644
--- a/lib/common/tests/output/pcmk__output_new_test.c
+++ b/lib/common/tests/output/pcmk__output_new_test.c
@@ -1,148 +1,154 @@
/*
- * Copyright 2022 the Pacemaker project contributors
+ * Copyright 2022-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU General Public License version 2
* or later (GPLv2+) WITHOUT ANY WARRANTY.
*/
#include <crm_internal.h>
#include <crm/common/unittest_internal.h>
#include <crm/common/output_internal.h>
#include "mock_private.h"
static bool init_succeeds = true;
static bool
fake_text_init(pcmk__output_t *out) {
return init_succeeds;
}
static void
fake_text_free_priv(pcmk__output_t *out) {
/* This function intentionally left blank */
}
/* "text" is the default for pcmk__output_new. */
static pcmk__output_t *
mk_fake_text_output(char **argv) {
pcmk__output_t *retval = calloc(1, sizeof(pcmk__output_t));
if (retval == NULL) {
return NULL;
}
retval->fmt_name = "text";
retval->init = fake_text_init;
retval->free_priv = fake_text_free_priv;
retval->register_message = pcmk__register_message;
retval->message = pcmk__call_message;
return retval;
}
static int
setup(void **state) {
pcmk__register_format(NULL, "text", mk_fake_text_output, NULL);
return 0;
}
static int
teardown(void **state) {
pcmk__unregister_formats();
return 0;
}
static void
empty_formatters(void **state) {
pcmk__output_t *out = NULL;
pcmk__assert_asserts(pcmk__output_new(&out, "fake", NULL, NULL));
}
static void
invalid_params(void **state) {
/* This must be called with the setup/teardown functions so formatters is not NULL. */
pcmk__assert_asserts(pcmk__output_new(NULL, "fake", NULL, NULL));
}
static void
no_such_format(void **state) {
pcmk__output_t *out = NULL;
assert_int_equal(pcmk__output_new(&out, "fake", NULL, NULL), pcmk_rc_unknown_format);
}
static void
create_fails(void **state) {
pcmk__output_t *out = NULL;
pcmk__mock_calloc = true; // calloc() will return NULL
expect_value(__wrap_calloc, nmemb, 1);
expect_value(__wrap_calloc, size, sizeof(pcmk__output_t));
assert_int_equal(pcmk__output_new(&out, "text", NULL, NULL), ENOMEM);
pcmk__mock_calloc = false; // Use real calloc()
}
static void
fopen_fails(void **state) {
pcmk__output_t *out = NULL;
pcmk__mock_fopen = true;
+#if defined(HAVE_FOPEN64) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) && (SIZEOF_LONG < 8)
+ expect_string(__wrap_fopen64, pathname, "destfile");
+ expect_string(__wrap_fopen64, mode, "w");
+ will_return(__wrap_fopen64, EPERM);
+#else
expect_string(__wrap_fopen, pathname, "destfile");
expect_string(__wrap_fopen, mode, "w");
will_return(__wrap_fopen, EPERM);
+#endif
assert_int_equal(pcmk__output_new(&out, "text", "destfile", NULL), EPERM);
pcmk__mock_fopen = false;
}
static void
init_fails(void **state) {
pcmk__output_t *out = NULL;
init_succeeds = false;
assert_int_equal(pcmk__output_new(&out, "text", NULL, NULL), ENOMEM);
init_succeeds = true;
}
static void
everything_succeeds(void **state) {
pcmk__output_t *out = NULL;
assert_int_equal(pcmk__output_new(&out, "text", NULL, NULL), pcmk_rc_ok);
assert_string_equal(out->fmt_name, "text");
assert_ptr_equal(out->dest, stdout);
assert_false(out->quiet);
assert_non_null(out->messages);
assert_string_equal(getenv("OCF_OUTPUT_FORMAT"), "text");
pcmk__output_free(out);
}
static void
no_fmt_name_given(void **state) {
pcmk__output_t *out = NULL;
assert_int_equal(pcmk__output_new(&out, NULL, NULL, NULL), pcmk_rc_ok);
assert_string_equal(out->fmt_name, "text");
pcmk__output_free(out);
}
PCMK__UNIT_TEST(NULL, NULL,
cmocka_unit_test(empty_formatters),
cmocka_unit_test_setup_teardown(invalid_params, setup, teardown),
cmocka_unit_test_setup_teardown(no_such_format, setup, teardown),
cmocka_unit_test_setup_teardown(create_fails, setup, teardown),
cmocka_unit_test_setup_teardown(init_fails, setup, teardown),
cmocka_unit_test_setup_teardown(fopen_fails, setup, teardown),
cmocka_unit_test_setup_teardown(everything_succeeds, setup, teardown),
cmocka_unit_test_setup_teardown(no_fmt_name_given, setup, teardown))
diff --git a/maint/Makefile.am b/maint/Makefile.am
index 788dd46d62..66804d5a6a 100644
--- a/maint/Makefile.am
+++ b/maint/Makefile.am
@@ -1,107 +1,109 @@
#
-# Copyright 2019-2022 the Pacemaker project contributors
+# Copyright 2019-2023 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
# Define release-related variables
include $(abs_srcdir)/../mk/release.mk
noinst_SCRIPTS = bumplibs
EXTRA_DIST = README
#
# Change log generation
#
# Count changes in these directories
CHANGELOG_DIRS = ../include ../lib ../daemons ../tools ../xml
.PHONY: require_last_release
require_last_release:
@if [ -z "$(CHECKOUT)" ]; then \
echo "This target must be run from a git checkout"; \
exit 1; \
- elif ! git rev-parse $(LAST_RELEASE) >/dev/null 2>&1; then \
+ elif ! "$(GIT)" rev-parse $(LAST_RELEASE) >/dev/null 2>&1; then \
echo "LAST_RELEASE must be set to a valid git tag"; \
exit 1; \
fi
.PHONY: summary
summary: require_last_release
@printf "* %s %s <%s> %s\n" "$$(date +'%a %b %d %Y')" \
- "$$(git config user.name)" "$$(git config user.email)" \
+ "$$("$(GIT)" config user.name)" \
+ "$$("$(GIT)" config user.email)" \
"$(NEXT_RELEASE)"
@printf "\055 %d commits with%s\n" \
- "$$(git log --pretty=oneline --no-merges \
+ "$$("$(GIT)" log --pretty=oneline --no-merges \
$(LAST_RELEASE)..HEAD | wc -l)" \
- "$$(git diff $(LAST_RELEASE)..HEAD --shortstat \
+ "$$("$(GIT)" diff $(LAST_RELEASE)..HEAD --shortstat \
$(CHANGELOG_DIRS))"
.PHONY: changes
changes: summary
@printf "\n- Features added since $(LAST_RELEASE)\n"
- @git log --pretty=format:'%s' --no-merges \
+ @"$(GIT)" log --pretty=format:'%s' --no-merges \
--abbrev-commit $(LAST_RELEASE)..HEAD \
| sed -n -e 's/^ *Feature: */ + /p' | sort -uf
@printf "\n- Fixes since $(LAST_RELEASE)\n"
- @git log --pretty=format:'%s' --no-merges \
+ @"$(GIT)" log --pretty=format:'%s' --no-merges \
--abbrev-commit $(LAST_RELEASE)..HEAD \
| sed -n -e 's/^ *\(Fix\|High\|Bug\): */ + /p' | sed \
-e 's/\(cib\|pacemaker-based\|based\):/CIB:/' \
-e 's/\(lrmd\|pacemaker-execd\|execd\):/executor:/' \
-e 's/\(crmd\|pacemaker-controld\|controld\):/controller:/' \
-e 's/\(Fencing\|stonithd?\|pacemaker-fenced\|fenced\):/fencing:/' \
-e 's/\(PE\|pengine\|pacemaker-schedulerd\|schedulerd\):/scheduler:/' \
| sort -uf
@printf "\n- Public API changes since $(LAST_RELEASE)\n"
- @git log --pretty=format:'%s' --no-merges \
+ @"$(GIT)" log --pretty=format:'%s' --no-merges \
--abbrev-commit $(LAST_RELEASE)..HEAD \
| sed -n -e 's/^ *API: */ + /p' | sort -uf
.PHONY: changelog
changelog: require_last_release
@printf "%s\n\n%s\n" \
"$$($(MAKE) $(AM_MAKEFLAGS) changes \
| grep -v 'make\(\[[0-9]*\]\)\?:')" \
"$$(cat ../ChangeLog)" > ../ChangeLog
.PHONY: authors
authors: require_last_release
- git log $(LAST_RELEASE)..$(COMMIT) --format='%an' | sort -u
+ "$(GIT)" log $(LAST_RELEASE)..$(COMMIT) --format='%an' | sort -u
#
# gnulib updates
#
# See https://www.gnu.org/software/gnulib/manual/html_node/
#
# V3 = scandir unsetenv alphasort xalloc
# V2 = setenv strerror strchrnul strndup
GNU_MODS = crypto/md5-buffer
# stdint appears to be surrogate only for C99-lacking environments
GNU_MODS_AVOID = stdint
.PHONY: gnulib-update
gnulib-update:
@echo 'Newer versions of gnulib require automake 1.14'
@echo 'Pacemaker cannot update until minimum supported automake is 1.14'
@exit 1
if test -e gnulib; then \
- cd gnulib && git pull; \
+ cd gnulib && "$(GIT)" pull; \
else \
- git clone https://git.savannah.gnu.org/git/gnulib.git gnulib \
- && cd gnulib && git config pull.rebase false; \
+ "$(GIT)" clone https://git.savannah.gnu.org/git/gnulib.git \
+ gnulib \
+ && cd gnulib && "$(GIT)" config pull.rebase false; \
fi
cd $(top_srcdir) && maint/gnulib/gnulib-tool --source-base=lib/gnu \
--lgpl=2 --no-vc-files --no-conditional-dependencies --libtool \
$(GNU_MODS_AVOID:%=--avoid %) --import $(GNU_MODS)
sed -i -e "s/bundled(gnulib).*/bundled(gnulib) = `date +'%Y%m%d'`/" \
../rpm/pacemaker.spec.in
sed -i -e "s/_GL_EXTERN_INLINE/_GL_INLINE/" \
-e "s#left_over -= 64;#left_over \&= 63; /* helps static analysis */#" \
-e "s#&ctx->buffer\[16\]#\&(((char *) ctx->buffer)[64]) /* helps static analysis */#" \
../lib/gnu/md5.c
diff --git a/mk/release.mk b/mk/release.mk
index 7d7259cbaf..b10bcf0bd8 100644
--- a/mk/release.mk
+++ b/mk/release.mk
@@ -1,87 +1,90 @@
#
-# Copyright 2008-2022 the Pacemaker project contributors
+# Copyright 2008-2023 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
# Define variables related to release version and such
COMMIT ?= HEAD
# TAG defaults to DIST when in a source distribution instead of a git checkout,
# the tag name if COMMIT is tagged, and the full commit ID otherwise.
-TAG ?= $(shell \
- T=$$(git describe --tags --exact-match '$(COMMIT)' 2>/dev/null); \
- [ -n "$${T}" ] && echo "$${T}" \
- || git log --pretty=format:%H -n 1 '$(COMMIT)' 2>/dev/null \
+TAG ?= $(shell \
+ T=$$("$(GIT)" describe --tags --exact-match '$(COMMIT)' \
+ 2>/dev/null); \
+ [ -n "$${T}" ] && echo "$${T}" \
+ || "$(GIT)" log --pretty=format:%H -n 1 '$(COMMIT)' \
+ 2>/dev/null \
|| echo DIST)
# If DIRTY=anything is passed to make, generated versions will end in ".mod"
# as long as there are uncommitted changes and COMMIT is not changed from the
# default.
DIRTY_EXT = $(shell [ -n "$(DIRTY)" ] \
&& [ "$(COMMIT)" == "HEAD" ] \
- && ! git diff-index --quiet HEAD -- 2>/dev/null \
+ && ! "$(GIT)" diff-index --quiet HEAD -- \
+ 2>/dev/null \
&& echo .mod)
# These can be used in case statements to avoid make interpreting parentheses
lparen = (
rparen = )
# This will be empty if not in a git checkout
-CHECKOUT = $(shell git rev-parse --git-dir 2>/dev/null)
+CHECKOUT = $(shell "$(GIT)" rev-parse --git-dir 2>/dev/null)
# VERSION is set by configure, but we allow some make targets to be run without
# running configure first, so set a reasonable default in that case.
VERSION ?= $(shell if [ -z "$(CHECKOUT)" ]; then \
echo 0.0.0; \
else \
- git tag -l \
+ "$(GIT)" tag -l \
| sed -n -e 's/^\(Pacemaker-[0-9.]*\)$$/\1/p' \
| sort -Vr | head -n 1; \
fi)
# What the git tag would be for configured VERSION (such as "Pacemaker-2.1.5")
LAST_RELEASE ?= Pacemaker-$(VERSION)
# What the git tag would be for the release after the configured VERSION
# (LAST_RELEASE stripped of its -rc* suffix if present, or with minor-minor
# version bumped if not; this should be manually overriden when bumping
# the major or minor version)
NEXT_RELEASE ?= $(shell case "$(LAST_RELEASE)" in \
*-rc*$(rparen) \
echo $(LAST_RELEASE) | sed s:-rc.*:: ;; \
*$(rparen) \
echo $(LAST_RELEASE) | awk -F. \
'/[0-9]+\./{$$3+=1;OFS=".";print $$1,$$2,$$3}' \
;; \
esac)
# We have two make targets for creating distributions:
#
# - "make dist" is automake's native functionality, based on the various
# dist/nodist make variables; it always uses the current sources
#
# - "make export" is a custom target based on "git archive" and relevant
# entries from .gitattributes; it defaults to current sources but can use any
# git tag
#
# Both targets use the same name for the result, though they generate different
# contents.
#
# The directory is named pacemaker-<version> when in a source distribution
# instead of a git checkout, pacemaker-<version_part_of_tag> for tagged
# commits, and pacemaker-<short_commit> otherwise.
top_distdir = $(PACKAGE)-$(shell \
case $(TAG) in \
DIST$(rparen) \
[ -n "$(VERSION)" ] && echo "$(VERSION)" \
|| echo DIST;; \
Pacemaker-*$(rparen) \
echo '$(TAG)' | cut -c11-;; \
*$(rparen) \
- git log --pretty=format:%h -n 1 '$(TAG)';; \
+ "$(GIT)" log --pretty=format:%h -n 1 '$(TAG)';; \
esac)$(DIRTY_EXT)
diff --git a/mk/tap.mk b/mk/tap.mk
index da67813e02..df57e7f63b 100644
--- a/mk/tap.mk
+++ b/mk/tap.mk
@@ -1,31 +1,36 @@
#
-# Copyright 2021-2022 the Pacemaker project contributors
+# Copyright 2021-2023 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
AM_TESTS_ENVIRONMENT= \
G_DEBUG=gc-friendly \
MALLOC_CHECK_=2 \
MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tests/tap-driver.sh
LOG_COMPILER = $(top_srcdir)/tests/tap-test
CLEANFILES = *.log *.trs
WRAPPED = calloc \
endgrent \
fopen \
getenv \
getpid \
getgrent \
getpwnam_r \
readlink \
setenv \
setgrent \
strdup \
uname \
unsetenv
+
+if WRAPPABLE_FOPEN64
+WRAPPED += fopen64
+endif
+
LDFLAGS_WRAP = $(foreach fn,$(WRAPPED),-Wl,--wrap=$(fn))
diff --git a/rpm/Makefile.am b/rpm/Makefile.am
index 956252efc4..91e381aaf0 100644
--- a/rpm/Makefile.am
+++ b/rpm/Makefile.am
@@ -1,286 +1,291 @@
#
# Copyright 2003-2023 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
# We want to support the use case where this file is fed straight to make
# without running automake first, so define defaults for any automake variables
# used in this file.
top_srcdir ?= ..
abs_srcdir ?= $(shell pwd)
abs_builddir ?= $(abs_srcdir)
MAKE ?= make
PACKAGE ?= pacemaker
AM_V_at ?= @
MKDIR_P ?= mkdir -p
include $(top_srcdir)/mk/common.mk
include $(top_srcdir)/mk/release.mk
EXTRA_DIST = pacemaker.spec.in \
rpmlintrc
# Extra options to pass to rpmbuild (this can be used to override the location
# options this file normally passes, or to override macros used by the spec)
RPM_EXTRA ?=
# Where to put RPM artifacts; possible values:
#
# - subtree (default): RPM sources (i.e. TARFILE) in top-level build directory,
# everything else in dedicated "rpm" subdirectory of build tree
#
# - toplevel (deprecated): RPM sources, spec, and source rpm in top-level build
# directory, everything else uses the usual rpmbuild defaults
#
# - anything else: The value will be treated as a directory path to be used for
# all RPM artifacts. WARNING: The entire directory will get removed with
# "make clean" or "make rpm-clean".
#
RPMDEST ?= subtree
RPM_SPEC_DIR_subtree = $(abs_builddir)/SPECS
RPM_SRCRPM_DIR_subtree = $(abs_builddir)/SRPMS
RPM_OPTS_subtree = --define "_sourcedir $(abs_builddir)/.." \
--define "_topdir $(abs_builddir)"
RPM_CLEAN_subtree = "$(abs_builddir)/BUILD" \
"$(abs_builddir)/BUILDROOT" \
"$(abs_builddir)/RPMS" \
"$(abs_builddir)/SPECS" \
"$(abs_builddir)/SRPMS"
RPM_SPEC_DIR_toplevel = $(abs_builddir)/..
RPM_SRCRPM_DIR_toplevel = $(abs_builddir)/..
RPM_OPTS_toplevel = --define "_sourcedir $(abs_builddir)/.." \
--define "_specdir $(RPM_SPEC_DIR_toplevel)" \
--define "_srcrpmdir $(RPM_SRCRPM_DIR_toplevel)"
RPM_CLEAN_toplevel =
RPM_SPEC_DIR_other = $(RPMDEST)/SPECS
RPM_SRCRPM_DIR_other = $(RPMDEST)/SRPMS
RPM_OPTS_other = --define "_sourcedir $(abs_builddir)/.." \
--define "_topdir $(RPMDEST)"
RPM_CLEAN_other = "$(RPMDEST)"
RPMTYPE = $(shell case "$(RPMDEST)" in \
toplevel$(rparen) echo toplevel ;; \
subtree$(rparen) echo subtree ;; \
*$(rparen) echo other ;; \
esac)
RPM_SPEC_DIR = $(RPM_SPEC_DIR_$(RPMTYPE))
RPM_SRCRPM_DIR = $(RPM_SRCRPM_DIR_$(RPMTYPE))
RPM_OPTS = $(RPM_OPTS_$(RPMTYPE)) $(RPM_EXTRA)
RPM_CLEAN = $(RPM_CLEAN_$(RPMTYPE))
WITH ?= --without doc
# If $(BUILD_COUNTER) is an existing file, its contents will be used as the
# spec version in built RPMs, unless $(SPECVERSION) is set to override it,
# and the next increment will be written back to the file after building.
BUILD_COUNTER ?= $(shell test -e build.counter && echo build.counter || echo ../build.counter)
LAST_COUNT = $(shell test -e "$(BUILD_COUNTER)" && cat "$(BUILD_COUNTER)" || echo 0)
COUNT = $(shell expr 1 + $(LAST_COUNT))
SPECVERSION ?= $(COUNT)
# SPEC_COMMIT is identical to TAG for DIST and tagged releases, otherwise it is
# the short commit ID (which must be used in order for "make export" to use the
# same archive name as "make dist")
SPEC_COMMIT ?= $(shell \
case $(TAG) in \
Pacemaker-*|DIST$(rparen) \
echo '$(TAG)' ;; \
*$(rparen) \
- git log --pretty=format:%h -n 1 '$(TAG)';; \
+ "$(GIT)" log --pretty=format:%h -n 1 '$(TAG)';; \
esac)$(DIRTY_EXT)
SPEC_ABBREV = $(shell printf %s '$(SPEC_COMMIT)' | wc -c)
SPEC_RELEASE = $(shell case "$(WITH)" in \
*pre_release*$(rparen) \
[ "$(LAST_RELEASE)" = "$(TAG)" ] \
&& echo "$(LAST_RELEASE)" \
|| echo "$(NEXT_RELEASE)" ;; \
*$(rparen) \
echo "$(LAST_RELEASE)" ;; \
esac)
SPEC_RELEASE_NO = $(shell echo $(SPEC_RELEASE) | sed -e s:Pacemaker-:: -e s:-.*::)
MOCK_DIR = $(abs_builddir)/mock
MOCK_OPTIONS ?= --resultdir="$(MOCK_DIR)" --no-cleanup-after
F ?= $(shell test ! -e /etc/fedora-release && echo 0; test -e /etc/fedora-release && rpm --eval %{fedora})
ARCH ?= $(shell test ! -e /etc/fedora-release && uname -m; test -e /etc/fedora-release && rpm --eval %{_arch})
MOCK_CFG ?= $(shell test -e /etc/fedora-release && echo fedora-$(F)-$(ARCH))
distdir = $(top_distdir)/rpm
TARFILE = $(abs_builddir)/../$(top_distdir).tar.gz
# Create a source distribution based on a git archive. (If we aren't in a git
# checkout, do a make dist instead.)
export:
cd $(abs_srcdir)/..; \
if [ -z "$(CHECKOUT)" ] && [ -f "$(TARFILE)" ]; then \
echo "`date`: Using existing tarball: $(TARFILE)"; \
elif [ -z "$(CHECKOUT)" ]; then \
$(MAKE) $(AM_MAKEFLAGS) dist; \
echo "`date`: Rebuilt tarball: $(TARFILE)"; \
elif [ -n "$(DIRTY_EXT)" ]; then \
- git commit -m "DO-NOT-PUSH" -a; \
- git archive --prefix=$(top_distdir)/ -o "$(TARFILE)" HEAD^{tree}; \
- git reset --mixed HEAD^; \
+ "$(GIT)" commit -m "DO-NOT-PUSH" -a; \
+ "$(GIT)" archive --prefix=$(top_distdir)/ -o "$(TARFILE)" \
+ HEAD^{tree}; \
+ "$(GIT)" reset --mixed HEAD^; \
echo "`date`: Rebuilt $(TARFILE)"; \
elif [ -f "$(TARFILE)" ]; then \
echo "`date`: Using existing tarball: $(TARFILE)"; \
else \
- git archive --prefix=$(top_distdir)/ -o "$(TARFILE)" $(TAG)^{tree}; \
+ "$(GIT)" archive --prefix=$(top_distdir)/ -o "$(TARFILE)" \
+ $(TAG)^{tree}; \
echo "`date`: Rebuilt $(TARFILE)"; \
fi
# Depend on spec-clean so the spec gets rebuilt every time
$(RPM_SPEC_DIR)/$(PACKAGE).spec: spec-clean pacemaker.spec.in
$(AM_V_at)$(MKDIR_P) "$(RPM_SPEC_DIR)"
- $(AM_V_GEN)if [ x"`git ls-files -m pacemaker.spec.in 2>/dev/null`" != x ]; then \
- cat "$(abs_srcdir)/pacemaker.spec.in"; \
- elif git cat-file -e $(TAG):rpm/pacemaker.spec.in 2>/dev/null; then \
- git show $(TAG):rpm/pacemaker.spec.in; \
- elif git cat-file -e $(TAG):pacemaker.spec.in 2>/dev/null; then \
- git show $(TAG):pacemaker.spec.in; \
- else \
- cat "$(abs_srcdir)/pacemaker.spec.in"; \
- fi | sed \
- -e 's/^\(%global pcmkversion \).*/\1$(SPEC_RELEASE_NO)/' \
- -e 's/^\(%global specversion \).*/\1$(SPECVERSION)/' \
- -e 's/^\(%global commit \).*/\1$(SPEC_COMMIT)/' \
- -e 's/^\(%global commit_abbrev \).*/\1$(SPEC_ABBREV)/' \
- -e "s/PACKAGE_DATE/$$(date +'%a %b %d %Y')/" \
- -e 's/PACKAGE_VERSION/$(SPEC_RELEASE_NO)-$(SPECVERSION)/' \
+ $(AM_V_GEN)if [ x"`"$(GIT)" ls-files \
+ -m pacemaker.spec.in 2>/dev/null`" != x ]; then \
+ cat "$(abs_srcdir)/pacemaker.spec.in"; \
+ elif "$(GIT)" cat-file -e $(TAG):rpm/pacemaker.spec.in \
+ 2>/dev/null; then \
+ "$(GIT)" show $(TAG):rpm/pacemaker.spec.in; \
+ elif "$(GIT)" cat-file -e $(TAG):pacemaker.spec.in 2>/dev/null; \
+ then \
+ "$(GIT)" show $(TAG):pacemaker.spec.in; \
+ else \
+ cat "$(abs_srcdir)/pacemaker.spec.in"; \
+ fi | sed \
+ -e 's/^\(%global pcmkversion \).*/\1$(SPEC_RELEASE_NO)/' \
+ -e 's/^\(%global specversion \).*/\1$(SPECVERSION)/' \
+ -e 's/^\(%global commit \).*/\1$(SPEC_COMMIT)/' \
+ -e 's/^\(%global commit_abbrev \).*/\1$(SPEC_ABBREV)/' \
+ -e "s/PACKAGE_DATE/$$(date +'%a %b %d %Y')/" \
+ -e 's/PACKAGE_VERSION/$(SPEC_RELEASE_NO)-$(SPECVERSION)/' \
> "$@"
.PHONY: spec $(PACKAGE).spec
spec $(PACKAGE).spec: $(RPM_SPEC_DIR)/$(PACKAGE).spec
spec-clean:
-rm -f "$(RPM_SPEC_DIR)/$(PACKAGE).spec"
.PHONY: srpm
srpm: export srpm-clean $(RPM_SPEC_DIR)/$(PACKAGE).spec
if [ -e "$(BUILD_COUNTER)" ]; then \
echo $(COUNT) > "$(BUILD_COUNTER)"; \
fi
rpmbuild -bs $(RPM_OPTS) $(WITH) "$(RPM_SPEC_DIR)/$(PACKAGE).spec"
.PHONY: srpm-clean
srpm-clean:
-rm -f "$(RPM_SRCRPM_DIR)"/*.src.rpm
# e.g. make WITH="--with pre_release" rpm
.PHONY: rpm
rpm: srpm
@echo To create custom builds, edit the flags and options in $(PACKAGE).spec first
rpmbuild $(RPM_OPTS) $(WITH) --rebuild "$(RPM_SRCRPM_DIR)"/*.src.rpm
.PHONY: rpm-clean
rpm-clean: spec-clean srpm-clean
-if [ -n "$(RPM_CLEAN)" ]; then rm -rf $(RPM_CLEAN); fi
.PHONY: rpmlint
rpmlint: $(RPM_SPEC_DIR)/$(PACKAGE).spec
rpmlint -f rpmlintrc "$<"
.PHONY: rpm-dep
rpm-dep: $(RPM_SPEC_DIR)/$(PACKAGE).spec
sudo yum-builddep "$(RPM_SPEC_DIR)/$(PACKAGE).spec"
.PHONY: release
release:
$(MAKE) $(AM_MAKEFLAGS) TAG=$(LAST_RELEASE) rpm
# Build the highest-versioned rc tag
.PHONY: rc
rc:
@if [ -z "$(CHECKOUT)" ]; then \
echo 'This target must be run from a git checkout'; \
exit 1; \
fi
- $(MAKE) $(AM_MAKEFLAGS) TAG="$$(git tag -l 2>/dev/null \
+ $(MAKE) $(AM_MAKEFLAGS) TAG="$$("$(GIT)" tag -l 2>/dev/null \
| sed -n -e 's/^\(Pacemaker-[0-9.]*-rc[0-9]*\)$$/\1/p' \
| sort -Vr | head -n 1)" rpm
.PHONY: chroot
chroot: mock-$(MOCK_CFG) mock-install-$(MOCK_CFG) mock-sh-$(MOCK_CFG)
@echo Done
.PHONY: mock-next
mock-next:
$(MAKE) $(AM_MAKEFLAGS) F=$(shell expr 1 + $(F)) mock
.PHONY: mock-rawhide
mock-rawhide:
$(MAKE) $(AM_MAKEFLAGS) F=rawhide mock
mock-install-%:
@echo "Installing packages"
mock --root=$* $(MOCK_OPTIONS) --install "$(MOCK_DIR)"/*.rpm \
vi sudo valgrind lcov gdb fence-agents psmisc
.PHONY: mock-install
mock-install: mock-install-$(MOCK_CFG)
@echo Done
.PHONY: mock-sh
mock-sh: mock-sh-$(MOCK_CFG)
@echo Done
mock-sh-%:
@echo Connecting
mock --root=$* $(MOCK_OPTIONS) --shell
@echo Done
mock-%: srpm mock-clean
mock $(MOCK_OPTIONS) --root=$* --no-cleanup-after --rebuild \
$(WITH) "$(RPM_SRCRPM_DIR)"/*.src.rpm
.PHONY: mock
mock: mock-$(MOCK_CFG)
@echo Done
.PHONY: dirty
dirty:
$(MAKE) $(AM_MAKEFLAGS) DIRTY=yes mock
.PHONY: mock-clean
mock-clean:
-rm -rf "$(MOCK_DIR)"
# Make debugging makefile issues easier
vars:
@echo "CHECKOUT=$(CHECKOUT)"
@echo "VERSION=$(VERSION)"
@echo "COMMIT=$(COMMIT)"
@echo "TAG=$(TAG)"
@echo "DIRTY=$(DIRTY)"
@echo "DIRTY_EXT=$(DIRTY_EXT)"
@echo "LAST_RELEASE=$(LAST_RELEASE)"
@echo "NEXT_RELEASE=$(NEXT_RELEASE)"
@echo "top_distdir=$(top_distdir)"
@echo "RPMDEST=$(RPMDEST)"
@echo "RPMTYPE=$(RPMTYPE)"
@echo "RPM_SPEC_DIR=$(RPM_SPEC_DIR)"
@echo "RPM_SRCRPM_DIR=$(RPM_SRCRPM_DIR)"
@echo "RPM_OPTS=$(RPM_OPTS)"
@echo "RPM_CLEAN=$(RPM_CLEAN)"
@echo "WITH=$(WITH)"
@echo "BUILD_COUNTER=$(BUILD_COUNTER)"
@echo "LAST_COUNT=$(LAST_COUNT)"
@echo "COUNT=$(COUNT)"
@echo "SPECVERSION=$(SPECVERSION)"
@echo "SPEC_COMMIT=$(SPEC_COMMIT)"
@echo "SPEC_ABBREV=$(SPEC_ABBREV)"
@echo "SPEC_RELEASE=$(SPEC_RELEASE)"
@echo "SPEC_RELEASE_NO=$(SPEC_RELEASE_NO)"
@echo "TARFILE=$(TARFILE)"
clean-local: mock-clean rpm-clean
-rm -f "$(TARFILE)"

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 8, 6:25 PM (7 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1985003
Default Alt Text
(144 KB)

Event Timeline