44

I have searched this problem in google, but still don't have some way to resolve a problem. I have 2 Makefiles: One as example and one as my file. Example:

BINDDIR=/src/binding
XBUILD=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
PROJECT_ROOT=XMBindingLibrarySample
PROJECT=$(PROJECT_ROOT)/XMBindingLibrarySample.xcodeproj
TARGET=XMBindingLibrarySample
BTOUCH=/Developer/MonoTouch/usr/bin/btouch

 XMBindingLibrary.dll
libXMBindingLibrarySample-i386.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator -configuration Release clean build -mv $(PROJECT_ROOT)/build/Release-iphonesimulator/lib$(TARGET).a $@
libXMBindingLibrarySample-armv6.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv6 -configuration Release clean      build -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@

libXMBindingLibrarySample-armv7.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv7 -configuration Release clean build -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@

libXMBindingLibrarySampleUniversal.a: libXMBindingLibrarySample-armv7.a libXMBindingLibrarySample-i386.a
lipo -create -output $@ $^

XMBindingLibrary.dll: AssemblyInfo.cs XMBindingLibrarySample.cs extras.cs libXMBindingLibrarySampleUniversal.a

$(BTOUCH) -unsafe --outdir=tmp -out:$@ XMBindingLibrarySample.cs -x=AssemblyInfo.cs -x=extras.cs --link-with=libXMBindingLibrarySampleUniversal.a,libXMBindingLibrarySampleUniversal.a

clean:
-rm -f *.a *.dll

My file:

BTOUCH=/Developer/MonoTouch/usr/bin/btouch
BINDDIR=/src/binding
XBUILD=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
PROJECT_ROOT=IIViewDeckControllerSample
PROJECT=$(PROJECT_ROOT)/IIViewDeckController.xcodeproj
TARGET=IIViewDeckController

all: IIViewDeckController.dll

libIIViewDeckController-i386.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator -configuration Release clean build -mv $(PROJECT_ROOT)/build/Release-iphonesimulator/lib$(TARGET).a $@

