Target is not bind to automatic variable in Makefile job expanded by macro
I'm trying to write jobs that contain a lot of similarities as below.
EMACS_VERS := 22.1 23.4 24.5 25.3 26.1
LOCAL_LISPDIRS := $(patsubst %,local/%/site-lisp,$(EMACS_VERS))
$(addsuffix /leaf, $(LOCAL_LISPDIRS)): site-lisp/leaf
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /orglyth, $(LOCAL_LISPDIRS)): site-lisp/orglyth
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /cort, $(LOCAL_LISPDIRS)): site-lisp/cort
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
However, when those job was expanded by below macro, the target name was not bind to the automatic variable, and an error occurred.
define build_repo
$1: $2
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
endef
$(eval $(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf))
$(eval $(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth))
$(eval $(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort))
The above code gets the following error. As I think, this happens because the name of the target is not an automatic variable bound.
mkdir -p
usage: mkdir [-pv] [-m mode] directory ...
make: *** [Makefile:72: local/22.1/site-lisp/leaf.el] Error 64
Is there a way to solve this problem?
On the other hand, the following code has been rejected as changes to leaf, orglyth, cort are all generated when change files in only leaf.
REPOS := leaf orglyth cort
REPODIRS := $(addprefix site-lisp/, $(REPOS))
LOCAL_REPOS := $(foreach repo, $(REPOS), $(addsuffix /$(repo), $(LOCAL_LISPDIRS)))
$(LOCAL_REPOS): $(REPODIRS)
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
Directory tree:
local
├── 22.1
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 23.4
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 24.5
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 25.3
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
└── 26.1
└── site-lisp
├── cort
├── leaf
└── orglyth
site-lisp
├── cort
├── leaf
└── orglyth
makefile sh
add a comment |
I'm trying to write jobs that contain a lot of similarities as below.
EMACS_VERS := 22.1 23.4 24.5 25.3 26.1
LOCAL_LISPDIRS := $(patsubst %,local/%/site-lisp,$(EMACS_VERS))
$(addsuffix /leaf, $(LOCAL_LISPDIRS)): site-lisp/leaf
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /orglyth, $(LOCAL_LISPDIRS)): site-lisp/orglyth
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /cort, $(LOCAL_LISPDIRS)): site-lisp/cort
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
However, when those job was expanded by below macro, the target name was not bind to the automatic variable, and an error occurred.
define build_repo
$1: $2
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
endef
$(eval $(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf))
$(eval $(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth))
$(eval $(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort))
The above code gets the following error. As I think, this happens because the name of the target is not an automatic variable bound.
mkdir -p
usage: mkdir [-pv] [-m mode] directory ...
make: *** [Makefile:72: local/22.1/site-lisp/leaf.el] Error 64
Is there a way to solve this problem?
On the other hand, the following code has been rejected as changes to leaf, orglyth, cort are all generated when change files in only leaf.
REPOS := leaf orglyth cort
REPODIRS := $(addprefix site-lisp/, $(REPOS))
LOCAL_REPOS := $(foreach repo, $(REPOS), $(addsuffix /$(repo), $(LOCAL_LISPDIRS)))
$(LOCAL_REPOS): $(REPODIRS)
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
Directory tree:
local
├── 22.1
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 23.4
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 24.5
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 25.3
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
└── 26.1
└── site-lisp
├── cort
├── leaf
└── orglyth
site-lisp
├── cort
├── leaf
└── orglyth
makefile sh
1
Your macro is expanded twice. Double all$
signs.
– Renaud Pacalet
Nov 23 '18 at 17:13
add a comment |
I'm trying to write jobs that contain a lot of similarities as below.
EMACS_VERS := 22.1 23.4 24.5 25.3 26.1
LOCAL_LISPDIRS := $(patsubst %,local/%/site-lisp,$(EMACS_VERS))
$(addsuffix /leaf, $(LOCAL_LISPDIRS)): site-lisp/leaf
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /orglyth, $(LOCAL_LISPDIRS)): site-lisp/orglyth
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /cort, $(LOCAL_LISPDIRS)): site-lisp/cort
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
However, when those job was expanded by below macro, the target name was not bind to the automatic variable, and an error occurred.
define build_repo
$1: $2
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
endef
$(eval $(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf))
$(eval $(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth))
$(eval $(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort))
The above code gets the following error. As I think, this happens because the name of the target is not an automatic variable bound.
mkdir -p
usage: mkdir [-pv] [-m mode] directory ...
make: *** [Makefile:72: local/22.1/site-lisp/leaf.el] Error 64
Is there a way to solve this problem?
On the other hand, the following code has been rejected as changes to leaf, orglyth, cort are all generated when change files in only leaf.
REPOS := leaf orglyth cort
REPODIRS := $(addprefix site-lisp/, $(REPOS))
LOCAL_REPOS := $(foreach repo, $(REPOS), $(addsuffix /$(repo), $(LOCAL_LISPDIRS)))
$(LOCAL_REPOS): $(REPODIRS)
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
Directory tree:
local
├── 22.1
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 23.4
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 24.5
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 25.3
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
└── 26.1
└── site-lisp
├── cort
├── leaf
└── orglyth
site-lisp
├── cort
├── leaf
└── orglyth
makefile sh
I'm trying to write jobs that contain a lot of similarities as below.
EMACS_VERS := 22.1 23.4 24.5 25.3 26.1
LOCAL_LISPDIRS := $(patsubst %,local/%/site-lisp,$(EMACS_VERS))
$(addsuffix /leaf, $(LOCAL_LISPDIRS)): site-lisp/leaf
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /orglyth, $(LOCAL_LISPDIRS)): site-lisp/orglyth
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
$(addsuffix /cort, $(LOCAL_LISPDIRS)): site-lisp/cort
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
However, when those job was expanded by below macro, the target name was not bind to the automatic variable, and an error occurred.
define build_repo
$1: $2
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
endef
$(eval $(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf))
$(eval $(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth))
$(eval $(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort))
The above code gets the following error. As I think, this happens because the name of the target is not an automatic variable bound.
mkdir -p
usage: mkdir [-pv] [-m mode] directory ...
make: *** [Makefile:72: local/22.1/site-lisp/leaf.el] Error 64
Is there a way to solve this problem?
On the other hand, the following code has been rejected as changes to leaf, orglyth, cort are all generated when change files in only leaf.
REPOS := leaf orglyth cort
REPODIRS := $(addprefix site-lisp/, $(REPOS))
LOCAL_REPOS := $(foreach repo, $(REPOS), $(addsuffix /$(repo), $(LOCAL_LISPDIRS)))
$(LOCAL_REPOS): $(REPODIRS)
mkdir -p $(@D)
cp -rf site-lisp/$(@F) $@
$(MAKE) --no-print-directory -C $(dir $(@D)) .make-repo-$(@F)
Directory tree:
local
├── 22.1
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 23.4
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 24.5
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
├── 25.3
│ └── site-lisp
│ ├── cort
│ ├── leaf
│ └── orglyth
└── 26.1
└── site-lisp
├── cort
├── leaf
└── orglyth
site-lisp
├── cort
├── leaf
└── orglyth
makefile sh
makefile sh
edited Nov 25 '18 at 16:43
Conao3
asked Nov 23 '18 at 16:28
Conao3Conao3
83316
83316
1
Your macro is expanded twice. Double all$
signs.
– Renaud Pacalet
Nov 23 '18 at 17:13
add a comment |
1
Your macro is expanded twice. Double all$
signs.
– Renaud Pacalet
Nov 23 '18 at 17:13
1
1
Your macro is expanded twice. Double all
$
signs.– Renaud Pacalet
Nov 23 '18 at 17:13
Your macro is expanded twice. Double all
$
signs.– Renaud Pacalet
Nov 23 '18 at 17:13
add a comment |
2 Answers
2
active
oldest
votes
Your macro is expanded twice. Double all $
signs to escape the first expansion.
As you have two nested loops (versions and repos) it would be difficult to use pattern rules instead of macros. But you can probably use macros a bit more efficiently:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
Or:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p local/$(2)/site-lisp
cp -rf site-lisp/$(1) local/$(2)/site-lisp/$(1)
$(MAKE) --no-print-directory -C local/$(2) .make-repo-$(1)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
The second version does not need any $
escape because everything is correctly and completely expanded at the first expansion. Yes, even $(MAKE)
that, most likely in your case, expands the same during the first or the second expansion.
But remember that this is a special case. If you continue using the $(eval...)
function do not forget the double expansion...
Awesome!! Your code worked perfectly, and I think it's a very smart code!!
– Conao3
Nov 23 '18 at 19:02
add a comment |
Thanks @Renaud Pacelet for your good reply!
define build_repo
$1: $2;
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf)
$(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth)
$(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort)
With this code I got what I wanted without error. But is there a smarter another way to not use macros?
[Additional notes]
I looked at the answer of @Renaud Pacalet and reconcidered.
Actually, when repositories are changed, I have to build on all versions, so I can do one loop as follows.
LOCALDIRS := $(addprefix local/, $(EMACS_VERS))
define build_repo
$(addsuffix /site-lisp/$(1), $(LOCALDIRS)): $(LISPDIR)/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach repo, $(REPOS), $(eval $(call build_repo,$(repo))))
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450137%2ftarget-is-not-bind-to-automatic-variable-in-makefile-job-expanded-by-macro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your macro is expanded twice. Double all $
signs to escape the first expansion.
As you have two nested loops (versions and repos) it would be difficult to use pattern rules instead of macros. But you can probably use macros a bit more efficiently:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
Or:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p local/$(2)/site-lisp
cp -rf site-lisp/$(1) local/$(2)/site-lisp/$(1)
$(MAKE) --no-print-directory -C local/$(2) .make-repo-$(1)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
The second version does not need any $
escape because everything is correctly and completely expanded at the first expansion. Yes, even $(MAKE)
that, most likely in your case, expands the same during the first or the second expansion.
But remember that this is a special case. If you continue using the $(eval...)
function do not forget the double expansion...
Awesome!! Your code worked perfectly, and I think it's a very smart code!!
– Conao3
Nov 23 '18 at 19:02
add a comment |
Your macro is expanded twice. Double all $
signs to escape the first expansion.
As you have two nested loops (versions and repos) it would be difficult to use pattern rules instead of macros. But you can probably use macros a bit more efficiently:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
Or:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p local/$(2)/site-lisp
cp -rf site-lisp/$(1) local/$(2)/site-lisp/$(1)
$(MAKE) --no-print-directory -C local/$(2) .make-repo-$(1)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
The second version does not need any $
escape because everything is correctly and completely expanded at the first expansion. Yes, even $(MAKE)
that, most likely in your case, expands the same during the first or the second expansion.
But remember that this is a special case. If you continue using the $(eval...)
function do not forget the double expansion...
Awesome!! Your code worked perfectly, and I think it's a very smart code!!
– Conao3
Nov 23 '18 at 19:02
add a comment |
Your macro is expanded twice. Double all $
signs to escape the first expansion.
As you have two nested loops (versions and repos) it would be difficult to use pattern rules instead of macros. But you can probably use macros a bit more efficiently:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
Or:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p local/$(2)/site-lisp
cp -rf site-lisp/$(1) local/$(2)/site-lisp/$(1)
$(MAKE) --no-print-directory -C local/$(2) .make-repo-$(1)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
The second version does not need any $
escape because everything is correctly and completely expanded at the first expansion. Yes, even $(MAKE)
that, most likely in your case, expands the same during the first or the second expansion.
But remember that this is a special case. If you continue using the $(eval...)
function do not forget the double expansion...
Your macro is expanded twice. Double all $
signs to escape the first expansion.
As you have two nested loops (versions and repos) it would be difficult to use pattern rules instead of macros. But you can probably use macros a bit more efficiently:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
Or:
# $(1): repo
# $(2): version
define build_repo
local/$(2)/site-lisp/$(1): site-lisp/$(1)
mkdir -p local/$(2)/site-lisp
cp -rf site-lisp/$(1) local/$(2)/site-lisp/$(1)
$(MAKE) --no-print-directory -C local/$(2) .make-repo-$(1)
endef
$(foreach r,$(REPOS),$(foreach v,$(EMACS_VERS),$(eval $(call build_repo,$(r),$(v)))))
The second version does not need any $
escape because everything is correctly and completely expanded at the first expansion. Yes, even $(MAKE)
that, most likely in your case, expands the same during the first or the second expansion.
But remember that this is a special case. If you continue using the $(eval...)
function do not forget the double expansion...
edited Nov 23 '18 at 18:18
answered Nov 23 '18 at 18:13
Renaud PacaletRenaud Pacalet
9,24321729
9,24321729
Awesome!! Your code worked perfectly, and I think it's a very smart code!!
– Conao3
Nov 23 '18 at 19:02
add a comment |
Awesome!! Your code worked perfectly, and I think it's a very smart code!!
– Conao3
Nov 23 '18 at 19:02
Awesome!! Your code worked perfectly, and I think it's a very smart code!!
– Conao3
Nov 23 '18 at 19:02
Awesome!! Your code worked perfectly, and I think it's a very smart code!!
– Conao3
Nov 23 '18 at 19:02
add a comment |
Thanks @Renaud Pacelet for your good reply!
define build_repo
$1: $2;
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf)
$(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth)
$(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort)
With this code I got what I wanted without error. But is there a smarter another way to not use macros?
[Additional notes]
I looked at the answer of @Renaud Pacalet and reconcidered.
Actually, when repositories are changed, I have to build on all versions, so I can do one loop as follows.
LOCALDIRS := $(addprefix local/, $(EMACS_VERS))
define build_repo
$(addsuffix /site-lisp/$(1), $(LOCALDIRS)): $(LISPDIR)/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach repo, $(REPOS), $(eval $(call build_repo,$(repo))))
add a comment |
Thanks @Renaud Pacelet for your good reply!
define build_repo
$1: $2;
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf)
$(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth)
$(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort)
With this code I got what I wanted without error. But is there a smarter another way to not use macros?
[Additional notes]
I looked at the answer of @Renaud Pacalet and reconcidered.
Actually, when repositories are changed, I have to build on all versions, so I can do one loop as follows.
LOCALDIRS := $(addprefix local/, $(EMACS_VERS))
define build_repo
$(addsuffix /site-lisp/$(1), $(LOCALDIRS)): $(LISPDIR)/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach repo, $(REPOS), $(eval $(call build_repo,$(repo))))
add a comment |
Thanks @Renaud Pacelet for your good reply!
define build_repo
$1: $2;
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf)
$(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth)
$(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort)
With this code I got what I wanted without error. But is there a smarter another way to not use macros?
[Additional notes]
I looked at the answer of @Renaud Pacalet and reconcidered.
Actually, when repositories are changed, I have to build on all versions, so I can do one loop as follows.
LOCALDIRS := $(addprefix local/, $(EMACS_VERS))
define build_repo
$(addsuffix /site-lisp/$(1), $(LOCALDIRS)): $(LISPDIR)/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach repo, $(REPOS), $(eval $(call build_repo,$(repo))))
Thanks @Renaud Pacelet for your good reply!
define build_repo
$1: $2;
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(call build_repo,$(addsuffix /leaf,$(LOCAL_LISPDIRS)),site-lisp/leaf)
$(call build_repo,$(addsuffix /orglyth,$(LOCAL_LISPDIRS)),site-lisp/orglyth)
$(call build_repo,$(addsuffix /cort,$(LOCAL_LISPDIRS)),site-lisp/cort)
With this code I got what I wanted without error. But is there a smarter another way to not use macros?
[Additional notes]
I looked at the answer of @Renaud Pacalet and reconcidered.
Actually, when repositories are changed, I have to build on all versions, so I can do one loop as follows.
LOCALDIRS := $(addprefix local/, $(EMACS_VERS))
define build_repo
$(addsuffix /site-lisp/$(1), $(LOCALDIRS)): $(LISPDIR)/$(1)
mkdir -p $$(@D)
cp -rf site-lisp/$$(@F) $$@
$$(MAKE) --no-print-directory -C $$(dir $$(@D)) .make-repo-$$(@F)
endef
$(foreach repo, $(REPOS), $(eval $(call build_repo,$(repo))))
edited Nov 23 '18 at 20:13
answered Nov 23 '18 at 17:46
Conao3Conao3
83316
83316
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450137%2ftarget-is-not-bind-to-automatic-variable-in-makefile-job-expanded-by-macro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Your macro is expanded twice. Double all
$
signs.– Renaud Pacalet
Nov 23 '18 at 17:13