I have an interesting problem. I have a makefile that builds files, then post processes them, then copies the final processed file to a release folder.
When I run make
, it will build everything correctly and then finishes without copying the final target file to the release folder. I have to run make again for it to see that the generated (newly built) file is newer than the release target and will copy it over.
I have even put in a sleep 5
to delay the final release target check to allow any file IO to finish and update the newly built file with the proper timestamp.
release : ./release/file.xml
./release/file.xml : gen/file_processed.xml sleep
cp gen/file_processed.xml ./release/file.xml
gen/file_processed.xml : gen/file.xml
python2.6 post_processing_scripts.py #saves output as gen/file_processed.xml
gen/file.xml : source_files
command to compile gen/file.xml
sleep :
sleep 5
What isn't working is make thinks that after it compiles all the other targets and executes the sleep recipe to wait 5 seconds, it still says that gen/file_processed.xml
is older than the release target. I have to rerun make to get that final step completed.
Any ideas as to what I can add to let the generated file finish updating before it checks it against the release target?
Thanks so much for your help, I appreciate it!
Cheers,
Brad
UPDATE:
I changed the code so that the question about the sleep command executing always is removed. it still behaves the same as described above however.
release : ./release/file.xml
./release/file.xml : gen/file_processed.xml
cp gen/file_processed.xml ./release/file.xml
gen/file_processed.xml : gen/file.xml
python2.6 post_processing_scripts.py #saves output as gen/file_processed.xml; sleep 5;
gen/file.xml : source_files
command to compile gen/file.xml
I still need to run make twice to get it to copy the final file over.
I will try and make sure this example exactly maps what my original makefile is doing.