Code

5324d3078f2987a62cd4e9cc121c2afcd1662585
[ncmpc.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT(ncmpc, 0.20~git, 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 AM_CONFIG_HEADER([config.h])
7 AC_CONFIG_MACRO_DIR([m4])
9 dnl Check for programs
10 AC_PROG_CC_C99
11 AC_PROG_INSTALL
13 dnl =======================================================
14 dnl initialize variables
15 dnl =======================================================
17 dnl i18n
18 ALL_LINGUAS=`grep -v '^\#' po/LINGUAS`
20 set -- $CFLAGS
23 dnl
24 dnl ncmpc-mini
25 dnl
27 AC_ARG_ENABLE(mini,
28     AS_HELP_STRING([--enable-mini],
29                 [Build ncmpc-mini, i.e. without all optional features (default: disabled)]),,
30     [enable_mini=no])
32 AM_CONDITIONAL(NCMPC_MINI, test x$enable_mini = xyes)
33 if test "x$enable_mini" = xyes; then
34     AC_DEFINE([NCMPC_MINI], [1], [Build ncmpc-mini, which disables lots of features])
35     auto=no
36     disable_mini=no
37     auto_mini=no
38     ncurses=ncurses
39 else
40     auto=auto
41     disable_mini=yes
42     auto_mini=auto
43     ncurses=auto
44 fi
47 dnl
48 dnl Check for libraries
49 dnl
51 dnl Try to find the socket functions
52 AC_CHECK_FUNC([socket],
53               [], 
54               [AC_CHECK_LIB([socket],[socket],[LIBS="$LIBS -lsocket"],
55                             [AC_MSG_ERROR(No UNIX socket API found)])
56               ])
58 dnl Try to find the gethostbyname functions
59 AC_CHECK_FUNC([gethostbyname],
60               [], 
61               [AC_CHECK_LIB([nsl],[gethostbyname],[LIBS="$LIBS -lnsl"],
62                             [AC_MSG_ERROR(No UNIX gethostbyname API found)])
63               ])
66 dnl wide character support
67 AC_ARG_ENABLE([wide],
68     AS_HELP_STRING([--enable-wide],
69                 [Enable wide character support]),,
70                    [enable_wide=auto])
73 dnl ncurses
74 AC_ARG_WITH([ncurses],
75             AS_HELP_STRING([--with-ncurses], [compile/link with ncurses library] ),
76             [ncurses=ncurses])
77 AC_ARG_WITH(ncursesw,
78             AS_HELP_STRING([--with-ncursesw], [compile/link with wide-char ncurses library @<:@default@:>@]),
79             [ncurses=ncursesw])
81 if test "x$enable_wide" = "xno"; then
82     if test "x$ncurses" = "xauto"; then
83         dnl select narrow ncurses
84         ncurses=ncurses
85     fi
87     if test "x$ncurses" = "xncursesw"; then
88         AC_MSG_WARN([Narrow ncmpc linking against wide libncurses])
89     fi
90 fi
92 if test "x$ncurses" = "xauto"; then
93         AC_CHECK_LIB([ncursesw], 
94                      [initscr],
95                      [ncurses=ncursesw],
96                      [ncurses=ncurses])
97 fi
99 AC_CHECK_LIB([$ncurses], 
100              [initscr],
101              [LIBS="$LIBS -l$ncurses"], 
102              [AC_MSG_ERROR($ncurses library is required)])
104 if test "x$ncurses" = "xncursesw"; then
105     AC_CHECK_HEADER([ncursesw/ncurses.h],
106                     AC_DEFINE([HAVE_NCURSESW_NCURSES_H], [1], [ncursesw/ncurses.h]),
107                     ,)
108 fi
111 dnl wide character support II
113 if test "x$enable_wide" = "xauto" ; then
114     AC_CHECK_LIB([$ncurses], 
115                  [wget_wch],
116                  [enable_wide=yes],
117                  [enable_wide=no])
118 fi
120 AC_MSG_CHECKING([wide character support])
121 AC_MSG_RESULT([$enable_wide])
123 if test "x$enable_wide" = "xyes" ; then
124     AC_DEFINE([ENABLE_WIDE], [1], [Enable wide character support])
125 fi
127 dnl multi-byte character support
129 AC_ARG_ENABLE([multibyte],
130         AS_HELP_STRING([--disable-multibyte],
131                 [Disable multibyte character support (default: enabled)]),,
132                 [enable_multibyte=$disable_mini])
134 if test x$enable_multibyte = xyes; then
135         AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support])
136 else
137         if test x$enable_wide = xyes; then
138                 AC_MSG_WARN(wide characters without multibyte characters makes little sense)
139         fi
140 fi
142 dnl Check for glib-2.12
143 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.12],,
144         [AC_MSG_ERROR([glib 2.12 is required])])
146 dnl Check for libmpdclient 2.2
147 PKG_CHECK_MODULES([LIBMPDCLIENT], [libmpdclient >= 2.2],,
148         [AC_MSG_ERROR([libmpdclient2 is required])])
151 dnl i18n
153 AC_ARG_ENABLE([locale],
154         AS_HELP_STRING([--disable-locale],
155                 [Disable locale support (default: auto)]),,
156                 [enable_locale=$auto_mini])
158 if test x$enable_locale = xyes; then
159         AC_CHECK_HEADER([locale.h],,
160                 [AC_MSG_ERROR(locale.h is unavailable)])
161 fi
163 if test x$enable_locale = xauto; then
164         AC_CHECK_HEADER([locale.h],
165                 [enable_locale=yes],
166                 [enable_locale=no])
167 fi
169 if test x$enable_locale = xyes; then
170         AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
171 fi
173 if test x$enable_mini != xyes; then
174         AM_NLS
175 else
176         USE_NLS=no
177 fi
179 if test x$USE_NLS = xyes; then
180    AM_GLIB_GNU_GETTEXT
181    GETTEXT_PACKAGE=$PACKAGE
182    AC_SUBST(GETTEXT_PACKAGE)
183    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], 
184                       ["${GETTEXT_PACKAGE}"], 
185                       [gettext domain])
186         USE_NLS=$gt_cv_have_gettext
187         if test x$USE_NLS != xyes; then
188      AC_MSG_WARN([NLS support disabled!])
189   fi
190 else
191   AM_PO_SUBDIRS
192 fi
194 dnl enable colors
195 AC_MSG_CHECKING([color support])
196 AC_ARG_ENABLE([colors],
197         AS_HELP_STRING([--enable-colors],
198                 [Enable color support]),,
199         [enable_colors=$disable_mini])
200 AC_MSG_RESULT([$enable_colors])
201 if test "x$enable_colors" = "xyes" ; then
202     AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])
203 fi
205 dnl test for LIRC support
207 AC_ARG_ENABLE([lirc],
208         AS_HELP_STRING([--enable-lirc],
209                 [Enable LIRC support]),,
210         [enable_lirc=no])
211 if test x$enable_lirc = xyes; then
212         PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
213                 [AC_MSG_ERROR([liblircclient0 not found])])
214         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
215 fi
217 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
220 dnl Optional screen - help screen
221 AC_MSG_CHECKING([whether to include the help screen])
222 AC_ARG_ENABLE([help-screen],
223         AS_HELP_STRING([--enable-help-screen],
224                 [Enable the help screen @<:@default=yes@:>@]),,
225         [enable_help_screen=$disable_mini])
226 AC_MSG_RESULT([$enable_help_screen])
227 if test "x$enable_help_screen" = "xyes" ; then
228         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
229 fi
231 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
233 dnl Optional - curses getmouse support
234 AC_MSG_CHECKING([whether to include mouse support])
235 AC_ARG_ENABLE([mouse], 
236               AS_HELP_STRING([--enable-mouse],
237                 [Enable curses getmouse support @<:@default=yes@:>@]),,
238         [enable_mouse=$disable_mini])
239 AC_MSG_RESULT([$enable_mouse])
240 if test "x$enable_mouse" = "xyes" ; then
241    AC_CHECK_LIB([$ncurses], 
242                 [getmouse],
243                 [AC_DEFINE([HAVE_GETMOUSE], [1], [$ncurses - getmouse()])],
244                 [])
245 fi
247 dnl Optional screen - artist
248 AC_MSG_CHECKING([whether to include the artist screen])
249 AC_ARG_ENABLE([artist-screen], 
250               AS_HELP_STRING([--enable-artist-screen],
251                 [Enable artist screen @<:@default=yes@:>@]),,
252         [enable_artist_screen=$disable_mini])
253 AC_MSG_RESULT([$enable_artist_screen])
254 if test "x$enable_artist_screen" = "xyes" ; then
255     AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
256 fi
258 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$enable_artist_screen = xyes)
260 dnl Optional screen - search
261 AC_MSG_CHECKING([whether to include the search screen])
262 AC_ARG_ENABLE([search-screen], 
263               AS_HELP_STRING([--enable-search-screen],
264                 [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),,
265         [enable_search_screen=$disable_mini])
266 AC_MSG_RESULT([$enable_search_screen])
267 if test "x$enable_search_screen" = "xyes" ; then
268     AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
269 fi
271 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$enable_search_screen = xyes)
273 dnl Optional screen - song viewer
274 AC_MSG_CHECKING([whether to include the song viewer screen])
275 AC_ARG_ENABLE([song-screen],
276         AS_HELP_STRING([--enable-song-screen],
277                 [Enable song viewer screen @<:@default=yes@:>@]),,
278         [enable_song_screen=$disable_mini])
279 AC_MSG_RESULT([$enable_song_screen])
280 if test "x$enable_song_screen" = "xyes" ; then
281         AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
282 fi
284 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$enable_song_screen = xyes)
285   
286 dnl Optional screen - key editor
287 AC_MSG_CHECKING([whether to include the key editor screen])
288 AC_ARG_ENABLE([key-screen], 
289               AS_HELP_STRING([--enable-key-screen],
290                 [Enable key editor screen @<:@default=yes@:>@]),,
291         [enable_key_screen=$disable_mini])
292 AC_MSG_RESULT([$enable_key_screen])
293 if test "x$enable_key_screen" = "xyes" ; then
294     AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
295 fi
297 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$enable_key_screen = xyes)
299 dnl Optional screen - lyrics
300 AC_MSG_CHECKING([whether to include the lyrics screen]) 
301 AC_ARG_ENABLE([lyrics-screen], 
302               AS_HELP_STRING([--enable-lyrics-screen],
303                 [Enable lyrics screen @<:@default=no@:>@]),,
304         [enable_lyrics_screen=no])
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)
330 AM_CONDITIONAL(ENABLE_SCREEN_TEXT, test x$enable_lyrics_screen = xyes)
332 dnl Optional screen - outputs
333 AC_MSG_CHECKING([whether to include the outputs screen])
334 AC_ARG_ENABLE([outputs-screen],
335         AS_HELP_STRING([--enable-outputs-screen],
336                 [Enable outputs screen @<:@default=yes@:>@]),,
337         [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])
347 dnl
348 dnl build options
349 dnl
351 AC_ARG_ENABLE(werror,
352         AS_HELP_STRING([--enable-werror],
353                 [Treat warnings as errors (default: disabled)]),,
354         enable_werror=no)
356 if test "x$enable_werror" = xyes; then
357         CHECK_CFLAG([-Werror])
358 fi
360 AC_ARG_ENABLE(debug,
361         AS_HELP_STRING([--enable-debug],
362                 [Enable debugging (default: disabled)]),,
363         enable_debug=no)
365 if test "x$enable_debug" = xno; then
366         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
367 fi
369 AC_ARG_ENABLE(test,
370         AS_HELP_STRING([--enable-test],
371                 [build the test programs @<:@default=no@:>@]),,
372         enable_test=$enable_debug)
374 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
377 dnl
378 dnl CFLAGS
379 dnl
381 AC_SUBST(AM_CFLAGS)
383 CHECK_CFLAG([-Wall])
384 CHECK_CFLAG([-Wextra])
385 CHECK_CFLAG([-Wno-deprecated-declarations])
386 CHECK_CFLAG([-Wmissing-prototypes])
387 CHECK_CFLAG([-Wshadow])
388 CHECK_CFLAG([-Wpointer-arith])
389 CHECK_CFLAG([-Wstrict-prototypes])
390 CHECK_CFLAG([-Wcast-qual])
391 CHECK_CFLAG([-Wwrite-strings])
394 dnl
395 dnl Generate output files
396 dnl
398 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
399 AC_OUTPUT