Makefile中获取当前所在目录的文件夹名

在Makefile中获取当前目录名(不含绝对路径),例如:

cd /prj/user/examples;

在Makefile中用以下命令:

DIRNAME = $(notdir $(shell pwd))

debug:

  @echo "DIRNAME=$(DIRNAME)"

执行make debug, 会打印:

DIRNAME=examples

posted on 2025-12-15 16:48  lybinger  阅读(0)  评论(0)    收藏  举报

导航