# $Id: Makefile.in,v 1.25 1998/02/23 08:03:59 assar Exp $ S

srcdir		= @srcdir@
VPATH		= @srcdir@

CC		= @CC@
CPP		= @CPP@
AS		= as
AR		= ar
RM		= rm
RANLIB		= @RANLIB@

INSTALL		= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
SHELL = /bin/sh

HOST_CPU	= @host_cpu@
HOST_OS		= @host_os@

INCLUDES	= -I../include

CFLAGS		= $(INCLUDES) @DEFS@ @CFLAGS@ -DFD_SPEED_HACK

LIBOBJS=lwp.o process.o lock.o iomgr.o timer.o fasttime.o preempt.o q.o

all: liblwp.a

install:	all

liblwp.a: $(LIBOBJS)
	-rm -f liblwp.a
	$(AR) rc liblwp.a ${LIBOBJS}
	$(RANLIB) liblwp.a


# More magic, close your eyes.
process.o:	process.S
	case "$(HOST_CPU)" in \
		sparc) CPUDEF="-Dsparc" ;; \
		i*86*) CPUDEF="-DAFS_386i_ENV" ;; \
		m68k)  CPUDEF="-Dmc68000" ;; \
		mips)  CPUDEF="-Dmips" ;; \
		alpha) CPUDEF="-Dalpha" ;; \
		mips)  CPUDEF="-Dmips" ;; \
		hppa*) CPUDEF="" ;; \
		*)  echo "Unknown host_cpu, good luck" ;; \
	esac ; \
	case "$(HOST_OS)" in \
		*bsd*) OSDEF="-DAFS_NETBSD_ENV" ;; \
		*linux*) OSDEF="-DAFS_LINUX_ENV" ;; \
		*irix*) OSDEF="-Dsgi" ;; \
		*dux* | *osf*) OSDEF="-DAFS_OSF_ENV" ;; \
		*solaris*) OSDEF="-DAFS_SUN5_ENV -D_ASM" ;; \
		*irix*) OSDEF="-Dsgi" ;; \
		*hpux*) OSDEF="-DAFS_HPUX_ENV" ;; \
		*) ;; \
	esac ; \
	case "$(CC)" in \
		gcc*) $(CC) $$CPUDEF $$OSDEF -c $(srcdir)/process.S ;; \
		*) $(AS) -P $$CPUDEF $$OSDEF $(srcdir)/process.S -o process.o || ($(CPP) -P $$CPUDEF $$OSDEF $(srcdir)/process.S > process.ss ; \
		$(AS) process.ss -o process.o ; \
		$(RM) -f process.ss) ;; \
	esac

iomgr.o: iomgr.c lwp.h timer.h
preempt.o: preempt.c lwp.h preempt.h
lwp.o: lwp.c lwp.h
lock.o: lock.c lock.h lwp.h
timer.o: timer.c
fasttime.o: fasttime.c
q.o: q.c

clean:
	rm -f *.o *.a core process.ss


