Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ test -z "$srcdir" && srcdir=.
cd "$srcdir"

echo "$0: Running autoreconf ..."
autoreconf -Wno-portability --force --install -I m4 || exit
autoreconf -Wno-portability --force --install -I m4 || exit

cd - >/dev/null # back to original directory
cd - >/dev/null # back to original directory

if [ -z "$NO_CONFIGURE" ]
then
Expand Down
102 changes: 58 additions & 44 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,57 @@ dnl It is restored later.
dnl
ENV_CFLAGS="$CFLAGS"

# Do not use autoconf's CFLAGS defaults set via AC_PROG_CC macro
# https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/C-Compiler.html
CFLAGS=

dnl ######################################################################
dnl Enable debugging
dnl ######################################################################

AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging]),
[debug=$enableval],
[debug=no])
AM_CONDITIONAL([NDEBUG], [test x"$debug" = x"no"])

AC_MSG_CHECKING([for debug option])
if test x"$debug" = x"yes"
then
AC_MSG_RESULT(yes)
AM_CFLAGS="$AM_CFLAGS -g3 -O0"
else
AC_MSG_RESULT(no)
AM_CFLAGS="$AM_CFLAGS -O2 -DNDEBUG"
fi

dnl ######################################################################
dnl Checks for programs.
dnl ######################################################################

AC_PROG_GREP
AC_PROG_EGREP
AC_PROG_CC
# check for clang first so we can use this info on macOS
AC_PROG_CC([clang gcc cc])
AC_PROG_MKDIR_P
AC_EXEEXT

AS_CASE([${target_os}],
[darwin*], [
# Since 15.4, macOS has strchrnul(), but only allows it for deployment version
# >= 15.4. Add -mmacosx-version-min parameter to CFLAGS if we're using clang
AS_IF([test "x$CC" = "xclang"], [
AC_CHECK_PROG([xcrun], [xcrun], [xcrun])
if test "x$xcrun" = "xxcrun" ; then
AC_MSG_CHECKING([for macOS SDK version])
MACOS_SDK_VERSION=`xcrun --show-sdk-version`
AC_MSG_RESULT([$MACOS_SDK_VERSION])
case "${MACOS_SDK_VERSION}" in
*.*) test "${MACOS_SDK_VERSION%.*}" -ge 15 && test "${MACOS_SDK_VERSION#*.}" -ge 4 && AM_CFLAGS="$AM_CFLAGS -mmacosx-version-min=$MACOS_SDK_VERSION";;
esac
fi
])

AC_CHECK_PROG([BREW], [brew], [brew])
AC_MSG_CHECKING([for OS X Homebrew])
AS_IF([test "x$BREW" = "xbrew"], [
Expand Down Expand Up @@ -141,14 +180,14 @@ AC_ARG_WITH([pthreads],

if test "x$with_pthreads" != x && test "x$with_pthreads" != "xyes" && test "x$with_pthreads" != "xno"; then
LIBS="$LIBS -L$with_pthreads/lib"
CPPFLAGS="-I$with_pthreads/include $CPPFLAGS"
AM_CPPFLAGS="-I$with_pthreads/include $AM_CPPFLAGS"
fi

ACX_PTHREAD([],
[AC_MSG_ERROR(pthread-compatible library is required to build CFEngine)])

CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
AM_CFLAGS="$PTHREAD_CFLAGS $AM_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"

dnl ######################################################################
Expand Down Expand Up @@ -225,32 +264,7 @@ AS_CASE([${target_os}],
[mingw*],
# Disable printf format warnings, because our wrapper supports more
# flags than vanilla Windows version, so they are false positives.
[CFLAGS="$CFLAGS -Wno-format"])

dnl ######################################################################
dnl Enable debugging
dnl ######################################################################

AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging]),
[debug=$enableval],
[debug=no])
AM_CONDITIONAL([NDEBUG], [test x"$debug" = x"no"])

dnl Even though CFLAGS should contain the command-line CFLAGS
dnl as last, some macro seem to messes the order up and insert
dnl its own optimisation flags as well. So we append ENV_CFLAGS
dnl at the end manually, causing a bit of flag duplication.

AC_MSG_CHECKING([for debug option])
if test x"$debug" = x"yes"
then
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -g3 -O0 $ENV_CFLAGS"
else
AC_MSG_RESULT(no)
CFLAGS="$CFLAGS -O2 -DNDEBUG $ENV_CFLAGS"
fi
[AM_CFLAGS="$AM_CFLAGS -Wno-format"])

dnl ######################################################################
dnl Checks for libraries.
Expand Down Expand Up @@ -488,7 +502,7 @@ AC_TYPE_OFF_T
# off_t, which causes a conflict.
#
if test "x$ac_cv_sys_large_files" = x1; then
CPPFLAGS="-D_LARGE_FILES=1 $CPPFLAGS"
AM_CPPFLAGS="-D_LARGE_FILES=1 $AM_CPPFLAGS"
fi

