Imported Upstream version 0.6.2.17
[psensor-pkg-debian.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.64])
5 AC_INIT([psensor], [0.6.2.17],[jeanfi@gmail.com],[psensor],[http://wpitchoune.net/psensor])
6
7 AM_INIT_AUTOMAKE([-Wall -Werror gnu])
8
9 AC_CONFIG_SRCDIR([src/compat.h])
10 AC_CONFIG_HEADERS([config.h])
11
12 # Checks for programs.
13 AC_PROG_CC
14 AM_PROG_CC_C_O
15
16 # Checks lib build
17 AC_PROG_RANLIB
18
19 # Checks for header files.
20 AC_PATH_X
21 AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h getopt.h])
22
23 # Checks for typedefs, structures, and compiler characteristics.
24 AC_TYPE_SIZE_T
25 AC_TYPE_SSIZE_T
26
27 # Checks for library functions.
28 AC_FUNC_MALLOC
29 AC_FUNC_REALLOC
30 AC_CHECK_FUNCS([gettimeofday memmove socket strdup strtol])
31
32 AM_GNU_GETTEXT_VERSION([0.16])
33 AM_GNU_GETTEXT([external])
34
35 ############### common 
36
37 # Checks sensors, required by psensor and psensor-server
38 AC_CHECK_LIB(sensors, sensors_init)
39 AC_CHECK_HEADERS([sensors/sensors.h sensors/errors.h])
40 SENSORS_LIBS=-lsensors
41 AC_SUBST(SENSORS_LIBS)
42
43 ############### psensor 
44
45 ### Required
46
47 PKG_CHECK_MODULES(X11, x11)
48 AC_SUBST(X11_CFLAGS)
49 AC_SUBST(X11_LIBS)
50
51 PKG_CHECK_MODULES(XEXT, xext)
52 AC_SUBST(XEXT_CFLAGS)
53 AC_SUBST(XEXT_LIBS)
54
55 # Checks GTK
56 GTK_LIBS=
57 PKG_CHECK_MODULES(GTK,
58                   gtk+-3.0,
59                   [AC_DEFINE([HAVE_GTK3],[1],[Use GTK3])],
60                   [AC_MSG_WARN("GTK+ 3 not present")])
61 AM_CONDITIONAL(GTK, test -n "$GTK_LIBS")
62 AC_SUBST(GTK_CFLAGS)
63 AC_SUBST(GTK_LIBS)
64
65 if test "$GTK_LIBS" == ""; then
66    PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.18)
67    AM_CONDITIONAL(GTK, test -n "$GTK_LIBS")
68    AC_SUBST(GTK_CFLAGS)
69    AC_SUBST(GTK_LIBS)
70 fi
71
72 # Check GCONF
73 PKG_CHECK_MODULES(GCONF, gconf-2.0)
74 AC_SUBST(GCONF_CFLAGS)
75 AC_SUBST(GCONF_LIBS)
76
77 ### Optional
78
79 # Check libnotify
80 LIBNOTIFY_LIBS=
81 PKG_CHECK_MODULES(LIBNOTIFY, 
82   libnotify, 
83   [AC_DEFINE([HAVE_LIBNOTIFY],[1],[Use desktop notification])], 
84   [AC_MSG_WARN("Desktop notification disabled")])
85 AM_CONDITIONAL(LIBNOTIFY, test -n "$LIBNOTIFY_LIBS")
86 AC_SUBST(LIBNOTIFY_CFLAGS)
87 AC_SUBST(LIBNOTIFY_LIBS)
88
89 # Checks AppIndicator 
90 APPINDICATOR_LIBS=
91
92 PKG_CHECK_MODULES(APPINDICATOR, appindicator3-0.1,
93      [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator3-0.1])],
94      [AC_MSG_WARN(AppIndicator 3-0.1 not present")])
95
96 if test "$APPINDICATOR_LIBS" == ""; then
97    PKG_CHECK_MODULES(APPINDICATOR, 
98      appindicator-0.1 <= 0.2.9 , 
99      [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator 0.2.9])
100       AC_DEFINE([HAVE_APPINDICATOR_029],[1],[Use AppIndicator 0.2.9])
101      ],
102      [AC_MSG_WARN(AppIndicator 0.2.9 not present")])
103 fi
104
105 if test "$APPINDICATOR_LIBS" == ""; then
106    PKG_CHECK_MODULES(APPINDICATOR, 
107      appindicator-0.1 > 0.2.9, 
108      [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator > 0.2.9])], 
109      [AC_MSG_WARN("AppIndicator > 0.2.9 not present")])
110 fi
111 AM_CONDITIONAL(APPINDICATOR, test -n "$APPINDICATOR_LIBS")
112 AC_SUBST(APPINDICATOR_CFLAGS)
113 AC_SUBST(APPINDICATOR_LIBS)
114
115 # Check CURL, needed for remote monitoring
116 CURL_LIBS=
117 PKG_CHECK_MODULES(CURL, 
118   libcurl, 
119   [AC_DEFINE([HAVE_CURL],[1],[Use CURL])], 
120   [AC_MSG_WARN("Remote monitoring disabled, curl missing")])
121 AM_CONDITIONAL(CURL, test -n "$CURL_LIBS")
122 AC_SUBST(CURL_CFLAGS)
123 AC_SUBST(CURL_LIBS)
124
125 # Check JSON, needed for remote monitoring
126 JSON_LIBS=
127 PKG_CHECK_MODULES(JSON, 
128   json, 
129   [AC_DEFINE([HAVE_JSON],[1],[Use JSON])], 
130   [AC_MSG_WARN("Remote monitoring disabled, json missing")])
131 AM_CONDITIONAL(JSON, test -n "$JSON_LIBS")
132 AC_SUBST(JSON_CFLAGS)
133 AC_SUBST(JSON_LIBS)
134
135 # Enables remote monitoring if JSON and CURL is present
136 if test -n "$JSON_LIBS"; then
137    if test -n "$CURL_LIBS"; then
138    AC_DEFINE([HAVE_REMOTE_SUPPORT],[1],[Remote monitoring enabled])
139    fi
140 fi
141
142 # Checks NVIDIA
143 # following code from sensors-applet
144 # sensors-applet.sourceforge.net/
145 AC_CHECK_HEADERS(NVCtrl/NVCtrl.h NVCtrl/NVCtrlLib.h, 
146                  [ HAVE_NVIDIA=true ], [], 
147                  [ 
148                   #include <X11/Xlib.h>
149                  ])
150 if test -n "${X11_LIBS}"; then
151 LIBS="${LIBS} -lX11 -lXext"
152
153 if test "${HAVE_NVIDIA}" = "true"; then
154   AC_CHECK_LIB(XNVCtrl,XNVCTRLQueryExtension, 
155                  [NVIDIA_LIBS="-lXNVCtrl -lX11 -lXext" 
156                   AC_DEFINE(HAVE_NVIDIA,1,[NVidia support enabled])
157                  ])                     
158 fi
159 fi
160 AM_CONDITIONAL(NVIDIA, test -n "$NVIDIA_LIBS")
161 AC_SUBST(NVIDIA_CFLAGS)
162 AC_SUBST(NVIDIA_LIBS)
163
164 # Checks Unity
165 PKG_CHECK_MODULES(UNITY, 
166                   unity >= 3.4.2,
167                   [AC_DEFINE([HAVE_UNITY],[1],[Use Unity])], 
168                   [AC_MSG_WARN(Unity not present)])
169 AC_SUBST(UNITY_CFLAGS)
170 AC_SUBST(UNITY_LIBS)
171 AM_CONDITIONAL(UNITY, test -n "$UNITY_LIBS")
172
173 # libatiadl
174 AC_ARG_WITH(libatiadl,
175 [  --with-libatiadl[=DIR]   use libatiadlxx in DIR],[
176                    ATIADL_DIR=${withval}
177                    CPPFLAGS="${CPPFLAGS} -I${ATIADL_DIR}/include"
178                    LIBS="$LIBS -L/usr/lib/fglrx -L/usr/lib64/fglrx -L/usr/lib/catalyst -L/usr/lib64/catalyst"
179                   ]
180 )
181
182 AC_CHECK_HEADERS(adl_defines.h,
183         AC_CHECK_LIB(atiadlxx,ADL_Main_Control_Refresh,
184                 [
185                         AC_DEFINE(HAVE_LIBATIADL,1,[libatiadl is available])
186                         LIBATIADL_CFLAGS="-I${ATIADL_DIR}/include"
187                         LIBATIADL_LIBS="-L/usr/lib/fglrx -L/usr/lib64/fglrx -L/usr/lib/catalyst -L/usr/lib64/catalyst -latiadlxx -ldl"
188                 ]))
189
190 AM_CONDITIONAL(LIBATIADL, test -n "$LIBATIADL_LIBS")
191 AC_SUBST(LIBATIADL_CFLAGS)
192 AC_SUBST(LIBATIADL_LIBS)
193
194 ############### psensor-server
195
196 # libmicrohttpd, mandatory for psensor-server
197 LIBMICROHTTPD_LIBS=
198 PKG_CHECK_MODULES(LIBMICROHTTPD, 
199   libmicrohttpd, 
200   [AC_DEFINE([HAVE_LIBMICROHTTPD],[1],[Use libmicrohttpd])], 
201   [AC_MSG_WARN("libmicrohttpd not present, psensor-server will NOT be built")])
202 AM_CONDITIONAL(LIBMICROHTTPD, test -n "$LIBMICROHTTPD_LIBS")
203 AC_SUBST(LIBMICROHTTPD_CFLAGS)
204 AC_SUBST(LIBMICROHTTPD_LIBS)
205
206 # GTop, optional
207
208 AC_ARG_WITH(gtop,
209 [  --with-gtop[=yes|no]   use gtop],[
210         with_gtop=$withval],[
211         with_gtop="yes"
212 ])
213
214 GTOP_LIBS=
215 if test "$with_gtop" = "yes"; then
216 PKG_CHECK_MODULES(GTOP, 
217   libgtop-2.0, 
218   [AC_DEFINE([HAVE_GTOP],[1],[Use GTOP])], 
219   [AC_MSG_WARN("gtop not present, CPU/Memory information will NOT be available")])
220 fi
221 AM_CONDITIONAL(GTOP, test -n "$GTOP_LIBS")
222 AC_SUBST(GTOP_CFLAGS)
223 AC_SUBST(GTOP_LIBS)
224
225 AC_CONFIG_FILES([
226  Makefile
227  src/Makefile
228  src/glade/Makefile
229  src/lib/Makefile
230  src/server/Makefile
231  icons/hicolor/scalable/Makefile
232  icons/hicolor/14x14/Makefile
233  icons/hicolor/16x16/Makefile
234  icons/hicolor/22x22/Makefile
235  icons/hicolor/24x24/Makefile
236  icons/hicolor/32x32/Makefile
237  icons/hicolor/48x48/Makefile
238  icons/hicolor/64x64/Makefile
239  icons/ubuntu-mono-dark/status/22/Makefile
240  icons/ubuntu-mono-light/status/22/Makefile
241  icons/ubuntu-mono-dark/apps/22/Makefile
242  www/Makefile
243  po/Makefile.in
244  tests/Makefile
245 ])
246
247 AC_CHECK_PROGS([HELP2MAN], [help2man])
248
249 AC_OUTPUT