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