dnl ######################################################################
Expand Down Expand Up @@ -998,7 +1012,7 @@ case "$target_os" in
AC_DEFINE(_PSTAT64, 1, [Enable wide data structures everywhere])
;;
aix*)
CPPFLAGS="$CPPFLAGS -w"
AM_CPPFLAGS="$AM_CPPFLAGS -w"
;;
linux*|*bsd*|*gnu*)
AC_CHECK_LIB(nss_nis, yp_get_default_domain)
Expand Down Expand Up @@ -1210,7 +1224,7 @@ dnl #####################################################################
AC_PATH_PROG(HOSTNAME, hostname, "", $PATH)

AC_DEFINE_UNQUOTED(AUTOCONF_HOSTNAME, "`$HOSTNAME`", [Special CFEngine symbol])
AC_DEFINE_UNQUOTED(AUTOCONF_SYSNAME, "$target_os", [Speial CFEngine symbol])
AC_DEFINE_UNQUOTED(AUTOCONF_SYSNAME, "$target_os", [Special CFEngine symbol])


dnl #####################################################################
Expand Down Expand Up @@ -1261,8 +1275,8 @@ if test "x$use_coverage" = "xyes"; then
changequote([,])

dnl Add the special gcc flags
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
LDFLAGS="$LDFLAGS -lgcov"
AM_CFLAGS="$AM_CFLAGS -fprofile-arcs -ftest-coverage"
AM_LDFLAGS="$AM_LDFLAGS -lgcov"
# Need to set ENABLE_COVERAGE so that tests/unit/Makefile.am can adapt for one
# test which needs gcov stubs if core not built with coverage.
AM_CONDITIONAL([ENABLE_COVERAGE], true)
Expand All @@ -1274,19 +1288,19 @@ dnl ######################################################################
dnl Collect all the options
dnl ######################################################################

CORE_CPPFLAGS="$PCRE2_CPPFLAGS $OPENSSL_CPPFLAGS $LIBYAML_CPPFLAGS $CPPFLAGS"
CORE_CFLAGS="$PCRE2_CFLAGS $OPENSSL_CFLAGS $LIBYAML_CFLAGS $CFLAGS"
CORE_LDFLAGS="$PCRE2_LDFLAGS $OPENSSL_LDFLAGS $LIBYAML_LDFLAGS $LDFLAGS"
CORE_LIBS="$PCRE2_LIBS $OPENSSL_LIBS $LIBYAML_LIBS $LIBS"
AM_CPPFLAGS="$PCRE2_CPPFLAGS $OPENSSL_CPPFLAGS $LIBYAML_CPPFLAGS $AM_CPPFLAGS"
AM_CFLAGS="$PCRE2_CFLAGS $OPENSSL_CFLAGS $LIBYAML_CFLAGS $AM_CFLAGS $ENV_CFLAGS"
AM_LDFLAGS="$PCRE2_LDFLAGS $OPENSSL_LDFLAGS $LIBYAML_LDFLAGS $AM_LDFLAGS"
AM_LIBS="$PCRE2_LIBS $OPENSSL_LIBS $LIBYAML_LIBS $AM_LIBS"

dnl ######################################################################
dnl Make them available to subprojects.
dnl ######################################################################

AC_SUBST([CORE_CPPFLAGS])
AC_SUBST([CORE_CFLAGS])
AC_SUBST([CORE_LDFLAGS])
AC_SUBST([CORE_LIBS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_SUBST([AM_LIBS])

#
# Populate contents of config.post.h
Expand All @@ -1313,7 +1327,7 @@ dnl ######################################################################
dnl Summarize
dnl ######################################################################

AC_MSG_RESULT( )
AC_MSG_RESULT

AC_MSG_RESULT(Summary:)
AC_MSG_RESULT(> Version: AC_PACKAGE_VERSION)
Expand All @@ -1330,7 +1344,7 @@ else
AC_MSG_RESULT([-> libyaml: disabled])
fi

AC_MSG_RESULT( )
AC_MSG_RESULT

dnl ######################################################################
dnl Now make the Makefiles
Expand Down
2 changes: 1 addition & 1 deletion libcompat/strcasecmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#if !HAVE_DECL_STRCASECMP
int strcasecmp(const char *s1, const char *s2);
#endif

int strcasecmp(const char *s1, const char *s2)
{
Expand Down Expand Up @@ -58,3 +57,4 @@ int strcasecmp(const char *s1, const char *s2)
}
return 0;
}
#endif
2 changes: 1 addition & 1 deletion libcompat/strcasestr.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#if !HAVE_DECL_STRCASESTR
char *strcasestr(const char *haystack, const char *needle);
#endif

char *strcasestr(const char *haystack, const char *needle)
{
Expand All @@ -45,3 +44,4 @@ char *strcasestr(const char *haystack, const char *needle)
}
return NULL;
}
#endif
2 changes: 1 addition & 1 deletion libcompat/strdup.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#if !HAVE_DECL_STRDUP
char *strdup(const char *str);
#endif

char *strdup(const char *str)
{
Expand All @@ -44,3 +43,4 @@ char *strdup(const char *str)
memcpy(sp, str, len);
return sp;
}
#endif
2 changes: 1 addition & 1 deletion libcompat/strerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#if !HAVE_DECL_STRERROR
char *strerror(int err);
#endif

char *strerror(int err)
{
Expand All @@ -38,3 +37,4 @@ char *strerror(int err)
snprintf(buffer, 20, "Error number %d\n", err);
return buffer;
}
#endif
2 changes: 2 additions & 0 deletions libcompat/strlcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sys/types.h>
#include <string.h>

#if !HAVE_DECL_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz);

/*
Expand Down Expand Up @@ -59,3 +60,4 @@ strlcat(char *dst, const char *src, size_t siz)

return(dlen + (s - src)); /* count does not include NUL */
}
#endif
2 changes: 2 additions & 0 deletions libcompat/strlcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sys/types.h>
#include <string.h>

#if !HAVE_DECL_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);

/*
Expand Down Expand Up @@ -55,3 +56,4 @@ strlcpy(char *dst, const char *src, size_t siz)

return(s - src - 1); /* count does not include NUL */
}
#endif
2 changes: 1 addition & 1 deletion libcompat/strncasecmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#if !HAVE_DECL_STRCASECMP
int strncasecmp(const char *s1, const char *s2);
#endif

int strncasecmp(const char *s1, const char *s2, size_t n)
{
Expand Down Expand Up @@ -58,3 +57,4 @@ int strncasecmp(const char *s1, const char *s2, size_t n)
}
return 0;
}
#endif
2 changes: 1 addition & 1 deletion libcompat/strndup.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ size_t strnlen(const char *str, size_t maxlen);

#if !HAVE_DECL_STRNDUP
char *strndup(const char *str, size_t n);
#endif

char *
strndup(const char *str, size_t maxlen)
Expand All @@ -49,3 +48,4 @@ strndup(const char *str, size_t maxlen)

return copy;
}
#endif
3 changes: 1 addition & 2 deletions libcompat/strnlen.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#if !HAVE_DECL_STRNLEN
size_t strnlen(const char *str, size_t maxlen);
#endif

size_t
strnlen(const char *str, size_t maxlen)
Expand All @@ -38,4 +37,4 @@ strnlen(const char *str, size_t maxlen)

return (size_t)(cp - str);
}

#endif
3 changes: 1 addition & 2 deletions libcompat/strrstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#if !HAVE_DECL_STRRSTR
char *strrstr(const char *haystack, const char *needle);
#endif

char *strrstr(const char *str, const char *pat) {
size_t len, patlen;
Expand All @@ -57,4 +56,4 @@ char *strrstr(const char *str, const char *pat) {
return (char *) p;
return NULL;
}

#endif
2 changes: 1 addition & 1 deletion libcompat/strsep.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#if !HAVE_DECL_STRSEP
char *strsep(char **stringp, const char *delim);
#endif

/*
* Get next token from string *stringp, where tokens are possibly-empty
Expand Down Expand Up @@ -75,3 +74,4 @@ strsep(char **stringp, const char *delim)
}
/* NOTREACHED */
}
#endif
3 changes: 1 addition & 2 deletions libcompat/strsignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ int rpl_snprintf(char *, size_t, const char *, ...);

#if !HAVE_DECL_STRSIGNAL
char *strsignal(int sig);
#endif

#include <stdio.h>

Expand All @@ -44,4 +43,4 @@ char *strsignal(int sig)
snprintf(SIGNAL_TEXT, 16, "Signal #%d", sig);
return SIGNAL_TEXT;
}

#endif
2 changes: 1 addition & 1 deletion libcompat/strstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#if !HAVE_DECL_STRSTR
char *strstr(const char *haystack, const char *needle);
#endif

char *strstr(const char *haystack, const char *needle)
{
Expand All @@ -45,3 +44,4 @@ char *strstr(const char *haystack, const char *needle)

return NULL;
}
#endif
3 changes: 0 additions & 3 deletions libutils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
noinst_LTLIBRARIES = libutils.la

# TODO remove the openssl dependency! It's only there for base64 encoding.
AM_CFLAGS = $(CORE_CFLAGS) $(PCRE2_CFLAGS) $(OPENSSL_CFLAGS)
AM_CPPFLAGS = $(CORE_CPPFLAGS) $(PCRE2_CPPFLAGS) $(OPENSSL_CPPFLAGS)
AM_LDFLAGS = $(CORE_LDFLAGS) $(PCRE2_LDFLAGS) $(OPENSSL_LDFLAGS)

libutils_la_LIBADD = ../libcompat/libcompat.la $(PCRE2_LIBS) $(OPENSSL_LIBS) $(SYSTEMD_LOGGING_LIBS) $(LIBYAML_LIBS)

Expand Down
Loading
Loading