Code

configure.ac: Add proper CFLAG checking and appending
[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 AC_CONFIG_HEADERS([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
46 AC_CANONICAL_HOST
48 case "$host_os" in
49 mingw32* | windows*)
50         LIBS="$LIBS -lws2_32"
51         ;;
52 *)
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         AC_CHECK_FUNC([gethostbyname],
60                 [], 
61                 [AC_CHECK_LIB([nsl],[gethostbyname],[LIBS="$LIBS -lnsl"],
62                 [AC_MSG_ERROR(No UNIX gethostbyname API found)])
63                 ])
64 esac
67 dnl wide character support
68 AC_ARG_ENABLE([wide],
69     AS_HELP_STRING([--enable-wide],
70                 [Enable wide character support]),,
71                    [enable_wide=auto])
74 dnl ncurses
75 AC_ARG_WITH([ncurses],
76             AS_HELP_STRING([--with-ncurses], [compile/link with ncurses library] ),
77             [ncurses=ncurses])
78 AC_ARG_WITH(ncursesw,
79             AS_HELP_STRING([--with-ncursesw], [compile/link with wide-char ncurses library @<:@default@:>@]),
80             [ncurses=ncursesw])
82 if test "x$enable_wide" = "xno"; then
83     if test "x$ncurses" = "xauto"; then
84         dnl select narrow ncurses
85         ncurses=ncurses
86     fi
88     if test "x$ncurses" = "xncursesw"; then
89         AC_MSG_WARN([Narrow ncmpc linking against wide libncurses])
90     fi
91 fi
93 if test "x$ncurses" = "xauto"; then
94         AC_CHECK_LIB([ncursesw], 
95                      [initscr],
96                      [ncurses=ncursesw],
97                      [ncurses=ncurses])
98 fi
100 AC_CHECK_LIB([$ncurses], 
101              [initscr],
102              [LIBS="$LIBS -l$ncurses"], 
103              [AC_MSG_ERROR($ncurses library is required)])
105 if test "x$ncurses" = "xncursesw"; then
106     AC_CHECK_HEADER([ncursesw/ncurses.h],
107                     AC_DEFINE([HAVE_NCURSESW_NCURSES_H], [1], [ncursesw/ncurses.h]),
108                     ,)
109 fi
112 dnl wide character support II
114 if test "x$enable_wide" = "xauto" ; then
115     AC_CHECK_LIB([$ncurses], 
116                  [wget_wch],
117                  [enable_wide=yes],
118                  [enable_wide=no])
119 fi
121 AC_MSG_CHECKING([wide character support])
122 AC_MSG_RESULT([$enable_wide])
124 if test "x$enable_wide" = "xyes" ; then
125     AC_DEFINE([ENABLE_WIDE], [1], [Enable wide character support])
126 fi
128 dnl multi-byte character support
130 AC_ARG_ENABLE([multibyte],
131         AS_HELP_STRING([--disable-multibyte],
132                 [Disable multibyte character support (default: enabled)]),,
133                 [enable_multibyte=$disable_mini])
135 if test x$enable_multibyte = xyes; then
136         AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support])
137 else
138         if test x$enable_wide = xyes; then
139                 AC_MSG_WARN(wide characters without multibyte characters makes little sense)
140         fi
141 fi
143 dnl Check for glib-2.12
144 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.12],,
145         [AC_MSG_ERROR([glib 2.12 is required])])
147 dnl Check for libmpdclient 2.2
148 PKG_CHECK_MODULES([LIBMPDCLIENT], [libmpdclient >= 2.2],,
149         [AC_MSG_ERROR([libmpdclient2 is required])])
152 dnl i18n
154 AC_ARG_ENABLE([locale],
155         AS_HELP_STRING([--disable-locale],
156                 [Disable locale support (default: auto)]),,
157                 [enable_locale=$auto_mini])
159 if test x$enable_locale = xyes; then
160         AC_CHECK_HEADER([locale.h],,
161                 [AC_MSG_ERROR(locale.h is unavailable)])
162 fi
164 if test x$enable_locale = xauto; then
165         AC_CHECK_HEADER([locale.h],
166                 [enable_locale=yes],
167                 [enable_locale=no])
168 fi
170 if test x$enable_locale = xyes; then
171         AC_DEFINE([ENABLE_LOCALE], [1], [Locale support is enabled])
172 fi
174 if test x$enable_mini != xyes; then
175         AM_NLS
176 else
177         USE_NLS=no
178 fi
180 if test x$USE_NLS = xyes; then
181    AM_GLIB_GNU_GETTEXT
182    GETTEXT_PACKAGE=$PACKAGE
183    AC_SUBST(GETTEXT_PACKAGE)
184    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], 
185                       ["${GETTEXT_PACKAGE}"], 
186                       [gettext domain])
187         USE_NLS=$gt_cv_have_gettext
188         if test x$USE_NLS != xyes; then
189      AC_MSG_WARN([NLS support disabled!])
190   fi
191 else
192   AM_PO_SUBDIRS
193 fi
195 dnl enable colors
196 AC_MSG_CHECKING([color support])
197 AC_ARG_ENABLE([colors],
198         AS_HELP_STRING([--enable-colors],
199                 [Enable color support]),,
200         [enable_colors=$disable_mini])
201 AC_MSG_RESULT([$enable_colors])
202 if test "x$enable_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         AS_HELP_STRING([--enable-lirc],
210                 [Enable LIRC support]),,
211         [enable_lirc=no])
212 if test x$enable_lirc = xyes; then
213         PKG_CHECK_MODULES([LIBLIRCCLIENT], [liblircclient0],,
214                 [AC_MSG_ERROR([liblircclient0 not found])])
215         AC_DEFINE([ENABLE_LIRC], [1], [Enable LIRC support])
216 fi
218 AM_CONDITIONAL(ENABLE_LIRC, test x$enable_lirc = xyes)
221 dnl Optional screen - help screen
222 AC_MSG_CHECKING([whether to include the help screen])
223 AC_ARG_ENABLE([help-screen],
224         AS_HELP_STRING([--enable-help-screen],
225                 [Enable the help screen @<:@default=yes@:>@]),,
226         [enable_help_screen=$disable_mini])
227 AC_MSG_RESULT([$enable_help_screen])
228 if test "x$enable_help_screen" = "xyes" ; then
229         AC_DEFINE(ENABLE_HELP_SCREEN, 1, [Enable the help screen])
230 fi
232 AM_CONDITIONAL(ENABLE_HELP_SCREEN, test x$enable_help_screen = xyes)
234 dnl Optional - curses getmouse support
235 AC_MSG_CHECKING([whether to include mouse support])
236 AC_ARG_ENABLE([mouse], 
237               AS_HELP_STRING([--enable-mouse],
238                 [Enable curses getmouse support @<:@default=yes@:>@]),,
239         [enable_mouse=$disable_mini])
240 AC_MSG_RESULT([$enable_mouse])
241 if test "x$enable_mouse" = "xyes" ; then
242    AC_CHECK_LIB([$ncurses], 
243                 [getmouse],
244                 [AC_DEFINE([HAVE_GETMOUSE], [1], [$ncurses - getmouse()])],
245                 [])
246 fi
248 dnl Optional screen - artist
249 AC_MSG_CHECKING([whether to include the artist screen])
250 AC_ARG_ENABLE([artist-screen], 
251               AS_HELP_STRING([--enable-artist-screen],
252                 [Enable artist screen @<:@default=yes@:>@]),,
253         [enable_artist_screen=$disable_mini])
254 AC_MSG_RESULT([$enable_artist_screen])
255 if test "x$enable_artist_screen" = "xyes" ; then
256     AC_DEFINE(ENABLE_ARTIST_SCREEN, 1, [Enable artist screen])
257 fi
259 AM_CONDITIONAL(ENABLE_ARTIST_SCREEN, test x$enable_artist_screen = xyes)
261 dnl Optional screen - search
262 AC_MSG_CHECKING([whether to include the search screen])
263 AC_ARG_ENABLE([search-screen], 
264               AS_HELP_STRING([--enable-search-screen],
265                 [Enable search screen (EXPERIMENTAL) @<:@default=yes@:>@]),,
266         [enable_search_screen=$disable_mini])
267 AC_MSG_RESULT([$enable_search_screen])
268 if test "x$enable_search_screen" = "xyes" ; then
269     AC_DEFINE(ENABLE_SEARCH_SCREEN, 1, [Enable search screen])
270 fi
272 AM_CONDITIONAL(ENABLE_SEARCH_SCREEN, test x$enable_search_screen = xyes)
274 dnl Optional screen - song viewer
275 AC_MSG_CHECKING([whether to include the song viewer screen])
276 AC_ARG_ENABLE([song-screen],
277         AS_HELP_STRING([--enable-song-screen],
278                 [Enable song viewer screen @<:@default=yes@:>@]),,
279         [enable_song_screen=$disable_mini])
280 AC_MSG_RESULT([$enable_song_screen])
281 if test "x$enable_song_screen" = "xyes" ; then
282         AC_DEFINE(ENABLE_SONG_SCREEN, 1, [Enable song viewer screen])
283 fi
285 AM_CONDITIONAL(ENABLE_SONG_SCREEN, test x$enable_song_screen = xyes)
286   
287 dnl Optional screen - key editor
288 AC_MSG_CHECKING([whether to include the key editor screen])
289 AC_ARG_ENABLE([key-screen], 
290               AS_HELP_STRING([--enable-key-screen],
291                 [Enable key editor screen @<:@default=yes@:>@]),,
292         [enable_key_screen=$disable_mini])
293 AC_MSG_RESULT([$enable_key_screen])
294 if test "x$enable_key_screen" = "xyes" ; then
295     AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen])
296 fi
298 AM_CONDITIONAL(ENABLE_KEYDEF_SCREEN, test x$enable_key_screen = xyes)
300 dnl Optional screen - lyrics
301 AC_MSG_CHECKING([whether to include the lyrics screen]) 
302 AC_ARG_ENABLE([lyrics-screen], 
303               AS_HELP_STRING([--enable-lyrics-screen],
304                 [Enable lyrics screen @<:@default=no@:>@]),,
305         [enable_lyrics_screen=no])
306 if test "x$enable_lyrics_screen" = "xyes" ; then
307     AC_DEFINE(ENABLE_LYRICS_SCREEN, 1, [Enable lyrics screen])
308 fi
310 AM_CONDITIONAL(ENABLE_LYRICS_SCREEN, test x$enable_lyrics_screen = xyes)
312 AC_MSG_RESULT([$enable_lyrics_screen])
314 AC_ARG_WITH([lyrics-plugin-dir],
315         AS_HELP_STRING([[--with-lyrics-plugin-dir[=DIRECTORY]]],
316                        [Directory where lyrics plugins are stored @<:@default=PREFIX/lib/ncmpc/lyrics@:>@]),
317        [lyrics_plugin_dir=$withval],
318        [lyrics_plugin_dir=""])
319 if test "x${lyrics_plugin_dir}" = "x"; then
320     if test "x${prefix}" = "xNONE"; then
321         lyrics_plugin_dir="${ac_default_prefix}/lib/ncmpc/lyrics"
322     else
323         lyrics_plugin_dir="${prefix}/lib/ncmpc/lyrics"
324     fi
325 fi
326 AC_DEFINE_UNQUOTED([LYRICS_PLUGIN_DIR], ["$lyrics_plugin_dir"],
327                   [Directory to search for lyrics plugins])
328 AC_SUBST(lyrics_plugin_dir)
330 AM_CONDITIONAL(ENABLE_PLUGIN_LIBRARY, test x$enable_lyrics_screen = xyes)
331 AM_CONDITIONAL(ENABLE_SCREEN_TEXT, test x$enable_lyrics_screen = xyes)
333 dnl Optional screen - outputs
334 AC_MSG_CHECKING([whether to include the outputs screen])
335 AC_ARG_ENABLE([outputs-screen],
336         AS_HELP_STRING([--enable-outputs-screen],
337                 [Enable outputs screen @<:@default=yes@:>@]),,
338         [enable_outputs_screen=$disable_mini])
339 if test "x$enable_outputs_screen" = "xyes" ; then
340         AC_DEFINE(ENABLE_OUTPUTS_SCREEN, 1, [Enable outputs screen])
341 fi
343 AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes)
344 AC_MSG_RESULT([$enable_outputs_screen])
348 dnl
349 dnl build options
350 dnl
352 AC_ARG_ENABLE(werror,
353         AS_HELP_STRING([--enable-werror],
354                 [Treat warnings as errors (default: disabled)]),,
355         enable_werror=no)
357 if test "x$enable_werror" = xyes; then
358         AX_APPEND_COMPILE_FLAGS([-Werror])
359 fi
361 AC_ARG_ENABLE(debug,
362         AS_HELP_STRING([--enable-debug],
363                 [Enable debugging (default: disabled)]),,
364         enable_debug=no)
366 if test "x$enable_debug" = xno; then
367         AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
368 fi
370 AC_ARG_ENABLE(test,
371         AS_HELP_STRING([--enable-test],
372                 [build the test programs @<:@default=no@:>@]),,
373         enable_test=$enable_debug)
375 AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
378 dnl
379 dnl CFLAGS
380 dnl
382 AC_SUBST(AM_CFLAGS)
384 AX_APPEND_COMPILE_FLAGS([-Wall])
385 AX_APPEND_COMPILE_FLAGS([-Wextra])
386 AX_APPEND_COMPILE_FLAGS([-Wno-deprecated-declarations])
387 AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])
388 AX_APPEND_COMPILE_FLAGS([-Wshadow])
389 AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
390 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes])
391 AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
392 AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
395 dnl
396 dnl Generate output files
397 dnl
399 AC_CONFIG_FILES([Makefile po/Makefile.in po/Makefile])
400 AC_OUTPUT