summaryrefslogtreecommitdiffstats
path: root/web/attachments/338026-0001-Attempt-at-detecting-64bit-compilation-flags-between.patch
blob: f31f4820dd7f6b26de8cf75977bebd368ec73f73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From 182964c5f6ca39f42f5225bc76f48a185eda04b8 Mon Sep 17 00:00:00 2001
From: Thomas Guyot-Sionnest <dermoth@aei.ca>
Date: Wed, 5 Aug 2009 01:32:02 -0400
Subject: [PATCH] Attempt at detecting 64bit compilation flags between gcc, old, and new versions of sun cc

Gcc accepts -m64, just as newer version of Suncc.
Older Suncc required -xarch=v9 (SPARC) or -xarch=amd64 (x86-64) to generate 64bit code.
---
 configure.in |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/configure.in b/configure.in
index 68ac0a0..197b88e 100644
--- a/configure.in
+++ b/configure.in
@@ -577,14 +577,70 @@ elif test "$ac_cv_uname_s" = "SunOS"; then
         ac_cv_ps_cols=9
         AC_MSG_RESULT([using nagios-plugins internal ps command (pst3) for solaris])
 	if test `isainfo -b` = 64 ; then
-		PST3CFLAGS="-m64"
-		AC_SUBST(PST3CFLAGS)
+		pst3_use_64bit=1
 		AC_MSG_NOTICE([using 64bit pst3])	
 	else
 		AC_MSG_NOTICE([using 32bit pst3])
 	fi
         EXTRAS_ROOT="$EXTRAS_ROOT pst3"
 
+	if test "$pst3_use_64bit" = 1; then
+		dnl Test if we can actually compile code in 64bit
+		old_cflags=$CFLAGS
+		CFLAGS="$CFLAGS -m64"
+		pst3_64bit_working=0
+		AC_RUN_IFELSE(
+			[AC_LANG_PROGRAM([], [
+return sizeof(void*) == 8 ? 0 : 1;
+			])
+		],[
+			PST3CFLAGS="-m64"
+			AC_SUBST(PST3CFLAGS)
+			pst3_64bit_working=1
+		],[
+			pst3_64bit_working=0
+			AC_MSG_NOTICE([compiler do not like -m64])
+		])
+		CFLAGS=$old_cflags
+		if test "$pst3_64bit_working" = 0; then
+			old_cflags=$CFLAGS
+			CFLAGS="$CFLAGS -xarch=v9"
+			AC_RUN_IFELSE(
+				[AC_LANG_PROGRAM([], [
+return sizeof(void*) == 8 ? 0 : 1;
+				])
+			],[
+				PST3CFLAGS="-xarch=v9"
+				AC_SUBST(PST3CFLAGS)
+				pst3_64bit_working=1
+			],[
+				pst3_64bit_working=0
+				AC_MSG_NOTICE([compiler do not like -xarch=v9])
+			])
+			CFLAGS=$old_cflags
+		fi
+		if test "$pst3_64bit_working" = 0; then
+			old_cflags=$CFLAGS
+			CFLAGS="$CFLAGS -xarch=amd64"
+			AC_RUN_IFELSE(
+				[AC_LANG_PROGRAM([], [
+return sizeof(void*) == 8 ? 0 : 1;
+				])
+			],[
+				PST3CFLAGS="-xarch=amd64"
+				AC_SUBST(PST3CFLAGS)
+				pst3_64bit_working=1
+			],[
+				pst3_64bit_working=0
+				AC_MSG_NOTICE([compiler do not like -xarch=amd64])
+			])
+			CFLAGS=$old_cflags
+		fi
+		if test "$pst3_64bit_working" = 0; then
+			AC_MSG_ERROR([Don't know how to build a 64-bit object.])
+		fi
+	fi
+
 dnl Removing this for the moment - Ton
 dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
 dnl Limitation that command name is not available
-- 
1.5.5