Release 0.8.2.
[lxde/lxpanel.git] / configure.ac
1 AC_PREREQ(2.53)
2 AC_INIT(lxpanel, 0.8.2, 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 if test ! -z $plugin_volume; then
271     AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
272     if test x$ac_cv_header_sys_soundcard_h = xno && test x$ac_cv_header_linux_soundcard_h = xno; then
273         AC_MSG_RESULT([no OSS headers found!])
274         plugin_volume=
275     fi
276 fi
277
278 dnl Exclude indicator support when there is no support.
279 if test x"$indicator_support" = "xno"; then
280     plugin_indicator=
281 fi
282
283 PLUGINS_LIST="\
284     $plugin_netstatus \
285     $plugin_netstat \
286     $plugin_volume \
287     $plugin_volumealsa \
288     $plugin_cpu \
289     $plugin_deskno \
290     $plugin_batt \
291     $plugin_kbled \
292     $plugin_xkb \
293     $plugin_thermal \
294     $plugin_cpufreq \
295     $plugin_monitors \
296     $plugin_indicator \
297     $plugin_weather"
298
299 AC_SUBST(PLUGINS_LIST)
300
301 # Plugin-specific dependencies
302 # nestat
303 if test x"$plugin_netstat" != "x";then
304 AC_CHECK_HEADER([iwlib.h],,
305  AC_MSG_ERROR([netstat plugin requires wireless-tools-devel]))
306 fi
307
308 # weather
309 if test x"$plugin_weather" != "x";then
310 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
311 AC_SUBST(LIBXML2_CFLAGS)
312 AC_SUBST(LIBXML2_LIBS)
313 fi
314
315 # Checks for header files.
316 AC_PATH_X
317 AC_HEADER_STDC
318 AC_HEADER_SYS_WAIT
319 AC_CHECK_HEADERS([locale.h stdlib.h string.h sys/time.h unistd.h])
320
321 # Checks for typedefs, structures, and compiler characteristics.
322 AC_C_CONST
323 AC_C_INLINE
324 AC_STRUCT_TM
325
326 # Checks for library functions.
327 AC_FUNC_MALLOC
328 AC_FUNC_MEMCMP
329 AC_TYPE_SIGNAL
330 AC_FUNC_STAT
331 AC_FUNC_STRFTIME
332 AC_CHECK_FUNCS([bzero memset mkdir setlocale strchr])
333
334 dnl check for menu-cache versions 0.4.x since no macro MENU_CACHE_CHECK_VERSION
335 dnl is available in those versions
336 LIBS_save="${LIBS}"
337 LIBS="${LIBS} ${MENU_CACHE_LIBS}"
338 AC_CHECK_FUNCS(menu_cache_dir_list_children)
339 LIBS="${LIBS_save}"
340
341 # Generate po/LINGUAS on the fly rather than relying on translators
342 # to maintain it manually. This also overcome the problem that Transifex
343 # cannot add a language to po/LINGUAS if a new po file is submitted.
344 rm -f $srcdir/po/LINGUAS
345 for po_file in `ls $srcdir/po/*.po | sort`;
346 do
347     lang=`echo "$po_file" | sed "s|.*/po/\(.*\)\.po|\1|g"`
348     echo $lang >> $srcdir/po/LINGUAS
349 done
350
351 GETTEXT_PACKAGE=lxpanel
352 AC_SUBST(GETTEXT_PACKAGE)
353 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
354
355 AM_GLIB_GNU_GETTEXT
356
357 AC_ARG_ENABLE(debug,
358     [AC_HELP_STRING([--enable-debug],
359         [enable debug support @<:@default=no@:>@])],
360     [enable_debug="${enableval}"],
361     [enable_debug=no]
362 )
363 if test "$enable_debug" = "yes"; then
364     # turn on debug and disable optimization
365     CPPFLAGS="$CPPFLAGS -DG_ENABLE_DEBUG -O0 -g"
366     case "$CC" in
367     gcc*)
368         CPPFLAGS="$CPPFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration"
369         ;;
370     *)
371         ;;
372     esac
373     dnl Be more strict on portability
374     #CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=700"
375 else
376     # turn off glib debug checks
377     CPPFLAGS="$CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
378 fi
379
380 dnl Make version subfields for LXPANEL_CHECK_VERSION macro
381 ac_version_subst_str=`echo $VERSION | awk -F '.' '/.*/ { printf "VERSION_MAJOR=%d VERSION_MINOR=%d VERSION_MICRO=%d", $1, $2, $3 }'`
382 eval ${ac_version_subst_str}
383 AC_SUBST(VERSION_MAJOR)
384 AC_SUBST(VERSION_MINOR)
385 AC_SUBST(VERSION_MICRO)
386
387 dnl Fix invalid sysconfdir when --prefix=/usr
388 if test `eval "echo $sysconfdir"` = /usr/etc
389 then
390     sysconfdir=/etc
391 fi
392
393 AC_CONFIG_FILES([
394     lxpanel.pc
395     Makefile
396     src/Makefile
397     src/panel.h
398     plugins/Makefile
399     po/Makefile.in
400     data/Makefile
401     data/default/panels/panel
402     data/two_panels/panels/top
403     data/two_panels/panels/bottom
404     man/Makefile
405 ])
406 AC_OUTPUT
407
408 echo
409 echo lxpanel ......................... : Version $VERSION
410 echo
411 echo Prefix........................... : $prefix
412 echo System config directory.......... : `eval "echo $sysconfdir"`
413 echo
414
415 if test x$plugins_loading = xyes; then
416 echo Building dynamic plugins:
417     if test x"$plugin_netstatus" != x; then
418         AC_MSG_RESULT([    netstatus - Monitor networking status])
419     fi
420     if test x"$plugin_netstat" != x; then
421         AC_MSG_RESULT([    netstat - Monitor networking status])
422     fi
423     if test x"$plugin_volume" != x; then
424         AC_MSG_RESULT([    volume - Display and adjust volume of sound card for OSS])
425     fi
426     if test x"$plugin_volumealsa" != x; then
427         AC_MSG_RESULT([    volumealsa - Display and adjust volume of sound card for ALSA])
428     fi
429     if test x"$plugin_cpu" != x; then
430         AC_MSG_RESULT([    cpu - Display CPU loading])
431     fi
432     if test x"$plugin_deskno" != x; then
433         AC_MSG_RESULT([    deskno - Display desktop number])
434     fi
435     if test x"$plugin_batt" != x; then
436         AC_MSG_RESULT([    batt - Monitor battery status])
437     fi
438     if test x"$plugin_kbled" != x; then
439         AC_MSG_RESULT([    kbled - Indicator for CapsLock, NumLock, and ScrLock])
440     fi
441     if test x"$plugin_xkb" != x; then
442         AC_MSG_RESULT([    xkb - Keyboard layout handler])
443     fi
444     if test x"$plugin_thermal" != x; then
445         AC_MSG_RESULT([    thermal - Temperature monitor])
446     fi
447     if test x"$plugin_cpufreq" != x; then
448         AC_MSG_RESULT([    cpufreq - CpuFreq frontend])
449     fi
450     if test x"$plugin_monitors" != x; then
451         AC_MSG_RESULT([    monitors - Monitors for CPU & RAM])
452     fi
453     if test x"$plugin_indicator" != x; then
454         AC_MSG_RESULT([    indicator - Indicator support])
455     fi
456     if test x"$plugin_weather" != x; then
457         AC_MSG_RESULT([    weather - Weather conditions and forecast])
458     fi
459 else
460 echo Dynamic loader for plugins....... : disabled.
461 fi
462
463 if test x"$sysconfdir" != x'/etc'; then
464     echo
465     echo 'Warning: sysconfdir is not /etc. It might be not what you want.'
466     echo 'Please consider passing --sysconfdir=/etc to configure.'
467 fi
468
469 echo
470 echo 'LXPanel requires menu-cache and lxmenu-data packages since'
471 echo 'version 0.4.0. Please make sure they are correctly installed.'
472 echo 'Otherwise, you will not be able to use applications menu.'
473 echo
474