> book: "Managing Projects with GNU make, 3rd Edition" say : > > "Prerequisites of this special target are treated as intermediate files but
> are never automatically deleted. The most common use of .SECONDARY is to > mark object files stored in libraries. Normally these object files will be > deleted as soon as they are added to an archive. Sometimes it is more
> convenient during development to keep these object files, but still use the > make support for updating archives". > > Normally these object files will be deleted as soon as they are added to an
> archive, but I create makefile to ensure in this behaviour and to my regret > i found that all object still locate in my directory when archive was > created
Here is an excerpt from the GNU make manual:
The targets which .SECONDARY depends on are treated as intermediate files, except that they are never automatically deleted... .SECONDARY with no prerequisites causes all targets to be treated as secondary (i.e., no target
is removed because it is considered intermediate).
It sounds to me like you are trying to delete your object files after they are added to the archive. The .SECONDARY target is designed to keep intermediate files from being deleted automatically, which is the normal behavior. I've noticed that when it comes to creating archives, GNU make is a bit flaky, not deleting object files when the manual tells you it will. I believe it will always err on the side of safety - eg., never delete anything unless it's absolutely sure it should. Here's a makefile that will do what you want: