Stefano Lattarini wrote: ... > Just out of curiosity: is [test FILE -nt OTHER_FILE] a feature in POSIX?
Not in any current standard. > Anyway, maybe it could be emulated with "find -newer" or something > similar... Sure, but not worth it, because some find programs probably lack support for the -newer predicate. Besides, I abandoned that approach because it seemed like it would not be worthwhile, and because it would impose overhead all of the time. >> or when things are out of date, the regular commands >> would run. Otherwise, it would simply touch the .1 file and exit >> successfully. >> >> AFAIK, there is no way in GNU make to specify dependencies that vary >> depending on the existence of a target. Does anyone know otherwise? >> I.e., a rule that would apply when foo.1 does not exist, vs. another >> one (with different dependents) that would apply when it does exist. >> > What about this (untested)? > > ifeq ($(wildcard target)$(wildcard $(srcdir)/target),) > target: prereq1 > @echo target existed already > else > target: prereq2 > @echo target did not exist > endif > > That would only work assuming 'target' is relative to be builddir > (i.e., 'dir/file', not $(srcdir)/dir/file'), but might be enough. Nice. That looks like it would work. If only we could depend on GNU make...
