{"id":1397,"date":"2026-07-16T15:12:09","date_gmt":"2026-07-16T06:12:09","guid":{"rendered":"https:\/\/www.ecoop.net\/memo\/?p=1397"},"modified":"2026-07-26T17:44:11","modified_gmt":"2026-07-26T08:44:11","slug":"makefile-variables-cheatsheet","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/makefile-variables-cheatsheet.html","title":{"rendered":"Makefile\u5909\u6570\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\uff1a\u81ea\u52d5\u5909\u6570 $@ $&lt; $^ \u3068 := = \u306e\u9055\u3044"},"content":{"rendered":"<p>Makefile\u3092\u66f8\u3044\u3066\u3044\u308b\u3068\u3001<code>$@<\/code> \u3084 <code>$&lt;<\/code> \u307f\u305f\u3044\u306a\u8a18\u53f7\u3084\u3001<code>=<\/code> \u3068 <code>:=<\/code> \u306e\u4f7f\u3044\u5206\u3051\u3067\u624b\u304c\u6b62\u307e\u308a\u304c\u3061\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u306f\u5909\u6570\u307e\u308f\u308a\u3060\u3051\u3092\u9006\u5f15\u304d\u3067\u307e\u3068\u3081\u305f\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\u3067\u3059\u3002\u6319\u52d5\u306f\u3059\u3079\u3066\u624b\u5143\u306e GNU Make \u3067\u5b9f\u884c\u3057\u3066\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3082\u3063\u3068\u8e0f\u307f\u8fbc\u3093\u3060\u4ed5\u69d8\u306f <a href=\"https:\/\/www.ecoop.net\/coop\/translated\/GNUMake4.4\/ch06.jp.html\">GNU Make 4.4 \u65e5\u672c\u8a9e\u30de\u30cb\u30e5\u30a2\u30eb \u7b2c6\u7ae0\u300c\u5909\u6570\u306e\u4f7f\u3044\u65b9\u300d<\/a> \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u8a18\u4e8b\u306f\u305d\u306e\u9006\u5f15\u304d\u7248\u3067\u3059\u3002<\/p>\n<h3><code>=<\/code> \u3068 <code>:=<\/code> \u306e\u9055\u3044\uff08\u3053\u3053\u3060\u3051\u306f\u62bc\u3055\u3048\u308b\uff09<\/h3>\n<p>\u3044\u3061\u3070\u3093\u5f15\u3063\u304b\u304b\u308b\u306e\u304c\u3053\u308c\u3067\u3059\u3002<\/p>\n<ul>\n<li><code>=<\/code> \u2026 \u9045\u5ef6\u5c55\u958b\u3002\u53f3\u8fba\u306f<strong>\u4f7f\u3046\u3068\u304d\u306b<\/strong>\u8a55\u4fa1\u3055\u308c\u308b\u3002<\/li>\n<li><code>:=<\/code> \u2026 \u5373\u6642\u5c55\u958b\u3002\u53f3\u8fba\u306f<strong>\u305d\u306e\u884c\u3092\u8aad\u3093\u3060\u6642\u70b9\u3067<\/strong>\u8a55\u4fa1\u3055\u308c\u308b\u3002<\/li>\n<\/ul>\n<p>\u6b21\u306e Makefile \u3067\u9055\u3044\u304c\u51fa\u307e\u3059\u3002<\/p>\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-code\"><code>DEFERRED = $(LATER)\nIMMEDIATE := $(LATER)\nLATER = value\n\ndemo:\n\t@echo \"deferred  = &#91;$(DEFERRED)]\"\n\t@echo \"immediate = &#91;$(IMMEDIATE)]\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>deferred  = &#91;value]\nimmediate = &#91;]<\/code><\/pre>\n\n\n<p><code>IMMEDIATE<\/code> \u304c\u7a7a\u306a\u306e\u306f\u3001<code>:=<\/code> \u306e\u884c\u3092\u8aad\u3093\u3060\u6642\u70b9\u3067 <code>LATER<\/code> \u304c\u307e\u3060\u672a\u5b9a\u7fa9\u3060\u304b\u3089\u3067\u3059\u3002<code>=<\/code> \u306e <code>DEFERRED<\/code> \u306f <code>demo<\/code> \u3092\u5b9f\u884c\u3059\u308b\u6642\u306b <code>LATER<\/code> \u3092\u898b\u306b\u884c\u304f\u306e\u3067 <code>value<\/code> \u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u8ff7\u3063\u305f\u3089\u57fa\u672c\u306f <code>:=<\/code> \u3092\u4f7f\u3046\u306e\u304c\u5b89\u5168\u3067\u3059\u3002\u53c2\u7167\u9806\u306b\u4f9d\u5b58\u305b\u305a\u3001\u30b7\u30a7\u30eb\u547c\u3073\u51fa\u3057\uff08\u5f8c\u8ff0\u306e <code>$(shell ...)<\/code>\uff09\u3092\u6bce\u56de\u5b9f\u884c\u3057\u3066\u3057\u307e\u3046\u4e8b\u6545\u3082\u9632\u3052\u307e\u3059\u3002<code>=<\/code> \u306f\u300c\u3042\u3068\u3067\u6c7a\u307e\u308b\u5024\u3092\u9045\u5ef6\u3055\u305b\u305f\u3044\u300d\u3068\u304d\u3060\u3051\u306b\u7d5e\u308b\u3068\u8aad\u307f\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><code>::=<\/code> \u306f <code>:=<\/code> \u3068\u540c\u3058\u610f\u5473\u3067\u3059\uff08POSIX \u3067\u6a19\u6e96\u5316\u3055\u308c\u305f\u66f8\u304d\u65b9\uff09\u3002\u3069\u3061\u3089\u3092\u4f7f\u3063\u3066\u3082\u6319\u52d5\u306f\u5909\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n<\/blockquote>\n<h3><code>?=<\/code> \u3068 <code>+=<\/code><\/h3>\n\n\n<pre class=\"wp-block-code\"><code>FLAGS := -Wall\nFLAGS += -O2\nNAME ?= default\n\ncfg:\n\t@echo \"FLAGS = $(FLAGS)\"\n\t@echo \"NAME  = $(NAME)\"<\/code><\/pre>\n\n\n<ul>\n<li><code>+=<\/code> \u2026 \u65e2\u5b58\u306e\u5024\u306b\u8ffd\u8a18\u3059\u308b\u3002\u4e0a\u306e\u4f8b\u3067\u306f <code>FLAGS<\/code> \u304c <code>-Wall -O2<\/code> \u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n<li><code>?=<\/code> \u2026 \u305d\u306e\u5909\u6570\u304c\u307e\u3060\u672a\u5b9a\u7fa9\u306e\u3068\u304d\u3060\u3051\u4ee3\u5165\u3059\u308b\u3002\u3059\u3067\u306b\u5024\u304c\u3042\u308c\u3070\u4f55\u3082\u3057\u307e\u305b\u3093\u3002<\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\"><code>$ make cfg\nFLAGS = -Wall -O2\nNAME  = default<\/code><\/pre>\n\n\n<p>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u4e0a\u66f8\u304d\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>$ make cfg NAME=custom\nFLAGS = -Wall -O2\nNAME  = custom<\/code><\/pre>\n\n\n<p><code>?=<\/code> \u306f\u300c\u30c7\u30d5\u30a9\u30eb\u30c8\u3092\u7528\u610f\u3057\u3064\u3064\u3001\u5916\u304b\u3089\u5dee\u3057\u66ff\u3048\u3089\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u300d\u7528\u9014\u306b\u3061\u3087\u3046\u3069\u5408\u3044\u307e\u3059\u3002<\/p>\n<h3>\u81ea\u52d5\u5909\u6570 <code>$@ $&lt; $^<\/code> \u306a\u3069<\/h3>\n<p>\u30eb\u30fc\u30eb\u306e\u30ec\u30b7\u30d4\u306e\u4e2d\u3067\u3060\u3051\u4f7f\u3048\u308b\u3001\u30bf\u30fc\u30b2\u30c3\u30c8\u3084\u524d\u63d0\u6761\u4ef6\u3092\u6307\u3059\u7279\u5225\u306a\u5909\u6570\u3067\u3059\u3002\u3088\u304f\u4f7f\u3046\u306e\u306f\u6b21\u306e3\u3064\u3067\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5909\u6570<\/th>\n<th>\u610f\u5473<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>$@<\/code><\/td>\n<td>\u30bf\u30fc\u30b2\u30c3\u30c8\u540d<\/td>\n<\/tr>\n<tr>\n<td><code>$&lt;<\/code><\/td>\n<td>\u6700\u521d\u306e\u524d\u63d0\u6761\u4ef6\uff08\u4f9d\u5b58\u30d5\u30a1\u30a4\u30eb\uff09<\/td>\n<\/tr>\n<tr>\n<td><code>$^<\/code><\/td>\n<td>\u3059\u3079\u3066\u306e\u524d\u63d0\u6761\u4ef6\uff08\u91cd\u8907\u3092\u9664\u304f\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n<pre class=\"wp-block-code\"><code>out.o: a.c b.c\n\t@echo \"target = $@\"\n\t@echo \"first prereq = $&lt;\"\n\t@echo \"all prereqs = $^\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>target = out.o\nfirst prereq = a.c\nall prereqs = a.c b.c<\/code><\/pre>\n\n\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\u5b9a\u7fa9\u306a\u3089\u3001\u3053\u3046\u66f8\u3051\u3070\u30bf\u30fc\u30b2\u30c3\u30c8\u3054\u3068\u306b\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u66f8\u304d\u76f4\u3055\u305a\u306b\u6e08\u307f\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>%.o: %.c\n\t$(CC) $(CFLAGS) -c $&lt; -o $@<\/code><\/pre>\n\n\n<p>\u4ed6\u306b\u3082\u3042\u308b\u81ea\u52d5\u5909\u6570:<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5909\u6570<\/th>\n<th>\u610f\u5473<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>$?<\/code><\/td>\n<td>\u524d\u63d0\u6761\u4ef6\u306e\u3046\u3061\u3001\u30bf\u30fc\u30b2\u30c3\u30c8\u3088\u308a\u65b0\u3057\u3044\u3082\u306e\u3060\u3051<\/td>\n<\/tr>\n<tr>\n<td><code>$*<\/code><\/td>\n<td>\u30d1\u30bf\u30fc\u30f3\u30eb\u30fc\u30eb\u306e <code>%<\/code> \u306b\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\uff08stem\uff09<\/td>\n<\/tr>\n<tr>\n<td><code>$(@D)<\/code> \/ <code>$(@F)<\/code><\/td>\n<td><code>$@<\/code> \u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u90e8\u5206 \/ \u30d5\u30a1\u30a4\u30eb\u540d\u90e8\u5206<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u81ea\u52d5\u5909\u6570\u306f\u6697\u9ed9\u306e\u30eb\u30fc\u30eb\u3068\u4e00\u7dd2\u306b\u4f7f\u3046\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3001\u8a73\u3057\u304f\u306f <a href=\"https:\/\/www.ecoop.net\/coop\/translated\/GNUMake4.4\/ch10.jp.html\">GNU Make 4.4 \u65e5\u672c\u8a9e\u30de\u30cb\u30e5\u30a2\u30eb \u7b2c10\u7ae0\u300c\u6697\u9ed9\u306e\u30eb\u30fc\u30eb\u306e\u4f7f\u3044\u65b9\u300d<\/a> \u304c\u53c2\u8003\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u74b0\u5883\u5909\u6570\u3068\u306e\u95a2\u4fc2<\/h3>\n<p>make \u306f\u8d77\u52d5\u6642\u306e\u74b0\u5883\u5909\u6570\u3092\u3001\u305d\u306e\u307e\u307e make \u306e\u5909\u6570\u3068\u3057\u3066\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\u3064\u307e\u308a <code>$(PATH)<\/code> \u3084 <code>$(HOME)<\/code> \u306f Makefile \u306b\u66f8\u304b\u306a\u304f\u3066\u3082\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u512a\u5148\u9806\u4f4d\u306f\u4ee5\u4e0b\u3067\u3059\uff08\u4e0b\u306b\u3044\u304f\u307b\u3069\u5f37\u3044\uff09\u3002<\/p>\n<ol>\n<li>\u74b0\u5883\u5909\u6570<\/li>\n<li>Makefile \u5185\u306e\u5b9a\u7fa9<\/li>\n<li>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u6307\u5b9a\uff08<code>make VAR=\u5024<\/code>\uff09<\/li>\n<\/ol>\n<p>\u3064\u307e\u308a Makefile \u5185\u306e <code>FOO = ...<\/code> \u306f\u3001\u540c\u540d\u306e\u74b0\u5883\u5909\u6570\u3088\u308a\u512a\u5148\u3055\u308c\u307e\u3059\uff08<code>make -e<\/code> \u3092\u4ed8\u3051\u308b\u3068\u74b0\u5883\u5909\u6570\u304c\u52dd\u3064\u3088\u3046\u306b\u9006\u8ee2\u3057\u307e\u3059\uff09\u3002<\/p>\n<p>\u5909\u6570\u304c\u3069\u3053\u7531\u6765\u304b\u3092\u8abf\u3079\u305f\u3044\u3068\u304d\u306f <code>$(origin)<\/code> \u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>src:\n\t@echo \"origin(PATH)   = $(origin PATH)\"\n\t@echo \"origin(DEBUG)  = $(origin DEBUG)\"\n\t@echo \"origin(UNDEF)  = $(origin UNDEF)\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>origin(PATH)   = environment\norigin(DEBUG)  = file\norigin(UNDEF)  = undefined<\/code><\/pre>\n\n\n<p>\u74b0\u5883\u5909\u6570\u306e\u5024\u3067\u51e6\u7406\u3092\u5206\u3051\u305f\u3044\u3068\u304d\u306f\u3001\u3053\u306e <code>origin<\/code> \u3084 <code>ifdef<\/code> \u3092\u6761\u4ef6\u5206\u5c90\u3068\u7d44\u307f\u5408\u308f\u305b\u307e\u3059\u3002\u66f8\u304d\u65b9\u306f <a href=\"\/memo\/archives\/makefile-ifeq-ifdef.html\">Makefile\u306e\u6761\u4ef6\u5206\u5c90 ifeq\/ifdef \u5b8c\u5168\u30ac\u30a4\u30c9<\/a> \u306b\u307e\u3068\u3081\u307e\u3057\u305f\u3002<\/p>\n<h3>\u304a\u307e\u3051: \u5909\u6570\u3092\u66f8\u304f\u3068\u304d\u306e\u3064\u307e\u305a\u304d<\/h3>\n<ul>\n<li>\u30ec\u30b7\u30d4\uff08\u30b3\u30de\u30f3\u30c9\u884c\uff09\u306e\u884c\u982d\u306f\u30bf\u30d6\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u30b9\u30da\u30fc\u30b9\u3060\u3068 <code>missing separator<\/code> \u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n<li><code>$<\/code> \u305d\u306e\u3082\u306e\u3092\u66f8\u304d\u305f\u3044\u3068\u304d\u306f <code>$$<\/code> \u3068\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u307e\u3059\uff08\u30b7\u30a7\u30eb\u5909\u6570\u3092\u4f7f\u3046\u30ec\u30b7\u30d4\u3067\u3088\u304f\u30cf\u30de\u308a\u307e\u3059\uff09\u3002<\/li>\n<li>\u5909\u6570\u5c55\u958b\u306f <code>$(VAR)<\/code> \u3067\u3082 <code>${VAR}<\/code> \u3067\u3082\u540c\u3058\u3067\u3059\u30021\u6587\u5b57\u5909\u6570\u306f <code>$X<\/code> \u3068\u66f8\u3051\u307e\u3059\u304c\u3001\u53ef\u8aad\u6027\u306e\u305f\u3081 <code>$(X)<\/code> \u3092\u63a8\u5968\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<h3>\u3055\u3044\u3054\u306b<\/h3>\n<p><code>=<\/code> \u3068 <code>:=<\/code> \u306e\u9055\u3044\u3001<code>$@ $&lt; $^<\/code> \u306e3\u3064\u3092\u62bc\u3055\u3048\u308c\u3070\u3001\u305f\u3044\u3066\u3044\u306e Makefile \u306f\u8aad\u3081\u307e\u3059\u3002\u4ed5\u69d8\u5168\u4f53\u306f <a href=\"https:\/\/www.ecoop.net\/coop\/translated\/GNUMake4.4\/index.jp.html\">GNU Make 4.4 \u65e5\u672c\u8a9e\u30de\u30cb\u30e5\u30a2\u30eb<\/a> \u306b\u307e\u3068\u307e\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u9006\u5f15\u304d\u3067\u8db3\u308a\u306a\u3044\u3068\u3053\u308d\u306f\u305d\u3061\u3089\u3078\u3069\u3046\u305e\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>Makefile\u3092\u66f8\u3044\u3066\u3044\u308b\u3068\u3001$@ \u3084 $&lt; \u307f\u305f\u3044\u306a\u8a18\u53f7\u3084\u3001= \u3068 := \u306e\u4f7f\u3044\u5206\u3051\u3067\u624b\u304c\u6b62\u307e\u308a\u304c\u3061\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u306f\u5909\u6570\u307e\u308f\u308a\u3060\u3051\u3092\u9006\u5f15\u304d\u3067\u307e\u3068\u3081\u305f\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\u3067\u3059\u3002\u6319\u52d5\u306f\u3059\u3079\u3066\u624b\u5143\u306e GNU Make \u3067\u5b9f\u884c &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/makefile-variables-cheatsheet.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Makefile\u5909\u6570\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\uff1a\u81ea\u52d5\u5909\u6570 $@ $&lt; $^ \u3068 := = \u306e\u9055\u3044<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[135,155],"tags":[158,163],"class_list":["post-1397","post","type-post","status-publish","format-standard","hentry","category-server","category-dev","tag-gnu-make","tag-makefile"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/1397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=1397"}],"version-history":[{"count":2,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/1397\/revisions"}],"predecessor-version":[{"id":1479,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/1397\/revisions\/1479"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=1397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=1397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=1397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}