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
|
# vi: ft=python
import sys, os, re
sys.path.insert(0, os.path.join(os.getcwd(), 'waftools'))
sys.path.insert(0, os.getcwd())
from waflib.Configure import conf
from waflib.Tools import c_preproc
from waflib import Utils
from waftools.checks.generic import *
from waftools.checks.custom import *
c_preproc.go_absolute=True # enable system folders
c_preproc.standard_includes.append('/usr/local/include')
build_options = [
{
'name': '--cplayer',
'desc': 'mpv CLI player',
'default': 'enable',
'func': check_true
}, {
'name': '--libmpv-shared',
'desc': 'shared library',
'default': 'disable',
'func': check_true
}, {
'name': '--libmpv-static',
'desc': 'static library',
'default': 'disable',
'deps_neg': [ 'libmpv-shared' ],
'func': check_true
}, {
'name': '--static-build',
'desc': 'static build',
'default': 'disable',
'func': check_true
}, {
'name': '--build-date',
'desc': 'whether to include binary compile time',
'default': 'enable',
'func': check_true
}, {
'name': '--optimize',
'desc': 'whether to optimize',
'default': 'enable',
'func': check_true
}, {
'name': '--debug-build',
'desc': 'whether to compile-in debugging information',
'default': 'enable',
'func': check_true
}, {
'name': '--manpage-build',
'desc': 'manpage generation',
'func': check_ctx_vars('RST2MAN')
}, {
'name': '--html-build',
'desc': 'html manual generation',
'func': check_ctx_vars('RST2HTML'),
'default': 'disable',
}, {
'name': '--pdf-build',
'desc': 'pdf manual generation',
'func': check_ctx_vars('RST2PDF'),
'default': 'disable',
}, {
'name': 'libdl',
'desc': 'dynamic loader',
'func': check_libs(['dl'], check_statement('dlfcn.h', 'dlopen("", 0)'))
}, {
'name': 'dlopen',
'desc': 'dlopen',
'deps_any': [ 'libdl', 'os-win32', 'os-cygwin' ],
'func': check_true
}, {
'name': '--vf-dlopen-filters',
'desc': 'compilation of default filters for vf_dlopen',
'deps': [ 'dlopen' ],
'default': 'disable',
'func': check_true
}, {
'name': '--zsh-comp',
'desc': 'zsh completion',
'func': check_true,
'default': 'disable',
}, {
# does nothing - left for backward and forward compatibility
'name': '--asm',
'desc': 'inline assembly (currently without effect)',
'default': 'enable',
'func': check_true,
}, {
'name': '--test',
'desc': 'test suite (using cmocka)',
'func': check_pkg_config('cmocka', '>= 1.0.0'),
'default': 'disable',
}, {
'name': '--clang-database',
'desc': 'generate a clang compilation database',
'func': check_true,
'default': 'disable',
}
]
main_dependencies = [
{
'name': 'noexecstack',
'desc': 'compiler support for noexecstack',
'func': check_cc(linkflags='-Wl,-z,noexecstack')
}, {
'name': 'noexecstack',
'desc': 'linker support for --nxcompat --no-seh --dynamicbase',
'func': check_cc(linkflags=['-Wl,--nxcompat', '-Wl,--no-seh', '-Wl,--dynamicbase'])
} , {
'name': 'libm',
'desc': '-lm',
'func': check_cc(lib='m')
}, {
'name': 'mingw',
'desc': 'MinGW',
'deps': [ 'os-win32' ],
'func': check_statement('stddef.h', 'int x = __MINGW32__;'
'int y = __MINGW64_VERSION_MAJOR'),
}, {
'name': 'posix',
'desc': 'POSIX environment',
# This should be good enough.
'func': check_statement(['poll.h', 'unistd.h', 'sys/mman.h'],
'struct pollfd pfd; poll(&pfd, 1, 0); fork(); int f[2]; pipe(f); munmap(f,0)'),
}, {
'name': 'fnmatch',
'desc': 'fnmatch()',
'func': check_statement('fnmatch.h', 'fnmatch("", "", 0)')
}, {
'name': 'posix-or-mingw',
'desc': 'development environment',
'deps_any': [ 'posix', 'mingw' ],
'func': check_true,
'req': True,
'fmsg': 'Unable to find either POSIX or MinGW-w64 environment, ' \
'or compiler does not work.',
}, {
'name': 'win32',
'desc': 'win32',
'deps_any': [ 'os-win32', 'os-cygwin' ],
'func': check_cc(lib=['winmm', 'gdi32', 'ole32', 'uuid', 'avrt', 'dwmapi']),
}, {
'name': '--win32-internal-pthreads',
'desc': 'internal pthread wrapper for win32 (Vista+)',
'deps_neg': [ 'posix' ],
'deps': [ 'win32' ],
'func': check_true,
}, {
'name': 'pthreads',
'desc': 'POSIX threads',
'func': check_pthreads,
'req': True,
'fmsg': 'Unable to find pthreads support.'
}, {
'name': 'gnuc',
'desc': 'GNU C extensions',
'func': check_statement([], "__GNUC__"),
}, {
'name': 'stdatomic',
'desc': 'stdatomic.h',
'func': check_libs(['atomic'],
check_statement('stdatomic.h',
'atomic_int_least64_t test = ATOMIC_VAR_INIT(123);'
'atomic_fetch_add(&test, 1)'))
}, {
'name': 'atomic-builtins',
'desc': 'compiler support for __atomic built-ins',
'func': check_libs(['atomic'],
check_statement('stdint.h',
'int64_t test = 0;'
'test = __atomic_add_fetch(&test, 1, __ATOMIC_SEQ_CST)')),
'deps_neg': [ 'stdatomic' ],
}, {
'name': 'sync-builtins',
'desc': 'compiler support for __sync built-ins',
'func': check_statement('stdint.h',
'int64_t test = 0;'
'__typeof__(test) x = ({int a = 1; a;});'
'test = __sync_add_and_fetch(&test, 1)'),
'deps_neg': [ 'stdatomic', 'atomic-builtins' ],
}, {
'name': 'atomics',
'desc': 'stdatomic.h support or emulation',
'func': check_true,
'req': True,
'deps_any': ['stdatomic', 'atomic-builtins', 'sync-builtins', 'gnuc'],
}, {
'name': 'c11-tls',
'desc': 'C11 TLS support',
'func': check_statement('stddef.h', 'static _Thread_local int x = 0'),
}, {
'name': 'gcc-tls',
'desc': 'GCC TLS support',
'func': check_statement('stddef.h', 'static __thread int x = 0'),
}, {
'name': 'librt',
'desc': 'linking with -lrt',
'deps': [ 'pthreads' ],
'func': check_cc(lib='rt')
}, {
'name': '--iconv',
'desc': 'iconv',
'func': check_iconv,
'req': True,
'fmsg': "Unable to find iconv which should be part of a standard \
compilation environment. Aborting. If you really mean to compile without \
iconv support use --disable-iconv.",
}, {
'name': 'dos-paths',
'desc': 'w32/dos paths',
'deps_any': [ 'os-win32', 'os-cygwin' ],
'func': check_true
}, {
'name': '--termios',
'desc': 'termios',
'func': check_headers('termios.h', 'sys/termios.h'),
}, {
'name': '--shm',
'desc': 'shm',
'func': check_statement(['sys/types.h', 'sys/ipc.h', 'sys/shm.h'],
'shmget(0, 0, 0); shmat(0, 0, 0); shmctl(0, 0, 0)')
}, {
'name': 'nanosleep',
'desc': 'nanosleep',
'func': check_statement('time.h', 'nanosleep(0,0)')
}, {
'name': 'posix-spawn',
'desc': 'POSIX spawnp()/kill()',
'func': check_statement(['spawn.h', 'signal.h'],
'posix_spawnp(0,0,0,0,0,0); kill(0,0)'),
'deps_neg': ['mingw'],
}, {
'name': 'subprocess',
'desc': 'posix_spawnp() or MinGW',
'func': check_true,
'deps_any': ['posix-spawn', 'mingw'],
}, {
'name': 'glob',
'desc': 'glob()',
'func': check_statement('glob.h', 'glob("filename", 0, 0, 0)')
}, {
'name': 'glob-win32-replacement',
'desc': 'glob() win32 replacement',
'deps_neg': [ 'glob' ],
'deps_any': [ 'os-win32', 'os-cygwin' ],
'func': check_true
}, {
'name': 'fchmod',
'desc': 'fchmod()',
'func': check_statement('sys/stat.h', 'fchmod(0, 0)'),
}, {
'name': 'vt.h',
'desc': 'vt.h',
'func': check_statement(['sys/vt.h', 'sys/ioctl.h'],
'int m; ioctl(0, VT_GETMODE, &m)'),
}, {
'name': 'gbm.h',
'desc': 'gbm.h',
'func': check_cc(header_name=['stdio.h', 'gbm.h']),
}, {
'name': 'glibc-thread-name',
'desc': 'GLIBC API for setting thread name',
'func': check_statement('pthread.h',
'pthread_setname_np(pthread_self(), "ducks")',
use=['pthreads']),
}, {
'name': 'osx-thread-name',
'desc': 'OSX API for setting thread name',
'deps_neg': [ 'glibc-thread-name' ],
'func': check_statement('pthread.h',
'pthread_setname_np("ducks")', use=['pthreads']),
}, {
'name': 'bsd-thread-name',
'desc': 'BSD API for setting thread name',
'deps_neg': [ 'glibc-thread-name', 'osx-thread-name' ],
'func': check_statement(['pthread.h', 'pthread_np.h'],
'pthread_set_name_np(pthread_self(), "ducks")',
use=['pthreads']),
}, {
'name': 'netbsd-thread-name',
'desc': 'NetBSD API for setting thread name',
'deps_neg': [ 'glibc-thread-name', 'osx-thread-name', 'bsd-thread-name' ],
'func': check_statement('pthread.h',
'pthread_setname_np(pthread_self(), "%s", (void *)"ducks")',
use=['pthreads']),
}, {
'name': 'bsd-fstatfs',
'desc': "BSD's fstatfs()",
'func': check_statement(['sys/param.h', 'sys/mount.h'],
'struct statfs fs; fstatfs(0, &fs); fs.f_fstypename')
}, {
'name': 'linux-fstatfs',
'desc': "Linux's fstatfs()",
'deps': [ 'os-linux' ],
'func': check_statement('sys/vfs.h',
'struct statfs fs; fstatfs(0, &fs); fs.f_namelen')
}, {
'name': '--libsmbclient',
'desc': 'Samba support',
'deps': [ 'libdl' ],
'func': check_pkg_config('smbclient'),
'module': 'input',
}, {
'name' : '--lua',
'desc' : 'Lua',
'func': check_lua,
}, {
'name': '--libass',
'desc': 'SSA/ASS support',
'func': check_pkg_config('libass', '>= 0.12.1'),
'req': True,
'fmsg': "Unable to find development files for libass, or the version " +
"found is too old. Aborting. If you really mean to compile " +
"without libass support use --disable-libass."
}, {
'name': '--libass-osd',
'desc': 'libass OSD support',
'deps': [ 'libass' ],
'func': check_true,
}, {
'name': 'dummy-osd',
'desc': 'dummy OSD support',
'deps_neg': [ 'libass-osd' ],
'func': check_true,
} , {
'name': 'zlib',
'desc': 'zlib',
'func': check_libs(['z'],
check_statement('zlib.h', 'inflate(0, Z_NO_FLUSH)')),
'req': True,
'fmsg': 'Unable to find development files for zlib.'
} , {
'name' : '--encoding',
'desc' : 'Encoding',
'func': check_true,
}, {
'name': '--libbluray',
'desc': 'Bluray support',
'func': check_pkg_config('libbluray', '>= 0.3.0'),
}, {
'name': '--dvdread',
'desc': 'dvdread support',
'func': check_pkg_config('dvdread', '>= 4.1.0'),
}, {
'name': '--dvdnav',
'desc': 'dvdnav support',
'deps': [ 'dvdread' ],
'func': check_pkg_config('dvdnav', '>= 4.2.0'),
}, {
'name': '--cdda',
'desc': 'cdda support (libcdio)',
'func': check_pkg_config('libcdio_paranoia'),
}, {
'name': '--enca',
'desc': 'ENCA support',
'deps': [ 'iconv' ],
'func': check_statement('enca.h', 'enca_get_languages(NULL)', lib='enca'),
}, {
'name': '--libguess',
'desc': 'libguess support',
'deps': [ 'iconv' ],
'func': check_pkg_config('libguess', '>= 1.0'),
}, {
'name': '--uchardet',
'desc': 'uchardet support',
'deps': [ 'iconv' ],
'func': check_pkg_config('uchardet'),
}, {
'name': '--rubberband',
'desc': 'librubberband support',
'func': check_pkg_config('rubberband', '>= 1.8.0'),
}, {
'name': '--lcms2',
'desc': 'LCMS2 support',
'func': check_pkg_config('lcms2', '>= 2.6'),
}, {
'name': '--vapoursynth',
'desc': 'VapourSynth filter bridge (Python)',
'func': check_pkg_config('vapoursynth', '>= 24',
'vapoursynth-script', '>= 23'),
}, {
'name': '--vapoursynth-lazy',
'desc': 'VapourSynth filter bridge (Lazy Lua)',
'deps': ['lua'],
'func': check_pkg_config('vapoursynth', '>= 24'),
}, {
'name': 'vapoursynth-core',
'desc': 'VapourSynth filter bridge (core)',
'deps_any': ['vapoursynth', 'vapoursynth-lazy'],
'func': check_true,
}, {
'name': '--libarchive',
'desc': 'libarchive wrapper for reading zip files and more',
'func': check_pkg_config('libarchive >= 3.0.0'),
'default': 'disable',
}
]
libav_pkg_config_checks = [
'libavutil', '>= 54.02.0',
'libavcodec', '>= 56.1.0',
'libavformat', '>= 56.01.0',
'libswscale', '>= 2.1.3'
]
libav_versions_string = "FFmpeg 2.4 or Libav 11"
libav_dependencies = [
{
'name': 'libav',
'desc': 'libav/ffmpeg',
'func': check_pkg_config(*libav_pkg_config_checks),
'req': True,
'fmsg': "Unable to find development files for some of the required \
FFmpeg/Libav libraries. You need at least {0}. Aborting.".format(libav_versions_string)
}, {
'name': '--libswresample',
'desc': 'libswresample',
'func': check_pkg_config('libswresample', '>= 1.1.100'),
}, {
'name': '--libavresample',
'desc': 'libavresample',
'func': check_pkg_config('libavresample', '>= 2.1.0'),
'deps_neg': ['libswresample'],
}, {
'name': 'resampler',
'desc': 'usable resampler found',
'deps_any': [ 'libavresample', 'libswresample' ],
'func': check_true,
'req': True,
'fmsg': 'No resampler found. Install libavresample or libswresample (FFmpeg).'
}, {
'name': 'libavfilter',
'desc': 'libavfilter',
'func': check_pkg_config('libavfilter', '>= 5.0.0'),
'req': True,
'fmsg': 'libavfilter is a required dependency.',
}, {
'name': '--libavdevice',
'desc': 'libavdevice',
'func': check_pkg_config('libavdevice', '>= 55.0.0'),
}, {
'name': 'avcodec-chroma-pos-api',
'desc': 'libavcodec avcodec_enum_to_chroma_pos API',
'func': check_statement('libavcodec/avcodec.h', """int x, y;
avcodec_enum_to_chroma_pos(&x, &y, AVCHROMA_LOC_UNSPECIFIED)""",
use='libav')
}, {
'name': 'avframe-metadata',
'desc': 'libavutil AVFrame metadata',
'func': check_statement('libavutil/frame.h',
'av_frame_get_metadata(NULL)',
use='libav')
}, {
'name': 'avframe-skip-samples',
'desc': 'libavutil AVFrame skip samples metadata',
'func': check_statement('libavutil/frame.h',
'enum AVFrameSideDataType type = AV_FRAME_DATA_SKIP_SAMPLES',
use='libav')
}, {
'name': 'av-pix-fmt-mmal',
'desc': 'libavutil AV_PIX_FMT_MMAL',
'func': check_statement('libavutil/pixfmt.h',
'int x = AV_PIX_FMT_MMAL',
use='libav'),
}, {
'name': 'av-version-info',
'desc': 'libavtuil av_version_info()',
'func': check_statement('libavutil/avutil.h',
'const char *x = av_version_info()',
use='libav'),
}, {
'name': 'av-new-pixdesc',
'desc': 'libavutil new pixdesc fields',
'func': check_statement('libavutil/pixdesc.h',
'AVComponentDescriptor d; int x = d.depth',
use='libav'),
}, {
'name': 'av-avpacket-int64-duration',
'desc': 'libavcodec 64 bit AVPacket.duration',
'func': check_statement('libavcodec/avcodec.h',
'int x[(int)sizeof(((AVPacket){0}).duration) - 7]',
use='libav'),
}, {
'name': 'av-subtitle-nopict',
'desc': 'libavcodec AVSubtitleRect AVPicture removal',
'func': check_statement('libavcodec/avcodec.h',
'AVSubtitleRect r = {.linesize={0}}',
use='libav'),
}, {
'name': 'avcodec-profile-name',
'desc': 'libavcodec avcodec_profile_name()',
'func': check_statement('libavcodec/avcodec.h',
'avcodec_profile_name(0,0)',
use='libav'),
}, {
'name': 'avcodec-new-codec-api',
'desc': 'libavcodec decode/encode API',
'func': check_statement('libavcodec/avcodec.h',
'avcodec_send_packet(0,0)',
use='libav'),
}, {
'name': 'avcodec-has-codecpar',
'desc': 'libavcodec AVCodecParameters API',
'func': check_statement('libavformat/avformat.h',
'(void)offsetof(AVStream, codecpar)',
use='libav'),
}, {
'name': 'avutil-has-hwcontext',
'desc': 'libavutil AVHWFramesContext API',
'func': check_statement('libavutil/frame.h',
'(void)offsetof(AVFrame, hw_frames_ctx)',
use='libav'),
}, {
'name': 'avutil-hdr',
'desc': 'libavutil HDR TRCs',
'func': check_statement('libavutil/pixfmt.h',
'AVCOL_TRC_SMPTEST2084,'
'AVCOL_TRC_ARIB_STD_B67',
use='libav'),
}, {
'name': 'avutil-mastering-metadata',
'desc': 'libavutil mastering display metadata struct',
'func': check_statement('libavutil/frame.h',
'AV_FRAME_DATA_MASTERING_DISPLAY_METADATA',
use='libav'),
}
]
audio_output_features = [
{
'name': '--sdl2',
'desc': 'SDL2',
'func': check_pkg_config('sdl2'),
'default': 'disable'
}, {
'name': '--sdl1',
'desc': 'SDL (1.x)',
'deps_neg': [ 'sdl2' ],
'func': check_pkg_config('sdl'),
'default': 'disable'
}, {
'name': 'oss-audio-4front',
'desc': 'OSS (implementation from opensound.com)',
'func': check_oss_4front,
'groups' : [ 'oss-audio' ]
}, {
'name': 'oss-audio-native',
'desc': 'OSS (platform-specific OSS implementation)',
'func': check_cc(header_name='sys/soundcard.h',
defines=['PATH_DEV_DSP="/dev/dsp"',
'PATH_DEV_MIXER="/dev/mixer"'],
fragment=load_fragment('oss_audio.c')),
'deps_neg': [ 'oss-audio-4front' ],
'groups' : [ 'oss-audio' ]
}, {
'name': 'oss-audio-sunaudio',
'desc': 'OSS (emulation on top of SunAudio)',
'func': check_cc(header_name='soundcard.h',
lib='ossaudio',
defines=['PATH_DEV_DSP="/dev/sound"',
'PATH_DEV_MIXER="/dev/mixer"'],
fragment=load_fragment('oss_audio_sunaudio.c')),
'deps_neg': [ 'oss-audio-4front', 'oss-audio-native' ],
'groups' : [ 'oss-audio' ]
}, {
'name': '--oss-audio',
'desc': 'OSS audio output',
'func': check_true,
'deps_any': [ 'oss-audio-native', 'oss-audio-sunaudio',
'oss-audio-4front' ]
}, {
'name': '--rsound',
'desc': 'RSound audio output',
'func': check_statement('rsound.h', 'rsd_init(NULL)', lib='rsound')
}, {
'name': '--sndio',
'desc': 'sndio audio input/output',
'func': check_statement('sndio.h',
'struct sio_par par; sio_initpar(&par); const char *s = SIO_DEVANY', lib='sndio'),
'default': 'disable'
}, {
'name': '--pulse',
'desc': 'PulseAudio audio output',
'func': check_pkg_config('libpulse', '>= 1.0')
}, {
'name': '--jack',
'desc': 'JACK audio output',
'func': check_pkg_config('jack'),
}, {
'name': '--openal',
'desc': 'OpenAL audio output',
'func': check_openal,
'default': 'disable'
}, {
'name': '--opensles',
'desc': 'OpenSL ES audio output',
'func': check_statement('SLES/OpenSLES.h', 'slCreateEngine', lib="OpenSLES"),
}, {
'name': '--alsa',
'desc': 'ALSA audio output',
'func': check_pkg_config('alsa', '>= 1.0.18'),
}, {
'name': '--coreaudio',
'desc': 'CoreAudio audio output',
'func': check_cc(
fragment=load_fragment('coreaudio.c'),
framework_name=['CoreFoundation', 'CoreAudio', 'AudioUnit', 'AudioToolbox'])
}, {
'name': '--audiounit',
'desc': 'AudioUnit output for iOS',
'deps': ['atomics'],
'func': check_cc(
fragment=load_fragment('audiounit.c'),
framework_name=['Foundation', 'AudioToolbox'])
}, {
'name': '--wasapi',
'desc': 'WASAPI audio output',
'deps': ['win32'],
'func': check_cc(fragment=load_fragment('wasapi.c')),
}
]
video_output_features = [
{
'name': '--cocoa',
'desc': 'Cocoa',
'func': check_cocoa
}, {
'name': '--drm',
'desc': 'DRM',
'deps': [ 'vt.h' ],
'func': check_pkg_config('libdrm'),
}, {
'name': '--gbm',
'desc': 'GBM',
'deps': [ 'gbm.h' ],
'func': check_pkg_config('gbm'),
} , {
'name': '--wayland',
'desc': 'Wayland',
'func': check_pkg_config('wayland-client', '>= 1.6.0',
'wayland-cursor', '>= 1.6.0',
'xkbcommon', '>= 0.3.0'),
} , {
'name': '--x11',
'desc': 'X11',
'func': check_pkg_config('x11'),
} , {
'name': '--xss',
'desc': 'Xss screensaver extensions',
'deps': [ 'x11' ],
'func': check_pkg_config('xscrnsaver'),
} , {
'name': '--xext',
'desc': 'X extensions',
'deps': [ 'x11' ],
'func': check_pkg_config('xext'),
} , {
'name': '--xv',
'desc': 'Xv video output',
'deps': [ 'x11' ],
'func': check_pkg_config('xv'),
} , {
'name': '--xinerama',
'desc': 'Xinerama',
'deps': [ 'x11' ],
'func': check_pkg_config('xinerama'),
}, {
'name': '--xrandr',
'desc': 'Xrandr',
'deps': [ 'x11' ],
'func': check_pkg_config('xrandr', '>= 1.2.0'),
} , {
'name': '--gl-cocoa',
'desc': 'OpenGL Cocoa Backend',
'deps': [ 'cocoa' ],
'groups': [ 'gl' ],
'func': check_statement('IOSurface/IOSurface.h',
'IOSurfaceRef surface;',
framework='IOSurface')
} , {
'name': '--gl-x11',
'desc': 'OpenGL X11 Backend',
'deps': [ 'x11' ],
'groups': [ 'gl' ],
'func': check_libs(['GL', 'GL Xdamage'],
check_cc(fragment=load_fragment('gl_x11.c'),
use=['x11', 'libdl', 'pthreads']))
} , {
'name': '--egl-x11',
'desc': 'OpenGL X11 EGL Backend',
'deps': [ 'x11' ],
'groups': [ 'gl' ],
'func': check_pkg_config('egl', 'gl'),
} , {
'name': '--egl-drm',
'desc': 'OpenGL DRM EGL Backend',
'deps': [ 'drm', 'gbm' ],
'groups': [ 'gl' ],
'func': compose_checks(
check_pkg_config('egl'),
check_pkg_config_cflags('gl')
)
} , {
'name': '--gl-wayland',
'desc': 'OpenGL Wayland Backend',
'deps': [ 'wayland' ],
'groups': [ 'gl' ],
'func': check_pkg_config('wayland-egl', '>= 9.0.0',
'egl', '>= 9.0.0')
} , {
'name': '--gl-win32',
'desc': 'OpenGL Win32 Backend',
'deps': [ 'win32' ],
'groups': [ 'gl' ],
'func': check_statement('windows.h', 'wglCreateContext(0)',
lib='opengl32')
} , {
'name': '--gl-dxinterop',
'desc': 'OpenGL/DirectX Interop Backend',
'deps': [ 'gl-win32' ],
'groups': [ 'gl' ],
'func': compose_checks(
check_statement(['GL/gl.h', 'GL/wglext.h'], 'int i = WGL_ACCESS_WRITE_DISCARD_NV'),
check_statement('d3d9.h', 'IDirect3D9Ex *d'))
} , {
'name': '--egl-angle',
'desc': 'OpenGL Win32 ANGLE Backend',
'deps_any': [ 'os-win32', 'os-cygwin' ],
'groups': [ 'gl' ],
'func': check_statement(['EGL/egl.h', 'EGL/eglext.h'],
'int x = EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE')
} , {
'name': '--vdpau',
'desc': 'VDPAU acceleration',
'deps': [ 'x11' ],
'func': check_pkg_config('vdpau', '>= 0.2'),
} , {
'name': '--vdpau-gl-x11',
'desc': 'VDPAU with OpenGL/X11',
'deps': [ 'vdpau', 'gl-x11' ],
'func': check_true,
}, {
'name': '--vaapi',
'desc': 'VAAPI acceleration',
'deps': [ 'libdl' ],
'deps_any': [ 'x11', 'wayland', 'egl-drm' ],
'func': check_pkg_config('libva', '>= 0.36.0'),
}, {
'name': '--vaapi-x11',
'desc': 'VAAPI (X11 support)',
'deps': [ 'vaapi', 'x11' ],
'func': check_pkg_config('libva-x11', '>= 0.36.0'),
}, {
'name': '--vaapi-wayland',
'desc': 'VAAPI (Wayland support)',
'deps': [ 'vaapi', 'gl-wayland' ],
'func': check_pkg_config('libva-wayland', '>= 0.36.0'),
}, {
'name': '--vaapi-drm',
'desc': 'VAAPI (DRM/EGL support)',
'deps': [ 'vaapi', 'egl-drm' ],
'func': check_pkg_config('libva-drm', '>= 0.36.0'),
}, {
'name': '--vaapi-glx',
'desc': 'VAAPI GLX',
'deps': [ 'vaapi-x11', 'gl-x11' ],
'func': check_true,
}, {
'name': '--vaapi-x-egl',
'desc': 'VAAPI EGL on X11',
'deps': [ 'vaapi-x11', 'egl-x11' ],
'func': check_true,
}, {
'name': 'vaapi-egl',
'desc': 'VAAPI EGL',
'deps_any': [ 'vaapi-x-egl', 'vaapi-wayland' ],
'func': check_true,
}, {
'name': '--caca',
'desc': 'CACA',
'func': check_pkg_config('caca', '>= 0.99.beta18'),
}, {
'name': '--jpeg',
'desc': 'JPEG support',
'func': check_cc(header_name=['stdio.h', 'jpeglib.h'],
lib='jpeg', use='libm'),
}, {
'name': '--direct3d',
'desc': 'Direct3D support',
'deps': [ 'win32' ],
'func': check_cc(header_name='d3d9.h'),
}, {
'name': '--android',
'desc': 'Android support',
'func': check_statement('android/api-level.h', '(void)__ANDROID__'), # arbitrary android-specific header
}, {
# We need MMAL/bcm_host/dispmanx APIs. Also, most RPI distros require
# every project to hardcode the paths to the include directories. Also,
# these headers are so broken that they spam tons of warnings by merely
# including them (compensate with -isystem and -fgnu89-inline).
'name': '--rpi',
'desc': 'Raspberry Pi support',
'func': compose_checks(
check_cc(cflags="-isystem/opt/vc/include/ "+
"-isystem/opt/vc/include/interface/vcos/pthreads " +
"-isystem/opt/vc/include/interface/vmcs_host/linux " +
"-fgnu89-inline",
linkflags="-L/opt/vc/lib",
header_name="bcm_host.h",
lib=['mmal_core', 'mmal_util', 'mmal_vc_client', 'bcm_host']),
# We still need all OpenGL symbols, because the vo_opengl code is
# generic and supports anything from GLES2/OpenGL 2.1 to OpenGL 4 core.
check_cc(lib="EGL"),
check_cc(lib="GLESv2"),
check_statement('GL/gl.h', '(void)GL_RGB32F'), # arbitrary OpenGL 3.0 symbol
check_statement('GL/gl.h', '(void)GL_LUMINANCE16') # arbitrary OpenGL legacy-only symbol
),
}, {
'name': '--standard-gl',
'desc': 'Desktop standard OpenGL support',
'func': compose_checks(
check_statement('GL/gl.h', '(void)GL_RGB32F'), # arbitrary OpenGL 3.0 symbol
check_statement('GL/gl.h', '(void)GL_LUMINANCE16') # arbitrary OpenGL legacy-only symbol
),
} , {
'name': '--android-gl',
'desc': 'Android OpenGL ES support',
'deps': ['android'],
'func': check_statement('GLES3/gl3.h', '(void)GL_RGB32F'), # arbitrary OpenGL ES 3.0 symbol
} , {
'name': '--ios-gl',
'desc': 'iOS OpenGL ES support',
'func': check_statement('OpenGLES/ES3/glext.h', '(void)GL_RGB32F'), # arbitrary OpenGL ES 3.0 symbol
} , {
'name': '--any-gl',
'desc': 'Any OpenGL (ES) support',
'deps_any': ['standard-gl', 'android-gl', 'ios-gl', 'cocoa'],
'func': check_true
} , {
'name': '--plain-gl',
'desc': 'OpenGL without platform-specific code (e.g. for libmpv)',
'deps': ['any-gl'],
'deps_any': [ 'libmpv-shared', 'libmpv-static' ],
'func': check_true,
}, {
'name': '--mali-fbdev',
'desc': 'MALI via Linux fbdev',
'deps': ['standard-gl', 'libdl'],
'func': compose_checks(
check_cc(lib="EGL"),
check_cc(lib="GLESv2"),
check_statement('EGL/fbdev_window.h', 'struct fbdev_window test'),
check_statement('linux/fb.h', 'struct fb_var_screeninfo test'),
),
}, {
'name': '--gl',
'desc': 'OpenGL video outputs',
'deps_any': [ 'gl-cocoa', 'gl-x11', 'egl-x11', 'egl-drm',
'gl-win32', 'gl-wayland', 'rpi', 'mali-fbdev',
'plain-gl' ],
'func': check_true,
'req': True,
'fmsg': "Unable to find OpenGL header files for video output. " +
"Aborting. If you really mean to compile without OpenGL " +
"video outputs use --disable-gl."
}, {
'name': 'egl-helpers',
'desc': 'EGL helper functions',
'deps_any': [ 'egl-x11', 'mali-fbdev', 'rpi', 'gl-wayland', 'egl-drm' ],
'func': check_true
}
]
hwaccel_features = [
{
'name': '--vaapi-hwaccel',
'desc': 'libavcodec VAAPI hwaccel',
'deps': [ 'vaapi' ],
'func': check_headers('libavcodec/vaapi.h', use='libav'),
}, {
'name': '--videotoolbox-hwaccel',
'desc': 'libavcodec videotoolbox hwaccel',
'func': compose_checks(
check_headers('VideoToolbox/VideoToolbox.h'),
check_statement('libavcodec/videotoolbox.h',
'av_videotoolbox_alloc_context()',
use='libav')),
} , {
'name': '--videotoolbox-gl',
'desc': 'Videotoolbox with OpenGL',
'deps': [ 'gl-cocoa', 'videotoolbox-hwaccel' ],
'func': check_true
} , {
'name': '--vdpau-hwaccel',
'desc': 'libavcodec VDPAU hwaccel',
'deps': [ 'vdpau' ],
'func': check_statement('libavcodec/vdpau.h',
'av_vdpau_bind_context(0,0,0,AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH)',
use='libav'),
}, {
'name': '--d3d-hwaccel',
'desc': 'libavcodec DXVA2 and D3D11VA hwaccel',
'deps': [ 'win32' ],
'func': compose_checks(
check_headers('libavcodec/dxva2.h', use='libav'),
check_headers('libavcodec/d3d11va.h', use='libav')),
}, {
'name': '--cuda-hwaccel',
'desc': 'CUDA hwaccel',
'func': compose_checks(
check_cc(lib="cuda"),
check_headers('libavutil/hwcontext_cuda.h', use='libav')),
}, {
'name': 'sse4-intrinsics',
'desc': 'GCC SSE4 intrinsics for GPU memcpy',
'deps_any': [ 'd3d-hwaccel', 'vaapi-hwaccel' ],
'func': check_cc(fragment=load_fragment('sse.c')),
}
]
radio_and_tv_features = [
{
'name': '--tv',
'desc': 'TV interface',
'func': check_true,
}, {
'name': 'sys_videoio_h',
'desc': 'videoio.h',
'func': check_cc(header_name=['sys/time.h', 'sys/videoio.h'])
}, {
'name': 'videodev',
'desc': 'videodev2.h',
'func': check_cc(header_name=['sys/time.h', 'linux/videodev2.h']),
'deps_neg': [ 'sys_videoio_h' ],
}, {
'name': '--tv-v4l2',
'desc': 'Video4Linux2 TV interface',
'deps': [ 'tv' ],
'deps_any': [ 'sys_videoio_h', 'videodev' ],
'func': check_true,
}, {
'name': '--libv4l2',
'desc': 'libv4l2 support',
'func': check_pkg_config('libv4l2'),
'deps': [ 'tv-v4l2' ],
}, {
'name': '--audio-input',
'desc': 'audio input support',
'deps_any': [ 'tv-v4l2' ],
'func': check_true
} , {
'name': '--dvbin',
'desc': 'DVB input module',
'func': check_cc(fragment=load_fragment('dvb.c')),
}
]
standalone_features = [
{
'name': 'win32-executable',
'desc': 'w32 executable',
'deps_any': [ 'os-win32', 'os-cygwin'],
'func': check_ctx_vars('WINDRES')
}, {
'name': '--apple-remote',
'desc': 'Apple Remote support',
'deps': [ 'cocoa' ],
'func': check_true
}
]
_INSTALL_DIRS_LIST = [
('bindir', '${PREFIX}/bin', 'binary files'),
('libdir', '${PREFIX}/lib', 'library files'),
('confdir', '${PREFIX}/etc/mpv', 'configuration files'),
('incdir', '${PREFIX}/include', 'include files'),
('datadir', '${PREFIX}/share', 'data files'),
('mandir', '${DATADIR}/man', 'man pages '),
('docdir', '${DATADIR}/doc/mpv', 'documentation files'),
('htmldir', '${DOCDIR}', 'html documentation files'),
('zshdir', '${DATADIR}/zsh/site-functions', 'zsh completion functions'),
('confloaddir', '${CONFDIR}', 'configuration files load directory'),
]
def options(opt):
opt.load('compiler_c')
opt.load('waf_customizations')
opt.load('features')
group = opt.get_option_group("build and install options")
for ident, default, desc in _INSTALL_DIRS_LIST:
group.add_option('--{0}'.format(ident),
type = 'string',
dest = ident,
default = default,
help = 'directory for installing {0} [{1}]' \
.format(desc, default))
group.add_option('--variant',
default = '',
help = 'variant name for saving configuration and build results')
opt.parse_features('build and install options', build_options)
optional_features = main_dependencies + libav_dependencies
opt.parse_features('optional features', optional_features)
opt.parse_features('audio outputs', audio_output_features)
opt.parse_features('video outputs', video_output_features)
opt.parse_features('hwaccels', hwaccel_features)
opt.parse_features('tv features', radio_and_tv_features)
opt.parse_features('standalone app', standalone_features)
group = opt.get_option_group("optional features")
group.add_option('--lua',
type = 'string',
dest = 'LUA_VER',
help = "select Lua package which should be autodetected. Choices: 51 51deb 51obsd 51fbsd 52 52deb 52arch 52fbsd luajit")
@conf
def is_optimization(ctx):
return getattr(ctx.options, 'enable_optimize')
@conf
def is_debug_build(ctx):
return getattr(ctx.options, 'enable_debug-build')
def configure(ctx):
ctx.resetenv(ctx.options.variant)
ctx.check_waf_version(mini='1.8.4')
target = os.environ.get('TARGET')
(cc, pkg_config, ar, windres) = ('cc', 'pkg-config', 'ar', 'windres')
if target:
cc = '-'.join([target, 'gcc'])
pkg_config = '-'.join([target, pkg_config])
ar = '-'.join([target, ar])
windres = '-'.join([target, windres])
ctx.find_program(cc, var='CC')
ctx.find_program(pkg_config, var='PKG_CONFIG')
ctx.find_program(ar, var='AR')
ctx.find_program('perl', var='BIN_PERL')
ctx.find_program('rst2html', var='RST2HTML', mandatory=False)
ctx.find_program('rst2man', var='RST2MAN', mandatory=False)
ctx.find_program('rst2pdf', var='RST2PDF', mandatory=False)
ctx.find_program(windres, var='WINDRES', mandatory=False)
for ident, _, _ in _INSTALL_DIRS_LIST:
varname = ident.upper()
ctx.env[varname] = getattr(ctx.options, ident)
# keep substituting vars, until the paths are fully expanded
while re.match('\$\{([^}]+)\}', ctx.env[varname]):
ctx.env[varname] = Utils.subst_vars(ctx.env[varname], ctx.env)
ctx.load('compiler_c')
ctx.load('waf_customizations')
ctx.load('dependencies')
ctx.load('detections.compiler')
ctx.load('detections.devices')
ctx.parse_dependencies(build_options)
ctx.parse_dependencies(main_dependencies)
ctx.parse_dependencies(audio_output_features)
ctx.parse_dependencies(video_output_features)
ctx.parse_dependencies(libav_dependencies)
ctx.parse_dependencies(hwaccel_features)
ctx.parse_dependencies(radio_and_tv_features)
if ctx.options.LUA_VER:
ctx.options.enable_lua = True
ctx.parse_dependencies(standalone_features)
ctx.define('HAVE_SYS_SOUNDCARD_H',
'(HAVE_OSS_AUDIO_NATIVE || HAVE_OSS_AUDIO_4FRONT)',
quote=False)
ctx.define('HAVE_SOUNDCARD_H',
'HAVE_OSS_AUDIO_SUNAUDIO',
quote=False)
ctx.load('generators.headers')
if not ctx.dependency_satisfied('build-date'):
ctx.env.CFLAGS += ['-DNO_BUILD_TIMESTAMPS']
if ctx.dependency_satisfied('clang-database'):
ctx.load('clang_compilation_database')
ctx.store_dependencies_lists()
def __write_version__(ctx):
ctx.env.VERSIONH_ST = '--versionh="%s"'
ctx.env.CWD_ST = '--cwd="%s"'
ctx.env.VERSIONSH_CWD = [ctx.srcnode.abspath()]
ctx(
source = 'version.sh',
target = 'version.h',
rule = 'sh ${SRC} ${CWD_ST:VERSIONSH_CWD} ${VERSIONH_ST:TGT}',
always = True,
update_outputs = True)
def build(ctx):
if ctx.options.variant not in ctx.all_envs:
from waflib import Errors
raise Errors.WafError(
'The project was not configured: run "waf --variant={0} configure" first!'
.format(ctx.options.variant))
ctx.unpack_dependencies_lists()
__write_version__(ctx)
ctx.load('wscript_build')
def init(ctx):
from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
class tmp(y):
variant = ctx.options.variant
# This is needed because waf initializes the ConfigurationContext with
# an arbitrary setenv('') which would rewrite the previous configuration
# cache for the default variant if the configure step finishes.
# Ideally ConfigurationContext should just let us override this at class
# level like the other Context subclasses do with variant
from waflib.Configure import ConfigurationContext
class cctx(ConfigurationContext):
def resetenv(self, name):
self.all_envs = {}
self.setenv(name)
|