/*
 * $Header: /home/campbell/Languages/Scheme/scm/x-scm/RCS/Imakefile,v 1.9 1992/08/29 01:19:34 campbell Beta $
 *
 * Imakefile for x-scm, the X11 sidecar for scm.  This expects to be
 * installed as a subdirectory within the scm build directory.
 *
 * Author: Larry Campbell (campbell@redsox.bsw.com)
 *
 * Copyright 1992 by The Boston Software Works, Inc.
 * Permission to use for any purpose whatsoever granted, as long
 * as this copyright notice remains intact.  Please send bug fixes
 * or enhancements to the above email address.
 */

IMAKE = imake

/*
 * Most systems have Motif or OpenLook, but not both.  If your
 * system lacks one, comment out the corresponding line here.
 * Or, define the corresponding -DSUPPRESS_xxx macro on your Imake
 * command line.
 */
#ifndef SUPPRESS_MOTIF
# define HAVE_MOTIF
#endif

#ifndef SUPPRESS_OPENLOOK
# define HAVE_OPENLOOK
#endif

/* Where to install binaries */
BINDIR=/usr/local/bin

/* Where to install Scheme code */
SLIB_DIR=/usr/lib/scheme

/* Where the scm sources reside (typically ..) */
SCMSRCDIR = ..

/* Where to find scm and X11 include files */
INCLUDES = -I$(SCMSRCDIR) -I/usr/include/X11

/*
 * -DFLOATS is only required because of the screwy way
 * the sys_protects are defined in scm.h.
 *
 * If you're using the default (non-ANSI) C compiler on a Sequent
 * box, you have to define _NO_PROTO, otherwise prototypes in the
 * Motif headers will give the compiler heartburn.
 */
#ifdef _SEQUENT_
CFLAGS = $(INCLUDES) -O -DSYSV -DFLOATS -D_NO_PROTO
#else
CFLAGS = $(INCLUDES) -O -DSYSV -DFLOATS
#endif

/*
 * Object modules from scm that we must link (this list may need
 * to be updated as scm evolves, >sigh<)
 */
SCMOBJS =			\
	$(SCMSRCDIR)/fscl.o	\
	$(SCMSRCDIR)/feval.o	\
	$(SCMSRCDIR)/funif.o	\
	$(SCMSRCDIR)/repl.o	\
	$(SCMSRCDIR)/sc2.o	\
	$(SCMSRCDIR)/subr.o	\
	$(SCMSRCDIR)/sys.o	\
	$(SCMSRCDIR)/time.o

/*
 * You shouldn't need to modify anything after this point.
 */


all: pgms

pgms::	xscm

InstallProgram(xscm,$(BINDIR))

#ifdef HAVE_MOTIF
pgms::	xmscm

InstallProgram(xmscm,$(BINDIR))
#endif

#ifdef HAVE_OPENLOOK
pgms::	olscm

InstallProgram(olscm,$(BINDIR))
#endif

InstallNonExec(assert.scm,$(SLIB_DIR))
InstallNonExec(x11.scm,$(SLIB_DIR))
InstallNonExec(xt.scm,$(SLIB_DIR))
InstallNonExec(xw.scm,$(SLIB_DIR))
InstallNonExec(xm.scm,$(SLIB_DIR))
InstallNonExec(ol.scm,$(SLIB_DIR))
InstallNonExec(xmsubs.scm,$(SLIB_DIR))
InstallNonExec(olsubs.scm,$(SLIB_DIR))
InstallNonExec(xevent.scm,$(SLIB_DIR))

NormalProgramTarget(xscm,xscm.o x.o,,$(SCMOBJS) $(XLIB),-lm)

NormalProgramTarget(xmscm,xmscm.o x.o,libxm.a,libxm.a $(SCMOBJS) -lXm -lXt $(XLIB),-lm)

NormalProgramTarget(olscm,olscm.o x.o,libol.a,libol.a $(SCMOBJS) -lXol -lXt $(XLIB),-lm)

OLOBJS = xt-ol.o ol.o
XMOBJS = xt-xm.o xm.o

libxm.a: $(XMOBJS)
	ar rc libxm.a $(XMOBJS)

libol.a: $(OLOBJS)
	ar rc libol.a $(OLOBJS)

/*
 * Note:  it is important that the inits get called in the following order:
 *   init_x, init_xt, init_{toolkit}
 * because SMOBs are defined by the init functions and later inits may
 * use SMOBs defined by earlier ones.
 */
xscm.o:	$(SCMSRCDIR)/scm.c $(SCMSRCDIR)/scm.h $(SCMSRCDIR)/config.h $(SCMSRCDIR)/patchlvl.h
	$(CC) $(CFLAGS) -c -DINITS=init_x\(\) $(SCMSRCDIR)/scm.c
	$(MV) scm.o xscm.o

olscm.o:	$(SCMSRCDIR)/scm.c $(SCMSRCDIR)/scm.h $(SCMSRCDIR)/config.h $(SCMSRCDIR)/patchlvl.h
	$(CC) $(CFLAGS) -c -DINITS=init_x\(\)\;init_xt\(\)\;init_ol\(\) $(SCMSRCDIR)/scm.c
	$(MV) scm.o olscm.o

xmscm.o:	$(SCMSRCDIR)/scm.c $(SCMSRCDIR)/scm.h $(SCMSRCDIR)/config.h $(SCMSRCDIR)/patchlvl.h
	$(CC) $(CFLAGS) -c -DINITS=init_x\(\)\;init_xt\(\)\;init_xm\(\) $(SCMSRCDIR)/scm.c
	$(MV) scm.o xmscm.o

ol.o:	ol.c x.h xt.h
	$(CC) $(CFLAGS) -c ol.c

x.o:	x.c xevent.h x.h version.h

xevent.h xevent.scm: xgen.scm
	scm xgen

xm.o: xm.c x.h xt.h
	$(CC) $(CFLAGS) -DMOTIF -c xm.c

xt-xm.o: xt.c x.h xt.h
	$(CC) $(CFLAGS) -DMOTIF -c xt.c
	$(MV) xt.o xt-xm.o
	
xt-ol.o: xt.c x.h xt.h
	$(CC) $(CFLAGS) -c xt.c
	$(MV) xt.o xt-ol.o

README: README.template
	./versionify <README.template >README

Makefile.std:	Imakefile
	imake -I/usr/X4/lib/config -DUseInstalled -s Makefile.std

PART1 =	README INSTALL Imakefile Makefile.std xgen.scm x.h xt.h

PART2 =	version.h x.c

PART3 =	xt.c xm.c ol.c

PART4 =	assert.scm x11.scm xm.scm xt.scm xw.scm ol.scm \
	olsubs.scm xmsubs.scm

PART5 =	oltest.scm xmtest.scm xelk.scm \
	xhello.scm xftp.scm xcolorselect.scm xmandel.scm

shar: part1.shar part2.shar part3.shar part4.shar part5.shar

part1.shar: $(PART1)
	shar $(PART1) >$@

part2.shar: $(PART2)
	shar $(PART2) >$@

part3.shar: $(PART3)
	shar $(PART3) >$@

part4.shar: $(PART4)
	shar $(PART4) >$@

part5.shar: $(PART5)
	shar $(PART5) >$@

clean::
	rm -f *.shar xevent.h xevent.scm README Makefile Makefile.std
