bug-make
[Top][All Lists]
Advanced

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

Order-only dependencies don't work


From: Daniel Olivier
Subject: Order-only dependencies don't work
Date: Mon, 18 Oct 2004 20:44:06 -0400

Is this supposed to work?

obj_dir lib_dir :
        [ -d $@ ] || mkdir -p $@

obj_dir/%.o : src_dir/%.c | obj_dir
#       [ -d obj_dir ] || mkdir -p obj_dir # this does work
        touch $@

lib_dir/%.b : obj_dir/obj1.o obj_dir/obj2.o | lib_dir
        touch $@

obj_dir/obj2.o : src_dir/obj2.c
obj_dir/obj1.o : src_dir/obj1.c

lib_dir/test.b : obj_dir/obj2.o obj_dir/obj1.o

It builds fine the first time, but for some reason. If I attempt to make a
second time, because the obj_dir directory (dependency) is newer than the
(target) obj1.o, the rule is re-run, causing the "compiler" (touch in this
simplified case) and "linker" to be re-invoked once each, despite the fact
that the this is an order-only dependency.

address@hidden ~/temp
$ mkdir src_dir

address@hidden ~/temp
$ touch src_dir/obj1.c

address@hidden ~/temp
$ touch src_dir/obj2.c

address@hidden ~/temp
$ make lib_dir/test.b
[ -d obj_dir ] || mkdir -p obj_dir
touch obj_dir/obj1.o
touch obj_dir/obj2.o
[ -d lib_dir ] || mkdir -p lib_dir
touch lib_dir/test.b

address@hidden ~/temp
$ make lib_dir/test.b
touch obj_dir/obj1.o
touch lib_dir/test.b

Please help. I don't understand this behavior.





reply via email to

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