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