make does not rebuild object files after a header file is changed
Open0a908bb93bb99e1ec828cfa04f2ca2dd51c1a033Created 43 days agoUpdated 43 days ago
Descriptionwiki2026-10-20 16:28:19
After changing a header file, make does not rebuild most of the object files which include it: in unix/Makefile.in only some object files list some headers ($(COMPILEHDR), $(IOHDR), etc), in win/Makefile.in none, and make depend needs makedepend ([427101ffff], [427105ffff]). For example, changing generic/tcl.h or unix/tclUnixPort.h rebuilds nothing, and changing generic/tclInt.h rebuilds 3 object files. The same issue in Tk is Tk ticket a0109510a8.
Proposed fix in branch header-dependencies, the same as in Tk: if the compiler supports -MMD -MP (gcc and clang) and ${MAKE-make} supports -include, the compiler writes the header dependencies of every object file into a .d file, which the Makefile includes. This is done in unix/ and win/ (MinGW, MSYS2, Cygwin). With it, changing tcl.h rebuilds 182 object files on Linux, tclInt.h 112 on Linux and 115 with MinGW and MSYS2. With win/makefile.vc, nmake -f makefile.vc depend already works.
Referenced by2
389c9cc74eFix [0a908bb93b] on Windows: generate header dependencies with -MMD -MP in win/Makefile.in too (MinGW, MSYS2, Cygwin). check-in2026-10-20 16:28:49a6056db6f1Fix [0a908bb93b]: make did not rebuild most object files after a header file (e.g. tcl.h, tclInt.h, tclUnixPort.h) was changed. If the compiler supports -MMD -MP (gcc, clang) and make supports -include (GNU and BSD make, but not Solaris make), let the compiler write the dependencies of each object file into a .d file and include them. check-in2026-10-20 15:46:55
Log in (anonymous is fine) to add a comment.