🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #1212

Re: The answer to make with multiple executables from same source files

#1212
From: Ken Weaverling
Date: Wed, 14 Nov 1990 05:20
87 lines
3167 bytes
I didn't respond to original article at first since I usually don't post
but... original article stated:

>I have two executables that depend on the same source files but are
>compiled with different CFLAGS.  Anybody have a good way to make a
>makefile understand this?
>
Then he responds to his own article with...

In article <4223@awdprime.UUCP> tif@doorstop.austin.ibm.com (Paul Chamberlain) writes:
>Well, I got it figured out.  Below I have included a makefile for
>two hypothetical executables that use the same .c's.  A fringe
>benefit is that even if you only have one executable, using this
>style of make file will allow you to remove all the .o's and it
>still won't recompile anything unless a .c or .h changed.
>
 <<< Complex makefile deleted >>>
  
Hmm, I am just a humble computer science student, but my Makefile for my
last project did what you said you wanted but is much more straight forward.
However, it *will* recompile missing .o files... It is below. It produces
two binaries, most of the modules are the same except for different compile
flags. Each one has a different main module.


# Makefile for least-cost communications anaylzer
# (project for Univ of Del, CIS 220 class)

CC = g++

#CFLAGS is *normal* flags for compiling program
#DFLAGS is compiled into the driver programs

CFLAGS = -O -g
DFLAGS = -DDEBUG -g

# OBJS is normal objects, DOBJS is debugging objects for driver program

OBJS = symtable.o main.o fileio.o table.o util.o
DOBJS = dsymtable.o dmain.o fileio.o dtable.o dutil.o

all: prog2 dprog2

prog2: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o prog2

dprog2:	$(DOBJS)
	$(CC) $(DFLAGS) $(DOBJS) -o dprog2

symtable.o: symtable.cc symtable.h general.h
	$(CC) $(CFLAGS) -c symtable.cc

table.o: table.cc table.h general.h
	$(CC) $(CFLAGS) -c table.cc

main.o: main.cc general.h symtable.h table.h util.h
	$(CC) $(CFLAGS) -c main.cc

dsymtable.o: symtable.cc symtable.h general.h
	$(CC) $(DFLAGS) -c symtable.cc -o dsymtable.o

dtable.o: table.cc table.h general.h
	$(CC) $(DFLAGS) -c table.cc -o dtable.o

dmain.o: driver.cc driver.h general.h
	$(CC) $(DFLAGS) -c driver.cc -o dmain.o

fileio.o: fileio.cc fileio.h general.h
	$(CC) $(CFLAGS) -c fileio.cc

util.o: util.cc util.h general.h fileio.h
	$(CC) $(CFLAGS) -c util.cc

dutil.o: util.cc util.h general.h fileio.h
	$(CC) $(DFLAGS) -c util.cc -o dutil.o

clean:
	rm -rf $(DOBJS) $(OBJS) prog2 dprog2 *~ core

strip:
	strip prog2 dprog2
	chmod 711 prog2 dprog2 .
	rm -rf $(OBJS) *~ core
-- 

Ken Weaverling (insert any job title here, except for official spokesperson)
Delaware Technical & Community College --- weave@brahms.udel.edu
Technical Details
Message-ID: <15770@brahms.udel.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!wuarchive!udel!brahms.udel.edu!weave
References: <4196@awdprime.UUCP> <4223@awdprime.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!wuarchive!udel!brahms.udel.edu!weave
From: weave@brahms.udel.edu (Ken Weaverling)
Newsgroups: comp.unix.programmer
Subject: Re: The answer to make with multiple executables from same source files
Message-ID: <15770@brahms.udel.edu>
Date: 14 Nov 90 05:20:20 GMT
References: <4196@awdprime.UUCP> <4223@awdprime.UUCP>
Distribution: usa
Organization: University of Delaware
Lines: 87