bug-make
[Top][All Lists]
Advanced

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

Archive Members as Targets


From: Michael Lehn
Subject: Archive Members as Targets
Date: Tue, 10 May 2022 22:45:13 +0200

I have a problem with GNU make when using [Archive Members as 
Targets](https://www.gnu.org/software/make/manual/html_node/Archive-Members.html#Archive-Members).
 The problem is that on some machines (e.g. running MacOS, Solaris) it works 
fine, i.e. builds the library and the next `make` gives `Nothing to be done for 
'all'`. 

But not on the Linux boxes there make always rebuild everything. On all 
machines I am using GNU Make.

Here the example with one source file `foo.c` and the `Makefile`


foo.c
```
void foo() {}
```

Makefile
```
all: libfoo.a

libfoo.a(%.o) : %.o
        $(AR) cr $@ $^

libfoo.a: libfoo.a(foo.o)
        ranlib libfoo.a
```

Run on Solaris 

```
theon$ make
gcc    -c -o foo.o foo.c
ar cr libfoo foo.o
ranlib libfoo
rm foo.o
theon$ make
make: Nothing to be done for 'all'.
```


Run on Linux
```
acker$ make
gcc    -c -o foo.o foo.c
ar cr libfoo foo.o
ranlib libfoo
rm foo.o
acker$ make
gcc    -c -o foo.o foo.c
ar cr libfoo foo.o
ranlib libfoo
rm foo.o
```


Can anyone confirm that? (or tell me what obvious stupid mistake I have done …?)

Best regards,
Michael




reply via email to

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