"multiple target patterns" Makefile error
MakefileMakefile Problem Overview
My makefile fails with error:
Makefile:34: *** multiple target patterns. Stop.
What does it really mean, how can I fix this?
(GNU make manual, written by Captain Obvious, isn't helping).
Found it. I had rule in form:
$(FOO): bar
where FOO
was set from shell command that polluted it with error message that contained a colon.
Makefile Solutions
Solution 1 - Makefile
I had it on the Makefile
MAPS+=reverse/db.901:550:2001.ip6.arpa
lastserial: ${MAPS}
./updateser ${MAPS}
It's because of the :
in the file name.
I solved this with
-------- notice / / v v MAPS+=reverse/db.901:550:2001.ip6.arpa lastserial: ${MAPS} ./updateser ${MAPS}
Solution 2 - Makefile
Besides having to escape colons as in the original answer, I have found if the indentation is off you could potentially get the same problem. In one makefile, I had to replace spaces with a tab and that allowed me to get past the error.
Solution 3 - Makefile
I just want to add, if you get this error because you are using Cygwin make and auto-generated files, you can fix it with the following sed,
sed -e 's@\\\([^ ]\)@/\1@g' -e 's@[cC]:@/cygdrive/c@' -i filename.d
You may need to add more characters than just space to the escape list in the first substitution but you get the idea. The concept here is that /cygdrive/c is an alias for c: that cygwin's make will recognize.
And may as well throw in
-e 's@^ \+@\t@'
just in case you did start with spaces on accident (although I /think/ this will usually be a "missing separator" error).
Solution 4 - Makefile
I met with the same error. After struggling, I found that it was due to "Space" in the folder name.
For example :
Earlier My folder name was : "Qt Projects"
Later I changed it to : "QtProjects"
and my issue was resolved.
Its very simple but sometimes a major issue.
Solution 5 - Makefile
My IDE left a mix of spaces and tabs in my Makefile.
Setting my Makefile to use only tabs fixed this error for me.
Solution 6 - Makefile
I had this problem (colons in the target name) because I had -n
in my GREP_OPTIONS
environment variable. Apparently, this caused configure
to generate the Makefile
incorrectly.
Solution 7 - Makefile
I also got this error (within the Eclipse-based STM32CubeIDE on Windows).
After double-clicking on the "multiple target patterns" error it showed a path to a .ld
file. It turns out to be another "illegal character" problem. The offending character was the (wait for it): =
Heuristic of the week: use only [a..z] in your paths, as there are bound to be other illegal characters </vomit>.
The GNU make manual doesn't explicitly document this.
Solution 8 - Makefile
I got the same error and my issue was an extra whitespace and a backslash at the end of listing source files:
SRCS := ft_striteri.c \
ft_putchar_fd.c \
ft_putstr_fd.c \
ft_putendl_fd.c \
ft_putnbr_fd.c \
BONUS_SRCS := ft_lstadd_back.c \
ft_lstadd_front.c \
ft_lstlast.c \
ft_lstnew.c \
ft_lstsize.c
The correct version that works looks like this:
SRCS := ft_striteri.c \
ft_putchar_fd.c \
ft_putstr_fd.c \
ft_putendl_fd.c \
ft_putnbr_fd.c
BONUS_SRCS := ft_lstadd_back.c \
ft_lstadd_front.c \
ft_lstlast.c \
ft_lstnew.c \
ft_lstsize.c