Refactored quickbuild.

This commit is contained in:
tukuyomi 2012-06-12 22:16:16 +02:00 committed by Themaister
parent 4ee0bde039
commit ae33d8c899
5 changed files with 284 additions and 440 deletions

6
configure vendored
View File

@ -1,14 +1,10 @@
#!/bin/sh
echo ""
PACKAGE_NAME=retroarch
PACKAGE_VERSION=0.9.6
. qb/qb.params.sh
. qb/qb.comp.sh
. qb/config.libs.sh
. qb/qb.libs.sh

View File

@ -1,59 +1,46 @@
. qb/qb.libs.sh
check_switch_c C99 -std=gnu99
check_critical C99 "Cannot find C99 compatible compiler."
check_switch_c C99 -std=gnu99 "Cannot find C99 compatible compiler."
check_switch_c NOUNUSED -Wno-unused-result
add_define_make NOUNUSED $HAVE_NOUNUSED
add_define_make NOUNUSED "$HAVE_NOUNUSED"
# There are still broken 64-bit Linux distros out there. :)
if [ -d /usr/lib64 ]; then
add_library_dirs /usr/lib64
fi
[ -d /usr/lib64 ] && add_library_dirs /usr/lib64
if [ -d /opt/local/lib ]; then
add_library_dirs /opt/local/lib
fi
[ -d /opt/local/lib ] && add_library_dirs /opt/local/lib
if [ "$OS" = BSD ]; then
DYLIB=-lc
else
DYLIB=-ldl
fi
if [ "$OS" = 'BSD' ]; then DYLIB=-lc; else DYLIB=-ldl; fi
if [ -z "$LIBRETRO" ]; then
LIBRETRO="-lretro"
else
if [ "$LIBRETRO" ]; then
echo "Explicit libsnes used, disabling dynamic libsnes loading ..."
HAVE_DYNAMIC=no
HAVE_DYNAMIC='no'
else LIBRETRO="-lretro"
fi
if [ "$HAVE_DYNAMIC" != yes ]; then
check_lib_cxx RETRO $LIBRETRO retro_init $DYLIB
check_critical RETRO "Cannot find libretro."
add_define_make libretro $LIBRETRO
fi
[ "$HAVE_DYNAMIC" = 'yes' ] || {
check_lib_cxx RETRO "$LIBRETRO" retro_init "$DYLIB" "Cannot find libretro."
add_define_make libretro "$LIBRETRO"
}
check_lib THREADS -lpthread pthread_create
check_lib DYLIB $DYLIB dlopen
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
HAVE_SOCKET_LEGACY=no
if [ "$HAVE_GETADDRINFO" = 'yes' ]; then
HAVE_SOCKET_LEGACY='no'
else
HAVE_SOCKET_LEGACY=yes
HAVE_SOCKET_LEGACY='yes'
fi
HAVE_NETWORK_CMD=yes
HAVE_NETWORK_CMD='yes'
else
HAVE_NETWORK_CMD=no
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
@ -82,31 +69,29 @@ check_pkgconf PULSE libpulse
check_lib COREAUDIO "-framework AudioUnit" AudioUnitInitialize
check_pkgconf SDL sdl 1.2.10
check_critical SDL "Cannot find SDL library."
check_pkgconf SDL sdl 1.2.10 "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."
HAVE_CG=no
HAVE_CG='no'
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
@ -116,34 +101,33 @@ 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
echo "Not building with threading support. Will skip FFmpeg."
HAVE_FFMPEG=no
HAVE_FFMPEG='no'
fi
check_lib DYNAMIC $DYLIB dlopen
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."
HAVE_XVIDEO=no
HAVE_XVIDEO='no'
fi
check_lib STRL -lc strlcpy
check_pkgconf PYTHON python3
add_define_make OS $OS
add_define_make OS "$OS"
# Creates config.mk and config.h.
VARS="ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL DYLIB GETOPT_LONG THREADS CG XML SDL_IMAGE DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE CONFIGFILE FREETYPE XVIDEO X11 XEXT NETPLAY NETWORK_CMD SOCKET_LEGACY FBO STRL PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 X264RGB SINC BSV_MOVIE"
create_config_make config.mk $VARS
create_config_header config.h $VARS
create_config_header config.h $VARS

