Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Realize makefile (http://www.velocityreviews.com/forums/t755101-realize-makefile.html)

wanglei wang 10-26-2011 12:59 AM

Realize makefile
 
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

Mark Bluemel 10-26-2011 08:11 AM

Re: Realize makefile
 
On 10/26/2011 01:59 AM, wanglei wang wrote:
> 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....

Nick Keighley 10-26-2011 09:14 AM

Re: Realize makefile
 
On Oct 26, 1:59*am, wanglei wang <arch...@gmail.com> wrote:

> 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.

James Kuyper 10-27-2011 10:18 AM

Re: Realize makefile
 
On 10/26/2011 03:11 PM, Gordon Burditt wrote:
>> 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

>
> 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.
--
James Kuyper

Jorgen Grahn 10-27-2011 08:35 PM

Re: Realize makefile
 
On Thu, 2011-10-27, James Kuyper wrote:
> On 10/26/2011 03:11 PM, Gordon Burditt wrote:
>>> 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

>>
>> 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.


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

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

James Kuyper 10-27-2011 09:32 PM

Re: Realize makefile
 
On 10/27/2011 04:35 PM, Jorgen Grahn wrote:
> On Thu, 2011-10-27, James Kuyper wrote:
>> On 10/26/2011 03:11 PM, Gordon Burditt wrote:

....
>>> 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.

>
> 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.


All times are GMT. The time now is 06:30 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.