Reputation: 11
As part of a makefile recipe I have:
@echo SOMEDIR:$(SOMEDIR)
@echo abspath:$(abspath $(SOMEDIR))
Which produces:
SOMEDIR:D:/one/two/three/../../four
abspath:D:/P4_sandbox/depot/ssg/embedded/industrial/MotorControl/ReferenceDesigns/DriveOnChip_SingleIPOneEach_SoC_FFT/software/CVSX_DS5/APP_RD/D:/one/four
I expected to get:
SOMEDIR:D:/one/two/three/../../four
abspath:D:/one/four
Why is abspath concatenating its result to the value of $(CURDIR), and how do I stop it?
Upvotes: 1
Views: 12306
Reputation: 2298
Actually, abspath is just not happy with drive-letter designations. Try it again with the D: removed. If removing D: beforehand is not possible for you, you're going to have to write a gmake macro (wrapper). Without having gmake at hand, here's an exercise in FP, defining three macros so that $(ABSPATH $(mypathvar)) works ...
_FLIP = $2 $1 _ABSPATH = $(subst \ ,:, $(strip $2 $(abspath $1))) ABSPATH = $(_ABSPATH $(FLIP $(subst :, ,$1))))
Upvotes: 2
Reputation: 81012
That's what abspath
does. It creates an absolute path. That means it must be anchored at the root. abspath
is not simply canonicalize path
.
You will need to subst
that off or something to get the behaviour you want I imagine.
Upvotes: 1