There's no place like $HOME

I highly suggest you to install programs to your home folder, here i explain
you how to do that. Also there is an example at the end.
I explained the reasons why i'm saying this.
  1. Download
  2. Extract
  3. Build
  4. Install
  5. Post Install

Download

The download manager of the browser is boring and terrifying? Yes, Of course you should use curl because it's a command and can be used in the terminal. It support almost all of the internet protocols like http and ftp.

Download the file using:
$ curl -L -O https://site.com/somefile
Explanation:
-L :redo the request if it has moved to another location.
-O :write the data to a file with the same name as remote file.
-o filename :write the data to 'filename'.

Continue the downloading:
It happens many times that transferring date breaks due to reasons but the
good news is that you don't have to start it from the beginning:
curl -C - -L -O https://site.com/somefile
But sometimes that file is big and your internet speed is in oogway mode, but dont worry(almost) we have a program called axel and it speed up the process by making multiple connections. axel https://site.com/somefile By default it write data to a file with the same name as remote one. but you change it with -o filename

Extract

If that's a tarball(*.tar.*) you can see the contents before extracting:
$ tar tf file.tar.gz
Extract with:
$ tar xf file.tar.gz
Explanation: That 'x' is for extract and 'f' is for file(tar reads input from stdin
by default and this for a good reason).
If that's a bzip2 file, it can be decompressed with this command: $ bzip2 -d file.bz2

Build

In this step we should check what building system the project used.
Some projects use multiple systems, if it has a file named
makefile you can simply jump to the make step but knowing
about other ones is a good idea because they are so popular.

Cmake

There should be a file named CMakeLists.txt if it's true follow this steps:

  1. Create build folder
  2. Config the CMake
  3. Generate Makefile
  4. Make
Create build folder
You dont want to get the result in the current(source) directory because it makes
it hard to seperate source and output. so first create one, name it whatever you like, people
usually choose the name build for that.
$ mkdir build $ cd build
Config the CMake
The big project have big options to choose, at first run ccmake program:
$ ccmake ..
It's a curses interface to the 'cmake' program.
If you dont see any option don't panic you should at first configure(press 'c') to see them.
You can go to the examples and check some mostly used options
and their meanings, but for specific ones, checkout the project manual.
Generate Makefile
The jop of the cmake and meson is to generate a Makefile(or some another ones that i explain later)
so now just generate(press 'g') to get that. If you haven't the proper dependencies
it will complains about them, but don't worry just install them and repeat this step.
Make

Go to the make step.

Meson

If you see a file with name meson.build follow this steps.
Just like cmake create a build directory and go to that.

Setup

First you should setup the project with default options we will change them later.

$ meson . ..
Config
Now we can change that options and setup the project again.
$ meson configure
It will show you a list options with default values, just press 'q' to quit.
You can checkout examples to get an idea of some of this options.
$ meson configure -Doption1=value1 -Doption2=value2
Ninja
At the end you should get a output file with name 'build.ninja' and we are done.
Refer to the ninja step for more information but it's simply
is something like 'make'.

Make

It's the program that execute the process of compiling, just run:
$ make -j
Exaplanation: That '-j' means to use all of the cpu cores, it will speed up the process that much that it make 2h compile time just some minutes.

Ninja

Like 'make' but it's faster. Use the same option as 'make' to use multiple cores.

Install

First choose a location on your home directory, i suggest you the '.local' folder, becaise
used by other programs and maybe already exist on your home.
All of the above build systems has some variable named 'PREFIX' and as the name says it the
prefix of installation path, It means for example binary files
will install on '$PREFIX/bin' and if the project is a library that be '$PREFIX/lib'.
$ make(ninja) install
If you set 'PREFIX' to something like '$HOME/.local' you don't need to be root to run it.

Post Install

Now you install the program and the only thing remains is to tell the system that we have this stuff in our home(It's not a good explain for that, i know).
There is some shell variables to set.

PATH

If the project output is binary files or something executable, you don't want to always
go to the full path(like: $HOME/.local/bin/prog) and run it, instead like other programs
that you run without this problem, here i explained it.
You run 'curl' on the shell but how shell found it? because it installed in the '/usr/bin/' and this path is in the 'PATH' variable, you can check the content of any bash(also zsh) variable with a '$' before the name: $ echo $PATH
So as you can guess we should add our path to 'PATH' so we can use that installed executables like other programs. $ export PATH=$HOME/.local/bin:$PATH Explanation: The 'HOME' is a variable that refers to the home of the current user, for example the content of that for user 'noob' would be '/home/noob'. You can put the full path instead of this variable, it doesn't matter.
We use 'PATH' itself and put it after a ':', it means we prepended our path to the content of 'PATH'. that's because you don't want to override that, so you have other paths as well.
Fish Shell
$ fish_add_path $HOME/.local/bin

LD_LIBRARY_PATH

But what if the output is a library or libraries?
This is variable same as 'PATH' but for libraries. The difference is that you should specify
other paths as well unlike 'PATH' that we simply prepend our one to that.
$ export LD_LIBRARY_PATH=$HOME/.local/lib:/usr/lib
Fish Shell
$ set -Ux LD_LIBRARY_PATH $HOME/.local/lib:/usr/lib

MANPATH

The important part of a project is the manual. When you type 'man curl' the man program
check this variable and in directories named man[1:9] searches through files with names
myprog.1[.gz], mylib.1(they are manpages) and show you that manpage(curl.1).
$ export MANPATH=$HOME/.local/share/man:
Explanation: Of course all programs don't have the same system, as you can see
this is a difference from how we set other variables. But we just do the same thing
as for 'PATH' but without puting that at the end, It's just the 'man' program decision.
Fish Shell
$ set -Ux MANPATH $HOME/.local/share/man:

PKG_CONFIG_PATH

There is a program called pkg-config and it find the version, and other information about a library. It mainly used by build systems, so libraries themselves have some files for this program(.pc files).
$ export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig

Fish Shell
set -Ux PKG_CONFIG_PATH $HOME/.local/lib/pkgconfig

Automation

You don't want to export all this variables everytime, you can just put them
in the '.bashrc'(for bash) or in '.zshrc'(for zsh) and reload the shell.
I recommend you to not use fish shell, because it has a completely different syntax.
Note: For Fish you don't need to add them to any file manually, with those commands that
i said fish itself will put them in it's config file.

Example

For an example there is the installation steps for the abseil library.

  1. Download
  2. Use curl to get the source code from the github page (go to the Releases and choose file with date in it's name).

  3. Extract
  4. With tar you can first check the content then extract it.

  5. Build
  6. This project uses cmake so follow the instructions but just change this variables:

    BUILD_TESTING = OFF
    CMAKE_BUILD_TYPE = Release
    CMAKE_INSTALL_PREFIX = /home/username/.local
    
  7. Install
  8. When you get the Makefile just compile and install.

  9. Post Install
  10. Follow this article so you installed the library successfully.
    You can check it with:
    $ pkg-config --modversion absl_die_if_null
    You should get a version number as same as the source you have downloaded but if not,
    just reread the 'post install' part.
    

Reasons

Why you should choose to build some programs manually ?
The First is that packages are build by someone and his/her decisions, in some cases
you don't want that options. The package builds up with some extra features that
cost you extra space, for example in LaTeX package(in arch and debian).
The second one is some features that you want but it hasn't been included.
The last one is that package managers install programs on paths that need the root access.
For me(maybe you) there is also another one and that is for learning purposes, i want
to have control over my system and know what i am doing.