enable configure to use gtk3
[lxde/lxpanel.git] / configure.ac
1 AC_PREREQ(2.53)
2 AC_INIT(lxpanel, 0.5.7, http://lxde.org/)
3 AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign])
4 AC_CONFIG_HEADER([config.h])
5
6 # Support silent build rules. Disable by either passing --disable-silent-rules
7 # to configure or passing V=1 to make
8 AM_SILENT_RULES([yes])
9
10 # Force to dynamic
11 AC_DISABLE_STATIC
12
13 # Checks for programs.
14 AC_PROG_CC
15 AC_PROG_INSTALL
16 AC_PROG_LN_S
17 AC_PROG_INTLTOOL(, [no-xml])
18 AM_PROG_CC_C_O
19
20 #Initialize libtool
21 LT_PREREQ([2.2])
22 LT_INIT
23
24 # Checks for libraries.
25 AC_ARG_ENABLE(gtk3,
26 AC_HELP_STRING([--enable-gtk3],[enable to use gtk-3.0 instead of gtk-2.0]),
27 [case "${enableval}" in
28   yes)  enable_gtk3=yes ;;
29   no)   enable_gtk3=no ;;
30   *) AC_MSG_ERROR([bad value "${enableval}" for --enable-gtk3, use "yes" (default) or "no".]) ;;
31 esac],[])
32
33 if test "x$enable_gtk3" = "xyes" ; then
34   CFLAGS="$CFLAGS -DENABLE_GTK3"
35   pkg_modules="$pkg_modules gtk+-3.0"
36 else
37   pkg_modules="$pkg_modules gtk+-2.0 >= 2.12.0"
38 fi
39
40 pkg_modules="$pkg_modules \
41              gio-unix-2.0 \
42              gthread-2.0"
43 #             libstartup-notification-1.0"
44 PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
45 AC_SUBST(PACKAGE_CFLAGS)
46 AC_SUBST(PACKAGE_LIBS)
47
48 pkg_modules="x11"
49 PKG_CHECK_MODULES(X11, [$pkg_modules])
50 AC_SUBST(X11_LIBS)
51
52 pkg_modules="libmenu-cache"
53 PKG_CHECK_MODULES(MENU_CACHE, [$pkg_modules],
54                   enable_menu_cache=yes, enable_menu_cache=no)
55 if test x"$enable_menu_cache" = "xno"; then
56         AC_WARN([No libmenu-cache found.  All menu related routines are not built.])
57         AC_DEFINE(DISABLE_MENU, [1], [Disable menu related routines])
58 fi
59 AC_SUBST(MENU_CACHE_CFLAGS)
60 AC_SUBST(MENU_CACHE_LIBS)
61 AM_CONDITIONAL(ENABLE_MENU_CACHE, test x"$enable_menu_cache" = x"yes")
62
63 AC_ARG_ENABLE(more_warnings,
64        [AC_HELP_STRING([--enable-more-warnings],
65                [Add more warnings @<:@default=no@:>@])],
66        [enable_more_warnings="${enableval}"],
67        [enable_more_warnings=no]
68 )
69
70 if test x"$enable_more_warnings" = x"yes"; then
71   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"
72 fi
73 AC_SUBST(ADDITIONAL_FLAGS)
74
75 PACKAGE_CFLAGS="$PACKAGE_CFLAGS $MENU_CACHE_CFLAGS $ADDITIONAL_FLAGS"
76 PACKAGE_LIBS="$PACKAGE_LIBS $MENU_CACHE_LIBS"
77
78 AC_ARG_ENABLE(man,
79         [AC_HELP_STRING([--enable-man],
80                 [regenerate roff man pages from Docbook @<:@default=no@:>@])],
81         [enable_man="${enableval}"],
82         [enable_man=no]
83 )
84
85 AC_ARG_ENABLE([cast-checks],
86     AS_HELP_STRING([--enable-cast-checks],
87                [enable Glib casting checks (default: disable)]),
88                cast_checks=$enableval, cast_checks="no")
89 G_CAST_CHECKS=""
90 if test x"$cast_checks" = "xno"; then
91     G_CAST_CHECKS="-DG_DISABLE_CAST_CHECKS"
92 fi
93 AC_SUBST(G_CAST_CHECKS)
94
95 dnl linker tweaking
96 # The function of the link flag --as-needed is to prevent unnecesary linking.
97 # Example: A -> B -> C
98 # Normally, A would link to B and also depend on C, this is of cource
99 # unnecesary. In this situation, however we do need to link to C, so this
100 # must be done explicitly. This flag comes in handy when a library ABI
101 # is changed, minimizing the amount of recompilations needed.
102 AC_MSG_CHECKING([whether $LD accepts --as-needed])
103 case `$LD --as-needed -v 2>&1 </dev/null` in
104 *GNU* | *'with BFD'*)
105     LDFLAGS="$LDFLAGS -Wl,--as-needed"
106     AC_MSG_RESULT([yes])
107     ;;
108 *)
109     AC_MSG_RESULT([no])
110     ;;
111 esac
112
113 dnl linker optimizations
114 AC_MSG_CHECKING([whether $LD accepts -O1])
115 case `$LD -O1 -v 2>&1 </dev/null` in
116 *GNU* | *'with BFD'*)
117   LDFLAGS="$LDFLAGS -Wl,-O1"
118   AC_MSG_RESULT([yes])
119   ;;
120 *)
121   AC_MSG_RESULT([no])
122   ;;
123 esac
124 AC_MSG_CHECKING([whether $LD accepts -Bsymbolic-functions])
125 case `$LD -Bsymbolic-functions -v 2>&1 </dev/null` in
126 *GNU* | *'with BFD'*)
127   LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
128   AC_MSG_RESULT([yes])
129   ;;
130 *)
131   AC_MSG_RESULT([no])
132   ;;
133 esac
134 AC_MSG_CHECKING([whether $LD accepts --sort-common])
135 case `$LD --sort-common -v 2>&1 </dev/null` in
136 *GNU* | *'with BFD'*)
137   LDFLAGS="$LDFLAGS -Wl,--sort-common"
138   AC_MSG_RESULT([yes])
139   ;;
140 *)
141   AC_MSG_RESULT([no])
142   ;;
143 esac
144
145 dnl FIXME: filter for undefined symbols in plugins
146 # when passing "-z defs" to linker, we would better to make sure
147 # there are no undefined references.  However, we intend not to
148 # fix at the moment since we don't have spin-off libraray containing
149 # the necessary functions.
150 if test ! -z "$LDFLAGS"; then
151     LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-Wl,-z,defs//'`
152 fi
153
154 LXPANEL_MODULE="-avoid-version \
155 -rpath \$(libdir)/lxpanel/plugins \
156 -no-undefined "'-export-symbols-regex "^[[^_]].*"'
157 AC_SUBST(LXPANEL_MODULE)
158
159 AC_ARG_ENABLE([alsa],
160     AS_HELP_STRING([--disable-alsa],
161                     [compile ALSA providers (default: enable)]),
162             compile_alsa=$enableval, compile_alsa="yes")
163 if test x"$compile_alsa" = "xyes"; then
164     AC_CHECK_HEADERS([alsa/asoundlib.h],
165                      [AC_CHECK_LIB([asound],
166                                    [snd_seq_open],
167                                    compile_alsa=yes,compile_alsa=no)],
168                           compile_alsa=no)
169 fi
170 AM_CONDITIONAL(BUILD_ALSA_PLUGINS, test x$compile_alsa = xyes)
171 dnl FIXME: check OSS existence
172 AM_CONDITIONAL(BUILD_OSS_PLUGINS, test x$compile_alsa = xno)
173
174 AC_ARG_ENABLE([plugins-loading],
175     AS_HELP_STRING([--disable-plugins-loading],
176                [disable plugin loading (default: enable)]),
177                plugins_loading=$enableval, plugins_loading="yes")
178
179 AM_CONDITIONAL(BUILD_PLUGIN_LOADER, test x$plugins_loading = xyes)
180
181 if test x"$plugins_loading" = "xno"; then
182     AC_DEFINE(DISABLE_PLUGINS_LOADING, [1], [Disable plugin loading])
183 fi
184
185 dnl Here are plugin listing.
186 plugin_netstatus=
187 plugin_volume=
188 plugin_volumealsa=
189 plugin_cpu=
190 plugin_deskno=
191 plugin_batt=
192 plugin_xkb=
193 plugin_kbled=
194 plugin_thermal=
195 plugin_cpufreq=
196
197 AC_MSG_CHECKING([which plugins should be built dynamically])
198 AC_ARG_WITH(plugins,
199 [  --with-plugins=<list>  compile dynamic plugins in <list> ]
200 [                         plugins may be comma separated ]
201 [                         'all' builds all plugins (default), 'none' builds none ]
202 [                         Possible plugins are: ]
203 [                         netstatus, volume, volumealsa, cpu, deskno, batt, kbled, xkb, thermal, cpufreq], plugins="$withval",[plugins="all"])
204
205 if test x"$plugins" != xall -a x"$plugins" != xnone; then
206     if test x"$plugins_loading" = xno; then
207         AC_MSG_ERROR(
208         [--disable-plugins-loading and --with-plugins conflict each other.])
209     fi
210 fi
211
212 ALL_PLUGINS_LIST="netstatus volume volumealsa cpu deskno batt kbled xkb thermal cpufreq"
213 AC_SUBST(ALL_PLUGINS_LIST)
214
215 if test x"$plugins" = xall; then
216 dnl    for name in $ALL_PLUGINS
217 dnl    do
218 dnl        export plugin_$name="$name"
219 dnl    done
220
221     plugin_netstatus=netstatus
222     plugin_volume=volume
223     plugin_volumealsa=volumealsa
224     plugin_cpu=cpu
225     plugin_deskno=deskno
226     plugin_batt=batt
227     plugin_kbled=kbled
228     plugin_xkb=xkb
229     plugin_thermal=thermal
230     plugin_cpufreq=cpufreq
231
232     AC_MSG_RESULT(all)
233 else
234     if test "$plugins" != "none"; then
235         plugins=`echo $plugins | sed 's/,/ /g'`
236         for plugin in $plugins
237         do
238         case "$plugin" in
239             netstatus)
240                 plugin_netstatus=netstatus
241                 ;;
242             volume)
243                 plugin_volume=volume
244                 ;;
245             volumealsa)
246                 plugin_volumealsa=volumealsa
247                 ;;
248             cpu)
249                 plugin_cpu=cpu
250                 ;;
251             deskno)
252                 plugin_deskno=deskno
253                 ;;
254             batt)
255                 plugin_batt=batt
256                 ;;
257             kbled)
258                 plugin_kbled=kbled
259                 ;;
260             xkb)
261                 plugin_xkb=xkb
262                 ;;
263             thermal)
264                 plugin_thermal=thermal
265                 ;;
266             cpufreq)
267                 plugin_cpufreq=cpufreq
268                 ;;
269             *)
270                 echo "Unknown plugin $plugin."
271                 exit 1
272                 ;;
273         esac
274         done
275         AC_MSG_RESULT($plugins)
276     fi
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 PLUGINS_LIST="\
290     $plugin_netstatus \
291     $plugin_volume \
292     $plugin_volumealsa \
293     $plugin_cpu \
294     $plugin_deskno \
295     $plugin_batt \
296     $plugin_kbled \
297     $plugin_xkb \
298     $plugin_thermal \
299     $plugin_cpufreq"
300
301 AC_SUBST(PLUGINS_LIST)
302
303
304 # Checks for header files.
305 AC_PATH_X
306 AC_HEADER_STDC
307 AC_HEADER_SYS_WAIT
308 AC_CHECK_HEADERS([locale.h stdlib.h string.h sys/time.h unistd.h])
309
310 # Checks for typedefs, structures, and compiler characteristics.
311 AC_C_CONST
312 AC_C_INLINE
313 AC_STRUCT_TM
314
315 # Checks for library functions.
316 AC_FUNC_MALLOC
317 AC_FUNC_MEMCMP
318 AC_TYPE_SIGNAL
319 AC_FUNC_STAT
320 AC_FUNC_STRFTIME
321 AC_CHECK_FUNCS([bzero memset mkdir setlocale strchr])
322
323
324 # Generate po/LINGUAS on the fly rather than relying on translators
325 # to maintain it manually. This also overcome the problem that Transifex
326 # cannot add a language to po/LINGUAS if a new po file is submitted.
327 rm -f $srcdir/po/LINGUAS
328 for po_file in `ls $srcdir/po/*.po | sort`;
329 do
330     lang=`echo "$po_file" | sed "s|.*/po/\(.*\)\.po|\1|g"`
331     echo $lang >> $srcdir/po/LINGUAS
332 done
333
334 GETTEXT_PACKAGE=lxpanel
335 #AM_GNU_GETTEXT([external])
336 AM_GNU_GETTEXT_VERSION(0.14.1)
337 AC_SUBST(GETTEXT_PACKAGE)
338 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
339
340 AM_GLIB_GNU_GETTEXT
341
342 if test x"$enable_man" = x"yes"; then
343         AC_PATH_PROG([XSLTPROC], [xsltproc])
344         if test -z "$XSLTPROC"; then
345                 enable_man=no
346         fi
347
348         dnl check for DocBook DTD and stylesheets in the local catalog.
349         JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
350                 [DocBook XML DTD V4.1.2], [], enable_man=no)
351         JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
352                 [DocBook XSL Stylesheets >= 1.70.1], [], enable_man=no)
353 fi
354
355 AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test "x$enable_man" != "xno")
356
357 AC_CONFIG_FILES([
358     lxpanel.pc
359     Makefile
360     src/Makefile
361     src/plugins/Makefile
362     src/plugins/netstatus/Makefile
363     src/plugins/volume/Makefile
364     src/plugins/volumealsa/Makefile
365     src/plugins/cpu/Makefile
366     src/plugins/deskno/Makefile
367     src/plugins/batt/Makefile
368     src/plugins/kbled/Makefile
369     src/plugins/xkb/Makefile
370     src/plugins/thermal/Makefile
371     src/plugins/cpufreq/Makefile
372     po/Makefile.in
373     data/Makefile
374     data/default/panels/panel
375     man/Makefile
376 ])
377 AC_OUTPUT
378
379 echo
380 echo lxpanel ......................... : Version $VERSION
381 echo
382 echo Prefix........................... : $prefix
383 if test x$plugins_loading = xyes; then
384 echo Building dynamic plugins:
385     if test x"$plugin_netstatus" != x; then
386         AC_MSG_RESULT([    netstatus - Monitor networking status])
387     fi
388     if test x"$plugin_volume" != x; then
389         AC_MSG_RESULT([    volume - Display and adjust volume of sound card for OSS])
390     fi
391     if test x"$plugin_volumealsa" != x; then
392         AC_MSG_RESULT([    volumealsa - Display and adjust volume of sound card for ALSA])
393     fi
394     if test x"$plugin_cpu" != x; then
395         AC_MSG_RESULT([    cpu - Display CPU loading])
396     fi
397     if test x"$plugin_deskno" != x; then
398         AC_MSG_RESULT([    deskno - Display desktop number])
399     fi
400     if test x"$plugin_batt" != x; then
401         AC_MSG_RESULT([    batt - Monitor battery status])
402     fi
403     if test x"$plugin_kbled" != x; then
404         AC_MSG_RESULT([    kbled - Indicator for CapsLock, NumLock, and ScrLock])
405     fi
406     if test x"$plugin_xkb" != x; then
407         AC_MSG_RESULT([    xkb - Keyboard layout switcher])
408     fi
409     if test x"$plugin_thermal" != x; then
410         AC_MSG_RESULT([    thermal - Temperature monitor])
411     fi
412     if test x"$plugin_cpufreq" != x; then
413         AC_MSG_RESULT([    cpufreq - CpuFreq frontend])
414     fi
415 else
416 echo Dynamic loader for plugins....... : disabled.
417 fi
418
419 echo
420 echo 'LXPanel requires menu-cache and lxmenu-data packages since'
421 echo 'version 0.4.0. Please make sure they are correctly installed.'
422 echo 'Otherwise, you will not be able to use applications menu.'
423 echo
424