# Begin of user-configurable section:

# List of directories where to invoke "make".  Add lib/xhp if you need
# the interface to the (obsolete) HP-widgets.  See README for an overview.

TARGETS= src\
	 lib\
	 lib/util\
	 lib/xlib\
	 lib/xt\
	 lib/xaw\
	 lib/motif\
	 lib/motif/xt

# Top level directory (where the runtime system will be installed).
# You can set TOP_DIR to the directory where this Makefile resides, i.e.
# where you have unpacked the distribution.
#
# Scheme files are loaded from SCM_DIR, object files from LIB_DIR.

TOP_DIR= /users/net/scm
SCM_DIR= $(TOP_DIR)/scm
LIB_DIR= $(TOP_DIR)/lib

# GENERIC pointer type.  Should be void*, but some C compilers (such as
# cc under 4.3BSD) can't handle void* correctly.

GENERIC= \"char*\"

# MACHTYPE is used to select a machine-specific version of the assembly
# files src/stack.s and src/alloca.s.  It is used as a filename suffix,
# i.e. src/stack.s.$(MACHTYPE) will be used by the Makefile in src.
#
# Set MACHTYPE to "port" if you want to make the portable version.
# In this case, make sure that PORTABLE is defined in src/config.h.
#
# Permitted values for MACHTYPE currently are 68k, vax, 386, sparc,
# symmetry, rt, sony68k, mips, hp9000s300, and port.

MACHTYPE= 68k

# If symbolic links are not supported by your system, define LINK=ln

LINK=ln -s

# Compiler options

 CFLAGS= -O                            # generic CFLAGS
#CFLAGS= -O -finline-functions         # gcc
#CFLAGS= -g -ma                        # IBM RT
#CFLAGS= +O1 -Wl,-x -Wc,-Ns4000        # HP-UX
#CFLAGS=                               # System V/386

# Linker options

 LDFLAGS= -x                                       # generic LDFLAGS
#LDFLAGS=                                          # IBM RT, HP-UX
#LDFLAGS= -Bstatic                                 # SunOS
#LDFLAGS= -x -lld                                  # System V
#LDFLAGS= -Wl,-D,800000 /usr/local/lib/gcc-gnulib  # MIPS (gcc)

# Sun has broken their linker under SunOS 4.1; the -l option doesn't work
# together with -r any longer.  Thus the full library paths must be given.
# MOTIFXT is Motif-1.0's Xt library; not needed for Motif 1.1.
# These symbols only are needed when you want to make the X11 interface.
#
# SunOS 4.1:
#XLIB=    /lib/libX11.a
#XT=      /lib/libXt.a
#XAW=     /lib/libXaw.a /lib/libXmu.a $(XT)
#MOTIF=   /lib/libXm.a
#MOTIFXT= /lib/libXtm.a
#
# Everywhere else:
 XLIB=    -lX11
 XT=      -lXt
 XAW=     -lXaw -lXmu $(XT)
 MOTIF=   -lXm
 MOTIFXT= -lXtm

# End of user-configurable section


DEFS= -DSCM_DIR=\\\"$(SCM_DIR)\\\" -DLIB_DIR=\\\"$(LIB_DIR)\\\"\
      -DGENERIC=$(GENERIC)

LINTFLAGS= $(DEFS)

all:
	-@for i in $(TARGETS) ;\
	do \
	    ( if [ ! -d $$i ]; then \
		echo mkdir $$i ;\
		mkdir $$i ;\
	      fi ;\
	      if [ ! -r $$i/Makefile ]; then \
		echo $(LINK) $(TOP_DIR)/$$i/Makefile $$i ;\
		$(LINK) $(TOP_DIR)/$$i/Makefile $$i ;\
	    fi ) ;\
	done
	@for i in $(TARGETS) ;\
	do \
	    ( cd $$i ;\
	    echo Making $$i ;\
	    make "MACHTYPE=$(MACHTYPE)" "CC=$(CC)" "CFLAGS=$(DEFS) $(CFLAGS)"\
		 "LDFLAGS=$(LDFLAGS)" "LINK=$(LINK)" "XLIB=$(XLIB)" "XT=$(XT)"\
		 "XAW=$(XAW)" "MOTIF=$(MOTIF)" "MOTIFXT=$(MOTIFXT)" ) ;\
	done

lint:
	@for i in $(TARGETS) ;\
	do \
	    ( cd $$i ;\
	    echo Linting $$i ;\
	    make "LINTFLAGS=$(LINTFLAGS)" lint );\
	done

clean:
	@for i in $(TARGETS) ;\
	do \
	    ( cd $$i ;\
	    echo Cleaning $$i ;\
	    make clean ) ;\
	done

dist:
	gnutar -cvf scheme.tar -X ExcludeFiles RELEASE README INSTALL ORIGIN\
				       MACHINES Makefile doc src scm tst lib stk
	compress scheme.tar
	rsh kraftbus uuencode scheme.tar.Z <scheme.tar.Z >scheme.tar.Z.uue
	rm scheme.tar.Z
	split -1000 scheme.tar.Z.uue
