[GRASS-dev] another make problem (OSX,
but could be a general problem)
Glynn Clements
glynn at gclements.plus.com
Thu Oct 4 08:41:04 EDT 2007
Glynn Clements wrote:
> sqlp *might* be due to lex/yacc issues (that's the only part that's
> different from other libraries).
It was due to lex/yacc issues.
> If yacc is being re-run, y.tab.h will
> be updated, which will force the rest of it to be compiled.
What was happening is that Rules.make has:
ifndef LOCAL_HEADERS
LOCAL_HEADERS = $(wildcard *.h)
endif
and:
$(OBJDIR)/%.o : %.c $(LOCAL_HEADERS) | $(OBJDIR)
On initial compilation, y.tab.h doesn't exist, so it isn't included in
$(LOCAL_HEADERS).
[This is a common pitfall of using $(wildcard ...). It only returns
what exists right now, omitting files which may be generated later.]
If $(OBJDIR)/y.tab.o isn't the first object file, then y.tab.h may[1]
end up being newer than some of the object files. On a second run,
y.tab.h is now a dependency for all object files, so any which are
older than y.tab.h will be re-compiled.
[1] File timestamps typically have a resolution of one second, so it's
probabilistic as to whether it's actually older.
The fix was to add $(EXTRA_HEADERS) as a dependency of $(OBJDIR)/%.o,
so that y.tab.h can be added even when it doesn't exist. This will
force y.tab.h to be generated before any of the object files, so
y.tab.h will be older.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list