View File

@ -4,66 +4,46 @@ TEMP_C=.tmp.c
TEMP_CXX=.tmp.cxx
TEMP_EXE=.tmp
ECHOBUF="Checking operating system ... "
OS="Win32" # whatever ;D
unamestr="`uname -a`"
if [ ! -z "`echo "$unamestr" | grep -i Linux`" ]; then
OS="Linux"
elif [ ! -z "`echo "$unamestr" | grep -i Darwin`" ]; then
OS="Darwin"
elif [ ! -z "`echo "$unamestr" | grep -i BSD`" ]; then
OS="BSD"
elif [ ! -z "`echo "$unamestr" | grep -i MINGW32`" ]; then
OS="MinGW"
elif [ ! -z "`echo "$unamestr" | grep -i NT`" ]; then
OS="Cygwin"
fi
echo $ECHOBUF $OS
ECHOBUF="Checking operating system"
#echo -n "Checking operating system"
case "$(uname)" in
'Linux') OS='Linux';;
*'BSD') OS='BSD';;
'Darwin') OS='Darwin';;
'MINGW32'*) OS='MinGW';;
'CYGWIN'*) OS='Cygwin';;
*) OS="Win32";;
esac
echo "$ECHOBUF ... $OS"
# Checking for working C compiler
if [ "$USE_LANG_C" = yes ]; then
echo "Checking for working C compiler ..."
if [ -z $CC ]; then
CC=`which gcc cc 2> /dev/null | grep ^/ | head -n 1`
fi
if [ -z $CC ]; then
echo "Could not find C compiler in path. Exiting ..."
exit 1
fi
ECHOBUF="Checking if $CC is a suitable compiler ..."
answer=no
echo "#include <stdio.h>" > $TEMP_C
echo "int main(void) { puts(\"Hai world!\"); return 0; }" >> $TEMP_C
$CC -o $TEMP_EXE $TEMP_C 2>/dev/null >/dev/null && answer=yes
echo $ECHOBUF $answer
rm -rf $TEMP_C $TEMP_EXE
[ "$answer" = no ] && echo "Can't find suitable C compiler. Exiting ..." && exit 1
if [ "$USE_LANG_C" = 'yes' ]; then
ECHOBUF="Checking for suitable working C compiler"
# echo -n "Checking for suitable working C compiler"
cat << EOF > "$TEMP_C"
#include <stdio.h>
int main(void) { puts("Hai world!"); return 0; }
EOF
for CC in ${CC:=$(which gcc cc)} ''; do
"$CC" -o "$TEMP_EXE" "$TEMP_C" >/dev/null 2>&1 && break
done
[ "$CC" ] || { echo "$ECHOBUF ... Not found. Exiting."; exit 1;}
echo "$ECHOBUF ... $CC"
rm "$TEMP_C" "$TEMP_EXE"
fi
# Checking for working C++ compiler
if [ "$USE_LANG_CXX" = "yes" ]; then
echo "Checking for working C++ compiler ..."
if [ -z $CXX ]; then
CXX=`which g++ c++ 2> /dev/null | grep ^/ | head -n 1`
fi
if [ -z $CXX ]; then
echo "Could not find C++ compiler in path. Exiting ..."
exit 1
fi
ECHOBUF="Checking if $CXX is a suitable compiler ..."
answer=no
echo "#include <iostream>" > $TEMP_CXX
echo "int main() { std::cout << \"Hai guise\" << std::endl; return 0; }" >> $TEMP_CXX
$CXX -o $TEMP_EXE $TEMP_CXX 2>/dev/null >/dev/null && answer=yes
echo $ECHOBUF $answer
rm -rf $TEMP_CXX $TEMP_EXE
[ "$answer" = no ] && echo "Can't find suitable C++ compiler. Exiting ..." && exit 1
# Checking for working C++
if [ "$USE_LANG_CXX" = 'yes' ]; then
ECHOBUF="Checking for suitable working C++ compiler"
# echo -n "Checking for suitable working C++ compiler"
cat << EOF > "$TEMP_CXX"
#include <iostream>
int main() { std::cout << "Hai guise" << std::endl; return 0; }
EOF
for CXX in ${CXX:=$(which g++ c++)} ''; do
"$CXX" -o "$TEMP_EXE" "$TEMP_CXX" >/dev/null 2>&1 && break
done
[ "$CXX" ] || { echo "$ECHOBUF ... Not found. Exiting."; exit 1;}
echo "$ECHOBUF ... $CXX"
rm "$TEMP_CXX" "$TEMP_EXE"
fi

