Hey guys and welcome back.
So now what I want to do is to walk you through the actual process of downloading a particular
package with our source code and being able to actually build from that source code so
that we have a fully functioning and working program as opposed to being able to just rely
on our nice package manager such as apt to do such a thing.
So let's get an example of what we are talking about then.
So like I say, the very first thing that we're going to have to do is to obtain that particular
source code.
This can be a source code for any particular application that you so choose.
In this case here, I'm just going to download the source code for a very simple game called
Ang Band.
So the reality is we've got to go and get this source code to what I will do is I will
just close this just now and I'll go to my browser.
Okay, open up Firefox.
Let me just close this and I will go to Google.
Okay.
Okay, so all I've done is search for the name Ang Band and source code.
So what I'm going to do is you can go to get up if you want.
In this case here, I will just go to the website.
So we click on the website here.
We can see indeed we have this link to download the source code.
You see that version four to four.
If I just click on this, we can see here, this is now going to download this particular
file.
Notice the extension.
We've got dot tar dot GZ.
That could also be dot TGZ as we already know.
So what I will do is this will now be in my downloads.
If I go back to my terminal right here, if I do an LS, let's CD into the downloads directory.
We're doing LS.
Now we have this tar file which has been compressed.
Now we know it is a dot GZ extension.
This means that we can ultimately extract this using Gunzip if we so wish.
So what I can say is Gunzip and then the name of the file.
If I enter and I do an LS, I now have this tar file and I can say tar and extract.
Angband and I can say dash fail and then Angband and if I enter, if I do an LS now, we can
see here we actually have this new directory structure.
This is what I was talking about.
So if I go into this particular directory and I do an LS, we can see all of these different
files and directories.
Now it is a good idea, very good practice to look at this particular file here.
This is a mark down file as denoted by the dot MD extension and it's called the readme.
This is something you're going to see very, very often when you're dealing with software.
You'll see this all the time on places like GitHub, for example.
And it's where a particular developer can signal to you instructions about this particular
program.
So it's a good idea that we actually do read the readme mark down file.
So let's go into this and we can see here it tells us the information about the game
itself.
It's just a little graphical dungeon adventure game and it tells us how to install it.
We can go to here to get the information or we can compile it ourselves by clicking this
link to get the instructions.
We can also see how to play the game and how to get help.
You might actually get much more information and a readme.
This is a very simple and minimal readme.
So don't just think it's always going to look like this.
You can get far more information, including crucial dependencies and whatnot.
So let's exit out of this for now.
You will notice though that we have this configure script and we can tell, of course, it is an
executable because of the coloration, but a better way to check is if we do an LS-L,
we can see here the actual permissions tells us it is executable.
So this is this configure file I was talking about.
Now, one thing before we even get started, before we can actually do things like compilation,
we actually need a compiler ourselves.
The compiler is going to be the program that is going to transform the human readable source
code into machine readable binary.
So we absolutely need to do this first.
Now we can have different types of compilers.
Say for example, we have one called LLVM.
A very popular one is called the GNU-C compiler, otherwise known as GCC.
Now in order to be able to get these compilers along with other essential commands, you can
do so via your particular package manager.
So if you happen to be on Red Hat, you could use DNF or YUM.
In the case of me, I'm using a Debian-based system.
So I will use the apt package manager.
So I will say sudo apt install and I will say build hyphen essential and then ceiling or
clang.
If I hit enter here and I'll type in my password for my super user privileges hit enter.
I will then say yes and hit enter.
And this is going to allow me to install the package so that I have access to my compiler.
So when I go through the process of compilation, I can actually transform that human readable
source code into the machine readable binary.
Okay, so that is now successfully installed.
What I want to do is I want to actually use this configure script.
Now you may recall the way we can actually execute a particular file is by saying dot slash
and then the name of the file.
So we can say dot slash configure.
And remember, if we want to happen to change the particular location, we can use this
prefix option and then specify a particular location.
In my case right now, I will just leave it as it is.
So if I hit enter, okay, that has ran through some basic checks.
If we scroll on up, we can see all the different types of checks it is doing.
Say for example, if the C compiler is working, yes, checking for particular command such
as the remove command, the move command, the copy command.
If we keep on scrolling, we see all of these checks going through.
We can see here where the install path is.
Remember that location we talked about.
Use our local very common one indeed.
We'll actually see where our documentation will be stored as well as some information
relating to our front ends.
We can see here X11.
No, we do not have the ability for X11.
We have missing libraries and we can also see other configurations such as SDL2 that indeed
is disabled.
So you may actually need to resolve a particular dependency if you want to have particular
features enabled.
Say for example, this dependency right here, SDL2, this relates to sound and this is what
Angband actually needs to play sound.
So what we actually need to do here is to get a particular library.
Now the library that SDL2 needs is one called libSDL2.
So in order to be able to use SDL2, what I'm going to do is say sudo apt install and on
Debian based systems, the library is lib SDL2-dev and if I hit enter, this is now going to install
this and I hit yes, run through the installation and just give it a minute or two to complete.
So now what we can actually do is we can run the configure command once again, but we will
now attempt to enable SDL2 now that we have resolved this missing dependency.
So we'll try again, we will say configure.
In fact, let me just clear the screen to make it a little bit cleaner.
I'll say configure and just like the way we could pass in the prefix option, I will pass
in the option to enable SDL2 and it would help if I could spell SDL2.
There we go.
So if I hit enter, we run through the same checks once again.
Okay, if we do an LS, let's just clear the screen.
Now what we're going to do is we're going to make use of this make file.
We go in and have a quick look at it.
We can see what we have right here.
Again we just see all this type of programming logic that we don't have to worry about too
much.
Just understand that the make command is going to actually be able to read these instructions
and build as necessary.
So we'll close this just now.
And if I just issued the make commands, this will begin to perform all the actions needed
to compile the program.
If I hit enter, we're getting to the source directory.
It's going to begin compiling.
We can see here all the compilation steps and this may take a few minutes depending on
your system.
And as we can see here, there's a lot of compilation going on.
So just be patient and there we go right there.
Now if I happen to say which Aang band, we're not actually going to see any information.
We want to have this command available as a system wide executable.
So this is what we're going to do with the make install command.
And like I say, because we're going to be copying files to very particular directories, these
directories are protected by root access.
So we're going to have to use the sudo command.
So we'll say sudo make install.
And if I hit enter, this is going to go through the same process of getting into particular
directories and it will do some copying to particular locations.
And now once this is done, if I say which Aang band, we can actually see here this command
is now available and again within the user local directory.
So if I clear this and I just say Aang band and hit enter, look at this, our little game
has now actually appeared on our system.
And how do we actually get this game on our system?
We just downloaded the source code as a tar file, which was compressed.
We decompressed it.
We then downloaded a particular compiler so that we could run the configure command to
ensure the checks that the project could indeed be built and create the make file.
We then used the make command to read the instructions within that make file to build
the program.
And then we use the make install command with super user privileges to make this a system
wide command that we can actually use from anywhere within the system.
If I just close this for now and if I go to a completely different directory, let's
maybe say go into the root directory and then I don't know, let's maybe go into it
say somewhere completely random.
I can still say Aang band to enter and load that game because like I say, we have used
the make install command to make it system wide and accessible.
So hopefully now seeing this process in action, the actual process of compilation from source
code is a little bit clearer.
Like I say, it does take a little bit of practice to get the process clear in your mind.
But once you do see how it's done, then you really just repeat the same type of processes
independent of the source code you're trying to compile.
Okay, so that is us for the configuration of installing from source code.
I hope this has been informative for you.
I'd like to thank you for viewing.