# ------------------------------------------------------------
# Makefile 
#
# Mauricio De Simone
# mdesimon@interlog.com
#
# Copyright (C) 1998  Mauricio De Simone
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation version 2.
# 
# This program is distributed 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 General Public License for more details.
# ------------------------------------------------------------

# -- Macro Definitions

D_BIN		= ./bin
D_DFE		= .
D_HDR		= ./include
D_STL		= ./include/HPstl
D_TST		= ./tst

CC		= CC
CFLAGS		= -D_PMAIN -D_REENTRANT -g -lthread -lsocket -lnsl 


JUNK		= *~ *.o core

# ------------------------------------------------------------
# -- Mode
# ------------------------------------------------------------
RTS			=				\
			-DSHMEM=0			\
			-DDISTMEM=1


# ------------------------------------------------------------
# -- Portability section
# ------------------------------------------------------------
HELPERS			= 				\
			-DSTL=1

THREAD_PACKAGE		=				\
			-DPTHREADS=0			\
			-DUITHREADS=1

PLATFORM		=				\
			-DSOLARIS=1			\
			-DAIX=0			

# ------------------------------------------------------------
# -- Debuging Level
# ------------------------------------------------------------
DEBUG_LEVEL		=				\
			-DDEBUG=1			\
			-DDEBUG_EE=1			\
			-DDEBUG_EE_MUTEX=0

# ------------------------------------------------------------
# -- Groups
# ------------------------------------------------------------

X_TST			=				\
			${D_BIN}/simplepipe		\
			${D_BIN}/taskfarm		\
			${D_BIN}/outfarm		\
			${D_BIN}/infarm			\

H_USR			=				\
			${D_HDR}/Ae.H

H_INTERNAL		=				\
			${D_HDR}/aehandle.H		\
			${D_HDR}/autoptr.H		\
			${D_HDR}/bang.H			\
			${D_HDR}/channel.H		\
			${D_HDR}/command.H		\
			${D_HDR}/commandhandler.H	\
			${D_HDR}/commengine.H		\
			${D_HDR}/commreply.H		\
			${D_HDR}/concexec.H		\
			${D_HDR}/cond.H			\
			${D_HDR}/createremotequeue.H	\
			${D_HDR}/createthreadinfo.H	\
			${D_HDR}/cycle.H		\
			${D_HDR}/deamon.H		\
			${D_HDR}/debug.H		\
			${D_HDR}/debug_s.H		\
			${D_HDR}/debugstate.H		\
			${D_HDR}/debugstate_s.H		\
			${D_HDR}/declarations.H		\
			${D_HDR}/deque.H		\
			${D_HDR}/dequehandler.H		\
			${D_HDR}/dfehandle.H		\
			${D_HDR}/dfenode.H		\
			${D_HDR}/dfeopnode.H		\
			${D_HDR}/enque.H		\
			${D_HDR}/eoq.H			\
			${D_HDR}/exception.H		\
			${D_HDR}/exception_s.H		\
			${D_HDR}/exsafethreadep.H	\
			${D_HDR}/exsafethreadep_s.H	\
			${D_HDR}/fail.H			\
			${D_HDR}/forward.H		\
			${D_HDR}/handler.H		\
			${D_HDR}/helpers.H		\
			${D_HDR}/initcommands.H		\
			${D_HDR}/initcommands_s.H	\
			${D_HDR}/initservers.H		\
			${D_HDR}/io.H			\
			${D_HDR}/joinhandler.H		\
			${D_HDR}/joinmanager.H		\
			${D_HDR}/limits.H		\
			${D_HDR}/localchannel.H		\
			${D_HDR}/msg.H			\
			${D_HDR}/mtautoptr.H		\
			${D_HDR}/mtvector.H		\
			${D_HDR}/mutex.H		\
			${D_HDR}/mutex_s.H		\
			${D_HDR}/pipe.H			\
			${D_HDR}/pmain.H		\
			${D_HDR}/pqueue_i.H		\
			${D_HDR}/pqueue_s.H		\
			${D_HDR}/pqueuechannel.H	\
			${D_HDR}/pqueuehandle.H		\
			${D_HDR}/pqueueinstantiator.H	\
			${D_HDR}/pqueueloc.H		\
			${D_HDR}/pqueueremote.H		\
			${D_HDR}/proc_t.H		\
			${D_HDR}/procbind.H		\
			${D_HDR}/procmap.H		\
			${D_HDR}/recursivesync.H	\
			${D_HDR}/reduce.H		\
			${D_HDR}/rep.H			\
			${D_HDR}/rts.H			\
			${D_HDR}/sautoptr.H		\
			${D_HDR}/semaphore.H		\
			${D_HDR}/server.H		\
			${D_HDR}/serverstatus.H		\
			${D_HDR}/singleton.H		\
			${D_HDR}/shared.H		\
			${D_HDR}/singmanage.H		\
			${D_HDR}/sizeable.H		\
			${D_HDR}/socket.H		\
			${D_HDR}/startup.H		\
			${D_HDR}/stopcommands.H		\
			${D_HDR}/stream.H		\
			${D_HDR}/synchronize.H		\
			${D_HDR}/tcpserver.H		\
			${D_HDR}/terminate.H		\
			${D_HDR}/terminateserver.H	\
			${D_HDR}/thread.H		\
			${D_HDR}/thread_s.H		\
			${D_HDR}/thread_t.H		\
			${D_HDR}/threadedhandler.H	\
			${D_HDR}/threadgroup_t.H	\
			${D_HDR}/threadremotecreate.H	\
			${D_HDR}/threadremotejoin.H	\
			${D_HDR}/types.H		\
			${D_HDR}/wait.H			\
			${D_HDR}/we.H			\
			${D_HDR}/we_s.H			\
			${D_HDR}/weboot.H		\
			${D_HDR}/wefactory.H

H_TST			=				\
			${D_TST}/tst.H

SRC			=				\
			./Makefile			\
			${H_USR}			\
			${H_INTERNAL}			\
			${H_TST}

# ------------------------------------------------------------
# -- Internal stuff (do not touch)
# ------------------------------------------------------------

_CFLAGS		=	${CFLAGS} ${DEBUG_LEVEL} 	\
			${THREAD_PACKAGE} ${PLATFORM}	\
			-I${D_HDR} -I${D_STL}		\
			${HELPERS} ${RTS}

# ------------------------------------------------------------
# -- Rules
# ------------------------------------------------------------

all		:	${X_TST}

${X_TST}	: ${D_TST}/${${@F}:=.C} ${SRC}
	${CC} -o $@ ${_CFLAGS} ${D_TST}/${@F:=.C}


# ------------------------------------------------------------
# -- Utilities
# ------------------------------------------------------------
ship		:	sterile
	cd ..; tar fc src.`date +%d_%m`.tar src; 	\
	chmod go-r src.`date +%d_%m`.tar; 		\
	gzip -9 src.`date +%d_%m`.tar

clean		:
	rm -f ${JUNK}
	rm -f */${JUNK}

sterile		:	clean
	#ptclean
	rm -rf ${STERILE} ${X_TST}



