With my Makefile, I’m trying to get my all my objects and binaries to end up in a Release directory. Seems every permutaion I’ve tried has some error so I’m asking for some help. Here is what I have and I need to know how to alter it. Thanks.
BUILDDIR = Release
CXXFLAGS = -O2 -g -Wall -fmessage-length=0
LDFLAGS=
HEADERS = $(wildcard *.h)
SOURCES = $(wildcard *.cpp)
OBJECTS = $(SOURCES:.cpp=.o)
LIBS =
EXECUTABLE= MyProgram
all: $(HEADERS) $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(LDFLAGS) $(OBJECTS) -o $@
clean:
rm -f $(OBJECTS) $(EXECUTABLE)
Modify these lines as follows:
Then there are two options. The first is to use
vpathto locate sources needed to be compiled into objects. The second is to use explicit pattern rule: