1	echo "Checking for RRDtool ..."
2
3	RRDDEF=""
4	RRDINC=""
5	RRDLIB=""
6	PNGLIB=""
7	ZLIB=""
8	for DIR in /opt/rrdtool* /usr/local/rrdtool* /usr/local /usr/pkg /opt/csw /opt/sfw /usr/sfw
9	do
10		if test -f $DIR/include/rrd.h
11		then
12			RRDINC=$DIR/include
13		fi
14
15		if test -f $DIR/lib/librrd.so
16		then
17			RRDLIB=$DIR/lib
18		fi
19		if test -f $DIR/lib/librrd.a
20		then
21			RRDLIB=$DIR/lib
22		fi
23		if test -f $DIR/lib64/librrd.so
24		then
25			RRDLIB=$DIR/lib64
26		fi
27		if test -f $DIR/lib64/librrd.a
28		then
29			RRDLIB=$DIR/lib64
30		fi
31
32		if test -f $DIR/lib/libpng.so
33		then
34			PNGLIB="-L$DIR/lib -lpng"
35		fi
36		if test -f $DIR/lib/libpng.a
37		then
38			PNGLIB="-L$DIR/lib -lpng"
39		fi
40		if test -f $DIR/lib64/libpng.so
41		then
42			PNGLIB="-L$DIR/lib64 -lpng"
43		fi
44		if test -f $DIR/lib64/libpng.a
45		then
46			PNGLIB="-L$DIR/lib64 -lpng"
47		fi
48
49		if test -f $DIR/lib/libz.so
50		then
51			ZLIB="-L$DIR/lib -lz"
52		fi
53		if test -f $DIR/lib/libz.a
54		then
55			ZLIB="-L$DIR/lib -lz"
56		fi
57		if test -f $DIR/lib64/libz.so
58		then
59			ZLIB="-L$DIR/lib64 -lz"
60		fi
61		if test -f $DIR/lib64/libz.a
62		then
63			ZLIB="-L$DIR/lib64 -lz"
64		fi
65	done
66
67	if test "$USERRRDINC" != ""; then
68		RRDINC="$USERRRDINC"
69	fi
70	if test "$USERRRDLIB" != ""; then
71		RRDLIB="$USERRRDLIB"
72	fi
73
74	# See if it builds
75	RRDOK="YES"
76	if test "$RRDINC" != ""; then INCOPT="-I$RRDINC"; fi
77	if test "$RRDLIB" != ""; then LIBOPT="-L$RRDLIB"; fi
78	cd build
79	OS=`uname -s | sed -e's@/@_@g'` $MAKE -f Makefile.test-rrd clean
80	OS=`uname -s | sed -e's@/@_@g'` RRDDEF="$RRDDEF" RRDINC="$INCOPT" $MAKE -f Makefile.test-rrd test-compile 2>/dev/null
81	if test $? -ne 0; then
82		# See if it's the new RRDtool 1.2.x
83		echo "Not RRDtool 1.0.x, checking for 1.2.x"
84		RRDDEF="-DRRDTOOL12"
85		OS=`uname -s | sed -e's@/@_@g'` $MAKE -f Makefile.test-rrd clean
86		OS=`uname -s | sed -e's@/@_@g'` RRDDEF="$RRDDEF" RRDINC="$INCOPT" $MAKE -f Makefile.test-rrd test-compile
87	fi
88	if test $? -eq 0; then
89		echo "Compiling with RRDtool works OK"
90	else
91		echo "ERROR: Cannot compile with RRDtool."
92		RRDOK="NO"
93	fi
94
95	OS=`uname -s | sed -e's@/@_@g'` RRDLIB="$LIBOPT" PNGLIB="$PNGLIB" $MAKE -f Makefile.test-rrd test-link 2>/dev/null
96	if test $? -ne 0; then
97		# Could be that we need -lz for RRD
98		PNGLIB="$PNGLIB $ZLIB"
99	fi
100	OS=`uname -s | sed -e's@/@_@g'` RRDLIB="$LIBOPT" PNGLIB="$PNGLIB" $MAKE -f Makefile.test-rrd test-link 2>/dev/null
101	if test $? -ne 0; then
102		# Could be that we need -lm for RRD
103		PNGLIB="$PNGLIB -lm"
104	fi
105	OS=`uname -s | sed -e's@/@_@g'` RRDLIB="$LIBOPT" PNGLIB="$PNGLIB" $MAKE -f Makefile.test-rrd test-link 2>/dev/null
106	if test $? -ne 0; then
107		# Could be that we need -L/usr/X11R6/lib (OpenBSD)
108		LIBOPT="$LIBOPT -L/usr/X11R6/lib"
109		RRDLIB="$RRDLIB -L/usr/X11R6/lib"
110	fi
111	OS=`uname -s | sed -e's@/@_@g'` RRDLIB="$LIBOPT" PNGLIB="$PNGLIB" $MAKE -f Makefile.test-rrd test-link 2>/dev/null
112	if test $? -eq 0; then
113		echo "Linking with RRDtool works OK"
114		if test "$PNGLIB" != ""; then
115			echo "Linking RRD needs extra library: $PNGLIB"
116		fi
117	else
118		echo "ERROR: Linking with RRDtool fails"
119		RRDOK="NO"
120	fi
121	OS=`uname -s | sed -e's@/@_@g'` $MAKE -f Makefile.test-rrd clean
122	cd ..
123
124	if test "$RRDOK" = "NO"; then
125		echo "RRDtool include- or library-files not found."
126		echo "These are REQUIRED for trend-graph support in Xymon, but Xymon can"
127		echo "be built without them (e.g. for a network-probe only installation."
128		echo ""
129		echo "RRDtool can be found at http://oss.oetiker.ch/rrdtool/"
130		echo "If you have RRDtool installed, use the \"--rrdinclude DIR\" and \"--rrdlib DIR\""
131		echo "options to configure to specify where they are."
132		echo ""
133		echo "Continuing with all trend-graph support DISABLED"
134		sleep 3
135	fi
136
137
138