File: acinclude.m4

package info (click to toggle)
openhpi 3.8.0-2.3
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 31,888 kB
  • sloc: ansic: 225,326; cpp: 63,687; java: 16,472; cs: 15,161; python: 11,884; sh: 11,508; makefile: 4,945; perl: 1,529; xml: 36; asm: 13
file content (253 lines) | stat: -rw-r--r-- 7,515 bytes parent folder | download | duplicates (3)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
##################################################
#
#  OpenHPI Macros
#
#  Copyright (C) IBM Corp 2003-2006
#
#  Author(s):
#      Sean Dague <http://dague.net/sean>
#      Renier Morales <renier@openhpi.org>
#
#  This file is licensed under the same terms as OpenHPI itself.
#  See the COPYING file in the top level of OpenHPI for more info.
#
# This is a set of common macros to be used by the top
# level configure.in.
#
##################################################


AC_DEFUN([OH_SET_SIZES],
    [

    if test "x$cross_compiling" != "xno"; then
        if test "x$OH_SIZEOF_UCHAR" = x; then
	    AC_CHECK_SIZEOF([unsigned char])
            OH_SIZEOF_UCHAR=$ac_cv_sizeof_uchar
        fi
        if test "x$OH_SIZEOF_USHORT" = x; then
	    AC_CHECK_SIZEOF([unsigned short])
            OH_SIZEOF_USHORT=$ac_cv_sizeof_ushort
        fi
        if test "x$OH_SIZEOF_UINT" = x; then
	    AC_CHECK_SIZEOF([unsigned int])
            OH_SIZEOF_UINT=$ac_cv_sizeof_uint
        fi
        if test "x$OH_SIZEOF_CHAR" = x; then
	    AC_CHECK_SIZEOF([char])
            OH_SIZEOF_CHAR=$ac_cv_sizeof_char
        fi
        if test "x$OH_SIZEOF_SHORT" = x; then
	    AC_CHECK_SIZEOF([short])
            OH_SIZEOF_SHORT=$ac_cv_sizeof_short
        fi
        if test "x$OH_SIZEOF_INT" = x; then
	    AC_CHECK_SIZEOF([int])
            OH_SIZEOF_INT=$ac_cv_sizeof_int
        fi
        if test "x$OH_SIZEOF_LLONG" = x; then
	    AC_CHECK_SIZEOF([long long])
            OH_SIZEOF_LLONG=$ac_cv_sizeof_longlong
        fi
        if test "x$OH_SIZEOF_FLOAT" = x; then
	    AC_CHECK_SIZEOF([float])
            OH_SIZEOF_FLOAT=$ac_cv_sizeof_float
        fi
        if test "x$OH_SIZEOF_DOUBLE" = x; then
	    AC_CHECK_SIZEOF([double])
            OH_SIZEOF_DOUBLE=$ac_cv_sizeof_double
        fi
    else
        OH_SSFILE=testsize
        OH_SSSOURCE="$OH_SSFILE.c"
        echo "#include <stdlib.h>" > $OH_SSSOURCE
        echo "#include <stdio.h>" >> $OH_SSSOURCE
        echo "int main() {" >> $OH_SSSOURCE
        # add more here if you need them
        # the lots of slashes are needed to do the processing below right
        echo "printf(\"unsigned char %u\\\\n\",(unsigned int)sizeof(unsigned char));" >> $OH_SSSOURCE
        echo "printf(\"unsigned short %u\\\\n\",(unsigned int)sizeof(unsigned short));" >> $OH_SSSOURCE
        echo "printf(\"unsigned int %u\\\\n\",(unsigned int)sizeof(unsigned int));" >> $OH_SSSOURCE
        echo "printf(\"char %u\\\\n\",(unsigned int)sizeof(char));" >> $OH_SSSOURCE
        echo "printf(\"short %u\\\\n\",(unsigned int)sizeof(short));" >> $OH_SSSOURCE
        echo "printf(\"int %u\\\\n\",(unsigned int)sizeof(int));" >> $OH_SSSOURCE
        echo "printf(\"long long %u\\\\n\",(unsigned int)sizeof(long long));" >> $OH_SSSOURCE
        echo "printf(\"float %u\\\\n\",(unsigned int)sizeof(float));" >> $OH_SSSOURCE
        echo "printf(\"double %u\\\\n\",(unsigned int)sizeof(double));" >> $OH_SSSOURCE
        echo "return 0;" >> $OH_SSSOURCE
        echo "}" >> $OH_SSSOURCE
    
        $CC -o $OH_SSFILE $OH_SSSOURCE

        OH_TYPE_SIZES=`./$OH_SSFILE`
        # feel free to define more logic here if we need it
    
        OH_SIZEOF_UCHAR=`echo -e $OH_TYPE_SIZES | grep "^unsigned char" | awk '{print $[3]}'`
        OH_SIZEOF_USHORT=`echo -e $OH_TYPE_SIZES | grep "^unsigned short" | awk '{print $[3]}'`
        OH_SIZEOF_UINT=`echo -e $OH_TYPE_SIZES | grep "^unsigned int" | awk '{print $[3]}'`
        OH_SIZEOF_CHAR=`echo -e $OH_TYPE_SIZES | grep "^char" | awk '{print $[2]}'`
        OH_SIZEOF_SHORT=`echo -e $OH_TYPE_SIZES | grep "^short" | awk '{print $[2]}'`
        OH_SIZEOF_INT=`echo -e $OH_TYPE_SIZES | grep "^int" | awk '{print $[2]}'`
        OH_SIZEOF_LLONG=`echo -e $OH_TYPE_SIZES | grep "^long long" | awk '{print $[3]}'`
        OH_SIZEOF_FLOAT=`echo -e $OH_TYPE_SIZES | grep "^float" | awk '{print $[2]}'`
        OH_SIZEOF_DOUBLE=`echo -e $OH_TYPE_SIZES | grep "^double" | awk '{print $[2]}'`
        rm -f $OH_SSFILE $OH_SSSOURCE

    fi
    ])

