#  Copyright (C) 1992, the Florida State University
#  Distributed by the Florida State University under the terms of the
#  GNU Library General Public License.
#
#This file is part of Pthreads.
#
#Pthreads is free software; you can redistribute it and/or
#modify it under the terms of the GNU Library General Public
#License as published by the Free Software Foundation (version 2).
#
#Pthreads is distributed "AS IS" in the hope that it will be
#useful, but WITHOUT ANY WARRANTY; without even the implied
#warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#See the GNU Library General Public License for more details.
#
#You should have received a copy of the GNU Library General Public
#License along with Pthreads; see the file COPYING.  If not, write
#to the Free Software Foundation, 675 Mass Ave, Cambridge,
#MA 02139, USA.
#
#Report problems and direct all questions to:
#
#  pthreads-bugs@ada.cs.fsu.edu
#
#   @(#)Makefile	1.16 3/5/93
#

#Compile flags:
#C_INTERFACE:		for C-language interface; if this option is omitted,
#			a language-independent interface will be generated
#			which has been tested for Verdix/SunAda.
#CLEANUP_HEAP:		allocate cleanup handlers on heap (default: stack).
#DEBUG:			dump out trace information (mainly for signals).
#DEF_RR:		supports round-robin time-sliced scheduling
#DRAFT5:		defines pthread_setprio() interface bypassing attributes
#IO:			I/O operations only block current thread, not process.
#			(SunOS kernel configuration must include light-weight
#			processes [LWP] and aynchronous I/O [AIO] if this
#			option is set.)
#NOERR_CHECK:		fast mutex operations without error checking.
#NO_INLINE:		no inlines for macros (internally CLEAR_KERNEL_FLAG).
#MUT_SWITCH:		forces context switch upon successful mutex_lock()
#			with regard to priorities
#RAND_SWITCH:		forces context switch on kernel exit at random intervals
#			and to random threads without regard to priorities
#RR_SWITCH:		forces context switch on kernel exit (round-robin queue)
#			without regard to priorities
#SIM_KERNEL:		simulate kernel implementation by using dummy UNIX
#			system call in selected routines.
#STACK_CHECK:		lock page to cause bus error / illegal instruction
#			on stack overflow
#TIMER_DEBUG:		dump out trace information for SIGALRM signals and timer


#for shipping
CFLAGS = -DNOERR_CHECK -DC_INTERFACE -DSTACK_CHECK
#for testing
#CFLAGS = -DDEBUG -DTIMER_DEBUG -DNOERR_CHECK -DC_INTERFACE

#for shipping
CCFLAGS = -O3 $(CFLAGS)
#for testing
#CCFLAGS = -g $(CFLAGS)

#for gnu C compiler
#CC = gcc

LINTFLAGS = -u $(CFLAGS)

LIBS = ../lib/libpthreads.a

CSRC = pthread.c stack.c mutex.c cond.c pthread_init.c signal.c \
	cond.c queue.c io.c

SCRS = $(CSRC) pthread_sched.S

OBJS = $(LIBS)(pthread.o stack.o mutex.o cond.o pthread_init.o \
		signal.o pthread_sched.o queue.o io.o)

HDR1 = pthread_internals.h pthread.h unistd.h limits.h errno.h \
	signal.h pthread_asm.h

DEP1 = $(HDR1) Makefile

HDRS = $(HDR1) pthread_offsets.h setjmp.h mutex.h signal_internals.h

COMP_C = $(CC) $(CCFLAGS) -c $*.c
COMP_ASM = $(CC) $(CCFLAGS) -c $*.S

all: $(LIBS)

$(LIBS):: $(OBJS)
	ar ru $(LIBS) *.o
	rm *.o
	ranlib $(LIBS)

$(LIBS)(cond.o): $(DEP1) mutex.h
	$(COMP_C)

$(LIBS)(mutex.o): $(DEP1) mutex.h
	$(COMP_C)

$(LIBS)(pthread.o): $(DEP1)
	$(COMP_C)

$(LIBS)(pthread_init.o): $(DEP1)
	$(COMP_C)

$(LIBS)(signal.o): $(DEP1) mutex.h signal_internals.h
	$(COMP_C)

$(LIBS)(stack.o): $(DEP1)
	$(COMP_C)

$(LIBS)(queue.o): $(DEP1)
	$(COMP_C)

$(LIBS)(io.o): $(DEP1)
	$(COMP_C)

$(LIBS)(pthread_sched.o): pthread_sched.S pthread_asm.h pthread_offsets.h Makefile
	$(COMP_ASM)

pthread_offsets.h: get_offsets
	get_offsets > pthread_offsets.h

get_offsets: get_offsets.c $(DEP1) setjmp.h
	$(CC) $(CCFLAGS) -o $@ $@.c

lint:
	lint $(LINTFLAGS) $(CSRC)

llib:
	lint $(LINTFLAGS) -Cthreads $(SRCS)

clean:
	-rm -f $(LIBS) a.out core errs *.o *.BAK *.CKP *~ #*
