-
Notifications
You must be signed in to change notification settings - Fork 4
/
configure.ac
114 lines (92 loc) · 3.17 KB
/
configure.ac
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
AC_INIT([libvirt-snmp],[0.0.4],[[email protected]],[],[https://libvirt.org])
AC_CONFIG_SRCDIR(src/libvirtSnmp.c)
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([-Wall -Werror])
AM_SILENT_RULES([yes])
AC_PROG_CC
AM_PROG_CC_C_O
AC_CHECK_FUNCS([memset])
AC_CHECK_FUNCS([strdup])
AC_CHECK_HEADERS([stdlib.h])
AC_FUNC_MALLOC
AC_TYPE_SIZE_T
AC_C_CONST
AC_TYPE_SIGNAL
dnl
dnl libvirt-snmp
dnl
dnl do we have libvirt installed?
LIBVIRT_REQUIRED=1.0.6
PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
AC_SUBST(LIBVIRT_LIBS)
AC_SUBST(LIBVIRT_CFLAGS)
SNMP_CONFIG="net-snmp-config"
SNMP_CFLAGS=""
SNMP_LIBS=""
SNMP_FOUND="no"
AC_ARG_WITH([net-snmp], [AS_HELP_STRING([--with-netsnmp], [net-snmp library location@<:@default=check@:>@])])
if test "x$with_netsnmp" = "xno" ; then
AC_MSG_ERROR([You must install net-snmp library in order to compile and run libvirt-snmp])
elif test "x$with_netsnmp" = "x" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES(SNMP, net-snmp, [SNMP_FOUND=yes], [SNMP_FOUND=no])
fi
if test "$SNMP_FOUND" = "no" ; then
if test "x$with_netsnmp" != "x" ; then
SNMP_CONFIG="$with_netsnmp/bin/$SNMP_CONFIG"
fi
AC_MSG_CHECKING(net-snmp $SNMP_CONFIG)
if ! $SNMP_CONFIG --version > /dev/null 2>&1 ; then
AC_MSG_ERROR([Could not find $SNMP_CONFIG anywhere (see config.log for details)])
fi
SNMP_LIBS="`$SNMP_CONFIG --agent-libs`"
SNMP_CFLAGS="`$SNMP_CONFIG --base-cflags`"
AC_MSG_RESULT([yes])
fi
AC_SUBST([SNMP_CFLAGS])
AC_SUBST([SNMP_LIBS])
MIB_DIR=""
AC_ARG_WITH([mibdir], [AS_HELP_STRING([--with-mibdir], [MIB directory location@<:@default=check@:>@])])
if test "x$with_mibdir" = "xno" ; then
AC_MSG_ERROR([You definitely want to specify MIB directory, so SNMP tools know libvirt MIB])
fi
if test "x$with_mibdir" = "x" ; then
AC_MSG_CHECKING([MIB directories])
MIB_DIR="`$SNMP_CONFIG --default-mibdirs`"
if test -z "$MIB_DIR" ; then
AC_MSG_ERROR([Could not find any default MIB directory. Please specify one by --with-mibdir])
fi
#choose the last one, it's likely system-wide
MIB_DIR=$(echo $MIB_DIR | awk -F : '{print $NF}')
AC_MSG_RESULT([found $MIB_DIR])
dnl Replace net-snmp's exec_prefix with our own.
dnl Note that ${exec_prefix} is kept verbatim at this point in time,
dnl and will only be expanded later, when make is called: this makes
dnl it possible to override such prefix at compilation or installation
dnl time
MIB_PREFIX="`$SNMP_CONFIG --prefix`"
MIB_DIR='${exec_prefix}'"${MIB_DIR#$MIB_PREFIX}"
else
AC_MSG_CHECKING([accessibility of $with_mibdir])
if test ! -d "$with_mibdir" ; then
AC_MSG_ERROR([$with_mibdir is not accessible])
fi
MIB_DIR=$with_mibdir
fi
AC_SUBST([MIB_DIR])
dnl pthread
PTHREAD_LIBS=
AC_CHECK_HEADERS(pthread.h, [], [AC_MSG_ERROR([pthread.h required])])
AC_CHECK_LIB(pthread, pthread_create, [PTHREAD_LIBS="-lpthread"])
AC_SUBST([PTHREAD_LIBS])
AC_CANONICAL_HOST
PIE_CFLAGS=
PIE_LDFLAGS=
case "$host" in
*-linux*)
PIE_CFLAGS="-fPIE -DPIE"
PIE_LDFLAGS="-pie"
esac
AC_SUBST(PIE_CFLAGS)
AC_SUBST(PIE_LDFLAGS)
AC_OUTPUT(Makefile src/Makefile docs/Makefile libvirt-snmp.spec)