By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,434 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,434 IT Pros & Developers. It's quick & easy.

Tools to make makefiles?

P: n/a
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

Nov 17 '05 #1
Share this Question
Share on Google+
19 Replies


P: n/a
use 'autoconf' & write it's script

Nov 17 '05 #2

P: n/a
[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)
Nov 17 '05 #3

P: n/a
milkyway <d0******@hotmail.com> 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.
--
__________________________________________________ ____________________________
| sp****@freenet.co.uk | |
|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 '05 #4

P: n/a
sp****@freenet.co.uk wrote:
milkyway <d0******@hotmail.com> 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/ ---]
Nov 17 '05 #5

P: n/a
"Arne Schmitz" <ar**********@gmx.net> wrote in message
news:3u************@news.dfncis.de...
sp****@freenet.co.uk wrote:
milkyway <d0******@hotmail.com> 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
Nov 17 '05 #6

P: n/a
On 2005-11-17, milkyway <d0******@hotmail.com> 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??...
Nov 17 '05 #7

P: n/a
"milkyway" <d0******@hotmail.com> 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.
Nov 17 '05 #8

P: n/a
In article <dl**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> 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 dj******@csclub.uwaterloo.ca
Note that non-portability of the translated code is not a requirement of
the C Standard.
--Richard Heathfield in comp.lang.c
Nov 17 '05 #9

P: n/a
Grant Edwards wrote:

On 2005-11-17, milkyway <d0******@hotmail.com> 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
Nov 17 '05 #10

P: n/a
Dave Vandervies said:
In article <dl**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> wrote:
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?


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)
Nov 17 '05 #11

P: n/a
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/ ---]
Nov 17 '05 #12

P: n/a
"Dave Vandervies" <dj******@csclub.uwaterloo.ca> wrote in message
news:dl**********@rumours.uwaterloo.ca...
In article <dl**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> wrote: <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?)


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

-Mike
Nov 17 '05 #13

P: n/a
Dave Vandervies a écrit :
printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv[i],
argv[i]);
(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
Nov 17 '05 #14

P: n/a
In article <dl**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> 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 dj******@csclub.uwaterloo.ca
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
Nov 17 '05 #15

P: n/a

"milkyway" <d0******@hotmail.com> 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.
Nov 19 '05 #16

P: n/a
"Malcolm" <re*******@btinternet.com> writes:
"milkyway" <d0******@hotmail.com> 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) ks***@mib.org <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.
Nov 19 '05 #17

P: n/a

"Keith Thompson" <ks***@mib.org> 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.
Nov 19 '05 #18

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


(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[i], argv[i]);

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.
Nov 20 '05 #19

P: n/a
Emmanuel Delahaye <em***@YOURBRAnoos.fr> writes:
Dave Vandervies a écrit :
printf("\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n", argv[i],
argv[i]);

(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) ks***@mib.org <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.
Nov 20 '05 #20

This discussion thread is closed

Replies have been disabled for this discussion.