Fixes for compatibility with older Linux versions

- Check for both -no_pie and -no-pie flags to disable
  position-independent code.
- Use AC_PROG_CC_C99 to force C99 standard.
This commit is contained in:
robxnano 2022-10-08 18:37:43 +01:00
parent 4b58ce3ea8
commit f61701df3c
2 changed files with 31 additions and 11 deletions

View File

@ -218,7 +218,7 @@ if [[ "x$HAVE_I386" = "xyes" ]]; then
fi
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CC_C99
AC_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_CXX
@ -1123,6 +1123,24 @@ AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
fi dnl HAVE_MMAP_VM
dnl Check if we can disable position-independent code
AC_CACHE_CHECK([for flag to disable position-independent code],
ac_cv_no_pie, [
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,-no-pie"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],[
ac_cv_no_pie="-no-pie"],[
LDFLAGS="$saved_LDFLAGS -Wl,-no_pie"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],[
ac_cv_no_pie="-no_pie"],[
ac_cv_no_pie="none"
])
])
if [[ "$ac_cv_no_pie" = "none" ]]; then
LDFLAGS="$saved_LDFLAGS"
fi
])
dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000],
ac_cv_pagezero_hack, [
@ -1473,10 +1491,6 @@ if [[ "x$OS_TYPE" = "xdarwin" ]]; then
fi
fi
if [[ "x$OS_TYPE" = "xlinux" ]]; then
LDFLAGS="$LDFLAGS -no-pie"
fi
dnl Enable VOSF screen updates with this feature is requested and feasible
if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])

View File

@ -75,7 +75,7 @@ AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX d
AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], [])
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CC_C99
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_MAKE_SET
@ -988,13 +988,19 @@ AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
fi dnl HAVE_MMAP_VM
dnl Check if we can disable position-independent code
AC_CACHE_CHECK([how to disable position-independent code],
AC_CACHE_CHECK([for flag to disable position-independent code],
ac_cv_no_pie, [
ac_cv_no_pie='-Wl,-no_pie'
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $ac_cv_no_pie"
AC_TRY_LINK(,,,[ac_cv_no_pie="cannot"])
if [[ "$ac_cv_no_pie" = "cannot" ]]; then
LDFLAGS="$LDFLAGS -Wl,-no-pie"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],[
ac_cv_no_pie="-no-pie"],[
LDFLAGS="$saved_LDFLAGS -Wl,-no_pie"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],[
ac_cv_no_pie="-no_pie"],[
ac_cv_no_pie="none"
])
])
if [[ "$ac_cv_no_pie" = "none" ]]; then
LDFLAGS="$saved_LDFLAGS"
fi
])