Note that there are some explanatory texts on larger screens.

plurals
  1. POGNU make Not Deleting Intermediate Files
    text
    copied!<p>My makefile is as follows:</p> <pre><code># The names of targets that can be built. Used in the list of valid targets when no target is specified, and when building all targets. TARGETS := libAurora.a libAurora.so # The place to put the finished binaries. TARGET_DIRECTORY := ./Binaries # The compiler to use to compile the source code into object files. COMPILER := g++ # Used when compiling source files into object files. COMPILER_OPTIONS := -I. -Wall -Wextra -fPIC -g -O4 # The archiver to use to consolidate the object files into one library. ARCHIVER := ar # Options to be passed to the archiver. ARCHIVER_OPTIONS := -r -c -s SOURCE_FILES := $(shell find Source -type f -name *.cpp) OBJECT_FILES := $(SOURCE_FILES:.cpp=.o) .PHONY: Default # The default target, which gives instructions, can be called regardless of whether or not files need to be updated. .INTERMEDIATE: $(OBJECT_FILES) # Specifying the object files as intermediates deletes them automatically after the build process. Default: @echo "Please specify a target, or use \"All\" to build all targets. Valid targets:" @echo "$(TARGETS)" All: $(TARGETS) lib%.a: $(OBJECT_FILES) $(ARCHIVER) $(ARCHIVER_OPTIONS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES) lib%.so: $(OBJECT_FILES) $(ARCHIVER) $(ARCHIVER_OPTIONS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES) %.o: $(COMPILER) $(COMPILER_OPTIONS) -c -o $@ $*.cpp </code></pre> <p>As you can see, the <code>.o</code> files are specified as intermediates via the <code>.INTERMEDIATE</code> target. However, they are not deleted as expected after compilation finishes. Instead, they remain where they were created, cluttering up my source directory.</p> <p>The strange thing is that it works perfectly on another machine. This leads me to believe it's a different version of <code>make</code>, but <code>man make</code> still shows it as the "GNU make utility."</p> <p>Why won't <code>make</code> delete the intermediate files?</p> <p>EDIT: <code>make -v</code> reports version 3.81.</p> <p>EDIT: After manually deleting the <code>.o</code> files (i.e., a clean slate), <code>make All</code> produces the following output:</p> <pre><code>g++ -I. -Wall -Wextra -fPIC -g -O4 -c -o Source/File/File.o Source/File/File.cpp g++ -I. -Wall -Wextra -fPIC -g -O4 -c -o Source/Timer/Timer.o Source/Timer/Timer.cpp ar -r -c -s ./Binaries/libAurora.a Source/File/File.o Source/Timer/Timer.o ar -r -c -s ./Binaries/libAurora.so Source/File/File.o Source/Timer/Timer.o </code></pre>
 

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