Allow -Wl,-z,defs to work - create a liblxpanel.so.0.0.0
[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   CFLAGS="$CFLAGS -DENABLE_GTK3"
38   pkg_modules="$pkg_modules gtk+-3.0 libfm-gtk3 >= 1.2.0 libwnck-3.0"
39 else
40   pkg_modules="$pkg_modules gtk+-2.0 >= 2.18.0 libfm-gtk >= 1.2.0 libwnck-1.0"
41 fi
42
43 pkg_modules="$pkg_modules \
44              gio-unix-2.0 \
45              gthread-2.0 \
46              gmodule-2.0"
47 PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
48 AC_SUBST(PACKAGE_CFLAGS)
49 AC_SUBST(PACKAGE_LIBS)
50
51 ###########################
52 # Indicator Info
53 ###########################
54 AC_ARG_ENABLE([indicator_support],
55     AS_HELP_STRING([--enable-indicator-support],
56                [enable plugin loading (default: disable)]),
57                indicator_support=$enableval, indicator_support="no")
58 AM_CONDITIONAL(ENABLE_INDICATOR_SUPPORT, test x"$indicator_support" = x"yes")
59
60 if test "$indicator_support" != "no"; then
61         INDICATOR_REQUIRED_VERSION=0.3.0
62         INDICATOR_PKG_NAME=indicator-0.4
63
64         PKG_CHECK_MODULES(APPLET, $INDICATOR_PKG_NAME >= $INDICATOR_REQUIRED_VERSION)
65         AC_SUBST(APPLET_CFLAGS)
66
67         if test "x$with_localinstall" = "xyes"; then
68                 INDICATORDIR="${libdir}/indicators/2/"
69                 INDICATORICONSDIR="${datadir}/indicator-applet/icons/"
70         else
71                 INDICATORDIR=`$PKG_CONFIG --variable=indicatordir $INDICATOR_PKG_NAME`
72                 INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir $INDICATOR_PKG_NAME`
73 fi
74         AC_SUBST(INDICATORDIR)
75         AC_SUBST(INDICATORICONSDIR)
76 fi
77
78
79 pkg_modules="x11"
80 PKG_CHECK_MODULES(X11, [$pkg_modules])
81 AC_SUBST(X11_LIBS)
82
83 pkg_modules="libmenu-cache"
84 PKG_CHECK_MODULES(MENU_CACHE, [$pkg_modules],
85                   enable_menu_cache=yes, enable_menu_cache=no)
86 if test x"$enable_menu_cache" = "xno"; then
87         AC_WARN([No libmenu-cache found.  All menu related routines are not built.])
88         AC_DEFINE(DISABLE_MENU, [1], [Disable menu related routines])
89 fi
90 AC_SUBST(MENU_CACHE_CFLAGS)
91 AC_SUBST(MENU_CACHE_LIBS)
92 AM_CONDITIONAL(ENABLE_MENU_CACHE, test x"$enable_menu_cache" = x"yes")
93
94 AC_ARG_ENABLE(more_warnings,
95        [AC_HELP_STRING([--enable-more-warnings],
96                [Add more warnings @<:@default=no@:>@])],
97        [enable_more_warnings="${enableval}"],
98        [enable_more_warnings=no]
99 )
100
101 if test x"$enable_more_warnings" = x"yes"; then
102   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"
103 fi
104 AC_SUBST(ADDITIONAL_FLAGS)
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 dnl FIXME: filter for undefined symbols in plugins
160 # when passing "-z defs" to linker, we would better to make sure
161 # there are no undefined references.  However, we intend not to
162 # fix at the moment since we don't have spin-off libraray containing
163 # the necessary functions.
164
165 AC_ARG_ENABLE([alsa],
166     AS_HELP_STRING([--disable-alsa],
167                     [compile ALSA providers (default: enable)]),
168             compile_alsa=$enableval, compile_alsa="yes")
169 if test x"$compile_alsa" = "xyes"; then
170     AC_CHECK_HEADERS([alsa/asoundlib.h],
171                      [AC_CHECK_LIB([asound],
172                                    [snd_seq_open],
173                                    compile_alsa=yes,compile_alsa=no)],
174                           compile_alsa=no)
175 fi
176 AM_CONDITIONAL(BUILD_ALSA_PLUGINS, test x$compile_alsa = xyes)
177 dnl FIXME: check OSS existence
178 AM_CONDITIONAL(BUILD_OSS_PLUGINS, test x$compile_alsa = xno)
179
180 AC_ARG_ENABLE([plugins-loading],
181     AS_HELP_STRING([--disable-plugins-loading],
182                [disable plugin loading (default: enable)]),
183                plugins_loading=$enableval, plugins_loading="yes")
184
185 AM_CONDITIONAL(BUILD_PLUGIN_LOADER, test x$plugins_loading = xyes)
186
187 if test x"$plugins_loading" = "xno"; then
188     AC_DEFINE(DISABLE_PLUGINS_LOADING, [1], [Disable plugin loading])
189 fi
190
191 dnl Here are plugin listing.
192 plugin_netstatus=
193 plugin_netstat=
194 plugin_volume=
195 plugin_volumealsa=
196 plugin_cpu=
197 plugin_deskno=
198 plugin_batt=
199 plugin_xkb=
200 plugin_kbled=
201 plugin_thermal=
202 plugin_cpufreq=
203 plugin_monitors=
204 plugin_indicator=
205
206 AC_MSG_CHECKING([which plugins should be built dynamically])
207 AC_ARG_WITH(plugins,
208 [  --with-plugins=<list>  compile dynamic plugins in <list> ]
209 [                         plugins may be comma separated ]
210 [                         'all' builds all plugins (default), 'none' builds none ]
211 [                         plugins prefixed with '-' are not built]
212 [                         Possible plugins are: ]
213 [                         netstatus, netstat, volume, volumealsa, cpu, deskno, batt,]
214 [                         kbled, xkb, thermal, cpufreq, monitors, indicator, weather]
215 , plugins="$withval",[plugins="all"])
216
217 if test x"$plugins" != xall -a x"$plugins" != xnone; then
218     if test x"$plugins_loading" = xno; then
219         AC_MSG_ERROR(
220         [--disable-plugins-loading and --with-plugins conflict each other.])
221     fi
222 fi
223
224 ALL_PLUGINS_LIST="netstatus netstat volume volumealsa cpu deskno batt kbled xkb thermal cpufreq monitors indicator weather"
225 AC_SUBST(ALL_PLUGINS_LIST)
226
227 AC_DEFUN([check_plugin_name],[
228     plugin_found=false
229     for name in $ALL_PLUGINS_LIST; do
230         if test x[$1] = x[$name]; then
231             plugin_found=true
232         fi
233     done
234     if test x[$plugin_found] = false; then
235         echo [Unknown plugin $1.]
236         exit 1
237     fi
238 ])
239
240 if test "$plugins" != "none"; then
241     plugins=`echo $plugins | sed 's/,/ /g'`
242     for plugin in $plugins
243     do
244         case "$plugin" in
245             all)
246                 for name in $ALL_PLUGINS_LIST
247                 do
248                     export plugin_$name="$name.la"
249                 done
250                 ;;
251             -*)
252                 check_plugin_name([${plugin#-}])
253                 export plugin_${plugin#-}=
254                 ;;
255             *)
256                 check_plugin_name([$plugin])
257                 export plugin_$plugin=$plugin.la
258                 ;;
259         esac
260     done
261     AC_MSG_RESULT($plugins)
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
275 dnl Exclude indicator support when there is no support.
276 if test x"$indicator_support" = "xno"; then
277     plugin_indicator=
278 fi
279
280 PLUGINS_LIST="\
281     $plugin_netstatus \
282     $plugin_netstat \
283     $plugin_volume \
284     $plugin_volumealsa \
285     $plugin_cpu \
286     $plugin_deskno \
287     $plugin_batt \
288     $plugin_kbled \
289     $plugin_xkb \
290     $plugin_thermal \
291     $plugin_cpufreq \
292     $plugin_monitors \
293     $plugin_indicator \
294     $plugin_weather"
295
296 AC_SUBST(PLUGINS_LIST)
297
298 # Plugin-specific dependencies
299 # nestat
300 if test x"$plugin_netstat" != "x";then
301 AC_CHECK_HEADER([iwlib.h],,
302  AC_MSG_ERROR([netstat plugin requires wireless-tools-devel]))
303 fi
304
305 # weather
306 if test x"$plugin_weather" != "x";then
307 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
308 AC_SUBST(LIBXML2_CFLAGS)
309 AC_SUBST(LIBXML2_LIBS)
310 fi
311
312 # Checks for header files.
313 AC_PATH_X
314 AC_HEADER_STDC
315 AC_HEADER_SYS_WAIT
316 AC_CHECK_HEADERS([locale.h stdlib.h string.h sys/time.h unistd.h])
317
318 # Checks for typedefs, structures, and compiler characteristics.
319 AC_C_CONST
320 AC_C_INLINE
321 AC_STRUCT_TM
322
323 # Checks for library functions.
324 AC_FUNC_MALLOC
325 AC_FUNC_MEMCMP
326 AC_TYPE_SIGNAL
327 AC_FUNC_STAT
328 AC_FUNC_STRFTIME
329 AC_CHECK_FUNCS([bzero memset mkdir setlocale strchr])
330
331 dnl check for menu-cache versions 0.4.x since no macro MENU_CACHE_CHECK_VERSION
332 dnl is available in those versions
333 LIBS_save="${LIBS}"
334 LIBS="${LIBS} ${MENU_CACHE_LIBS}"
335 AC_CHECK_FUNCS(menu_cache_dir_list_children)
336 LIBS="${LIBS_save}"
337
338 # Generate po/LINGUAS on the fly rather than relying on translators
339 # to maintain it manually. This also overcome the problem that Transifex
340 # cannot add a language to po/LINGUAS if a new po file is submitted.
341 rm -f $srcdir/po/LINGUAS
342 for po_file in `ls $srcdir/po/*.po | sort`;
343 do
344     lang=`echo "$po_file" | sed "s|.*/po/\(.*\)\.po|\1|g"`
345     echo $lang >> $srcdir/po/LINGUAS
346 done
347
348 GETTEXT_PACKAGE=lxpanel
349 AC_SUBST(GETTEXT_PACKAGE)
350 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
351
352 AM_GLIB_GNU_GETTEXT
353
354 AC_ARG_ENABLE(debug,
355     [AC_HELP_STRING([--enable-debug],
356         [enable debug support @<:@default=no@:>@])],
357     [enable_debug="${enableval}"],
358     [enable_debug=no]
359 )
360 if test "$enable_debug" = "yes"; then
361     # turn on debug and disable optimization
362     CPPFLAGS="$CPPFLAGS -DG_ENABLE_DEBUG -O0 -g"
363     case "$CC" in
364     gcc*)
365         CPPFLAGS="$CPPFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration"
366         ;;
367     *)
368         ;;
369     esac
370     dnl Be more strict on portability
371     #CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=700"
372 else
373     # turn off glib debug checks
374     CPPFLAGS="$CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
375 fi
376
377 dnl Fix invalid sysconfdir when --prefix=/usr
378 if test `eval "echo $sysconfdir"` = /usr/etc
379 then
380     sysconfdir=/etc
381 fi
382
383 AC_CONFIG_FILES([
384     lxpanel.pc
385     Makefile
386     src/Makefile
387     plugins/Makefile
388     po/Makefile.in
389     data/Makefile
390     data/default/panels/panel
391     data/two_panels/panels/top
392     data/two_panels/panels/bottom
393     man/Makefile
394 ])
395 AC_OUTPUT
396
397 echo
398 echo lxpanel ......................... : Version $VERSION
399 echo
400 echo Prefix........................... : $prefix
401 echo System config directory.......... : `eval "echo $sysconfdir"`
402 echo
403
404 if test x$plugins_loading = xyes; then
405 echo Building dynamic plugins:
406     if test x"$plugin_netstatus" != x; then
407         AC_MSG_RESULT([    netstatus - Monitor networking status])
408     fi
409     if test x"$plugin_netstat" != x; then
410         AC_MSG_RESULT([    netstat - Monitor networking status])
411     fi
412     if test x"$plugin_volume" != x; then
413         AC_MSG_RESULT([    volume - Display and adjust volume of sound card for OSS])
414     fi
415     if test x"$plugin_volumealsa" != x; then
416         AC_MSG_RESULT([    volumealsa - Display and adjust volume of sound card for ALSA])
417     fi
418     if test x"$plugin_cpu" != x; then
419         AC_MSG_RESULT([    cpu - Display CPU loading])
420     fi
421     if test x"$plugin_deskno" != x; then
422         AC_MSG_RESULT([    deskno - Display desktop number])
423     fi
424     if test x"$plugin_batt" != x; then
425         AC_MSG_RESULT([    batt - Monitor battery status])
426     fi
427     if test x"$plugin_kbled" != x; then
428         AC_MSG_RESULT([    kbled - Indicator for CapsLock, NumLock, and ScrLock])
429     fi
430     if test x"$plugin_xkb" != x; then
431         AC_MSG_RESULT([    xkb - Keyboard layout handler])
432     fi
433     if test x"$plugin_thermal" != x; then
434         AC_MSG_RESULT([    thermal - Temperature monitor])
435     fi
436     if test x"$plugin_cpufreq" != x; then
437         AC_MSG_RESULT([    cpufreq - CpuFreq frontend])
438     fi
439     if test x"$plugin_monitors" != x; then
440         AC_MSG_RESULT([    monitors - Monitors for CPU & RAM])
441     fi
442     if test x"$plugin_indicator" != x; then
443         AC_MSG_RESULT([    indicator - Indicator support])
444     fi
445     if test x"$plugin_weather" != x; then
446         AC_MSG_RESULT([    weather - Weather conditions and forecast])
447     fi
448 else
449 echo Dynamic loader for plugins....... : disabled.
450 fi
451
452 if test x"$sysconfdir" != x'/etc'; then
453     echo
454     echo 'Warning: sysconfdir is not /etc. It might be not what you want.'
455     echo 'Please consider passing --sysconfdir=/etc to configure.'
456 fi
457
458 echo
459 echo 'LXPanel requires menu-cache and lxmenu-data packages since'
460 echo 'version 0.4.0. Please make sure they are correctly installed.'
461 echo 'Otherwise, you will not be able to use applications menu.'
462 echo
463