Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't my eval function in my Makefile working?
    primarykey
    data
    text
    <p>When I try to run the following make file (updated with suggestions below):</p> <pre><code># Build Directories src_dir=src obj_dir=obj bin_dir=bin cc=cl cc_flags= configs = dbg rel # create the directory for the current target. dir_guard=@mkdir -p $(@D) # source files src = MainTest.cpp define build_template = # object files - replace .cpp on source files with .o and add the temp directory prefix obj_$(1) = $$(addprefix $$(obj_dir)/$(1)/, $$(addsuffix .obj, $$(basename $$(src)))) testVar = "wooo" # build TwoDee.exe from all of the object files. $$(bin_dir)/$(1)/MainTest.exe : $$(obj_$(1)) $$(dir_guard) $$(cc) -out:$$@ $$(obj_$(1)) -link # build all of the object files in the temp directory from their corresponding cpp files. $$(obj): $$(obj_dir)/$(1)/%.obj : $$(src_dir)/%.cpp $$(dir_guard) $$(cc) $$(cc_flags) -Fo$$(obj_dir)/$$(1) -c $$&lt; endef $(foreach cfg_dir,$(configs),$(eval $(call build_template,$(cfg_dir)))) release: $(bin_dir)/rel/MainTest.exe debug: cc_flags += -Yd -ZI debug: $(bin_dir)/dbg/MainTest.exe $(warning testVar $(testVar)) </code></pre> <p>All I get is:</p> <pre><code>$ make Makefile:41: testVar make: *** No rule to make target `bin/rel/MainTest.exe', needed by `release'. Stop. </code></pre> <p>You can see from the output that the testVar variable is never set. I made these changes based on my last question: <a href="https://stackoverflow.com/questions/11331390/why-doesnt-my-makefile-target-specific-variable-work">Why doesn&#39;t my makefile target-specific variable work?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload