# Makefile for SCIX. Johan Ihren.

# $Id: Makefile,v 1.3 91/08/26 22:11:46 johani Exp Locker: johani $

# This Makefile is ugly. Someday I must take the time to do this properly.

MODULES = scixlowlev scixatypes scixdtypes scixreq1 scixreq2 scixmh \
          scixobj scixwin scixdpy scixcmap scixgc \
	  scixlwobj scixbmsk scixvmsk scixce scixmu hash

# Byte-order is now determined automagically.

.SUFFIXES:

.SUFFIXES:	.sc .c .o

SCC	  = scc
#SCC	  = /usr/local/bin/scc

# SCCFLAGS  = -O -Ob -Og -On -Ot
SCCFLAGS  = -O -On -Ob
.sc.o: ;	-$(SCC) -c $(SCCFLAGS) $*.sc

SCIXSRC   = util.sc requests1.sc \
	    lowlevel.sc atypes.sc dtypes.sc msg-hndl.sc requests2.sc \
	    hash-obj.sc bitmasks.sc vmasks.sc objects.sc font-obj.sc \
	    cur-obj.sc screenobj.sc lw-objs.sc graphic-objects.sc view-obj.sc \
	    create-ev.sc dpy-obj.sc win-obj.sc gc-obj.sc \
	    cmap-obj.sc msg-util.sc scix.sc

SCIXOBJ   = util.o lowlevel.o requests1.o \
	    requests2.o atypes.o dtypes.o msg-hndl.o hash-obj.o \
	    bitmasks.o vmasks.o objects.o lw-objs.o create-ev.o dpy-obj.o \
	    win-obj.o gc-obj.o cmap-obj.o msg-util.o

all:		../libscix.a

../libscix.a:	scix.o $(SCIXOBJ)
		cd ../csrc ; $(MAKE) ../libscix.a
		ar r ../libscix.a scix.o $(SCIXOBJ)
		ranlib ../libscix.a

clean: ;	rm -f core *.o *~ #* *obj*.c SC-TO-C* create-ev.c \
		      lowlevel.c *masks.c msg-*.c requests*.c types.c \
		      util.c

scix.sc:	Makefile
		-rm -f scix.sc
		echo -n "(module scix (with " >> scix.sc
		echo -n $(MODULES) >> scix.sc
		echo "))" >> scix.sc
		echo "(define (scix-version)" >> scix.sc
		echo "  \"SCIX version $(VERSION) (beta) -- `date`\")" \
		     >> scix.sc
		echo "(display (scix-version))" >> scix.sc
		echo "(newline)" >> scix.sc

# Some animals need special treatment for byte-order sickness.
indian:		indian.c
		$(CC) -o indian indian.c

dtypes.sc:	dtypes.tmpl indian mkendian.sh
		-rm -f dtypes.sc
		sh mkendian.sh dtypes.tmpl > dtypes.sc

vmasks.sc:	vmasks.tmpl indian mkendian.sh
		-rm -f vmasks.sc
		sh mkendian.sh vmasks.tmpl > vmasks.sc

# For the following rule replace /usr/include/X11 with wherever the X11
# include files are located if you need to recreate atoms.sc for some reason.
atoms.sc:	atoms.awk # /usr/include/X11/Xatom.h
		rm -f atoms.sc
		awk -f atoms.awk /usr/include/X11/Xatom.h | \
		sed -e 's/XA_//' -e '/LAST_PRE/d' > atoms.sc

# Dependencies. I have removed some ".sch" dependencies for "stable stuff" to
# avoid "unnecessary" recompilation. /Johan

# create-event loses if we try to optimize (on pmaxes with standard cc).
# Haven't had time to find out why.
create-ev.o:	create-ev.sc ../include/types.sch
		$(SCC) -c create-ev.sc

formats.o:	formats.sc ../include/util.sch
hash-obj.o:	hash-obj.sc
lowlevel.o:	lowlevel.sc ../include/util.sch
bitmasks.o:	../macros/extsyntax.sc ../macros/mask-obj.sc bitmasks.sc \
		../include/util.sch ../include/types.sch
vmasks.o:	../macros/extsyntax.sc ../macros/mask-obj.sc vmasks.sc \
		../include/util.sch ../include/types.sch
requests1.o:	requests1.sc ../include/types.sch
requests2.o:	requests2.sc ../include/types.sch
atypes.o:	atypes.sc
dtypes.o:	dtypes.sc ../macros/extsyntax.sc ../macros/mask-obj.sc
util.o:		util.sc ../include/types.sch
msg-hndl.o:	msg-hndl.sc
msg-util.o:	msg-util.sc ../include/types.sch

# Objects.
lw-objs.o:	lw-objs.sc graph-obj.sc ../include/types.sch
objects.o:	../macros/extsyntax.sc ../macros/oos.sc \
		../include/lw-objs.sch ../include/requests.sch \
		../include/msgutil.sch 
cmap-obj.o:	cmap-obj.sc ../macros/extsyntax.sc ../macros/oos.sc 
dpy-obj.o:	dpy-obj.sc formats.sc ../macros/extsyntax.sc ../macros/oos.sc
gc-obj.o:	gc-obj.sc ../macros/extsyntax.sc ../macros/oos.sc
win-obj.o:	win-obj.sc ../macros/extsyntax.sc ../macros/oos.sc
