I
I
Igor Lebedev2021-07-30 18:39:23
Command line
Igor Lebedev, 2021-07-30 18:39:23

How to make target arguments in Makefile?

I'm making a makefile, for example, to manage docker.

I want to make restartreload all containers, make restart webonly the container I need (there are an unlimited number of them).

Something rummaged through the entire manual, but got completely confused

as a shell bin/sh, notbin/bash

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-07-30
@jcmvbkbc

It is most logical to pass the target parameters through a variable. Something like that:

$ cat Makefile
CONTAINER ?= all
restart:
        @echo 'Restarting $(CONTAINER)'
$ make restart
Restarting all
$ make restart CONTAINER=web
Restarting web

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question