aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 67e2cb1f686e7d9a174e089a02bb3ee60d3432cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
AC_PREREQ(2.60)
AC_INIT(mpd, 0.15~git, musicpd-dev-team@lists.sourceforge.net)
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])

AC_DEFINE(PROTOCOL_VERSION, "0.15.0", [The mpd protocol version])


dnl
dnl programs
dnl

AC_PROG_CC_C99
AC_PROG_INSTALL
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG


dnl
dnl declare variables
dnl

AC_SUBST(MPD_LIBS)
AC_SUBST(MPD_CFLAGS)
MPD_LIBS=""
MPD_CFLAGS=""


dnl
dnl OS specific defaults
dnl

case "$host" in
*-mingw32* | *-windows*)
	MPD_LIBS="$MPD_LIBS -lws2_32"
	;;
esac

if test -z "$prefix" || test "x$prefix" = xNONE; then
	local_lib=
	local_include=

	# aren't autotools supposed to be smart enough to figure this out?  oh
	# well, the git-core Makefile managed to do some of the work for us :)
	case "$host_os" in
	darwin*)
		local_lib='/sw/lib /opt/local/lib'
		local_include='/sw/include /opt/local/include'
		;;
	freebsd* | openbsd*)
		local_lib=/usr/local/lib
		local_include=/usr/local/include
		;;
	netbsd*)
		local_lib=/usr/pkg/lib
		local_include=/usr/pkg/include
		LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/pkg/lib"
		;;
	esac

	for d in $local_lib; do
		if test -d "$d"; then
			LDFLAGS="$LDFLAGS -L$d"
			break
		fi
	done
	for d in $local_include; do
		if test -d "$d"; then
			CFLAGS="$CFLAGS -I$d"
			break
		fi
	done
fi


dnl
dnl libc features
dnl

AC_CHECK_FUNCS(syslog)
if test $ac_cv_func_syslog = no; then
	# syslog is not in the default libraries.  See if it's in some other.
	for lib in bsd socket inet; do
		AC_CHECK_LIB($lib, syslog,
			[AC_DEFINE(HAVE_SYSLOG)
			LIBS="$LIBS -l$lib"; break])
	done
fi

AC_CHECK_LIB(socket,socket,MPD_LIBS="$MPD_LIBS -lsocket",)
AC_CHECK_LIB(nsl,gethostbyname,MPD_LIBS="$MPD_LIBS -lnsl",)

AC_CHECK_LIB(m,exp,MPD_LIBS="$MPD_LIBS -lm",)

AC_CHECK_HEADERS(locale.h)


dnl
dnl mandatory libraries
dnl

PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.4 gthread-2.0],,
		  [AC_MSG_ERROR([glib-2.4 is required])])


dnl
dnl protocol options
dnl

AC_ARG_ENABLE(tcp,
	AS_HELP_STRING([--disable-tcp],
		[disable support for clients connecting via TCP (default: enable)]),
	[enable_tcp=$enableval],
	[enable_tcp=yes])

AC_ARG_ENABLE(ipv6,
	AS_HELP_STRING([--disable-ipv6],
		[disable IPv6 support (default: enable)]),
	[enable_ipv6=$enableval],
	[enable_ipv6=yes])

if test x$enable_tcp = xno; then
	# if we don't support TCP, we don't need IPv6 either
	enable_ipv6=no
fi

if test x$enable_ipv6 = xyes; then
	AC_MSG_CHECKING(for ipv6)
	AC_EGREP_CPP([AP_maGiC_VALUE],
	[
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#ifdef PF_INET6
#ifdef AF_INET6
AP_maGiC_VALUE
#endif
#endif
	],
	AC_DEFINE(HAVE_IPV6, 1, [Define if IPv6 support present])
	AC_MSG_RESULT([yes]),
	AC_MSG_RESULT([no])
)
fi

if test x$enable_tcp = xyes; then
	AC_DEFINE(HAVE_TCP, 1, [Define if TCP socket support is enabled])
fi

AC_ARG_ENABLE(un,
	AS_HELP_STRING([--disable-un],
		[disable support for clients connecting via unix domain sockets (default: enable)]),
	[enable_un=$enableval],
	[enable_un=yes])

if test x$enable_un = xyes; then
	AC_DEFINE(HAVE_UN, 1, [Define if unix domain socket support is enabled])
	STRUCT_UCRED
fi


dnl
dnl misc libraries
dnl

AC_ARG_WITH(zeroconf,[[  --with-zeroconf=[auto|avahi|bonjour|no]    Enable zeroconf backend (default=auto)]], with_zeroconf="$withval", with_zeroconf="auto")

case $with_zeroconf in
no|avahi|bonjour)
	;;
*)
	with_zeroconf=auto
	;;
esac

if test x$with_zeroconf != xno; then
	if test x$with_zeroconf = xavahi || test x$with_zeroconf = xauto; then
		PKG_CHECK_MODULES([AVAHI], [avahi-client avahi-glib],
		                  [found_avahi=1;AC_DEFINE([HAVE_AVAHI], 1, [Define to enable Avahi Zeroconf support])]
		                  MPD_LIBS="$MPD_LIBS $AVAHI_LIBS" MPD_CFLAGS="$MPD_CFLAGS $AVAHI_CFLAGS",
		                  [found_avahi=0])
	fi

	if test x$found_avahi = x1; then
		with_zeroconf=avahi
	elif test x$with_zeroconf = xavahi; then
		AC_MSG_ERROR([Avahi support requested but not found])
	fi

	if test x$with_zeroconf = xbonjour || test x$with_zeroconf = xauto; then
		AC_CHECK_HEADER(dns_sd.h,
		                [found_bonjour=1;AC_DEFINE([HAVE_BONJOUR], 1, [Define to enable Bonjour Zeroconf support])],
		                [found_bonjour=0])
		AC_CHECK_LIB(dns_sd, DNSServiceRegister,
		             MPD_LIBS="$MPD_LIBS -ldns_sd")
	fi

	if test x$found_bonjour = x1; then
		with_zeroconf=bonjour
	elif test x$with_zeroconf = xbonjour; then
		AC_MSG_ERROR([Bonjour support requested but not found])
	fi

	if test x$with_zeroconf = xauto; then
		AC_MSG_WARN([No supported Zeroconf backend found, disabling Zeroconf])
		with_zeroconf=no
	else
		AC_DEFINE([HAVE_ZEROCONF], 1, [Define to enable Zeroconf support])
	fi
fi

AM_CONDITIONAL(HAVE_ZEROCONF, test x$with_zeroconf != xno)
AM_CONDITIONAL(HAVE_AVAHI, test x$with_zeroconf = xavahi)
AM_CONDITIONAL(HAVE_BONJOUR, test x$with_zeroconf = xbonjour)

