Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Tools to make makefiles?

Reply
Thread Tools

Tools to make makefiles?

 
 
milkyway
Guest
Posts: n/a
 
      11-17-2005
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

 
Reply With Quote
 
 
 
 
vietor
Guest
Posts: n/a
 
      11-17-2005
use 'autoconf' & write it's script

 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      11-17-2005
[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[i]);
}
printf("\n\t$(CC) $(CFLAGS) $(DFLAGS) -o %s %s.o", argv[1], argv[1]);
for(i = 2; i < argc; i++)
{
printf(" %s.o", argv[i]);
}
putchar('\n');
}

void makeobjs(int argc, char **argv)
{
int i = 0;
for(i = 1; i < argc; i++)
{
printf("%s.o: %s.c\n", argv[i], argv[i]);
printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv[i],
argv[i]);
}
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[i]);
}
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)
 
Reply With Quote
 
spike1@freenet.co.uk
Guest
Posts: n/a
 
      11-17-2005
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 |
------------------------------------------------------------------------------
 
Reply With Quote
 
Arne Schmitz
Guest
Posts: n/a
 
      11-17-2005
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/ ---]
 
Reply With Quote
 
Alex Fraser
Guest
Posts: n/a
 
      11-17-2005
"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


 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      11-17-2005
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??...
 
Reply With Quote
 
Dan Espen
Guest
Posts: n/a
 
      11-17-2005
"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.
 
Reply With Quote
 
Dave Vandervies
Guest
Posts: n/a
 
      11-17-2005
In article <dlhjrr$5jd$>,
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[i],
>argv[i]);


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
 
Reply With Quote
 
Wolfgang Riedel
Guest
Posts: n/a
 
      11-17-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C++ 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C Programming 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui Python 0 04-27-2009 12:46 PM
Article : Security Tools Part -- 2 (.Net FrameWork Tools Series) Namratha Shah \(Nasha\) ASP .Net 0 11-23-2004 04:01 PM
DIGIDESIGN PRO TOOLS LE V6.1 WIN2KXP, DIGIDESIGN PRO TOOLS TDM V6.1WINXP, tel4@ath.forthnet.gr, tel2003@pathfinder.gr NZ Computing 0 10-25-2003 10:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57