- clang 2 does c++ now, so only fall back to c mode if we are running
  clang1
- clang2 has some nice macros for version stuff, use them

tested with both clang2 (bsd) and clang1 (linux), both appear to be 
fine.

thanks to viktor for solving my troubles with the 
$($(shell(($($((subst))$)zoink))$)$))kaboom)$)) madness.

Index: src/common/hbver.c
===================================================================
--- src/common/hbver.c  (revision 14637)
+++ src/common/hbver.c  (working copy)
@@ -700,6 +700,18 @@
       iVerPatch = 0;
    #endif
 
+#elif defined( __llvm__ ) && defined( __clang_major__ )
+
+   pszName = "LLVM/Clang C";
+
+   iVerMajor = __clang_major__;
+   iVerMinor = __clang_minor__;
+   iVerPatch = __clang_patchlevel__;
+
+   #if defined( __cplusplus )
+      hb_strncpy( szSub, "++", sizeof( szSub ) - 1 );
+   #endif
+
 #elif defined( __GNUC__ )
 
    #if defined( __DJGPP__ )
@@ -783,6 +795,15 @@
    else
       hb_strncpy( pszCompiler, "(unknown)", COMPILER_BUF_SIZE - 1 );
 
+#if defined( __clang_version__ )
+   if (strstr( __clang_version__, "("))
+      /* "2.0 (trunk 103176)" -> "(trunk 103176)" */
+      hb_snprintf( szSub, sizeof( szSub ), " %s", strstr( __clang_version__, 
"("));
+   else
+      hb_snprintf( szSub, sizeof( szSub ), " (%s)", __clang_version__);
+   hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 );
+#endif
+
 #if defined( __DJGPP__ )
    hb_snprintf( szSub, sizeof( szSub ), " (DJGPP %i.%02i)", ( int ) __DJGPP__, 
( int ) __DJGPP_MINOR__ );
    hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 );
Index: config/bsd/clang.mk
===================================================================
--- config/bsd/clang.mk (revision 14637)
+++ config/bsd/clang.mk (working copy)
@@ -3,8 +3,11 @@
 #
 
 ifeq ($(HB_BUILD_MODE),cpp)
-   # -ccc-clang-cxx
-   HB_CMP := clang
+   ifneq ($(findstring clang$(subst x, ,x)version$(subst x, ,x)1,$(shell clang 
--version)),)
+      HB_BUILD_MODE := c
+   else
+      HB_CMP := clang++
+   endif
 else
    HB_CMP := clang
 endif
Index: config/linux/clang.mk
===================================================================
--- config/linux/clang.mk       (revision 14637)
+++ config/linux/clang.mk       (working copy)
@@ -3,8 +3,11 @@
 #
 
 ifeq ($(HB_BUILD_MODE),cpp)
-   # -ccc-clang-cxx
-   HB_CMP := clang
+   ifneq ($(findstring clang$(subst x, ,x)version$(subst x, ,x)1,$(shell clang 
--version)),)
+      HB_BUILD_MODE := c
+   else
+      HB_CMP := clang++
+   endif
 else
    HB_CMP := clang
 endif

-- 
[-]

mkdir /nonexistent
Index: src/common/hbver.c
===================================================================
--- src/common/hbver.c	(revision 14637)
+++ src/common/hbver.c	(working copy)
@@ -700,6 +700,18 @@
       iVerPatch = 0;
    #endif
 
+#elif defined( __llvm__ ) && defined( __clang_major__ )
+
+   pszName = "LLVM/Clang C";
+
+   iVerMajor = __clang_major__;
+   iVerMinor = __clang_minor__;
+   iVerPatch = __clang_patchlevel__;
+
+   #if defined( __cplusplus )
+      hb_strncpy( szSub, "++", sizeof( szSub ) - 1 );
+   #endif
+
 #elif defined( __GNUC__ )
 
    #if defined( __DJGPP__ )
@@ -783,6 +795,15 @@
    else
       hb_strncpy( pszCompiler, "(unknown)", COMPILER_BUF_SIZE - 1 );
 
+#if defined( __clang_version__ )
+   if (strstr( __clang_version__, "("))
+      /* "2.0 (trunk 103176)" -> "(trunk 103176)" */
+      hb_snprintf( szSub, sizeof( szSub ), " %s", strstr( __clang_version__, "("));
+   else
+      hb_snprintf( szSub, sizeof( szSub ), " (%s)", __clang_version__);
+   hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 );
+#endif
+
 #if defined( __DJGPP__ )
    hb_snprintf( szSub, sizeof( szSub ), " (DJGPP %i.%02i)", ( int ) __DJGPP__, ( int ) __DJGPP_MINOR__ );
    hb_strncat( pszCompiler, szSub, COMPILER_BUF_SIZE - 1 );
Index: config/bsd/clang.mk
===================================================================
--- config/bsd/clang.mk	(revision 14637)
+++ config/bsd/clang.mk	(working copy)
@@ -3,8 +3,11 @@
 #
 
 ifeq ($(HB_BUILD_MODE),cpp)
-   # -ccc-clang-cxx
-   HB_CMP := clang
+   ifneq ($(findstring clang$(subst x, ,x)version$(subst x, ,x)1,$(shell clang --version)),)
+      HB_BUILD_MODE := c
+   else
+      HB_CMP := clang++
+   endif
 else
    HB_CMP := clang
 endif
Index: config/linux/clang.mk
===================================================================
--- config/linux/clang.mk	(revision 14637)
+++ config/linux/clang.mk	(working copy)
@@ -3,8 +3,11 @@
 #
 
 ifeq ($(HB_BUILD_MODE),cpp)
-   # -ccc-clang-cxx
-   HB_CMP := clang
+   ifneq ($(findstring clang$(subst x, ,x)version$(subst x, ,x)1,$(shell clang --version)),)
+      HB_BUILD_MODE := c
+   else
+      HB_CMP := clang++
+   endif
 else
    HB_CMP := clang
 endif
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to