#
#   Copyright (C) 1994-2001 Digitool, Inc
#   This file is part of OpenMCL.  
#
#   OpenMCL is licensed under the terms of the Lisp Lesser GNU Public
#   License , known as the LLGPL and distributed with OpenMCL as the
#   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
#   which is distributed with OpenMCL as the file "LGPL".  Where these
#   conflict, the preamble takes precedence.  
#
#   OpenMCL is referenced in the preamble as the "LIBRARY."
#
#   The LLGPL is also available online at
#   http://opensource.franz.com/preamble.html

VPATH = ../
RM = /bin/rm
# Versions of GNU as >= 2.9.1 all seem to work
# AS = gas-2.9.1
AS = as
M4 = m4
ASFLAGS = -mregnames
M4FLAGS = -DLINUX
CDEFINES = -DLINUX
CDEBUG = -g
COPT = -O2

.s.o:
	$(M4) $(M4FLAGS) -I../ $< | $(AS) $(ASFLAGS) -o $@
.c.o:
	$(CC) -c $< $(CDEFINES) $(CDEBUG) $(COPT) -o $@

SPOBJ = pad.o spjump.o subprims.o  sp_call.o sp_lambda.o sp_bind.o \
	sp_catch.o sp_ffi.o sp_heap_cons.o  sp_stack_cons.o sp_values.o \
	sp_vref.o sp_builtin.o sp_end.o

COBJ  = pmcl-kernel.o gc.o bits.o kernel-init.o lisp-exceptions.o mathtrap.o \
	image.o thread_manager.o lisp-debug.o 

DEBUGOBJ = lispdcmd.o plprint.o plsym.o plbt.o ppc_print.o
KERNELOBJ= $(COBJ) asmutils.o qtppc.o imports.o

SPINC =	lisp.s m4macros.m4 constants.s macros.s errors.s uuo.s

CHEADERS = area.h bits.h constants.h lisp-errors.h gc.h lisp.h lisptypes.h\
	lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h

# Subprims linked into the kernel ?
# Yes:

KSPOBJ = $(SPOBJ)
all:	../../ppccl


# No:

# KSPOBJ=
# all:	../../ppccl ../../subprims.so

OSLIBS = -ldl -lm 


../../ppccl:	$(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ)
	$(CC) $(CDEBUG)  -Wl,--export-dynamic  -o $@ -T ./elf32ppclinux.x $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) $(OSLIBS)


../../subprims.so: $(SPOBJ)
	ld -shared -o $@ $(SPOBJ)

$(SPOBJ): $(SPINC)
$(COBJ): $(CHEADERS)
$(DEBUGOBJ): $(CHEADERS) lispdcmd.h

thread_manager.o: thread_manager.c qt.h


cclean:
	$(RM) -f $(KERNELOBJ) $(DEBUGOBJ) ../../ppccl

clean:	cclean
	$(RM) -f $(SPOBJ) ../../subprims.so

strip:	../../dppccl
	strip -g ../../dppccl
