Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 152 lines (128 sloc) 3.17 KB
#!/bin/bash
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
cat << EOF
Usage: [PKG_CONFIG_PATH=/foo/bar/lib/pkgconfig] ./configure [options]
options:
--cc=CC use a defined compiler for compilation and linking [gcc]
--target-os=OS build programs to run on OS [auto]
--cross-prefix=PREFIX use PREFIX for compilation tools [none]
--sysroot=DIR specify toolchain's directory [none]
--enable-debug compile with debug symbols and never strip
--extra-cflags=XCFLAGS add XCFLAGS to CFLAGS
--extra-ldflags=XLDFLAGS add XLDFLAGS to LDFLAGS
EOF
exit 1
fi
error_exit()
{
echo error: $1
exit 1
}
cc_check()
{
rm -f conftest.c
if [ -n "$3" ]; then
echo "#include <$3>" > conftest.c
fi
echo "int main(void){$4 return 0;}" >> conftest.c
$CC conftest.c -o conftest $1 $2 2> /dev/null
ret=$?
rm -f conftest*
return $ret
}
rm -f config.* .depend
TARGET_OS=""
CROSS=""
SYSROOT=""
CC="gcc"
LD="gcc"
STRIP="strip"
CFLAGS="-Wall -Wshadow -std=gnu99 -I."
LIBS="-lturbojpeg"
for opt; do
optarg="${opt#*=}"
case "$opt" in
--cc=*)
CC="$optarg"
LD="$optarg"
;;
--target-os=*)
TARGET_OS="$optarg"
;;
--cross-prefix=*)
CROSS="$optarg"
;;
--sysroot=*)
CFLAGS="$CFLAGS --sysroot=$optarg"
LDFLAGS="$LDFLAGS --sysroot=$optarg"
;;
--enable-debug)
DEBUG="enabled"
;;
--extra-cflags=*)
XCFLAGS="$optarg"
;;
--extra-ldflags=*)
XLDFLAGS="$optarg"
;;
*)
error_exit "unknown option $opt"
;;
esac
done
CC="${CROSS}${CC}"
LD="${CROSS}${LD}"
STRIP="${CROSS}${STRIP}"
for f in "$CC" "$LD" "$STRIP"; do
test -n "$(which $f 2> /dev/null)" || error_exit "$f is not executable"
done
if test -n "$TARGET_OS"; then
TARGET_OS=$(echo $TARGET_OS | tr '[A-Z]' '[a-z]')
else
TARGET_OS=$($CC -dumpmachine | tr '[A-Z]' '[a-z]')
fi
case "$TARGET_OS" in
*mingw* | *cygwin*)
LIBNAME="vsjpgreader.dll"
LDFLAGS="-shared -Wl,--add-stdcall-alias -L."
;;
*linux*)
LIBNAME="libvsjpgreader.so"
CFLAGS="$CFLAGS -fPIC"
LDFLAGS="-shared -fPIC -L."
;;
*)
error_exit "patches welcome"
;;
esac
CFLAGS="$CFLAGS $XCFLAGS"
LDFLAGS="$LDFLAGS $XLDFLAGS"
if test -n "$DEBUG"; then
CFLAGS="$CFLAGS -g3 -O0"
STRIP=""
else
CFLAGS="-Os -g0 -ffast-math -fomit-frame-pointer $CFLAGS"
fi
if ! cc_check "$CFLAGS" "$LDFLAGS"; then
error_exit "invalid CFLAGS/LDFLAGS"
fi
if cc_check "-march=i686 $CFLAGS" "$LDFLAGS"; then
CFLAGS="-march=i686 $CFLAGS"
fi
if cc_check "$CFLAGS -fexcess-precision=fast" "$LDFLAGS"; then
CFLAGS="$CFLAGS -fexcess-precision=fast"
fi
if ! cc_check "$CFLAGS" "$LDFLAGS $LIBS" "turbojpeg.h" "tjInitDecompress();" ; then
error_exit "turbojpeg.h might not be installed or libturbojpeg missing."
fi
cat >> config.mak << EOF
CC = $CC
LD = $LD
STRIP = $STRIP
LIBNAME = $LIBNAME
CFLAGS = $CFLAGS
LDFLAGS = $LDFLAGS
LIBS = $LIBS
EOF
echo configure finished.
exit 0
Something went wrong with that request. Please try again.