export headers and pkg-config for plugin development.
[lxde/lxpanel.git] / configure.ac
1 AC_PREREQ(2.53)
2 AC_INIT(lxpanel, 0.3.8.1, http://lxde.org/)
3 AM_INIT_AUTOMAKE
4 AC_CONFIG_SRCDIR([src/bg.c])
5 AC_CONFIG_HEADER([config.h])
6
7 # Force to dynamic
8 AC_DISABLE_STATIC
9
10 # Checks for programs.
11 AC_PROG_CC
12 AC_PROG_INSTALL
13 AC_PROG_LN_S
14 AC_PROG_LIBTOOL
15 AC_PROG_INTLTOOL(, [no-xml])
16
17 # Checks for libraries.
18 pkg_modules="gtk+-2.0 >= 2.12.0 \
19              gthread-2.0 \
20              libmenu-cache"
21 #             libstartup-notification-1.0"
22 PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
23 AC_SUBST(PACKAGE_CFLAGS)
24 AC_SUBST(PACKAGE_LIBS)
25
26 # Gtk Builder
27 #AC_PATH_PROG([GTK_BUILDER_CONVERT],[gtk-builder-convert],[false])
28 #if test "$GTK_BUILDER_CONVERT" = "false"; then
29 #  AC_MSG_ERROR([gtk-builder-convert not found])
30 #fi
31
32 AC_ARG_ENABLE([cast-checks],
33     AS_HELP_STRING([--enable-cast-checks],
34                [enable Glib casting checks (default: disable)]),
35                cast_checks=$enableval, cast_checks="no")
36 G_CAST_CHECKS=""
37 if test x"$cast_checks" = "xno"; then
38     G_CAST_CHECKS="-DG_DISABLE_CAST_CHECKS"
39 fi
40 AC_SUBST(G_CAST_CHECKS)
41
42 dnl linker tweaking
43 # The function of the link flag --as-needed is to prevent unnecesary linking.
44 # Example: A -> B -> C
45 # Normally, A would link to B and also depend on C, this is of cource
46 # unnecesary. In this situation, however we do need to link to C, so this
47 # must be done explicitly. This flag comes in handy when a library ABI
48 # is changed, minimizing the amount of recompilations needed.
49 AC_MSG_CHECKING([whether $LD accepts --as-needed])
50 case `$LD --as-needed -v 2>&1 </dev/null` in
51 *GNU* | *'with BFD'*)
52     LDFLAGS="$LDFLAGS -Wl,--as-needed"
53     AC_MSG_RESULT([yes])
54     ;;
55 *)
56     AC_MSG_RESULT([no])
57     ;;
58 esac
59
60 dnl linker optimizations
61 AC_MSG_CHECKING([whether $LD accepts -O1])
62 case `$LD -O1 -v 2>&1 </dev/null` in
63 *GNU* | *'with BFD'*)
64   LDFLAGS="$LDFLAGS -Wl,-O1"
65   AC_MSG_RESULT([yes])
66   ;;
67 *)
68   AC_MSG_RESULT([no])
69   ;;
70 esac
71 AC_MSG_CHECKING([whether $LD accepts -Bsymbolic-functions])
72 case `$LD -Bsymbolic-functions -v 2>&1 </dev/null` in
73 *GNU* | *'with BFD'*)
74   LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
75   AC_MSG_RESULT([yes])
76   ;;
77 *)
78   AC_MSG_RESULT([no])
79   ;;
80 esac
81 AC_MSG_CHECKING([whether $LD accepts --sort-common])
82 case `$LD --sort-common -v 2>&1 </dev/null` in
83 *GNU* | *'with BFD'*)
84   LDFLAGS="$LDFLAGS -Wl,--sort-common"
85   AC_MSG_RESULT([yes])
86   ;;
87 *)
88   AC_MSG_RESULT([no])
89   ;;
90 esac
91
92 dnl FIXME: filter for undefined symbols in plugins
93 # when passing "-z defs" to linker, we would better to make sure
94 # there are no undefined references.  However, we intend not to
95 # fix at the moment since we don't have spin-off libraray containing
96 # the necessary functions.
97 if test ! -z "$LDFLAGS"; then
98     LDFLAGS=`echo "$LDFLAGS" | sed -e 's/-Wl,-z,defs//'`
99 fi
100
101 LXPANEL_MODULE="-avoid-version \
102 -rpath \$(libdir)/lxpanel/plugins \
103 -no-undefined "'-export-symbols-regex "^[[^_]].*"'
104 AC_SUBST(LXPANEL_MODULE)
105
106 AC_ARG_ENABLE([alsa],
107     AS_HELP_STRING([--disable-alsa],
108                     [compile ALSA providers (default: enable)]),
109             compile_alsa=$enableval, compile_alsa="yes")
110 if test x"$compile_alsa" = "xyes"; then
111     AC_CHECK_HEADERS([alsa/asoundlib.h],
112                      [AC_CHECK_LIB([asound],
113                                    [snd_seq_open],
114                                    compile_alsa=yes,compile_alsa=no)],
115                           compile_alsa=no)
116 fi
117 AM_CONDITIONAL(BUILD_ALSA_PLUGINS, test x$compile_alsa = xyes)
118 dnl FIXME: check OSS existence
119 AM_CONDITIONAL(BUILD_OSS_PLUGINS, test x$compile_alsa = xno)
120
121 # check libiw for netstat plugin
122 AC_ARG_ENABLE([libiw],
123     AS_HELP_STRING([--disable-libiw],
124                     [compile libiw-based netstat plugin (default: enable)]),
125             compile_libiw=$enableval, compile_libiw="yes")
126 if test x"$compile_libiw" = "xyes"; then
127     AC_CHECK_HEADERS(iwlib.h,
128                      [AC_CHECK_LIB(iw,
129                                    iw_sockets_open,
130                                    compile_libiw=yes,
131                                    compile_libiw=no)],
132                                    compile_libiw=no)
133 fi
134 AM_CONDITIONAL(BUILD_LIBIW_PLUGINS, test x$compile_libiw = xyes)
135
136 AC_ARG_ENABLE([plugins-loading],
137     AS_HELP_STRING([--disable-plugins-loading],
138                [disable plugin loading (default: enable)]),
139                plugins_loading=$enableval, plugins_loading="yes")
140
141 AM_CONDITIONAL(BUILD_PLUGIN_LOADER, test x$plugins_loading = xyes)
142
143 if test x"$plugins_loading" = "xno"; then
144     AC_DEFINE(DISABLE_PLUGINS_LOADING, [1], [Disable plugin loading])
145 fi
146
147 dnl Here are plugin listing.
148 plugin_netstatus=
149 plugin_netstat=
150 plugin_volume=
151 plugin_volumealsa=
152 plugin_cpu=
153 plugin_deskno=
154 plugin_batt=
155 plugin_xkb=
156 plugin_kbled=
157 plugin_thermal=thermal
158
159 AC_MSG_CHECKING([which plugins should be built dynamically])
160 AC_ARG_WITH(plugins,
161 [  --with-plugins=<list>  compile dynamic plugins in <list> ]
162 [                         plugins may be comma separated ]
163 [                         'all' builds all plugins (default), 'none' builds none ]
164 [                         Possible plugins are: ]
165 [                         netstatus, netstat, volume, volumealsa, cpu, deskno, batt, kbled, xkb, thermal], plugins="$withval",[plugins="all"])
166
167 if test x"$plugins" != xall -a x"$plugins" != xnone; then
168     if test x"$plugins_loading" = xno; then
169         AC_MSG_ERROR(
170         [--disable-plugins-loading and --with-plugins conflict each other.])
171     fi
172 fi
173
174 ALL_PLUGINS_LIST="netstatus netstat volume volumealsa cpu deskno batt kbled xkb thermal"
175 AC_SUBST(ALL_PLUGINS_LIST)
176
177 if test x"$plugins" = xall; then
178 dnl    for name in $ALL_PLUGINS
179 dnl    do
180 dnl        export plugin_$name="$name"
181 dnl    done
182
183     plugin_netstatus=netstatus
184     plugin_netstat=netstat
185     plugin_volume=volume
186     plugin_volumealsa=volumealsa
187     plugin_cpu=cpu
188     plugin_deskno=deskno
189     plugin_batt=batt
190     plugin_kbled=kbled
191     plugin_xkb=
192     plugin_thermal=thermal
193
194     AC_MSG_RESULT(all)
195 else
196     if test "$plugins" != "none"; then
197         plugins=`echo $plugins | sed 's/,/ /g'`
198         for plugin in $plugins
199         do
200         case "$plugin" in
201             netstatus)
202                 plugin_netstatus=netstatus
203                 ;;
204             netstat)
205                 plugin_netstat=netstat
206                 ;;
207             volume)
208                 plugin_volume=volume
209                 ;;
210             volumealsa)
211                 plugin_volumealsa=volumealsa
212                 ;;
213             cpu)
214                 plugin_cpu=cpu
215                 ;;
216             deskno)
217                 plugin_deskno=deskno
218                 ;;
219             batt)
220                 plugin_batt=batt
221                 ;;
222             kbled)
223                 plugin_kbled=kbled
224                 ;;
225             xkb)
226                 plugin_xkb=xkb
227                 ;;
228             thermal)
229                 plugin_thermal=thermal
230                 ;;
231             *)
232                 echo "Unknown plugin $plugin."
233                 exit 1
234                 ;;
235         esac
236         done
237         AC_MSG_RESULT($plugins)
238     fi
239 fi
240
241 dnl FIXME: OSS/ALSA checking
242 if test x"$compile_alsa" = "xno"; then
243     if test ! -z $plugin_volumealsa; then
244         AC_MSG_RESULT([no ALSA headers/libraries found!])
245         plugin_volumealsa=
246     fi
247 else
248     dnl force OSS plugin to <null>
249     plugin_volume=
250 fi
251 if test x"$compile_libiw" = "xno"; then
252    if test ! -z $plugin_netstat; then
253        AC_MSG_RESULT([no libiw headers/libraries found!])
254    fi
255    plugin_netstat=
256 fi
257 PLUGINS_LIST="\
258     $plugin_netstatus \
259     $plugin_netstat \
260     $plugin_volume \
261     $plugin_volumealsa \
262     $plugin_cpu \
263     $plugin_deskno \
264     $plugin_batt \
265     $plugin_kbled \
266     $plugin_xkb \
267     $plugin_thermal"
268
269 AC_SUBST(PLUGINS_LIST)
270
271
272 # Checks for header files.
273 AC_PATH_X
274 AC_HEADER_STDC
275 AC_HEADER_SYS_WAIT
276 AC_CHECK_HEADERS([locale.h stdlib.h string.h sys/time.h unistd.h])
277
278 # Checks for typedefs, structures, and compiler characteristics.
279 AC_C_CONST
280 AC_C_INLINE
281 AC_STRUCT_TM
282
283 # Checks for library functions.
284 AC_FUNC_MALLOC
285 AC_FUNC_MEMCMP
286 AC_TYPE_SIGNAL
287 AC_FUNC_STAT
288 AC_FUNC_STRFTIME
289 AC_CHECK_FUNCS([bzero memset mkdir setlocale strchr])
290
291
292 GETTEXT_PACKAGE=lxpanel
293 #AM_GNU_GETTEXT([external])
294 AM_GNU_GETTEXT_VERSION(0.14.1)
295 AC_SUBST(GETTEXT_PACKAGE)
296 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
297
298 ALL_LINGUAS="zh_TW ko hu sk pl fr pt_BR fi de es zh_CN"
299 AM_GLIB_GNU_GETTEXT
300
301 AC_CONFIG_FILES([
302     lxpanel.pc
303     Makefile
304     src/Makefile
305     src/plugins/Makefile
306     src/plugins/netstatus/Makefile
307     src/plugins/netstat/Makefile
308     src/plugins/volume/Makefile
309     src/plugins/volumealsa/Makefile
310     src/plugins/cpu/Makefile
311     src/plugins/deskno/Makefile
312     src/plugins/batt/Makefile
313     src/plugins/kbled/Makefile
314     src/plugins/xkb/Makefile
315     src/plugins/thermal/Makefile
316     po/Makefile.in
317     data/Makefile
318     data/default/panels/panel
319     man/Makefile
320 ])
321 AC_OUTPUT
322
323 echo
324 echo lxpanel ......................... : Version $VERSION
325 echo
326 echo Prefix........................... : $prefix
327 if test x$plugins_loading = xyes; then
328 echo Building dynamic plugins:
329     if test x"$plugin_netstatus" != x; then
330         AC_MSG_RESULT([    netstatus - Monitor networking status])
331     fi
332     if test x"$plugin_netstat" != x; then
333         AC_MSG_RESULT([    netstat - Monitor networking status (Linux Only)])
334     fi
335     if test x"$plugin_volume" != x; then
336         AC_MSG_RESULT([    volume - Display and adjust volume of sound card])
337     fi
338     if test x"$plugin_volumealsa" != x; then
339         AC_MSG_RESULT([    volumealsa - Display and adjust volume of sound card for ALSA])
340     fi
341     if test x"$plugin_cpu" != x; then
342         AC_MSG_RESULT([    cpu - Display CPU loading])
343     fi
344     if test x"$plugin_deskno" != x; then
345         AC_MSG_RESULT([    deskno - Display desktop number])
346     fi
347     if test x"$plugin_batt" != x; then
348         AC_MSG_RESULT([    batt - Monitor battery status])
349     fi
350     if test x"$plugin_kbled" != x; then
351         AC_MSG_RESULT([    kbled - Indicator for CapsLock, NumLock, and ScrLock])
352     fi
353     if test x"$plugin_xkb" != x; then
354         AC_MSG_RESULT([    xkb - Keyboard layout switcher])
355     fi
356     if test x"$plugin_thermal" != x; then
357         AC_MSG_RESULT([    thermal - Temperature monitor])
358     fi
359 else
360 echo Dynamic loader for plugins....... : disabled.
361 fi