# If you have trouble getting it from nntb.no, you can also get it from
# the GitHub release page:
# https://github.com/dreibh/subnetcalc/releases/tag/subnetcalc-2.4.22
# Get the tarball
cd
test -f installed/subnetcalc-2.4.22.tar.xz &&
mv -f installed/subnetcalc-2.4.22.tar.xz .
test ! -f subnetcalc-2.4.22.tar.xz &&
wget https://www.nntb.no/~dreibh/subnetcalc/download/subnetcalc-2.4.22.tar.xz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "subnetcalc-*" -exec rm -r {} \;
tar xJvf ~/subnetcalc-2.4.22.tar.xz
cd subnetcalc-2.4.22
test $UID = 0 && chown -R root:root .
# Create the build directory
mkdir build
cd build
# Configure the build
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_INSTALL_MANDIR=/usr/local/man ..
# Build it
make
# Become root to install it
su
# Install it
make install
# Become your non-root user again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/subnetcalc-*.tar.*
mv subnetcalc-2.4.22.tar.xz installed/
# If you ever want to uninstall SubNetCalc, this should do it:
cd ~/src/subnetcalc-2.4.22/build
su
# See install_manifest.txt for a list of files to remove.
# There are only 2, but if there were many, you might do something
# like this:
# cat install_manifest.txt | xargs rm
exit
find ~/src -maxdepth 1 -type d -name "subnetcalc-*" -exec rm -r {} \;
rm -f ~/installed/subnetcalc-*.tar.*