Could you help me with the following code I have written?
VPATH= balll mall fall
OBJECTS= objj/goka.o objj/foka.o objj/hoka.o
exec/gola: $(OBJECTS)
gcc $^ -o $@
$(OBJECTS): objj/%.o : %.c
gcc -c $< -o $@
What I want to do is: I don’t have exec directory and obj directory and I want them to be created during the compiling of the file and save those files in their respective directories. Can I do that? Creating the directory exec and telling the gcc to save the gola target file in exec directory and same with the objective files.
Is there any command to deal with it?
Just add
mkdir -p dir1 dir2to the appropriate rule of your makefile, prior to compilation.Example: (You’ll have to modify this for your particular setup)