################################################################################
#																			   #
#  Makefile for WAMM 1.0 - 21/6/95											   #
#																			   #
################################################################################


#
#          WAMM version 1.0: Wide Area Metacomputer Manager
#     CNUCE - Institute of the Italian National Research Council
#      Authors:  R. Baraglia, G. Faieta, M. Formica, D. Laforenza
#                   (C) 1995 All Rights Reserved
#
#                              NOTICE
#
#
# Permission is hereby granted, without written agreement and without license
# or royalty fees, to use, copy, modify, and distribute this software and
# its documentation for educational and research purpose only, provided that
# the above copyright notice and the following two paragraphs appear in all
# copies of this software and in the supporting documentation. No charge,
# other than an "at-cost" distribution fee, may be charged for copies,
# derivations, or distributions of this material without the express written
# consent of the copyright holder.
# 
# IN NO EVENT SHALL THE INSTITUTION (CNUCE-CNR) AND THE AUTHORS BE LIABLE TO
# ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
# DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
# IF THEINSTITUTION OR THE AUTHORS HAS BEEN ADVISED OF THE POSSIBILITY OF 
# SUCH DAMAGE.
#
# THE INSTITUTION (CNUCE-CNR) AND THE AUTHORS SPECIFICALLY DISCLAIMS ANY 
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
# ON AN "AS IS" BASIS, AND THE AUTHORS HAS NO OBLIGATION TO
# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.



#### Change these according to your system: ####

INCLUDE_MOTIF = -I/usr/include/Motif1.2			# Motif header files path
INCLUDE_X     = -I/usr/include/X11R5			# X11 header files path
INCLUDE_XPM   = -I$(HOME)/include				# xpm header files path
INCLUDE_PVM   = -I$(PVM_ROOT)/include			# pvm header files path

LIB_MOTIF     = -L/usr/lib/Motif1.2				# Motif library path
LIB_X         = -L/usr/lib/X11R5				# X11 library path
LIB_XPM       = -L$(HOME)/lib					# xpm library path
LIB_PVM       = -L$(PVM_ROOT)/lib/$(PVM_ARCH)	# pvm library path

#### "ping" path: (reverse comments if you don't have ping ####

PING	  = -DPINGPATH=\"/etc/ping\"
#PING     =

#### "traceroute" path: (reverse comments if you don't have traceroute) ####

TROUTE    = -DTROUTEPATH=\"/disc2/users/meta/bin/traceroute\"
#TROUTE   =

#### remote shell path: ####

RSH		  = -DRSHPATH=\"/usr/bin/rsh\"

#### Compiler: ####

CC  = gcc

#### Compiler flags: ####

SOURCEFLAGS	  = -Wall
LINKFLAGS	  = -s

#### Destination directory for main program: ####

MASTERDIR	= $(HOME)/bin

#### Destination directory for slave programs: ####

SLAVEDIR	= $(PVM_ROOT)/bin/$(PVM_ARCH)

#### Program used to install executable files: ####

INSTALL = install -m 755
# INSTALL = cp

###############################################################################
#### Don't touch anything below! ##############################################
###############################################################################

INCLUDES    = $(INCLUDE_MOTIF) $(INCLUDE_X) $(INCLUDE_XPM) $(INCLUDE_PVM)
LIBS        = $(LIB_MOTIF) $(LIB_X) $(LIB_XPM) $(LIB_PVM)

all: master slaves
master: bin/wamm
slaves: bin/PVMTasker bin/PVMHoster bin/PVMMaker

OBJS	 =	src/main.o \
			src/modNetworkObj.o \
			src/modParser.o \
			src/modPVM.o \
			src/modInternet.o \
			src/modWAN.o \
			src/modMAN.o \
			src/modLAN.o \
			src/modTasks.o \
			src/modSpawn.o \
			src/modMake.o \
			src/motifutil.o \
			src/util.o

bin/wamm: $(OBJS)
	$(CC) -o $@ $(LINKFLAGS) $(OBJS) $(LIBS) -lXpm -lXm -lXt -lXmu -lXext -lX11 -lpvm3

bin/PVMTasker: src/PVMTasker.c src/util.c
	$(CC) -o $@ $(SOURCEFLAGS) $(LINKFLAGS) $(INCLUDE_PVM) $? $(LIB_PVM) -lpvm3

bin/PVMHoster: src/PVMHoster.c
	$(CC) -o $@ $(SOURCEFLAGS) $(LINKFLAGS) $(RSH) $(INCLUDE_PVM) $? $(LIB_PVM) -lpvm3

bin/PVMMaker: src/PVMMaker.c
	$(CC) -o $@ $(SOURCEFLAGS) $(LINKFLAGS) $(INCLUDE_PVM) $? $(LIB_PVM) -lpvm3

.c.o:
	$(CC) $(SOURCEFLAGS) $(INCLUDES) $(PING) $(TROUTE) -c $< -o $@
	
clean:
	rm -f src/*.o bin/wamm bin/PVMTasker bin/PVMHoster bin/PVMMaker

install: install-master install-slaves

install-master: bin/wamm
	$(INSTALL) $? $(MASTERDIR)
	
install-slaves: bin/PVMTasker bin/PVMMaker bin/PVMHoster bin/PVMKill
	$(INSTALL) $? $(SLAVEDIR)
	
package:
	mkdir /tmp/wamm10
	cp -R * /tmp/wamm10
	rm -f /tmp/wamm10/src/*.o
	rm -f /tmp/wamm10/bin/PVMTasker
	rm -f /tmp/wamm10/bin/PVMHoster
	rm -f /tmp/wamm10/bin/PVMMaker
	rm -f /tmp/wamm10/bin/wamm
	tar cvf /tmp/wamm10.tar -C /tmp wamm10
	gzip -best /tmp/wamm10.tar
	mv /tmp/wamm10.tar.gz .
	rm -Rf /tmp/wamm10
	
