I had the following folder structure:
include/
src/
data/
binary-file
makefile
I would execute the binary like so: ./binary-file
But now I want my binary in it's own folder like so:
bin/ <- binary-file is in here now
include/
src/
data/
makefile
Everything goes fine when I execute it from the main folder like so: bin/binary-file
But if I am in another folder other than the main folder, the program will be ill-behaved and will not be able to locate the paths to #include's. For example, if I were in the bin/ folder, the program will be ill-behaved if I execute it like so: ./binary-file
My question is: How can I tell my makefile or binary file to execute like it was in the main folder, from anywhere on my system?
In my makefile, all I changed was:
$(CC) $(CFLAGS) -I$(IDIR) -I$(BDIR) -I$(DDIR) -o $(PROG) $^ $(LFLAGS)
to
$(CC) $(CFLAGS) -I$(IDIR) -I$(BDIR) -I$(DDIR) -o $(BDIR)/$(PROG) $^ $(LFLAGS)