Hi,
Thanks for the patch for the .INTERMEDIATE option (does not delete
file when explicitly requested on the command line). Now that we
are using this option, we have noticed the following behaviour:

$ make clean
rm -f libbug.a *.o core
$ make
g++ -Wall -o lib.o -c lib.cpp
ar rv libbug.a lib.o
a - lib.o
rm lib.o
$ touch lib.h
$ make
make: Nothing to be done for `all'.

This contrasts with:
$ make clean 
rm -f libbug.a *.o core
$ make
g++ -Wall -o lib.o -c lib.cpp
ar rv libbug.a lib.o
a - lib.o
rm lib.o
$ touch lib.cpp
$ make
g++ -Wall -o lib.o -c lib.cpp
ar rv libbug.a lib.o
r - lib.o
rm lib.o

In other words, *providing lib.o does not exist and is an INTERMEDIATE
file*, make refuses to regenerate the lib.o file if it is out-of-date
w.r.t. lib.h, but does regenerate it if it is out-of-date w.r.t. lib.cpp.

I have tested this with make 3.77; this version works correctly.

Cheers,
Chris

-- Makefile -- cut here ------------------------------------------
CXX=g++
CXXFLAGS=-Wall

SRC=lib.cpp
OBJ=$(SRC:.cpp=.o)

all: libbug.a

libbug.a: libbug.a($(OBJ))

.PHONY: all clean
.INTERMEDIATE: $(OBJ)

clean:
        $(RM) libbug.a *.o core

%.o: %.cpp
        $(CXX) $(CXXFLAGS) -o $@ -c $<

lib.o: lib.cpp lib.h

-- lib.cpp -- cut here --------------------------------------------
#include "lib.h"


ostream& hello(ostream &out)
{
  out << "Hello World!";
  return out;
}

-- lib.h -- cut here ----------------------------------------------
#ifndef LIB_H
#define LIB_H

#include <iostream>
using std::ostream;

ostream& hello(ostream &ostr);

#endif


Reply via email to