diff options
author | wm4 <wm4@nowhere> | 2014-05-14 20:29:00 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-05-14 20:42:04 +0200 |
commit | d0a66dbd5d4bbcd66338a6fd3a27e6d00a22f317 (patch) | |
tree | a91e82bdac2afab7f415ddcd5c16fe42dd3ecbc9 | |
parent | eb4487cc4f8761bddb7dc7b9548d11107e9209da (diff) | |
download | mpv-d0a66dbd5d4bbcd66338a6fd3a27e6d00a22f317.tar.bz2 mpv-d0a66dbd5d4bbcd66338a6fd3a27e6d00a22f317.tar.xz |
old-build: accidental rewrite
This started as a bunch of smaller changes to make the old configure
script maintainable with minimum effort. It ended up as complete
rewrite, because at once point I started to like shell programming (I
hope this sickness is curable), and I wanted to see how small I can
make the configure script. The typical configure test is now 1 or 2
lines big, located in 1 or 2 places, instead of >15 lines and being
spread over 5 or 6 places.
The main "trick" is factoring the tests into a few generic, commonly
needed tests, instead of writing everything manually.
-rwxr-xr-x | old-configure | 2460 | ||||
-rw-r--r-- | old-makefile | 82 |
2 files changed, 484 insertions, 2058 deletions
diff --git a/old-configure b/old-configure index 1ac1e5db2a..819676ed6b 100755 --- a/old-configure +++ b/old-configure @@ -1,12 +1,8 @@ #! /bin/sh # -# Original version (C) 2000 Pontscho/fresh!mindworkz -# pontscho@makacs.poliod.hu -# -# History / Contributors: Check the Subversion log. -# +# Original version (C) 2000 Pontscho/fresh!mindworkz pontscho@makacs.poliod.hu # Cleanups all over the place (c) 2001 pl -# +# Rewritten for mpv in 2014. # # This configure script is *not* autoconf-based and has different semantics. # It attempts to autodetect all settings and options where possible. It is @@ -21,18 +17,6 @@ # # If you want to add a new check for $feature, look at the existing checks # and try to use helper functions where you can. -# -# Furthermore you need to add the variable _feature to the list of default -# settings and set it to one of yes/no/auto. Also add appropriate -# --enable-feature/--disable-feature command line options. -# The results of the check should be written to config.h and config.mak -# at the end of this script. The variable names used for this should be -# uniform, i.e. if the option is named 'feature': -# -# _feature : should have a value of yes/no/auto -# def_feature : '#define ... 1' or '#undef ...' for conditional compilation -# _ld_feature : '-L/path/dir -lfeature' GCC options -# ############################################################################# # Prevent locale nonsense from breaking basic text processing utils @@ -58,99 +42,29 @@ compile_check() { echo >> "$TMPLOG" cat "$source" >> "$TMPLOG" echo >> "$TMPLOG" - echo "$_cc $WARNFLAGS $WARN_CFLAGS $CFLAGS $source $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o $TMPEXE $@" >> "$TMPLOG" + echo "$_cc $OURCFLAGS $CFLAGS $source $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o $TMPEXE $@" >> "$TMPLOG" rm -f "$TMPEXE" - $_cc $WARNFLAGS $WARN_CFLAGS $CFLAGS "$source" $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o "$TMPEXE" "$@" >> "$TMPLOG" 2>&1 + $_cc $OURCFLAGS $CFLAGS "$source" $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o "$TMPEXE" $@ >> "$TMPLOG" 2>&1 TMPRES="$?" echo >> "$TMPLOG" echo >> "$TMPLOG" return "$TMPRES" } -cc_check() { - compile_check $TMPC $@ -} - cflag_check() { - cat > $TMPC << EOF -int main(void) { return 0; } -EOF - compile_check $TMPC $@ -} - -header_check() { - cat > $TMPC << EOF -#include <$1> -int main(void) { return 0; } -EOF - shift - compile_check $TMPC $@ -} - -return_check() { - cat > $TMPC << EOF -#include <$1> -int main(void) { return $2; } -EOF - shift 2 - compile_check $TMPC $@ + echo "int main(void) { return 0; }" > $TMPC + compile_check $TMPC $@ } statement_check() { - cat > $TMPC << EOF -#include <$1> -int main(void) { $2; return 0; } -EOF - shift - shift - compile_check $TMPC $@ -} - -define_statement_check() { - cat > $TMPC << EOF -#define $1 -#include <$2> -int main(void) { $3; return 0; } -EOF - shift 3 - compile_check $TMPC $@ -} - -return_statement_check() { - cat > $TMPC << EOF -#include <$1> -int main(void) { $2; return $3; } -EOF - shift 3 - compile_check $TMPC $@ -} - -# The following checks are special and should only be used with broken and -# non-selfsufficient headers that do not include all of their dependencies. - -header_check_broken() { - cat > $TMPC << EOF -#include <$1> -#include <$2> -int main(void) { return 0; } -EOF - shift - shift - compile_check $TMPC $@ -} - -statement_check_broken() { - cat > $TMPC << EOF -#include <$1> -#include <$2> -int main(void) { $3; return 0; } -EOF - shift 3 - compile_check $TMPC $@ + echo "" > $TMPC + for _header in $1 ; do echo "#include <$_header>" >> $TMPC ; done + echo "int main(void) { $2; return 0; }" >> $TMPC + shift 2 + compile_check $TMPC $@ } pkg_config_add() { - unset IFS # shell should not be used for programming echo >> "$TMPLOG" echo "$_pkg_config --cflags $@" >> "$TMPLOG" ctmp=$($_pkg_config --cflags "$@" 2>> "$TMPLOG") || return $? @@ -165,16 +79,12 @@ pkg_config_add() { libs_mplayer="$libs_mplayer $ltmp" } -tmp_run() { - "$TMPEXE" >> "$TMPLOG" 2>&1 -} - # Display error message, flushes tempfile, exit die () { echo echo "Error: $@" >&2 echo >&2 - rm -f "$TMPEXE" "$TMPC" "$TMPS" "$TMPCPP" + rm -f "$TMPEXE" "$TMPC" echo "Check \"$TMPLOG\" if you do not understand why it failed." exit 1 } @@ -187,16 +97,13 @@ echocheck() { # Use this to echo the results of a check echores() { - if test "$res_comment" ; then - res_comment="($res_comment)" - fi + test "$res_comment" && res_comment="($res_comment)" echo "Result is: $@ $res_comment" >> "$TMPLOG" echo "##########################################" >> "$TMPLOG" echo "" >> "$TMPLOG" echo "$@ $res_comment" res_comment="" } -############################################################################# # Check how echo works in this /bin/sh case $(echo -n) in @@ -204,6 +111,116 @@ case $(echo -n) in *) _echo_n='-n ' _echo_c= ;; # BSD echo esac +# setind $a b sets the variable named by the value of the variable a to b +setind() { eval "$1=\"\$2\"" ; } + +# Generate --enable-NAME/--disable-NAME options, set $1 to the option value. +# Since shell has no data structures, do a weird statemachine thing. +# Arguments: "_name"($1) "description"($2) "default"($3) +# If "default"($3) is empty, use "auto" +# Option name: a leading "_" in name is stripped, further "_" are changed to "-" +opt_yes_no() { + _name=$(echo "$1" | sed 's/^_//' | tr _ -) + _defval="$3" + test -z "$_defval" && _defval=auto + + case "$_opt_state_mode" in + init) + setind "$1" "$_defval" + ;; + help) + if test "$_defval" = yes || test "$_defval" = auto ; then + _defdesc=enable + test "$_defval" = auto && _defdesc=auto + printf " %-21s disable $2 [$_defdesc]\n" "--disable-$_name" + unset _defdesc + else + printf " %-21s enable $2 [disable]\n" "--enable-$_name" + fi + ;; + parse) + if test "$_opt_state_name" = "--enable-$_name" ; then + setind "$1" yes + _opt_state_known=yes + elif test "$_opt_state_name" = "--disable-$_name" ; then + setind "$1" no + _opt_state_known=yes + elif test "$_opt_state_name" = "--auto-$_name" ; then + setind "$1" auto + _opt_state_known=yes + fi + ;; + esac + unset _name + unset _defval +} + +options_state_machine() { + _opt_state_mode=$1 + _opt_state_name=$2 + _opt_state_known=no + + opt_yes_no _gl "OpenGL video output" + opt_yes_no _libguess "libguess" + opt_yes_no _terminfo "terminfo database for key codes" + opt_yes_no _termcap "termcap database for key codes" + opt_yes_no _termios "termios database for key codes" + opt_yes_no _iconv "iconv for encoding conversion" + opt_yes_no _lirc "LIRC (remote control) support" + opt_yes_no _joystick "joystick support" no + opt_yes_no _vm "X video mode extensions" + opt_yes_no _xf86keysym "support for multimedia keys" + opt_yes_no _dvb "DVB input" + opt_yes_no _tv "TV interface (TV/DVB grabbers)" yes + opt_yes_no _tv_v4l2 "Video4Linux2 TV interface" + opt_yes_no _libv4l2 "libv4l2" + opt_yes_no _pvr "Video4Linux2 MPEG PVR" + opt_yes_no _smb "Samba (SMB) input" + opt_yes_no _libquvi4 "libquvi 0.4.x" + opt_yes_no _libquvi9 "libquvi 0.9.x" + opt_yes_no _lcms2 "LCMS2 support" + opt_yes_no _vcd "VCD support" yes + opt_yes_no _bluray "Blu-ray support" + opt_yes_no _dvdread "libdvdread" + opt_yes_no _dvdnav "libdvdnav" + opt_yes_no _enca "ENCA charset oracle library" + opt_yes_no _libass "subtitle rendering with libass" + opt_yes_no _libpostproc "postprocess filter (vf_pp)" + opt_yes_no _libavdevice "libavdevice demuxers" + opt_yes_no _libavfilter "libavfilter" + opt_yes_no _vapoursynth "VapourSynth filter bridge" + opt_yes_no _jpeg "support for writing JPEG screenshots" + opt_yes_no _libcdio "libcdio support" + opt_yes_no _ffmpeg "skip FFmpeg/Libav autodetection" + opt_yes_no _ladspa "LADSPA plugin support" + opt_yes_no _libbs2b "libbs2b audio filter support" + opt_yes_no _mpg123 " libmpg123 MP3 decoding support" + opt_yes_no _libavresample "libavresample (preferred over libswresample)" + opt_yes_no _libswresample "libswresample" + opt_yes_no _caca "CACA video output" + opt_yes_no _sdl2 "SDL2 video and audio outputs" no + opt_yes_no _xv "Xv video output" + opt_yes_no _vdpau "VDPAU acceleration" + opt_yes_no _vaapi "VAAPI acceleration" + opt_yes_no _vm "XF86VidMode support (used for monitor FPS detection)" + opt_yes_no _xinerama "Xinerama support" + opt_yes_no _x11 "X11 video output" + opt_yes_no _wayland "Wayland video output" + opt_yes_no _xss "support for disabling screensaver via xss" + opt_yes_no _alsa "ALSA audio output" + opt_yes_no _ossaudio "OSS audio output" + opt_yes_no _rsound "RSound audio output" + opt_yes_no _sndio "sndio audio output" + opt_yes_no _pulse "Pulseaudio audio output" + opt_yes_no _portaudio "PortAudio audio output" + opt_yes_no _jack "JACK audio output" + opt_yes_no _openal "OpenAL audio output" + opt_yes_no _select "using select() on the audio device" yes + opt_yes_no _shm "X11/Xv shared memory" + opt_yes_no _lua "Lua scripting" + opt_yes_no _encoding "encoding functionality" yes + opt_yes_no _build_man "building manpage" +} show_help(){ cat << EOF @@ -218,102 +235,25 @@ Installation directories: --datadir=DIR directory for installing machine independent data files (skins, etc) [PREFIX/share/mpv] --mandir=DIR directory for installing man pages [PREFIX/share/man] - --docdir=DIR directory for installing docs [PREFIX/share/doc/mpv] --confdir=DIR directory for installing configuration files [PREFIX/etc/mpv] -Optional features: - --disable-encoding disable encoding functionality [enable] - --disable-lua disable Lua scripting support [autodetect] - --lua=LUA select Lua package which should be autodetected - Choices: 51 51deb 52 52deb luajit - --disable-libguess disable libguess [autodetect] - --enable-terminfo use terminfo database for key codes [autodetect] - --enable-termcap use termcap database for key codes [autodetect] - --enable-termios use termios database for key codes [autodetect] - --disable-iconv disable iconv for encoding conversion [autodetect] - --enable-lirc enable LIRC (remote control) support [autodetect] - --enable-joystick enable joystick support [disable] - --disable-vm disable X video mode extensions [autodetect] - --disable-xf86keysym disable support for multimedia keys [autodetect] - --disable-tv disable TV interface (TV/DVB grabbers) [enable] - --disable-tv-v4l2 disable Video4Linux2 TV interface [autodetect] - --disable-libv4l2 disable libv4l2 [autodetect] - --disable-pvr disable Video4Linux2 MPEG PVR [autodetect] - --enable-smb enable Samba (SMB) input [autodetect] - --disable-libquvi4 disable libquvi 0.4.x [autodetect] - --disable-libquvi9 disable libquvi 0.9.x [autodetect] - --enable-lcms2 enable LCMS2 support [autodetect] - --disable-vcd disable VCD support [autodetect] - --disable-bluray disable Blu-ray support [autodetect] - --disable-dvdread disable libdvdread [autodetect] - --disable-dvdnav disable libdvdnav [autodetect] - --disable-enca disable ENCA charset oracle library [autodetect] - --disable-libass disable subtitle rendering with libass [autodetect] - --disable-libass-osd disable OSD rendering with libass [autodetect] - --enable-rpath enable runtime linker path for extra libs [disabled] - --disable-libpostproc disable postprocess filter (vf_pp) [autodetect] - --disable-libavdevice disable libavdevice demuxers [autodetect] - --disable-libavfilter disable libavfilter [autodetect] - --disable-vapoursynth disable VapourSynth filter bridge [autodetect] - -Codecs: - --enable-jpeg enable JPEG input/output support [autodetect] - --enable-libcdio enable libcdio support [autodetect] - --enable-libav skip Libav autodetection [autodetect] - --disable-ladspa disable LADSPA plugin support [autodetect] - --disable-libbs2b disable libbs2b audio filter support [autodetect] - --disable-mpg123 disable libmpg123 MP3 decoding support [autodetect] - -Resampler: - --disable-libavresample check for libswresample only [autodetect] - -Video output: - --enable-gl enable OpenGL video output [autodetect] - --enable-caca enable CACA video output [autodetect] - --enable-sdl enable SDL audio output [disable] - --enable-sdl2 enable SDL 2.0+ audio and video output [disable] - --enable-xv enable Xv video output [autodetect] - --enable-vdpau enable VDPAU acceleration [autodetect] - --enable-vaapi enable VAAPI acceleration [autodetect] - --enable-vm enable XF86VidMode support [autodetect] - --enable-xinerama enable Xinerama support [autodetect] - --enable-x11 enable X11 video output [autodetect] - --enable-wayland enable Wayland video output [autodetect] - --disable-xss disable screensaver support via xss [autodetect] - -Audio output: - --disable-alsa disable ALSA audio output [autodetect] - --disable-ossaudio disable OSS audio output [autodetect] - --disable-rsound disable RSound audio output [autodetect] - --disable-sndio disable sndio audio output [autodetect] - --disable-pulse disable Pulseaudio audio output [autodetect] - --disable-portaudio disable PortAudio audio output [autodetect] - --disable-jack disable JACK audio output [autodetect] - --enable-openal enable OpenAL audio output [disable] - --disable-select disable using select() on the audio device [enable] - -Miscellaneous options: - --enable-cross-compile enable cross-compilation [disable] +Compilation options: --cc=COMPILER C compiler to build mpv [gcc] --pkg-config=PKGCONFIG pkg-config to find some libraries [pkg-config] - --target=PLATFORM target platform (i386-linux, arm-linux, etc) --enable-static build a statically linked binary - --with-install=PATH path to a custom install program - --disable-manpage do not build and install manpage [auto] - --disable-pdf do not build and install PDF manual [auto] - --disable-build-date do not include binary compile time - -Advanced options: - --enable-shm enable shm [autodetect] - --disable-debug compile-in debugging information [enable] - --disable-optimization compile without -O2 [enable] + --disable-debug compile-in debugging information [enable] + --disable-optimization compile without -O2 [enable] Use these options if autodetection fails: - --extra-cflags=FLAGS extra CFLAGS - --extra-ldflags=FLAGS extra LDFLAGS - --extra-libs=FLAGS extra linker flags - --extra-libs-mpv=FLAGS extra linker flags for mpv + --extra-cflags=FLAGS extra CFLAGS + --extra-ldflags=FLAGS extra LDFLAGS + --extra-libs=FLAGS extra linker flags + +Features: +EOF +options_state_machine help +cat << EOF This configure script is NOT autoconf-based, even though its output is similar. It will try to autodetect all configuration options. If you --enable an option @@ -326,79 +266,12 @@ exit 0 # GOTCHA: the variables below defines the default behavior for autodetection # and have - unless stated otherwise - at least 2 states : yes no # If autodetection is available then the third state is: auto -_install=install _pkg_config=auto _cc=auto test "$CC" && _cc="$CC" -_debug=-g _opt=-O2 -_cross_compile=no _prefix="/usr/local" -ffmpeg=auto -_encoding=yes -_disable_avresample=no -_x11=auto -_wayland=auto -_xss=auto -_xv=auto -_vdpau=auto -_vaapi=auto -_sdl=no -_sdl2=no -_jpeg=auto -_gl=auto -_aa=auto -_caca=auto -_dvb=auto -_iconv=auto -_ossaudio=auto -_rsound=auto -_pulse=auto -_portaudio=auto -_jack=auto -_openal=no -_libcdio=auto -_mpg123=auto -_ladspa=auto -_libbs2b=auto -_vcd=auto -_bluray=auto -_dvdread=auto -_dvdnav=auto -_lcms2=auto -_vapoursynth=auto -_xinerama=auto -_vm=auto -_xf86keysym=auto -_sndio=auto -_alsa=auto -_select=yes -_tv=yes -_tv_v4l2=auto -_libv4l2=auto -_pvr=auto -_smb=auto -_libquvi4=auto -_libquvi9=auto -_libguess=auto -_joystick=no -_lirc=auto -_terminfo=auto -_termcap=auto -_termios=auto -_shm=auto -_cdda=auto -_enca=auto -_ass=auto -_libass_osd=auto -lua=auto -libpostproc=auto -libavfilter=auto -libavdevice=auto -_stream_cache=yes -_build_man=auto -_build_pdf=auto -_build_date=yes +options_state_machine init for ac_option do case "$ac_option" in --help|-help|-h) @@ -413,17 +286,9 @@ for ac_option do --mandir=*) _mandir=$(echo $ac_option | cut -d '=' -f 2) ;; - --docdir=*) - _docdir=$(echo $ac_option | cut -d '=' -f 2) - ;; --confdir=*) _confdir=$(echo $ac_option | cut -d '=' -f 2) ;; - - --with-install=*) - _install=$(echo $ac_option | cut -d '=' -f 2 ) - ;; - --extra-cflags=*) extra_cflags="$extra_cflags $(echo $ac_option | cut -d '=' -f 2-)" ;; @@ -431,37 +296,20 @@ for ac_option do extra_ldflags="$extra_ldflags $(echo $ac_option | cut -d '=' -f 2-)" ;; --extra-libs=*) - extra_libs=$(echo $ac_option | cut -d '=' -f 2) - ;; - --extra-libs-mpv=*) libs_mplayer=$(echo $ac_option | cut -d '=' -f 2) ;; - - --target=*) - _target=$(echo $ac_option | cut -d '=' -f 2) - ;; --cc=*) _cc=$(echo $ac_option | cut -d '=' -f 2) ;; --pkg-config=*) _pkg_config=$(echo $ac_option | cut -d '=' -f 2) ;; - --enable-static) _ld_static='-static' ;; --disable-static) _ld_static='' ;; - --enable-debug) - _debug='-g' - ;; - --enable-debug=*) - _debug=$(echo $_echo_n '-g'$_echo_c; echo $ac_option | cut -d '=' -f 2) - ;; - --disable-debug) - _debug= - ;; --enable-optimization) _opt='-O2' ;; @@ -471,577 +319,220 @@ for ac_option do --disable-optimization) _opt= ;; - --enable-cross-compile) _cross_compile=yes ;; - --disable-cross-compile) _cross_compile=no ;; - --enable-encoding) _encoding=yes ;; - --disable-encoding) _encoding=no ;; - --enable-wayland) _wayland=yes ;; - --disable-wayland) _wayland=no ;; - --enable-x11) _x11=yes ;; - --disable-x11) _x11=no ;; - --enable-xss) _xss=yes ;; - --disable-xss) _xss=no ;; - --enable-xv) _xv=yes ;; - --disable-xv) _xv=no ;; - --enable-vdpau) _vdpau=yes ;; - --disable-vdpau) _vdpau=no ;; - --enable-vaapi) _vaapi=yes ;; - --disable-vaapi) _vaapi=no ;; - --enable-sdl) _sdl=yes ;; - --disable-sdl) _sdl=no ;; - --enable-sdl2) _sdl2=yes ;; - --disable-sdl2) _sdl2=no ;; - --enable-jpeg) _jpeg=yes ;; - --disable-jpeg) _jpeg=no ;; - --enable-gl) _gl=yes ;; - --disable-gl) _gl=no ;; - --enable-caca) _caca=yes ;; - --disable-caca) _caca=no ;; - --enable-dvb) _dvb=yes ;; - --disable-dvb) _dvb=no ;; - --enable-iconv) _iconv=yes ;; - --disable-iconv) _iconv=no ;; - --enable-ossaudio) _ossaudio=yes ;; - --disable-ossaudio) _ossaudio=no ;; - --enable-rsound) _rsound=yes ;; - --disable-rsound) _rsound=no ;; - --enable-sndio) _sndio=yes ;; - --disable-sndio) _sndio=no ;; - --enable-pulse) _pulse=yes ;; - --disable-pulse) _pulse=no ;; - --enable-portaudio) _portaudio=yes ;; - --disable-portaudio) _portaudio=no ;; - --enable-jack) _jack=yes ;; - --disable-jack) _jack=no ;; - --enable-openal) _openal=auto ;; - --disable-openal) _openal=no ;; - --enable-libcdio) _libcdio=yes ;; - --disable-libcdio) _libcdio=no ;; - --enable-mpg123) _mpg123=yes ;; - --disable-mpg123) _mpg123=no ;; - --enable-ladspa) _ladspa=yes ;; - --disable-ladspa) _ladspa=no ;; - --enable-libbs2b) _libbs2b=yes ;; - --disable-libbs2b) _libbs2b=no ;; - --enable-vcd) _vcd=yes ;; - --disable-vcd) _vcd=no ;; - --enable-bluray) _bluray=yes ;; - --disable-bluray) _bluray=no ;; - --enable-dvdread) _dvdread=yes ;; - --disable-dvdread) _dvdread=no ;; - --enable-dvdnav) _dvdnav=yes ;; - --disable-dvdnav) _dvdnav=no ;; - --enable-lcms2) _lcms2=yes ;; - --disable-lcms2) _lcms2=no ;; - --enable-vapoursynth) _vapoursynth=yes ;; - --dsiable-vapoursynth)_vapoursynth=no ;; - --enable-xinerama) _xinerama=yes ;; - --disable-xinerama) _xinerama=no ;; - --enable-vm) _vm=yes ;; - --disable-vm) _vm=no ;; - --enable-xf86keysym) _xf86keysym=yes ;; - --disable-xf86keysym) _xf86keysym=no ;; - --enable-alsa) _alsa=yes ;; - --disable-alsa) _alsa=no ;; - --enable-tv) _tv=yes ;; - --disable-tv) _tv=no ;; - --enable-tv-v4l2) _tv_v4l2=yes ;; - --disable-tv-v4l2) _tv_v4l2=no ;; - --enable-libv4l2) _libv4l2=yes ;; - --disable-libv4l2) _libv4l2=no ;; - --enable-pvr) _pvr=yes ;; - --disable-pvr) _pvr=no ;; - --enable-smb) _smb=yes ;; - --disable-smb) _smb=no ;; - --enable-libquvi4) _libquvi4=yes ;; - --disable-libquvi4) _libquvi4=no ;; - --enable-libquvi9) _libquvi9=yes ;; - --disable-libquvi9) _libquvi9=no ;; - --enable-libguess) _libguess=yes ;; - --disable-libguess) _libguess=no ;; - --enable-joystick) _joystick=yes ;; - --disable-joystick) _joystick=no ;; - --enable-libav) ffmpeg=yes ;; - --disable-libavresample) _disable_avresample=yes ;; - --enable-libavresample) _disable_avresample=no ;; - - --enable-lua) lua=yes ;; - --disable-lua) lua=no ;; - --lua=*) lua_pkg=$(echo $ac_option | cut -d '=' -f 2) ;; - --enable-lirc) _lirc=yes ;; - --disable-lirc) _lirc=no ;; - --enable-terminfo) _terminfo=yes ;; - --disable-terminfo) _terminfo=no ;; - --enable-termcap) _termcap=yes ;; - --disable-termcap) _termcap=no ;; - --enable-termios) _termios=yes ;; - --disable-termios) _termios=no ;; - --enable-shm) _shm=yes ;; - --disable-shm) _shm=no ;; - --enable-select) _select=yes ;; - --disable-select) _select=no ;; - --enable-libass) _ass=yes ;; - --disable-libass) _ass=no ;; - --enable-libass-osd) _libass_osd=yes ;; - --disable-libass-osd) _libass_osd=no ;; - --enable-libpostproc) libpostproc=yes ;; - --disable-libpostproc) libpostproc=no ;; - --enable-libavdevice) libavdevice=auto ;; - --disable-libavdevice) libavdevice=no ;; - --enable-libavfilter) libavfilter=auto ;; - --disable-libavfilter) libavfilter=no ;; - - --enable-enca) _enca=yes ;; - --disable-enca) _enca=no ;; - - --enable-manpage) _build_man=yes ;; - --disable-manpage) _build_man=no ;; - --enable-pdf) _build_pdf=yes ;; - --disable-pdf) _build_pdf=no ;; - - --enable-build-date) _build_date=yes ;; - --disable-build-date) _build_date=no ;; *) - echo "Unknown parameter: $ac_option" >&2 - exit 1 + options_state_machine parse "$ac_option" + if test "$_opt_state_known" != yes ; then + echo "Unknown parameter: $ac_option" >&2 + exit 1 + fi ;; esac done -# Atmos: moved this here, to be correct, if --prefix is specified test -z "$_bindir" && _bindir="$_prefix/bin" test -z "$_mandir" && _mandir="$_prefix/share/man" -test -z "$_docdir" && _docdir="$_prefix/share/doc/mpv" test -z "$_confdir" && _confdir="$_prefix/etc/mpv" -for tmpdir in "$TMPDIR" "$TEMPDIR" "/tmp" ; do - test "$tmpdir" && break -done - -mplayer_tmpdir="$tmpdir/mpv-configure-$RANDOM-$$" -mkdir $mplayer_tmpdir || die "Unable to create tmpdir." +mplayer_tmpdir=$(mktemp -d --tmpdir mpv-configure-XXXX) +test -n "$mplayer_tmpdir" || die "Unable to create tmpdir." TMPLOG="config.log" rm -f "$TMPLOG" echo Parameters configure was run with: > "$TMPLOG" -if test -n "$CFLAGS" ; then - echo ${_echo_n} CFLAGS="'$CFLAGS' ${_echo_c}" >> "$TMPLOG" -fi -if test -n "$PKG_CONFIG_PATH" ; then - echo ${_echo_n} PKG_CONFIG_PATH="'$PKG_CONFIG_PATH' ${_echo_c}" >> "$TMPLOG" -fi -echo ./configure $configuration >> "$TMPLOG" +echo CFLAGS="'$CFLAGS'" PKG_CONFIG_PATH="'$PKG_CONFIG_PATH'" ./configure $configuration >> "$TMPLOG" echo >> "$TMPLOG" +TMPC="$mplayer_tmpdir/tmp.c" +TMPEXE="$mplayer_tmpdir/tmp" +CONFIG_MAK="$mplayer_tmpdir/config.mak" +CONFIG_H="$mplayer_tmpdir/config.h" -echocheck "cross compilation" -echores $_cross_compile - -if test $_cross_compile = yes; then - tmp_run() { - return 0 - } -fi - -tool_prefix="" - -if test $_cross_compile = yes ; then - # Usually cross-compiler prefixes match with the target triplet - test -n "$_target" && tool_prefix="$_target"- -fi - -test "$_pkg_config" = auto && _pkg_config="$tool_prefix"pkg-config +echo > $CONFIG_MAK +echo > $CONFIG_H -if test "$_cc" = auto ; then - if test -n "$tool_prefix" ; then - _cc="$tool_prefix"gcc - else - _cc=cc - fi -fi +test "$_pkg_config" = auto && _pkg_config=pkg-config +test "$_cc" = auto && _cc=cc extra_cflags="-I. -D_GNU_SOURCE $extra_cflags" _rst2man=rst2man -if [ -f "$(which rst2man.py)" ] ; then - _rst2man=rst2man.py -fi +test -f "$(which rst2man.py)" && _rst2man=rst2man.py echocheck "whether to build manpages with rst2man" if test "$_build_man" = auto ; then _build_man=no command_check "$_rst2man" --version && _build_man=yes -else - _build_man=no fi echores "$_build_man" -_rst2pdf=rst2pdf -if [ -f "$(which rst2pdf.py)" ] ; then - _rst2pdf=rst2pdf.py -fi - -echocheck "whether to build manual PDFs with rst2pdf" -pdfcheck() { - echo test | $_rst2pdf -c --repeat-table-rows -o "$mplayer_tmpdir/test.pdf" -} - -if test "$_build_pdf" = auto ; then - _build_pdf=no - command_check pdfcheck && _build_pdf=yes -else - _build_pdf=no -fi -echores "$_build_pdf" - -echocheck "whether to print binary build date" -if test "$_build_date" = yes ; then - _build_yes=yes -else - _build_date=no - extra_cflags="$extra_cflags -DNO_BUILD_TIMESTAMPS" -fi -echores "$_build_date" - - - -TMPC="$mplayer_tmpdir/tmp.c" -TMPCPP="$mplayer_tmpdir/tmp.cpp" -TMPEXE="$mplayer_tmpdir/tmp" -TMPH="$mplayer_tmpdir/tmp.h" -TMPS="$mplayer_tmpdir/tmp.S" - echocheck "working compiler" cflag_check "" || die "Compiler is not functioning correctly. Check your installation and custom CFLAGS $CFLAGS ." -echo "yes" +echores "yes" echocheck "perl" command_check perl -Mv5.8 -e';' || die "Perl is not functioning correctly or is ancient. Install the latest perl available." -echo yes - - -# --- +echores yes echocheck "compiler support of -pipe option" cflag_check -pipe -I. && _pipe="-pipe" && echores "yes" || echores "no" -OURCFLAGS="-std=c99 -Wall" +addcflags() { cflag_check "$@" && OURCFLAGS="$OURCFLAGS $@" ; } -addcflags() { - cflag_check "$@" && OURCFLAGS="$OURCFLAGS $@" -} +OURCFLAGS="-std=c99 -Wall $_opt" -addcflags "-Wundef -Wmissing-prototypes -Wshadow -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Werror=implicit-function-declaration -Wno-error=deprecated-declarations -Wno-error=unused-function" -addcflags "-Wempty-body" +addcflags -g -g3 -ggdb +addcflags -Wundef -Wmissing-prototypes -Wshadow -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Werror=implicit-function-declaration -Wno-error=deprecated-declarations -Wno-error=unused-function -Wempty-body # clang -addcflags "-Wno-logical-op-parentheses -fcolor-diagnostics -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare" +addcflags -Wno-logical-op-parentheses -fcolor-diagnostics -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare cflag_check -MD -MP && DEPFLAGS="-MD -MP" +cflag_check -lm && _ld_lm="-lm" extra_ldflags="$extra_ldflags $LDFLAGS" extra_cflags="$extra_cflags $CPPFLAGS" -###################### -# MAIN TESTS GO HERE # -###################### +# If $1 is "yes", define $2 as 1 in config.h, else define it as 0 +define_yes_no() { + if test "$1" = yes ; then + echo "#define $2 1" >> $CONFIG_H + else + echo "#define $2 0" >> $CONFIG_H + fi +} +# Write the results of a check to config.mak/.h. +# Arguments: "yes/no"($1) "name"($2) +check_yes_no() { + define_yes_no $1 "HAVE_$2" + echo "$2 = $1" >> $CONFIG_MAK +} -echocheck "-lm" -if cflag_check -lm ; then - _ld_lm="-lm" - echores "yes" -else - _ld_lm="" - echores "no" -fi +check_trivial() { + echocheck "$1" + check_yes_no $2 $3 + echores "$2" +} +# Arguments: "message"($1) "setting"($2) "name"($3) "code"($4) +# Also, $5 - $N can be libraries needed - it'll try each separately. +# Use " " as first entry if you want to try with no libraries too. +check_compile() { + _res="$2" + _name="$3" + _code="$4" + echocheck "$1" + if test $_res = auto ; then + _res=no + shift 4 + while true ; do + compile_check "$_code" "$1" && libs_mplayer="$libs_mplayer $1" && _res=yes && break + test -z "$1" && break + shift + done + fi + check_yes_no $_res $_name + echores $_res + test $_res = yes && return 0 || return 1 +} -echocheck "nanosleep" -_nanosleep=no -statement_check time.h 'nanosleep(0, 0)' && _nanosleep=yes -if test "$_nanosleep" = yes ; then - def_nanosleep='#define HAVE_NANOSLEEP 1' -else - def_nanosleep='#define HAVE_NANOSLEEP 0' -fi -echores "$_nanosleep" +# Arguments: "message"($1) "setting"($2) "name"($3) "include"($4) "statement"($5) +# Also, $6 - $N can be libraries needed - it'll try each separately. +# Use " " as first entry if you want to try with no libraries too. +check_statement_libs() { + _res="$2" + _name="$3" + _inc="$4" + _st="$5" + echocheck "$1" + if test $_res = auto ; then + _res=no + shift 5 + while true ; do + statement_check "$_inc" "$_st" "$1" && libs_mplayer="$libs_mplayer $1" && _res=yes && break + test -z "$1" && break + shift + done + fi + check_yes_no $_res $_name + echores $_res + test $_res = yes && return 0 || return 1 +} +# Print "yes" if previous command succeeded, else "no" +defretval() { # shell is retarded? + if test $? == 0 ; then + echo "yes" + else + echo "no" + fi +} echocheck "dynamic loader" _dl=no for _ld_tmp in "" "-ldl"; do statement_check dlfcn.h 'dlopen("", 0)' $_ld_tmp && _ld_dl="$_ld_tmp" && _dl=yes && break done -if test "$_dl" = yes ; then - def_dl='#define HAVE_LIBDL 1' -else - def_dl='#define HAVE_LIBDL 0' -fi +define_yes_no $_dl HAVE_LIBDL echores "$_dl" - echocheck "pthread" cflag_check -pthread && _ld_pthread="$_ld_pthread -pthread" cflag_check -lpthread && _ld_pthread="$_ld_pthread -lpthread" +cflag_check -lrt && _ld_pthread="$_ld_pthread -lrt" extra_cflags="$extra_cflags -D_REENTRANT -D_THREAD_SAFE" -cat > $TMPC << EOF -#include <pthread.h> -static void *func(void *arg) { return arg; } -int main(void) { - pthread_t tid; - return pthread_create (&tid, 0, func, 0) != 0; -} -EOF -_pthreads=no -if cc_check "$_ld_pthread" ; then - _pthreads=yes -fi -echores "$_pthreads" -if test "$_pthreads" = no ; then - die "Unable to find pthreads support." -fi +compile_check waftools/fragments/pthreads.c "$_ld_pthread" || die "Unable to find pthreads support." +echores "yes" +check_statement_libs "compiler support for __atomic built-ins" auto ATOMIC_BUILTINS \ + stdint.h 'int64_t test = 0; test = __atomic_add_fetch(&test, 1, __ATOMIC_SEQ_CST)' \ + " " "-latomic" +_atomic=$(defretval) -echocheck "compiler support for __atomic built-ins" -_atomic=no -for _ld_tmp in "" "-latomic" ; do - statement_check stdint.h 'int64_t test = 0; test = __atomic_add_fetch(&test, 1, __ATOMIC_SEQ_CST)' $_ld_tmp && - libs_mplayer="$libs_mplayer $_ld_tmp" && _atomic=yes && break -done -if test "$_atomic" = yes ; then - def_atomic="#define HAVE_ATOMIC_BUILTINS 1" -else - def_atom |