AC_ARG_ENABLE(sqlite,
	AS_HELP_STRING([--enable-sqlite],
		[enable support for the SQLite database (default: disable)]),
	[enable_sqlite=$enableval],
	[enable_sqlite=no])

if test x$enable_sqlite = xyes; then
	PKG_CHECK_MODULES([SQLITE], [sqlite3],,
		[AC_MSG_ERROR(sqlite not found)])
	AC_DEFINE([ENABLE_SQLITE], 1, [Define to enable sqlite database support])
fi

AM_CONDITIONAL(ENABLE_SQLITE, test x$enable_sqlite = xyes)


dnl
dnl input plugins
dnl

AC_ARG_ENABLE(curl,
	AS_HELP_STRING([--disable-curl],
		[enable support obtaining song data via HTTP (default: enable)]),
	[enable_curl=$enableval],
	[enable_curl=yes])

if test x$enable_curl = xyes; then
	PKG_CHECK_MODULES(CURL, [libcurl],
		AC_DEFINE(HAVE_CURL, 1, [Define when libcurl is used for HTTP streaming]),
		enable_curl=no)
fi
AM_CONDITIONAL(HAVE_CURL, test x$enable_curl = xyes)

AC_ARG_ENABLE(mms,
	AS_HELP_STRING([--enable-mms],
		[enable the MMS protocol with libmms (default: disable)]),,
	[enable_mms=no])

if test x$enable_mms = xyes; then
	PKG_CHECK_MODULES(MMS, [libmms],
		AC_DEFINE(ENABLE_MMS, 1, [Define when libmms is used for the MMS protocol]),
		AC_MSG_ERROR([libmms not found]))
fi
AM_CONDITIONAL(ENABLE_MMS, test x$enable_mms = xyes)


dnl
dnl archive plugins
dnl

dnl bzip2
AC_ARG_ENABLE(bzip2,
	AS_HELP_STRING([--enable-bzip2],
		[enable bzip2 archive support (default: disabled)]),
	enable_bz2=$enableval,
	enable_bz2=no)

if test x$enable_bz2 = xyes; then
	AC_CHECK_LIB(bz2, BZ2_bzDecompressInit,
		[MPD_LIBS="$MPD_LIBS -lbz2"],
		enable_bz2=no)
fi

AM_CONDITIONAL(HAVE_BZ2, test x$enable_bz2 = xyes)
if test x$enable_bz2 = xyes; then
	AC_DEFINE(HAVE_BZ2, 1, [Define to have bz2 archive support])
fi

dnl zip
AC_ARG_ENABLE(zip,
	AS_HELP_STRING([--enable-zip],
		[enable zip archive support (default: disabled)]),
	enable_zip=$enableval,
	enable_zip=no)

if test x$enable_zip = xyes; then
	AC_CHECK_LIB(zzip, zzip_dir_open,
		[MPD_LIBS="$MPD_LIBS -lzzip"],
		enable_zip=no)
fi

AM_CONDITIONAL(HAVE_ZIP, test x$enable_zip = xyes)
if test x$enable_zip = xyes; then
	AC_DEFINE(HAVE_ZIP, 1, [Define to have zip archive support])
fi

dnl iso9660
AC_ARG_ENABLE(iso9660,
	AS_HELP_STRING([--enable-iso9660],
		[enable iso9660 archive support (default: disabled)]),
	enable_iso=$enableval,
	enable_iso=no)

if test x$enable_iso = xyes; then
	AC_CHECK_LIB(iso9660, iso9660_ifs_readdir,
		[MPD_LIBS="$MPD_LIBS -liso9660"],
		enable_iso=no)
fi

AM_CONDITIONAL(HAVE_ISO, test x$enable_iso = xyes)
if test x$enable_iso = xyes; then
	AC_DEFINE(HAVE_ISO, 1, [Define to have iso archive support])
fi

dnl archive API
if test x$enable_bz2 = xyes || test x$enable_zip = xyes || test x$enable_iso = xyes; then
	enable_archive=yes
	AC_DEFINE(ENABLE_ARCHIVE, 1, [The archive API is available])
else
	enable_archive=no
fi

AM_CONDITIONAL(ENABLE_ARCHIVE, test x$enable_archive = xyes)


dnl
dnl metadata
dnl

AC_ARG_ENABLE(id3,
	AS_HELP_STRING([--disable-id3],
		[disable id3 support (default: enable)]),
	enable_id3=$enableval,
	enable_id3=yes)


dnl
dnl decoder plugins
dnl

AC_ARG_ENABLE(aac,
	AS_HELP_STRING([--disable-aac],
		[disable AAC support (default: enable)]),
	enable_aac=$enableval,
	enable_aac=yes)

AC_ARG_WITH(faad,[  --with-faad=PFX             Prefix where faad2 is installed], faad_prefix="$withval", faad_prefix="")
AC_ARG_WITH(faad-libraries,[  --with-faad-libraries=DIR   Directory where faad2 library is installed (optional)], faad_libraries="$withval", faad_libraries="")
AC_ARG_WITH(faad-includes,[  --with-faad-includes=DIR    Directory where faad2 header files are installed (optional)], faad_includes="$withval", faad_includes="")

AC_ARG_ENABLE(audiofile,
	AS_HELP_STRING([--disable-audiofile],
		[disable audiofile support, disables wave support (default: enable)]),
	enable_audiofile=$enableval,
	enable_audiofile=yes)

AC_ARG_ENABLE(ffmpeg,
	AS_HELP_STRING([--disable-ffmpeg],
		[enable FFMPEG support (default: enable)]),
	enable_ffmpeg=$enableval,
	enable_ffmpeg=yes)

AC_ARG_ENABLE(flac,
	AS_HELP_STRING([--disable-flac],
		[disable flac support (default: enable)]),
	enable_flac=$enableval,
	enable_flac=yes)

AC_ARG_ENABLE(mod,
	AS_HELP_STRING([--enable-mod],
		[enable MOD support (default: disable)]),
	enable_mod=$enableval,
	enable_mod=no)

AC_ARG_ENABLE(modplug,
	AS_HELP_STRING([--enable-modplug],
		[enable MODPLUG support (default: disable)]),
	enable_modplug=$enableval,
	enable_modplug=no)

AC_ARG_ENABLE(mp3,
	AS_HELP_STRING([--disable-mp3],
		[disable mp3 support (default: enable)]),
	enable_mp3=$enableval,
	enable_mp3=yes)

AC_ARG_ENABLE(mpc,
	AS_HELP_STRING([--disable-mpc],
		[disable musepack (MPC) support (default: enable)]),
	enable_mpc=$enableval,
	enable_mpc=yes)

AC_ARG_ENABLE(oggflac,
	AS_HELP_STRING([--disable-oggflac],
		[disable OggFLAC support (default: enable)]),
	enable_oggflac=$enableval,
	enable_oggflac=yes)

