Code

ncmpc version 0.20
[ncmpc.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT(ncmpc, 0.20, max@duempel.org)
3 AC_CONFIG_SRCDIR([src/main.c])
4 AC_CONFIG_AUX_DIR(build)
5 AM_INIT_AUTOMAKE([foreign 1.10 dist-bzip2 subdir-objects])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_MACRO_DIR([m4])
9 dnl Check for programs
10 AC_PROG_CC_C99
11 AC_PROG_INSTALL
12 AX_WITH_CURSES
14 AS_IF([ test "x$ax_cv_curses" = xno ],
15         [AC_MSG_ERROR([No curses support detected.])
16         ])
18 dnl =======================================================
19 dnl initialize variables
20 dnl =======================================================
22 dnl i18n
23 ALL_LINGUAS=`grep -v '^\#' po/LINGUAS`
25 set -- $CFLAGS
28 dnl
29 dnl ncmpc-mini
30 dnl
32 AC_ARG_ENABLE(mini,
33     AS_HELP_STRING([--enable-mini],
34                 [Build ncmpc-mini, i.e. without all optional features @<:@default=no@:>@]),,
35     [enable_mini=no])
37 AM_CONDITIONAL(NCMPC_MINI, test x$enable_mini = xyes)
38 if test "x$enable_mini" = xyes; then
39     AC_DEFINE([NCMPC_MINI], [1], [Build ncmpc-mini, which disables lots of features])
40     auto=no
41     disable_mini=no
42     auto_mini=no
43 else
44     auto=auto
45     disable_mini=yes
46     auto_mini=auto
47 fi
49 AC_CANONICAL_HOST
51 case "$host_os" in
52 mingw32* | windows*)
53         LIBS="$LIBS -lws2_32"
54         ;;
56 *)
57         AC_CHECK_FUNC([socket],
58                 [],
59                 [AC_CHECK_LIB([socket],[socket],[LIBS="$LIBS -lsocket"],
60                 [AC_MSG_ERROR(No UNIX socket API found)])
61                 ])
63         AC_CHECK_FUNC([gethostbyname],
64                 [], 
65                 [AC_CHECK_LIB([nsl],[gethostbyname],[LIBS="$LIBS -lnsl"],
66                 [AC_MSG_ERROR(No UNIX gethostbyname API found)])
67                 ])
68 esac
70 dnl multi-byte character support
72 AC_ARG_ENABLE([multibyte],
73         AS_HELP_STRING([--disable-multibyte],
74                 [Disable multibyte character support @<:@default=yes@:>@]),,
75                 [enable_multibyte=$disable_mini])
77 if test x$enable_multibyte = xyes; then
78         AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support])
79 else
80         if test "x$ax_cv_curses_enhanced" = xyes; then
81                 AC_MSG_WARN(wide characters without multibyte characters makes little sense)
82         fi
83 fi
85 dnl Check for glib-2.12
86 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.12],,
87         [AC_MSG_ERROR([glib 2.12 is required])])
89 dnl Check for libmpdclient 2.2
90 PKG_CHECK_MODULES([LIBMPDCLIENT], [libmpdclient >= 2.2],,
91         [AC_MSG_ERROR([libmpdclient2 is required])])
94 dnl i18n
96 AC_ARG_ENABLE([locale],
97         AS_HELP_STRING([--disable-locale],
98                 [Disable locale support @<:@default=auto@:>@]),,
99                 [enable_locale=$auto_mini])
101 if test x$enable_locale = xyes; then
102         AC_CHECK_HEADER([locale.h],,
103                 [AC_MSG_ERROR(locale.h is unavailable)])
104 fi
106 if test x$enable_locale = xauto; then
107         AC_CHECK_HEADER([locale.h],
108                 [enable_locale=yes],
109                 [enable_locale=no])
110 fi
112 if test x$enable_locale = xyes; then
113         AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
114 fi
116 if test x$enable_mini != xyes; then
117         AM_NLS
118 else
119         USE_NLS=no
120 fi
122 if test x$USE_NLS = xyes; then
123    AM_GLIB_GNU_GETTEXT
124    GETTEXT_PACKAGE=$PACKAGE
125    AC_SUBST(GETTEXT_PACKAGE)
126    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], 
127                       ["${GETTEXT_PACKAGE}"], 
128                       [gettext domain])
129         USE_NLS=$gt_cv_have_gettext
130         if test x$USE_NLS != xyes; then
131      AC_MSG_WARN([NLS support disabled!])
132   fi
133 else
134   AM_PO_SUBDIRS
135 fi
137 dnl enable colors
138 AC_ARG_ENABLE([colors],
139         AS_HELP_STRING([--enable-colors],
140                 [Enable color support]),
141                 [enable_colors=$enableval],
142                 [enable_colors=auto])
143 AC_MSG_CHECKING([whether to include color support])
144 AS_IF([ test "x$enable_colors" = xyes || test "x$enable_colors" = xauto ],
145         [AS_IF([ test "x$disable_mini" = xyes],
146                 [AS_IF([ test "x$ax_cv_curses_color" = xyes ],
147                         [AC_MSG_RESULT([yes])
148                                 AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])],
149                                 [AS_IF([ test "x$enable_colors" = xyes ],
150                                         AC_MSG_ERROR(["No color support found in curses library"])
151                                         AC_MSG_RESULT([no]),
152                                         AC_MSG_RESULT([no])
153                                 )
154                         ])
155                 ],
156                 [AC_MSG_RESULT([no])
157                 AC_MSG_WARN(["Colors disabled due to mini mode being enabled."])]
158         )],
159         [AC_MSG_RESULT([no])])
161 dnl test for LIRC support
163 AC_ARG_ENABLE([lirc],
164         AS_HELP_STRING([--enable-lirc],
165                 [Enable LIRC support]),,
166         [enable_lirc=no])
167 if test x$enable_lirc = xyes; then
168         PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
169                 [AC_MSG_ERROR([liblircclient0 not found])])
170         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
171 fi
173 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
176 dnl Optional screen - help screen
177 AC_MSG_CHECKING([whether to include the help screen])
178 AC_ARG_ENABLE([help-screen],
179         AS_HELP_STRING([--enable-help-screen],
180                 [Enable the help screen @<:@default=yes@:>@]),,
181         [enable_help_screen=$disable_mini])
182 AC_MSG_RESULT([$enable_help_screen])
183 if test "x$enable_help_screen" = "xyes" ; then
184         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
185 fi
187 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
189 dnl Optional - curses getmouse support
191 dnl AC_CHECK_LIB depends on being able to prepend a '-l', remove the '-l' from CURSES_LIB first
192 AC_CHECK_LIB([$(expr substr $CURSES_LIB 3 99)],
193                 [getmouse],
194                 [ax_cv_curses_mouse=yes],
195                 [ax_cv_curses_mouse=no])
197 AC_ARG_ENABLE([mouse], 
198         AS_HELP_STRING([--enable-mouse],
199                 [Enable curses getmouse support @<:@default=yes@:>@]),
200                 [enable_mouse=$enableval],
201                 [enable_mouse=auto])
203 AC_MSG_CHECKING([whether to include mouse support])
205 AS_IF([ test "x$enable_mouse" = xyes || test "x$enable_mouse" = xauto ],
206         [AS_IF([ test "x$disable_mini" = xyes],
207                 [AS_IF([ test "x$ax_cv_curses_mouse" = xyes ],
208                         [AC_MSG_RESULT([yes])
209                         AC_DEFINE([HAVE_GETMOUSE], [1], [Enable mouse support])],
210                         [AC_MSG_RESULT([no])
211                         AS_IF([ test "x$enable_mouse" = xyes ],
212                                 [AC_MSG_ERROR(["No mouse support found in curses library"])
213                                 ])
214                         ])
215                 ],
216                 [AC_MSG_RESULT([no])
217                 AC_MSG_WARN("Mouse disabled due to mini mode being enabled.")]
218         )],
219         [AC_MSG_RESULT([no])])
221 dnl Optional screen - artist
222 AC_MSG_CHECKING([whether to include the artist screen])
223 AC_ARG_ENABLE([artist-screen], 
224               AS_HELP_STRING([--enable-artist-screen],
225                 [Enable artist screen @<:@default=yes@:>@]),,
226         [enable_artist_screen=$disable_mini])
227 AC_MSG_RESULT([$enable_artist_screen])
228 if test "x$enable_artist_screen" = "xyes" ; then
229     AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
230 fi
232 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$enable_artist_screen = xyes)
234 dnl Optional screen - search
235 AC_MSG_CHECKING([whether to include the search screen])
236 AC_ARG_ENABLE([search-screen], 
237               AS_HELP_STRING([--enable-search-screen],
238                 [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),,
239         [enable_search_screen=$disable_mini])
240 AC_MSG_RESULT([$enable_search_screen])
241 if test "x$enable_search_screen" = "xyes" ; then
242     AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
243 fi
245 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$enable_search_screen = xyes)
247 dnl Optional screen - song viewer
248 AC_MSG_CHECKING([whether to include the song viewer screen])
249 AC_ARG_ENABLE([song-screen],
250         AS_HELP_STRING([--enable-song-screen],
251                 [Enable song viewer screen @<:@default=yes@:>@]),,
252         [enable_song_screen=$disable_mini])
253 AC_MSG_RESULT([$enable_song_screen])
254 if test "x$enable_song_screen" = "xyes" ; then
255         AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
256 fi
258 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$enable_song_screen = xyes)
259   
260 dnl Optional screen - key editor
261 AC_MSG_CHECKING([whether to include the key editor screen])
262 AC_ARG_ENABLE([key-screen], 
263               AS_HELP_STRING([--enable-key-screen],
264                 [Enable key editor screen @<:@default=yes@:>@]),,
265         [enable_key_screen=$disable_mini])
266 AC_MSG_RESULT([$enable_key_screen])
267 if test "x$enable_key_screen" = "xyes" ; then
268     AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
269 fi
271 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$enable_key_screen = xyes)
273 dnl Optional screen - lyrics
274 AC_MSG_CHECKING([whether to include the lyrics screen]) 
275 AC_ARG_ENABLE([lyrics-screen], 
276               AS_HELP_STRING([--enable-lyrics-screen],
277                 [Enable lyrics screen @<:@default=no@:>@]),
278         [enable_lyrics_screen=$enableval],
279         [enable_lyrics_screen=no])
281 case "$host_os" in
282 mingw32* | windows*)
283         AS_IF([ test "x$enable_lyrics_screen" = xyes ],
284                 [AC_MSG_ERROR([Lyrics screen is not yet compatible with windows.])
285                 ])
286 esac
288 if test "x$enable_lyrics_screen" = "xyes" ; then
289     AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
290 fi
292 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$enable_lyrics_screen = xyes)
294 AC_MSG_RESULT([$enable_lyrics_screen])
296 AC_ARG_WITH([lyrics-plugin-dir],
297         AS_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
298                        [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
299        [lyrics_plugin_dir=$withval],
300        [lyrics_plugin_dir=""])
301 if test "x${lyrics_plugin_dir}" = "x"; then
302     if test "x${prefix}" = "xNONE"; then
303         lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
304     else
305         lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
306     fi
307 fi
308 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
309                   [Directory to search for lyrics plugins])
310 AC_SUBST(lyrics_plugin_dir)
312 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$enable_lyrics_screen = xyes)
313 AM_CONDITIONAL(ENABLE_SCREEN_TEXT, test x$enable_lyrics_screen = xyes)
315 dnl Optional screen - outputs
316 AC_MSG_CHECKING([whether to include the outputs screen])
317 AC_ARG_ENABLE([outputs-screen],
318         AS_HELP_STRING([--enable-outputs-screen],
319                 [Enable outputs screen @<:@default=yes@:>@]),,
320         [enable_outputs_screen=$disable_mini])
322 if test "x$enable_outputs_screen" = "xyes" ; then
323         AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
324 fi
326 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes)
327 AC_MSG_RESULT([$enable_outputs_screen])
331 dnl
332 dnl build options
333 dnl
335 AC_ARG_ENABLE(werror,
336         AS_HELP_STRING([--enable-werror],
337                 [Treat warnings as errors @<:@default=no@:>@]),,
338         enable_werror=no)
340 if test "x$enable_werror" = xyes; then
341         AX_APPEND_COMPILE_FLAGS([-Werror])
342 fi
344 AC_ARG_ENABLE(debug,
345         AS_HELP_STRING([--enable-debug],
346                 [Enable debugging @<:@default=no@:>@]),,
347         enable_debug=no)
349 if test "x$enable_debug" = xno; then
350         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
351 fi
353 AC_ARG_ENABLE(test,
354         AS_HELP_STRING([--enable-test],
355                 [build the test programs @<:@default=no@:>@]),,
356         enable_test=$enable_debug)
358 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
360 dnl
361 dnl autogenerated documentation
362 dnl
364 AC_ARG_ENABLE(documentation,
365         AS_HELP_STRING([--enable-documentation],
366                 [build doxygen documentation @<:@default=no@:>@]),,
367         enable_documentation=no)
369 if test x$enable_documentation = xyes; then
370         AC_PATH_PROG(DOXYGEN, doxygen)
371         if test x$DOXYGEN = x; then
372                 AC_MSG_ERROR([doxygen not found])
373         fi
374         AC_SUBST(DOXYGEN)
375 fi
377 AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
379 dnl
380 dnl CFLAGS
381 dnl
383 AC_SUBST(AM_CFLAGS)
385 AX_APPEND_COMPILE_FLAGS([-Wall])
386 AX_APPEND_COMPILE_FLAGS([-Wextra])
387 AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations])
388 AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
389 AX_APPEND_COMPILE_FLAGS([-Wshadow])
390 AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
391 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
392 AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
393 AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
396 dnl
397 dnl Generate output files
398 dnl
400 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
401 AC_OUTPUT(doc/doxygen.conf)