Hi--

What's the right way to handle dependency on a build directory? 
I want to make sure my build directory gets created before I try
and generate files there.

My first attempt looks like this:

        BUILD_DIR=build

        all: $(BUILD_DIR)/foo $(BUILD_DIR)/bar

        $(BUILD_DIR):
                mkdir $(BUILD_DIR)

        $(BUILD_DIR)/foo: $(BUILD_DIR)
                echo "hello" > $(BUILD_DIR)/foo

        $(BUILD_DIR)/bar: $(BUILD_DIR)
                sleep 1
                echo "hi there" > $(BUILD_DIR)/bar


That works, but it isn't perfect. The trouble is when you run make
a second time it does unnecessary work. Writing files into the
build directory touches its timestamp (on my platform anyway). The
build directory winds up being newer than some of its contents, so
make regenerates the contents.

I looked through the manual but I couldn't see anything that would
help me here. I'm sorry if I just missed it, or I'm missing 
something obvious.

I guess what I want is to have make ignore the timestamp for 
$(BUILD_DIR) only, invoking that rule only if it fails to exist.

Justin



_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to