delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/05/18:03:41

Message-ID: <38EB8F1B.16885EDC@corel.com>
Date: Wed, 05 Apr 2000 15:08:11 -0400
From: Jonathan Meunier <jonathanm AT corel DOT com>
X-Mailer: Mozilla 4.7 [en] (Win95; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Generic makefile! (Re: Reverse-compiler)
References: <8c3eae$j1l$1 AT news6 DOT svr DOT pol DOT co DOT uk> <8c457a$162$1 AT news7 DOT svr DOT pol DOT co DOT uk> <8caj5q$ii3$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <8cb2cm$t25$1 AT news6 DOT svr DOT pol DOT co DOT uk> <krflesoh3bp0b7p47ss14ki2rce8cp245a AT 4ax DOT com> <38EB7931 DOT C8B9E132 AT is DOT elta DOT co DOT il>
NNTP-Posting-Host: 120.150.3.42
X-Trace: 5 Apr 2000 15:08:37 -0500, 120.150.3.42
Lines: 40
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
> 
> Damian Yerrick wrote:
> >
> > %.o: %.c $(HEADS)
> >         gcc $(CFLAGS) -o $@ -c $<
> 
> This rule is redundant: Make knows how to compile .c files into .o files
> without your telling it.  It also knows that every .o file depends on the
> corresponding .c file.  The only piece of knowledge you need to convey to
> Make is that the .o files depend on the headers.  Here's how you do that:
> 
> $(OBJS): $(HEADS)
> 
> That's it!  Do NOT put any commands under this line, because this isn't a
> rule, it's just a dependency description.

Make knows how to compile C files, but is there any easy way to make it
compile C++ files? 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.. :\  There must be a way to simply
tell make to take each .cpp file and compile them with gpp with those
flags.

Thanks,
	.(Trancelucid).
	  .  Jaune  .

- Raw text -


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