Code

cbd3989de985d45eb8f82df69448d31ac88f1f6a
[ncmpc.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT(ncmpc, 0.26, max@duempel.org)
4 VERSION_MAJOR=0
5 VERSION_MINOR=26
6 VERSION_REVISION=0
7 VERSION_EXTRA=0
9 AC_CONFIG_SRCDIR([src/main.c])
10 AC_CONFIG_AUX_DIR(build)
11 AM_INIT_AUTOMAKE([foreign 1.11 dist-xz subdir-objects])
12 AM_SILENT_RULES
13 AC_CONFIG_HEADERS([config.h])
14 AC_CONFIG_MACRO_DIR([m4])
17 dnl Check for programs
18 AC_PROG_CC_C99
19 AC_PROG_INSTALL
20 AX_WITH_CURSES
22 AS_IF([ test "x$ax_cv_curses" = xno ],
23         [AC_MSG_ERROR([No curses support detected.])
24         ])
26 dnl =======================================================
27 dnl initialize variables
28 dnl =======================================================
30 dnl i18n
31 ALL_LINGUAS=`grep -v '^\#' $srcdir/po/LINGUAS`
33 set -- $CFLAGS
36 dnl
37 dnl ncmpc-mini
38 dnl
40 AC_ARG_ENABLE(mini,
41     AS_HELP_STRING([--enable-mini],
42                 [Build ncmpc-mini, i.e. without all optional features @<:@default=no@:>@]),,
43     [enable_mini=no])
45 AM_CONDITIONAL(NCMPC_MINI, test x$enable_mini = xyes)
46 if test "x$enable_mini" = xyes; then
47     AC_DEFINE([NCMPC_MINI], [1], [Build ncmpc-mini, which disables lots of features])
48     auto=no
49     disable_mini=no
50     auto_mini=no
51 else
52     auto=auto
53     disable_mini=yes
54     auto_mini=auto
55 fi
57 AC_CANONICAL_HOST
59 case "$host_os" in
60 mingw32* | windows*)
61         LIBS="$LIBS -lws2_32"
63         AC_CONFIG_FILES([
64                 src/win/ncmpc_win32_rc.rc
65         ])
66         AC_CHECK_TOOL(WINDRES, windres)
67         HAVE_WINDOWS=1
68         ;;
69 *)
70         AC_CHECK_FUNC([socket],
71                 [],
72                 [AC_CHECK_LIB([socket],[socket],[LIBS="$LIBS -lsocket"],
73                 [AC_MSG_ERROR(No UNIX socket API found)])
74                 ])
76         AC_CHECK_FUNC([gethostbyname],
77                 [], 
78                 [AC_CHECK_LIB([nsl],[gethostbyname],[LIBS="$LIBS -lnsl"],
79                 [AC_MSG_ERROR(No UNIX gethostbyname API found)])
80                 ])
82         HAVE_WINDOWS=0
83 esac
84 AM_CONDITIONAL([HAVE_WINDOWS], [test $HAVE_WINDOWS -eq 1])
86 dnl multi-byte character support
88 AC_ARG_ENABLE([multibyte],
89         AS_HELP_STRING([--disable-multibyte],
90                 [Disable multibyte character support @<:@default=yes@:>@]),,
91                 [enable_multibyte=$disable_mini])
93 if test x$enable_multibyte = xyes; then
94         AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support])
95 else
96         if test "x$ax_cv_curses_enhanced" = xyes; then
97                 AC_MSG_WARN(wide characters without multibyte characters makes little sense)
98         fi
99 fi
101 dnl Check for GLib
102 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.30],,
103         [AC_MSG_ERROR([glib 2.30 is required])])
105 dnl Check for libmpdclient 2.9
106 PKG_CHECK_MODULES([LIBMPDCLIENT], [libmpdclient >= 2.9],,
107         [AC_MSG_ERROR([libmpdclient2 is required])])
109 dnl i18n
111 AC_ARG_ENABLE([locale],
112         AS_HELP_STRING([--disable-locale],
113                 [Disable locale support @<:@default=auto@:>@]),,
114                 [enable_locale=$auto_mini])
116 if test x$enable_locale = xyes; then
117         AC_CHECK_HEADER([locale.h],,
118                 [AC_MSG_ERROR(locale.h is unavailable)])
119 fi
121 if test x$enable_locale = xauto; then
122         AC_CHECK_HEADER([locale.h],
123                 [enable_locale=yes],
124                 [enable_locale=no])
125 fi
127 if test x$enable_locale = xyes; then
128         AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
129 fi
131 if test x$enable_mini != xyes; then
132         AM_NLS
133 else
134         USE_NLS=no
135 fi
137 if test x$USE_NLS = xyes; then
138    AM_GLIB_GNU_GETTEXT
139    GETTEXT_PACKAGE=$PACKAGE
140    AC_SUBST(GETTEXT_PACKAGE)
141    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], 
142                       ["${GETTEXT_PACKAGE}"], 
143                       [gettext domain])
144         USE_NLS=$gt_cv_have_gettext
145         if test x$USE_NLS != xyes; then
146      AC_MSG_WARN([NLS support disabled!])
147   fi
148 else
149   AM_PO_SUBDIRS
150 fi
152 dnl enable colors
153 AC_ARG_ENABLE([colors],
154         AS_HELP_STRING([--enable-colors],
155                 [Enable color support]),,
156                 [enable_colors=auto])
157 AC_MSG_CHECKING([whether to include color support])
158 AS_IF([ test "x$enable_colors" = xyes || test "x$enable_colors" = xauto ],
159         [AS_IF([ test "x$disable_mini" = xyes],
160                 [AS_IF([ test "x$ax_cv_curses_color" = xyes ],
161                         [AC_MSG_RESULT([yes])
162                                 AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])],
163                                 [AS_IF([ test "x$enable_colors" = xyes ],
164                                         AC_MSG_ERROR(["No color support found in curses library"])
165                                         AC_MSG_RESULT([no]),
166                                         AC_MSG_RESULT([no])
167                                 )
168                         ])
169                 ],
170                 [AC_MSG_RESULT([no])
171                 AC_MSG_WARN(["Colors disabled due to mini mode being enabled."])]
172         )],
173         [AC_MSG_RESULT([no])])
175 dnl test for LIRC support
177 AC_ARG_ENABLE([lirc],
178         AS_HELP_STRING([--enable-lirc],
179                 [Enable LIRC support]),,
180         [enable_lirc=no])
181 if test x$enable_lirc = xyes; then
182         PKG_CHECK_MODULES([LIBLIRCCLIENT], [lirc],,
183                 [PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
184                         [AC_MSG_ERROR([lirc not found])]
185                 )]
186         )
188         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
189 fi
191 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
194 dnl Optional screen - help screen
195 AC_MSG_CHECKING([whether to include the help screen])
196 AC_ARG_ENABLE([help-screen],
197         AS_HELP_STRING([--enable-help-screen],
198                 [Enable the help screen @<:@default=yes@:>@]),,
199         [enable_help_screen=$disable_mini])
200 AC_MSG_RESULT([$enable_help_screen])
201 if test "x$enable_help_screen" = "xyes" ; then
202         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
203 fi
205 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
207 dnl Optional - curses getmouse support
209 dnl AC_CHECK_LIB depends on being able to prepend a '-l', remove the '-l' from CURSES_LIB first
210 AC_CHECK_LIB([$(expr substr $CURSES_LIB 3 99)],
211                 [getmouse],
212                 [ax_cv_curses_mouse=yes],
213                 [ax_cv_curses_mouse=no])
215 AC_ARG_ENABLE([mouse], 
216         AS_HELP_STRING([--enable-mouse],
217                 [Enable curses getmouse support @<:@default=yes@:>@]),,
218                 [enable_mouse=auto])
220 AC_MSG_CHECKING([whether to include mouse support])
222 AS_IF([ test "x$enable_mouse" = xyes || test "x$enable_mouse" = xauto ],
223         [AS_IF([ test "x$disable_mini" = xyes],
224                 [AS_IF([ test "x$ax_cv_curses_mouse" = xyes ],
225                         [AC_MSG_RESULT([yes])
226                         AC_DEFINE([HAVE_GETMOUSE], [1], [Enable mouse support])],
227                         [AC_MSG_RESULT([no])
228                         AS_IF([ test "x$enable_mouse" = xyes ],
229                                 [AC_MSG_ERROR(["No mouse support found in curses library"])
230                                 ])
231                         ])
232                 ],
233                 [AC_MSG_RESULT([no])
234                 AC_MSG_WARN("Mouse disabled due to mini mode being enabled.")]
235         )],
236         [AC_MSG_RESULT([no])])
238 dnl Optional screen - artist
239 AC_MSG_CHECKING([whether to include the artist screen])
240 AC_ARG_ENABLE([artist-screen], 
241               AS_HELP_STRING([--enable-artist-screen],
242                 [Enable artist screen @<:@default=yes@:>@]),,
243         [enable_artist_screen=$disable_mini])
244 AC_MSG_RESULT([$enable_artist_screen])
245 if test "x$enable_artist_screen" = "xyes" ; then
246     AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
247 fi
249 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$enable_artist_screen = xyes)
251 dnl Optional screen - search
252 AC_MSG_CHECKING([whether to include the search screen])
253 AC_ARG_ENABLE([search-screen], 
254               AS_HELP_STRING([--enable-search-screen],
255                 [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),,
256         [enable_search_screen=$disable_mini])
257 AC_MSG_RESULT([$enable_search_screen])
258 if test "x$enable_search_screen" = "xyes" ; then
259     AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
260 fi
262 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$enable_search_screen = xyes)
264 dnl Optional screen - song viewer
265 AC_MSG_CHECKING([whether to include the song viewer screen])
266 AC_ARG_ENABLE([song-screen],
267         AS_HELP_STRING([--enable-song-screen],
268                 [Enable song viewer screen @<:@default=yes@:>@]),,
269         [enable_song_screen=$disable_mini])
270 AC_MSG_RESULT([$enable_song_screen])
271 if test "x$enable_song_screen" = "xyes" ; then
272         AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
273 fi
275 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$enable_song_screen = xyes)
276   
277 dnl Optional screen - key editor
278 AC_MSG_CHECKING([whether to include the key editor screen])
279 AC_ARG_ENABLE([key-screen], 
280               AS_HELP_STRING([--enable-key-screen],
281                 [Enable key editor screen @<:@default=yes@:>@]),,
282         [enable_key_screen=$disable_mini])
283 AC_MSG_RESULT([$enable_key_screen])
284 if test "x$enable_key_screen" = "xyes" ; then
285     AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
286 fi
288 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$enable_key_screen = xyes)
290 dnl Optional screen - lyrics
291 AC_MSG_CHECKING([whether to include the lyrics screen]) 
292 AC_ARG_ENABLE([lyrics-screen], 
293               AS_HELP_STRING([--enable-lyrics-screen],
294                 [Enable lyrics screen @<:@default=no@:>@]),,
295         [enable_lyrics_screen=no])
297 case "$host_os" in
298 mingw32* | windows*)
299         AS_IF([ test "x$enable_lyrics_screen" = xyes ],
300                 [AC_MSG_ERROR([Lyrics screen is not yet compatible with windows.])
301                 ])
302 esac
304 if test "x$enable_lyrics_screen" = "xyes" ; then
305     AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
306 fi
308 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$enable_lyrics_screen = xyes)
310 AC_MSG_RESULT([$enable_lyrics_screen])
312 AC_ARG_WITH([lyrics-plugin-dir],
313         AS_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
314                        [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
315        [lyrics_plugin_dir=$withval],
316        [lyrics_plugin_dir=""])
317 if test "x${lyrics_plugin_dir}" = "x"; then
318     if test "x${prefix}" = "xNONE"; then
319         lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
320     else
321         lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
322     fi
323 fi
324 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
325                   [Directory to search for lyrics plugins])
326 AC_SUBST(lyrics_plugin_dir)
328 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$enable_lyrics_screen = xyes)
330 dnl Optional screen - outputs
331 AC_MSG_CHECKING([whether to include the outputs screen])
332 AC_ARG_ENABLE([outputs-screen],
333         AS_HELP_STRING([--enable-outputs-screen],
334                 [Enable outputs screen @<:@default=yes@:>@]),,
335         [enable_outputs_screen=$disable_mini])
337 if test "x$enable_outputs_screen" = "xyes" ; then
338         AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
339 fi
341 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes)
342 AC_MSG_RESULT([$enable_outputs_screen])
345 dnl Optional screen - client-to-client chat
346 AC_MSG_CHECKING([whether to include the chat screen])
347 AC_ARG_ENABLE([chat-screen],
348               AC_HELP_STRING([--enable-chat-screen],
349                 [Enable chat screen @<:@default=no@:>@]),,
350         [enable_chat_screen=no])
351 if test "x$enable_chat_screen" = "xauto"; then
352         enable_chat_screen=yes
353 fi
354 AC_MSG_RESULT([$enable_chat_screen])
355 if test "x$enable_chat_screen" = "xyes" ; then
356         AC_DEFINE(ENABLE_CHAT_SCREEN, 1, [Enable chat screen])
357 fi
358 AM_CONDITIONAL(ENABLE_CHAT_SCREEN, test x$enable_chat_screen = xyes)
360 AM_CONDITIONAL(ENABLE_SCREEN_TEXT,
361         test x$enable_lyrics_screen = xyes -o x$enable_chat_screen = xyes)
363 dnl
364 dnl Windows OS Resource File
365 dnl
366 AC_SUBST(VERSION_MAJOR)
367 AC_SUBST(VERSION_MINOR)
368 AC_SUBST(VERSION_REVISION)
369 AC_SUBST(VERSION_EXTRA)
371 dnl
372 dnl build options
373 dnl
375 AC_ARG_ENABLE(werror,
376         AS_HELP_STRING([--enable-werror],
377                 [Treat warnings as errors @<:@default=no@:>@]),,
378         enable_werror=no)
380 if test "x$enable_werror" = xyes; then
381         AX_APPEND_COMPILE_FLAGS([-Werror])
382 fi
384 AC_ARG_ENABLE(debug,
385         AS_HELP_STRING([--enable-debug],
386                 [Enable debugging @<:@default=no@:>@]),,
387         enable_debug=no)
389 if test "x$enable_debug" = xno; then
390         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
392         AX_APPEND_COMPILE_FLAGS([-ffunction-sections])
393         AX_APPEND_COMPILE_FLAGS([-fdata-sections])
395         AX_APPEND_LINK_FLAGS([-Wl,--gc-sections])
396 fi
398 AC_ARG_ENABLE(test,
399         AS_HELP_STRING([--enable-test],
400                 [build the test programs @<:@default=no@:>@]),,
401         enable_test=$enable_debug)
403 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
405 dnl
406 dnl autogenerated documentation
407 dnl
409 AC_ARG_ENABLE(documentation,
410         AS_HELP_STRING([--enable-documentation],
411                 [build doxygen documentation @<:@default=no@:>@]),,
412         enable_documentation=no)
414 if test x$enable_documentation = xyes; then
415         AC_PATH_PROG(DOXYGEN, doxygen)
416         if test x$DOXYGEN = x; then
417                 AC_MSG_ERROR([doxygen not found])
418         fi
419         AC_SUBST(DOXYGEN)
420 fi
422 AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
424 dnl
425 dnl CFLAGS
426 dnl
428 AC_SUBST(AM_CFLAGS)
430 AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
431 AX_APPEND_COMPILE_FLAGS([-ffast-math])
432 AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
434 AX_APPEND_COMPILE_FLAGS([-Wall])
435 AX_APPEND_COMPILE_FLAGS([-Wextra])
436 AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations])
437 AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
438 AX_APPEND_COMPILE_FLAGS([-Wshadow])
439 AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
440 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
441 AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
442 AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
445 dnl
446 dnl Generate output files
447 dnl
449 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
450 AC_OUTPUT(doc/doxygen.conf)