Code

configure.ac: set HAVE_WINDOWS=0 to avoid a "test" warning
[ncmpc.git] / configure.ac
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                 ])
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-2.12
100 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.12],,
101         [AC_MSG_ERROR([glib 2.12 is required])])
103 dnl Check for libmpdclient 2.2
104 PKG_CHECK_MODULES([LIBMPDCLIENT], [libmpdclient >= 2.2],,
105         [AC_MSG_ERROR([libmpdclient2 is required])])
108 dnl i18n
110 AC_ARG_ENABLE([locale],
111         AS_HELP_STRING([--disable-locale],
112                 [Disable locale support @<:@default=auto@:>@]),,
113                 [enable_locale=$auto_mini])
115 if test x$enable_locale = xyes; then
116         AC_CHECK_HEADER([locale.h],,
117                 [AC_MSG_ERROR(locale.h is unavailable)])
118 fi
120 if test x$enable_locale = xauto; then
121         AC_CHECK_HEADER([locale.h],
122                 [enable_locale=yes],
123                 [enable_locale=no])
124 fi
126 if test x$enable_locale = xyes; then
127         AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
128 fi
130 if test x$enable_mini != xyes; then
131         AM_NLS
132 else
133         USE_NLS=no
134 fi
136 if test x$USE_NLS = xyes; then
137    AM_GLIB_GNU_GETTEXT
138    GETTEXT_PACKAGE=$PACKAGE
139    AC_SUBST(GETTEXT_PACKAGE)
140    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], 
141                       ["${GETTEXT_PACKAGE}"], 
142                       [gettext domain])
143         USE_NLS=$gt_cv_have_gettext
144         if test x$USE_NLS != xyes; then
145      AC_MSG_WARN([NLS support disabled!])
146   fi
147 else
148   AM_PO_SUBDIRS
149 fi
151 dnl enable colors
152 AC_ARG_ENABLE([colors],
153         AS_HELP_STRING([--enable-colors],
154                 [Enable color support]),
155                 [enable_colors=$enableval],
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], [liblircclient0],,
183                 [AC_MSG_ERROR([liblircclient0 not found])])
184         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
185 fi
187 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
190 dnl Optional screen - help screen
191 AC_MSG_CHECKING([whether to include the help screen])
192 AC_ARG_ENABLE([help-screen],
193         AS_HELP_STRING([--enable-help-screen],
194                 [Enable the help screen @<:@default=yes@:>@]),,
195         [enable_help_screen=$disable_mini])
196 AC_MSG_RESULT([$enable_help_screen])
197 if test "x$enable_help_screen" = "xyes" ; then
198         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
199 fi
201 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
203 dnl Optional - curses getmouse support
205 dnl AC_CHECK_LIB depends on being able to prepend a '-l', remove the '-l' from CURSES_LIB first
206 AC_CHECK_LIB([$(expr substr $CURSES_LIB 3 99)],
207                 [getmouse],
208                 [ax_cv_curses_mouse=yes],
209                 [ax_cv_curses_mouse=no])
211 AC_ARG_ENABLE([mouse], 
212         AS_HELP_STRING([--enable-mouse],
213                 [Enable curses getmouse support @<:@default=yes@:>@]),
214                 [enable_mouse=$enableval],
215                 [enable_mouse=auto])
217 AC_MSG_CHECKING([whether to include mouse support])
219 AS_IF([ test "x$enable_mouse" = xyes || test "x$enable_mouse" = xauto ],
220         [AS_IF([ test "x$disable_mini" = xyes],
221                 [AS_IF([ test "x$ax_cv_curses_mouse" = xyes ],
222                         [AC_MSG_RESULT([yes])
223                         AC_DEFINE([HAVE_GETMOUSE], [1], [Enable mouse support])],
224                         [AC_MSG_RESULT([no])
225                         AS_IF([ test "x$enable_mouse" = xyes ],
226                                 [AC_MSG_ERROR(["No mouse support found in curses library"])
227                                 ])
228                         ])
229                 ],
230                 [AC_MSG_RESULT([no])
231                 AC_MSG_WARN("Mouse disabled due to mini mode being enabled.")]
232         )],
233         [AC_MSG_RESULT([no])])
235 dnl Optional screen - artist
236 AC_MSG_CHECKING([whether to include the artist screen])
237 AC_ARG_ENABLE([artist-screen], 
238               AS_HELP_STRING([--enable-artist-screen],
239                 [Enable artist screen @<:@default=yes@:>@]),,
240         [enable_artist_screen=$disable_mini])
241 AC_MSG_RESULT([$enable_artist_screen])
242 if test "x$enable_artist_screen" = "xyes" ; then
243     AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
244 fi
246 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$enable_artist_screen = xyes)
248 dnl Optional screen - search
249 AC_MSG_CHECKING([whether to include the search screen])
250 AC_ARG_ENABLE([search-screen], 
251               AS_HELP_STRING([--enable-search-screen],
252                 [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),,
253         [enable_search_screen=$disable_mini])
254 AC_MSG_RESULT([$enable_search_screen])
255 if test "x$enable_search_screen" = "xyes" ; then
256     AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
257 fi
259 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$enable_search_screen = xyes)
261 dnl Optional screen - song viewer
262 AC_MSG_CHECKING([whether to include the song viewer screen])
263 AC_ARG_ENABLE([song-screen],
264         AS_HELP_STRING([--enable-song-screen],
265                 [Enable song viewer screen @<:@default=yes@:>@]),,
266         [enable_song_screen=$disable_mini])
267 AC_MSG_RESULT([$enable_song_screen])
268 if test "x$enable_song_screen" = "xyes" ; then
269         AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
270 fi
272 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$enable_song_screen = xyes)
273   
274 dnl Optional screen - key editor
275 AC_MSG_CHECKING([whether to include the key editor screen])
276 AC_ARG_ENABLE([key-screen], 
277               AS_HELP_STRING([--enable-key-screen],
278                 [Enable key editor screen @<:@default=yes@:>@]),,
279         [enable_key_screen=$disable_mini])
280 AC_MSG_RESULT([$enable_key_screen])
281 if test "x$enable_key_screen" = "xyes" ; then
282     AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
283 fi
285 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$enable_key_screen = xyes)
287 dnl Optional screen - lyrics
288 AC_MSG_CHECKING([whether to include the lyrics screen]) 
289 AC_ARG_ENABLE([lyrics-screen], 
290               AS_HELP_STRING([--enable-lyrics-screen],
291                 [Enable lyrics screen @<:@default=no@:>@]),
292         [enable_lyrics_screen=$enableval],
293         [enable_lyrics_screen=no])
295 case "$host_os" in
296 mingw32* | windows*)
297         AS_IF([ test "x$enable_lyrics_screen" = xyes ],
298                 [AC_MSG_ERROR([Lyrics screen is not yet compatible with windows.])
299                 ])
300 esac
302 if test "x$enable_lyrics_screen" = "xyes" ; then
303     AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
304 fi
306 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$enable_lyrics_screen = xyes)
308 AC_MSG_RESULT([$enable_lyrics_screen])
310 AC_ARG_WITH([lyrics-plugin-dir],
311         AS_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
312                        [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
313        [lyrics_plugin_dir=$withval],
314        [lyrics_plugin_dir=""])
315 if test "x${lyrics_plugin_dir}" = "x"; then
316     if test "x${prefix}" = "xNONE"; then
317         lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
318     else
319         lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
320     fi
321 fi
322 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
323                   [Directory to search for lyrics plugins])
324 AC_SUBST(lyrics_plugin_dir)
326 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$enable_lyrics_screen = xyes)
327 AM_CONDITIONAL(ENABLE_SCREEN_TEXT, test x$enable_lyrics_screen = xyes)
329 dnl Optional screen - outputs
330 AC_MSG_CHECKING([whether to include the outputs screen])
331 AC_ARG_ENABLE([outputs-screen],
332         AS_HELP_STRING([--enable-outputs-screen],
333                 [Enable outputs screen @<:@default=yes@:>@]),,
334         [enable_outputs_screen=$disable_mini])
336 if test "x$enable_outputs_screen" = "xyes" ; then
337         AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
338 fi
340 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes)
341 AC_MSG_RESULT([$enable_outputs_screen])
344 dnl
345 dnl Windows OS Resource File
346 dnl
347 AC_SUBST(VERSION_MAJOR)
348 AC_SUBST(VERSION_MINOR)
349 AC_SUBST(VERSION_REVISION)
350 AC_SUBST(VERSION_EXTRA)
352 dnl
353 dnl build options
354 dnl
356 AC_ARG_ENABLE(werror,
357         AS_HELP_STRING([--enable-werror],
358                 [Treat warnings as errors @<:@default=no@:>@]),,
359         enable_werror=no)
361 if test "x$enable_werror" = xyes; then
362         AX_APPEND_COMPILE_FLAGS([-Werror])
363 fi
365 AC_ARG_ENABLE(debug,
366         AS_HELP_STRING([--enable-debug],
367                 [Enable debugging @<:@default=no@:>@]),,
368         enable_debug=no)
370 if test "x$enable_debug" = xno; then
371         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
372 fi
374 AC_ARG_ENABLE(test,
375         AS_HELP_STRING([--enable-test],
376                 [build the test programs @<:@default=no@:>@]),,
377         enable_test=$enable_debug)
379 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
381 dnl
382 dnl autogenerated documentation
383 dnl
385 AC_ARG_ENABLE(documentation,
386         AS_HELP_STRING([--enable-documentation],
387                 [build doxygen documentation @<:@default=no@:>@]),,
388         enable_documentation=no)
390 if test x$enable_documentation = xyes; then
391         AC_PATH_PROG(DOXYGEN, doxygen)
392         if test x$DOXYGEN = x; then
393                 AC_MSG_ERROR([doxygen not found])
394         fi
395         AC_SUBST(DOXYGEN)
396 fi
398 AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
400 dnl
401 dnl CFLAGS
402 dnl
404 AC_SUBST(AM_CFLAGS)
406 AX_APPEND_COMPILE_FLAGS([-Wall])
407 AX_APPEND_COMPILE_FLAGS([-Wextra])
408 AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations])
409 AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
410 AX_APPEND_COMPILE_FLAGS([-Wshadow])
411 AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
412 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
413 AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
414 AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
417 dnl
418 dnl Generate output files
419 dnl
421 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
422 AC_OUTPUT(doc/doxygen.conf)