# Makefile for SCIX. Johan Ihren.

# $Id: Makefile,v 1.12 90/06/26 09:45:24 johani Exp $

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

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

# To install SCIX on a machine running DECwindows (ie not X11R4) uncomment the
# following line. This affects one file that is borrowed from X11R4.
# DECWINDOWS = -DDECWINDOWS

# LSB machines include DECstations and VAXes. On those use this:
ENDIAN = -DLITTLEENDIAN
# MSB machines include Sparcs, Sun3s. On those use this:
# ENDIAN = -DBIGENDIAN

.SUFFIXES:

.SUFFIXES:	.sc .c .o

SCC	  = scc

.sc.o: ;	-$(SCC) -c $(SCCFLAGS) $*.sc

.c.o: ;		-$(SCC) -c $(SCCFLAGS) $*.c

SCIXDEMOS = -m scixdemo ../demo/scixdemos.o

SCIXSRC   = Xlibsock.c ftypes.c rwsock.c util.sc requests1.sc \
	    lowlevel.sc types.sc msg-hndl.sc requests2.sc \
	    hash-obj.sc bitmasks.sc valmasks.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   = Xlibsock.o ftypes.o rwsock.o util.o requests1.o \
	    lowlevel.o types.o msg-hndl.o requests2.o hash-obj.o \
	    bitmasks.o valmasks.o objects.o lw-objs.o create-ev.o dpy-obj.o \
	    win-obj.o gc-obj.o cmap-obj.o msg-util.o

LIBS      = -L.. -lscixt

../scix:	scix.sc $(SCIXOBJ) Makefile
		$(SCC) -i -o Xscix scix.sc $(SCIXOBJ) $(SCIXDEMOS) $(LIBS)
		mv Xscix ../scix

../rawscix:	$(SCIXOBJ) Makefile
		$(SCC) -i -o Xrawscix scix.sc $(SCIXOBJ)
		mv Xrawscix ../rawscix

../libscix.a:	scix.o $(SCIXOBJ)
		rm -f ../libscix.a
		ar q ../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

# I don't intend to leave the entire date in the scix-version procedure, but
# now it is convenient. -- johani
scix.sc:	../Makefile 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.
newtypes.sc:	newtypes.tmpl Makefile
		-rm -f newtypes.sc
		/lib/cpp -P $(ENDIAN) newtypes.tmpl > newtypes.sc

valmasks.sc:	valmasks.tmpl Makefile
		-rm -f valmasks.sc
		/lib/cpp -P $(ENDIAN) valmasks.tmpl > valmasks.sc

# For the following two rules replace /usr/include/X11 with wherever the
# X11 include files are located if you need to recreate opcodes.sc or atoms.sc
# for some reason.
opcodes.sc:	opcodes.awk # /usr/include/X11/Xproto.h
		rm -f opcodes.sc
		awk -f opcodes.awk /usr/include/X11/Xproto.h | \
		sed -e 's/X_//' > opcodes.sc

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

rwsock.o:	rwsock.c
		$(CC) -O2 -c $(CFLAGS) rwsock.c

ftypes.o:	ftypes.c
		$(CC) -O2 -c $(CFLAGS) ftypes.c

CONNTYPES = -DTCPCONN -DUNIXCONN # -DSTREAMSCONN -DDNETCONN

Xlibsock.o:	Xlibsock.c
		$(SCC) -O $(CONNTYPES) $(DECWINDOWS) -c Xlibsock.c

# 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
valmasks.o:	../macros/extsyntax.sc ../macros/mask-obj.sc valmasks.sc \
		../include/util.sch ../include/types.sch
requests1.o:	requests1.sc ../include/opcodes.sch ../include/types.sch
requests2.o:	requests2.sc ../include/opcodes.sch ../include/types.sch
types.o:	types.sc ../macros/extsyntax.sc ../macros/mask-obj.sc \
		newtypes.sc
util.o:		util.sc mktext.sc mkatom.sc ../include/types.sch
msg-hndl.o:	msg-hndl.sc
msg-util.o:	msg-util.sc formats.sc ../include/types.sch

# Objects.
lw-obj.o:	lw-objs.sc graphic-objs.sc view-obj.sc ../include/types.sch
objects.o:	../macros/extsyntax.sc ../macros/defclass.sc \
		../include/lw-objs.sch ../include/requests.sch \
		../include/msg-hndl.sch screenobj.sc font-obj.sc \
		cur-obj.sc
cmap-obj.o:	cmap-obj.sc ../macros/extsyntax.sc ../macros/defclass.sc 
dpy-obj.o:	dpy-obj.sc ../macros/extsyntax.sc ../macros/defclass.sc
gc-obj.o:	gc-obj.sc ../macros/extsyntax.sc ../macros/defclass.sc
win-obj.o:	win-obj.sc ../macros/extsyntax.sc ../macros/defclass.sc
