Code

Compiler.h: add macro GCC_OLDER_THAN()
[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.14],,
103         [AC_MSG_ERROR([glib 2.14 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 Check for libmpdclient 2.5 (the chat screen requires this version)
110 PKG_CHECK_EXISTS([libmpdclient >= 2.5],
111         [have_libmpdclient_2_5=yes], [have_libmpdclient_2_5=no])
113 dnl i18n
115 AC_ARG_ENABLE([locale],
116         AS_HELP_STRING([--disable-locale],
117                 [Disable locale support @<:@default=auto@:>@]),,
118                 [enable_locale=$auto_mini])
120 if test x$enable_locale = xyes; then
121         AC_CHECK_HEADER([locale.h],,
122                 [AC_MSG_ERROR(locale.h is unavailable)])
123 fi
125 if test x$enable_locale = xauto; then
126         AC_CHECK_HEADER([locale.h],
127                 [enable_locale=yes],
128                 [enable_locale=no])
129 fi
131 if test x$enable_locale = xyes; then
132         AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
133 fi
135 if test x$enable_mini != xyes; then
136         AM_NLS
137 else
138         USE_NLS=no
139 fi
141 if test x$USE_NLS = xyes; then
142    AM_GLIB_GNU_GETTEXT
143    GETTEXT_PACKAGE=$PACKAGE
144    AC_SUBST(GETTEXT_PACKAGE)
145    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], 
146                       ["${GETTEXT_PACKAGE}"], 
147                       [gettext domain])
148         USE_NLS=$gt_cv_have_gettext
149         if test x$USE_NLS != xyes; then
150      AC_MSG_WARN([NLS support disabled!])
151   fi
152 else
153   AM_PO_SUBDIRS
154 fi
156 dnl enable colors
157 AC_ARG_ENABLE([colors],
158         AS_HELP_STRING([--enable-colors],
159                 [Enable color support]),
160                 [enable_colors=$enableval],
161                 [enable_colors=auto])
162 AC_MSG_CHECKING([whether to include color support])
163 AS_IF([ test "x$enable_colors" = xyes || test "x$enable_colors" = xauto ],
164         [AS_IF([ test "x$disable_mini" = xyes],
165                 [AS_IF([ test "x$ax_cv_curses_color" = xyes ],
166                         [AC_MSG_RESULT([yes])
167                                 AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])],
168                                 [AS_IF([ test "x$enable_colors" = xyes ],
169                                         AC_MSG_ERROR(["No color support found in curses library"])
170                                         AC_MSG_RESULT([no]),
171                                         AC_MSG_RESULT([no])
172                                 )
173                         ])
174                 ],
175                 [AC_MSG_RESULT([no])
176                 AC_MSG_WARN(["Colors disabled due to mini mode being enabled."])]
177         )],
178         [AC_MSG_RESULT([no])])
180 dnl test for LIRC support
182 AC_ARG_ENABLE([lirc],
183         AS_HELP_STRING([--enable-lirc],
184                 [Enable LIRC support]),,
185         [enable_lirc=no])
186 if test x$enable_lirc = xyes; then
187         PKG_CHECK_MODULES([LIBLIRCCLIENT], [lirc],,
188                 [PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
189                         [AC_MSG_ERROR([lirc not found])]
190                 )]
191         )
193         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
194 fi
196 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
199 dnl Optional screen - help screen
200 AC_MSG_CHECKING([whether to include the help screen])
201 AC_ARG_ENABLE([help-screen],
202         AS_HELP_STRING([--enable-help-screen],
203                 [Enable the help screen @<:@default=yes@:>@]),,
204         [enable_help_screen=$disable_mini])
205 AC_MSG_RESULT([$enable_help_screen])
206 if test "x$enable_help_screen" = "xyes" ; then
207         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
208 fi
210 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
212 dnl Optional - curses getmouse support
214 dnl AC_CHECK_LIB depends on being able to prepend a '-l', remove the '-l' from CURSES_LIB first
215 AC_CHECK_LIB([$(expr substr $CURSES_LIB 3 99)],
216                 [getmouse],
217                 [ax_cv_curses_mouse=yes],
218                 [ax_cv_curses_mouse=no])
220 AC_ARG_ENABLE([mouse], 
221         AS_HELP_STRING([--enable-mouse],
222                 [Enable curses getmouse support @<:@default=yes@:>@]),
223                 [enable_mouse=$enableval],
224                 [enable_mouse=auto])
226 AC_MSG_CHECKING([whether to include mouse support])
228 AS_IF([ test "x$enable_mouse" = xyes || test "x$enable_mouse" = xauto ],
229         [AS_IF([ test "x$disable_mini" = xyes],
230                 [AS_IF([ test "x$ax_cv_curses_mouse" = xyes ],
231                         [AC_MSG_RESULT([yes])
232                         AC_DEFINE([HAVE_GETMOUSE], [1], [Enable mouse support])],
233                         [AC_MSG_RESULT([no])
234                         AS_IF([ test "x$enable_mouse" = xyes ],
235                                 [AC_MSG_ERROR(["No mouse support found in curses library"])
236                                 ])
237                         ])
238                 ],
239                 [AC_MSG_RESULT([no])
240                 AC_MSG_WARN("Mouse disabled due to mini mode being enabled.")]
241         )],
242         [AC_MSG_RESULT([no])])
244 dnl Optional screen - artist
245 AC_MSG_CHECKING([whether to include the artist screen])
246 AC_ARG_ENABLE([artist-screen], 
247               AS_HELP_STRING([--enable-artist-screen],
248                 [Enable artist screen @<:@default=yes@:>@]),,
249         [enable_artist_screen=$disable_mini])
250 AC_MSG_RESULT([$enable_artist_screen])
251 if test "x$enable_artist_screen" = "xyes" ; then
252     AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
253 fi
255 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$enable_artist_screen = xyes)
257 dnl Optional screen - search
258 AC_MSG_CHECKING([whether to include the search screen])
259 AC_ARG_ENABLE([search-screen], 
260               AS_HELP_STRING([--enable-search-screen],
261                 [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),,
262         [enable_search_screen=$disable_mini])
263 AC_MSG_RESULT([$enable_search_screen])
264 if test "x$enable_search_screen" = "xyes" ; then
265     AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
266 fi
268 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$enable_search_screen = xyes)
270 dnl Optional screen - song viewer
271 AC_MSG_CHECKING([whether to include the song viewer screen])
272 AC_ARG_ENABLE([song-screen],
273         AS_HELP_STRING([--enable-song-screen],
274                 [Enable song viewer screen @<:@default=yes@:>@]),,
275         [enable_song_screen=$disable_mini])
276 AC_MSG_RESULT([$enable_song_screen])
277 if test "x$enable_song_screen" = "xyes" ; then
278         AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
279 fi
281 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$enable_song_screen = xyes)
282   
283 dnl Optional screen - key editor
284 AC_MSG_CHECKING([whether to include the key editor screen])
285 AC_ARG_ENABLE([key-screen], 
286               AS_HELP_STRING([--enable-key-screen],
287                 [Enable key editor screen @<:@default=yes@:>@]),,
288         [enable_key_screen=$disable_mini])
289 AC_MSG_RESULT([$enable_key_screen])
290 if test "x$enable_key_screen" = "xyes" ; then
291     AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
292 fi
294 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$enable_key_screen = xyes)
296 dnl Optional screen - lyrics
297 AC_MSG_CHECKING([whether to include the lyrics screen]) 
298 AC_ARG_ENABLE([lyrics-screen], 
299               AS_HELP_STRING([--enable-lyrics-screen],
300                 [Enable lyrics screen @<:@default=no@:>@]),
301         [enable_lyrics_screen=$enableval],
302         [enable_lyrics_screen=no])
304 case "$host_os" in
305 mingw32* | windows*)
306         AS_IF([ test "x$enable_lyrics_screen" = xyes ],
307                 [AC_MSG_ERROR([Lyrics screen is not yet compatible with windows.])
308                 ])
309 esac
311 if test "x$enable_lyrics_screen" = "xyes" ; then
312     AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
313 fi
315 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$enable_lyrics_screen = xyes)
317 AC_MSG_RESULT([$enable_lyrics_screen])
319 AC_ARG_WITH([lyrics-plugin-dir],
320         AS_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
321                        [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
322        [lyrics_plugin_dir=$withval],
323        [lyrics_plugin_dir=""])
324 if test "x${lyrics_plugin_dir}" = "x"; then
325     if test "x${prefix}" = "xNONE"; then
326         lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
327     else
328         lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
329     fi
330 fi
331 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
332                   [Directory to search for lyrics plugins])
333 AC_SUBST(lyrics_plugin_dir)
335 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$enable_lyrics_screen = xyes)
337 dnl Optional screen - outputs
338 AC_MSG_CHECKING([whether to include the outputs screen])
339 AC_ARG_ENABLE([outputs-screen],
340         AS_HELP_STRING([--enable-outputs-screen],
341                 [Enable outputs screen @<:@default=yes@:>@]),,
342         [enable_outputs_screen=$disable_mini])
344 if test "x$enable_outputs_screen" = "xyes" ; then
345         AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
346 fi
348 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes)
349 AC_MSG_RESULT([$enable_outputs_screen])
352 dnl Optional screen - client-to-client chat
353 AC_MSG_CHECKING([whether to include the chat screen])
354 AC_ARG_ENABLE([chat-screen],
355               AC_HELP_STRING([--enable-chat-screen],
356                 [Enable chat screen @<:@default=no@:>@]),,
357         [enable_chat_screen=no])
358 if test "x$enable_chat_screen" = "xauto"; then
359         enable_chat_screen=$have_libmpdclient_2_5
360 fi
361 AC_MSG_RESULT([$enable_chat_screen])
362 if test "x$enable_chat_screen" = "xyes" ; then
363         if test "x$have_libmpdclient_2_5" = "xno"; then
364                 AC_MSG_ERROR(The chat screen requires at least libmpclient 2.5)
365         fi
366         AC_DEFINE(ENABLE_CHAT_SCREEN, 1, [Enable chat screen])
367 fi
368 AM_CONDITIONAL(ENABLE_CHAT_SCREEN, test x$enable_chat_screen = xyes)
370 AM_CONDITIONAL(ENABLE_SCREEN_TEXT,
371         test x$enable_lyrics_screen = xyes -o x$enable_chat_screen = xyes)
373 dnl
374 dnl Windows OS Resource File
375 dnl
376 AC_SUBST(VERSION_MAJOR)
377 AC_SUBST(VERSION_MINOR)
378 AC_SUBST(VERSION_REVISION)
379 AC_SUBST(VERSION_EXTRA)
381 dnl
382 dnl build options
383 dnl
385 AC_ARG_ENABLE(werror,
386         AS_HELP_STRING([--enable-werror],
387                 [Treat warnings as errors @<:@default=no@:>@]),,
388         enable_werror=no)
390 if test "x$enable_werror" = xyes; then
391         AX_APPEND_COMPILE_FLAGS([-Werror])
392 fi
394 AC_ARG_ENABLE(debug,
395         AS_HELP_STRING([--enable-debug],
396                 [Enable debugging @<:@default=no@:>@]),,
397         enable_debug=no)
399 if test "x$enable_debug" = xno; then
400         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
402         AX_APPEND_COMPILE_FLAGS([-ffunction-sections])
403         AX_APPEND_COMPILE_FLAGS([-fdata-sections])
405         AX_APPEND_LINK_FLAGS([-Wl,--gc-sections])
406 fi
408 AC_ARG_ENABLE(test,
409         AS_HELP_STRING([--enable-test],
410                 [build the test programs @<:@default=no@:>@]),,
411         enable_test=$enable_debug)
413 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
415 dnl
416 dnl autogenerated documentation
417 dnl
419 AC_ARG_ENABLE(documentation,
420         AS_HELP_STRING([--enable-documentation],
421                 [build doxygen documentation @<:@default=no@:>@]),,
422         enable_documentation=no)
424 if test x$enable_documentation = xyes; then
425         AC_PATH_PROG(DOXYGEN, doxygen)
426         if test x$DOXYGEN = x; then
427                 AC_MSG_ERROR([doxygen not found])
428         fi
429         AC_SUBST(DOXYGEN)
430 fi
432 AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
434 dnl
435 dnl CFLAGS
436 dnl
438 AC_SUBST(AM_CFLAGS)
440 AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
441 AX_APPEND_COMPILE_FLAGS([-ffast-math])
442 AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
444 AX_APPEND_COMPILE_FLAGS([-Wall])
445 AX_APPEND_COMPILE_FLAGS([-Wextra])
446 AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations])
447 AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
448 AX_APPEND_COMPILE_FLAGS([-Wshadow])
449 AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
450 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
451 AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
452 AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
455 dnl
456 dnl Generate output files
457 dnl
459 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
460 AC_OUTPUT(doc/doxygen.conf)