1 AC_PREREQ(2.60)
2 AC_INIT(ncmpc, 0.21~git, 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 ])
79 esac
80 AM_CONDITIONAL([HAVE_WINDOWS], [test $HAVE_WINDOWS -eq 1])
82 dnl multi-byte character support
84 AC_ARG_ENABLE([multibyte],
85 AS_HELP_STRING([--disable-multibyte],
86 [Disable multibyte character support @<:@default=yes@:>@]),,
87 [enable_multibyte=$disable_mini])
89 if test x$enable_multibyte = xyes; then
90 AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support])
91 else
92 if test "x$ax_cv_curses_enhanced" = xyes; then
93 AC_MSG_WARN(wide characters without multibyte characters makes little sense)
94 fi
95 fi
97 dnl Check for glib-2.12
98 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.12],,
99 [AC_MSG_ERROR([glib 2.12 is required])])
101 dnl Check for libmpdclient 2.2
102 PKG_CHECK_MODULES([LIBMPDCLIENT], [libmpdclient >= 2.2],,
103 [AC_MSG_ERROR([libmpdclient2 is required])])
106 dnl i18n
108 AC_ARG_ENABLE([locale],
109 AS_HELP_STRING([--disable-locale],
110 [Disable locale support @<:@default=auto@:>@]),,
111 [enable_locale=$auto_mini])
113 if test x$enable_locale = xyes; then
114 AC_CHECK_HEADER([locale.h],,
115 [AC_MSG_ERROR(locale.h is unavailable)])
116 fi
118 if test x$enable_locale = xauto; then
119 AC_CHECK_HEADER([locale.h],
120 [enable_locale=yes],
121 [enable_locale=no])
122 fi
124 if test x$enable_locale = xyes; then
125 AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
126 fi
128 if test x$enable_mini != xyes; then
129 AM_NLS
130 else
131 USE_NLS=no
132 fi
134 if test x$USE_NLS = xyes; then
135 AM_GLIB_GNU_GETTEXT
136 GETTEXT_PACKAGE=$PACKAGE
137 AC_SUBST(GETTEXT_PACKAGE)
138 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],
139 ["${GETTEXT_PACKAGE}"],
140 [gettext domain])
141 USE_NLS=$gt_cv_have_gettext
142 if test x$USE_NLS != xyes; then
143 AC_MSG_WARN([NLS support disabled!])
144 fi
145 else
146 AM_PO_SUBDIRS
147 fi
149 dnl enable colors
150 AC_ARG_ENABLE([colors],
151 AS_HELP_STRING([--enable-colors],
152 [Enable color support]),
153 [enable_colors=$enableval],
154 [enable_colors=auto])
155 AC_MSG_CHECKING([whether to include color support])
156 AS_IF([ test "x$enable_colors" = xyes || test "x$enable_colors" = xauto ],
157 [AS_IF([ test "x$disable_mini" = xyes],
158 [AS_IF([ test "x$ax_cv_curses_color" = xyes ],
159 [AC_MSG_RESULT([yes])
160 AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])],
161 [AS_IF([ test "x$enable_colors" = xyes ],
162 AC_MSG_ERROR(["No color support found in curses library"])
163 AC_MSG_RESULT([no]),
164 AC_MSG_RESULT([no])
165 )
166 ])
167 ],
168 [AC_MSG_RESULT([no])
169 AC_MSG_WARN(["Colors disabled due to mini mode being enabled."])]
170 )],
171 [AC_MSG_RESULT([no])])
173 dnl test for LIRC support
175 AC_ARG_ENABLE([lirc],
176 AS_HELP_STRING([--enable-lirc],
177 [Enable LIRC support]),,
178 [enable_lirc=no])
179 if test x$enable_lirc = xyes; then
180 PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
181 [AC_MSG_ERROR([liblircclient0 not found])])
182 AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
183 fi
185 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
188 dnl Optional screen - help screen
189 AC_MSG_CHECKING([whether to include the help screen])
190 AC_ARG_ENABLE([help-screen],
191 AS_HELP_STRING([--enable-help-screen],
192 [Enable the help screen @<:@default=yes@:>@]),,
193 [enable_help_screen=$disable_mini])
194 AC_MSG_RESULT([$enable_help_screen])
195 if test "x$enable_help_screen" = "xyes" ; then
196 AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
197 fi
199 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
201 dnl Optional - curses getmouse support
203 dnl AC_CHECK_LIB depends on being able to prepend a '-l', remove the '-l' from CURSES_LIB first
204 AC_CHECK_LIB([$(expr substr $CURSES_LIB 3 99)],
205 [getmouse],
206 [ax_cv_curses_mouse=yes],
207 [ax_cv_curses_mouse=no])
209 AC_ARG_ENABLE([mouse],
210 AS_HELP_STRING([--enable-mouse],
211 [Enable curses getmouse support @<:@default=yes@:>@]),
212 [enable_mouse=$enableval],
213 [enable_mouse=auto])
215 AC_MSG_CHECKING([whether to include mouse support])
217 AS_IF([ test "x$enable_mouse" = xyes || test "x$enable_mouse" = xauto ],
218 [AS_IF([ test "x$disable_mini" = xyes],
219 [AS_IF([ test "x$ax_cv_curses_mouse" = xyes ],
220 [AC_MSG_RESULT([yes])
221 AC_DEFINE([HAVE_GETMOUSE], [1], [Enable mouse support])],
222 [AC_MSG_RESULT([no])
223 AS_IF([ test "x$enable_mouse" = xyes ],
224 [AC_MSG_ERROR(["No mouse support found in curses library"])
225 ])
226 ])
227 ],
228 [AC_MSG_RESULT([no])
229 AC_MSG_WARN("Mouse disabled due to mini mode being enabled.")]
230 )],
231 [AC_MSG_RESULT([no])])
233 dnl Optional screen - artist
234 AC_MSG_CHECKING([whether to include the artist screen])
235 AC_ARG_ENABLE([artist-screen],
236 AS_HELP_STRING([--enable-artist-screen],
237 [Enable artist screen @<:@default=yes@:>@]),,
238 [enable_artist_screen=$disable_mini])
239 AC_MSG_RESULT([$enable_artist_screen])
240 if test "x$enable_artist_screen" = "xyes" ; then
241 AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
242 fi
244 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$enable_artist_screen = xyes)
246 dnl Optional screen - search
247 AC_MSG_CHECKING([whether to include the search screen])
248 AC_ARG_ENABLE([search-screen],
249 AS_HELP_STRING([--enable-search-screen],
250 [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),,
251 [enable_search_screen=$disable_mini])
252 AC_MSG_RESULT([$enable_search_screen])
253 if test "x$enable_search_screen" = "xyes" ; then
254 AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
255 fi
257 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$enable_search_screen = xyes)
259 dnl Optional screen - song viewer
260 AC_MSG_CHECKING([whether to include the song viewer screen])
261 AC_ARG_ENABLE([song-screen],
262 AS_HELP_STRING([--enable-song-screen],
263 [Enable song viewer screen @<:@default=yes@:>@]),,
264 [enable_song_screen=$disable_mini])
265 AC_MSG_RESULT([$enable_song_screen])
266 if test "x$enable_song_screen" = "xyes" ; then
267 AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
268 fi
270 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$enable_song_screen = xyes)
272 dnl Optional screen - key editor
273 AC_MSG_CHECKING([whether to include the key editor screen])
274 AC_ARG_ENABLE([key-screen],
275 AS_HELP_STRING([--enable-key-screen],
276 [Enable key editor screen @<:@default=yes@:>@]),,
277 [enable_key_screen=$disable_mini])
278 AC_MSG_RESULT([$enable_key_screen])
279 if test "x$enable_key_screen" = "xyes" ; then
280 AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
281 fi
283 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$enable_key_screen = xyes)
285 dnl Optional screen - lyrics
286 AC_MSG_CHECKING([whether to include the lyrics screen])
287 AC_ARG_ENABLE([lyrics-screen],
288 AS_HELP_STRING([--enable-lyrics-screen],
289 [Enable lyrics screen @<:@default=no@:>@]),
290 [enable_lyrics_screen=$enableval],
291 [enable_lyrics_screen=no])
293 case "$host_os" in
294 mingw32* | windows*)
295 AS_IF([ test "x$enable_lyrics_screen" = xyes ],
296 [AC_MSG_ERROR([Lyrics screen is not yet compatible with windows.])
297 ])
298 esac
300 if test "x$enable_lyrics_screen" = "xyes" ; then
301 AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
302 fi
304 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$enable_lyrics_screen = xyes)
306 AC_MSG_RESULT([$enable_lyrics_screen])
308 AC_ARG_WITH([lyrics-plugin-dir],
309 AS_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
310 [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
311 [lyrics_plugin_dir=$withval],
312 [lyrics_plugin_dir=""])
313 if test "x${lyrics_plugin_dir}" = "x"; then
314 if test "x${prefix}" = "xNONE"; then
315 lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
316 else
317 lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
318 fi
319 fi
320 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
321 [Directory to search for lyrics plugins])
322 AC_SUBST(lyrics_plugin_dir)
324 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$enable_lyrics_screen = xyes)
325 AM_CONDITIONAL(ENABLE_SCREEN_TEXT, test x$enable_lyrics_screen = xyes)
327 dnl Optional screen - outputs
328 AC_MSG_CHECKING([whether to include the outputs screen])
329 AC_ARG_ENABLE([outputs-screen],
330 AS_HELP_STRING([--enable-outputs-screen],
331 [Enable outputs screen @<:@default=yes@:>@]),,
332 [enable_outputs_screen=$disable_mini])
334 if test "x$enable_outputs_screen" = "xyes" ; then
335 AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
336 fi
338 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes)
339 AC_MSG_RESULT([$enable_outputs_screen])
342 dnl
343 dnl Windows OS Resource File
344 dnl
345 AC_SUBST(VERSION_MAJOR)
346 AC_SUBST(VERSION_MINOR)
347 AC_SUBST(VERSION_REVISION)
348 AC_SUBST(VERSION_EXTRA)
350 dnl
351 dnl build options
352 dnl
354 AC_ARG_ENABLE(werror,
355 AS_HELP_STRING([--enable-werror],
356 [Treat warnings as errors @<:@default=no@:>@]),,
357 enable_werror=no)
359 if test "x$enable_werror" = xyes; then
360 AX_APPEND_COMPILE_FLAGS([-Werror])
361 fi
363 AC_ARG_ENABLE(debug,
364 AS_HELP_STRING([--enable-debug],
365 [Enable debugging @<:@default=no@:>@]),,
366 enable_debug=no)
368 if test "x$enable_debug" = xno; then
369 AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
370 fi
372 AC_ARG_ENABLE(test,
373 AS_HELP_STRING([--enable-test],
374 [build the test programs @<:@default=no@:>@]),,
375 enable_test=$enable_debug)
377 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
379 dnl
380 dnl autogenerated documentation
381 dnl
383 AC_ARG_ENABLE(documentation,
384 AS_HELP_STRING([--enable-documentation],
385 [build doxygen documentation @<:@default=no@:>@]),,
386 enable_documentation=no)
388 if test x$enable_documentation = xyes; then
389 AC_PATH_PROG(DOXYGEN, doxygen)
390 if test x$DOXYGEN = x; then
391 AC_MSG_ERROR([doxygen not found])
392 fi
393 AC_SUBST(DOXYGEN)
394 fi
396 AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
398 dnl
399 dnl CFLAGS
400 dnl
402 AC_SUBST(AM_CFLAGS)
404 AX_APPEND_COMPILE_FLAGS([-Wall])
405 AX_APPEND_COMPILE_FLAGS([-Wextra])
406 AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations])
407 AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
408 AX_APPEND_COMPILE_FLAGS([-Wshadow])
409 AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
410 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
411 AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
412 AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
415 dnl
416 dnl Generate output files
417 dnl
419 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
420 AC_OUTPUT(doc/doxygen.conf)