AC_ARG_ENABLE(oggvorbis,
	AS_HELP_STRING([--disable-oggvorbis],
		[disable Ogg Vorbis support (default: enable)]),
	enable_oggvorbis=$enableval,
	enable_oggvorbis=yes)

AC_ARG_WITH(tremor,[[  --with-tremor[=PFX]         Use Tremor(vorbisidec) integer Ogg-Vorbis decoder (with optional prefix)]], use_tremor=yes; test x$withval != xyes && tremor_prefix="$withval",)
AC_ARG_WITH(tremor-libraries,[  --with-tremor-libraries=DIR Directory where Tremor library is installed (optional)], tremor_libraries="$withval", tremor_libraries="")
AC_ARG_WITH(tremor-includes,[  --with-tremor-includes=DIR  Directory where Tremor header files are installed (optional)], tremor_includes="$withval", tremor_includes="")

AC_ARG_ENABLE(sidplay,
	AS_HELP_STRING([--enable-sidplay],
		[enable C64 SID support via libsidplay2 (default: disable)]),,
	enable_sidplay=no)

AC_ARG_ENABLE(fluidsynth,
	AS_HELP_STRING([--enable-fluidsynth],
		[enable MIDI support via fluidsynth (default: disable)]),,
	enable_fluidsynth=no)

AC_ARG_ENABLE(wildmidi,
	AS_HELP_STRING([--enable-wildmidi],
		[enable MIDI support via wildmidi (default: disable)]),,
	enable_wildmidi=no)

AC_ARG_ENABLE(wavpack,
	AS_HELP_STRING([--disable-wavpack],
		[disable WavPack support (default: enable)]),
	enable_wavpack=$enableval,
	enable_wavpack=yes)


dnl
dnl converters
dnl

AC_ARG_ENABLE(lsr,
	AS_HELP_STRING([--disable-lsr],
		[disable libsamplerate support (default: enable)]),
	enable_lsr=$enableval,
	enable_lsr=yes)

if test x$enable_lsr = xyes; then
	PKG_CHECK_MODULES([SAMPLERATE], [samplerate >= 0.0.15],
	                  [enable_lsr=yes;AC_DEFINE([HAVE_LIBSAMPLERATE], 1, [Define to enable libsamplerate])] MPD_LIBS="$MPD_LIBS $SAMPLERATE_LIBS" MPD_CFLAGS="$MPD_CFLAGS $SAMPLERATE_CFLAGS",
	                  [enable_lsr=no;AC_MSG_WARN([libsamplerate not found -- disabling])])
fi

if test x$enable_lsr = xyes; then
	PKG_CHECK_MODULES([SAMPLERATE_013], [samplerate >= 0.1.3],,
		[AC_DEFINE([HAVE_LIBSAMPLERATE_NOINT], 1, [libsamplerate doesn't provide src_int_to_float_array() (<0.1.3)])])
fi

AM_CONDITIONAL(HAVE_LIBSAMPLERATE, test x$enable_lsr = xyes)


dnl
dnl encoder plugins
dnl

AC_ARG_ENABLE(lame,
	AS_HELP_STRING([--disable-lame],
		[disable lame support (default: enable)]),
	enable_lame=$enableval,
	enable_lame=yes)


dnl
dnl audio output plugins
dnl

AC_ARG_ENABLE(alsa,
	AS_HELP_STRING([--disable-alsa],
		[disable ALSA support (default: enable)]),
	enable_alsa=$enableval,
	enable_alsa=yes)

AC_ARG_ENABLE(ao,
	AS_HELP_STRING([--enable-ao],
		[enable support for libao (default: disable)]),
	enable_ao=$enableval,
	enable_ao=no)

AC_ARG_ENABLE(fifo,
	AS_HELP_STRING([--disable-fifo],
		[disable support for writing audio to a FIFO (default: enable)]),
	enable_fifo=$enableval,
	enable_fifo=yes)

AC_ARG_ENABLE(jack,
	AS_HELP_STRING([--disable-jack],
		[disable jack support (default: enable)]),
	enable_jack=$enableval,
	enable_jack=yes)

AC_ARG_ENABLE(mvp,
	AS_HELP_STRING([--enable-mvp],
		[enable support for Hauppauge Media MVP (default: disable)]),
	enable_mvp=$enableval,
	enable_mvp=no)

AC_ARG_ENABLE(oss,
	AS_HELP_STRING([--disable-oss],
		[disable OSS support (default: enable)]),
	enable_oss=$enableval,
	enable_oss=yes)

AC_ARG_ENABLE(pulse,
	AS_HELP_STRING([--disable-pulse],
		[disable support for the PulseAudio sound server (default: enable)]),
	enable_pulse=$enableval,
	enable_pulse=yes)

AC_ARG_ENABLE(shout-ogg,
	AS_HELP_STRING([--disable-shout-ogg],
		[disable support for ogg streaming through shout (default: enable)]),
	[enable_shout_ogg=$enableval],
	[enable_shout_ogg=yes])

AC_ARG_ENABLE(shout-mp3,
	AS_HELP_STRING([--disable-shout-mp3],
		[disable support for mp3 streaming through shout (default: enable)]),
	[enable_shout_mp3=$enableval],
	[enable_shout_mp3=yes])

enable_osx=no
case $host in
	*-darwin*)
                AC_DEFINE(HAVE_OSX, 1, [Define for compiling OS X support])
		MPD_LIBS="$MPD_LIBS -framework AudioUnit -framework CoreServices"
		enable_osx=yes ;;
esac

AM_CONDITIONAL(HAVE_OSX, test x$enable_osx = xyes)

if test x$enable_shout_ogg = xyes || test x$enable_shout_mp3 = xyes; then
	PKG_CHECK_MODULES([SHOUT], [shout],,
		[enable_shout_ogg=no; enable_shout_mp3=no;
		AC_MSG_WARN([disabling shout streaming support because libshout is not available])])
fi

if test x$enable_shout_ogg = xyes; then
	if test x$enable_oggvorbis = xno; then
		AC_MSG_WARN([disabling ogg shout streaming support because vorbis is not enabled])
		enable_shout_ogg=no
	fi
	if test x$use_tremor = xyes; then
		AC_MSG_WARN([disabling ogg shout streaming support because tremor does not support vorbis encoding])
		enable_shout_ogg=no
	fi
	if test x$enable_shout_ogg = xyes; then
		PKG_CHECK_MODULES(VORBISENC, [vorbisenc],
			AC_DEFINE(HAVE_SHOUT_OGG, 1, [Define to enable ogg streaming support]),
			enable_shout_ogg=no)
	fi
fi

if test x$enable_lame = xyes; then
	AM_PATH_LAME([MPD_LIBS="$MPD_LIBS $LAME_LIBS" MPD_CFLAGS="$MPD_CFLAGS $LAME_CFLAGS"],
		[enable_lame=no; AC_MSG_WARN(You need lame -- disabling lame support)])
fi

if test x$enable_shout_mp3 = xyes; then
	if test x$enable_lame = xno; then
		AC_MSG_WARN([disabling mp3 shout streaming support because lame is not enabled])
		enable_shout_mp3=no
	fi
	if test x$enable_shout_mp3 = xyes; then
		AC_DEFINE(HAVE_SHOUT_MP3, 1, [Define to enable mp3 streaming support])
	fi
fi

if test x$enable_shout_ogg = xyes || test x$enable_shout_mp3 = xyes; then
	enable_shout=yes
	AC_DEFINE(HAVE_SHOUT, 1, [Define to enable libshout support])
else
	enable_shout=no
fi

AM_CONDITIONAL(HAVE_SHOUT, test x$enable_shout = xyes)
AM_CONDITIONAL(HAVE_SHOUT_OGG, test x$enable_shout_ogg = xyes)
AM_CONDITIONAL(HAVE_SHOUT_MP3, test x$enable_shout_mp3 = xyes)

if test x$enable_ao = xyes; then
	PKG_CHECK_MODULES(AO, [ao],
		AC_DEFINE(HAVE_AO, 1, [Define to play with ao]),
		enable_ao=no)
fi

AM_CONDITIONAL(HAVE_AO, test x$enable_ao = xyes)

if test x$enable_oss = xyes; then
        AC_CHECK_HEADER(sys/soundcard.h,[enable_oss=yes;AC_DEFINE(HAVE_OSS,1,[Define to enable OSS])],[AC_MSG_WARN(Soundcard headers not found -- disabling OSS support);enable_oss=no])
fi

AM_CONDITIONAL(HAVE_OSS, test x$enable_oss = xyes)

if test x$enable_pulse = xyes; then
	PKG_CHECK_MODULES([PULSE], [libpulse-simple],
	                  [enable_pulse=yes;AC_DEFINE([HAVE_PULSE], 1, [Define to enable PulseAudio support])] MPD_LIBS="$MPD_LIBS $PULSE_LIBS" MPD_CFLAGS="$MPD_CFLAGS $PULSE_CFLAGS",
	                  [enable_pulse=no;AC_MSG_WARN([PulseAudio not found -- disabling])])
fi

AM_CONDITIONAL(HAVE_PULSE, test x$enable_pulse = xyes)

if test x$enable_fifo = xyes; then
	AC_CHECK_FUNC([mkfifo],
	              [enable_fifo=yes;AC_DEFINE([HAVE_FIFO], 1, [Define to enable support for writing audio to a FIFO])],
	              [enable_fifo=no;AC_MSG_WARN([mkfifo not found -- disabling support for writing audio to a FIFO])])
fi

AM_CONDITIONAL(HAVE_FIFO, test x$enable_fifo = xyes)

if test x$enable_mvp = xyes; then
   AC_DEFINE(HAVE_MVP,1,[Define to enable Hauppauge Media MVP support])
fi

AM_CONDITIONAL(HAVE_MVP, test x$enable_mvp = xyes)

if test x$enable_alsa = xyes; then
	PKG_CHECK_MODULES(ALSA, [alsa >= 0.9.0],
		AC_DEFINE(HAVE_ALSA, 1, [Define to enable ALSA support]),
		enable_alsa=no)
fi

AM_CONDITIONAL(HAVE_ALSA, test x$enable_alsa = xyes)

if test x$enable_jack = xyes; then
	PKG_CHECK_MODULES([JACK], [jack >= 0.4],
	                  [enable_jack=yes;AC_DEFINE([HAVE_JACK], 1, [Define to enable JACK support])] MPD_LIBS="$MPD_LIBS $JACK_LIBS" MPD_CFLAGS="$MPD_CFLAGS $JACK_CFLAGS",
	                  [enable_jack=no;AC_MSG_WARN([JACK not found -- disabling])])
fi

if test x$enable_jack = xyes; then
	# check whether jack_set_info_function() is available
	old_LIBS=$LIBS
	LIBS="$LIBS $JACK_LIBS"

	AC_CHECK_FUNCS(jack_set_info_function)

	LIBS=$old_LIBS
fi

AM_CONDITIONAL(HAVE_JACK, test x$enable_jack = xyes)

if test x$enable_id3 = xyes; then
	PKG_CHECK_MODULES([ID3TAG], [id3tag],,
		AC_CHECK_LIB(id3tag, id3_file_open,
			[ID3TAG_LIBS="-lid3tag -lz" ID3TAG_CFLAGS=""],
			enable_id3=no))
fi

if test x$enable_id3 = xyes; then
	AC_DEFINE(HAVE_ID3TAG, 1, [Define to use id3tag])
fi

AM_CONDITIONAL(HAVE_ID3TAG, test x$enable_id3 = xyes)

if test x$enable_mp3 = xyes; then
	PKG_CHECK_MODULES([MAD], [mad],
		AC_DEFINE(HAVE_MAD, 1, [Define to use libmad]),
		enable_mp3=no)
fi

AM_CONDITIONAL(HAVE_MAD, test x$enable_mp3 = xyes)


if test x$enable_mpc = xyes; then
  	if test "x$mpcdec_libraries" != "x" ; then
  		MPCDEC_LIBS="-L$mpcdec_libraries"
  	elif test "x$mpcdec_prefix" != "x" ; then
		MPCDEC_LIBS="-L$mpcdec_prefix/lib"
  	fi

 	MPCDEC_LIBS="$MPCDEC_LIBS -lmpcdec"

  	if test "x$mpcdec_includes" != "x" ; then
  		MPCDEC_CFLAGS="-I$mpcdec_includes"
  	elif test "x$mpcdec_prefix" != "x" ; then
    		MPCDEC_CFLAGS="-I$mpcdec_prefix/include"
  	fi

	oldcflags=$CFLAGS
	oldlibs=$LIBS
	oldcppflags=$CPPFLAGS
	CFLAGS="$CFLAGS $MPD_CFLAGS $MPCDEC_CFLAGS -I."
	LIBS="$LIBS $MPD_LIBS $MPCDEC_LIBS"
	CPPFLAGS=$CFLAGS
	AC_CHECK_HEADER(mpcdec/mpcdec.h,,enable_mpc=no)
	if test x$enable_mpc = xyes; then
		AC_CHECK_LIB(mpcdec,main,[MPD_LIBS="$MPD_LIBS $MPCDEC_LIBS";MPD_CFLAGS="$MPD_CFLAGS $MPCDEC_CFLAGS";],enable_mpc=no)
	fi
	if test x$enable_mpc = xyes; then
		AC_DEFINE(HAVE_MPCDEC,1,[Define to use libmpcdec for MPC decoding])
	else
		AC_MSG_WARN([mpcdec lib needed for MPC support -- disabling MPC support])
	fi
	CFLAGS=$oldcflags
	LIBS=$oldlibs
	CPPFLAGS=$oldcppflags
fi

AM_CONDITIONAL(HAVE_MPCDEC, test x$enable_mpc = xyes)

if test x$enable_wavpack = xyes; then
	PKG_CHECK_MODULES([WAVPACK], [wavpack],
	                  [enable_wavpack=yes;AC_DEFINE([HAVE_WAVPACK], 1, [Define to enable WavPack support])] MPD_LIBS="$MPD_LIBS $WAVPACK_LIBS" MPD_CFLAGS="$MPD_CFLAGS $WAVPACK_CFLAGS",
	                  [enable_wavpack=no;AC_MSG_WARN([WavPack not found -- disabling])])
fi

AM_CONDITIONAL(HAVE_WAVPACK, test x$enable_wavpack = xyes)

if test x$enable_aac = xyes; then
	if test "x$faad_libraries" != "x" ; then
		FAAD_LIBS="-L$faad_libraries"
	elif test "x$faad_prefix" != "x" ; then
		FAAD_LIBS="-L$faad_prefix/lib"
	fi

	FAAD_LIBS="$FAAD_LIBS -lfaad"

	if test "x$faad_includes" != "x" ; then
		FAAD_CFLAGS="-I$faad_includes"
	elif test "x$faad_prefix" != "x" ; then
		FAAD_CFLAGS="-I$faad_prefix/include"
	fi

	oldcflags=$CFLAGS
	oldlibs=$LIBS
	oldcppflags=$CPPFLAGS
	CFLAGS="$CFLAGS $MPD_CFLAGS $FAAD_CFLAGS -I."
	LIBS="$LIBS $MPD_LIBS $FAAD_LIBS"
	CPPFLAGS=$CFLAGS
	AC_CHECK_HEADER(faad.h,,enable_aac=no)
	if test x$enable_aac = xyes; then
		AC_CHECK_DECL(FAAD2_VERSION,,enable_aac=no,[#include <faad.h>])
	fi
	if test x$enable_aac = xyes; then
		AC_CHECK_DECL(faacDecInit2,,enable_aac=no,[#include <faad.h>])
	fi
	if test x$enable_aac = xyes; then
		AC_CHECK_LIB(faad,faacDecInit2,[MPD_LIBS="$MPD_LIBS $FAAD_LIBS";MPD_CFLAGS="$MPD_CFLAGS $FAAD_CFLAGS"],enable_aac=no)
		if test x$enable_aac = xno; then
			enable_aac=yes
			AC_CHECK_LIB(faad,NeAACDecInit2,[MPD_LIBS="$MPD_LIBS $FAAD_LIBS";MPD_CFLAGS="$MPD_CFLAGS $FAAD_CFLAGS"],enable_aac=no)
		fi
	fi
	if test x$enable_aac = xyes; then
  		AC_MSG_CHECKING(that FAAD2 uses buffer and bufferlen)
		AC_COMPILE_IFELSE([
#include <faad.h>

int main() {
	char buffer;
	long bufferlen = 0;
	faacDecHandle decoder;
	faacDecFrameInfo frameInfo;
	faacDecConfigurationPtr config;
	unsigned char channels;
	long sampleRate;
        mp4AudioSpecificConfig mp4ASC;

	decoder = faacDecOpen();
	config = faacDecGetCurrentConfiguration(decoder);
	config->outputFormat = FAAD_FMT_16BIT;
	faacDecSetConfiguration(decoder,config);
	AudioSpecificConfig(&buffer, bufferlen, &mp4ASC);
	faacDecInit(decoder,&buffer,bufferlen,&sampleRate,&channels);
	faacDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
	faacDecDecode(decoder,&frameInfo,&buffer,bufferlen);

	return 0;
}
],[AC_MSG_RESULT(yes);AC_DEFINE(HAVE_FAAD_BUFLEN_FUNCS,1,[Define if FAAD2 uses buflen in function calls])],[AC_MSG_RESULT(no);
		AC_MSG_CHECKING(that FAAD2 can even be used)
		AC_COMPILE_IFELSE([
#include <faad.h>

int main() {
	char buffer;
	faacDecHandle decoder;
	faacDecFrameInfo frameInfo;
	faacDecConfigurationPtr config;
	unsigned char channels;
	long sampleRate;
	long bufferlen = 0;
	unsigned long dummy1_32;
        unsigned char dummy2_8, dummy3_8, dummy4_8, dummy5_8, dummy6_8,
                                dummy7_8, dummy8_8;

	decoder = faacDecOpen();
	config = faacDecGetCurrentConfiguration(decoder);
	config->outputFormat = FAAD_FMT_16BIT;
	faacDecSetConfiguration(decoder,config);
	AudioSpecificConfig(&buffer,&dummy1_32,&dummy2_8,
                                &dummy3_8,&dummy4_8,&dummy5_8,
                                &dummy6_8,&dummy7_8,&dummy8_8);
	faacDecInit(decoder,&buffer,&sampleRate,&channels);
	faacDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
	faacDecDecode(decoder,&frameInfo,&buffer);
	faacDecClose(decoder);

	return 0;
}
],AC_MSG_RESULT(yes),[AC_MSG_RESULT(no);enable_aac=no])
		])
	fi
	if test x$enable_aac = xyes; then
		AC_CHECK_TYPES(mp4AudioSpecificConfig,,,[#include <faad.h>])
		AC_CHECK_MEMBERS([faacDecConfiguration.downMatrix,faacDecConfiguration.dontUpSampleImplicitSBR,faacDecFrameInfo.samplerate],,,[#include <faad.h>])
		AC_DEFINE(HAVE_FAAD,1,[Define to use FAAD2 for AAC decoding])
	else
		AC_MSG_WARN([faad2 lib needed for MP4/AAC support -- disabling MP4/AAC support])
	fi
	CFLAGS=$oldcflags
	LIBS=$oldlibs
	CPPFLAGS=$oldcppflags
fi

AM_CONDITIONAL(HAVE_FAAD, test x$enable_aac = xyes)

if test x$enable_aac = xyes; then
	oldcflags=$CFLAGS
	oldlibs=$LIBS
	oldcppflags=$CPPFLAGS
	CFLAGS="$CFLAGS $MPD_CFLAGS $FAAD_CFLAGS -Werror"
	LIBS="$LIBS $MPD_LIBS $FAAD_LIBS"
	CPPFLAGS=$CFLAGS

	AC_MSG_CHECKING(for broken libfaad headers)
	AC_COMPILE_IFELSE([
#include <faad.h>
#include <stddef.h>
#include <stdint.h>

int main() {
	unsigned char channels;
	uint32_t sample_rate;

	faacDecInit2(NULL, NULL, 0, &sample_rate, &channels);
	return 0;
}
	],
		[AC_MSG_RESULT(correct)],
		[AC_MSG_RESULT(broken);
		AC_DEFINE(HAVE_FAAD_LONG, 1, [Define if faad.h uses the broken "unsigned long" pointers])])

	CFLAGS=$oldcflags
	LIBS=$oldlibs
	CPPFLAGS=$oldcppflags
fi

if test x$enable_aac = xyes; then
	enable_mp4=yes
	MP4FF_LIBS="-lmp4ff"

	oldcflags=$CFLAGS
	oldlibs=$LIBS
	oldcppflags=$CPPFLAGS
	CFLAGS="$CFLAGS $FAAD_CFLAGS"
	LIBS="$LIBS $MP4FF_LIBS"
	CPPFLAGS=$CFLAGS

	AC_CHECK_HEADER(mp4ff.h,,enable_mp4=no)

	if test x$enable_mp4 = xyes; then
		AC_CHECK_LIB(mp4ff,mp4ff_open_read,,enable_mp4=no)
	fi

	if test x$enable_mp4 = xyes; then
		AC_SUBST(MP4FF_LIBS)
		AC_DEFINE(HAVE_MP4, 1, [Define to use FAAD2+mp4ff for MP4 decoding])
	else
		AC_MSG_WARN([libmp4ff needed for MP4 support -- disabling MP4 support])
		unset MP4FF_LIBS
	fi

	CFLAGS=$oldcflags
	LIBS=$oldlibs
	CPPFLAGS=$oldcppflags
fi

AM_CONDITIONAL(HAVE_MP4, test x$enable_mp4 = xyes)

if test x$use_tremor = xyes; then
	if test "x$tremor_libraries" != "x" ; then
		TREMOR_LIBS="-L$tremor_libraries"
	elif test "x$tremor_prefix" != "x" ; then
		TREMOR_LIBS="-L$tremor_prefix/lib"
	fi
	TREMOR_LIBS="$TREMOR_LIBS -lvorbisidec"
	if test "x$tremor_includes" != "x" ; then
		TREMOR_CFLAGS="-I$tremor_includes"
	elif test "x$tremor_prefix" != "x" ; then
		TREMOR_CFLAGS="-I$tremor_prefix/include"
	fi
	ac_save_CFLAGS="$CFLAGS"
	ac_save_LIBS="$LIBS"
	CFLAGS="$CFLAGS $TREMOR_CFLAGS"
	LIBS="$LIBS $TREMOR_LIBS"
	AC_CHECK_LIB(vorbisidec,ov_read,enable_oggvorbis=yes,enable_oggvorbis=no;AC_MSG_WARN([vorbisidec lib needed for ogg support with tremor -- disabling ogg support]))
	if test x$enable_oggvorbis = xyes; then
		AC_DEFINE(HAVE_OGGVORBIS, 1, [Define for Ogg Vorbis support]),
	else
		CFLAGS="$ac_save_CFLAGS"
		LIBS="$ac_save_LIBS"
	fi
elif test x$enable_oggvorbis = xyes; then
	PKG_CHECK_MODULES(OGGVORBIS, [ogg vorbis vorbisfile],
		AC_DEFINE(HAVE_OGGVORBIS, 1, [Define for Ogg Vorbis support]),
		enable_oggvorbis=no)
fi

AM_CONDITIONAL(HAVE_OGGVORBIS, test x$enable_oggvorbis = xyes)

if test x$use_tremor = xyes; then
	AC_DEFINE(HAVE_TREMOR,1,[Define to use tremor (libvorbisidec) for ogg support])
	if test x$enable_oggflac = xyes; then
		AC_MSG_WARN([disabling OggFLAC support because it is incompatible with tremor])
		enable_oggflac=no
	fi
fi

if test x$enable_flac = xyes; then
	PKG_CHECK_MODULES(FLAC, [flac >= 1.1],
		AC_DEFINE(HAVE_FLAC, 1, [Define for FLAC support]),
		enable_flac=no)

	oldcflags="$CFLAGS"
	oldlibs="$LIBS"
	CFLAGS="$CFLAGS $FLAC_CFLAGS"
	LIBS="$LIBS $FLAC_LIBS"
	if test x$enable_flac = xyes && test x$enable_oggflac = xyes; then
		AC_CHECK_DECL(FLAC_API_SUPPORTS_OGG_FLAC,
		              [enable_oggflac=flac], [],
			      [#include <FLAC/export.h>])
	fi
	CFLAGS="$oldcflags"
	LIBS="$oldlibs"
fi

AM_CONDITIONAL(HAVE_FLAC, test x$enable_flac = xyes)

if test x$enable_oggflac = xyes; then
	oldmpdcflags="$MPD_CFLAGS"
	oldmpdlibs="$MPD_LIBS"
	AM_PATH_LIBOGGFLAC(MPD_LIBS="$MPD_LIBS $LIBOGGFLAC_LIBS" MPD_CFLAGS="$MPD_CFLAGS $LIBOGGFLAC_CFLAGS",enable_oggflac=no)
fi

if test x$enable_oggflac = xyes; then
	AC_DEFINE(HAVE_OGGFLAC,1,[Define for OggFLAC support])
fi

AM_CONDITIONAL(HAVE_OGGFLAC, test x$enable_oggflac = xyes)

AM_CONDITIONAL(HAVE_FLAC_COMMON, test x$enable_flac = xyes || test x$enable_oggflac = xyes)
AM_CONDITIONAL(HAVE_OGG_COMMON, test x$enable_oggvorbis = xyes || test x$enable_oggflac = xyes || test x$enable_flac = xyes)

if test x$enable_audiofile = xyes; then
	PKG_CHECK_MODULES(AUDIOFILE, [audiofile >= 0.1.7],
		AC_DEFINE(HAVE_AUDIOFILE, 1, [Define for audiofile support]),
		enable_audiofile=no)
fi

AM_CONDITIONAL(HAVE_AUDIOFILE, test x$enable_audiofile = xyes)

if test x$enable_mod = xyes; then
	AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config)
	if test x$LIBMIKMOD_CONFIG != x ; then
		AC_SUBST(LIBMIKMOD_CFLAGS, `$LIBMIKMOD_CONFIG --cflags`)
		AC_SUBST(LIBMIKMOD_LIBS, `$LIBMIKMOD_CONFIG --libs`)
		AC_DEFINE(HAVE_MIKMOD, 1, [Define for mikmod support])
	else
		enable_mod=no
	fi
fi

AM_CONDITIONAL(HAVE_MIKMOD, test x$enable_mod = xyes)

if test x$enable_modplug = xyes; then
	PKG_CHECK_MODULES(MODPLUG, [libmodplug],
	    AC_DEFINE(HAVE_MODPLUG, 1, [Define for modplug support]),
	    enable_modplug=no)
fi

AM_CONDITIONAL(HAVE_MODPLUG, test x$enable_modplug = xyes)

if test x$enable_ffmpeg = xyes; then
	PKG_CHECK_MODULES(FFMPEG, [libavformat libavcodec libavutil],,
		enable_ffmpeg=no)
fi

if test x$enable_ffmpeg = xyes; then
	old_LIBS=$LIBS
	LIBS="$LIBS $FFMPEG_LIBS"
	AC_CHECK_LIB(avcodec, avcodec_decode_audio2,,
		enable_ffmpeg=no)
	LIBS=$old_LIBS
fi

if test x$enable_ffmpeg = xyes; then
	# prior to ffmpeg svn12865, you had to specify include files
	# without path prefix
	old_CPPCFLAGS=$CPPFLAGS
	CPPFLAGS="$CPPFLAGS $FFMPEG_CFLAGS"
	AC_CHECK_HEADER(libavcodec/avcodec.h,,
		AC_DEFINE(OLD_FFMPEG_INCLUDES, 1,
			[Define if avcodec.h instead of libavcodec/avcodec.h should be included]))
	CPPCFLAGS=$old_CPPFLAGS
fi

if test x$enable_ffmpeg = xyes; then
	AC_DEFINE(HAVE_FFMPEG, 1, [Define for FFMPEG support])
fi

AM_CONDITIONAL(HAVE_FFMPEG, test x$enable_ffmpeg = xyes)

if test x$enable_sidplay = xyes; then
	# libsidplay2 exposes a C++ interface
	AC_PROG_CXX

	# we have no test yet.. we're not using pkg-config here
	# because libsidplay2's .pc file requires libtool
	AC_SUBST(SIDPLAY_LIBS,"-lsidplay2 -lresid-builder")
	AC_SUBST(SIDPLAY_CFLAGS,)

	AC_DEFINE(ENABLE_SIDPLAY, 1, [Define for libsidplay2 support])
else
	AM_CONDITIONAL(am__fastdepCXX, false)
fi

AM_CONDITIONAL(ENABLE_SIDPLAY, test x$enable_sidplay = xyes)

if test x$enable_fluidsynth = xyes; then
	PKG_CHECK_MODULES(FLUIDSYNTH, [fluidsynth],
		AC_DEFINE(ENABLE_FLUIDSYNTH, 1, [Define for fluidsynth support]),
		enable_fluidsynth=no)
fi

AM_CONDITIONAL(ENABLE_FLUIDSYNTH, test x$enable_fluidsynth = xyes)

if test x$enable_wildmidi = xyes; then
	oldcflags=$CFLAGS
	oldlibs=$LIBS
	oldcppflags=$CPPFLAGS

	AC_CHECK_LIB(WildMidi, WildMidi_Init,,
		AC_MSG_ERROR([libwildmidi not found]))

	CFLAGS=$oldcflags
	LIBS=$oldlibs
	CPPFLAGS=$oldcppflags

	AC_SUBST(WILDMIDI_LIBS,-lWildMidi)
	AC_SUBST(WILDMIDI_CFLAGS,)

	AC_DEFINE(ENABLE_WILDMIDI, 1, [Define for wildmidi support])
fi

AM_CONDITIONAL(ENABLE_WILDMIDI, test x$enable_wildmidi = xyes)


dnl
dnl Documentation
dnl

AC_ARG_ENABLE(documentation,
	AS_HELP_STRING([--enable-documentation],
		[build documentation (default: disable)]),,
	[enable_documentation=no])

if test x$enable_documentation = xyes; then
	AC_PATH_PROG(XMLTO, xmlto)
	if test x$XMLTO = x; then
		AC_MSG_ERROR([xmlto not found])
	fi

	AC_SUBST(XMLTO)
fi

AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)


dnl
dnl build options
dnl

AC_ARG_ENABLE(werror,
	AS_HELP_STRING([--enable-werror],
		[Treat warnings as errors (default: disabled)]),
	ENABLE_WERROR=$enableval,
	ENABLE_WERROR=no)

if test "x$ENABLE_WERROR" = xyes; then
	MPD_CFLAGS="$MPD_CFLAGS -Werror -pedantic-errors"
fi

AC_ARG_ENABLE(debug,
	AS_HELP_STRING([--enable-debug],
		[Enable debugging (default: disabled)]),
	ENABLE_DEBUG=$enableval,
	ENABLE_DEBUG=no)

#if test "x$ENABLE_DEBUG" = xno; then
	# don't set NDEBUG for now, until MPD is stable
	#MPD_CFLAGS="$MPD_CFLAGS -DNDEBUG"
#fi

AC_ARG_ENABLE(gprof,
	AS_HELP_STRING([--enable-gprof],
		[Enable profiling via gprof (default: disabled)]),
	ENABLE_GPROF=$enableval,
	ENABLE_GPROF=no)

if test "x$ENABLE_GPROF" = xyes; then
	MPD_CFLAGS="$MPD_CFLAGS -pg"
fi


dnl
dnl CFLAGS
dnl

if test x$GCC = xyes
then
	MPD_CHECK_FLAG([-Wall])
	MPD_CHECK_FLAG([-Wextra])
	MPD_CHECK_FLAG([-Wno-deprecated-declarations])
	MPD_CHECK_FLAG([-Wmissing-prototypes])
	MPD_CHECK_FLAG([-Wdeclaration-after-statement])
	MPD_CHECK_FLAG([-Wshadow])
	MPD_CHECK_FLAG([-Wpointer-arith])
	MPD_CHECK_FLAG([-Wstrict-prototypes])
	MPD_CHECK_FLAG([-Wcast-qual])
	MPD_CHECK_FLAG([-Wwrite-strings])
	MPD_CHECK_FLAG([-pedantic])
fi

dnl
dnl pretty-print result
dnl

echo ""
echo "########### MPD CONFIGURATION ############"
echo ""

echo " Client Support:"
if test x$enable_tcp = xyes; then
	echo " TCP support ...................enabled"
else
	echo " TCP support ...................disabled"
fi

if test x$enable_ipv6 = xyes; then
	echo " IPv6 support ..................enabled"
else
	echo " IPv6 support ..................disabled"
fi

if test x$enable_un = xyes; then
	echo " Unix domain socket support ....enabled"
else
	echo " Unix domain socket support ....disabled"
fi

echo ""

if
	test x$enable_tcp = xno &&
	test x$enable_un = xno; then
	AC_MSG_ERROR([No client interfaces configured!])
fi

echo " Playback Support:"
if test x$enable_ao = xyes; then
	echo " libao support .................enabled"
else
	echo " libao support .................disabled"
fi

if test x$enable_oss = xyes; then
	echo " OSS support ...................enabled"
else
	echo " OSS support ...................disabled"
fi

if test x$enable_alsa = xyes; then
	echo " ALSA support ..................enabled"
else
	echo " ALSA support ..................disabled"
fi

if test x$enable_jack = xyes; then
	echo " JACK support ..................enabled"
else
	echo " JACK support ..................disabled"
fi

if test x$enable_osx = xyes; then
	echo " OS X support ..................enabled"
else
	echo " OS X support ..................disabled"
fi

if test x$enable_pulse = xyes; then
	echo " PulseAudio support ............enabled"
else
	echo " PulseAudio support ............disabled"
fi

if test x$enable_fifo = xyes; then
	echo " FIFO support ..................enabled"
else
	echo " FIFO support ..................disabled"
fi

if test x$enable_mvp = xyes; then
	echo " Media MVP support .............enabled"
else
	echo " Media MVP support .............disabled"
fi

if test x$enable_shout_ogg = xyes; then
	echo " Shout ogg streaming support ...enabled"
else
	echo " Shout ogg streaming support ...disabled"
fi

if test x$enable_shout_mp3 = xyes; then
	echo " Shout mp3 streaming support ...enabled"
else
	echo " Shout mp3 streaming support ...disabled"
fi

echo ""

if test x$enable_ao = xno &&
   test x$enable_oss = xno &&
   test x$enable_shout_ogg = xno &&
   test x$enable_shout_mp3 = xno &&
   test x$enable_alsa = xno &&
   test x$enable_osx = xno &&
   test x$enable_pulse = xno &&
   test x$enable_jack = xno &&
   test x$enable_fifo = xno &&
   test x$enable_mvp = xno; then
	AC_MSG_ERROR([No Audio Output types configured!])
fi

echo " File Format Support:"

if test x$enable_id3 = xyes; then
	echo " ID3 tag support ...............enabled"
else
	echo " ID3 tag support ...............disabled"
fi

if test x$enable_mp3 = xyes; then
	echo " mp3 support ...................enabled"
else
	echo " mp3 support ...................disabled"
fi

if test x$enable_lame = xyes; then
        echo " lame support ..................enabled"
else
        echo " lame support ..................disabled"
fi

if test x$enable_oggvorbis = xyes; then
	echo " Ogg Vorbis support ............enabled"
	if test x$use_tremor = xyes; then
		echo "   using tremor.................yes"
	else
		echo "   using tremor.................no"
	fi
else
	echo " Ogg Vorbis support ............disabled"
fi

if test x$enable_flac = xyes; then
	echo " FLAC support ..................enabled"
else
	echo " FLAC support ..................disabled"
fi

case $enable_oggflac in
yes)
	echo " OggFLAC support ...............enabled"
	;;
flac)
	echo " OggFLAC support ...............enabled(FLAC 1.1.3)"
	;;
*)
	echo " OggFLAC support ...............disabled"
	;;
esac

if test x$enable_audiofile = xyes; then
	echo " Wave file support .............enabled"
else
	echo " Wave file support .............disabled"
fi

if test x$enable_aac = xyes; then
	echo " AAC support ...................enabled"
else
	echo " AAC support ...................disabled"
fi

if test x$enable_mp4 = xyes; then
	echo " MP4 support ...................enabled"
else
	echo " MP4 support ...................disabled"
fi

if test x$enable_mpc = xyes; then
	echo " Musepack (MPC) support ........enabled"
else
	echo " Musepack (MPC) support ........disabled"
fi

if test x$enable_wavpack = xyes; then
	echo " WavPack support ...............enabled"
else
	echo " WavPack support ...............disabled"
fi

if test x$enable_mod = xyes; then
	echo " MOD support ...................enabled"
else
	echo " MOD support ...................disabled"
fi

if test x$enable_modplug = xyes; then
	echo " MODPLUG support ...............enabled"
else
	echo " MODPLUG support ...............disabled"
fi

if test x$enable_sidplay = xyes; then
	echo " C64 SID support ...............enabled"
else
	echo " C64 SID support ...............disabled"
fi

if test x$enable_fluidsynth = xyes; then
	echo " fluidsynth MIDI support .......enabled"
else
	echo " fluidsynth MIDI support .......disabled"
fi

if test x$enable_wildmidi = xyes; then
	echo " wildmidi MIDI support .........enabled"
else
	echo " wildmidi MIDI support .........disabled"
fi

if test x$enable_ffmpeg = xyes; then
	echo " FFMPEG support ................enabled"
else
	echo " FFMPEG support ................disabled"
fi

if
	test x$enable_mp3 = xno &&
	test x$enable_oggvorbis = xno &&
	test x$enable_flac = xno && 
	test x$enable_oggflac = xno &&
	test x$enable_audiofile = xno && 
	test x$enable_aac = xno &&
	test x$enable_mpc = xno &&
	test x$enable_wavpack = xno &&
	test x$enable_ffmpeg = xno &&
	test x$enable_modplug = xno &&
	test x$enable_sidplay = xno &&
	test x$enable_fluidsynth = xno &&
	test x$enable_wildmidi = xno &&
	test x$enable_mod = xno; then
	AC_MSG_ERROR([No input plugins supported!])
fi

echo ""
echo " Archive support:"

if test x$enable_bz2 = xyes; then
	echo " BZ2 archives support ..........enabled"
else
	echo " BZ2 archives support ..........disabled"
fi

if test x$enable_zip = xyes; then
	echo " ZIP archives support ..........enabled"
else
	echo " ZIP archives support ..........disabled"
fi

if test x$enable_iso = xyes; then
	echo " ISO 9660 archives support .....enabled"
else
	echo " ISO 9660 archives support .....disabled"
fi

echo ""
echo " Other features:"

if test x$enable_lsr = xyes; then
        echo " libsamplerate support .........enabled"
else
	echo " libsamplerate support .........disabled"
fi
                

if test x$with_zeroconf != xno; then
	echo " Zeroconf support ..............$with_zeroconf"
else
	echo " Zeroconf support ..............disabled"
fi


if test x$enable_curl != xno; then
	echo " HTTP streaming (libcurl) ......enabled"
else
	echo " HTTP streaming (libcurl) ......disabled"
fi

if test x$enable_mms != xno; then
	echo " MMS streaming (libmms) ........enabled"
else
	echo " MMS streaming (libmms) ........disabled"
fi

echo ""
echo "##########################################"
echo ""

echo "Generating needed files for compilation"
echo ""

dnl
dnl generate files
dnl

AC_OUTPUT(doc/Makefile src/Makefile Makefile)

echo ""

echo "You are now ready to compile MPD"
echo "Type \"make\" to compile MPD"