diff --git a/configure b/configure index d50a2b8eae..4401272470 100755 --- a/configure +++ b/configure @@ -2,9 +2,10 @@ echo "" -. qb/config.params.sh +PACKAGE_NAME=ssnes +PACKAGE_VERSION=0.9.6-rc1 -parse_input "$@" +. qb/qb.params.sh . qb/qb.comp.sh . qb/config.libs.sh diff --git a/qb/config.libs.sh b/qb/config.libs.sh index abf40ebc0f..9d7352b995 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -15,7 +15,7 @@ if [ -d /opt/local/lib ]; then add_library_dirs /opt/local/lib fi -if [ $OS = BSD ]; then +if [ "$OS" = BSD ]; then DYLIB=-lc else DYLIB=-ldl @@ -28,7 +28,7 @@ else HAVE_DYNAMIC=no fi -if [ $HAVE_DYNAMIC != yes ]; then +if [ "$HAVE_DYNAMIC" != yes ]; then check_lib_cxx RETRO $LIBRETRO retro_init $DYLIB check_critical RETRO "Cannot find libretro." add_define_make libretro $LIBRETRO @@ -38,10 +38,10 @@ check_lib THREADS -lpthread pthread_create check_lib DYLIB $DYLIB dlopen check_lib NETPLAY -lc socket -if [ $HAVE_NETPLAY = yes ]; then +if [ "$HAVE_NETPLAY" = yes ]; then HAVE_GETADDRINFO=auto check_lib GETADDRINFO -lc getaddrinfo - if [ $HAVE_GETADDRINFO = yes ]; then + if [ "$HAVE_GETADDRINFO" = yes ]; then HAVE_SOCKET_LEGACY=no else HAVE_SOCKET_LEGACY=yes @@ -51,10 +51,9 @@ else HAVE_NETWORK_CMD=no fi - check_lib GETOPT_LONG -lc getopt_long -if [ $HAVE_DYLIB = no ] && [ $HAVE_DYNAMIC = yes ]; then +if [ "$HAVE_DYLIB" = no ] && [ "$HAVE_DYNAMIC" = yes ]; then echo "Dynamic loading of libsnes is enabled, but your platform does not appear to have dlopen(), use --disable-dynamic or --with-libsnes=\"-lsnes\"". exit 1 fi @@ -64,13 +63,13 @@ check_header OSS sys/soundcard.h check_header OSS_BSD soundcard.h check_lib OSS_LIB -lossaudio -if [ $OS = Darwin ]; then +if [ "$OS" = Darwin ]; then check_lib AL "-framework OpenAL" alcOpenDevice else check_lib AL -lopenal alcOpenDevice fi -if [ $OS = Darwin ]; then +if [ "$OS" = Darwin ]; then check_lib FBO "-framework OpenGL" glFramebufferTexture2D else check_lib FBO -lGL glFramebufferTexture2D @@ -87,7 +86,7 @@ check_pkgconf SDL sdl 1.2.10 check_critical SDL "Cannot find SDL library." # On some distros, -lCg doesn't link against -lstdc++ it seems ... -if [ $HAVE_OPENGL != no ]; then +if [ "$HAVE_OPENGL" != no ]; then check_lib_cxx CG -lCg cgCreateContext else echo "Ignoring Cg. OpenGL is not enabled." @@ -97,17 +96,17 @@ fi check_pkgconf XML libxml-2.0 check_pkgconf SDL_IMAGE SDL_image -if [ $HAVE_THREADS != no ]; then - if [ $HAVE_FFMPEG != no ]; then +if [ "$HAVE_THREADS" != no ]; then + if [ "$HAVE_FFMPEG" != no ]; then check_pkgconf AVCODEC libavcodec check_pkgconf AVFORMAT libavformat check_pkgconf AVUTIL libavutil check_pkgconf SWSCALE libswscale - ( [ $HAVE_FFMPEG = auto ] && ( [ $HAVE_AVCODEC = no ] || [ $HAVE_AVFORMAT = no ] || [ $HAVE_AVUTIL = no ] || [ $HAVE_SWSCALE = no ] ) && HAVE_FFMPEG=no ) || HAVE_FFMPEG=yes + ( [ "$HAVE_FFMPEG" = auto ] && ( [ "$HAVE_AVCODEC" = no ] || [ "$HAVE_AVFORMAT" = no ] || [ "$HAVE_AVUTIL" = no ] || [ "$HAVE_SWSCALE" = no ] ) && HAVE_FFMPEG=no ) || HAVE_FFMPEG=yes fi - if [ $HAVE_FFMPEG = yes ]; then + if [ "$HAVE_FFMPEG" = yes ]; then check_lib FFMPEG_ALLOC_CONTEXT3 "$AVCODEC_LIBS" avcodec_alloc_context3 check_lib FFMPEG_AVCODEC_OPEN2 "$AVCODEC_LIBS" avcodec_open2 check_lib FFMPEG_AVCODEC_ENCODE_AUDIO2 "$AVCODEC_LIBS" avcodec_encode_audio2 @@ -117,7 +116,7 @@ if [ $HAVE_THREADS != no ]; then check_lib FFMPEG_AVCODEC_ENCODE_VIDEO2 "$AVCODEC_LIBS" avcodec_encode_video2 fi - if [ $HAVE_FFMPEG = no ] && [ $HAVE_X264RGB = yes ]; then + if [ "$HAVE_FFMPEG" = no ] && [ "$HAVE_X264RGB" = yes ]; then echo "x264 RGB recording is enabled, but FFmpeg is not. --enable-x264rgb will not have any effect." fi else @@ -130,7 +129,7 @@ check_lib DYNAMIC $DYLIB dlopen check_pkgconf FREETYPE freetype2 check_pkgconf X11 x11 check_pkgconf XEXT xext -if [ $HAVE_X11 = yes ] && [ $HAVE_XEXT = yes ]; then +if [ "$HAVE_X11" = yes ] && [ "$HAVE_XEXT" = yes ]; then check_pkgconf XVIDEO xv else echo "X11 or Xext not present. Skipping XVideo." diff --git a/qb/config.params.sh b/qb/config.params.sh index df9fb84079..3a2f311363 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -1,35 +1,26 @@ -. qb/qb.params.sh - -PACKAGE_NAME=ssnes -PACKAGE_VERSION=0.9.6-rc1 - -# Adds a command line opt to ./configure --help -# $1: Variable (HAVE_ALSA, HAVE_OSS, etc) -# $2: Comment -# $3: Default arg. auto implies that HAVE_ALSA will be set according to library checks later on. -add_command_line_enable DYNAMIC "Disable dynamic loading of libsnes library" yes -add_command_line_string LIBRETRO "libretro library used" "" -add_command_line_enable THREADS "Threading support" auto -add_command_line_enable FFMPEG "Enable FFmpeg recording support" auto -add_command_line_enable X264RGB "Enable lossless X264 RGB recording" no -add_command_line_enable DYLIB "Enable dynamic loading support" auto -add_command_line_enable NETPLAY "Enable netplay support" auto -add_command_line_enable CONFIGFILE "Disable support for config file" yes -add_command_line_enable OPENGL "Disable OpenGL support" yes -add_command_line_enable CG "Enable Cg shader support" auto -add_command_line_enable XML "Enable bSNES-style XML shader support" auto -add_command_line_enable FBO "Enable render-to-texture (FBO) support" auto -add_command_line_enable ALSA "Enable ALSA support" auto -add_command_line_enable OSS "Enable OSS support" auto -add_command_line_enable RSOUND "Enable RSound support" auto -add_command_line_enable ROAR "Enable RoarAudio support" auto -add_command_line_enable AL "Enable OpenAL support" auto -add_command_line_enable JACK "Enable JACK support" auto -add_command_line_enable COREAUDIO "Enable CoreAudio support" auto -add_command_line_enable PULSE "Enable PulseAudio support" auto -add_command_line_enable FREETYPE "Enable FreeType support" auto -add_command_line_enable XVIDEO "Enable XVideo support" auto -add_command_line_enable SDL_IMAGE "Enable SDL_image support" auto -add_command_line_enable PYTHON "Enable Python 3 support for shaders" auto -add_command_line_enable SINC "Disable SINC resampler" yes -add_command_line_enable BSV_MOVIE "Disable BSV movie support" yes +HAVE_DYNAMIC=yes # Disable dynamic loading of libsnes library +HAVE_LIBRETRO= # libretro library used +HAVE_THREADS=auto # Threading support +HAVE_FFMPEG=auto # Enable FFmpeg recording support +HAVE_X264RGB=no # Enable lossless X264 RGB recording +HAVE_DYLIB=auto # Enable dynamic loading support +HAVE_NETPLAY=auto # Enable netplay support +HAVE_CONFIGFILE=yes # Disable support for config file +HAVE_OPENGL=yes # Disable OpenGL support +HAVE_CG=auto # Enable Cg shader support +HAVE_XML=auto # Enable bSNES-style XML shader support +HAVE_FBO=auto # Enable render-to-texture (FBO) support +HAVE_ALSA=auto # Enable ALSA support +HAVE_OSS=auto # Enable OSS support +HAVE_RSOUND=auto # Enable RSound support +HAVE_ROAR=auto # Enable RoarAudio support +HAVE_AL=auto # Enable OpenAL support +HAVE_JACK=auto # Enable JACK support +HAVE_COREAUDIO=auto # Enable CoreAudio support +HAVE_PULSE=auto # Enable PulseAudio support +HAVE_FREETYPE=auto # Enable FreeType support +HAVE_XVIDEO=auto # Enable XVideo support +HAVE_SDL_IMAGE=auto # Enable SDL_image support +HAVE_PYTHON=auto # Enable Python 3 support for shaders +HAVE_SINC=yes # Disable SINC resampler +HAVE_BSV_MOVIE=yes # Disable BSV movie support diff --git a/qb/qb.comp.sh b/qb/qb.comp.sh index cd7e273b37..3ff8f9c469 100644 --- a/qb/qb.comp.sh +++ b/qb/qb.comp.sh @@ -41,7 +41,7 @@ if [ "$USE_LANG_C" = yes ]; then rm -rf $TEMP_C $TEMP_EXE - [ $answer = no ] && echo "Can't find suitable C compiler. Exiting ..." && exit 1 + [ "$answer" = no ] && echo "Can't find suitable C compiler. Exiting ..." && exit 1 fi # Checking for working C++ compiler @@ -64,6 +64,6 @@ if [ "$USE_LANG_CXX" = "yes" ]; then rm -rf $TEMP_CXX $TEMP_EXE - [ $answer = no ] && echo "Can't find suitable C++ compiler. Exiting ..." && exit 1 + [ "$answer" = no ] && echo "Can't find suitable C++ compiler. Exiting ..." && exit 1 fi diff --git a/qb/qb.params.sh b/qb/qb.params.sh index 0e5988e5f2..c5669a0f28 100644 --- a/qb/qb.params.sh +++ b/qb/qb.params.sh @@ -1,153 +1,79 @@ -COMMAND_LINE_OPTS_ENABLE="" - -add_command_line_enable() -{ - COMMAND_LINE_OPTS_ENABLE="$COMMAND_LINE_OPTS_ENABLE:\"$1\" \"$2\" \"$3\":" - eval HAVE_$1=$3 -} - -add_command_line_string() -{ - COMMAND_LINE_OPTS_STRINGS="$COMMAND_LINE_OPTS_STRINGS:\"$1\" \"$2\" \"$3\":" - eval $1=$3 -} - ## lvl. 43 regex dragon awaits thee. print_help() -{ - echo "====================" - echo " Quickbuild script" - echo "====================" - echo "Package: $PACKAGE_NAME" - echo "Version: $PACKAGE_VERSION" - echo "" - echo "General environment variables:" - echo "CC: C compiler" - echo "CFLAGS: C compiler flags" - echo "CXX: C++ compiler" - echo "CXXFLAGS: C++ compiler flags" - echo "LDFLAGS: Linker flags" - echo "" - echo "General options:" - echo "--prefix=\$path: Install path prefix" - echo "--help: Show this help" - echo "" - echo "Custom options:" +{ cat << EOF +==================== + Quickbuild script +==================== +Package: $PACKAGE_NAME +Version: $PACKAGE_VERSION - tmpopts="$COMMAND_LINE_OPTS_ENABLE" - while [ ! -z "$tmpopts" ] - do - subopts="`echo $tmpopts | sed 's|^:"\([^"]*\)"."\([^"]*\)"."\([^"]*\)":.*$|"\1":"\2":"\3"|'`" - tmpopts="`echo $tmpopts | sed 's|^\W*$||'`" - tmpopts="`echo $tmpopts | sed 's|^:"[^"]*"."[^"]*"."[^"]*":||'`" - print_sub_opt "$subopts" - done +General environment variables: +CC: C compiler +CFLAGS: C compiler flags +CXX: C++ compiler +CXXFLAGS: C++ compiler flags +LDFLAGS: Linker flags - echo "" +General options: +--prefix=\$path: Install path prefix +--help: Show this help - tmpopts="$COMMAND_LINE_OPTS_STRINGS" - while [ ! -z "$tmpopts" ] - do - subopts="`echo $tmpopts | sed 's|^:"\([^"]*\)"."\([^"]*\)"."\([^"]*\)":.*$|"\1":"\2":"\3"|'`" - tmpopts="`echo $tmpopts | sed 's|^\W*$||'`" - tmpopts="`echo $tmpopts | sed 's|^:"[^"]*"."[^"]*"."[^"]*":||'`" - print_sub_str_opt "$subopts" - done +Custom options: +EOF + while IFS='=#' read VAR VAL COMMENT; do + VAR=$(echo "${VAR##HAVE_}" | tr '[A-Z]' '[a-z]') + case "$VAL" in + 'yes'*) echo "--disable-$VAR: $COMMENT";; + 'no'*) echo "--enable-$VAR: $COMMENT";; + 'auto'*) echo "--enable-$VAR: $COMMENT"; echo "--disable-$VAR";; + *) echo "--with-$VAR: $COMMENT";; + esac + done < 'qb/config.params.sh' } -print_sub_opt() +opt_exists() # $opt is returned if exists in OPTS { - arg1="`echo $1 | sed 's|^"\([^"]*\)":"\([^"]*\)":"\([^"]*\)"$|\1|'`" - arg2="`echo $1 | sed 's|^"\([^"]*\)":"\([^"]*\)":"\([^"]*\)"$|\2|'`" - arg3="`echo $1 | sed 's|^"\([^"]*\)":"\([^"]*\)":"\([^"]*\)"$|\3|'`" - - lowertext="`echo $arg1 | tr '[A-Z]' '[a-z]'`" - - if [ "$arg3" = "auto" ]; then - echo "--enable-$lowertext: $arg2" - echo "--disable-$lowertext" - elif [ "$arg3" = "yes" ]; then - echo "--disable-$lowertext: $arg2" - elif [ "$arg3" = "no" ]; then - echo "--enable-$lowertext: $arg2" - fi + opt=$(echo "$1" | tr '[a-z]' '[A-Z]') + for OPT in $OPTS; do [ "$opt" = "$OPT" ] && return; done + print_help; exit 1 } -print_sub_str_opt() +parse_input() # Parse stuff :V { - arg1="`echo $1 | sed 's|^"\([^"]*\)":"\([^"]*\)":"\([^"]*\)"$|\1|'`" - arg2="`echo $1 | sed 's|^"\([^"]*\)":"\([^"]*\)":"\([^"]*\)"$|\2|'`" - arg3="`echo $1 | sed 's|^"\([^"]*\)":"\([^"]*\)":"\([^"]*\)"$|\3|'`" + #OPTS contains all available options in config.params.sh + while IFS='=' read VAR dummy; do OPTS="$OPTS ${VAR##HAVE_}"; done < 'qb/config.params.sh' + + while [ "$1" ]; do + case "$1" in + --prefix=*) PREFIX=${1##--prefix=};; - lowertext="`echo $arg1 | tr '[A-Z]' '[a-z]'`" + --enable-*) + opt_exists "${1##--enable-}" "$OPTS" + eval "HAVE_$opt=yes" + ;; - echo "--with-$lowertext: $arg2" + --disable-*) + opt_exists "${1##--disable-}" "$OPTS" + eval "HAVE_$opt=no" + ;; + + --with-*) + arg=${1##--with-} + val=${arg##*=} + opt_exists "${arg%%=*}" "$OPTS" + eval "$opt=$val" + ;; + + -h|--help) print_help; exit 0;; + + *) print_help; exit 1;; + esac + shift + done } -parse_input() -{ - ### Parse stuff :V - - while [ ! -z "$1" ] - do - - case "$1" in - - --prefix=*) - prefix="`echo $1 | sed -e 's|^--prefix=||' -e 's|^\(.*\)/$|\1|'`" - - if [ "$prefix" != "$1" ]; then - PREFIX="$prefix" - fi - ;; - - --enable-*) - tmp="$1" - enable="${tmp#--enable-}" - if [ -z "`echo $COMMAND_LINE_OPTS_ENABLE | grep -i -- $enable`" ]; then - print_help - exit 1 - fi - eval HAVE_`echo $enable | tr '[a-z]' '[A-Z]'`=yes - ;; - - --disable-*) - tmp="$1" - disable="${tmp#--disable-}" - if [ -z "`echo $COMMAND_LINE_OPTS_ENABLE | grep -i -- $disable`" ]; then - print_help - exit 1 - fi - eval HAVE_`echo $disable | tr '[a-z]' '[A-Z]'`=no - ;; - - --with-*) - tmp="$1" - arg="${tmp#--with-*=}" - tmp="${tmp#--with-}" - with="${tmp%%=*}" - if [ -z "`echo $COMMAND_LINE_OPTS_STRINGS | grep -i -- $with`" ]; then - print_help - exit 1 - fi - eval "`echo $with | tr '[a-z]' '[A-Z]'`=\"$arg\"" - ;; - - - -h|--help) - print_help - exit 0 - ;; - *) - print_help - exit 1 - ;; - - esac - - shift - - done -} +. qb/config.params.sh +parse_input "$@" +