# threads/Makefile
#
# $Source: /usr0/ecc/nectar/src/cab/threads/RCS/Makefile,v $
#
# $Header: Makefile,v 1.6 88/05/09 16:03:06 ecc Exp $
#
# Makefile for threads package.
#
# Parameters for "generic" rules:
#
#	LIB		libthreads.a or libthreads_p.a
#
#	PROFILE		null, -p, or -pg
#
# Implicit parameters:
#
#	machine		machine type, set by make

INCDIR = ./
LIBDIR = ./
LIB = libthreads.a
PROFILE =
COMMONFLAGS = -I$(INCDIR)
CFLAGS = -g $(COMMONFLAGS) $(PROFILE) 
LINTFLAGS = -u $(COMMONFLAGS)
# CC = /mit/c++/vaxbin/CC

# destiniation directories for install - LIBDEST for library,
#	INCDEST for include file
LIBDEST = /mit/pss2/src/lib
INCDEST = /mit/pss2/src/include

# Use the following definition to enable inline expansion.
INLINE = $(LIBDIR)/thread_inline
# Use the following definition to disable inline expansion.
# INLINE = cat

.SUFFIXES: .c .o

.c.o:
	$(CC) $(CFLAGS) -S $*.c
	mv $*.s $*.S
	$(INLINE) $(LIBDIR) $*.S > $*.s
	$(AS) -o $@ $*.s
	rm -f $*.s $*.S

SRCS = mutex.c procs.c stack.c threads.c time.c unix.c intr.c

OBJS = mutex.o procs.o stack.o \
       threads.o time.o unix.o \
       csw.o lock.o intr.o

all: machine $(LIB)

install: all
	cp $(LIB) $(LIBDEST)
	ranlib $(LIBDEST)/$(LIB)
	cp threads.h $(INCDEST)

$(LIB): $(OBJS)
	ar r $(LIB) $?
	ranlib $(LIB)

$(OBJS):threads.h thread_internals.h

time.o unix.o: $(INCDIR)/thread_time.h

csw.o: machine/csw.s
	$(AS) -o csw.o machine/csw.s

lock.o: machine/lock.s
	$(AS) -o lock.o machine/lock.s

lint:
	lint $(LINTFLAGS) $(SRCS)

machine:
	-@if [ -d machine ] ; then \
		true ; \
	else \
		if [ "$(machine)" ] ; then \
			echo Linking machine to $(machine) ; \
			ln -s $(machine) machine ; \
		else \
			echo Unable to determine machine type. ; \
			echo Please make symbolic link manually. ; \
			false ; \
		fi ; \
	fi

tidy:
	-rm -f a.out core errs *.d *.s *.S *.o *.BAK *.CKP

clean:
	-rm -f $(LIB) a.out core errs *.d *.s *.S *.o *.BAK *.CKP


# Pradeep
#   Added blank rule for "depend" so that top level Makefile works in one
# clean sweep

depend:
