I've got this directory structure:
./src
contains the the .cpp
and the.h
of all the files I need./bin
should contain the.o
temporarily and the.bin
permanently. Also, this folder should be deleted when callingmake clean
../
contains theMakefile
This is my current Makefile
:
CFLAGS = -Wall -pedantic -g
CC = g++
EXEC = flrfile
SRC_DIR = src
BIN_DIR = bin
OBJ = FixedLengthFieldsRecord.o FixedLengthRecordFile.o main.o
all: flrfile
../$(BIN_DIR)/%.o: $(SRC_DIR)%.cpp $(SRC_DIR)%.h
$(CC) $(CFLAGS) -c $(SRC_DIR)%.cpp -o $@
$(EXEC): $(OBJ)
@mkdir -p bin
$(CC) $(CFLAGS) $(BIN_DIR)/$(OBJ) -o $(BIN_DIR)/$(EXEC)
.PHONY : clean
clean:
-rm -rf $(BIN_DIR)
When I run make
, I get this error:
make: *** No rule to make target `FixedLengthFieldsRecord.o', needed by `flrfile'. Stop.
Why is this?
PS: Also, how could I make the OBJ = FixedLengthFieldsRecord.o FixedLengthRecordFile.o main.o
more generic? I don't want to write all the .o
...