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