"pereges" <Broli00@[EMAIL PROTECTED]
> schrieb im Newsbeitrag
news:ab6bd1df-68e8-47ae-8419-117478a85be0@[EMAIL PROTECTED]
> On May 9, 12:37 pm, Richard Heathfield <r...@[EMAIL PROTECTED]
> wrote:
>
>>
>> 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$(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;
>
> }
>
>
----------------------------------------------------------------------------------------------------
>
>
> I would like to use this for my project. Can you please tell me what
> is the purpose behind the functions makeclean and makeinstall ?
Just for the fun of it I've writen that program as a shell script:
$ cat makegen.sh
#!/bin/sh
if [ $# -gt 1 ]
then
# genflags
cat <<-!
CC=gcc
CFLAGS= -W -WALL -ansi -pedantic -O2
DFLAGS=-g -pg
!
# makeprg
printf '%s:' $1
for arg in $@[EMAIL PROTECTED]
do
printf ' %s.o' $arg
done
printf '\n\n'
# makeobjs
for arg in $@[EMAIL PROTECTED]
do
printf '%s.o: %s.c\n' $arg $arg
printf '\t$(CC) $(CFLAGS) $(DFLAGS) -c -o %s.o %s.c\n'
$arg
$arg
done
printf '\n'
# makeclean
printf 'clean:\n\trm -f %s' $arg
for arg in $@[EMAIL PROTECTED]
do
printf ' %s.o' $arg
done
printf '\n\n'
# makeinstall
printf 'install:\n\tcp %s /usr/local/bin\n\n' $arg
else
echo "Usage: makegen.sh progname [sourcename*]" >&2
fi
return 0
Has the advantage that to change it doesn't requite a recompile...
downside: you need a shell with builtin echo), the printf, rm and cp
commands and most im****tantly: it is off topic here 8-)
Bye, Jojo


|