Mat
07-12-2009, 18:47
Hallo,
ich habe folgendes Makefile welches mir in meinem aktuellen ordner alle *.cpp dateigen kompiliert.
TARGET := out
CXXFLAGS := -O3 -Wall
CXX := g++
LIBS :=
EXT := cpp
SOURCES := $(wildcard *.$(EXT))
OBJECTS := $(patsubst %.$(EXT), %.o, $(SOURCES))
.PHONY: all
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)
$(OBJECTS): %.o: %.$(EXT)
$(CXX) $(CXXFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -rf *.o
Nun habe 2 unterordner erstellt subdir1 und subdir2 indem files liegen. Ich schaffe es allerdings nicht dass make meine files dort drin erknent. Mir ist klar dass jeder unterordner ein eigenes makefile braucht doch:
1) soll dieses makefile dort genauso aussehen wie das obige ?
2) und wie erkennt jetzt das root-makefile welche abhängigkeiten entstehen?
Kann mir jemand helfen und das obige makefile ergänzen?
Danke
ich habe folgendes Makefile welches mir in meinem aktuellen ordner alle *.cpp dateigen kompiliert.
TARGET := out
CXXFLAGS := -O3 -Wall
CXX := g++
LIBS :=
EXT := cpp
SOURCES := $(wildcard *.$(EXT))
OBJECTS := $(patsubst %.$(EXT), %.o, $(SOURCES))
.PHONY: all
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)
$(OBJECTS): %.o: %.$(EXT)
$(CXX) $(CXXFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -rf *.o
Nun habe 2 unterordner erstellt subdir1 und subdir2 indem files liegen. Ich schaffe es allerdings nicht dass make meine files dort drin erknent. Mir ist klar dass jeder unterordner ein eigenes makefile braucht doch:
1) soll dieses makefile dort genauso aussehen wie das obige ?
2) und wie erkennt jetzt das root-makefile welche abhängigkeiten entstehen?
Kann mir jemand helfen und das obige makefile ergänzen?
Danke