help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

isn't --always-make (make 3.80.0) overdoing things ?


From: jerome.zago
Subject: isn't --always-make (make 3.80.0) overdoing things ?
Date: Thu, 28 Nov 2002 10:11:34 CET

----- Makefile -----
CC = gcc
PROGRAM = main
SOURCES = $(wildcard *.c)

all: $(PROGRAM)

$(PROGRAM): $(SOURCES:.c=.o)
        $(CC) -o $@ $^

ifneq (clean, $(MAKECMDGOALS))
    include $(SOURCES:.c=.d)
endif

%.d: %.c
        set -e; $(CC) -M $(CPPFLAGS) $< \
            | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
            [ -s $@ ] || rm -f $@

clean:
        rm -f $(PROGRAM) *.o *.d
----------

----- hello.c -----
#include <stdio.h>
#include "hello.h"

void hello (void)
{
    printf ("Hello, World\n");
}
----------

----- hello.h -----
void hello (void);
----------

----- main.c -----
#include "hello.h"

int main (int argc, char **argv)
{
    hello();
}
----------

----- UNIX session -----
$ make clean; make
rm -f main *.o *.d
Makefile:11: hello.d: No such file or directory
Makefile:11: main.d: No such file or directory
set -e; gcc -M  main.c \
    | sed 's/\(main\)\.o[ :]*/\1.o main.d : /g' > main.d; \
    [ -s main.d ] || rm -f main.d
set -e; gcc -M  hello.c \
    | sed 's/\(hello\)\.o[ :]*/\1.o hello.d : /g' > hello.d; \
    [ -s hello.d ] || rm -f hello.d
gcc    -c -o hello.o hello.c
gcc    -c -o main.o main.c
gcc -o main hello.o main.o

$ cat hello.d
hello.o hello.d : hello.c /usr/include/stdio.h /usr/include/sys/stdsyms.h \
  
/users/ie/jza/arch/lauhpj7/lib/gcc-lib/hppa2.0w-hp-hpux11.00/3.0.4/include/sys/types.h
 \
  /usr/include/sys/_inttypes.h /usr/include/machine/vmtypes.h \
  /usr/include/sys/_fd_macros.h /usr/include/sys/_null.h \
  /usr/include/sys/_size_t.h hello.h

$ cat main.d
main.o main.d : main.c hello.h
----------

So far, so good...

----- UNIX session (continued) -----
$ make --always-make
set -e; gcc -M  main.c \
    | sed 's/\(main\)\.o[ :]*/\1.o main.d : /g' > main.d; \
    [ -s main.d ] || rm -f main.d
set -e; gcc -M  hello.c \
    | sed 's/\(hello\)\.o[ :]*/\1.o hello.d : /g' > hello.d; \
    [ -s hello.d ] || rm -f hello.d
set -e; gcc -M  main.c \
    | sed 's/\(main\)\.o[ :]*/\1.o main.d : /g' > main.d; \
    [ -s main.d ] || rm -f main.d
set -e; gcc -M  hello.c \
    | sed 's/\(hello\)\.o[ :]*/\1.o hello.d : /g' > hello.d; \
    [ -s hello.d ] || rm -f hello.d
gcc    -c -o hello.o hello.c
gcc    -c -o main.o main.c
gcc -o main hello.o main.o
----------

So, why are hello.d and main.d generated twice ?
What can I do to avoid this problem ?

Thanks for your time.

        Jerome Zago.

___________________________________
Webmail Nerim, http://www.nerim.net/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]