I am playing around with GNU GCC makefiles, and made this simple one to build a "Hello, world!" program.
CC=gcc
SOURCES=./Source/main.c
BUILD_DIR=./Build
TARGET=main
all: $(BUILD_DIR)/$(TARGET).exe
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(SOURCES)))
$(BUILD_DIR)/%.o: %.c
$(CC) -c $< -o $@
$(BUILD_DIR)/%.exe: $(OBJECTS)
$(CC) $< -o $@
I cannot understand why when I remove or comment this line
vpath %.c $(sort $(dir $(SOURCES)))
, make stops and returns this error:
> Executing task: D:\Servers\Compilers\MinGW\bin\mingw32-make.exe GCC_PATH=D:\Servers\Compilers\gcc-arm-none-eabi\bin <
mingw32-make: *** No rule to make target 'Build/main.exe', needed by 'all'. Stop.
Could you please explain me why?