Skip to content

Commit

Permalink
configure: make more robust the check for elf 64
Browse files Browse the repository at this point in the history
The check if 'elf.h' defines the type 'Elf64_Ehdr' is currently
done through 'grep' on the file. While there is no false positive,
so far, such test could incorrectly find the text inside a comment
or in a block guarded by #if/#endif.

Use the autoconf macro AC_CHECK_TYPE() to detect if the type is
properly declared.

Change-Id: Ibb74db3d90ac6d1589b9dc1e5a7ae59e47945e78
Signed-off-by: Antonio Borneo <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/8591
Tested-by: jenkins
  • Loading branch information
borneoa committed Jan 25, 2025
1 parent 345473f commit ac18b8c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ AC_SEARCH_LIBS([openpty], [util])

AC_CHECK_HEADERS([sys/socket.h])
AC_CHECK_HEADERS([elf.h])
AC_EGREP_HEADER(Elf64_Ehdr, [elf.h], [
AC_DEFINE([HAVE_ELF64], [1], [Define to 1 if the system has the type `Elf64_Ehdr'.])
])

AC_CHECK_TYPE([Elf64_Ehdr],
AC_DEFINE([HAVE_ELF64], [1], [Define to 1 if the system has the type 'Elf64_Ehdr'.]),
[], [[#include <elf.h>]])

AC_CHECK_HEADERS([fcntl.h])
AC_CHECK_HEADERS([malloc.h])
AC_CHECK_HEADERS([netdb.h])
Expand Down

0 comments on commit ac18b8c

Please sign in to comment.