Realize makefile

W

wanglei wang

Such as: make file.c file to generate the executable file, make
file2.c generate executable file file2.
make a different file name on the back of the input to generate a
different executable file
 
M

Mark Bluemel

Such as: make file.c file to generate the executable file, make
file2.c generate executable file file2.
make a different file name on the back of the input to generate a
different executable file

Smells like teen spirit^W^Wcoursework....
 
N

Nick Keighley

Such as: make file.c file to generate the executable file, make
file2.c generate executable file file2.
 make a different file name on the back of the input to generate a
different executable file

I *think* you're trying to ask how to wite a makefile. This is not on-
topic to comp.lang.c. A unix programming group (even if you are using
make on something else) might suit you better.

For a makefile as simple as the one, I think, you want I'd have
thought any basic introduction to make would be good enough.
 
J

James Kuyper

This isn't really about C.

I find that if you have file.c and say "make file", it works
fine *without* a Makefile.

Not if 'file.o' needs to be linked with several other object files to
make your executable.
 
J

Jorgen Grahn

Not if 'file.o' needs to be linked with several other object files to
make your executable.

And not if you want a decent set of warnings and standards compliance
flags passed to your compiler.

/Jorgen
 
J

James Kuyper

And not if you want a decent set of warnings and standards compliance
flags passed to your compiler.

A POSIX-conforming make provided with no make file is supposed to behave
as if it were using a make file which contained the following lines
(among many others):

LDFLAGS=
CC=c99
CFLAGS=-O
..c:
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<


The default values of CC, CFLAGS, and LDFLAGS can be overridden either
by setting the corresponding environment variables, or overriding them
explicitly from the command line. Therefore, you can customize the
behavior of make without having to create a make file. CFLAGS is the
appropriate place for the compiler flags you were talking about.

Real-world make utilities are not necessarily POSIX-conforming, or if
they are, they might not be conforming in their default mode. However,
any make that's sufficiently close to standard-conforming will tell you
what it's non-standard default rules are if you type:

make -p -f /dev/null

Even when using a non-conforming make, you're likely to find it behaving
as if it were using the above rules, if all you fiddle with are the
values of CC, CFLAGS, and LDFLAGS.

Any big project built with make has to use a make file; but if you know
what the default rules are, that make file can be pretty small, and for
small projects it can often be dispensed with entirely.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top