Q:

Makefile with sed throwing *** target pattern contains no '%'. Stop

I have a Makefile in which I need to pass an image name to another script but the issue is, Image Name has : and - in its line for eg: image.name-v1:latest. As per google make file having : in variable causes issue. How to resolve this issue in Makefile. Below is the sample code that I am trying in which IMAGE has image.name-v1:latest
IMAGE2 ?= ''
.PHONY: image
image:
    IMAGE2 := $(subst :,\:,$(IMAGE_R)) ## IMAGE_R is a run time variable for make target
    rr/image.sh $(IMAGE2)

Error:
IMAGE2 := docker-rs\:latest ## Test Image using Image Reference
/bin/sh: 1: IMAGE2: not found
Makefile:75: recipe for target 'image' failed
make: *** [image] Error 127

SHELL SCRIPT: image.sh
#!/bin/bash
set -ex
IMAGE="$1"
echo "Image:  $IMAGE"

A:

You could try escaping the colon like this:
# Mock IMAGE with colon in name
IMAGE := test:123
# Create new variable adding an escapeing slash
IMAGE2 := $(subst :,\:,$(IMAGE))

# Use IMAGE2 from here on
$(info IMAGE $(IMAGE))
$(info IMAGE2 $(IMAGE2))

.PHONY: xyz-pp
xyz-pp: $(IMAGE2)

.PHONY: $(IMAGE2)
$(IMAGE2):
    @echo "1234" > $(IMAGE2)
    @ls
    @rr/image.sh $(IMAGE2)

I added a script in sub folder rr:
echo "------------- SCRIPT ----------"
echo PARAM: $1
echo $(find -name "$1")
echo "------------- SCRIPT ----------"

output:
> make
IMAGE test:123
IMAGE2 test\:123
makefile  rr  test:123
------------- SCRIPT ----------
PARAM: test:123
./test:123
------------- SCRIPT ----------

So here I just replace ":" with ":" into a variable IMAGE2 and then use that.
Note: I tested this by just echo'ing your command (since I don't have that file) and touch'ing IMAGE2 to create the file

