Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After reading cdhowie's answer, I started looking into mkdep, however it appears such programs are deprecated, and have been replaced by compiler flags that do the same thing. I have included the body of my makefile which compiles both the main program (code in srcpath) and the tests (code in testpath) then runs the tests. Two seperate dependency files are created during this, one for main, the other for the tests.</p> <pre><code>src = $(shell cd $(srcpath); find ./ -name "*.cpp") testsrc = $(shell cd $(testpath); find ./ -name "*.cpp") obj = $(src:%.cpp=%.o) testobj = $(testsrc:%.cpp=%.o) head = $(shell cd $(srcpath); find ./ -name "*.h") testhead = $(shell cd $(testpath); find ./ -name "*.h") skip_files = ./main.o makedep = $(shell $(cpp) $(cflags) -MM -MT '$(patsubst $(srcpath)%.cpp, $(objpath)%.o, $(file))' $(file) &gt;&gt; .depend) makedeptest = $(shell $(cpp) $(cflags) -MM -MT '$(patsubst $(testpath)%.cpp, $(testobjpath)%.o, $(file))' $(file) &gt;&gt; .dependtest) all: main Test Test: .dependtest $(addprefix $(testobjpath),$(testobj)) @echo "Linking Tests" @$(cpp) $(lflags) -o $(testbin) $(addprefix $(testobjpath), $(testobj)) $(addprefix $(objpath), $(filter-out $(skip_files),$(obj))) @./$(testbin) .dependtest: $(addprefix $(testpath), $(testsrc)) $(addprefix $(testpath), $(testhead)) $(shell rm -f .dependtest) $(foreach file,$(addprefix $(testpath), $(testsrc)), $(makedeptest)) $(addprefix $(testobjpath), %.o): $(addprefix $(testpath), %.cpp) $(cpp) $(cflags) -c -o $@ $&lt; main: .depend $(addprefix $(objpath), $(obj)) @echo "Linking Program" @$(cpp) $(lflags) -o $(bin) $(addprefix $(objpath),$(obj)) .depend: $(addprefix $(srcpath), $(src)) $(addprefix $(srcpath), $(head)) $(shell rm -f .depend) $(foreach file, $(addprefix $(srcpath), $(src)), $(makedep)) $(addprefix $(objpath), %.o): $(addprefix $(srcpath), %.cpp) $(cpp) $(cflags) -c -o $@ $&lt; clean: -rm $(testbin) $(bin) $(addprefix $(objpath),$(obj)) $(addprefix $(testobjpath),$(testobj)) -include .depend -include .dependtest </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