Linux, makefiles, compiling your own source
Hi guys,
Does anyone know of a good tutorial/overview of how packages and gnu makefiles work? I'm especially interested in what happens when you've run "make" it seems to compile the package and exits... What is meant to happen after that exactly?
Currently I'm getting-by with Googling for rpm packages whenever trying to install anything with dependancies.
The learning curve is steep, but very addictive!
a Padded Cell our articles site!
Abhishek Reddy posted this at 00:07 — 1st March 2005.
He has: 3,348 posts
Joined: Jul 2001
Can't think of any tutorials at this point. I'm at uni now so I can't refer to the bookmarks anyway.
I'm just getting into Makefiles as I progress through C/C++ programming. As I understand it, what a Makefile does is contain a set of commands (flags and options included) to link and build the source files.
A single source file may be compiled with a command like so:
g++ infile.cc -o outfile.bin
'In a slightly more sophisticated program, you may have tens, hundreds, of these files, often requiring complex header inclusion, library linking and whatnot. A Makefile, used with make (automake), allows you to set these parameters and automate the task of building, which may have taken many steps manually. If you keep your eyes on the output as a program is makeing, you'll be able to pick out individual commands such as gcc or g++.
What you usually do next is `make install`, as the root user. It runs a lot of shell commands to place all the built files in the right paths so they can be used in the system.
Packages, as you might have noticed, aren't of a standard format. Some are pure source designed for automake, others may use unique methods, and distro-specific packages are used by that distro's package manager -- yum rpms, portage ebuilds, apt debs, slack tgzs, and so on. Many package managers are automated to handle the packages on their own; Gentoo's portage uses `emerge` to very simply download an ebuild and its dependencies and run the configure and make. Fedora's `yum` downloads an rpm and maybe its dependencies and moves the binary files to the right paths. Each works differently, but they are normally a lot easier than searching for individual packages and dependencies on your own.
I hope this made sense.
Abhishek Reddy posted this at 09:40 — 3rd March 2005.
He has: 3,348 posts
Joined: Jul 2001
This explains it all better than I can ever hope to:
http://www.gnu.org/software/make/manual/html_mono/make.html#SEC1
JeevesBond posted this at 15:20 — 7th March 2005.
He has: 3,956 posts
Joined: Jun 2002
Perfect, thanks Abhi! But hang on... "Downloads the package and it's dependancies" how rude, it's getting rpm's of dependent packages to work that's causing me the biggest problems! I presume you can mix distro's methodolgy, i.e. I could use 'emerge'?
I got BlueFish working though (hurrah) - rather good, thanks for the tip!
a Padded Cell our articles site!
Abhishek Reddy posted this at 19:53 — 7th March 2005.
He has: 3,348 posts
Joined: Jul 2001
Oh yes. I've noticed a lot of people like using apt/Synaptic (Debian's) on distros like Slackware. I don't know how popular portage is outside of Gentoo but I don't see why youldn't be able to use it. The inital installation procedure could be unusual, and you may have to do some tweaking with portage's configuration to suit your system. Have a look here: http://forums.gentoo.org/viewtopic.php?t=125553
Fyi, the easiest way to get portage is to simply use Gentoo.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.