#!/bin/sh # Heavily based on the Slackware 13.1 SlackBuild # Written by jimmy_page_89 ( jimmy_page_89@hotmail.it ) # Last build from jimmy_page_89 ( jimmy_page_89@hotmail.it ) # Slackware build script for opencv # Official Site: http://opencv.willowgarage.com/wiki/ # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. set -e # Set to YES to enable ffmpeg support SB_FFMPEG=${SB_FFMPEG:-NO} # Set to YES to enable gstreamer support (take precedence over ffmpeg) SB_GST=${SB_GST:-YES} # Set to YES to enable xine-lib support SB_XINE=${SB_XINE:-YES} PKGNAME=opencv DNAME=OpenCV VERSION=${VERSION:-2.1.0} BUILD=${BUILD:-1sl} ARCH=${ARCH:-x86_64} SOURCE="http://prdownloads.sourceforge.net/opencvlibrary/$DNAME-$VERSION.tar.bz2" if [ ! -e $DNAME-$VERSION.tar.bz2 ];then wget $SOURCE fi CWD=$(pwd) TMP=${TMP:-/tmp/buildpkgs/$PKGNAME} PKG=$TMP/package-$PKGNAME OUTPUT=${OUTPUT:-$CWD} if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" LIBDIRSUFFIX="" SLKLDFLAGS="-L/usr/lib$LIBDIRSUFFIX" elif [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" SLKLDFLAGS="-L/usr/lib$LIBDIRSUFFIX" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" SLKLDFLAGS="-L/usr/lib$LIBDIRSUFFIX" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" SLKLDFLAGS="-L/usr/lib$LIBDIRSUFFIX" fi rm -rf $TMP mkdir -p $TMP $PKG $OUTPUT cd $TMP tar xvf $CWD/$DNAME-$VERSION.tar.bz2 cd $DNAME-$VERSION ### installazione patch (se presenti) patch -p1 -E --backup -z .libdir --verbose -i $CWD/$PKGNAME-cmake-libdir.patch patch -p1 -E --backup --verbose -i $CWD/$PKGNAME-libpng-1.4.patch if [ "${SB_FFMPEG}" = "YES" -a "${SB_GST}" = "YES" ] ;then SB_FFMPEG=NO SB_GST=YES fi [ "${SB_FFMPEG}" = "YES" ] || SB_FFMPEG=OFF [ "${SB_GST}" = "YES" ] || SB_GST=OFF [ "${SB_XINE}" = "YES" ] || SB_XINE=OFF export CFLAGS="${SLKCFLAGS}" export CXXFLAGS="${SLKCFLAGS}" export FFLAGS="${SLKCFLAGS}" chown -R root:root . chmod -R u+w,go+r-w,a-s . mkdir -p build ( cd build || exit $? cmake .. \ -DCMAKE_INSTALL_PREFIX:PATH=/usr \ -DSYSCONF_INSTALL_DIR:PATH=/etc \ -DINCLUDE_INSTALL_DIR:PATH=/usr/include \ -DLIB_INSTALL_DIR:PATH=/usr/lib${LIBDIRSUFFIX} \ -DLIB_SUFFIX=${LIBDIRSUFFIX} \ -DSHARE_INSTALL_PREFIX:PATH=/usr/share \ -DMAN_INSTALL_DIR:PATH=/usr/man \ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS:BOOL=ON \ -DCMAKE_SKIP_RPATH:BOOL=ON \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DUSE_O3:BOOL=OFF \ -DBUILD_SWIG_PYTHON_SUPPORT=1 \ -DINSTALL_C_EXAMPLES=1 \ -DINSTALL_PYTHON_EXAMPLES=1 \ -DWITH_FFMPEG=${SB_FFMPEG} \ -DWITH_GSTREAMER=${SB_GST} \ -DWITH_XINE=${SB_XINE} make make install DESTDIR=$PKG INSTALL="install -p" CPPROG="cp -p" ) ### In this section you may remove some not needed files or move that file in other path rm -f \ $PKG/usr/share/$PKGNAME/samples/c/build_all.sh \ $PKG/usr/share/$PKGNAME/samples/c/cvsample.dsp \ $PKG/usr/share/$PKGNAME/samples/c/cvsample.vcproj \ $PKG/usr/share/$PKGNAME/samples/c/facedetect.cmd cat > $PKG/usr/share/$PKGNAME/samples/c/GNUmakefile << 'EOF' CFLAGS := `pkg-config --cflags opencv` $(CFLAGS) CXXFLAGS := `pkg-config --cflags opencv` $(CXXFLAGS) LDFLAGS := `pkg-config --libs opencv` $(LDFLAGS) PROGRAMS := $(patsubst %.c,%,$(wildcard *.c)) $(patsubst %.cpp,%,$(wildcard *.cpp)) .PHONY: all clean all: $(PROGRAMS) clean: rm -f $(PROGRAMS) EOF install -m644 build/cvconfig.h $PKG/usr/include/$PKGNAME/cvconfig.h || exit 1 rm -rf $PKG/usr/share/$PKGNAME/{samples/octave/,ChangeLog,THANKS} ### copy some documentation files mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION cat $CWD/$PKGNAME.SlackBuild > $PKG/usr/doc/$PKGNAME-$VERSION/$PKGNAME.SlackBuild cat $CWD/slack-desc > $PKG/usr/doc/$PKGNAME-$VERSION/slack-desc ### compress man pages if [ -d $PKG/usr/man ]; then ( cd $PKG/usr/man find . -type f -exec gzip -9 {} \; for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) fi ### now you must do 'strip' all binary files ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true ) ### popolate the install/ directory mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc ### reset owner and create slack-required file. cd $PKG chown -R root:root $PKG if [ -x "$(which depfinder 2>/dev/null)" ];then depfinder -f -s -a -p $PKG mv slack-required $CWD/ elif [ -x "$(which requiredbuilder 2>/dev/null)" ];then requiredbuilder -y -v -s $CWD $PKG else touch $CWD/slack-required fi ### finally make the package. /sbin/makepkg -l y -c n $OUTPUT/$PKGNAME-$VERSION-$ARCH-$BUILD.${PKGTYPE:-txz} if [ "$1" = "--cleanup" ]; then rm -rf $TMP fi