Date: Thu, 6 Apr 2000 12:59:00 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Jonathan Meunier cc: djgpp AT delorie DOT com Subject: Re: Generic makefile! (Re: Reverse-compiler) In-Reply-To: <38EB8F1B.16885EDC@corel.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 5 Apr 2000, Jonathan Meunier wrote: > Make knows how to compile C files, but is there any easy way to make it > compile C++ files? Make knows how to compile C++ files as well, it recognizes .cc, .cpp, and .C (Capital C) extensions. Please try it. > What I'm doing right now is this: > > CC = gpp > CFLAGS = -Wall -O3 > > OBJS = file1.o file2.o > HEADS = file1.h file2.h > > file.exe: $(OBJS) > $(CC) $(CFLAGS) -o $@ $(OBJS) > file1.o: $(HEADS) > $(CC) $(CFLAGS) -c file1.cpp > file2.o: $(HEADS) > $(CC) $(CFLAGS) -c file2.cpp > > This gets very long in big projects.. :\ This is redundant, Make already knows all this stuff. If you have specific problems, please report them. > There must be a way to simply > tell make to take each .cpp file and compile them with gpp with those > flags. You don't need gpp to compile, only to link. And in a Makefile, this isn't really a problem: you can simply add -lstdcxx to the LDLIBS variable, like this: LDLIBS = -lstdcxx Alternatively, say this: LINK.cc = gpp $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) LINK.cpp = gpp $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)