# $Id: Makefile.in,v 1.55.2.1 2000/10/08 03:13:37 lha Exp $

srcdir		= @srcdir@
VPATH		= @srcdir@

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

INSTALL		= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
SHELL 		= /bin/sh
LN_S		= @LN_S@
MKINSTALLDIRS   = @top_srcdir@/mkinstalldirs

prefix 		= @prefix@
exec_prefix	= @exec_prefix@
libdir		= @libdir@
includedir	= @includedir@

HOST_CPU	= @host_cpu@
HOST_OS		= @host_os@

INCLUDES	= -I../include

PROCESS_S	= process.aix22.S \
		  process.alpha.S \
		  process.hpux.S \
		  process.i386.S \
		  process.ibm032.S \
		  process.m68k.S \
		  process.mips.S \
		  process.ppc.S \
		  process.rios.S \
		  process.sparc.S \
		  process.vax.S


REALCFLAGS	= $(INCLUDES) @DEFS@ @CFLAGS@ -DFD_SPEED_HACK -DDEBUG \
		  $(CFLAGS) @PLWP_INC_FLAGS@

LIB		= liblwp.a

include_HEADERS = lock.h preempt.h timer.h

liblwp_OBJECTS  = @LWP_O@ @LWP_PROCESS@ lock.o iomgr.o timer.o fasttime.o q.o \
		  preempt.o

TEST_PROGRAMS	= testlwp rw

all:		$(LIB) $(TEST_PROGRAMS)

install:	all
		$(MKINSTALLDIRS) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
		$(INSTALL_DATA) $(LIB) $(DESTDIR)$(libdir)/$(LIB)
		for x in $(include_HEADERS); do \
			b=`basename $$x`; \
			$(INSTALL_DATA) $(srcdir)/$$b $(DESTDIR)$(includedir)/$$b; \
		done
		$(INSTALL_DATA) $(srcdir)/@LWP_H@ $(DESTDIR)$(includedir)/lwp.h

uninstall:
		rm -f $(DESTDIR)$(libdir)/$(LIB)
		for x in $(include_HEADERS); do \
			rm -f $(DESTDIR)$(includedir)/$$x; \
		done
		rm -f $(DESTDIR)$(includedir)/lwp.h

liblwp.a:	$(liblwp_OBJECTS)
		$(RM) -f $@
		$(AR) rc $@ $(liblwp_OBJECTS)
		$(RANLIB) $@

make-process.o.sh: make-process.o.sh.in ../config.status
		cd ..; CONFIG_FILES=lwp/make-process.o.sh CONFIG_HEADERS= $(SHELL) config.status

# More magic, close your eyes.
process.o:	$(PROCESS_S) make-process.o.sh testprocess.o preempt.o @LWP_O@
		$(SHELL) make-process.o.sh

testlwp: testlwp.o liblwp.a
	$(CC) -o testlwp testlwp.o -L. -llwp -L../lib/roken \
	-lroken @PLWP_LIB_FLAGS@
rw: rw.o liblwp.a
	$(CC) -o rw rw.o -L. -llwp -L../lib/roken \
	-lroken @PLWP_LIB_FLAGS@
.c.o:
		$(CC) -c $(CPPFLAGS) $(DEFS) $(REALCFLAGS) -I$(srcdir) -I. $<

# dependencies

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
rw.o: rw.c
testprocess.o: testprocess.c
testlwp.o: testlwp.c

clean:
	rm -f *.o *.a core process.ss process.i $(LIB) make-process.o.sh testprocess $(TEST_PROGRAMS) process.S

distclean: clean
	rm -f Makefile

realclean: clean

Makefile:	Makefile.in ../config.status
		cd ..; CONFIG_FILES=lwp/Makefile CONFIG_HEADERS= $(SHELL) config.status

.PHONY: all install uninstall clean distclean realclean
