Solved

makefile

Posted on 2004-08-26
3
368 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
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.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now