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