On Wed, 2026-02-11 at 22:01 +0800, lijh.8 wrote:
> If I use U option, the ar recipe will not get executed as it is not
> out-dated. Unless I run make clean or touch command manually.
Then there's something incorrect or unexpected about your makefile or
your build environment. The archive handling behavior does work (we
have a full regression test suite in GNU Make and it includes many
tests of this feature).
It's kind of difficult to understand the examples you're posting since
they are missing the indentation although I can guess where it goes.
Here is an example showing the archive behavior working as expected:
$ cat Makefile
ARFLAGS = -rvU
libfoo.a(foo.o): foo.c
foo.c: ; echo 'int main() { return 0; }' > $@
$ make
echo 'int main() { return 0; }' > foo.c
cc -c -o foo.o foo.c
ar -rvU libfoo.a foo.o
ar: creating libfoo.a
a - foo.o
rm foo.o
$ make
make: 'libfoo.a(foo.o)' is up to date.
$ touch foo.c
$ make
cc -c -o foo.o foo.c
ar -rvU libfoo.a foo.o
r - foo.o
rm foo.o