15
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Makefileのディレクトリから親のディレクトリの絶対パスを取得する

Last updated at Posted at 2020-01-29

概要

Makefile内のスクリプトで親のディレクトリの絶対パスを取得する方法のメモ

コード

# Makefileの存在するディレクトリ
MAKEFILE_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# 一つ上のディレクトリ
PARENT_DIR := $(shell dirname ${MAKEFILE_DIR})

メモ

  • $(shell dirname ディレクトリ)でディレクトリの親のパスが取得できます

    • 親の親のディレクトリとかも可能です
  • pwd${CURDIR}を使用するとMakefileのディレクトリではなく、makeコマンドを実行したディレクトリが基準となるので注意

15
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?