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