I've got this directory structure:
./srccontains the the .cppand the.hof all the files I need./binshould contain the.otemporarily and the.binpermanently. 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...