nmake и автоматические зависимости
makefile для nmake, не для gnu.
Записано правило .cpp.obj:, все нормально, все хорошо. Не считая того, что если я меняю .h-файл, то nmake не понимает, что надо перекомпилировать соответствующие .cpp-файлы, которые от него зависят.
Конечно, можно решить вопрос, руками прописав вместо одного .cpp.obj: массу правил с зависимостями для каждого файла, но это жутко неудобно и резко увеличивает запутанность и размер файла. Есть ли какой-то способ покрасивее?
Ответы (1 шт):
Возможно, что Вам подойдёт вот это:
Using Targets in Multiple Description Blocks
A target can appear in only one description block when specified using the single-colon (:) syntax to separate the target from the dependent. To update a target using more than one description block, specify two consecutive colons (::) between targets and dependents. One use for this feature is for building a complex target that contains components created with different commands.
Example
The following makefile updates a library:target.lib :: one.asm two.asm three.asm ML one.asm two.asm three.asm LIB target -+one.obj -+two.obj -+three.obj; target.lib :: four.c five.c CL /c four.c five.c LIB target -+four.obj -+five.obj;If any of the assembly-language files have changed more recently than the library, NMAKE assembles the source files and updates the library. Similarly, if any of the C-language files have changed, NMAKE compiles the C files and updates the library.
Смысл этого в том, что при измении любого из файлов зависимости, будут автоматически выполненые команды для данных целей с обновлением библиотек.