Reputation: 681
So in a makefile, if you want to get the directory just above you, you can do:
UP_ONE_DIR := $(subst $(notdir $(CURDIR)),,$(CURDIR))
The problem is, it ends with an '/' ending slash. Is there a pattern to remove this slash from the UP_ONE_DIR variable?
Upvotes: 2
Views: 1022
Reputation: 100956
It's not a great idea to use subst
because it can match multiple identical strings, for example if your path was /foo/bar/foo/bar
or whatever. You can use:
UP_ONE_DIR := $(patsubst %/,%,$(dir $(CURDIR)))
Upvotes: 3