Note that there are some explanatory texts on larger screens.

plurals
  1. POMakefile variable being ignored
    text
    copied!<p>I have the following makefile which is a slight modification on others that I have used in the past. There is an odd issue though with my variable <code>${CXXOPTS}</code> not being used in the <code>.c.o</code> makefile rule. When I execute the makefile, this is what is executed <code>g++ -c -o SeqPrep2.o SeqPrep2.cpp</code> when I expect this to be executed: <code>g++ -Iseqan-03-02-2012 -c -o SeqPrep2.o SeqPrep2.cpp</code>. (Edit: I solved the problem but see my updated question below about why this makefile worked at all in the first place)</p> <pre><code>L=-lm -lz SEQANINC=seqan-03-02-2012 DESTDIR=$(HOME)/ BINDIR=bin CXXOPTS=-I${SEQANINC} CXX=g++ A=SeqPrep2 USEROPTS= O=$(patsubst %.cpp,%.o,$(wildcard *.cpp)) SOURCES=$(wildcard *.cpp) all: ${A} ${O} ${SOURCES} install: ${O} ${MYLIBS} ${SOURCES} ${CXX} ${USEROPTS} -o ${DESTDIR}${BINDIR}/${A} ${O} ${L} ${A}: ${O} ${MYLIBS} ${SOURCES} ${CXX} ${USEROPTS} -o ${A} ${O} ${L} clean:: rm -f ${A} ${O} .c.o: ${CXX} ${CXXOPTS} ${USEROPTS} -c $&lt; -o $@ check-syntax: ${CXX} ${CXXOPTS} ${USEROPTS} -c -o .nul -S ${CHK_SOURCES} </code></pre> <p>UPDATE:</p> <p>I changed <code>.c.o</code> to <code>.cpp.o</code>. Is this a case of gnu make guessing that when I asked for a .o file in one of my rules, that it should make it just by running <code>g++ -c -o SeqPrep2.o SeqPrep2.cpp</code> even though I didn't tell it to do that? I guess that is my new question, why did the above makefile work at all, and why did it have the odd behavior I observed. One thing to note is that even though it didn't come though in the formatting, there is a lot of white space between the <code>g++</code> and the <code>-c</code>, kind of like it was trying to put in my variables, but it didn't. That is partially what originally lead me to believe that it was seeing my rule at all, even though it seems like it didn't now. Thanks for helping me understand how this stuff works.</p>
 

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