Code

configure.ac: use AC_CONFIG_AUX_DIR
[ncmpc.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT(ncmpc, 0.13~git, max@duempel.org)
3 AC_CONFIG_SRCDIR([src/main.c])
4 AC_CONFIG_AUX_DIR(build)
5 AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2])
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="es da de fr gl no ru sk sv hu"
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=$enableval],
31     [enable_mini=no])
33 AM_CONDITIONAL(NCMPC_MINI, test x$enable_mini = xyes)
34 if test "x$enable_mini" = xyes; then
35     AC_DEFINE([NCMPC_MINI], [1], [Build ncmpc-mini, which disables lots of features])
36     auto=no
37     disable_mini=no
38     auto_mini=no
39     ncurses=ncurses
40 else
41     auto=auto
42     disable_mini=yes
43     auto_mini=auto
44     ncurses=auto
45 fi
48 dnl
49 dnl Check for libraries
50 dnl
52 dnl Try to find the socket functions
53 AC_CHECK_FUNC([socket],
54               [], 
55               [AC_CHECK_LIB([socket],[socket],[LIBS="$LIBS -lsocket"],
56                             [AC_MSG_ERROR(No UNIX socket API found)])
57               ])
59 dnl Try to find the gethostbyname functions
60 AC_CHECK_FUNC([gethostbyname],
61               [], 
62               [AC_CHECK_LIB([nsl],[gethostbyname],[LIBS="$LIBS -lnsl"],
63                             [AC_MSG_ERROR(No UNIX gethostbyname API found)])
64               ])
67 dnl wide character support
68 AC_ARG_ENABLE([wide],
69     AC_HELP_STRING([--enable-wide],
70                    [Enable wide character support]),
71                    [enable_wide=$enableval],
72                    [enable_wide=auto])
75 dnl ncurses
76 AC_ARG_WITH([ncurses],
77             AC_HELP_STRING([--with-ncurses], [compile/link with ncurses library] ),
78             [ncurses=ncurses])
79 AC_ARG_WITH(ncursesw,
80             AC_HELP_STRING([--with-ncursesw], [compile/link with wide-char ncurses library @<:@default@:>@]),
81             [ncurses=ncursesw])
83 if test "x$enable_wide" = "xno"; then
84     if test "x$ncurses" = "xauto"; then
85         dnl select narrow ncurses
86         ncurses=ncurses
87     fi
89     if test "x$ncurses" = "xncursesw"; then
90         AC_MSG_WARN([Narrow ncmpc linking against wide libncurses])
91     fi
92 fi
94 if test "x$ncurses" = "xauto"; then
95         AC_CHECK_LIB([ncursesw], 
96                      [initscr],
97                      [ncurses=ncursesw],
98                      [ncurses=ncurses])
99 fi
101 AC_CHECK_LIB([$ncurses], 
102              [initscr],
103              [LIBS="$LIBS -l$ncurses"], 
104              [AC_MSG_ERROR($ncurses library is required)])
106 if test "x$ncurses" = "xncursesw"; then
107     AC_CHECK_HEADER([ncursesw/ncurses.h],
108                     AC_DEFINE([HAVE_NCURSESW_NCURSES_H], [1], [ncursesw/ncurses.h]),
109                     ,)
110 fi
113 dnl wide character support II
115 if test "x$enable_wide" = "xauto" ; then
116     AC_CHECK_LIB([$ncurses], 
117                  [wget_wch],
118                  [enable_wide=yes],
119                  [enable_wide=no])
120 fi
122 AC_MSG_CHECKING([wide character support])
123 AC_MSG_RESULT([$enable_wide])
125 if test "x$enable_wide" = "xyes" ; then
126     AC_DEFINE([ENABLE_WIDE], [1], [Enable wide character support])
127 fi
129 dnl multi-byte character support
131 AC_ARG_ENABLE([multibyte],
132         AC_HELP_STRING([--disable-multibyte],
133                 [Disable multibyte character support (default: enabled)]),
134                 [enable_multibyte=$enableval],
135                 [enable_multibyte=$disable_mini])
137 if test x$enable_multibyte = xyes; then
138         AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support])
139 else
140         if test x$enable_wide = xyes; then
141                 AC_MSG_WARN(wide characters without multibyte characters makes little sense)
142         fi
143 fi
145 dnl Check for glib-2.4
146 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.4],,
147         [AC_MSG_ERROR([glib 2.4 is required])])
150 dnl i18n
152 AC_ARG_ENABLE([locale],
153         AC_HELP_STRING([--disable-locale],
154                 [Disable locale support (default: auto)]),
155                 [enable_locale=$enableval],
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         AC_HELP_STRING([--enable-colors],
198                        [Enable color support]),
199                        [use_colors=$enableval], 
200         [use_colors=$disable_mini])
201 AC_MSG_RESULT([$use_colors])
202 if test "x$use_colors" = "xyes" ; then
203     AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])
204 fi
206 dnl test for LIRC support
208 AC_ARG_ENABLE([lirc],
209         AC_HELP_STRING([--enable-lirc],
210                 [Enable LIRC support]),
211         [enable_lirc=$enableval],
212         [enable_lirc=no])
213 if test x$enable_lirc = xyes; then
214         PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
215                 [AC_MSG_ERROR([liblircclient0 not found])])
216         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
217 fi
219 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
222 dnl Optional screen - help screen
223 AC_MSG_CHECKING([whether to include the help screen])
224 AC_ARG_ENABLE([help-screen],
225         AS_HELP_STRING([--enable-help-screen],
226                 [Enable the help screen @<:@default=yes@:>@]),
227         [help_screen="$enableval"],
228         [help_screen=$disable_mini])
229 AC_MSG_RESULT([$help_screen])
230 if test "x$help_screen" = "xyes" ; then
231         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
232 fi
234 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$help_screen = xyes)
236 dnl Optional screen - browse screen
237 #AC_MSG_CHECKING([whether to include the browse screen])r
238 #AC_ARG_ENABLE([browse-screen], 
239 #              AC_HELP_STRING([--enable-browse-screen],
240 #                            [Enable the browse screen @<:@default=yes@:>@]),
241 #             [browse_screen="$enableval"],
242 #             [browse_screen=yes])
243 #AC_MSG_RESULT([$browse_screen])
244 #if test "x$browse_screen" = "xyes" ; then
245 #   AC_DEFINE(ENABLE_BROWSE_SCREEN, 1, [Enable the browse screen])
246 #fi
248 dnl Optional - curses getmouse support
249 AC_MSG_CHECKING([whether to include mouse support])
250 AC_ARG_ENABLE([mouse], 
251               AC_HELP_STRING([--enable-mouse],
252                              [Enable curses getmouse support @<:@default=yes@:>@]),
253               [getmouse="$enableval"],
254               [getmouse=$disable_mini])
255 AC_MSG_RESULT([$getmouse])
256 if test "x$getmouse" = "xyes" ; then
257    AC_CHECK_LIB([$ncurses], 
258                 [getmouse],
259                 [AC_DEFINE([HAVE_GETMOUSE], [1], [$ncurses - getmouse()])],
260                 [])
261 fi
263 dnl Optional screen - artist
264 AC_MSG_CHECKING([whether to include the artist screen])
265 AC_ARG_ENABLE([artist-screen], 
266               AC_HELP_STRING([--enable-artist-screen],
267                              [Enable artist screen @<:@default=yes@:>@]),
268               [artist_screen="$enableval"],
269               [artist_screen=$disable_mini])
270 AC_MSG_RESULT([$artist_screen])
271 if test "x$artist_screen" = "xyes" ; then
272     AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
273 fi
275 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$artist_screen = xyes)
277 dnl Optional screen - search
278 AC_MSG_CHECKING([whether to include the search screen])
279 AC_ARG_ENABLE([search-screen], 
280               AC_HELP_STRING([--enable-search-screen],
281                              [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),
282               [search_screen="$enableval"],
283               [search_screen=$disable_mini])
284 AC_MSG_RESULT([$search_screen])
285 if test "x$search_screen" = "xyes" ; then
286     AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
287 fi
289 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$search_screen = xyes)
291 dnl Optional screen - song viewer
292 AC_MSG_CHECKING([whether to include the song viewer screen])
293 AC_ARG_ENABLE([song-screen],
294         AC_HELP_STRING([--enable-song-screen],
295                 [Enable song viewer screen @<:@default=yes@:>@]),
296         [song_screen="$enableval"],
297         [song_screen=$disable_mini])
298 AC_MSG_RESULT([$song_screen])
299 if test "x$song_screen" = "xyes" ; then
300         AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
301 fi
303 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$song_screen = xyes)
304   
305 dnl Optional screen - key editor
306 AC_MSG_CHECKING([whether to include the key editor screen])
307 AC_ARG_ENABLE([key-screen], 
308               AC_HELP_STRING([--enable-key-screen],
309                              [Enable key editor screen @<:@default=yes@:>@]),
310               [keydef_screen="$enableval"],
311               [keydef_screen=$disable_mini])
312 AC_MSG_RESULT([$keydef_screen])
313 if test "x$keydef_screen" = "xyes" ; then
314     AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
315 fi
317 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$keydef_screen = xyes)
319 dnl Optional screen - lyrics
320 AC_MSG_CHECKING([whether to include the lyrics screen]) 
321 AC_ARG_ENABLE([lyrics-screen], 
322               AC_HELP_STRING([--enable-lyrics-screen],
323                              [Enable lyrics screen @<:@default=no@:>@]),
324               [lyrics_screen="$enableval"],
325               [lyrics_screen=no])       
326 if test "x$lyrics_screen" = "xyes" ; then
327     AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
328 fi
330 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$lyrics_screen = xyes)
332 AC_MSG_RESULT([$lyrics_screen])
334 AC_ARG_WITH([lyrics-plugin-dir],
335         AC_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
336                        [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
337        [lyrics_plugin_dir=$withval],
338        [lyrics_plugin_dir=""])
339 if test "x${lyrics_plugin_dir}" = "x"; then
340     if test "x${prefix}" = "xNONE"; then
341         lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
342     else
343         lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
344     fi
345 fi
346 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
347                   [Directory to search for lyrics plugins])
348 AC_SUBST(lyrics_plugin_dir)
350 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$lyrics_screen = xyes)
351 AM_CONDITIONAL(ENABLE_SCREEN_TEXT, test x$lyrics_screen = xyes)
353 dnl Optional screen - outputs
354 AC_MSG_CHECKING([whether to include the outputs screen])
355 AC_ARG_ENABLE([outputs-screen],
356         AC_HELP_STRING([--enable-outputs-screen],
357                 [Enable outputs screen @<:@default=yes@:>@]),
358         [outputs_screen=$enableval],
359         [outputs_screen=$disable_mini])
360 if test "x$outputs_screen" = "xyes" ; then
361         AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
362 fi
364 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$outputs_screen = xyes)
366 dnl Default host
367 AC_MSG_CHECKING([for default MPD host])
368 AC_ARG_WITH([default-host],
369             AC_HELP_STRING([--with-default-host=ARG],
370                            [Default MPD host @<:@localhost@:>@]),
371             [DEFAULT_HOST="$withval"],
372             [DEFAULT_HOST="localhost"])
373 AC_MSG_RESULT([$DEFAULT_HOST])
374 AC_DEFINE_UNQUOTED([DEFAULT_HOST], ["$DEFAULT_HOST"], [Default MPD host])
376 dnl Default port
377 AC_MSG_CHECKING([for default MPD port])
378 AC_ARG_WITH([default-port],
379             AC_HELP_STRING([--with-default-port=ARG],
380                            [Default port @<:@6600@:>@]),
381             [DEFAULT_PORT="$withval"],
382             [DEFAULT_PORT="6600"])
383 AC_MSG_RESULT([$DEFAULT_PORT])
384 AC_DEFINE_UNQUOTED([DEFAULT_PORT],     [$DEFAULT_PORT],   [Default MPD port])
385 AC_DEFINE_UNQUOTED([DEFAULT_PORT_STR], ["$DEFAULT_PORT"], [Default MPD port])
387 dnl Default timedisplay type
388 AC_MSG_CHECKING([for default timedisplay type])
389 AC_ARG_WITH([default-timedisplay_type],
390             AC_HELP_STRING([--with-default-timedisplay_type=ARG],
391                            [default_timedisplay]),
392             [DEFAULT_TIMEDISPLAY_TYPE="$withval"],
393             [DEFAULT_TIMEDISPLAY_TYPE="elapsed"])
394 AC_MSG_RESULT([$DEFAULT_TIMEDISPLAY_TYPE])
395 AC_DEFINE_UNQUOTED([DEFAULT_TIMEDISPLAY_TYPE], ["$DEFAULT_TIMEDISPLAY_TYPE"], [Default way to display time, either 'elapsed' or 'remaining'])
398 dnl
399 dnl build options
400 dnl
402 AC_ARG_ENABLE(werror,
403         AS_HELP_STRING([--enable-werror],
404                 [Treat warnings as errors (default: disabled)]),
405         ENABLE_WERROR=$enableval,
406         ENABLE_WERROR=no)
408 if test "x$ENABLE_WERROR" = xyes; then
409         AM_CFLAGS="$AM_CFLAGS -Werror"
410 fi
412 AC_ARG_ENABLE(debug,
413         AS_HELP_STRING([--enable-debug],
414                 [Enable debugging (default: disabled)]),
415         ENABLE_DEBUG=$enableval,
416         ENABLE_DEBUG=no)
418 if test "x$ENABLE_DEBUG" = xno; then
419         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
420 fi
423 dnl
424 dnl CFLAGS
425 dnl
427 AC_SUBST(AM_CFLAGS)
429 CHECK_CFLAG([-Wall])
430 CHECK_CFLAG([-Wextra])
431 CHECK_CFLAG([-Wno-deprecated-declarations])
432 CHECK_CFLAG([-Wmissing-prototypes])
433 CHECK_CFLAG([-Wdeclaration-after-statement])
434 CHECK_CFLAG([-Wshadow])
435 CHECK_CFLAG([-Wpointer-arith])
436 CHECK_CFLAG([-Wstrict-prototypes])
437 CHECK_CFLAG([-Wcast-qual])
438 CHECK_CFLAG([-Wwrite-strings])
441 dnl
442 dnl Generate output files
443 dnl
445 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in po/Makefile])
446 AC_OUTPUT