libIIViewDeckController-armv7.a:
$(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv7 -configuration Release clean build  -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@

libIIViewDeckControllerUniversal.a: libIIViewDeckController-armv7.a libIIViewDeckController-i386.a
lipo -create -output $@ $^

IIViewDeckController.dll: AssemblyInfo.cs APIDefinition.cs StructsAndEnums.cs libIIViewDeckControllerUniversal.a
$(BTOUCH) -unsafe  -out:$@ APIDefinition.cs -x=AssemblyInfo.cs -x=StructsAndEnums.cs --link-with=libIIViewDeckControllerUniversal.a,libIIViewDeckControllerUniversal.a

clean:
-rm -f *.a *.dll

With example file everything is OK, with mine I have Error:

Makefile:4: *** target pattern contains no `%'.  Stop.
make: *** [all] Error 2
Mike
  • 2,547
  • 3
  • 16
  • 30
  • 1
    Spaces and tabs are significant in Makefiles, so can you upload these two files somewhere that doesn't eat whitespace? (gist.github.com or pastebin.com for instance). – Rolf Bjarne Kvinge Feb 27 '13 at 14:05
  • 1
    Or better, do an accurate copy-and-paste of the actual makefiles into the question. Better still, *simplify them*, and give us the smallest, simplest makefile that produces the error. – Beta Feb 27 '13 at 14:37
  • I didn't know about tabs. Thank you for replying. tabs fixed error make: *** [all] Error 2. – Mike Feb 28 '13 at 07:32
  • First problem was still existed.Example: https://github.com/xamarin/monotouch-samples/blob/master/BindingSample/src/binding/Makefile. My makefile:https://github.com/mkovalyk/IIViewDeckControllerBinding/blob/master/src/binding/Makefile – Mike Feb 28 '13 at 08:02
  • 2
    I know I'm two years late, but this is likely to be spaces used rather than tabs. Replace any spaces before commands with tabs. – gingerCodeNinja Jun 13 '15 at 15:11
  • "Spaces and tabs are significant in Makefiles" - Thanks, @RolfBjarneKvinge that comment spotted what I was doing wrong. – Luis Milanese May 15 '17 at 14:43

9 Answers9

52

This is a badly written error message from Make. It means "one of your filenames had a character that could be part of a regular expression". Make is very naive about filesystems and quoting. It doesn't believe that:

foo:  'The bar.'

refers to a literal string. It takes The as one word, bar. as another word, and then barfs on the period. Do this instead:

foo:  The\ bar\.

or in your case, backslash to the period in .xcodeproj.

Smi
  • 13,850
  • 9
  • 56
  • 64
Charles Merriam
  • 19,908
  • 6
  • 73
  • 83
  • 9
    Most of this answer is not right. First, make doesn't know anything about regular expressions and makes no use of them. Second, make won't "barf on the period"; make doesn't care about period characters; it treats them just like any other normal character (in virtually every context--certainly this one). Third, if you show `'the bar.'` in your prerequisites that's considered two prerequisites: first is `'the` and second is `bar.'` (note the quotes are included!) The accurate part of this answer is that make _is_ very naive about quoting :). – MadScientist Oct 18 '20 at 20:03
  • 1
    Sorry, post examples or have a more civil tone. – Charles Merriam Oct 19 '20 at 21:49
  • 5
    There's nothing uncivil in my comment. It's simply a fact that make doesn't support regular expressions, and that make won't "barf" on periods (I mean, it's hard to find _any_ makefile that doesn't have at least one prerequisite containing a period!! Clearly they work!), and that it will include literal quotes in quoted prerequisites. I don't really know what you mean by "post examples". – MadScientist Oct 20 '20 at 04:50
46

This won't work:

default:
        echo "Hello world!"

This will:

default:
	echo "Hello world!"

Can you spot the difference?

That's right, the first one has spaces, the second one has tabs. The one with spaces will give you:

Makefile:2: *** missing separator. Stop.

And this is why we cannot have nice things...

Jeroen
  • 60,696
  • 40
  • 206
  • 339
  • 3
    GNU make has supported a feature (`.RECIPEPREFIX`) to avoid this common error for >10 years now (since GNU make 3.82). But, most people don't use it. – MadScientist Oct 18 '20 at 20:05
20

This error occurred for me because I had a rule of the form

foo: bar:
        baz

(note the trailing :).

Resigned June 2023
  • 4,638
  • 3
  • 38
  • 49
11

Make sure there is no : in your path, i.e. cd ${url} => ://. If so, escape it like this:

cd ${url} => \://
danius
  • 2,664
  • 27
  • 33
RzR
  • 3,068
  • 29
  • 26
1

Saw the issue when your source files are contained in directory whose name contains colon (:).

Alok Prasad
  • 622
  • 7
  • 12
1

Another cause of this message: Absolute pathnames

I had an IDE-generated project created on a Windows PC, pushed to github, and then cloned on a Mac. I got the same message ("*** target pattern contains no '%'.").

In my case, it was because the Makefile contained absolute pathnames of the form "C:/Users/...".

The fix was to remove the offending files from the IDE project then re-add them, but being sure to specify relative pathnames.

(I know this is far off the OP's issue, but the error message was the same, and this might be helpful to someone else.)

fearless_fool
  • 33,645
  • 23
  • 135
  • 217
0

I had this problem if there was a colon in the target file name (i.e. a time stamp), for example:

 all: foo_01:34.txt
 
 foo_%.txt: bar_%.txt
      foobar $< > $@

I had to escape it:

 all: foo_01\:34.txt
 
 foo_%.txt: bar_%.txt
      foobar $< > $@
Mark Lakata
  • 19,989
  • 5
  • 106
  • 123
-2

Solved: just go to the project tab it will present on vertical tab section then go to general and just change the location of project

-4

Drop the line 11 on https://github.com/mkovalyk/IIViewDeckControllerBinding/blob/master/src/binding/Makefile. %' is not recognised by make

Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85
  • yes,but it doesn't help. **Makefile:4: *** target pattern contains no `%'. Stop. ** is still exist. – Mike Feb 28 '13 at 08:55
  • you Makefile is fine here. what's the output of `make --version` on your mac ? Are you using GNU make ? Do you have xcode command line tools installed ? – Stephane Delcroix Feb 28 '13 at 12:01