makefile判斷絕對路徑。
# VAR = /a/b/c/d
# $(eval REMAINDER := $$$(VAR)) # variable minus the first char
# FIRST := $(subst $(REMAINDER),,$(VAR)) # variable minus that
currentdir=/a/b/e/f/g
FIRST=$(shell echo $(currentdir) | head -c 1)
FIRST := $(subst p,q,$(FIRST))
FIRST := $(subst /,p,$(FIRST))
ifeq ($(FIRST),p)
else
endif
currentdir2=e:/tmp/abc/def
SECOND := $(shell echo $(currentdir2) | head -c 2)
SECOND := $(shell echo $(SECOND) | tail -c 2)
SECOND := $(subst p,q,$(SECOND))
SECOND := $(subst :,p,$(SECOND))
ifeq($(SECOND),p)
else
endif
all:
@echo $(FIRST)
@echo $(SECOND)