Hello, I want to write a makefile that compiles each .cpp files with the same command and create an executable file with all .o files.

Qt Code:
  1. $(OUTPUT): ?dependencies?
  2. $(LINK) $^ -o $@ $(LIBS) $(LFLAGS)
  3.  
  4. $(OBJECTS_DIR)/%.o: $(SOURCES_DIR)/%.cpp $(SOURCES_DIR)/%.hpp
  5. $(CXX) $< -c -o $@ $(INCLUDE) $(CXXFLAGS)
To copy to clipboard, switch view to plain text mode 

The problem is the dependencies of the main rule. I tried $(OBJECTS_DIR)/%.o but it does not work. I do not want to write the name of each .o file.
The dependencies names are all .cpp files that are in $(SOURCES_DIR) folder, with .o suffix instead of .cpp and in $(OBJECTS_DIR) folder.

Thanks