Linux Makefile

Suppose the following files are in the current directory, (hellomake.c, hellofunc.c and hellomake.h)

Inside the makefile :
CC=gcc
CFLAGS=-I.
DEPS = hellomake.h
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)

hellomake: hellomake.o hellofunc.o
gcc -o hellomake hellomake.o hellofunc.o -I.

What will be replaced in the line "$(CC) -c -o $@ $< $(CFLAGS)" ?

Thanks
AXISHKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gheistCommented:
Is it a exam question?
0
Zephyr ICTCloud ArchitectCommented:
What do you mean with "replaced"? As in files, or what the variables mean?

Like $(CC)= gcc for example?
0
Zephyr ICTCloud ArchitectCommented:

Is it a exam question?

Would think so wouldn't you :)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

gheistCommented:
Just that what is written reflects what gnu make already knows - make .o from .c file
0
AXISHKAuthor Commented:
No, this is just seen in an article about makefile..

$(CC) -c -o $@ $< $(CFLAGS)

will be translated as

gcc -c -o hellomake.o -I
gcc -c -o hellofunc.o -I

ie, gcc will find xxx.c and complie it to the corresponding object file, xxx.o ... correct ?
0
gheistCommented:
gmake knows that line without makefile
if you say
make x.o
it will run gcc x.c -o x.o
see http://c.learncodethehardway.org/book
0
AXISHKAuthor Commented:
Tks, but I want to clarify what does the line do in makefile,

$(CC) -c -o $@ $< $(CFLAGS)

Tks again.
0
gheistCommented:
Read first 3 pages of book I sent to you in a link... It answers your question.
0
AXISHKAuthor Commented:
Thanks, but i still can't sure whether my understanding is correct or not..

Will the command line
$(CC) -c -o $@ $< $(CFLAGS)

 be translated as

 gcc -c -o hellomake.o -I
 gcc -c -o hellofunc.o -I

and gcc will automatically look for the source code hellomake.c and hellofunc.c respectively ? Tks
0
gheistCommented:
make looks for the file and makes accurate parameters for gcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.