Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

makefile

Posted on 2004-08-26
3
Medium Priority
?
411 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 4

Accepted Solution

by:
pankajtiwary earned 90 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

722 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