Hi All,

I am using GNU Make and i have a peculiar kind of error, i am not able to understand, Firstly have a look at the make file used by me

CFLAGS=-c -Wall
exec: $(OBJ)/*.o
$(CC) $^ -o $@
%.o: $(SRC)/*.c
$(CC) $(CFLAGS) $^ -I$(INC)
mv *.o $(OBJ)
rm -f $(OBJ)/*.o exec

as for as my knowledge goes it is correct, and it execute properly, but the problem is when i change some of my code, and rerun make, it throws a error as below,

gcc -c -Wall src/main.c src/read.c -I./inc
mv *.o ./obj
gcc makefile.o -o makefile
gcc: makefile.o: No such file or directory
gcc: no input files
make: *** [makefile] Error 1

I tried a lot of things but not able to understand why it is happening, if i open the make file and save it, then it works properly, or in other words, if make file is the last one to be edited or it is the one having the latest time stamp than any other file then it is ok, or else it gives an error as above, Kindly help me understand where have i gone wrong in writing the make file.

Thanks & Regards,

niranjanvg is offline