summaryrefslogtreecommitdiff
path: root/configure.ac
blob: c20c2e56309d6e891244560311eb3085df546b1b (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
92
93
94
95
96
97
98
99
AC_PREREQ([2.69])
AC_INIT([sila-snmp],
        [m4_esyscmd_s([git describe --dirty --long --always])],
        [https://github.com/SILA/obmc-sila-snmp])
AC_LANG([C++])
AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign])
AM_SILENT_RULES([yes])

# Checks for programs
AC_PROG_CXX
AM_PROG_AR
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P

# Checks for typedefs, structures and compiler characteristics.
AX_CXX_COMPILE_STDCXX_17([noext])
AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS])

# Checks for libraries.
PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
AC_SUBST(SDBUSPLUS_CFLAGS)
AC_SUBST(SDBUSPLUS_LIBS)

PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus])
AC_SUBST(SDEVENTPLUS_CLFAGS)
AC_SUBST(SDEVENTPLUS_LIBS)

PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces])

# Check for sdbus++
AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
AS_IF([test "x$SDBUSPLUSPLUS" == "x"],
    AC_MSG_ERROR(["Requires sdbus++"]))

AC_CHECK_HEADERS([net-snmp/net-snmp-config.h],,\
    AC_MSG_ERROR(["Requires net-snmp headers"]))

# Check for net-snmp-config
AC_PATH_PROG([NETSNMP_CONFIG], [net-snmp-config])
AS_IF([test "x$NETSNMP_CONFIG" == "x"],
    AC_MSG_ERROR(["Requires net-snmp-config"]))

NETSNMP_CFLAGS=`$NETSNMP_CONFIG --base-cflags`
NETSNMP_AGENT_LIBS=`$NETSNMP_CONFIG --agent-libs`
AC_SUBST([NETSNMP_CFLAGS])
AC_SUBST([NETSNMP_AGENT_LIBS])

# Checks for library functions
LT_INIT # Required for systemd linking

PKG_PROG_PKG_CONFIG
AC_ARG_WITH([systemdsystemunitdir],
     [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
     [],
     [with_systemdsystemunitdir=auto]
)
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
    [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
     AS_IF([test "x$def_systemdsystemunitdir" = "x"],
           [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
                  [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]
            )
            with_systemdsystemunitdir=no],
           [with_systemdsystemunitdir="$def_systemdsystemunitdir"]
     )]
)
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
      [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]
)
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])

AC_ARG_ENABLE([agent],
    AS_HELP_STRING([--disable-agent], [Disable sila-snmp-agent.]))
AC_ARG_ENABLE([cfg-manager],
    AS_HELP_STRING([--disable-cfg-manager], [Disable sila-snmp-cfg-manager.]))

AM_CONDITIONAL([WANT_AGENT], [test "x$enable_agent" != "xno"])
AM_CONDITIONAL([WANT_CFG_MANAGER], [test "x$enable_cfg_manager" != "xno"])

AC_ARG_VAR(SYSTEMD_TARGET, "Target for starting this service")
AS_IF([test "x$SYSTEMD_TARGET" = "x"], [SYSTEMD_TARGET="multi-user.target"])

# Package specific checks.
AS_IF([test "x$enable_agent" != "xno"], [
       AC_CONFIG_FILES([agent/Makefile])
       AC_CONFIG_FILES([agent/sila-snmp-agent.service])
])
AS_IF([test "x$enable_cfg_manager" != "xno"], [
       AC_CONFIG_FILES([snmpcfg/Makefile])
       AC_CONFIG_FILES([snmpcfg/sila-snmp-cfg-manager.service])
])

# Create configured output
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT