compiler-type.m4 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. dnl Autoconf configure script for GDB, the GNU debugger.
  2. dnl Copyright (C) 2022 Free Software Foundation, Inc.
  3. dnl
  4. dnl This file is part of GDB.
  5. dnl
  6. dnl This program is free software; you can redistribute it and/or modify
  7. dnl it under the terms of the GNU General Public License as published by
  8. dnl the Free Software Foundation; either version 3 of the License, or
  9. dnl (at your option) any later version.
  10. dnl
  11. dnl This program is distributed in the hope that it will be useful,
  12. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. dnl GNU General Public License for more details.
  15. dnl
  16. dnl You should have received a copy of the GNU General Public License
  17. dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # Sets up GDB_COMPILER_TYPE to either 'gcc', 'clang', or 'unknown'.
  19. # The autoconf compiler check will set GCC=yes for clang as well as
  20. # gcc, it's really more of a "is gcc like" check.
  21. #
  22. # By contrast, this will set the GDB_COMPILER_TYPE to 'gcc' only for
  23. # versions of gcc.
  24. #
  25. # There's no reason why this can't be extended to identify other
  26. # compiler types if needed in the future, users of this variable
  27. # should therefore avoid relying on the 'unknown' value, instead
  28. # checks should be written in terms of the known compiler types.
  29. AC_DEFUN([AM_GDB_COMPILER_TYPE],[
  30. AC_CACHE_CHECK([the compiler type],
  31. [gdb_cv_compiler_type],
  32. [gdb_cv_compiler_type=unknown
  33. if test "$gdb_cv_compiler_type" = unknown; then
  34. AC_COMPILE_IFELSE(
  35. [AC_LANG_PROGRAM([],
  36. [
  37. #if !defined __GNUC__ || defined __clang__
  38. #error not gcc
  39. #endif
  40. ])],
  41. [gdb_cv_compiler_type=gcc], [])
  42. fi
  43. if test "$gdb_cv_compiler_type" = unknown; then
  44. AC_COMPILE_IFELSE(
  45. [AC_LANG_PROGRAM([],
  46. [
  47. #ifndef __clang__
  48. #error not clang
  49. #endif
  50. ])],
  51. [gdb_cv_compiler_type=clang], [])
  52. fi
  53. ])
  54. GDB_COMPILER_TYPE="$gdb_cv_compiler_type"
  55. ])