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