# Get it
cd
test -f installed/motion-4.0.1.tar.gz &&
mv -f installed/motion-4.0.1.tar.gz .
test ! -f motion-4.0.1.tar.gz &&
wget https://github.com/Motion-Project/motion/archive/\
release-4.0.1.tar.gz -O motion-4.0.1.tar.gz
# Extract it, remove older versions' source
mkdir -p -m 0700 src
cd src
test -d ./motion-trunk && rm -r ./motion-trunk
find -maxdepth 1 -type d -name "motion-[123].*" -exec rm -r {} \;
find -maxdepth 1 -type d -name "motion-release-*" -exec rm -r {} \;
tar xzvf ~/motion-4.0.1.tar.gz
cd motion-release-4.0.1
test $UID = 0 && chown -R root:root .
# If you want to enable libjpeg-turbo, apply this patch if you are 64-bit.
# configure appears to be looking for libjpeg (not libturbojpeg) anyway
# by actually checking if the library file exists (what about 'pkg-config
# --exists libturbojpeg'?). So, when you pass --with-jpeg-turbo, it only
# checks /lib/, not /lib64/. This patch makes it check both.
wget http://englanders.us/pub/linux/patches/motion-4.0.1.lib64.patch &&
patch -p0 < motion-4.0.1.lib64.patch
# The default Makefile is using datadir/doc/motion
# (/usr/local/share/doc/motion) instead of what you pass to configure with
# --docdir This patch fixes that.
wget -nc http://englanders.us/pub/linux/patches/motion-4.0.1.docdir.patch &&
patch -p0 < motion-4.0.1.docdir.patch
# Create configure and friends
test ! -f ./configure && autoreconf -fiv
# As done here, the motion binary will be in /usr/local/bin,
# the man page will be in /usr/local/man/man1, configuration files will be
# in /usr/local/etc/motion, example config files (and init scripts) will be
# under the configuration file directory in examples/, and docs will be in
# /usr/local/doc/motion
# Configure the build with libjpeg-turbo
./configure --with-jpeg-turbo=/usr \
--datadir=/usr/local/etc --docdir=/usr/local/doc/motion \
--mandir=/usr/local/man
# ...or configure the build with normal libjpeg
test $(uname -m) = 'x86_64' &&
./configure --datadir=/usr/local/etc --docdir=/usr/local/doc/motion \
--mandir=/usr/local/man
# Build it
make
# Become root to install it
su
# Install it
make install
# The last version of this HOWTO (in 2013) set the configuration file as
# /usr/local/etc/motion.conf If you have one there, move it into
# /usr/local/etc/motion/ or make sure that whatever init script you use
# to start motion specifies -c and the full path to it.
# Create a /usr/local/etc/motion/motion.conf configuration file based on the
# motion-dist.conf sample and also see the samples in
# /usr/local/etc/motion/examples
( cd /usr/local/etc/motion
test ! -f motion.conf && cp -a motion-dist.conf motion.conf )
# Create this dir for the pid file
mkdir /var/run/motion
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/motion-*.tar.* installed/motion.README
mv motion-4.0.1.tar.gz installed/
# If you ever want to uninstall Motion, this should do it:
cd
su
test -d src/motion-* && ( cd src/motion-* ; make uninstall )
rm -f /usr/lib/libmotion-1.* /usr/lib/pkgconfig/motion.pc
test -d /usr/include/motion-1.0 && rm -r /usr/include/motion-1.0
test -d /usr/share/gtk-doc/html/motion && rm -r /usr/share/gtk-doc/html/motion
find /usr/share/locale -type f -name motion10.mo -exec rm {} \;
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "motion-*" -exec rm -r {} \;
rm -f ~/installed/motion-*.tar.*