How to pass args or environment variables with Makefile and make command on #Linux

arg in Makefile

$(FOO)

env variable

FOO=BAR make

command arg

make FOO=BAR

Makefile

send:
	echo $(MESSAGE1) $(MESSAGE2)

Run

$ make send MESSAGE1=YES MESSAGE2=OK
echo YES OK
YES OK
$ make send MESSAGE1= MESSAGE2=
echo

$ make send
echo

environment variable

# specify env variables directly

$ MESSAGE1=YES MESSAGE2=OK make send
echo YES OK
YES OK

$ MESSAGE1=YES make send MESSAGE2=OK
echo YES OK
YES OK

# args overwrite env ?

$ MESSAGE1=NO MESSAGE2=NG make send
echo NO NG
NO NG
$ MESSAGE1=NO MESSAGE2=NG make send MESSAGE1=YES MESSAGE2=OK
echo YES OK
YES OK

# export env variable works

$ export MESSAGE1=YES
$ make send
echo YES
YES

$ export MESSAGE2=OK
$ make send
echo YES OK
YES OK

Ref

makefile - Passing additional variables from command line to make - Stack Overflow

JP

How to pass arguments to the make command

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2831

Recommended Posts

How to pass args or environment variables with Makefile and make command on #Linux
How to copy and paste command line content without mouse in bash on Linux or mac
How to build Java environment on Ubuntu (Linux)
How to make Linux compatible with Japanese keyboard
How to prepare an environment with different python version and package for each project with pyenv-virtualenv on Amazon Linux
Yum command to access MySQL with Python 3 on Linux
How to pass matplotlib backend settings in environment variables
How to build a Python environment on amazon linux 2
[Linux] How to display CPU usage, display header, and not display grep process with ps command
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
A memo on how to easily prepare a Linux exercise environment
[Python] How to play with class variables with decorator and metaclass
[For beginners] How to use for statements on Linux (variables, etc.)
Minimum Makefile and buildout.cfg to create an environment with buildout
How to deal with the problem that pandas 1.1.0 or later build fails on Alpine Linux
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
How to install nkf with rpm file on Red Hat Enterprise Linux 7.7 (for non-internet environment)
How to display a specified line of a file or command result on Linux (sed, awk)
How to make a command to read the configuration file with pyramid
How to make a surveillance camera (Security Camera) with Opencv and Python
How to install VMware-Tools on Linux
How to use Serverless Framework & Python environment variables and manage stages
How to run Jupyter and Spark on Mac with minimal settings
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
How to display PDF resolution and detailed information on Linux (pdfinfo)
How to get all traffic through VPN with OpenVPN on Linux
How to pass arguments using an instance with systemd's systemctl command
How to use Python with Jw_cad (Part 2 Command explanation and operation)
How to build Python and Jupyter execution environment with VS Code
How to read environment variables from .env file in PyCharm (on Mac)
Build Linux on a Windows environment. Steps to install Laradock and migrate
How to access environment variables in Python
How to install aws-session-manager-plugin on Manajro Linux
Fractal to make and play with Python
[Linux] How to use the echo command
How to use the Linux grep command
How to update php on Amazon linux 2
How to display emoji on Manjaro Linux
How to install packages on Alpine Linux
How to install Anisble on Amazon Linux 2
[Python / Tkinter] How to pass arguments to command
How to power off Linux with Ultra96-V2
How to update security on CentOS Linux 8
How to install php7.4 on Linux (Ubuntu)
"How to pass PATH" to learn with homebrew
How to use CUT command (with sample)
How to find large files on Linux
How to get started with laravel (Linux)
A command to specify a file with a specific name in a directory with find and mv, cp, or gzip it (linux)
Useful for changing permissions on Linux! How to count up to 31 with one hand.
How to make VS Code aware of the venv environment and its benefits
How to pass the path to the library built with pyenv and virtualenv in PyCharm
"OZV study session LT" "Linux" process and priority to know with nice command
How to write environment variables that you don't want to put on [GitHub] Python
LINUX: How to make arrow keys correspond to 2,4,6,8 on a notebook without a numeric keypad
Introduce VS Code and Remote Development to an offline environment to make linux development comfortable
How to run a Django application on a Docker container (development and production environment)
Build a TensorFlow development environment on Amazon EC2 with command copy and paste
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
How to make an embedded Linux device driver (11)
How to debug with Jupyter or iPython Notebook