Realize makefile

Discussion in 'C Programming' started by wanglei wang, Oct 26, 2011.

  1. wanglei wang

    wanglei wang Guest

    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
     
    wanglei wang, Oct 26, 2011
    #1
    1. Advertising

  2. wanglei wang

    Mark Bluemel Guest

    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....
     
    Mark Bluemel, Oct 26, 2011
    #2
    1. Advertising

  3. On Oct 26, 1: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


    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.
     
    Nick Keighley, Oct 26, 2011
    #3
  4. wanglei wang

    James Kuyper Guest

    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
     
    James Kuyper, Oct 27, 2011
    #4
  5. wanglei wang

    Jorgen Grahn Guest

    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 .
     
    Jorgen Grahn, Oct 27, 2011
    #5
  6. wanglei wang

    James Kuyper Guest

    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.
     
    James Kuyper, Oct 27, 2011
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lei Guangfu
    Replies:
    1
    Views:
    313
    Natty Gur
    Oct 19, 2003
  2. Ryan Ternier
    Replies:
    1
    Views:
    550
    John Saunders
    Jul 25, 2004
  3. Íõ•
    Replies:
    0
    Views:
    531
    Íõ•
    Aug 23, 2004
  4. Shugong Wang
    Replies:
    2
    Views:
    9,624
    Raymond Martineau
    Nov 28, 2004
  5. Davide  M3xican  Coppola

    how to realize a friend interface?

    Davide M3xican Coppola, Apr 21, 2005, in forum: C++
    Replies:
    3
    Views:
    426
    Davide M3xican Coppola
    Apr 26, 2005
Loading...

Share This Page