#
#
#

CC = gcc
CCFLAGS = -O2

#SCCFLAGS = -O2 -Ob -Og -Ot
SCCFLAGS = -O2

# Scheme X includes and libs
SCXINC = /u/mann/Scheme-to-C/15mar93/xlib
SCXLIB = /u/mann/Scheme-to-C/15mar93/SOLARIS/xlib

# Location of OPENGL/Mesa library
GLLIB = /u/mann/Software/Mesa/lib/libMesaGL.a

# X libraries
XLIBS = -lX11 -lXext

# Other stuff needed by your system (I need this on Solaris)
OTHERLIBS = -lsocket -lnsl

# Cleanup
clean:
	rm -f *.o
	rm -f scigl
	rm -f gl-xdemo gl-spin

# Access to arrays of C types (via low-level interface in Scheme-to-C)
c-array.o: c-array.sc
	scc -cc $(CC) $(SCCFLAGS) -c c-array.sc
	rm -f c-array.c

# GL bindings
gl.o: gl.sc
	scc -cc $(CC) $(SCCFLAGS) -c gl.sc
	rm -f gl.c

# Plain SCI interpreter with X and GL.
# Note module name for C-array (compiler replaces `-' with `_2d').
scigl: gl.o c-array.o
	scc -o scigl -i\
		-m gl gl.o\
		-m c_2darray c-array.o\
		-m xlib $(SCXLIB)/scxl.a\
		$(GLLIB) $(XLIBS) $(OTHERLIBS)

# Sample application program that uses X and GL.
gl-spin.o: gl-spin.sc
	scc -cc $(CC) $(SCCFLAGS) -I $(SCXINC) -c gl-spin.sc
	rm -f gl-spin.c

gl-spin: gl-spin.o
	scc -o gl-spin gl-spin.o\
		$(SCXLIB)/scxl.a\
		gl.o $(GLLIB)\
    	    	$(XLIBS) $(OTHERLIBS)

# Sample application program that uses X and GL (also needs c-array)
gl-xdemo.o: gl-xdemo.sc c-array.sch
	scc -cc $(CC) $(SCCFLAGS) -I $(SCXINC) -c gl-xdemo.sc
	rm -f gl-xdemo.c

gl-xdemo: gl-xdemo.o c-array.o
	scc -o gl-xdemo gl-xdemo.o\
		c-array.o\
		$(SCXLIB)/scxl.a\
		gl.o $(GLLIB)\
    	    	$(XLIBS) $(OTHERLIBS)

