From: devin@frodo.colorado.edu (Sonja Orlavski)
Subject: Re:  ivmkmf template macro for "MakeObjectOnly".
Organization: Colorado Center for Astrodynamics Research
Date: Tue, 7 Apr 1992 19:38:43 GMT

In article <9204080311.AA09544@hkueee.hku.hk>, leo@HKUEEE.HKU.HK (Leo Chow) writes:
|> We're interested to know too. Our situation is that we have several
|> source code directories. Some directories are InterViews-related while
|> others are not. We want the ability to select different combinations of
|> object files from a pool of object files so that different executables
|> can be eventually formed. "ivmkmf", without "MakeObjectOnly" option,
|> forces us to maintain our own version of makefiles.

MakeObjectFromSrc(foo)
will compile foo.$(CCSUFFIX) into foo.o.

I have written a template-type file which compiles source files in
different directories.  Most of the MakeSimple*() and Make*() rules
are just tweaked copies of the original MakeObjectFromSrc() rule.

Imakefile:
--- cut here --- cut here --- cut here --- cut here --- cut here ---
/*
 *	Imakefile
 */

/*
 * RCSid:  $Id: Imakefile,v 1.1 1992/04/03 22:40:25 devin Exp $
 */

#ifdef InObjectCodeDir

#include "foo.tmpl"

AOUT = foo

ENTITIES = \
	Entity1.o \
	Entity2.o

CLASSES = \
	Class1.o \
	Class2.o

IVSTUFF = \
	CursorHandler.o \
	Editor.o \
	page.o \
	xpainter.o

OTHER = \
	3dMath.o \
	Misc.o \
	foo.o

OBJS = $(ENTITIES) $(CLASSES) $(IVSTUFF) $(OTHER) 

Use_libInterViews()
ComplexProgramTarget(foo)

all:: $(AOUT)
	mv $(AOUT) $(SRC)

MakeSimpleEntity(Entity1)
MakeSimpleEntity(Entity2)

MakeSimpleClass(Class1)
MakeSimpleClass(Class2)

MakeSimpleIV(CursorHandler)
MakeSimpleIV(Editor)
MakeSimpleIV(page)
MakeSimpleIV(xpainter)

MakeSimpleMisc(3dMath)
MakeSimpleMisc(Misc)
MakeSimpleMisc(foo)

#else

MakeInObjectCodeDir()

#endif
--- cut here --- cut here --- cut here --- cut here --- cut here ---

And then, foo.tmpl:
--- cut here --- cut here --- cut here --- cut here --- cut here ---
/*
 * Imake Template file
 */

/*
 * RCSid:  $Id: foo.tmpl,v 1.1 1992/04/03 22:40:29 devin Exp $
 */

/* Shorthands for MakeObjectRule */

SRCS = $(SRC)$(SLASH)*.$(CCSUFFIX) \
	$(SRC)$(SLASH)Entities$(SLASH)*.$(CCSUFFIX) \
	$(SRC)$(SLASH)Classes$(SLASH)*.$(CCSUFFIX) \
	$(SRC)$(SLASH)IV$(SLASH)*.$(CCSUFFIX)

  APP_CCINCLUDES = -I$(SRC)$(SLASH)include -I$(SRC)$(SLASH)Entities \
			-I$(SRC)$(SLASH)Classes -I$(SRC)$(SLASH)IV \
			-I$(SRC)

 ENTITYFLAGS = 
  CLASSFLAGS = 
   MISCFLAGS = 

/* For Entities */
#ifndef MakeEntity
#define MakeEntity(file,flags)						@@\
$(AOUT): file.o								@@\
file.o: $(SRC)/Entities/file.$(CCSUFFIX)				@@\
	@$(RM) file.o file..c						@@\
	$(CCDRIVER) $(CCFLAGS) $(ENTITYFLAGS) flags -c \
		$(SRC)/Entities/file.$(CCSUFFIX)
#endif

#ifndef MakeSimpleEntity
#define MakeSimpleEntity(file)						@@\
MakeEntity(file,NullParameter)
#endif

/* For Classes */
#ifndef MakeClass
#define MakeClass(file,flags)						@@\
$(AOUT): file.o								@@\
file.o: $(SRC)/Classes/file.$(CCSUFFIX)					@@\
	@$(RM) file.o file..c						@@\
	$(CCDRIVER) $(CCFLAGS) $(CLASSFLAGS) flags -c \
		$(SRC)/Classes/file.$(CCSUFFIX)
#endif

#ifndef MakeSimpleClass
#define MakeSimpleClass(file)						@@\
MakeClass(file,NullParameter)
#endif

/* For InterViews Classes */
#ifndef MakeIV
#define MakeIV(file,flags)						@@\
$(AOUT): file.o								@@\
file.o: $(SRC)/IV/file.$(CCSUFFIX)					@@\
	@$(RM) file.o file..c						@@\
	$(CCDRIVER) $(CCFLAGS) $(CLASSFLAGS) flags -c \
		$(SRC)/IV/file.$(CCSUFFIX)
#endif

#ifndef MakeSimpleIV
#define MakeSimpleIV(file)						@@\
MakeIV(file,NullParameter)
#endif

/* For Misc */
#ifndef MakeMisc
#define MakeMisc(file,flags)						@@\
$(AOUT): file.o								@@\
file.o: $(SRC)/file.$(CCSUFFIX)						@@\
	@$(RM) file.o file..c						@@\
	$(CCDRIVER) $(CCFLAGS) $(MISCFLAGS) flags -c $(SRC)/file.$(CCSUFFIX)
#endif

#ifndef MakeSimpleMisc
#define MakeSimpleMisc(file)						@@\
MakeMisc(file,NullParameter)
#endif
--- cut here --- cut here --- cut here --- cut here --- cut here ---

Enjoy!

		-Devin

-- 
Devin Hooker     (RP90)     DoD #0034    devin@boulder.colorado.edu
"It's being both that's a bitch."
"I'm entirely TOO lucid right now."
"This howling in the distance, it's a captivating sound.
	Can't tell if it's ecstasy or pain..."  -DW
Newsgroups: comp.windows.interviews