Merge branch 'weather'
[lxde/lxpanel.git] / configure.ac
1 AC_PREREQ(2.53)
2 AC_INIT(lxpanel, 0.6.1, http://lxde.org/)
3 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-xz])
4 AC_CONFIG_HEADER([config.h])
5 AC_CONFIG_MACRO_DIR([m4])
6
7 # Support silent build rules. Disable by either passing --disable-silent-rules
8 # to configure or passing V=1 to make
9 AM_SILENT_RULES([yes])
10
11 # Force to dynamic
12 AC_DISABLE_STATIC
13
14 # Checks for programs.
15 AC_PROG_CC
16 AC_PROG_INSTALL
17 AC_PROG_LN_S
18 AC_PROG_INTLTOOL(, [no-xml])
19 AM_PROG_CC_C_O
20 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
21
22 #Initialize libtool
23 LT_PREREQ([2.2])
24 LT_INIT
25
26 # Checks for libraries.
27 AC_ARG_ENABLE(gtk3,
28 AC_HELP_STRING([--enable-gtk3],[enable to use gtk-3.0 instead of gtk-2.0]),
29 [case "${enableval}" in
30   yes)  enable_gtk3=yes ;;
31   no)   enable_gtk3=no ;;
32   *) AC_MSG_ERROR([bad value "${enableval}" for --enable-gtk3, use "yes" (default) or "no".]) ;;
33 esac],[])
34
35 if test "x$enable_gtk3" = "xyes" ; then
36   CFLAGS="$CFLAGS -DENABLE_GTK3"
37   pkg_modules="$pkg_modules gtk+-3.0 libfm-gtk3 >= 1.2.0 libwnck-3.0"
38 else
39   pkg_modules="$pkg_modules gtk+-2.0 >= 2.16.0 libfm-gtk >= 1.2.0 libwnck-1.0"
40 fi
41
42 pkg_modules="$pkg_modules \
43              gio-unix-2.0 \
44              gthread-2.0 \
45              gmodule-2.0 \
46              libmenu-cache"
47 PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
48 AC_SUBST(PACKAGE_CFLAGS)
49 AC_SUBST(PACKAGE_LIBS)
50
51 ###########################
52 # Indicator Info
53 ###########################
54 AC_ARG_ENABLE([indicator_support],
55     AS_HELP_STRING([--enable-indicator-support],
56                [enable plugin loading (default: disable)]),
57                indicator_support=$enableval, indicator_support="no")
58 AM_CONDITIONAL(ENABLE_INDICATOR_SUPPORT, test x"$indicator_support" = x"yes")
59
60 if test "$indicator_support" != "no"; then
61         INDICATOR_REQUIRED_VERSION=0.3.0
62         INDICATOR_PKG_NAME=indicator-0.4
63
64         PKG_CHECK_MODULES(APPLET, $INDICATOR_PKG_NAME >= $INDICATOR_REQUIRED_VERSION)
65         AC_SUBST(APPLET_CFLAGS)
66
67         if test "x$with_localinstall" = "xyes"; then
68                 INDICATORDIR="${libdir}/indicators/2/"
69                 INDICATORICONSDIR="${datadir}/indicator-applet/icons/"
70         else
71                 INDICATORDIR=`$PKG_CONFIG --variable=indicatordir $INDICATOR_PKG_NAME`
72                 INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir $INDICATOR_PKG_NAME`
73 fi
74         AC_SUBST(INDICATORDIR)
75         AC_SUBST(INDICATORICONSDIR)
76 fi
77
78
79 pkg_modules="x11"
80 PKG_CHECK_MODULES(X11, [$pkg_modules])
81 AC_SUBST(X11_LIBS)
82
83 pkg_modules="libmenu-cache"
84 PKG_CHECK_MODULES(MENU_CACHE, [$pkg_modules],
85                   enable_menu_cache=yes, enable_menu_cache=no)
86 if test x"$enable_menu_cache" = "xno"; then
87         AC_WARN([No libmenu-cache found.  All menu related routines are not built.])
88         AC_DEFINE(DISABLE_MENU, [1], [Disable menu related routines])
89 fi
90 AC_SUBST(MENU_CACHE_CFLAGS)
91 AC_SUBST(MENU_CACHE_LIBS)
92 AM_CONDITIONAL(ENABLE_MENU_CACHE, test x"$enable_menu_cache" = x"yes")
93
94 AC_ARG_ENABLE(more_warnings,
95        [AC_HELP_STRING([--enable-more-warnings],
96                [Add more warnings @<:@default=no@:>@])],
97        [enable_more_warnings="${enableval}"],
98        [enable_more_warnings=no]
99 )
100
101 if test x"$enable_more_warnings" = x"yes"; then
102   ADDITIONAL_FLAGS="-Wall -Werror=all -Werror=format -Werror=implicit-function-declaration -Werror=implicit-int -Werror=missing-braces -Werror=parentheses -Werror=return-type -Werror=strict-aliasing -Werror=switch -Wuninitialized -Werror=unused-label -Werror=unused-value -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Werror=missing-declarations -Wredundant-decls -Wmissing-noreturn -Wpointer-arith -Wcast-align -Wwrite-strings -Werror=inline -Werror=format-nonliteral -Wformat-nonliteral -Werror=format-security -Wformat-security -Winit-self -Werror=missing-include-dirs -Werror=undef -Werror=aggregate-return -Wmissing-format-attribute -Werror=nested-externs -fno-strict-aliasing -fmessage-length=0 -Wp,-D_FORTIFY_SOURCE=2 -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES"
103 fi
104 AC_SUBST(ADDITIONAL_FLAGS)
105
106 PACKAGE_CFLAGS="$PACKAGE_CFLAGS $MENU_CACHE_CFLAGS $ADDITIONAL_FLAGS"
107 PACKAGE_LIBS="$PACKAGE_LIBS $MENU_CACHE_LIBS"
108
109 AC_ARG_ENABLE(man,
110         [AC_HELP_STRING([--enable-man],
111                 [regenerate roff man pages from Docbook @<:@default=no@:>@])],
112         [enable_man="${enableval}"],
113         [enable_man=no]
114 )
115
116 dnl linker tweaking
117 # The function of the link flag --as-needed is to prevent unnecesary linking.
118 # Example: A -> B -> C
119 # Normally, A would link to B and also depend on C, this is of cource
120 # unnecesary. In this situation, however we do need to link to C, so this
121 # must be done explicitly. This flag comes in handy when a library ABI
122 # is changed, minimizing the amount of recompilations needed.
123 AC_MSG_CHECKING([whether $LD accepts --as-needed])
124 case `$LD --as-needed -v 2>&1 </dev/null` in
125 *GNU* | *'with BFD'*)
126     LDFLAGS="$LDFLAGS -Wl,--as-needed"
127     AC_MSG_RESULT([yes])
128     ;;
129 *)
130     AC_MSG_RESULT([no])
131     ;;
132 esac
133
134 dnl linker optimizations
135 AC_MSG_CHECKING([whether $LD accepts -O1])
136 case `$LD -O1 -v 2>&1 </dev/null` in
137 *GNU* | *'with BFD'*)
138   LDFLAGS="$LDFLAGS -Wl,-O1"
139   AC_MSG_RESULT([yes])
140   ;;
141 *)
142   AC_MSG_RESULT([no])
143   ;;
144 esac
145 AC_MSG_CHECKING([whether $LD accepts -Bsymbolic-functions])
146 case `$LD -Bsymbolic-functions -v 2>&1 </dev/null` in
147 *GNU* | *'with BFD'*)
148   LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
149   AC_MSG_RESULT([yes])
150   ;;
151 *)
152   AC_MSG_RESULT([no])
153   ;;
154 esac
155 AC_MSG_CHECKING([whether $LD accepts --sort-common])
156 case `$LD --sort-common -v 2>&1 </dev/null` in
157 *GNU* | *'with BFD'*)
158   LDFLAGS="$LDFLAGS -Wl,--sort-common"
159   AC_MSG_RESULT([yes])
160   ;;
161 *)
162   AC_MSG_RESULT([no])
163   ;;
164 esac
165
166 dnl FIXME: filter for undefined symbols in plugins
167 # when passing "-z defs" to linker, we would better to make sure
168 # there are no undefined references.  However, we intend not to
169 # fix at the moment since we don't have spin-off libraray containing
170 # the necessary functions.
171 if test ! -z "$LDFLAGS"; then
172     LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-Wl,-z,defs//'`
173 fi
174
175 LXPANEL_MODULE="-avoid-version \
176 -rpath \$(libdir)/lxpanel/plugins \
177 -no-undefined "'-export-symbols-regex "^[[^_]].*"'
178 AC_SUBST(LXPANEL_MODULE)
179
180 AC_ARG_ENABLE([alsa],
181     AS_HELP_STRING([--disable-alsa],
182                     [compile ALSA providers (default: enable)]),
183             compile_alsa=$enableval, compile_alsa="yes")
184 if test x"$compile_alsa" = "xyes"; then
185     AC_CHECK_HEADERS([alsa/asoundlib.h],
186                      [AC_CHECK_LIB([asound],
187                                    [snd_seq_open],
188                                    compile_alsa=yes,compile_alsa=no)],
189                           compile_alsa=no)
190 fi
191 AM_CONDITIONAL(BUILD_ALSA_PLUGINS, test x$compile_alsa = xyes)
192 dnl FIXME: check OSS existence
193 AM_CONDITIONAL(BUILD_OSS_PLUGINS, test x$compile_alsa = xno)
194
195 AC_ARG_ENABLE([plugins-loading],
196     AS_HELP_STRING([--disable-plugins-loading],
197                [disable plugin loading (default: enable)]),
198                plugins_loading=$enableval, plugins_loading="yes")
199
200 AM_CONDITIONAL(BUILD_PLUGIN_LOADER, test x$plugins_loading = xyes)
201
202 if test x"$plugins_loading" = "xno"; then
203     AC_DEFINE(DISABLE_PLUGINS_LOADING, [1], [Disable plugin loading])
204 fi
205
206 dnl Here are plugin listing.
207 plugin_netstatus=
208 plugin_netstat=
209 plugin_volume=
210 plugin_volumealsa=
211 plugin_cpu=
212 plugin_deskno=
213 plugin_batt=
214 plugin_xkb=
215 plugin_kbled=
216 plugin_thermal=
217 plugin_cpufreq=
218 plugin_monitors=
219 plugin_indicator=
220
221 AC_MSG_CHECKING([which plugins should be built dynamically])
222 AC_ARG_WITH(plugins,
223 [  --with-plugins=<list>  compile dynamic plugins in <list> ]
224 [                         plugins may be comma separated ]
225 [                         'all' builds all plugins (default), 'none' builds none ]
226 [                         plugins prefixed with '-' are not built]
227 [                         Possible plugins are: ]
228 [                         netstatus, netstat, volume, volumealsa, cpu, deskno, batt,]
229 [                         kbled, xkb, thermal, cpufreq, monitors, weather]
230 , plugins="$withval",[plugins="all"])
231
232 if test x"$plugins" != xall -a x"$plugins" != xnone; then
233     if test x"$plugins_loading" = xno; then
234         AC_MSG_ERROR(
235         [--disable-plugins-loading and --with-plugins conflict each other.])
236     fi
237 fi
238
239 ALL_PLUGINS_LIST="netstatus netstat volume volumealsa cpu deskno batt kbled xkb thermal cpufreq monitors indicator weather"
240 AC_SUBST(ALL_PLUGINS_LIST)
241
242 AC_DEFUN([check_plugin_name],[
243     plugin_found=false
244     for name in $ALL_PLUGINS_LIST; do
245         if test x[$1] = x[$name]; then
246             plugin_found=true
247         fi
248     done
249     if test x[$plugin_found] = false; then
250         echo [Unknown plugin $1.]
251         exit 1
252     fi
253 ])
254
255 if test "$plugins" != "none"; then
256     plugins=`echo $plugins | sed 's/,/ /g'`
257     for plugin in $plugins
258     do
259         case "$plugin" in
260             all)
261                 for name in $ALL_PLUGINS_LIST
262                 do
263                     export plugin_$name="$name"
264                 done
265                 ;;
266             -*)
267                 check_plugin_name([${plugin#-}])
268                 export plugin_${plugin#-}=
269                 ;;
270             *)
271                 check_plugin_name([$plugin])
272                 export plugin_$plugin=$plugin
273                 ;;
274         esac
275     done
276     AC_MSG_RESULT($plugins)
277 fi
278
279 dnl FIXME: OSS/ALSA checking
280 if test x"$compile_alsa" = "xno"; then
281     if test ! -z $plugin_volumealsa; then
282         AC_MSG_RESULT([no ALSA headers/libraries found!])
283         plugin_volumealsa=
284     fi
285 else
286     dnl force OSS plugin to <null>
287     plugin_volume=
288 fi
289
290 dnl Exclude indicator support when there is no support.
291 if test x"$indicator_support" = "xno"; then
292     plugin_indicator=
293 fi
294
295 PLUGINS_LIST="\
296     $plugin_netstatus \
297     $plugin_netstat \
298     $plugin_volume \
299     $plugin_volumealsa \
300     $plugin_cpu \
301     $plugin_deskno \
302     $plugin_batt \
303     $plugin_kbled \
304     $plugin_xkb \
305     $plugin_thermal \
306     $plugin_cpufreq \
307     $plugin_monitors \
308     $plugin_indicator \
309     $plugin_weather"
310
311 AC_SUBST(PLUGINS_LIST)
312
313 # Plugin-specific dependencies
314 # nestat
315 if test x"$plugin_netstat" != "x";then
316 AC_CHECK_HEADER([iwlib.h],,
317  AC_MSG_ERROR([netstat plugin requires wireless-tools-devel]))
318 fi
319
320 # weather
321 if test x"$plugin_weather" != "x";then
322 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
323 AC_SUBST(LIBXML2_CFLAGS)
324 AC_SUBST(LIBXML2_LIBS)
325 fi
326
327 # Checks for header files.
328 AC_PATH_X
329 AC_HEADER_STDC
330 AC_HEADER_SYS_WAIT
331 AC_CHECK_HEADERS([locale.h stdlib.h string.h sys/time.h unistd.h])
332
333 # Checks for typedefs, structures, and compiler characteristics.
334 AC_C_CONST
335 AC_C_INLINE
336 AC_STRUCT_TM
337
338 # Checks for library functions.
339 AC_FUNC_MALLOC
340 AC_FUNC_MEMCMP
341 AC_TYPE_SIGNAL
342 AC_FUNC_STAT
343 AC_FUNC_STRFTIME
344 AC_CHECK_FUNCS([bzero memset mkdir setlocale strchr])
345
346
347 # Generate po/LINGUAS on the fly rather than relying on translators
348 # to maintain it manually. This also overcome the problem that Transifex
349 # cannot add a language to po/LINGUAS if a new po file is submitted.
350 rm -f $srcdir/po/LINGUAS
351 for po_file in `ls $srcdir/po/*.po | sort`;
352 do
353     lang=`echo "$po_file" | sed "s|.*/po/\(.*\)\.po|\1|g"`
354     echo $lang >> $srcdir/po/LINGUAS
355 done
356
357 GETTEXT_PACKAGE=lxpanel
358 AM_GNU_GETTEXT([external])
359 AM_GNU_GETTEXT_VERSION(0.14.1)
360 AC_SUBST(GETTEXT_PACKAGE)
361 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
362
363 AM_GLIB_GNU_GETTEXT
364
365 if test x"$enable_man" = x"yes"; then
366         AC_PATH_PROG([XSLTPROC], [xsltproc])
367         if test -z "$XSLTPROC"; then
368                 enable_man=no
369         fi
370
371         dnl check for DocBook DTD and stylesheets in the local catalog.
372         JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
373                 [DocBook XML DTD V4.1.2], [], enable_man=no)
374         JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
375                 [DocBook XSL Stylesheets >= 1.70.1], [], enable_man=no)
376 fi
377
378 AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test "x$enable_man" != "xno")
379
380 AC_ARG_ENABLE(debug,
381     [AC_HELP_STRING([--enable-debug],
382         [enable debug support @<:@default=no@:>@])],
383     [enable_debug="${enableval}"],
384     [enable_debug=no]
385 )
386 if test "$enable_debug" = "yes"; then
387     # turn on debug and disable optimization
388     CPPFLAGS="$CPPFLAGS -DG_ENABLE_DEBUG -O0 -g"
389     case "$CC" in
390     gcc*)
391         CPPFLAGS="$CPPFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration"
392         ;;
393     *)
394         ;;
395     esac
396     dnl Be more strict on portability
397     #CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=700"
398 else
399     # turn off glib debug checks
400     CPPFLAGS="$CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
401 fi
402
403 AC_CONFIG_FILES([
404     lxpanel.pc
405     Makefile
406     src/Makefile
407     src/plugins/Makefile
408     src/plugins/netstatus/Makefile
409     src/plugins/netstat/Makefile
410     src/plugins/volume/Makefile
411     src/plugins/volumealsa/Makefile
412     src/plugins/cpu/Makefile
413     src/plugins/deskno/Makefile
414     src/plugins/batt/Makefile
415     src/plugins/kbled/Makefile
416     src/plugins/xkb/Makefile
417     src/plugins/thermal/Makefile
418     src/plugins/cpufreq/Makefile
419     src/plugins/monitors/Makefile
420     src/plugins/indicator/Makefile
421     src/plugins/weather/Makefile
422     po/Makefile.in
423     data/Makefile
424     data/default/panels/panel
425     data/two_panels/panels/top
426     data/two_panels/panels/bottom
427     man/Makefile
428 ])
429 AC_OUTPUT
430
431 echo
432 echo lxpanel ......................... : Version $VERSION
433 echo
434 echo Prefix........................... : $prefix
435 if test x$plugins_loading = xyes; then
436 echo Building dynamic plugins:
437     if test x"$plugin_netstatus" != x; then
438         AC_MSG_RESULT([    netstatus - Monitor networking status])
439     fi
440     if test x"$plugin_netstat" != x; then
441         AC_MSG_RESULT([    netstat - Monitor networking status])
442     fi
443     if test x"$plugin_volume" != x; then
444         AC_MSG_RESULT([    volume - Display and adjust volume of sound card for OSS])
445     fi
446     if test x"$plugin_volumealsa" != x; then
447         AC_MSG_RESULT([    volumealsa - Display and adjust volume of sound card for ALSA])
448     fi
449     if test x"$plugin_cpu" != x; then
450         AC_MSG_RESULT([    cpu - Display CPU loading])
451     fi
452     if test x"$plugin_deskno" != x; then
453         AC_MSG_RESULT([    deskno - Display desktop number])
454     fi
455     if test x"$plugin_batt" != x; then
456         AC_MSG_RESULT([    batt - Monitor battery status])
457     fi
458     if test x"$plugin_kbled" != x; then
459         AC_MSG_RESULT([    kbled - Indicator for CapsLock, NumLock, and ScrLock])
460     fi
461     if test x"$plugin_xkb" != x; then
462         AC_MSG_RESULT([    xkb - Keyboard layout handler])
463     fi
464     if test x"$plugin_thermal" != x; then
465         AC_MSG_RESULT([    thermal - Temperature monitor])
466     fi
467     if test x"$plugin_cpufreq" != x; then
468         AC_MSG_RESULT([    cpufreq - CpuFreq frontend])
469     fi
470     if test x"$plugin_monitors" != x; then
471         AC_MSG_RESULT([    monitors - Monitors for CPU & RAM])
472     fi
473     if test x"$plugin_indicator" != x; then
474         AC_MSG_RESULT([    indicator - Indicator support])
475     fi
476     if test x"$plugin_weather" != x; then
477         AC_MSG_RESULT([    weather - Weather conditions and forecast])
478     fi
479 else
480 echo Dynamic loader for plugins....... : disabled.
481 fi
482
483 echo
484 echo 'LXPanel requires menu-cache and lxmenu-data packages since'
485 echo 'version 0.4.0. Please make sure they are correctly installed.'
486 echo 'Otherwise, you will not be able to use applications menu.'
487 echo
488