Reputation: 565
I want to write a make file to compile my source code. I have to put in my make file the includes paths but i have a lot of folders with source codes. In make file i have a list with all .c files like this :
__MDA_SRC = \
$(__VIEWPATH)\f_03\test\mda\src\mda.c
now i need to find out the path of this file.
I tried this one :
__PATHS_FEATURE = \
$(dir $(__MDA_SRC ))
__INCLUDE_PATHES := \
-I$(__PATHS_FEATURE)
but i have an error F100: cannot open ...bla bla..
i supposed that the problem is on the path, because the path is extructed with the last backslash like:
..\..\..\..\..\f_03\test\mda\src\
How could i have the path without the last backslash like this :
..\..\..\..\..\f_02\hydraulic\btc\src
Upvotes: 14
Views: 13872
Reputation: 73
This may not work for your problem since your path is not absolute, however the 'abspath' and 'realpath' indirectly do what you are looking for. 'realpath' will remove the last forward slash as well as any . .. or repeated /
pathwslash=/dirs/and/more/dirs/
path=$(realpath $(pathwslash))
echo $(path) # /dirs/and/more/dirs
Here is some documentation for some other functions that may be helpful: https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html
Upvotes: 3
Reputation: 81012
That seems unlikely to be the problem to me but you can remove it with
$(__PATHS_FEATURE:\=)
or
$(patsubst %\,%,$(__PATHS_FEATURE))
Upvotes: 17