Remove path name from test case
[binutils-gdb.git] / gdbsupport / compiler-type.m4
1 dnl Autoconf configure script for GDB, the GNU debugger.
2 dnl Copyright (C) 2022-2023 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
19 # Sets up GDB_COMPILER_TYPE to either 'gcc', 'clang', or 'unknown'.
20 # The autoconf compiler check will set GCC=yes for clang as well as
21 # gcc, it's really more of a "is gcc like" check.
22 #
23 # By contrast, this will set the GDB_COMPILER_TYPE to 'gcc' only for
24 # versions of gcc.
25 #
26 # There's no reason why this can't be extended to identify other
27 # compiler types if needed in the future, users of this variable
28 # should therefore avoid relying on the 'unknown' value, instead
29 # checks should be written in terms of the known compiler types.
30 AC_DEFUN([AM_GDB_COMPILER_TYPE],[
31
32 AC_CACHE_CHECK([the compiler type],
33 [gdb_cv_compiler_type],
34 [gdb_cv_compiler_type=unknown
35 if test "$gdb_cv_compiler_type" = unknown; then
36 AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM([],
38 [
39 #if !defined __GNUC__ || defined __clang__
40 #error not gcc
41 #endif
42 ])],
43 [gdb_cv_compiler_type=gcc], [])
44 fi
45
46 if test "$gdb_cv_compiler_type" = unknown; then
47 AC_COMPILE_IFELSE(
48 [AC_LANG_PROGRAM([],
49 [
50 #ifndef __clang__
51 #error not clang
52 #endif
53 ])],
54 [gdb_cv_compiler_type=clang], [])
55 fi
56 ])
57
58 GDB_COMPILER_TYPE="$gdb_cv_compiler_type"
59 ])