2

I'm using MinGW 3.18 under Windows XP SP2, GNU make 3.82.

I'm trying to incorporate a value returned by a script in a path and receive an error.

This works:

PROD_DIR=$(ROOT_DIR)/PROD
version=1.1.1

PROD_SOURCE_files = \
    file1 \
    file2

PROD_TARGET_files = $(patsubst %,$(PROD_DIR)/$(version)/%,$(PROD_SOURCE_files))

This doesn't:

PROD_DIR=$(ROOT_DIR)/PROD
version=`get_version.sh`

PROD_SOURCE_files = \
    file1 \
    file2

PROD_TARGET_files = $(patsubst %,$(PROD_DIR)/$(version)/%,$(PROD_SOURCE_files))

Makefile:1359: *** multiple target patterns.  Stop.

(line 1359 is the definition of PROD_TARGET_files)

I've double-checked $(version), it has the same value in both cases, with apparently no leading/trailing blanks or newlines:

@echo [$(version)]
[1.1.1]
Joseph Stine
  • 1,022
  • 1
  • 12
  • 23
  • 4
    You have a Makefile that's (at least) 1359 lines long? That makes me want to cry! – Oliver Charlesworth Mar 25 '12 at 15:49
  • Are you sure it's set to the same value? For example, if it can't find the command it'd be set to `/bin/sh: get_version.sh: command not found` which contains colons and would cause that exact problem. – Joachim Isaksson Mar 25 '12 at 15:57

1 Answers1

3

Backticks (`) are a Bash thing, not a Make thing.

If you want to call out to an external shell, you should use the shell function:

version=$(shell get_version.sh)
Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680