View File

@ -1,352 +1,239 @@
#<maister> echo -n is broken on recent OSX btw
PKG_CONF_PATH=""
PKG_CONF_USED=""
CONFIG_DEFINES=""
MAKEFILE_DEFINES=""
INCLUDE_DIRS=""
LIBRARY_DIRS=""
[ -z "$PREFIX" ] && PREFIX="/usr/local"
MAKEFILE_DEFINES='.MAKEFILE_DEFINES'
CONFIG_DEFINES='.CONFIG_DEFINES'
cat /dev/null > "$MAKEFILE_DEFINES" > "$CONFIG_DEFINES"
#cat /dev/null > "${MAKEFILE_DEFINES:=.MAKEFILE_DEFINES}" > "${CONFIG_DEFINES=.CONFIG_DEFINES}"
[ "$PREFIX" ] || PREFIX="/usr/local"
add_define_header()
{
CONFIG_DEFINES="$CONFIG_DEFINES:@$1@$2@:"
}
{ echo "$1=$2" >> "$CONFIG_DEFINES";}
add_define_make()
{
MAKEFILE_DEFINES="$MAKEFILE_DEFINES:@$1@$2@:"
}
{ echo "$1=$2" >> "$MAKEFILE_DEFINES";}
add_include_dirs()
{
while [ ! -z "$1" ]
do
INCLUDE_DIRS="$INCLUDE_DIRS -I$1"
shift
done
}
{ while [ "$1" ]; do INCLUDE_DIRS="$INCLUDE_DIRS -I$1"; shift; done;}
add_library_dirs()
{
while [ ! -z "$1" ]
do
LIBRARY_DIRS="$LIBRARY_DIRS -L$1"
shift
done
{ while [ "$1" ]; do LIBRARY_DIRS="$LIBRARY_DIRS -L$1"; shift; done;}
check_lib() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs
{ tmpval="$(eval echo \$HAVE_$1)"
[ "$tmpval" = 'no' ] && return 0
if [ "$3" ]; then
ECHOBUF="Checking function $3 in ${2% }"
echo "void $3(void); int main(void) { $3(); return 0; }" > $TEMP_C
else
ECHOBUF="Checking existence of ${2% }"
echo "int main(void) { return 0; }" > $TEMP_C
fi
answer='no'
# echo -n "$ECHOBUF"
"$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS $LIBRARY_DIRS $4 $CFLAGS $LDFLAGS $2 >/dev/null 2>&1 && answer='yes'
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
rm "$TEMP_C" "$TEMP_EXE" >/dev/null 2>&1
[ "$tmpval" = 'yes' ] && [ "$answer" = 'no' ] && {
echo "Forced to build with library $2, but cannot locate. Exiting ..."
exit 1
}
}
check_lib()
{
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
[ "$tmpval" = "no" ] && return 0
check_lib_cxx() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = critical error message [checked only if non-empty]
{ tmpval="$(eval echo \$HAVE_$1)"
[ "$tmpval" = 'no' ] && return 0
if [ -z "$3" ]; then
ECHOBUF="Checking existence of $2 ..."
echo "int main(void) { return 0; }" > $TEMP_C
else
ECHOBUF="Checking function $3 in $2 ..."
echo "void $3(void); int main(void) { $3(); return 0; }" > $TEMP_C
fi
eval HAVE_$1=no
answer=no
extralibs="$4"
$CC -o $TEMP_EXE $TEMP_C $INCLUDE_DIRS $LIBRARY_DIRS $extralibs $CFLAGS $LDFLAGS $2 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -f $TEMP_C $TEMP_EXE
if [ "$tmpval" = "yes" ] && [ "$answer" = "no" ]; then
echo "Forced to build with library $2, but cannot locate. Exiting ..."
exit 1
fi
}
check_lib_cxx()
{
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
[ "$tmpval" = "no" ] && return 0
if [ -z "$3" ]; then
ECHOBUF="Checking existence of $2 ..."
echo "int main() { return 0; }" > $TEMP_CXX
else
ECHOBUF="Checking function $3 in $2 ..."
echo "extern \"C\" { void $3(void); } int main() { $3(); }" > $TEMP_CXX
fi
eval HAVE_$1=no
answer=no
extralibs="$4"
$CXX -o $TEMP_EXE $TEMP_CXX $INCLUDE_DIRS $LIBRARY_DIRS $extralibs $CFLAGS $LDFLAGS $2 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -f $TEMP_CXX $TEMP_EXE
if [ "$tmpval" = "yes" ] && [ "$answer" = "no" ]; then
echo "Forced to build with library $2, but cannot locate. Exiting ..."
exit 1
fi
if [ "$3" ]; then
ECHOBUF="Checking function $3 in ${2% }"
echo "extern \"C\" { void $3(void); } int main() { $3(); }" > $TEMP_CXX
else
ECHOBUF="Checking existence of ${2% }"
echo "int main() { return 0; }" > $TEMP_CXX
fi
answer='no'
# echo -n "$ECHOBUF"
"$CXX" -o "$TEMP_EXE" "$TEMP_CXX" $INCLUDE_DIRS $LIBRARY_DIRS $4 $CFLAGS $LDFLAGS $2 >/dev/null 2>&1 && answer='yes'
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
rm "$TEMP_CXX" "$TEMP_EXE" >/dev/null 2>&1
[ "$answer" = 'no' ] && {
[ "$5" ] && { echo "$5"; exit 1;}
[ "$tmpval" = 'yes' ] && {
echo "Forced to build with library $2, but cannot locate. Exiting ..."
exit 1
}
}
}
check_code_c()
{
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
[ "$tmpval" = "no" ] && return 0
{ tmpval="$(eval echo \$HAVE_$1)"
[ "$tmpval" = 'no' ] && return 0
ECHOBUF="Checking C code snippet \"$3\" ..."
eval HAVE_$1=no
answer=no
$CC -o $TEMP_EXE $TEMP_C $INCLUDE_DIRS $LIBRARY_DIRS $2 $CFLAGS $LDFLAGS 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -f $TEMP_C $TEMP_EXE
ECHOBUF="Checking C code snippet \"$3\""
# echo -n "Checking C code snippet \"$3\""
answer='no'
"$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS $LIBRARY_DIRS $2 $CFLAGS $LDFLAGS >/dev/null 2>&1 && answer='yes'
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
rm "$TEMP_C" "$TEMP_EXE" >/dev/null 2>&1
}
check_code_cxx()
{
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
[ "$tmpval" = "no" ] && return 0
{ tmpval="$(eval echo \$HAVE_$1)"
[ "$tmpval" = 'no' ] && return 0
ECHOBUF="Checking C++ code snippet \"$3\" ..."
eval HAVE_$1=no
answer=no
$CXX -o $TEMP_EXE $TEMP_CXX $INCLUDE_DIRS $LIBRARY_DIRS $2 $CXXFLAGS $LDFLAGS 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -f $TEMP_CXX $TEMP_EXE
ECHOBUF="Checking C++ code snippet \"$3\""
# echo -n "Checking C++ code snippet \"$3\""
answer='no'
"$CXX" -o "$TEMP_EXE" "$TEMP_CXX" $INCLUDE_DIRS $LIBRARY_DIRS $2 $CXXFLAGS $LDFLAGS >/dev/null 2>&1 && answer='yes'
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
rm "$TEMP_CXX" "$TEMP_EXE" >/dev/null 2>&1
}
locate_pkg_conf()
{
ECHOBUF="Checking for pkg-config ... "
PKG_CONF_PATH="`which pkg-config | grep ^/ | head -n1`"
if [ -z $PKG_CONF_PATH ]; then
echo "not found"
echo "Cannot locate pkg-config. Exiting ..."
exit 1
fi
echo $ECHOBUF $PKG_CONF_PATH
check_pkgconf() #$1 = HAVE_$1 $2 = package $3 = version $4 = critical error message [checked only if non-empty]
{ tmpval="$(eval echo \$HAVE_$1)"
[ "$tmpval" = 'no' ] && return 0
[ "$PKG_CONF_PATH" ] || {
ECHOBUF="Checking for pkg-config"
# echo -n "Checking for pkg-config"
for PKG_CONF_PATH in $(which pkg-config) ''; do [ "$PKG_CONF_PATH" ] && break; done
[ "$PKG_CONF_PATH" ] || { echo "Not found. Exiting ..."; exit 1;}
echo "$ECHOBUF ... $PKG_CONF_PATH"
}
ECHOBUF="Checking presence of package $2"
[ "$3" ] && ECHOBUF="$ECHOBUF with minimum version $3"
# echo -n "$ECHOBUF ... "
answer='no'
pkg-config --atleast-version="${3:-0.0}" "$2" && {
answer='yes'
eval $1_CFLAGS=\"$(pkg-config $2 --cflags)\"
eval $1_LIBS=\"$(pkg-config $2 --libs)\"
}
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
PKG_CONF_USED="$PKG_CONF_USED $1"
[ "$answer" = 'no' ] && {
[ "$4" ] && { echo "$4"; exit 1;}
[ "$tmpval" = 'yes' ] && {
echo "Forced to build with package $2, but cannot locate. Exiting ..."
exit 1
}
}
}
check_pkgconf()
{
[ -z "$PKG_CONF_PATH" ] && locate_pkg_conf
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
[ "$tmpval" = "no" ] && return 0
ECHOBUF="Checking presence of package $2"
eval HAVE_$1=no
eval $1_CFLAGS=""
eval $1_LIBS=""
answer=no
minver=0.0
[ ! -z $3 ] && minver=$3 && ECHOBUF="$ECHOBUF with minimum version $minver"
ECHOBUF="$ECHOBUF ... "
pkg-config --atleast-version=$minver "$2" && eval HAVE_$1=yes && eval $1_CFLAGS='"`pkg-config $2 --cflags`"' && eval $1_LIBS='"`pkg-config $2 --libs`"' && answer=yes
echo $ECHOBUF $answer
PKG_CONF_USED="$PKG_CONF_USED $1"
if [ "$tmpval" = "yes" ] && [ "$answer" = "no" ]; then
echo "Forced to build with package $2, but cannot locate. Exiting ..."
exit 1
fi
check_header() #$1 = HAVE_$1 $2 = header file
{ tmpval="$(eval echo \$HAVE_$1)"
[ "$tmpval" = 'no' ] && return 0
ECHOBUF="Checking presence of header file $2"
# echo -n "Checking presence of header file $2"
cat << EOF > "$TEMP_C"
#include<$2>
int main(void) { return 0; }
EOF
answer='no'
"$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS >/dev/null 2>&1 && answer='yes'
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
rm "$TEMP_C" "$TEMP_EXE" >/dev/null 2>&1
[ "$tmpval" = 'yes' ] && [ "$answer" = 'no' ] && {
echo "Build assumed that $2 exists, but cannot locate. Exiting ..."
exit 1
}
}
check_header()
{
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
[ "$tmpval" = "no" ] && return 0
ECHOBUF="Checking presence of header file $2 ..."
echo "#include<$2>" > $TEMP_C
echo "int main(void) { return 0; }" >> $TEMP_C
eval HAVE_$1=no
answer=no
$CC -o $TEMP_EXE $TEMP_C $INCLUDE_DIRS 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -rf $TEMP_C $TEMP_EXE
if [ "$tmpval" = "yes" ] && [ "$answer" = "no" ]; then
echo "Build assumed that $2 exists, but cannot locate. Exiting ..."
exit 1
fi
check_switch_c() #$1 = HAVE_$1 $2 = switch $3 = critical error message [checked only if non-empty]
{ ECHOBUF="Checking for availability of switch $2 in $CC"
# echo -n "Checking for availability of switch $2 in $CC "
echo "int main(void) { return 0; }" > $TEMP_C
answer='no'
"$CC" -o "$TEMP_EXE" "$TEMP_C" $2 >/dev/null 2>&1 && answer='yes'
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
rm "$TEMP_C" "$TEMP_EXE" >/dev/null 2>&1
[ "$answer" = 'no' ] && {
[ "$3" ] && { echo "$3"; exit 1;}
}
}
check_switch_c()
{
ECHOBUF="Checking for availability of switch $2 in $CC ..."
if [ -z "$CC" ]; then
echo "No C compiler, cannot check ..."
exit 1
fi
echo "int main(void) { return 0; }" > $TEMP_C
eval HAVE_$1=no
answer=no
$CC -o $TEMP_EXE $TEMP_C $2 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -rf $TEMP_C $TEMP_EXE
}
check_switch_cxx()
{
ECHOBUF="Checking for availability of switch $2 in $CXX ... "
if [ -z "$CXX" ]; then
echo "No C++ compiler, cannot check ..."
exit 1
fi
echo "int main() { return 0; }" > $TEMP_CXX
eval HAVE_$1=no
answer=no
$CXX -o $TEMP_EXE $TEMP_CXX $2 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -rf $TEMP_CXX $TEMP_EXE
}
check_critical()
{
val=HAVE_$1
eval val=\$$val
if [ "$val" != "yes" ]; then
echo "$2"
exit 1
fi
}
output_define_header()
{
arg1="`echo $2 | sed 's|^@\([^@]*\)@\([^@]*\)@$|\1|'`"
arg2="`echo $2 | sed 's|^@\([^@]*\)@\([^@]*\)@$|\2|'`"
echo "#define $arg1 $arg2" >> "$outfile"
check_switch_cxx() #$1 = HAVE_$1 $2 = switch $3 = critical error message [checked only if non-empty]
{ ECHOBUF="Checking for availability of switch $2 in $CXX"
# echo -n "Checking for availability of switch $2 in $CXX"
echo "int main() { return 0; }" > $TEMP_CXX
answer='no'
"$CXX" -o "$TEMP_EXE" "$TEMP_CXX" "$2" >/dev/null 2>&1 && answer='yes'
eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer"
rm "$TEMP_CXX" "$TEMP_EXE" >/dev/null 2>&1
[ "$answer" = 'no' ] && {
[ "$3" ] && { echo "$3"; exit 1;}
}
}
create_config_header()
{
outfile="$1"
shift
{ outfile="$1"; shift
echo "Creating config header: $outfile"
echo "Creating config header: $outfile"
name=$(echo "QB_${outfile}__" | tr '.[a-z]' '_[A-Z]')
{ echo "#ifndef $name"
echo "#define $name"
echo ""
echo "#define PACKAGE_NAME \"$PACKAGE_NAME\""
echo "#define PACKAGE_VERSION \"$PACKAGE_VERSION\""
name="`echo QB_${outfile}__ | sed 's|[\./]|_|g' | tr '[a-z]' '[A-Z]'`"
echo "#ifndef $name" > "$outfile"
echo "#define $name" >> "$outfile"
echo "" >> "$outfile"
echo "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >> "$outfile"
echo "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >> "$outfile"
while [ "$1" ]; do
case $(eval echo \$HAVE_$1) in
'yes') echo "#define HAVE_$1 1";;
'no') echo "/* #undef HAVE_$1 */";;
esac
shift
done
while [ ! -z "$1" ]
do
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
if [ "$tmpval" = "yes" ]; then
echo "#define HAVE_$1 1" >> "$outfile"
elif [ "$tmpval" = "no" ]; then
echo "/* #undef HAVE_$1 */" >> "$outfile"
fi
while IFS='=' read VAR VAL; do echo "#define $VAR $VAL"; done < "$CONFIG_DEFINES"
shift
done
echo "" >> "$outfile"
tmpdefs="$CONFIG_DEFINES"
while [ ! -z "$tmpdefs" ]
do
subdefs="`echo $tmpdefs | sed 's|^:\(@[^@]*@[^@]*@\):.*$|\1|'`"
tmpdefs="`echo $tmpdefs | sed 's|^\W*$||'`"
tmpdefs="`echo $tmpdefs | sed 's|^:\(@[^@]*@[^@]*@\):||'`"
output_define_header "$outfile" "$subdefs"
done
echo "#endif" >> "$outfile"
}
output_define_make()
{
arg1="`echo $2 | sed 's|^@\([^@]*\)@\([^@]*\)@$|\1|'`"
arg2="`echo $2 | sed 's|^@\([^@]*\)@\([^@]*\)@$|\2|'`"
echo "$arg1 = $arg2" >> "$outfile"
echo "#endif"
} > "$outfile"
}
create_config_make()
{
outfile="$1"
shift
{ outfile="$1"; shift
echo "Creating make config: $outfile"
echo "Creating make config: $outfile"
rm -rf "$outfile"
touch "$outfile"
if [ "$USE_LANG_C" = "yes" ]; then
echo "CC = $CC" >> "$outfile"
echo "CFLAGS = $CFLAGS" >> "$outfile"
fi
if [ "$USE_LANG_CXX" = "yes" ]; then
echo "CXX = $CXX" >> "$outfile"
echo "CXXFLAGS = $CXXFLAGS" >> "$outfile"
fi
echo "LDFLAGS = $LDFLAGS" >> "$outfile"
echo "INCLUDE_DIRS = $INCLUDE_DIRS" >> "$outfile"
echo "LIBRARY_DIRS = $LIBRARY_DIRS" >> "$outfile"
echo "PACKAGE_NAME = $PACKAGE_NAME" >> "$outfile"
echo "PACKAGE_VERSION = $PACKAGE_VERSION" >> "$outfile"
echo "PREFIX = $PREFIX" >> "$outfile"
{ if [ "$USE_LANG_C" = 'yes' ]; then
echo "CC = $CC"
echo "CFLAGS = $CFLAGS"
fi
if [ "$USE_LANG_CXX" = 'yes' ]; then
echo "CXX = $CXX"
echo "CXXFLAGS = $CXXFLAGS"
fi
echo "LDFLAGS = $LDFLAGS"
echo "INCLUDE_DIRS = $INCLUDE_DIRS"
echo "LIBRARY_DIRS = $LIBRARY_DIRS"
echo "PACKAGE_NAME = $PACKAGE_NAME"
echo "PACKAGE_VERSION = $PACKAGE_VERSION"
echo "PREFIX = $PREFIX"
while [ ! -z "$1" ]
do
tmpval="HAVE_$1"
eval tmpval=\$$tmpval
if [ "$tmpval" = yes ]; then
echo "HAVE_$1 = 1" >> "$outfile"
elif [ "$tmpval" = no ]; then
echo "HAVE_$1 = 0" >> "$outfile"
fi
if [ ! -z "`echo $PKG_CONF_USED | grep $1`" ]; then
tmpval="$1_CFLAGS"
eval tmpval=\$$tmpval
echo "$1_CFLAGS = $tmpval" >> "$outfile"
tmpval="$1_LIBS"
eval tmpval=\$$tmpval
echo "$1_LIBS = $tmpval" >> "$outfile"
fi
shift
done
echo "" >> "$outfile"
tmpdefs="$MAKEFILE_DEFINES"
while [ ! -z "$tmpdefs" ]
do
subdefs="`echo $tmpdefs | sed 's|^:\(@[^@]*@[^@]*@\):.*$|\1|'`"
tmpdefs="`echo $tmpdefs | sed 's|^\W*$||'`"
tmpdefs="`echo $tmpdefs | sed 's|^:\(@[^@]*@[^@]*@\):||'`"
output_define_make "$outfile" "$subdefs"
done
while [ "$1" ]; do
case $(eval echo \$HAVE_$1) in
'yes') echo "HAVE_$1 = 1";;
'no') echo "HAVE_$1 = 0";;
esac
case "$PKG_CONF_USED" in
*$1*)
echo "$1_CFLAGS = $(eval echo \$$1_CFLAGS)"
echo "$1_LIBS = $(eval echo \$$1_LIBS)"
;;
esac
shift
done
while IFS='=' read VAR VAL; do echo "$VAR = $VAL"; done < "$MAKEFILE_DEFINES"
} > "$outfile"
}
. qb/config.libs.sh
rm "$MAKEFILE_DEFINES" "$CONFIG_DEFINES"

View File

@ -23,49 +23,48 @@ 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";;
'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'
}
opt_exists() # $opt is returned if exists in OPTS
{
opt=$(echo "$1" | tr '[a-z]' '[A-Z]')
{ opt=$(echo "$1" | tr '[a-z]' '[A-Z]')
for OPT in $OPTS; do [ "$opt" = "$OPT" ] && return; done
print_help; exit 1
}
parse_input() # Parse stuff :V
{
#OPTS contains all available options in config.params.sh
while IFS='=' read VAR dummy; do OPTS="$OPTS ${VAR##HAVE_}"; done < 'qb/config.params.sh'
{ OPTS=; while IFS='=' read VAR dummy; do OPTS="$OPTS ${VAR##HAVE_}"; done < 'qb/config.params.sh'
#OPTS contains all available options in config.params.sh - used to speedup
#things in opt_exists()
while [ "$1" ]; do
case "$1" in
--prefix=*) PREFIX=${1##--prefix=};;
--enable-*)
opt_exists "${1##--enable-}" "$OPTS"
opt_exists "${1##--enable-}"
eval "HAVE_$opt=yes"
;;
--disable-*)
opt_exists "${1##--disable-}" "$OPTS"
opt_exists "${1##--disable-}"
eval "HAVE_$opt=no"
;;
--with-*)
arg=${1##--with-}
val=${arg##*=}
opt_exists "${arg%%=*}" "$OPTS"
opt_exists "${arg%%=*}"
eval "$opt=$val"
;;
-h|--help) print_help; exit 0;;
*) print_help; exit 1;;
esac
shift
@ -74,6 +73,4 @@ parse_input() # Parse stuff :V
. qb/config.params.sh
parse_input "$@"
parse_input "$@"