Code

release 0.21
[ncmpc.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT(ncmpc, 0.21, max@duempel.org)
4 VERSION_MAJOR=0
5 VERSION_MINOR=21
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.10 dist-bzip2 subdir-objects])
12 AC_CONFIG_HEADERS([config.h])
13 AC_CONFIG_MACRO_DIR([m4])
15 dnl Check for programs
16 AC_PROG_CC_C99
17 AC_PROG_INSTALL
18 AX_WITH_CURSES
20 AS_IF([ test "x$ax_cv_curses" = xno ],
21         [AC_MSG_ERROR([No curses support detected.])
22         ])
24 dnl =======================================================
25 dnl initialize variables
26 dnl =======================================================
28 dnl i18n
29 ALL_LINGUAS=`grep -v '^\#' po/LINGUAS`
31 set -- $CFLAGS
34 dnl
35 dnl ncmpc-mini
36 dnl
38 AC_ARG_ENABLE(mini,
39     AS_HELP_STRING([--enable-mini],
40                 [Build ncmpc-mini, i.e. without all optional features @<:@default=no@:>@]),,
41     [enable_mini=no])
43 AM_CONDITIONAL(NCMPC_MINI, test x$enable_mini = xyes)
44 if test "x$enable_mini" = xyes; then
45     AC_DEFINE([NCMPC_MINI], [1], [Build ncmpc-mini, which disables lots of features])
46     auto=no
47     disable_mini=no
48     auto_mini=no
49 else
50     auto=auto
51     disable_mini=yes
52     auto_mini=auto
53 fi
55 AC_CANONICAL_HOST
57 case "$host_os" in
58 mingw32* | windows*)
59         LIBS="$LIBS -lws2_32"
61         AC_CONFIG_FILES([
62                 src/win/ncmpc_win32_rc.rc
63         ])
64         AC_CHECK_TOOL(WINDRES, windres)
65         HAVE_WINDOWS=1
66         ;;
67 *)
68         AC_CHECK_FUNC([socket],
69                 [],
70                 [AC_CHECK_LIB([socket],[socket],[LIBS="$LIBS -lsocket"],
71                 [AC_MSG_ERROR(No UNIX socket API found)])
72                 ])
74         AC_CHECK_FUNC([gethostbyname],
75                 [], 
76                 [AC_CHECK_LIB([nsl],[gethostbyname],[LIBS="$LIBS -lnsl"],
77                 [AC_MSG_ERROR(No UNIX gethostbyname API found)])
78                 ])
80         HAVE_WINDOWS=0
81 esac
82 AM_CONDITIONAL([HAVE_WINDOWS], [test $HAVE_WINDOWS -eq 1])
84 dnl multi-byte character support
86 AC_ARG_ENABLE([multibyte],
87         AS_HELP_STRING([--disable-multibyte],
88                 [Disable multibyte character support @<:@default=yes@:>@]),,
89                 [enable_multibyte=$disable_mini])
91 if test x$enable_multibyte = xyes; then
92         AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support])
93 else
94         if test "x$ax_cv_curses_enhanced" = xyes; then
95                 AC_MSG_WARN(wide characters without multibyte characters makes little sense)
96         fi
97 fi
99 dnl Check for GLib
100 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.14],,
101         [AC_MSG_ERROR([glib 2.14 is required])])
103 dnl Check for libmpdclient 2.2
104 PKG_CHECK_MODULES([LIBMPDCLIENT], [libmpdclient >= 2.2],,
105         [AC_MSG_ERROR([libmpdclient2 is required])])
107 dnl Check for libmpdclient 2.5 (the chat screen requires this version)
108 PKG_CHECK_EXISTS([libmpdclient >= 2.5],
109         [have_libmpdclient_2_5=yes], [have_libmpdclient_2_5=no])
111 dnl i18n
113 AC_ARG_ENABLE([locale],
114         AS_HELP_STRING([--disable-locale],
115                 [Disable locale support @<:@default=auto@:>@]),,
116                 [enable_locale=$auto_mini])
118 if test x$enable_locale = xyes; then
119         AC_CHECK_HEADER([locale.h],,
120                 [AC_MSG_ERROR(locale.h is unavailable)])
121 fi
123 if test x$enable_locale = xauto; then
124         AC_CHECK_HEADER([locale.h],
125                 [enable_locale=yes],
126                 [enable_locale=no])
127 fi
129 if test x$enable_locale = xyes; then
130         AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
131 fi
133 if test x$enable_mini != xyes; then
134         AM_NLS
135 else
136         USE_NLS=no
137 fi
139 if test x$USE_NLS = xyes; then
140    AM_GLIB_GNU_GETTEXT
141    GETTEXT_PACKAGE=$PACKAGE
142    AC_SUBST(GETTEXT_PACKAGE)
143    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], 
144                       ["${GETTEXT_PACKAGE}"], 
145                       [gettext domain])
146         USE_NLS=$gt_cv_have_gettext
147         if test x$USE_NLS != xyes; then
148      AC_MSG_WARN([NLS support disabled!])
149   fi
150 else
151   AM_PO_SUBDIRS
152 fi
154 dnl enable colors
155 AC_ARG_ENABLE([colors],
156         AS_HELP_STRING([--enable-colors],
157                 [Enable color support]),
158                 [enable_colors=$enableval],
159                 [enable_colors=auto])
160 AC_MSG_CHECKING([whether to include color support])
161 AS_IF([ test "x$enable_colors" = xyes || test "x$enable_colors" = xauto ],
162         [AS_IF([ test "x$disable_mini" = xyes],
163                 [AS_IF([ test "x$ax_cv_curses_color" = xyes ],
164                         [AC_MSG_RESULT([yes])
165                                 AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])],
166                                 [AS_IF([ test "x$enable_colors" = xyes ],
167                                         AC_MSG_ERROR(["No color support found in curses library"])
168                                         AC_MSG_RESULT([no]),
169                                         AC_MSG_RESULT([no])
170                                 )
171                         ])
172                 ],
173                 [AC_MSG_RESULT([no])
174                 AC_MSG_WARN(["Colors disabled due to mini mode being enabled."])]
175         )],
176         [AC_MSG_RESULT([no])])
178 dnl test for LIRC support
180 AC_ARG_ENABLE([lirc],
181         AS_HELP_STRING([--enable-lirc],
182                 [Enable LIRC support]),,
183         [enable_lirc=no])
184 if test x$enable_lirc = xyes; then
185         PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
186                 [AC_MSG_ERROR([liblircclient0 not found])])
187         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
188 fi
190 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
193 dnl Optional screen - help screen
194 AC_MSG_CHECKING([whether to include the help screen])
195 AC_ARG_ENABLE([help-screen],
196         AS_HELP_STRING([--enable-help-screen],
197                 [Enable the help screen @<:@default=yes@:>@]),,
198         [enable_help_screen=$disable_mini])
199 AC_MSG_RESULT([$enable_help_screen])
200 if test "x$enable_help_screen" = "xyes" ; then
201         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
202 fi
204 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
206 dnl Optional - curses getmouse support
208 dnl AC_CHECK_LIB depends on being able to prepend a '-l', remove the '-l' from CURSES_LIB first
209 AC_CHECK_LIB([$(expr substr $CURSES_LIB 3 99)],
210                 [getmouse],
211                 [ax_cv_curses_mouse=yes],
212                 [ax_cv_curses_mouse=no])
214 AC_ARG_ENABLE([mouse], 
215         AS_HELP_STRING([--enable-mouse],
216                 [Enable curses getmouse support @<:@default=yes@:>@]),
217                 [enable_mouse=$enableval],
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=$enableval],
296         [enable_lyrics_screen=no])
298 case "$host_os" in
299 mingw32* | windows*)
300         AS_IF([ test "x$enable_lyrics_screen" = xyes ],
301                 [AC_MSG_ERROR([Lyrics screen is not yet compatible with windows.])
302                 ])
303 esac
305 if test "x$enable_lyrics_screen" = "xyes" ; then
306     AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
307 fi
309 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$enable_lyrics_screen = xyes)
311 AC_MSG_RESULT([$enable_lyrics_screen])
313 AC_ARG_WITH([lyrics-plugin-dir],
314         AS_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
315                        [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
316        [lyrics_plugin_dir=$withval],
317        [lyrics_plugin_dir=""])
318 if test "x${lyrics_plugin_dir}" = "x"; then
319     if test "x${prefix}" = "xNONE"; then
320         lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
321     else
322         lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
323     fi
324 fi
325 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
326                   [Directory to search for lyrics plugins])
327 AC_SUBST(lyrics_plugin_dir)
329 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$enable_lyrics_screen = xyes)
331 dnl Optional screen - outputs
332 AC_MSG_CHECKING([whether to include the outputs screen])
333 AC_ARG_ENABLE([outputs-screen],
334         AS_HELP_STRING([--enable-outputs-screen],
335                 [Enable outputs screen @<:@default=yes@:>@]),,
336         [enable_outputs_screen=$disable_mini])
338 if test "x$enable_outputs_screen" = "xyes" ; then
339         AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
340 fi
342 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes)
343 AC_MSG_RESULT([$enable_outputs_screen])
346 dnl Optional screen - client-to-client chat
347 AC_MSG_CHECKING([whether to include the chat screen])
348 AC_ARG_ENABLE([chat-screen],
349               AC_HELP_STRING([--enable-chat-screen],
350                 [Enable chat screen @<:@default=no@:>@]),,
351         [enable_chat_screen=no])
352 if test "x$enable_chat_screen" = "xauto"; then
353         enable_chat_screen=$have_libmpdclient_2_5
354 fi
355 AC_MSG_RESULT([$enable_chat_screen])
356 if test "x$enable_chat_screen" = "xyes" ; then
357         if test "x$have_libmpdclient_2_5" = "xno"; then
358                 AC_MSG_ERROR(The chat screen requires at least libmpclient 2.5)
359         fi
360         AC_DEFINE(ENABLE_CHAT_SCREEN, 1, [Enable chat screen])
361 fi
362 AM_CONDITIONAL(ENABLE_CHAT_SCREEN, test x$enable_chat_screen = xyes)
364 AM_CONDITIONAL(ENABLE_SCREEN_TEXT,
365         test x$enable_lyrics_screen = xyes -o x$enable_chat_screen = xyes)
367 dnl
368 dnl Windows OS Resource File
369 dnl
370 AC_SUBST(VERSION_MAJOR)
371 AC_SUBST(VERSION_MINOR)
372 AC_SUBST(VERSION_REVISION)
373 AC_SUBST(VERSION_EXTRA)
375 dnl
376 dnl build options
377 dnl
379 AC_ARG_ENABLE(werror,
380         AS_HELP_STRING([--enable-werror],
381                 [Treat warnings as errors @<:@default=no@:>@]),,
382         enable_werror=no)
384 if test "x$enable_werror" = xyes; then
385         AX_APPEND_COMPILE_FLAGS([-Werror])
386 fi
388 AC_ARG_ENABLE(debug,
389         AS_HELP_STRING([--enable-debug],
390                 [Enable debugging @<:@default=no@:>@]),,
391         enable_debug=no)
393 if test "x$enable_debug" = xno; then
394         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
395 fi
397 AC_ARG_ENABLE(test,
398         AS_HELP_STRING([--enable-test],
399                 [build the test programs @<:@default=no@:>@]),,
400         enable_test=$enable_debug)
402 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
404 dnl
405 dnl autogenerated documentation
406 dnl
408 AC_ARG_ENABLE(documentation,
409         AS_HELP_STRING([--enable-documentation],
410                 [build doxygen documentation @<:@default=no@:>@]),,
411         enable_documentation=no)
413 if test x$enable_documentation = xyes; then
414         AC_PATH_PROG(DOXYGEN, doxygen)
415         if test x$DOXYGEN = x; then
416                 AC_MSG_ERROR([doxygen not found])
417         fi
418         AC_SUBST(DOXYGEN)
419 fi
421 AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
423 dnl
424 dnl CFLAGS
425 dnl
427 AC_SUBST(AM_CFLAGS)
429 AX_APPEND_COMPILE_FLAGS([-Wall])
430 AX_APPEND_COMPILE_FLAGS([-Wextra])
431 AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations])
432 AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
433 AX_APPEND_COMPILE_FLAGS([-Wshadow])
434 AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
435 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
436 AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
437 AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
440 dnl
441 dnl Generate output files
442 dnl
444 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
445 AC_OUTPUT(doc/doxygen.conf)