delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/07/13:57:17

Date: Thu, 6 Apr 2000 12:59:00 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Jonathan Meunier <jonathanm AT corel DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Generic makefile! (Re: Reverse-compiler)
In-Reply-To: <38EB8F1B.16885EDC@corel.com>
Message-ID: <Pine.SUN.3.91.1000406125832.3003C-100000@is>
MIME-Version: 1.0
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

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)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019