When I type 'make' again and again, I'm seeing version.o recompiled and gnuplot binary(ies) relinked every time, albeit I made no changes to any sources. This happens both typing make from the top-level directory, and from the src/ one.
I found out this patch fixes the situation for me
https://sourceforge.net/u/kefren/gnuplot/ci/dd17d1599aeff2b714bb224d62d500c0ceb4c639/
(dropping .PHONY and any dependencies from timestamp.h, as the target is already NOT rebuilt if unchanged, thanks to the last line "if cmp -s ...")
However, I'm not too convinced this is really the right fix, as timestamp.h is a prerequisite for all .o files, but this rebuild problem is only occurring on version.o (note that the build process does not change any timestamp to the version.{c,h} files, AFAICS).
Perhaps someone who knows/understands better the make pipeline might have a say here...
Thanks.
forgot: building git master tree, with GNU make 4.3, on Ubuntu 20.10.
What version source do you use?
I have been make gnuplot binaries on the cygwin 64 using GNU make but have not met phenomena that you mention at least 5.4.2, 5.4.3 and the current git (5.5).
repo: https://github.com/gnuplot/gnuplot.git
branch: master
(commit: 7a547280)
it recompiles all the times version.c into version.o, then links version.o into the gnuplot executable.
Last edit: Tommaso Cucinotta 2022-01-23
from some further diggings:
In other words, I'm inclined to think that my patch is actually correct :-).
Thanks.
Last edit: Tommaso Cucinotta 2022-01-23
updated patch mentioning this bug# for extended info...
https://sourceforge.net/u/kefren/gnuplot/ci/8db9fe2d58aba5317870f5ab843020fa27b5340a/
Last edit: Tommaso Cucinotta 2022-01-23
timestamp.h is not a "real" file. It is not part of the git repository, and not part of any distribution release. It exists only transiently as a phony target for make in the development version. It is there so that the executable can correctly report when it was built. I.e. when you run the program it reports:
We went through several rounds of trying to set things so that you could tell exactly where in the development process the executable was built. For a while it was reporting instead the most recent git commit hash. That makes a lot of sense but had the large downside (for me anyway) that "make" would fail if run outside of the git repository directory. So we ended up using the date instead.
AFAIU, it is working fine, in that with DEVELOPMENT_VERSION version.c will include and depend on timestamp.h, which will be rebuilt by the Makefile rule fetching from git the timestamp. Just, it should not be .PHONY, it's a real file (not on repo), and its rebuild rule avoids overwriting it if the git timestamp does not change, thus once you remove the .PHONY, make does the right thing (attempt to rebuild timestamp.h, but ending up not updating it (if cmp -s ....), thus not following up on to rebuilding its dependant version.o)
This is just a little annoyance for devels, just as I noticed the git version was being rebuilt all the times, I thought to have a look....
I have forgotten all the messy details of what was tried earlier and what broke, and hence why we ended up with things the way they are. I seem to recall that "git bisect" did not work correctly in the immediately prior mechanism, but I don't recall now whether the .PHONY attribute was a fix for that or something else.
Why is it a problem that it re-links when you say "make"? It only takes a couple of seconds. If the intent is to see whether anything in the source has changed recently, wouldn't it be better to type
git status
?yeah, I'm seeing it in the commit [ef315e6f] by Henri, the part of supporting out-of-git tree make of the DEVELOPMENT_VERSION is preserved, as it is preserved the part that removed a direct Makefile dependency of timestamp.h from the .git/HEAD file.
You can try rebuilding with my patch above,
https://sourceforge.net/u/kefren/gnuplot/ci/8db9fe2d58aba5317870f5ab843020fa27b5340a/
you should see that you're still able to build out of a git tree (just did it right now wiping out the .git/ folder altogether, then cleaning, dist-cleaning, reconfiguring and rebuilding from scractch, seems all right).
I think our goals are at cross-purposes here. With your patch in place, the timestamp is not updated when I change something and rebuild. That kind of defeats the purpose of having it. Here's an example of my typical work-flow:
The
.prepare
step will rebuild the Makefiles, but since timestamp.h no longer depends on the Makefile it remains as it was before and is now out of date.I honestly don't understand this
.PHONY: ...
business. But with or without the .PHONY I think the dependence of timestamp on Makefile is necessary at a minimum. Ideally I suspect it should depend on all source files (maybe that's what .PHONY does??) so that any change to the source updates the timestamp.Last edit: Ethan Merritt 2022-01-24
Ah good, now I'm getting closer to what you need:
a) under git, you want the timestamp of the last git commit, not caring about dates of local sources;
b) out of git, you want a timestamp reflecting the latest changes to the code in the local sources (pls, confirm that's your intended behavior).
As I think a) is already there, let's focus on b): you can't achieve that the way the Makefile.am is written now, because the timestamp is coming from:
so if Makefile.am changes date on disk, then you get a new timestamp, and the last "if cmp -s..." line overwrites timestamp.h because it's now different from before. However, if Makefile.am doesn't change date on disk, then the last line "if cmp -s..." will see no change of contents, and it won't update the timestamp of timestamp.h. Plus, the execution of the whole rule might be skipped altogether if you add any pre-requisite to timestamp.h. In my patch, timestamp.h has NO prerequisites, so this allow us to control this in both a) and b) cases above (I would suggest to keep it as it is, with no prerequisites).
So, I'd propose this little further change, on top of my patch:
This, in case of an out-of-git build, gives you a full date/time timestamp (i.e., "2022-01-24 15:47:36") of the last updated file, among all of the on-disk GNUPLOT sources, plus Makefile.am.
Would it do what you need?
Thx!