I made a C/C++ makefile project, that now needs to be shared with some other people out of my project group. It could be handed over by USB or mail etc. That does not matter to me.
My problem is, that i used fully written paths in my makefile ("/home/name/.../project/.../src/etc.") to connect libraries and src-files in my Project.
Now I want to know, if its possible to change the fully written path to something else, so other people does not have to change those fully written path.
It would be very helpfully, if you have any suggestions of what I can do.
You could use environment variables such as ${HOME}
to replace /home/name
and anything relating to the environment.
As for the rest of the fully written path, either the people using the same Makefile will have to have a somewhat similar architecture or you'll have to pass parameters to your rules.
For example, you could execute make ARGS="path" all
where path is a custom path and then use ${ARGS}
which will be equivalent to path
in your all:
rule in the Makefile.
But as tripleee said, the best practice would be to use relative paths.
In that case, the Makefile could be downloaded at the root of the project and the source files created in a src
directory, like so:
.
├── Makefile
└── src
├── file1.c
└── file2.c
A (very basic) Makefile to compile all .c
files in src
using relative paths would be:
CC=gcc
SRC=./src/*.c
all:
${CC} ${SRC}