Solved

makefile

Posted on 2004-08-26
3
388 Views
Last Modified: 2010-04-15
This is a sample makefile. Pls explain

myprog: prog.o func.o
       cc prog.o func.o -o myprog
prog.o: prog.c head.h
       cc -c prog.c
func.o: func.c
       cc -c func.c
clean:
      rm *.o core  
print:
      lpr -Papm2337 *.c *.h
backup:
      cp *.c *.h Makefile backupdir
0
Comment
Question by:manojantony
3 Comments
 
LVL 11

Expert Comment

by:avizit
ID: 11909867
0
 
LVL 4

Accepted Solution

by:
pankajtiwary earned 30 total points
ID: 11910116
myprog: prog.o func.o
>> The target myprog(executable, your ultimate target) needs prog.o and func.o as input files.
      cc prog.o func.o -o myprog
>> And above is the command to make myprog from the prog.o an func.o input files.
prog.o: prog.c head.h
>> similarly to produce prog.o you need prog.c and head.h as input files
      cc -c prog.c
>> similarly the command to make prog.o from the input files is above
func.o: func.c
>> To produce func.o you just need func.c and nothing else
      cc -c func.c
>> Above is the command to produce func.o from func.c
clean:
     rm *.o core
>> When you say "ake clean" the above command will be executed which will remove the intermediate files i.e. object files
print:
     lpr -Papm2337 *.c *.h
>> When you say "make print", the above command will be executed and the *.c and *.h files will be sent to the printer device.
backup:
     cp *.c *.h Makefile backupdir
>> When you say make backup, it will execute the above command.

To understand, just remember a make file needs to know which are the targets to make and the rule how to make that target. Each of the section above shows this and nothing else.
0
 
LVL 1

Author Comment

by:manojantony
ID: 11910245
thanx buddy.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Statment to match two tables in c# 6 79
negation in C function 14 153
Need example 5 113
What is atomic operation? 6 59
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question