forked from savonet/liquidsoap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1212 lines (1017 loc) · 29.8 KB
/
configure.ac
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
# Liquidsoap autoconf setup
AC_INIT([liquidsoap],
m4_esyscmd([cat liquidsoap.opam | grep ^version | sed 's/version: "\([^"]*\)"/\1/' | tr -d '\r\n']),
[liquidsoap],
[https://github.com/savonet/liquidsoap])
git_snapshot=true
version="$PACKAGE_VERSION"
min_ocaml_version=m4_esyscmd([cat liquidsoap.opam | grep \"ocaml\" | sed 's/[ ]*"ocaml" {>= "\([^"]*\)"}/\1/' | tr -d '\r\n'])
git_commit=`git rev-parse --short HEAD || true`
if test $git_snapshot != "false"; then
if test -n "$git_commit"; then
version="$version+git@$git_commit"
libs_dir_version="git/$git_commit"
else
version="$version+dev"
libs_dir_version="dev"
fi
else
libs_dir_version="$version"
fi
AC_SUBST(version)
AC_SUBST(min_ocaml_version)
AC_SUBST(libs_dir_version)
ocaml_version_descr=">= ${min_ocaml_version}"
AC_SUBST(ocaml_version_descr)
AC_PREREQ(2.61)
AC_CONFIG_SRCDIR([src/main.ml])
AC_PROG_INSTALL
# Check which make is GNU's
AC_MSG_CHECKING(for GNU make)
make_command=""
for a in "$MAKE" make gmake gnumake
do test -z "$a" && continue
if ( sh -c "$a --version" 2>/dev/null | grep GNU >/dev/null )
then make_command=$a ; break;
fi
done
if test $make_command != ""
then
MAKE=$make_command
AC_SUBST(MAKE)
AC_MSG_RESULT($MAKE)
else
AC_MSG_ERROR(not found)
fi
# Include a config.h
AC_CONFIG_HEADERS([config.h:config.h.in])
# Include it
CFLAGS="$CFLAGS -I\$(top_srcdir)"
cat > src/configure.ml << _BLAH_
let version = "$version"
let git_commit = "$git_commit"
let git_snapshot = $git_snapshot
let conf = Utils.conf
let var_script = ref "default"
let substs = ref
[[
"<script>", (fun () -> !var_script);
"<pid>", (fun () -> string_of_int (Unix.getpid ()));
"<home>", (fun () -> try Sys.getenv "HOME" with Not_found -> "<home>");
]]
let add_subst r s = substs := (r, fun () -> s) :: !substs
let subst_vars s =
List.fold_left
(fun v (r, s) -> Str.global_replace (Str.regexp r) (s ()) v)
s !substs
let init = Dtools.Init.make ~name:"init" (fun () -> ())
let at_init f = ignore(Dtools.Init.make ~after:[[init]] f)
let run_init () = Dtools.Init.exec init
_BLAH_
# This is ugly, I'd like to find a better solution.
if test "x$prefix" = "xNONE" ; then
prefix=/usr/local
default_prefix=/usr
else
# Add passed prefix to compilation variables.
CFLAGS="$CFLAGS -I$prefix/include"
LDFLAGS="$LDFLAGS -L$prefix/lib"
CPPFLAGS="$CPPFLAGS -I$prefix/include"
default_prefix=$prefix
fi
# User/group for installed files and directories
# user is assumed to have access to the group.
AC_ARG_WITH([user],
AS_HELP_STRING([--with-user],[sets the owner of installed files]))
AC_ARG_WITH([group],
AS_HELP_STRING([--with-group],[sets the group of installed files]))
if test -z "$with_user" ; then
install_user=liquidsoap
else
install_user=$with_user
fi
if test -z "$with_group" ; then
install_group=$install_user
else
install_group=$with_group
fi
AC_SUBST(install_user)
AC_SUBST(install_group)
AC_MSG_CHECKING(whether user $install_user exists)
if ! id $install_user >/dev/null 2>&1 ; then
AC_MSG_RESULT(no)
INSTALL_DAEMON=""
else
AC_MSG_RESULT(ok)
AC_MSG_CHECKING(if user $install_user belongs to group $install_group)
if ! groups $install_user | grep $install_group >/dev/null 2>&1 ; then
AC_MSG_RESULT(no)
INSTALL_DAEMON=""
else
AC_MSG_RESULT(ok)
INSTALL_DAEMON="yes"
fi
fi
if test "$INSTALL_DAEMON" != "yes" ; then
AC_MSG_WARN([Won't be able to install log and PID directories!])
fi
AC_SUBST(INSTALL_DAEMON)
AC_PROG_CC
if test -z `which pkg-config 2>/dev/null` ; then
AC_MSG_ERROR(Cannot find pkg-config)
fi
AC_ARG_WITH([bash-completion-dir],
AC_HELP_STRING(
[--with-bash-completion-dir=path],
[path to directory used to install bash-completion files (autodetected by default)]))
if test -n "${with_bash_completion_dir}" ; then
bashcompdir="${with_bash_completion_dir}"
else
dnl The following does not correctly uses prefix
dnl PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], , bashcompdir="${sysconfdir}/bash_completion.d")
bashcompdir=`pkg-config --define-variable=prefix='${prefix}' --variable=completionsdir bash-completion 2>/dev/null`
AS_IF([test -z "$bashcompdir"], [bashcompdir='${sysconfdir}/bash_completion.d'])
fi
AC_SUBST(bashcompdir)
emacsdir='${prefix}'/share/emacs/site-lisp/liquidsoap-mode
AC_SUBST(emacsdir)
# Check endianess
AC_C_BIGENDIAN
if test "x$ac_cv_c_bigendian" = "xyes"; then
cat >> src/configure.ml <<__BLAH__
let big_endian = true
__BLAH__
else
cat >> src/configure.ml <<__BLAH__
let big_endian = false
__BLAH__
fi
#
# OCaml stuff
#
###############################################################################
AC_CHECK_OCAML_COMPILERS()
# Check for OS
OCAMLC_SYSTEM=`$OCAMLFIND ocamlc -config | grep system | cut -d' ' -f 2`
if test "$OCAMLC_SYSTEM" = "mingw" -o "$OCAMLC_SYSTEM" = "mingw64"; then
OS_TYPE="Win32"
WIN32_HOST="yes"
else
OS_TYPE="Unix"
UNIX_HOST="yes"
fi
AC_SUBST(OS_TYPE)
AC_SUBST(WIN32_HOST)
AC_SUBST(UNIX_HOST)
# Add -fPIC to CFLAGS for compatibility with x86_64
if test "$OS_TYPE" \!= "Win32" ; then
CFLAGS="$CFLAGS -fPIC"
fi
OCAML_WHERE="`$OCAMLFIND ocamlc -where`"
# Beurk!
FINDLIB_PATH="`$OCAMLFIND printconf path | tr \\\\n \\; | sed -e 's#;$##' | sed -e 's#;#";"#g'`"
if test -n "${FINDLIB_PATH}"; then
FINDLIB_PATH="\"${FINDLIB_PATH}\""
fi
# Add -I`ocamlc -where` to CFLAGS for
# user with locally installed headers.
CFLAGS="$CFLAGS -I${OCAML_WHERE}"
cat >> src/configure.ml <<__BLAH__
let findlib_path = [[${FINDLIB_PATH}]]
__BLAH__
# Optimize for local machine
AC_ARG_ENABLE([optimize],
AS_HELP_STRING([--enable-optimize],[optimize for local machine (adds "-03 -march=native -mtune=native" to CFLAGS)]))
if test "x$enable_optimize" = "xyes" ; then
CFLAGS="$CFLAGS -O3 -march=native -mtune=native"
fi
liquidsoap_ocamlcflags="$OCAMLFLAGS -ccopt \"\$(CFLAGS)\""
liquidsoap_ocamllflags="-linkpkg -package unix -package threads -package str -package bigarray"
if test "$OS_TYPE" \!= "Win32" ; then
liquidsoap_ocamllflags="$liquidsoap_ocamllflags -cc \"\$(CC)\""
fi
requires="unix threads str"
if test "$enable_debugging" \!= "no" ; then
CFLAGS="$CFLAGS -g"
liquidsoap_ocamlcflags="-g -annot -bin-annot $liquidsoap_ocamlcflags"
liquidsoap_ocamllflags="-g $liquidsoap_ocamllflags"
fi
# Disable nativecode if ocamlopt is not present
if test "$OCAMLOPT" = "no"; then
enable_nativecode="no"
fi
if test "$enable_nativecode" \!= "no" ; then
BYTE=
OCAMLCOMP=OCAMLOPT
cma=cmxa
cmo=cmx
cmi=cmi
cmxs=cmxs
shared_flag=-shared
liquidsoap_ocamlcflags="$liquidsoap_ocamlcflags"
if test "x$enable_profiling" = "xyes" ; then
liquidsoap_ocamlcflags="-p $liquidsoap_ocamlcflags"
fi
AC_MSG_CHECKING(whether ocamlopt accepts -ffast-math)
if [ `$OCAMLFIND ocamlopt -ffast-math 2>/dev/null` ]; then
AC_MSG_RESULT(yes)
liquidsoap_ocamlcflags="-ffast-math $liquidsoap_ocamlcflags"
else
AC_MSG_RESULT(no)
fi
OCAMLC="$OCAMLFIND ocamlopt"
_DEP_OPTS="-native"
else
BYTE=yes
OCAMLCOMP=OCAMLC
cma=cma
cmo=cmo
cmi=cmi
cmxs=cma
shared_flag=-a
if test "$enable_custom" = "no" ; then
NO_CUSTOM=yes ;
AC_PATH_PROG(OCAMLMKLIB,ocamlmklib,no)
if test "$OCAMLMKLIB" = "no"; then
AC_MSG_ERROR(Not found.)
fi
fi
if test "x$enable_profiling" = "xyes" ; then
OCAMLC="$OCAMLFIND ocamlcp"
else
OCAMLC="$OCAMLFIND ocamlc"
fi
_DEP_OPTS=""
fi
OCAML_VERSION="`$OCAMLC -version`"
OCAML_MAJOR="`echo $OCAML_VERSION | cut -d'.' -f 1`"
AC_SUBST(OCAML_MAJOR)
OCAML_MINOR="`echo $OCAML_VERSION | cut -d'.' -f 2`"
AC_SUBST(OCAML_MINOR)
OCAML_REVISION="`echo $OCAML_VERSION | cut -d'.' -f 3`"
AC_SUBST(OCAML_REVISION)
AC_MSG_CHECKING([for ocamlc version])
AC_MSG_RESULT([$OCAML_MAJOR.$OCAML_MINOR.$OCAML_REVISION])
AC_OCAML_COMPARE_VERSION([$OCAML_MAJOR.$OCAML_MINOR.$OCAML_REVISION],[$min_ocaml_version])
if test -z "${VERSION_OK}"; then
AC_MSG_ERROR([version $min_ocaml_version or greater of the OCaml compiler is required to build liquidsoap])
fi
AC_SUBST(BYTE)
AC_ARG_ENABLE([custom-path],
AS_HELP_STRING([--enable-custom-path],[Enable custom path support for loading liquidsoap's dependencies (always enable for win32 builds).]))
if test "$OS_TYPE" = "Win32" -o "x$enable_custom_path" = "xyes"; then
W_CUSTOM_PATH="yes"
w_CUSTOM_PATH="ok"
cat >> src/configure.ml <<__BLAH__
let get_dir d =
let dir =
Utils.resolve_path (Filename.dirname Sys.executable_name)
in
let cwd =
match Utils.getenv_opt "LIQUIDSOAP_BASE_DIR" with
| None -> dir
| Some path -> Utils.resolve_path ~cwd:dir path
in
Utils.resolve_path ~cwd d
__BLAH__
else
W_CUSTOM_PATH="no"
w_CUSTOM_PATH=""
fi
AC_SUBST(W_CUSTOM_PATH)
#
# Libs
#
###############################################################################
#
# Graphics
#
AC_CHECK_OCAML_BINDING([graphics])
#
# Bytes
#
AC_CHECK_OCAML_BINDING([bytes],[],[1])
#
# PCRE
#
AC_CHECK_OCAML_BINDING([pcre],[],[1])
#
# SEDLEX
#
AC_CHECK_OCAML_BINDING([sedlex],[],[1],[sedlex sedlex.ppx],[1])
#
# MENHIR
#
AC_CHECK_OCAML_BINDING([menhirLib],[],[1],[],[1])
MENHIR=`which menhir 2>/dev/null`
if test -z "${MENHIR}" ; then
AC_MSG_ERROR(Cannot find menhir binary)
fi
AC_SUBST(MENHIR)
#
# Dtools
#
AC_CHECK_OCAML_BINDING([dtools],[],[1])
#
# Duppy
#
AC_CHECK_OCAML_BINDING([duppy],[],[1])
#
# Cry
#
AC_CHECK_OCAML_BINDING([cry])
# ocaml-mm
#
AC_CHECK_OCAML_BINDING([mm],[],[1])
#
# xmlplaylist
#
AC_CHECK_OCAML_BINDING([xmlplaylist])
#
# Lastfm
#
AC_CHECK_OCAML_BINDING([lastfm],[xmlplaylist])
#
# Ogg
#
AC_CHECK_OCAML_BINDING([ogg])
#
# Vorbis
#
AC_CHECK_OCAML_BINDING([vorbis],[ogg])
#
# Opus
#
AC_CHECK_OCAML_BINDING([opus],[ogg])
#
# Speex
#
AC_CHECK_OCAML_BINDING([speex],[ogg])
#
# Mad
#
AC_CHECK_OCAML_BINDING([mad])
#
# Flac
#
AC_CHECK_OCAML_BINDING([flac])
# Small hack..
if test -z "${with_flac_ogg_dir}"; then
with_flac_ogg_dir=${with_flac_dir}
fi
AC_CHECK_OCAML_BINDING([flac.ogg],[ogg flac],[],[],[flac])
#
# Dynlink
#
AC_CHECK_OCAML_BINDING([dynlink])
# Dynlink may be for bytecode only..
AC_MSG_CHECKING([whether ocaml compiler supports dynlink])
if test -n "${W_DYNLINK}"; then
DYN_TEST_FILE_ML=`mktemp XXXX.ml`
trap "rm -f $DYN_TEST_FILE_ML; exit" SIGHUP SIGINT SIGTERM
echo "module Foo = Dynlink" > $DYN_TEST_FILE_ML
if ! $OCAMLC -linkpkg -package dynlink -o /dev/null $DYN_TEST_FILE_ML >/dev/null 2>&1; then
AC_MSG_RESULT([no])
AC_MSG_WARN([Dynlink module is installed but not available])
AC_MSG_WARN([Are you compiling to native code with ocaml < 3.11 ?])
AC_MSG_WARN([If your version of ocaml is >= 3.11, you may want to])
AC_MSG_WARN([report that issue to your distribution.])
W_DYNLINK=""
w_DYNLINK="no (not available)"
else
AC_MSG_RESULT([yes])
fi
DYN_TEST_FILE=`basename $DYN_TEST_FILE_ML .ml`
rm -f $DYN_TEST_FILE_ML $DYN_TEST_FILE.cmx $DYN_TEST_FILE.cmo $DYN_TEST_FILE.cmi $DYN_TEST_FILE.o
fi
if test -z "${W_DYNLINK}"; then
AC_MSG_WARN([no dynlink module: liquidsoap will not be able to load dynamic plugins!])
cat >> src/configure.ml <<EOCONF
let dynlink = false
EOCONF
else
cat >> src/configure.ml <<EOCONF
let dynlink = true
let () =
at_init (fun () ->
Dyntools.load_dynlinks ())
EOCONF
fi
#
# Lame
#
AC_CHECK_OCAML_BINDING([lame])
if test -z "${W_LAME}"; then
if test -n "${W_DYNLINK}"; then
if test -n "${OCAML_HAS_FIRST_CLASS_MODULES}"; then
W_LAME_DYN=yes
w_LAME="detected at runtime"
fi
fi
fi
AC_SUBST(W_LAME_DYN)
#
# Shine
#
AC_CHECK_OCAML_BINDING([shine])
#
# Gstreamer
#
AC_CHECK_OCAML_BINDING([gstreamer])
#
# frei0r
#
AC_CHECK_OCAML_BINDING([frei0r])
#
# Fdkaac
#
AC_CHECK_OCAML_BINDING([fdkaac])
if test -z "${W_FDKAAC}"; then
if test -n "${W_DYNLINK}"; then
if test -n "${OCAML_HAS_FIRST_CLASS_MODULES}"; then
W_FDKAAC_DYN=yes
w_FDKAAC="detected at runtime"
fi
fi
fi
AC_SUBST(W_FDKAAC_DYN)
#
# Theora
#
AC_CHECK_OCAML_BINDING([theora],[ogg])
#
# Gavl
#
AC_CHECK_OCAML_BINDING([gavl])
#
# FFMPEG
#
AC_CHECK_OCAML_BINDING([ffmpeg-avutil], [], [], [], [avutil])
AC_CHECK_OCAML_BINDING([ffmpeg-avcodec], [ffmpeg-avutil], [], [], [avcodec])
AC_CHECK_OCAML_BINDING([ffmpeg-av], [ffmpeg-avutil ffmpeg-avcodec], [], [], [av])
AC_CHECK_OCAML_BINDING([ffmpeg-avfilter], [ffmpeg-avutil], [], [], [avfilter])
AC_CHECK_OCAML_BINDING([ffmpeg-swresample], [ffmpeg-avutil ffmpeg-avcodec], [], [], [swresample])
AC_CHECK_OCAML_BINDING([ffmpeg-swscale], [ffmpeg-avutil], [], [], [swscale])
if test -n "${W_FFMPEG_AV}" && test -n "${W_FFMPEG_AVFILTER}" &&
test -n "${W_FFMPEG_SWSCALE}" && test -n "${W_FFMPEG_SWRESAMPLE}"; then
W_FFMPEG_DECODER=yes
w_FFMPEG_DECODER=yes
b_FFMPEG_DECODER=true
else
W_FFMPEG_DECODER=""
w_FFMPEG_DECODER="no (require ffmpeg-av, ffmpeg-avfilter, ffmpeg-swscale and ffmpeg-swresample)"
b_FFMPEG_DECODER=false
fi
AC_SUBST(W_FFMPEG_DECODER)
if test -n "${W_FFMPEG_AV}" && test -n "${W_FFMPEG_SWSCALE}" && test -n "${W_FFMPEG_SWRESAMPLE}"; then
W_FFMPEG_ENCODER=yes
w_FFMPEG_ENCODER=yes
b_FFMPEG_ENCODER=true
else
W_FFMPEG_ENCODER=""
w_FFMPEG_ENCODER="no (require ffmpeg-av, ffmpeg-swscale and ffmpeg-swresample)"
b_FFMPEG_ENCODER=false
fi
AC_SUBST(W_FFMPEG_ENCODER)
if test -n "${W_FFMPEG_AVFILTER}" &&
test -n "${W_FFMPEG_SWSCALE}" && test -n "${W_FFMPEG_SWRESAMPLE}"; then
W_FFMPEG_LIQ_FILTER=yes
w_FFMPEG_LIQ_FILTER=yes
b_FFMPEG_LIQ_FILTER=true
else
W_FFMPEG_LIQ_FILTER=""
w_FFMPEG_LIQ_FILTER="no (require ffmpeg-avfilter, ffmpeg-swscale and ffmpeg-swresample)"
b_FFMPEG_LIQ_FILTER=false
fi
AC_SUBST(W_FFMPEG_LIQ_FILTER)
#
# Jack
#
AC_CHECK_OCAML_BINDING([bjack])
#
# Alsa
#
AC_CHECK_OCAML_BINDING([alsa])
#
# LibAO
#
AC_CHECK_OCAML_BINDING([ao])
#
# Samplerate
#
AC_CHECK_OCAML_BINDING([samplerate])
#
# Taglib
#
AC_CHECK_OCAML_BINDING([taglib])
#
# OSS
#
AC_ARG_ENABLE([oss],AS_HELP_STRING([--disable-oss],[don't use OSS]))
if test "x$enable_oss" != "xno" ; then
AC_CHECK_HEADERS([sys/soundcard.h],[W_OSS="yes"])
fi
if test "a$W_OSS" = "ayes" ; then
w_OSS=yes
else
w_OSS=no
fi
AC_SUBST(W_OSS)
#
# SSL
#
AC_CHECK_OCAML_BINDING([ssl])
if test "a$W_SSL" = "ayes"; then
cat >> src/configure.ml <<EOCONF
let () =
Ssl_threads.init ();
Ssl.init ()
EOCONF
fi
#
# SecureTransport (OSX)
#
AC_CHECK_OCAML_BINDING([osx-secure-transport])
#
# Magic
#
AC_CHECK_OCAML_BINDING([magic])
if test -z "$W_MAGIC" ; then
cat >> src/configure.ml <<EOCONF
let file_mime = None
let data_mime = None
EOCONF
else
if test -z "$w_CUSTOM_PATH"; then
cat >> src/configure.ml <<EOCONF
let magic_cookie = Magic.create ~flags:[[Magic.Mime; Magic.Symlink]] [[]]
let file_mime = Some (Magic.file magic_cookie)
let data_mime = Some (Magic.buffer magic_cookie)
EOCONF
else
cat >> src/configure.ml <<EOCONF
let magic_file =
let cwd = Filename.dirname Sys.executable_name in
let magic =
Utils.getenv ~default:(get_dir "magic/magic.mgc") "MAGIC"
in
Utils.resolve_path ~cwd magic
let magic_cookie = Magic.create ~flags:[[Magic.Mime; Magic.Symlink]] [[magic_file]]
let file_mime = Some (Magic.file magic_cookie)
let data_mime = Some (Magic.buffer magic_cookie)
EOCONF
fi
fi
#
# Camomile
#
AC_ARG_ENABLE([camomile],
AS_HELP_STRING([--disable-camomile],[don't use camomile (no charset detection and conversion)]))
AC_CHECK_OCAML_BINDING([camomile])
AC_ARG_WITH([camomile-data-dir],
AC_HELP_STRING(
[--with-camomile-data-dir=path],
[path to camomile data files (autodetected by default)]))
if test -z "$W_CAMOMILE" ; then
if test "x$enable_camomile" = "xno" ; then
echo let recode_tag ?in_enc:_ ?out_enc:_ s = s >> src/configure.ml
else
AC_MSG_ERROR([Camomile provides charset detection and conversions. It is strongly advised to enable those features. If you really don't want this, use --disable-camomile.])
fi
else
if test -n "${with_camomile_data_dir}" ; then
camencoding="CamomileLibrary.CharEncoding.Configure(CamomileConfig)"
cat >> src/configure.ml <<EOCONF
module CamomileConfig =
struct
let datadir = Filename.concat "${with_camomile_data_dir}" "database"
let localedir = Filename.concat "${with_camomile_data_dir}" "locales"
let charmapdir = Filename.concat "${with_camomile_data_dir}" "charmaps"
let unimapdir = Filename.concat "${with_camomile_data_dir}" "mappings"
end
EOCONF
elif test -n "$w_CUSTOM_PATH" ; then
camencoding="CamomileLibrary.CharEncoding.Configure(CamomileConfig)"
cat >> src/configure.ml <<EOCONF
module CamomileConfig =
struct
let datadir = Filename.concat (get_dir "camomile") "database"
let localedir = Filename.concat (get_dir "camomile") "locales"
let charmapdir = Filename.concat (get_dir "camomile") "charmaps"
let unimapdir = Filename.concat (get_dir "camomile") "mappings"
end
EOCONF
else
camencoding=CamomileLibraryDefault.Camomile.CharEncoding
fi
cat >> src/configure.ml <<EOCONF
module C = $camencoding
exception Unknown_encoding of string
let enc_of_name s =
try C.of_name s with
| Not_found -> raise (Unknown_encoding s)
let conf_tag =
Dtools.Conf.void ~p:(conf#plug "tag") "Settings related to metadata tags"
let conf_encoding =
(* The [["foo";"bla"]] may be stripped by configure here.. We avoided it by chance because
* the configure script takes conf_tag#plug as the begining of a comment.
* Don't forget this when modifying this inclusion later... *)
Dtools.Conf.list ~p:(conf_tag#plug "encodings") ~d:["UTF-8";"ISO-8859-1"]
"List of encodings to try for automatic encoding detection"
let custom_encoding = ref None
let get_encoding () =
match !custom_encoding with
| Some e -> e
| None ->
let encs = conf_encoding#get in
let e = C.automatic "LIQ-TAGS" (List.map enc_of_name encs) C.utf8 in
custom_encoding := Some e ;
e
let camolog = Log.make [["camomile"]]
exception Input_encoding of string
exception Output_encoding of string
let recode_tag ?in_enc ?out_enc s =
try
let in_enc =
try
match in_enc with
| Some e -> enc_of_name e
| None -> get_encoding ()
with Unknown_encoding s ->
raise (Input_encoding s)
in
let out_enc =
try
match out_enc with
| Some e -> enc_of_name e
| None -> C.utf8
with Unknown_encoding s ->
raise (Output_encoding s)
in
try C.recode_string ~in_enc ~out_enc s with e ->
let in_enc =
if in_enc == get_encoding () then
Printf.sprintf "auto(%s)" (String.concat "," conf_encoding#get)
else
C.name_of in_enc
in
camolog#important "Failed to convert %S from %s to %s (%s)!"
s in_enc (C.name_of out_enc) (Printexc.to_string e) ;
s
with
| Unknown_encoding e ->
camolog#important "Failed to convert %S: unknown encoding %s"
s e ; s
| Input_encoding e ->
camolog#important "Failed to convert %S: unknown input encoding %s"
s e ; s
| Output_encoding e ->
camolog#important "Failed to convert %S: unknown output encoding %s"
s e ; s
| e ->
camolog#important "Failed to convert %S: unknown error %s"
s (Printexc.to_string e) ; s
let env_has key = try ignore (Sys.getenv key) ; true with Not_found -> false
let recode_tag =
if env_has "LIQ_DISABLE_CAMOMILE" then
fun ?in_enc:_ ?out_enc:_ s -> s
else
recode_tag
EOCONF
fi
# Inotify
AC_CHECK_OCAML_BINDING([inotify])
cat >> src/configure.ml <<EOCONF
let file_watcher = ref File_watcher_mtime.watch
EOCONF
# Yojson
AC_CHECK_OCAML_BINDING([yojson])
if test -z "${W_YOJSON}"; then
cat >> src/configure.ml <<__BLAH__
module JSON = JSON
__BLAH__
else
cat >> src/configure.ml <<__BLAH__
module JSON = struct include Yojson.Basic let from_string s = from_string s let to_string j = pretty_to_string j end
__BLAH__
fi
# OCaml bindings
AC_CHECK_OCAML_BINDING([faad])
AC_CHECK_OCAML_BINDING([soundtouch])
AC_CHECK_OCAML_BINDING([portaudio])
AC_CHECK_OCAML_BINDING([pulseaudio])
AC_CHECK_OCAML_BINDING([ladspa])
AC_CHECK_OCAML_BINDING([dssi])
AC_CHECK_OCAML_BINDING([lilv])
AC_CHECK_OCAML_BINDING([tsdl])
AC_CHECK_OCAML_BINDING([tsdl_ttf],[tsdl])
AC_CHECK_OCAML_BINDING([tsdl_image],[tsdl])
AC_CHECK_OCAML_BINDING([camlimages],[],[],[camlimages.all_formats])
AC_CHECK_OCAML_BINDING([cohttp-lwt-unix])
AC_CHECK_OCAML_BINDING([prometheus-app],[cohttp-lwt-unix])
# TODO: switch to dune all the way?
with_srt_types_dir=${with_srt_dir}
liquidsoap_ocamlcflags="${liquidsoap_ocamlcflags} -I ${with_srt_dir}/types"
AC_CHECK_OCAML_BINDING([srt.types],[],[],[],[srt_types])
with_srt_stubs_dir=${with_srt_dir}
liquidsoap_ocamlcflags="${liquidsoap_ocamlcflags} -I ${with_srt_dir}/stubs"
AC_CHECK_OCAML_BINDING([srt.stubs],[srt.types],[],[],[srt_stubs])
with_srt_stubs_locked_dir=${with_srt_dir}
liquidsoap_ocamlcflags="${liquidsoap_ocamlcflags} -I ${with_srt_dir}/stubs/locked"
AC_CHECK_OCAML_BINDING([srt.stubs],[],[],[],[srt_stubs_locked])
AC_CHECK_OCAML_BINDING([srt],[srt.types srt.stubs srt.stubs.locked])
AC_CHECK_OCAML_BINDING([lo])
AC_CHECK_OCAML_BINDING([gd])
# Winsvc (to run as a service)
AC_CHECK_OCAML_BINDING([winsvc])
#
# Tuning (See INSTALL to understand these features)
#
###############################################################################
#
# Requests
#
requests_table_size=50
requests_max_id=50
cat >> src/configure.ml <<EOCONF
let requests_max_id = $requests_max_id
let requests_table_size = $requests_table_size
EOCONF
#
# Font for video.add_text*()
#
AC_ARG_WITH([default-font],
AS_HELP_STRING([--with-default-font],
[sets the default TTF font for video.add_text()]))
if test -z "$with_default_font" ; then
DEFAULT_FONT=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
else
DEFAULT_FONT=$with_default_font
fi
cat >> src/configure.ml <<__BLAH__
let default_font = "$DEFAULT_FONT"
__BLAH__
#
# GUI
#
AC_ARG_ENABLE([gui],
AS_HELP_STRING([--disable-gui],[don't use the controller GUI]))
w_PYTHON=no
if test "x$enable_gui" != "xno" ; then
AC_PATH_PROG(PYTHON,python,no)
if test \! "$PYTHON" = no ; then
AC_MSG_CHECKING(for pygtk)
dnl Check for pygtk and find python version
PYVERSION=`$PYTHON -c "import sys ; import re ; import pygtk ; print re.search('^\d+\.\d+',sys.version).group(0)" 2> /dev/null`
if test $? = 0 ; then
AC_MSG_RESULT(yes)
PYMDIR="\${libdir}/python$PYVERSION/site-packages/liquidsoap"
W_PYTHON=yes
w_PYTHON="yes (requires >=pyGTK-2.0)"
cat > gui/liguidsoap <<__EOP__
#!/usr/bin/env python
import sys
sys.path.insert(0,"${prefix}/lib/python$PYVERSION/site-packages/liquidsoap")
import liguidsoap
liguidsoap.liguidsoap()
__EOP__
chmod +x gui/liguidsoap
else
AC_MSG_RESULT(no)
fi
fi
fi
AC_SUBST(W_PYTHON)
AC_SUBST(PYMDIR)
if test "x$W_AO" = "xyes" ; then
prefered_output=output.ao
else
if test "x$W_ALSA" = "xyes" ; then
prefered_output=output.alsa
else
prefered_output=output.dummy
fi
fi
AC_SUBST(prefered_output)
#
# All done.
#
###############################################################################
cat >> src/configure.ml <<__BLAH__
let libs_versions = "$LIBS_VERSIONS"
__BLAH__
AC_SUBST(OCAMLCOMP)
AC_SUBST(NO_CUSTOM)
AC_SUBST(_DEP_OPTS)
AC_SUBST(liquidsoap_ocamlcflags)
AC_SUBST(liquidsoap_ocamllflags)
AC_SUBST(requires)
AC_SUBST(cma)
AC_SUBST(cmo)
AC_SUBST(cmi)
AC_SUBST(cmxs)
AC_SUBST(shared_flag)
echo
AC_CONFIG_FILES([doc/content/install.md])
AC_CONFIG_FILES([doc/content/build.md])
AC_CONFIG_FILES([doc/liquidsoap.1.md])
AC_CONFIG_FILES([Makefile.defs],[chmod a-w Makefile.defs])
AC_CONFIG_FILES([src/META],[chmod a-w src/META])
AC_OUTPUT
$MAKE finish-configure
if test "$BYTE" = "yes"; then
if test "$NO_CUSTOM" = "yes" ; then
BYTE_COMP="NO_CUSTOM : yes
OCAMLMKLIB : $OCAMLMKLIB
"
fi
fi
if test "$CAMLP4O" != "no"; then
CAMLP4O_COMP="CAMLP4O : $CAMLP4O
"
fi
cat <<EOMSG
----------------------------------------------------------------- Compilation