hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
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
From 086b5fa8fe4ba74404e92b5f838263dfcf9f173d Mon Sep 17 00:00:00 2001
From: Jim Klimov <jim@jimklimov.com>
Date: Thu, 7 Apr 2016 03:56:51 +0200
Subject: [PATCH] Allow to customize path to gdlib-config and net-snmp-config
 programs
 
[yann.morin.1998@free.fr: backport]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 
---
Backported from upstream commit 086b5fa8fe4ba74404e92b5f838263dfcf9f173d
---
 docs/configure.txt         | 14 ++++++++++++++
 m4/nut_check_libgd.m4      | 29 +++++++++++++++++++++++------
 m4/nut_check_libnetsnmp.m4 | 25 +++++++++++++++++++++----
 3 files changed, 58 insertions(+), 10 deletions(-)
 
diff --git a/docs/configure.txt b/docs/configure.txt
index aff82c1..b3b542a 100644
--- a/docs/configure.txt
+++ b/docs/configure.txt
@@ -23,6 +23,13 @@ Note that you need to install the libusb development package or files.
 Build and install the SNMP drivers (default: auto-detect)
 Note that you need to install libsnmp development package or files.
 
+    --with-net-snmp-config
+
+In addition to the `--with-snmp` option above, this one allows to provide
+a custom program name (in `PATH`) or complete pathname to `net-snmp-config`.
+This may be needed on build systems which support multiple architectures,
+or in cases where your distribution names this program differently.
+
     --with-neon
 
 Build and install the XML drivers (default: auto-detect)
@@ -335,6 +342,13 @@ NOTE: the --with-gd switches are not necessary if you have gd 2.0.8
 or higher installed properly.  The gdlib-config script will be 
 detected and used by default in that situation.
 
+    --with-gdlib-config
+
+This option allows to provide a custom program name (in `PATH`) or
+a complete pathname to `gdlib-config`. This may be needed on build
+systems which support multiple architectures, or in cases where your
+distribution names this program differently.
+
     --with-ssl-includes, --with-usb-includes, --with-snmp-includes,
     --with-neon-includes, --with-libltdl-includes,
     --with-powerman-includes="-I/foo/bar"
diff --git a/m4/nut_check_libgd.m4 b/m4/nut_check_libgd.m4
index 01cc882..73f4da7 100644
--- a/m4/nut_check_libgd.m4
+++ b/m4/nut_check_libgd.m4
@@ -19,8 +19,25 @@ if test -z "${nut_have_libgd_seen}"; then
     LDFLAGS="-L/usr/X11R6/lib"
     LIBS="-lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11"
 
-    AC_MSG_CHECKING(for gd version via gdlib-config)
-    GD_VERSION=`gdlib-config --version 2>/dev/null`
+    dnl By default seek in PATH
+    GDLIB_CONFIG=gdlib-config
+    AC_ARG_WITH(gdlib-config,
+        AS_HELP_STRING([@<:@--with-gdlib-config=/path/to/gdlib-config@:>@],
+            [path to program that reports GDLIB configuration]),
+    [
+        case "${withval}" in
+        "") ;;
+        yes|no)
+            AC_MSG_ERROR(invalid option --with(out)-gdlib-config - see docs/configure.txt)
+            ;;
+        *)
+            GDLIB_CONFIG="${withval}"
+            ;;
+        esac
+    ])
+
+    AC_MSG_CHECKING(for gd version via ${GDLIB_CONFIG})
+    GD_VERSION=`${GDLIB_CONFIG} --version 2>/dev/null`
     if test "$?" != "0" -o -z "${GD_VERSION}"; then
         GD_VERSION="none"
     fi
@@ -30,13 +47,13 @@ if test -z "${nut_have_libgd_seen}"; then
     none)
         ;;
     2.0.5 | 2.0.6 | 2.0.7)
-        AC_MSG_WARN([[gd ${GD_VERSION} detected, unable to use gdlib-config script]])
+        AC_MSG_WARN([[gd ${GD_VERSION} detected, unable to use ${GDLIB_CONFIG} script]])
         AC_MSG_WARN([[If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs]])
         ;;
     *)
-        CFLAGS="`gdlib-config --includes 2>/dev/null`"
-        LDFLAGS="`gdlib-config --ldflags 2>/dev/null`"
-        LIBS="`gdlib-config --libs 2>/dev/null`"
+        CFLAGS="`${GDLIB_CONFIG} --includes 2>/dev/null`"
+        LDFLAGS="`${GDLIB_CONFIG} --ldflags 2>/dev/null`"
+        LIBS="`${GDLIB_CONFIG} --libs 2>/dev/null`"
         ;;
     esac
 
diff --git a/m4/nut_check_libnetsnmp.m4 b/m4/nut_check_libnetsnmp.m4
index e1c1426..83b2633 100644
--- a/m4/nut_check_libnetsnmp.m4
+++ b/m4/nut_check_libnetsnmp.m4
@@ -13,9 +13,26 @@ if test -z "${nut_have_libnetsnmp_seen}"; then
     CFLAGS_ORIG="${CFLAGS}"
     LIBS_ORIG="${LIBS}"
 
+    dnl By default seek in PATH
+    NET_SNMP_CONFIG=net-snmp-config
+    AC_ARG_WITH(net-snmp-config,
+        AS_HELP_STRING([@<:@--with-net-snmp-config=/path/to/net-snmp-config@:>@],
+            [path to program that reports Net-SNMP configuration]),
+    [
+        case "${withval}" in
+        "") ;;
+        yes|no)
+            AC_MSG_ERROR(invalid option --with(out)-net-snmp-config - see docs/configure.txt)
+            ;;
+        *)
+            NET_SNMP_CONFIG="${withval}"
+            ;;
+        esac
+    ])
+
     dnl See which version of the Net-SNMP library (if any) is installed
-    AC_MSG_CHECKING(for Net-SNMP version via net-snmp-config)
-    SNMP_VERSION=`net-snmp-config --version 2>/dev/null`
+    AC_MSG_CHECKING(for Net-SNMP version via ${NET_SNMP_CONFIG})
+    SNMP_VERSION=`${NET_SNMP_CONFIG} --version 2>/dev/null`
     if test "$?" != "0" -o -z "${SNMP_VERSION}"; then
         SNMP_VERSION="none"
     fi
@@ -33,7 +50,7 @@ if test -z "${nut_have_libnetsnmp_seen}"; then
             CFLAGS="${withval}"
             ;;
         esac
-    ], [CFLAGS="`net-snmp-config --base-cflags 2>/dev/null`"])
+    ], [CFLAGS="`${NET_SNMP_CONFIG} --base-cflags 2>/dev/null`"])
     AC_MSG_RESULT([${CFLAGS}])
 
     AC_MSG_CHECKING(for Net-SNMP libs)
@@ -48,7 +65,7 @@ if test -z "${nut_have_libnetsnmp_seen}"; then
             LIBS="${withval}"
             ;;
         esac
-    ], [LIBS="`net-snmp-config --libs 2>/dev/null`"])
+    ], [LIBS="`${NET_SNMP_CONFIG} --libs 2>/dev/null`"])
     AC_MSG_RESULT([${LIBS}])
 
     dnl Check if the Net-SNMP library is usable
-- 
2.7.4