LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-02-2006, 07:55 PM   #1
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 958

Rep: Reputation: 35
compiling and makefiles


i have seen afew peices of software where you need to compile the soucecode yorself with several compile time options specified in a makefile,
then use the MAKE command to do the actuaila compile

all the documentation i have been able to find allready assumes you know how to do this!

the man pages on MAKE seem little use as tehy assume you know the ins and outs of compiling anyway (so dont need to read teh man pages in teh first place ?!?!)

im fairly new to linux but seem to be doing fine with all binary installs just compiling my own stuff i seem to have a problem with

i am running SuSE 10.1 with KDE

if anyone can suggets a web site designed for people who have only the barest cule about compiling software i would be greatfull
 
Old 06-02-2006, 08:31 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
As often as not, you simply do:

untar the source code to a directory of your choosing

cd to said directory

run ./configure (sometimes you will need to specify some option(s) )

run make

run (as root) make install

You're done. You can optionally, then do

make clean

The first step, 'configure', examines your system to find optimal flags to supply the compiler. You probably don't need to do any heavy lifting at all.

Usually, yopu will find this spelled out in more detail in a file named INSTALL, or README, or some such name.

Hope this helps.

--- rod.
 
Old 06-02-2006, 08:44 PM   #3
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
Compiling from source is a good way to do things. There are plenty of tutorials on the web and here within linuxquestions, as it is a common problem.

You seem to already have the basic jist of things, and that is to do ./configure, make, and make install. The extra info that may be passed to configure can make or break the whole deal. Here is what I usually do when compiling something new.

I start with ./configure --help. That will usually give you a list of all the options that configure will take. 9 times out of 10 you don't need to do anything besides ./configure. As you watch the output of configure, if there are problems it will tell you, say for example it can't find a certain library file. At that point you may need to pass info into configure, like the location of the library it couldn't locate on its own. You'll also hit errors if it is looking for something you don't have, in which case you need to install it yourself.

Once configure gets done successfully, make follows. Usually if configure is cool, make is cool, and then make install as root does the rest. I usually use /usr/local ans the location to unzip the gzip or bz2 file. To do that you usually need to be root as well, so the entire ./configure make make install all gets done as root. Other folks prefer to do all their source installations in their home directory, that way they don't need to be root except for the make install step.

For the most part, the more you do the source compilations, the better you get at it, and the better you are at getting around the problems that come up.

The main downside to doing source compilations is it isn't nearly as easy as installing from the .deb or .rpm, or using aptitude, yum, emerge, or whatever. Once it is more comfortable, you have the issue that you don't get software updated automatically when a new version comes out. If your package manager installs firefox 1.5.0.3, and 1.5.1.0 comes out, your manager will update you. If you are running firefox 1.5.0.3 that you compiled yourself, you will never be upgraded automatically, it will take you downloading the source for the update, and again going through the compilation and installing. Not a huge problem, it just isn't as easy. The nice thing is once you get some version of a program installed, you probably have all the requirements, so upgrading will be just a configure, make, make install.

Use the source!

peace,
JimBass
 
Old 06-03-2006, 12:12 PM   #4
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 958

Original Poster
Rep: Reputation: 35
hmm thats seems logical, but where does the makefile come in?

i am looking to compile netcat from source so that i can use the Gaping_sucuraty_hole
option, this needs specifing in a makefile as a
Dflags line

how do i do this?
 
Old 06-03-2006, 01:50 PM   #5
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
The makefile is included in the package or generated in the the configure step. It will appear most often in the directory where the tar.gz or tar.bz2 file was unzipped. At that point you could just edit the Makefile and include the line you read about.

Peace,
JimBass
 
Old 06-03-2006, 10:42 PM   #6
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 75
The origin of Makefiles has already been explained. As for netcat, all you have to do is put something like
Code:
DFLAGS = -DGAPING_SECURITY_HOLE
in the beginning part of the Makefile. Netcat was written before `autoconf' and friends became popular (autoconf is what uses configure scripts to make sure the code compiles well on different setups).

In case you are a little curious about how such an expression magically causes the program to include the -e option, it is quite simple. In general, a Makefile provides
  1. Instructions to the computer on how to compile the code.
  2. A way to see what internal dependencies are (i.e., what files have to be recompiled when a simple change is made to one of the source files).

The -D option (to the c compiler) defines whatever comes after it when compiling code. The netcat.c has a check that happens at the preprocessor level to know what code to leave out.
 
Old 06-09-2006, 04:42 PM   #7
jenlowe0010
LQ Newbie
 
Registered: Jun 2006
Posts: 15

Rep: Reputation: 0
how would you explain this to someone who doesn't have a clue about makefiles? I'm trying to install a program from a .tar.gz file and have very little experience of linux. thanks
 
Old 06-09-2006, 09:26 PM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If you just want the necessary mod's made to the Makefile, just post the first 25 or so lines of it here. Someone can add the extra line, and you can copy it back into your version. If you want a full description of how make works, that might be a little beyond the scope of this forum.

--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Makefiles deveshs Linux - Software 2 05-02-2005 06:26 AM
Those makefiles... boku Programming 10 03-01-2005 09:19 AM
Makefiles and Me dpottinger Linux - Newbie 5 07-25-2004 12:14 AM
MAKEFILEs shinpadsmt Linux - Newbie 3 02-21-2004 03:52 AM
Why makefiles parthi4u Programming 4 03-08-2003 04:14 PM


All times are GMT -5. The time now is 08:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration