# If you ever want to remove cmocka, skip down to the bottom for info
# Get the source tarball
cd
test -f installed/cmocka-1.1.7.tar.xz &&
mv -f installed/cmocka-1.1.7.tar.xz .
test ! -f cmocka-1.1.7.tar.xz &&
wget https://cmocka.org/files/1.1/cmocka-1.1.7.tar.xz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "cmocka-*" -exec rm -r {} \;
tar xJvf ~/cmocka-1.1.7.tar.xz
cd cmocka-1.1.7
test $UID = 0 && chown -R root:root .
# Read ./README.md, ./INSTALL.md
# If upgrading read ./ChangeLog
# Create a build directory
mkdir build
cd build
# Configure the build
# The default prefix is /usr/local
# It will figure out lib|lib64
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug \
-DUNIT_TESTING=ON ..
# Build it
make
# Test it (if you added -DUNIT_TESTING=ON)
make test
# Become root to install it
su
# Install it
make install
ldconfig
# Become your non-root user again
exit
# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/cmocka-*.tar.*
mv cmocka-1.1.7.tar.xz installed/
# If you ever want to uninstall cmocka, this should do it:
# (look for install_manifest.txt in your source build directory
# for a list of files that were installed)
su
( cd /usr/include ; rm -f cmocka.h cmocka_pbc.h )
( cd /usr/lib
test -d ./cmake/cmocka && rm -r ./cmake/cmocka
rm -f pkgconfig/cmocka.pc libcmocka.* )
test -d /usr/lib64 &&
( cd /usr/lib64
test -d ./cmake/cmocka && rm -r ./cmake/cmocka
rm -f pkgconfig/cmocka.pc libcmocka.* )
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "cmocka-*" -exec rm -r {} \;
rm -f ~/installed/cmocka-*.tar.*