Re: Archive Members as Targets

2022-05-11 Thread Paul Smith
On Tue, 2022-05-10 at 22:45 +0200, Michael Lehn wrote:
> But not on the Linux boxes there make always rebuild everything. On
> all machines I am using GNU Make.

This is because whatever GNU/Linux distribution is being used, has
configured their binutils so that ar is in "deterministic mode" by
default, which is bogus and breaks make.

On such a system you'll have to pass the "U" option to ar, to disable
deterministic mode.



Re: Archive Members as Targets

2022-05-10 Thread Henrik Carlqvist
On Tue, 10 May 2022 22:05:22 -0400
Dmitry Goncharov  wrote:

> > But not on the Linux boxes there make always rebuild everything. On all
> > machines I am using GNU Make.
> ...
> > Can anyone confirm that?
> 
> i can confirm that for me on linux the latest make from git as well as
> make-4.3 correctly detect that libfoo.a is up to date.

I can confirm that it works fine also on Slackware Linux 14.2 using make
version 4.1:

nazgul:/tmp> make
cc-c -o foo.o foo.c
ar cr libfoo.a foo.o
ranlib libfoo.a
rm foo.o
nazgul:/tmp> make
make: Nothing to be done for 'all'.
nazgul:/tmp> make --version
GNU Make 4.1
Built for x86_64-slackware-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
nazgul:/tmp> cat /etc/slackware-version
Slackware 14.2

regards Henrik



Re: Archive Members as Targets

2022-05-10 Thread Dmitry Goncharov
On Tue, May 10, 2022 at 5:12 PM Michael Lehn  wrote:
> But not on the Linux boxes there make always rebuild everything. On all 
> machines I am using GNU Make.
...
> Can anyone confirm that?

i can confirm that for me on linux the latest make from git as well as
make-4.3 correctly detect that libfoo.a is up to date.
What version of make do you use?

> (or tell me what obvious stupid mistake I have done …?)

you don't really need ranlib any longer.

regards, Dmitry



Archive Members as Targets

2022-05-10 Thread Michael Lehn
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