help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

‘multiple target patterns. Stop.’ error in my first makefile to use wit


From: Ted Byers
Subject: ‘multiple target patterns. Stop.’ error in my first makefile to use with GNU Make
Date: Thu, 21 Jan 2010 14:42:35 -0500

Hello

I am trying to use Gnu make on cygwin.

I put together the following based on fragments I found in the pdf manual.

=============first attempt==================================
CC = g++
sources := $(wildcard *.cpp)
objects := $(patsubst %.cpp, %.o, $(sources))

objs: $(Objects)

.PHONY: objs

%.d: %.cpp
    $(CC) -MM $(CPPFLAGS) $< > address@hidden; \
    sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < address@hidden > $@; \
    rm -f address@hidden

%.o: %.cpp
    $(CC) -c %.cpp

include $(sources:.c=.d)
=============================end==========================

I wanted this first attempt to just compile each of the compilation units to their respective object file.

With both GNU Make 3.80 and 3.81, I get the error ‘multiple target patterns. Stop.’  From the searching on the web, it seems this is a well known problem with GNU Make on Cygwin, but contrary to the info I found in my search, it happens with both 3.80 and 3.81.

I constructed my sources and objects from the following, which I found in the manual (I just made it in two steps rather than one):
objects := $(patsubst %.c,%.o,$(wildcard *.c))

The %d rule I copied directly from the manual:
Here is the pattern rule to generate a file of prerequisites (i.e., a makefile) called ‘name.d’
from a C source file called ‘name.c’:
%.d: %.c
$(CC) -M $(CPPFLAGS) $< > address@hidden; \
sed ’s,\($*\)\.o[ :]*,\1.o $@ : ,g’ < address@hidden > $@; \
rm -f address@hidden

I have not yet tried to figure out how to have a makefile work with code organized into subdirectories (e.g. include, lib1, lib2, app, &c.).

Any help would be appreciated.

Thanks

Ted

reply via email to

[Prev in Thread] Current Thread [Next in Thread]