简体   繁体   中英

VAR evaluation in Makefile

I want that make wheel print the wheel name

cat Makefile
wheel:
    @rm -fr build dist
    @python setup.py bdist_wheel
    $(eval WHEEL=$(shell find . -name '*.whl'))
    @printf '\n => wheel ready %s\n\n' $(WHEEL)

This almost work, effectively because eval is evaluated BEFORE the call to setup.py the dist folder is empty.

I've tryed with WHEEL:=$(shell find . -name '*.whl') too, same result

Use a different target to create the files. Store the command in a variable with $(shell) (you're using GNU Make, right?), using it will run the associated command:

WHEEL = $(shell find . -name '*.whl')

wheel: create_wheel
    printf '\n => wheel ready %s\n\n' $(WHEEL)

create_wheel:
    @rm -fr build dist
    @python setup.py bdist_wheel

You need to use = when assigning the command, otherwise (with := ) it will be evaluated at the beginning of the make process.

Putting the results in a variable seems completely misdirected.

wheel:
    @rm -fr build dist
    python setup.py bdist_wheel
    @printf '\n => wheel ready %s\n\n' $$(find . -name '*.whl')

The printf newlines look wacky but maybe you like spurious empty lines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM