Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
my-autoconf-snapshots/AcSplit/CF_CLANG_COMPILER
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
67 lines (62 sloc)
2.03 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04 | |
dnl ----------------- | |
dnl Check if the given compiler is really clang. clang's C driver defines | |
dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does | |
dnl not ignore some gcc options. | |
dnl | |
dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to | |
dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from | |
dnl the wrappers for gcc and g++ warnings. | |
dnl | |
dnl $1 = GCC (default) or GXX | |
dnl $2 = CLANG_COMPILER (default) | |
dnl $3 = CFLAGS (default) or CXXFLAGS | |
AC_DEFUN([CF_CLANG_COMPILER],[ | |
ifelse([$2],,CLANG_COMPILER,[$2])=no | |
if test "$ifelse([$1],,[$1],GCC)" = yes ; then | |
AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler) | |
cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])" | |
AC_TRY_COMPILE([],[ | |
#ifdef __clang__ | |
#else | |
make an error | |
#endif | |
],[ifelse([$2],,CLANG_COMPILER,[$2])=yes | |
],[]) | |
ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" | |
AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2])) | |
fi | |
CLANG_VERSION=none | |
if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then | |
case "$CC" in | |
(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]]) | |
AC_MSG_WARN(replacing broken compiler alias $CC) | |
CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" | |
CC=clang | |
;; | |
esac | |
AC_MSG_CHECKING(version of $CC) | |
CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" | |
test -z "$CLANG_VERSION" && CLANG_VERSION=unknown | |
AC_MSG_RESULT($CLANG_VERSION) | |
for cf_clang_opt in \ | |
-Qunused-arguments \ | |
-Wno-error=implicit-function-declaration | |
do | |
AC_MSG_CHECKING(if option $cf_clang_opt works) | |
cf_save_CFLAGS="$CFLAGS" | |
CFLAGS="$CFLAGS $cf_clang_opt" | |
AC_TRY_LINK([ | |
#include <stdio.h>],[ | |
printf("hello!\\n");],[ | |
cf_clang_optok=yes],[ | |
cf_clang_optok=no]) | |
AC_MSG_RESULT($cf_clang_optok) | |
CFLAGS="$cf_save_CFLAGS" | |
if test "$cf_clang_optok" = yes; then | |
CF_VERBOSE(adding option $cf_clang_opt) | |
CF_APPEND_TEXT(CFLAGS,$cf_clang_opt) | |
fi | |
done | |
fi | |
]) |