# $Id: Makefile.in,v 1.47 1999/05/15 22:43:39 assar Exp $ S

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

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

LIB		= liblwp.a

include_HEADERS = @LWP_H@ 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

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

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

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

# More magic, close your eyes.
process.o:	process.S process.s.hpux 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
testprocess.o:	testprocess.c
testlwp.o: testlwp.c

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

distclean: clean

realclean: clean

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

.PHONY: all install uninstall clean distclean realclean
