Skip to content

Instantly share code, notes, and snippets.

@maiha
Last active October 8, 2020 20:14
Show Gist options
  • Save maiha/1eb52411744b0379fe3ea1248837dc14 to your computer and use it in GitHub Desktop.
Save maiha/1eb52411744b0379fe3ea1248837dc14 to your computer and use it in GitHub Desktop.
Makefileメモ

TL;DR

定義 事前実行 参照時 再参照
FOO=1 なし 実行 実行
FOO:=1 あり(cache) (cached) (cached)

基本

MAKE=make --no-print-directory
SHELL=/bin/bash
.SHELLFLAGS = -o pipefail -c

変数の保証

all: var/FOO
        echo ${FOO}

var/%:
        @[[ ! -z "${$*}" ]] || (echo "empty variable [$*]"; exit 1)

# 引数が数値であることを保証する
numeric/%:
        @[ "$*" -eq "$*" ] 2>/dev/null || (echo "not numeric variable [$*]"; exit 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment