Solved

makefile

Posted on 2004-08-26
3
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

763 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