On May 9, 12:37 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
>
Make files save on typing and braining. Which would you rather have to
remember and type: this...
$ cc -o test file1.c file2.c file3.c
or this?
$ make
It's no contest, right? Also, make only bothers to compile stuff that needs
compiling. If you haven't touched file3.c, why bother to recompile it? It
only needs to be re-linked. So if you separate compilation from linking,
you can save yourself some actual time.
hello, i think this C program for generating make files on linux was
written by you which I found by searching through archives :
---------------------------------------------------------------------------------------------------
#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$(C C) $(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(arg c, argv);
}
else
{
fputs("Usage: makegen progname [sourcename*]\n", stderr);
}
return 0;
}
----------------------------------------------------------------------------------------------------
I would like to use this for my project. Can you please tell me what
is the purpose behind the functions makeclean and makeinstall ?