🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3362

Makefile dependencies for multiple directories project using g++

#3362
From: Yos P.
Date: Mon, 08 Jan 2007 11:56
37 lines
1993 bytes
Hello,
I'm using this makefile to compile a C++ project (using g++):

CC = g++
CFLAGS = -Wall
OBJ = somefile.o somefile.o... somefile_in_another_dir.o...
somefile_in_another_dir.o...

all: test

.cpp.o:
	$(CC) $(CFLAGS) -c $<

test: $(OBJ)
	$(CC) $(CFLAGS) $^ -o $@

clean:
	rm -f *.o *~ test

depend:
	echo -e '\n' >> Makefile
	$(CC) -MM *.cpp >> Makefile

.PHONY: all clean

By now, all of my files were in the same directory, but since my
project grew larger I've add some sub-directories.
My questions are:
1. How do I config the depend to include dependencies from other
directories.

2. I'll be happy if anyone could remind me the g++ flags for compiling
when #include from other directories, and linking when involved .o
files from multiple directories.

Thanks,
Yos P.
Technical Details
Message-ID: <1168257415.104749.312440@42g2000cwt.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!42g2000cwt.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: fc89c,d9c06db749d745aa,start
X-Google-Thread: 10ba33,d9c06db749d745aa,start
X-Google-Attributes: gidfc89c,gid10ba33,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!42g2000cwt.googlegroups.com!not-for-mail
From: "Yos P." <yospgroups@gmail.com>
Newsgroups: comp.unix.programmer,gnu.g++.help
Subject: Makefile dependencies for multiple directories project using g++
Date: 8 Jan 2007 03:56:55 -0800
Organization: http://groups.google.com
Lines: 38
Message-ID: <1168257415.104749.312440@42g2000cwt.googlegroups.com>
NNTP-Posting-Host: 89.139.37.197
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1168257422 8322 127.0.0.1 (8 Jan 2007 11:57:02 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 8 Jan 2007 11:57:02 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: 42g2000cwt.googlegroups.com; posting-host=89.139.37.197;
   posting-account=ZdW9CQ0AAACtYq4jd232AIjMzLYBdBs0