You are not logged in.
Pages: 1
Is there a way to tell Make to ignore the timestamps of specific files (so that simply by existing they are 'up to date')? Alternatively, is there a command to alter the timestamp of a file?
The reason I ask is that I am using Make to re-create my build directories (which I prefer to keep seperate from source) when they are needed. Unfortunately, when some unrelated object is rebuilt, the build directory's timestamp is updated too, and because other targets depend on the directory, they are rebuilt unnecessarily. This sometimes leads to weird results.
Offline
1) Fix your Makefile. Either you depend on a directory, or not. Being lazy and using it instead of the files within it is wrong.
2) See touch(1).
Offline
I'm not sure I explained this correctly. I'll try again.
I have something like this:
$(TARGETDIR) :
@mkdir -p $@
$(TARGET) : $(TARGETDIR) $(OBJECTS)
@echo " DSO $(TARGET)"
@gcc -shared $(LINKAGE) -o$(TARGET) $(OBJECTS)
$(TARGETDIR) is actually ./bin, where all the final binaries/libraries go. If I remake program X, it updates the ./bin directory's timestamp. When I run make again it procedes to relink all the other programs, even though I have not modified anything.
Of course everything works fine removing the directory as a dependency. I could just make sure the directories are always there and won't be deleted, but I'd really like this to work since it is a much nicer way.
I just looked at touch's man page. To be honest I didn't know it could set any time. I'll try that.
Offline
instead of using mkdir, try using 'install -D" to place the final binaries. See if that changes anything.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
Why not just use install with the -D option? Or just always call mkdir -p, even easier and clearer than the extra rule.
I guess the problem is that the mtime of the dir changeswhen you put files in it. The next time you run make it will think it's newer than TARGET and will rebuild everything.
Offline
...Or just always call mkdir -p, even easier and clearer than the extra rule.
Great idea. It works well, cheers!
It seems so obvious now. No more will I have directories as dependencies (phew).
Offline
If stuck, always go for the easiest and cleanest solution, often that is the best one. If that solution makes things more ugly, then go fix things higher up the trouble chain.
Offline
Pages: 1