I am trying to run my makefile using make run but its getting some errors : "No rule to make target 'put.h', needed by 'straps.o'. Stop". The error is about GCC can't find the headers file(put.h) when running makefile with the text below :
In kernel directory's Makefile
VPATH=../../include
all : straps.o entry.o head.o
straps.o : straps.c put.h
$(GCC) -c straps.c $(CFLAG)
entry.o : entry.S
$(GCC) -c entry.S $(CFLAG)
head.o : head.S
$(GCC) -c head.S $(CFLAG)
(straps.c include"put.h" so i need to include put.h) I am trying to include headers file in the gcc command line (by using $(GCC) -c straps.c $(CFLAG) -I../include) but still not working. Can anyone explain why I am getting this error and suggest a fix solution if possible. Thank you
My file list
Linux
├── arch
│ └── riscv
│ ├── kernel
│ │ ├── entry.S
│ │ ├── head.S
│ │ ├── Makefile
│ │ ├── straps.c
│ │ └── vmlinux.lds
│ └── Makefile
├── include
│ ├── put.h
│ └── test.h
├── init
│ ├── main.c
│ ├── Makefile
│ └── test.c
├── lib
│ ├── Makefile
│ └── put.c
└── Makefile
Main Makefile gives the variable as below :
export
CROSS_= riscv64-unknown-elf-
AR=${CROSS_}ar
GCC=${CROSS_}gcc
LD=${CROSS_}ld
OBJCOPY=${CROSS_}objcopy
ISA ?= rv64imafd
ABI ?= lp64
INCLUDE = -I ../include
CF = -g -O3 -march=$(ISA) -mabi=$(ABI) -mcmodel=medany -ffunction-sections -fdata-sections -nostartfiles -nostdlib -nostdinc -static -lgcc -Wl,--nmagic -Wl,--gc-sections
CFLAG = ${CF} ${INCLUDE}
***Solution : The kernel directory's Makefile Updated as below (refers to the answer given in the post below):
VPATH = ../../../include
CFLAG += -I../../../include
all : straps.o entry.o head.o
straps.o : straps.c put.h
$(GCC) -c straps.c $(CFLAG)
entry.o : entry.S
$(GCC) -c entry.S $(CFLAG)
head.o : head.S
$(GCC) -c head.S $(CFLAG)
lab2/arch/riscv/kerneldirectory. If that's the case shouldn't you haveVPATH=../../../include? - G.M.