#
# OH_CHECK_FAIL($LIBNAME,$PACKAGE_SUGGEST,$URL,$EXTRA)
#

AC_DEFUN([OH_CHECK_FAIL],
    [
    OH_MSG=`echo -e "- $1 not found!\n"`
    if test "x" != "x$4"; then
        OH_MSG=`echo -e "$OH_MSG\n- $4"`
    fi
    if test "x$2" != "x"; then
        OH_MSG=`echo -e "$OH_MSG\n- Try installing the $2 package\n"`
    fi
    if test "x$3" != "x"; then
        OH_MSG=`echo -e "$OH_MSG\n- or get the latest software from $3\n"`
    fi
    
    AC_MSG_ERROR(
!
************************************************************
$OH_MSG
************************************************************
)
    ]
)

#
#  gcc version check.
#

AC_DEFUN([OH_CHECK_GCC],
    [
    GCCVERSIONOK=`gcc -dumpversion | \
    sed 's/\./ /g' | \
    awk '{ \
        if ( $[1] > $1) { \
            print "OK"; \
        } \
        if ( $[1] == $1 ) { \
            if( $[2] > $2 ) { \
                print "OK"; \
            } \
            if( $[2] == $2 ) { \
                print "OK"; \
            } \
        } \
    }'` \
    
    if test "$GCCVERSIONOK" = "OK"; then
        AC_MSG_RESULT(yes)
    else
        OH_CHECK_FAIL(gcc >= $1.$2 is required to build OpenHPI)
    fi
])
    

# it is worth noting that we have to strip 
# optimization from the cflags for net-snmp
# hopefully they'll fix that bug in the future

AC_DEFUN([OH_CHECK_NETSNMP],
    [
    AC_MSG_CHECKING(for net-snmp)
    AC_TRY_LINK(
    [
        #include <net-snmp/net-snmp-config.h>
        #include <net-snmp/net-snmp-includes.h>
    ],
    [
        struct snmp_session session
    ],
    [
        have_netsnmp=yes
        SNMPFLAGS=`${net_snmp_config:-net-snmp-config} --cflags | perl -p -e 's/ -O\S*//g'`
        SNMPLIBS=`${net_snmp_config:-net-snmp-config} --libs`
        AC_MSG_RESULT(yes)
    ],
    [AC_MSG_RESULT(no.  No SNMP based plugins can be built!)])
])


AC_DEFUN([OH_CHECK_OPENIPMI],
	[
	AC_MSG_CHECKING(for OpenIPMI)

	OH_OI_FILE=ipmi_ver
	OH_OI_SRC="ipmi_ver.c"
	echo "#include <stdio.h>" > $OH_OI_SRC
	echo "#include <OpenIPMI/ipmiif.h>" >> $OH_OI_SRC
	echo "int main() {" >> $OH_OI_SRC
	echo "printf(\"%d.%d.%d\", OPENIPMI_VERSION_MAJOR, \
				   OPENIPMI_VERSION_MINOR, \
				   OPENIPMI_VERSION_RELEASE);" >> $OH_OI_SRC
	echo "return 0;}" >> $OH_OI_SRC

	gcc -o $OH_OI_FILE $CFLAGS $CPPFLAGS $LDFLAGS $OH_OI_SRC >& /dev/null

	if test -f "ipmi_ver"; then
		OPENIPMI_VERSION=`./ipmi_ver | \
		awk -F. '{ \
			if ( $[1] == $1 ) { \
				if ( $[2] == $2 ) { \
			    	if ( $[3] >= $3 ) { \
			    		print "OK"; \
					} \
				}
			}

		}'` 
	fi
		
	if test "$OPENIPMI_VERSION" = "OK"; then
		have_openipmi=yes
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no...OpenIPMI missing or wrong version IPMI plug-in can't build)
		have_openipmi=no
   	fi

	rm -rf $OH_OI_FILE $OH_OI_SRC
])

AC_DEFUN([PKG_CFG_SETPATH],
[
	if test "x$cross_compiling" != "xyes"; then
		if test -f "/etc/ld.so.conf"; then
			TEMP=`cat /etc/ld.so.conf | grep "/lib$"`
			TEMP=`echo $TEMP | sed -e 's/\/lib \|\/lib$/\/lib\/pkgconfig:/g'`
			PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${TEMP}"
			export PKG_CONFIG_PATH
		fi
	fi
])

AC_DEFUN([OH_CHECK_RTAS],
    [
    AC_MSG_CHECKING(for RTAS libary)
    AC_TRY_COMPILE(
        [
	    #include <stdio.h>
	    #include <librtas.h>
        ],    
        [
            rtas_activate_firmware();
        ],
        [
	    if test -f "/usr/bin/lsvpd"; then
		    have_rtas_lib=yes
        	    AC_MSG_RESULT(yes)
	    else
		    AC_MSG_RESULT(no)
	    fi
       ],
       [AC_MSG_RESULT(no)]
    )])