Tools to make makefiles?

Discussion in 'C Programming' started by milkyway, Nov 17, 2005.

  1. milkyway

    milkyway Guest

    Hello,

    I am running under Suse Linux and am putting together some code written
    in C. I am not clear on how to create makefiles and was wondering if
    there were any "makefile tools" out there. If so, what are the best
    ones?

    TIA
    milkyway, Nov 17, 2005
    #1
    1. Advertising

  2. milkyway

    vietor Guest

    use 'autoconf' & write it's script
    vietor, Nov 17, 2005
    #2
    1. Advertising

  3. [Followups set to comp.lang.c]

    milkyway said:

    > Hello,
    >
    > I am running under Suse Linux and am putting together some code written
    > in C. I am not clear on how to create makefiles and was wondering if
    > there were any "makefile tools" out there. If so, what are the best
    > ones?


    If you don't want to get into autoconf etc, it's trivial to generate your
    own simple makefiles by writing a program in elementary ISO C. Here's a
    really, really simple one which you can hack to your heart's content.

    #include <stdio.h>

    void genflags(void)
    {
    puts("CC=gcc");
    puts("CFLAGS=-W -Wall -ansi -pedantic -O2");
    puts("DFLAGS=-g -pg");
    }

    void makeprg(int argc, char **argv)
    {
    int i = 0;
    printf("%s: %s.o", argv[1], argv[1]);
    for(i = 2; i < argc; i++)
    {
    printf(" %s.o", argv);
    }
    printf("\n\t$(CC) $(CFLAGS) $(DFLAGS) -o %s %s.o", argv[1], argv[1]);
    for(i = 2; i < argc; i++)
    {
    printf(" %s.o", argv);
    }
    putchar('\n');
    }

    void makeobjs(int argc, char **argv)
    {
    int i = 0;
    for(i = 1; i < argc; i++)
    {
    printf("%s.o: %s.c\n", argv, argv);
    printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv,
    argv);
    }
    putchar('\n');
    }

    void makeclean(int argc, char **argv)
    {
    int i = 0;
    printf("clean:\n");
    for(i = 1; i < argc; i++)
    {
    printf("\trm %s.o\n", argv);
    }
    printf("\trm %s\n", argv[1]);
    putchar('\n');
    }
    void makeinstall(int argc, char **argv)
    {
    printf("install:\n");
    printf("\tcp %s /usr/local/bin\n", argv[1]);
    putchar('\n');
    }

    int main(int argc, char **argv)
    {
    if(argc > 1)
    {
    genflags();
    makeprg(argc, argv);
    makeobjs(argc, argv);
    makeclean(argc, argv);
    makeinstall(argc, argv);
    }
    else
    {
    fputs("Usage: makegen progname [sourcename*]\n", stderr);
    }
    return 0;
    }

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
    Richard Heathfield, Nov 17, 2005
    #3
  4. milkyway

    Guest

    milkyway <> did eloquently scribble:
    > Hello,
    >
    > I am running under Suse Linux and am putting together some code written
    > in C. I am not clear on how to create makefiles and was wondering if
    > there were any "makefile tools" out there. If so, what are the best
    > ones?


    autoconf, automake
    :)
    should help a bit at least.
    --
    ______________________________________________________________________________
    | | |
    |Andrew Halliwell BSc(hons)| "The day Microsoft makes something that doesn't |
    | in | suck is probably the day they start making |
    | Computer science | vacuum cleaners" - Ernst Jan Plugge |
    ------------------------------------------------------------------------------
    , Nov 17, 2005
    #4
  5. milkyway

    Arne Schmitz Guest

    wrote:

    > milkyway <> did eloquently scribble:
    >> Hello,
    >>
    >> I am running under Suse Linux and am putting together some code written
    >> in C. I am not clear on how to create makefiles and was wondering if
    >> there were any "makefile tools" out there. If so, what are the best
    >> ones?

    >
    > autoconf, automake


    Thats quite a big step. Also scons is very nice, and IMHO much easier for
    small projects. Alternatively, just use a text editor to write your make
    file. With implicit rules, you do not even have to list all your source
    files.

    Arne

    --
    [--- PGP key FD05BED7 --- http://www.root42.de/ ---]
    Arne Schmitz, Nov 17, 2005
    #5
  6. milkyway

    Alex Fraser Guest

    "Arne Schmitz" <> wrote in message
    news:...
    > wrote:
    > > milkyway <> did eloquently scribble:
    > >> I am running under Suse Linux and am putting together some code
    > >> written in C. I am not clear on how to create makefiles and was
    > >> wondering if there were any "makefile tools" out there. If so, what
    > >> are the best ones?

    > >
    > > autoconf, automake

    >
    > Thats quite a big step.


    Definitely.

    > Also scons is very nice, and IMHO much easier for small projects.


    Looks interesting. Being written in Python is unfortunate in some respects.

    > Alternatively, just use a text editor to write your make file. With
    > implicit rules, you do not even have to list all your source files.


    Yes, you only need to list source files which #include any non-system header
    files, which is normally all of them if there is more than one source file.

    I suspect at least a basic understanding of how you would write a makefile
    for a given project would be very useful for most, if not all, "makefile
    tools".

    Alex
    Alex Fraser, Nov 17, 2005
    #6
  7. On 2005-11-17, milkyway <> wrote:

    > I am running under Suse Linux and am putting together some code written
    > in C. I am not clear on how to create makefiles


    You don't create a makefile. You copy one and modify it.

    Somebody once asked who created the first makefile, but there
    was no first makefile -- it's just turtles all the way down...

    --
    Grant Edwards grante Yow! Look DEEP into the
    at OPENINGS!! Do you see any
    visi.com ELVES or EDSELS... or a
    HIGHBALL??...
    Grant Edwards, Nov 17, 2005
    #7
  8. milkyway

    Dan Espen Guest

    "milkyway" <> writes:

    > Hello,
    >
    > I am running under Suse Linux and am putting together some code written
    > in C. I am not clear on how to create makefiles and was wondering if
    > there were any "makefile tools" out there. If so, what are the best
    > ones?


    Hmm, looks like some of the answers you've gotten are meant to
    be humorous.

    autoconf and friends are more complex than make.

    I think you question is equivalent to asking for a tool to
    write .bat files. Make is pretty simple,
    using a tool to write make files is overkill unless you are
    dealing with a really large project.

    Spend a few minutes over at gnu.org reading the make documentation
    or ask specific questions.
    Dan Espen, Nov 17, 2005
    #8
  9. In article <dlhjrr$5jd$-infra.bt.com>,
    Richard Heathfield <> wrote:
    >[Followups set to comp.lang.c]
    >
    >milkyway said:
    >
    >> Hello,
    >>
    >> I am running under Suse Linux and am putting together some code written
    >> in C. I am not clear on how to create makefiles and was wondering if
    >> there were any "makefile tools" out there. If so, what are the best
    >> ones?

    >
    >If you don't want to get into autoconf etc, it's trivial to generate your
    >own simple makefiles by writing a program in elementary ISO C. Here's a
    >really, really simple one which you can hack to your heart's content.


    <snippage>

    > printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv,
    >argv);


    Posting a non-strictly-conforming program to comp.lang.c? What have
    you done with The Real Richard Heathfield?


    dave
    (exercise for the reader: What's non-strictly-conforming about the code
    I quoted?)

    --
    Dave Vandervies
    Note that non-portability of the translated code is not a requirement of
    the C Standard.
    --Richard Heathfield in comp.lang.c
    Dave Vandervies, Nov 17, 2005
    #9
  10. Grant Edwards wrote:
    >
    > On 2005-11-17, milkyway <> wrote:
    >
    > > I am running under Suse Linux and am putting together some code written
    > > in C. I am not clear on how to create makefiles

    >
    > You don't create a makefile. You copy one and modify it.
    >
    > Somebody once asked who created the first makefile, but there
    > was no first makefile -- it's just turtles all the way down...
    >


    THE original:

    %s/make/JCL/g

    Wolfgang
    Wolfgang Riedel, Nov 17, 2005
    #10
  11. Dave Vandervies said:

    > In article <dlhjrr$5jd$-infra.bt.com>,
    > Richard Heathfield <> wrote:
    >
    >> printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv,
    >>argv);

    >
    > Posting a non-strictly-conforming program to comp.lang.c? What have
    > you done with The Real Richard Heathfield?


    Er, eek.

    > (exercise for the reader: What's non-strictly-conforming about the code
    > I quoted?)


    I hear ya. Sorry, Dave - I was in helpful mode instead of picky guy mode.
    I'll try not to let it happen again. :)

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
    Richard Heathfield, Nov 17, 2005
    #11
  12. milkyway

    Arne Schmitz Guest

    Alex Fraser wrote:

    >> Also scons is very nice, and IMHO much easier for small projects.

    >
    > Looks interesting. Being written in Python is unfortunate in some
    > respects.


    Why so?

    Arne

    --
    [--- PGP key FD05BED7 --- http://www.root42.de/ ---]
    Arne Schmitz, Nov 17, 2005
    #12
  13. milkyway

    Mike Wahler Guest

    "Dave Vandervies" <> wrote in message
    news:dliao1$jgb$...
    > In article <dlhjrr$5jd$-infra.bt.com>,
    > Richard Heathfield <> wrote:


    > <snippage>
    >
    >> printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv,
    >>argv);

    >
    > Posting a non-strictly-conforming program to comp.lang.c? What have
    > you done with The Real Richard Heathfield?
    >
    >
    > dave
    > (exercise for the reader: What's non-strictly-conforming about the code
    > I quoted?)


    I don't have my copy of standard handy, so this is just a guess:
    No '$' character guaranteed in execution character set?

    -Mike
    Mike Wahler, Nov 17, 2005
    #13
  14. Dave Vandervies a écrit :
    >> printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv,
    >>argv);


    > (exercise for the reader: What's non-strictly-conforming about the code
    > I quoted?)


    Too easy. '$' is not part of the standard charset.

    --
    A+

    Emmanuel Delahaye
    Emmanuel Delahaye, Nov 17, 2005
    #14
  15. In article <dlih83$ftl$-infra.bt.com>,
    Richard Heathfield <> wrote:
    >Dave Vandervies said:


    >> Posting a non-strictly-conforming program to comp.lang.c? What have
    >> you done with The Real Richard Heathfield?



    >I hear ya. Sorry, Dave - I was in helpful mode instead of picky guy mode.
    >I'll try not to let it happen again. :)


    It's the "instead of" that I'm worried about. Who says you can't do both?


    dave
    (helpful is good, nitpicky is better, helpful AND nitpicky is best of all.
    Unless it's homework questions.)

    --
    Dave Vandervies
    Normally if something is simple enough that anyone should be able to put their
    brain in gear and do it, you'd say "It's not rocket science!" but of course in
    this case it is. --Anthony de Boer in the scary devil monastery
    Dave Vandervies, Nov 17, 2005
    #15
  16. milkyway

    Malcolm Guest

    "milkyway" <> wrote

    > I am running under Suse Linux and am putting together some code written
    > in C. I am not clear on how to create makefiles and was wondering if
    > there were any "makefile tools" out there. If so, what are the best
    > ones?
    >

    make is already a tool to make programs.
    Once you need a tool to make a makefile, you've reached the end of make's
    usefulness, and it's time to look for something else.
    Malcolm, Nov 19, 2005
    #16
  17. "Malcolm" <> writes:
    > "milkyway" <> wrote
    >> I am running under Suse Linux and am putting together some code written
    >> in C. I am not clear on how to create makefiles and was wondering if
    >> there were any "makefile tools" out there. If so, what are the best
    >> ones?
    >>

    > make is already a tool to make programs.
    > Once you need a tool to make a makefile, you've reached the end of make's
    > usefulness, and it's time to look for something else.


    Actually, tools that generate Makefiles are fairly common.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Nov 19, 2005
    #17
  18. milkyway

    Malcolm Guest

    "Keith Thompson" <> wrote
    >
    > Actually, tools that generate Makefiles are fairly common.
    >

    And you need the horrible things to make emacs debug / error edit properly.

    I'm a gcc *.c man myself.
    Malcolm, Nov 19, 2005
    #18
  19. milkyway

    Simon Biber Guest

    Emmanuel Delahaye wrote:
    > Dave Vandervies a écrit :
    >
    >>> printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv,
    >>> argv);

    >
    >
    >> (exercise for the reader: What's non-strictly-conforming about the code
    >> I quoted?)

    >
    >
    > Too easy. '$' is not part of the standard charset.


    4#5 "A strictly conforming program shall use only those features of the
    language and library specified in this International Standard. It shall
    not produce output dependent on any unspecified, undefined, or
    implementation-defined behavior, and shall not exceed any minimum
    implementation limit.

    5.2.1#1 "The values of the members of the execution character set are
    implementation-defined."

    6.4.5#5"The value of a string literal containing a multibyte character
    or escape sequence not represented in the execution character set is
    implementation-defined."

    What if we use universal character names?

    printf("\t\u0024(CC) \u0024(CFLAGS) \u0024(DFLAGS) -c -o %s.o %s.c\n",
    argv, argv);

    Unfortunately, it is still implementation-defined whether \u0024 is a
    member of the execution character set, so this program cannot be
    considered strictly conforming.

    --
    Simon.
    Simon Biber, Nov 20, 2005
    #19
  20. Emmanuel Delahaye <> writes:
    > Dave Vandervies a écrit :
    >>> printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv,
    >>> argv);

    >
    >> (exercise for the reader: What's non-strictly-conforming about the code
    >> I quoted?)

    >
    > Too easy. '$' is not part of the standard charset.


    Of course, we've never had a rule against posting
    non-strictly-conforming code here. If we did, we couldn't post

    #include <stdio.h>
    int main(void)
    {
    printf("sizeof(int) = %d\n", (int)sizeof(int));
    return 0;
    }

    (Yeah, I know, I'm spoiling the joke.)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Nov 20, 2005
    #20
    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. sasquatch

    Makefiles for JAVA

    sasquatch, Nov 8, 2003, in forum: Java
    Replies:
    5
    Views:
    735
    Dale King
    Nov 12, 2003
  2. Harris L

    Ant vs Makefiles

    Harris L, Nov 26, 2004, in forum: Java
    Replies:
    20
    Views:
    10,729
    Jacob
    Dec 2, 2004
  3. dharmesh Gupta

    Making of Makefiles

    dharmesh Gupta, Aug 26, 2003, in forum: C++
    Replies:
    2
    Views:
    335
    Kevin Goodsell
    Aug 26, 2003
  4. Janne Naukkarinen
    Replies:
    1
    Views:
    365
    Jack Klein
    Jan 15, 2004
  5. db
    Replies:
    2
    Views:
    426
Loading...

Share This Page