Hi,
I'm playing around with makefiles on Linux and I can't quite figure out what's wrong with this one:
Code:
# makefile for test build.
###########################################################
CC = g++
CDEBUG = -g3
CRELEASE = -O3
DEFS =
CFLAGS = -I. $(DEFS) -c -pedantic-errors
LDFLAGS =
OBJS = main.o
DEBUG_PATH = debug
RELEASE_PATH = release
TARGET = main
clean:
rm -f $(DEBUG_PATH)/*.o $(DEBUG_PATH)/$(TARGET)
rm -f $(RELEASE_PATH)/*.o $(RELEASE_PATH)/$(TARGET)
rmdir $(DEBUG_PATH)
rmdir $(RELEASE_PATH)
all: debug release
debug: $(DEBUG_PATH) $(DEBUG_PATH)/$(OBJS)
cd $(DEBUG_PATH)
$(CC) $(LDFLAGS) $(OBJS) -o $(TARGET)
release: $(RELEASE_PATH) $(RELEASE_PATH)/$(OBJS)
cd $(RELEASE_PATH)
$(CC) $(LDFLAGS) $(OBJS) -o $(TARGET)
$(DEBUG_PATH):
mkdir $(DEBUG_PATH)
$(RELEASE_PATH):
mkdir $(RELEASE_PATH)
$(DEBUG_PATH)/main.o: main.cpp
cd $(DEBUG_PATH)
$(CC) $(CDEBUG) $(CFLAGS) ../main.cpp
$(RELEASE_PATH)/main.o: main.cpp
cd $(RELEASE_PATH)
$(CC) $(CRELEASE) $(CFLAGS) ../main.cpp
If I run make debug it barfs out all these errors:
Code:
makefile:32: warning: overriding commands for target `debug'
makefile:24: warning: ignoring old commands for target `debug'
makefile:35: warning: overriding commands for target `release'
makefile:28: warning: ignoring old commands for target `release'
make: Circular debug <- debug dependency dropped.
cd debug
/bin/sh: line 0: cd: debug: No such file or directory
make: *** [debug/main.o] Error 1
Here's main.cpp in case it matters:
Code:
// main.cpp
/////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
Can someone explain what those warnings mean and especially why the debug directory isn't being created?