drgn/libdrgn/configure.ac
Omar Sandoval 6cf0c244e6 libdrgn: enable -Wshadow
There are a few places that need fixups.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2024-06-20 23:34:14 -07:00

158 lines
5.4 KiB
Plaintext

dnl Copyright (c) Meta Platforms, Inc. and affiliates.
dnl SPDX-License-Identifier: LGPL-2.1-or-later
AC_INIT([libdrgn], [0.0.26],
[https://github.com/osandov/drgn/issues],,
[https://github.com/osandov/drgn])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign nostdinc subdir-objects])
AM_SILENT_RULES([yes])
AM_PROG_AR
LT_INIT
AC_SYS_LARGEFILE
AC_REQUIRE_AUX_FILE([tap-driver.sh])
MY_C_AUTO
MY_CHECK_VA_ARGS_COMMA_DELETION
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--enable-openmp@<:@=ARG@:>@],
[use OpenMP. ARG may be yes, no, or the name of
the OpenMP runtime library to use (e.g., gomp or
omp)
@<:@default=yes@:>@])],
[], [enable_openmp=yes])
OPENMP_CFLAGS=
OPENMP_LIBS=
AS_CASE(["x$enable_openmp"],
[xyes], [OPENMP_CFLAGS=-fopenmp],
[xno], [],
dnl Use -Wc so that -fopenmp only gets passed when compiling, not
dnl linking, otherwise the linker will add the default runtime library.
[OPENMP_CFLAGS=-Wc,-fopenmp
OPENMP_LIBS=-l$enable_openmp])
AC_SUBST(OPENMP_CFLAGS)
AC_SUBST(OPENMP_LIBS)
dnl We need Python for code generation even if we're not building the bindings.
AM_PATH_PYTHON([3.6])
AC_ARG_ENABLE([python],
[AS_HELP_STRING([--enable-python],
[build Python bindings @<:@default=no@:>@])],
[], [enable_python=no])
AM_CONDITIONAL([ENABLE_PYTHON], [test "x$enable_python" != xno])
AM_COND_IF([ENABLE_PYTHON],
[AS_IF([test -z "$PYTHON_CPPFLAGS"],
[prog="import sysconfig
include = sysconfig.get_path('include')
platinclude = sysconfig.get_path('platinclude')
include_paths = [[include]]
if platinclude != include:
include_paths.append(plat_include)
print(' '.join('-I' + path for path in include_paths))"
PYTHON_CPPFLAGS=`"$PYTHON" -c "$prog"`])
AC_SUBST(PYTHON_CPPFLAGS)
AC_MSG_CHECKING([for $PYTHON development headers])
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <Python.h>]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR(
[Could not compile test program with Python headers.
You may need to install your distribution's Python development package (e.g.,
python3-devel or python3-dev) or specify the location of the Python development
headers by setting the PYTHON_CPPFLAGS environment variable.])])
CPPFLAGS="$save_CPPFLAGS"])
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(elfutils, [libelf >= 0.165 libdw >= 0.165])
AC_ARG_WITH([libkdumpfile],
[AS_HELP_STRING([--with-libkdumpfile],
[build with support for the makedumpfile kernel
core dump format using libkdumpfile
@<:@default=auto@:>@])],
[], [with_libkdumpfile=auto])
AS_CASE(["x$with_libkdumpfile"],
[xyes], [PKG_CHECK_MODULES(libkdumpfile, [libkdumpfile])],
[xauto], [PKG_CHECK_MODULES(libkdumpfile, [libkdumpfile],
[with_libkdumpfile=yes],
[with_libkdumpfile=no])])
AM_CONDITIONAL([WITH_LIBKDUMPFILE], [test "x$with_libkdumpfile" = xyes])
AM_COND_IF([WITH_LIBKDUMPFILE], [AC_DEFINE(WITH_LIBKDUMPFILE)])
dnl We need check for running tests, but we don't want to fail the build over
dnl it. Instead, if it's not found, set variables so that only `make check`
dnl fails.
PKG_CHECK_MODULES(check, [check >= 0.10.0],,
[check_CFLAGS="\$(error Test requires 'check' ('check-devel') >= 0.10.0)"
check_LIBS="\$(error Test requires 'check' ('check-devel') >= 0.10.0)"])
AC_ARG_ENABLE([compiler-warnings],
[AS_HELP_STRING([--enable-compiler-warnings@<:@=no|yes|error@:>@],
[enable compiler warnings. If no, then only the
default compiler warnings are enabled. If yes,
then additional warnings required by the package
are enabled. If error, then warnings are treated
as errors (this is only intended for
developers). @<:@default=yes@:>@])],
[], [enable_compiler_warnings=no])
dnl Make Clang error instead of warn for unknown warning options.
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
[compiler_flags_test="-Werror=unknown-warning-option"],
[compiler_flags_test=""])
AS_IF([test "x$enable_compiler_warnings" != xno],
[AX_APPEND_COMPILE_FLAGS([ dnl
-Wall dnl
-Wformat-overflow=2 dnl
-Wformat-truncation=2 dnl
-Wimplicit-fallthrough dnl
-Wmissing-prototypes dnl
-Wpointer-arith dnl
-Wshadow dnl
-Wvla dnl
-Wno-format-zero-length dnl
], [WARN_CFLAGS], [$compiler_flags_test])])
AS_IF([test "x$enable_compiler_warnings" = xerror],
[AX_APPEND_FLAG([-Werror], [WARN_CFLAGS])])
AC_SUBST(WARN_CFLAGS)
AC_ARG_ENABLE([asan],
[AS_HELP_STRING([--enable-asan], [enable AddressSanitizer])],
[], [enable_asan=no])
AS_IF([test "x$enable_asan" != xno],
[AX_APPEND_FLAG([-fsanitize=address], [SANITIZER_CFLAGS])
AX_APPEND_FLAG([-fno-omit-frame-pointer], [SANITIZER_CFLAGS])
AX_APPEND_FLAG([-fsanitize=address], [SANITIZER_LDFLAGS])])
AC_ARG_ENABLE([ubsan],
[AS_HELP_STRING([--enable-ubsan],
[enable UndefinedBehaviorSanitizer])],
[], [enable_ubsan=no])
AS_IF([test "x$enable_ubsan" != xno],
[AX_APPEND_FLAG([-fsanitize=undefined], [SANITIZER_CFLAGS])
AX_APPEND_FLAG([-fno-omit-frame-pointer], [SANITIZER_CFLAGS])
AX_APPEND_FLAG([-fsanitize=undefined], [SANITIZER_LDFLAGS])])
AC_SUBST(SANITIZER_CFLAGS)
AC_SUBST(SANITIZER_LDFLAGS)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT