LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 11-02-2003, 02:45 PM   #1
linorg
Member
 
Registered: Nov 2003
Location: delhi
Distribution: redhat 8.0 ,fedora
Posts: 32

Rep: Reputation: 15
what is a make file


hi
can sombody plz tell what a make file is and how is it created


thanxs
linorg
 
Old 11-02-2003, 02:53 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
A makefile is a file that contains instructions
for tools to do repetitive tasks on files, when
involved repeatedly it will only touch files
that have a newer date than their related
resulting file. I.e. gcc test.c -o test in a makefile
will only execute gcc if you modified the
source after you last compiled it.

You create them using your favourite editor.


Cheers,
Tink
 
Old 11-02-2003, 03:02 PM   #3
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Rep: Reputation: 47
it is used to compile a program from source, it is made by the developers for everyones benefit.
 
Old 11-02-2003, 03:09 PM   #4
linorg
Member
 
Registered: Nov 2003
Location: delhi
Distribution: redhat 8.0 ,fedora
Posts: 32

Original Poster
Rep: Reputation: 15
so is it somewhat similar to batch file in dos
how do i execute a makefile
what extension does it have
 
Old 11-02-2003, 03:13 PM   #5
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Rep: Reputation: 47
rofl, the equivilent of a batch from dos is a shell script, makefile is differnet, but at basic level I cannot say you are wrong...

you do not execute a makefile, it is called from another executable.

first off see if there is a file called "configure" in the directory with the makefile, if so type:
./configure

when that is finished or if there is not one type this:
make
that will call the makefile and compile the software.
then to install type:
make install
that calls the makefile section for installing the program.
 
Old 11-02-2003, 03:15 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
And no, it's not like a batch. It's way
smarter :} and serves a completely
different purpose. It's primarily targeted
at programmers, to cut down on compile
times by only recompiling things that
have been modified.

You call it Makefile (no extension)
and you invoke it by typing make<ENTER>

Cheers,
Tink
 
Old 11-03-2003, 04:50 PM   #7
linorg
Member
 
Registered: Nov 2003
Location: delhi
Distribution: redhat 8.0 ,fedora
Posts: 32

Original Poster
Rep: Reputation: 15
does this means a single directory can have only one makefile..
to create a makefile i should just put the commands to be executed in a file called makefile
and just call make from the promt in the same directory...

consider the following makefile for compiling the kernel module i'm learnimg to write
(taken from a tutorial frm tldp.org)

Makefile for a basic kernel module

TARGET := hello-1
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc-3.0

${TARGET}.o: ${TARGET}.c

.PHONY: clean

clean:
rm -rf {TARGET}.o

are all the labels used here (target,clean ...) preefined.
 
Old 11-03-2003, 10:40 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by linorg
does this means a single directory can have only one makefile..
No, just the invocation gets more complex :)

if you called your makefile
my_makefile.txt
you'd invoke it with
make -f my_makefile.txt

Quote:
from man make
Code:
       make  executes  commands  in the makefile to update one or
       more target names, where name is typically a program.   If
       no  -f option is present, make will look for the makefiles
       GNUmakefile, makefile, and Makefile, in that order.

Cheers,
Tink
 
  


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
how to make nonblocking FILE *fp? Thinking Programming 1 09-14-2005 06:07 AM
when creating a *.iso file, how to make the file size smaller? minm Linux - Newbie 8 12-26-2004 10:58 PM
Make file help rajesh_b Programming 1 11-25-2004 05:39 AM
I accidentally deleted make file in /usr/local/bin, now cannot use make command.... Niceman2005 Linux - Software 2 11-17-2004 08:55 PM
why can't i do 'make' on this file!? ambelos Linux - Software 6 02-04-2004 11:19 PM


All times are GMT -5. The time now is 08:28 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