xparq / NMAKE-Jumpstart

Single-file MSVC/NMAKE "jumpstart" Makefile for building source trees without fuss or extra tooling
0 stars 0 forks source link

Mysteriously duplicated `!MESSAGE`s... #8

Closed xparq closed 1 year ago

xparq commented 1 year ago

Wow, the entire Makefile gets parsed twice, for some reason! :-o

xparq commented 1 year ago

FTR:

traverse_src_tree:
    @cmd /v:on /c <<treewalk.cmd
    @echo off
    rem !!This below fails to run without the extra shell! :-o
    rem !!Also: if the env var is just called "make", the makefile gets parsed twice! :-oo
    set _make_=cmd /c $(MAKE_CMD)
    set srcroot_fullpath=!CD!\$(src_dir)
    :: echo $(src_dir)
    :: echo !srcroot_fullpath!
    rem Do the root level first (-> preps!)...
    rem (Note: naming a (different) target would avoid inf. recursion.)
    !_make_! /c start compiling
    rem Scan the source tree for sources...
    for /f %%i in ('dir /s /b /a:d !srcroot_fullpath!') do (
        rem It's *vital* to use a local name here, not dir (==DIR!!!):
        set _dir_=%%i
        set _dir_=!_dir_:%srcroot_fullpath%=!
        !_make_! /c compiling DIR=!_dir_!
    )
    !_make_! RECURSED_FOR_FINISHING=1 finish
<<

There's no preexisting %MAKE%, or nothing expects one either, I suppose... Mmm... But there's $(MAKE)! :-o

But how's that supposed to clash in that context?! And even if it does -- well, through the recursed NMAKE inheriting it! :) --, how does it end up in such a doubled processing?! Ahh, Got it: it has /f Makefile twice on its command-line then! :-o

xparq commented 1 year ago

Except... I can't reproduce it now, even with e.g.

nmake /f Makefile RECURSING_FOR_COMPILING=1 /f Makefile out/obj/main.obj

(OK, finally could, with a brand new, almost empty makefile. :) )