#
# RcsID = " $Header: Makefile,v 1.8 92/11/11 13:26:54 meyer Exp $ ";
#
#*********************************************************************
#
# File:          Makefile
#
# Project:       Device Servers with sun-rpc
#
# Description:   Makefile for the network manager
#
# Author(s):     Jens Meyer
#
# Original:      January 1991
#
#
# $Revision: 1.8 $
# $Date: 92/11/11 13:26:54 $
#
# $Author: meyer $
#
# $Log:	Makefile,v $
# Revision 1.8  92/11/11  13:26:54  13:26:54  meyer (Jens Meyer)
# Added compile options.
# 
# Revision 1.7  92/11/11  12:06:52  12:06:52  meyer (Jens Meyer)
# Standart Makefile
# 
# Revision 1.6  92/11/10  11:26:36  11:26:36  meyer (Jens Meyer)
# corrected bugs
# 
# Revision 1.5  92/11/10  11:00:46  11:00:46  meyer (Jens Meyer)
# Standardised the Makefile.
# 
# Revision 1.4  92/05/12  09:24:53  09:24:53  meyer (Jens Meyer)
# changed library pathes.
#
# Revision 1.3  91/04/22  15:53:50  15:53:50  meyer ()
# added link to database library
#
# Revision 1.2  91/03/28  10:54:15  10:54:15  meyer ()
# added compilation with CC68
#
# Revision 1.1  91/02/26  10:14:00  10:14:00  meyer ()
# Initial revision
#
#
#
# Copyright (c) 1990 by European Synchrotron Radiation Facility,
#                       Grenoble, France
#
#                       All Rights Reserved
#
#**********************************************************************

#---------------------------------------------------------------------
# Home Directories
#
#
#       The variables DSHOME is passed to the Makefile
#       as input argument or via the environment.
#
# external variable DSHOME
DS_HOME =       $(DSHOME)

ifdef OSK
LIB_HOME     =  $(DS_HOME)/lib/os9
INSTALL_HOME =  $(DS_HOME)/system/bin/os9
endif
ifdef __hp9000s300
LIB_HOME     =  $(DS_HOME)/lib/s300
INSTALL_HOME =  $(DS_HOME)/system/bin/s300
endif
ifdef __hp9000s700
LIB_HOME     =  $(DS_HOME)/lib/s700
INSTALL_HOME =  $(DS_HOME)/system/bin/s700
endif
ifdef __hp9000s800
LIB_HOME     =  $(DS_HOME)/lib/s800
INSTALL_HOME =  $(DS_HOME)/system/bin/s800
endif
ifdef _solaris
LIB_HOME     =  $(DS_HOME)/lib/solaris
INSTALL_HOME =  $(DS_HOME)/system/bin/solaris
endif
ifdef linux
ifdef x86
LIB_HOME     =  $(DS_HOME)/lib/linux/x86
INSTALL_HOME =  $(DS_HOME)/system/bin/linux/x86
else
LIB_HOME     =  $(DS_HOME)/lib/linux/68k
INSTALL_HOME =  $(DS_HOME)/system/bin/linux/68k
endif
endif


#---------------------------------------------------------------------
# All necessary compiler flags for UNIX and OS9
#
ifdef OSK
#               The C Compiler for OS9

#               ... and his Flags
#                       Includes
INCLDIRS =  	-v=../include \
		-v=$(DSHOME)/include \
		-v=$(DSHOME)/include/private

#                       Libraries
LFLAGS =       	-l=$(LIB_HOME)/os9-dsapilib.l \
		-l=$(LIB_HOME)/os9-dsxdrlib.l \
		-l=$(LIB_HOME)/os9dbapi.l \
		-l=$(CLIB)/rpclib.l \
		-l=$(CLIB)/netdb.l \
		-l=$(CLIB)/socklib.l \
		-l=$(CLIB)/math881.l \
		-l=$(CLIB)/clib020h.l

#               Compiler Flags
CFLAGS =       	-Q -DBUG -DOPERATOR -K=2F $(INCLDIRS) 
NAME =       	-fd=$@
endif

ifdef unix
#
#               ... and his Flags
#                       Includes
INCLDIRS =      -I../include \
		-I$(DSHOME)/include \
		-I$(DSHOME)/include/private \
		-I../../api/apilib/include

#                       Libraries
LIBDIRS =       -L$(LIB_HOME)
ifdef _solaris
LFLAGS = 	$(LIBDIRS) -ldsxdr -ldsapi -ldbapi -ldsxdr \
		-lnsl -lsocket -lrt
else
LFLAGS = 	$(LIBDIRS) -ldsxdr -ldsapi -ldbapi -ldsxdr
endif # _solaris

NAME =       	-o 
endif

#            	Optimizer and ANSI standart for UNIX
ifdef __hpux
CFLAGS = 	-O -DBUG -Dunix -Aa -D_HPUX_SOURCE $(INCLDIRS) 
endif
ifdef _solaris
CFLAGS = 	-O -DBUG -Dunix $(CCOPTIONS) $(INCLDIRS) 
endif
ifdef linux
ifdef x86
CFLAGS  =      	-Dlinux -Dlinuxx86 -Dunix -D_BSD_SOURCE -ansi -DEBUG \
		$(INCLDIRS) -g 
else
CFLAGS  =      	-Dlinux -Dlinux68k -Dunix -D_BSD_SOURCE -ansi -DEBUG \
		-c $(INCLDIRS) -g
endif
endif


#---------------------------------------------------------------------
# RCS options
#
#               RCS lock options
RCSLOCK =      	co -l -r$(VERSION)
#               RCS check out options
RCSCO   =      	co -r$(VERSION)
#               RCS check in options
RCSCI   =      	ci -u -f -s"Rel" -r$(VERSION) -m"$(LOCKMSG)"


#---------------------------------------------------------------------
# All Files needed for the Server and the client
#
#               all include files
INCL     =	ManagerP.h

#               source files
SRC	 =	Manager.c \
		ManagerMain.c

#               object files
ifdef OSK
SVC_OBJS =	Manager.r \
		ManagerMain.r
endif

ifdef unix
SVC_OBJS =	Manager.o \
		ManagerMain.o
endif


#---------------------------------------------------------------------
# What has to be made
#
#		Names of executables in the home directory
ifdef OSK
SERVER	 = 	Manager.os9
endif
ifdef unix
SERVER	 = 	Manager
endif

#		Names of executables in the installation directory
SVC_INST = 	Manager


#---------------------------------------------------------------------
# build server and client
#

ifdef OSK
#               Rule for making OS-9 relocatable files (.r)
.SUFFIXES:      .r .cpp

all:		$(SERVER)

$(SERVER):  	$(SVC_OBJS) 
		$(CC) $(CFLAGS) $(NAME) $(SVC_OBJS) $(LFLAGS) $(LFLAGS)

.c.r:
		$(CC) $(CFLAGS) -r $<
		@echo
endif


ifdef unix
all:		$(SERVER) unreg

$(SERVER):  	$(SVC_OBJS)
		$(CC) $(NAME) $@ $(SVC_OBJS) $(LFLAGS)

unreg:  	unreg.o
		$(CC) $(NAME) $@ unreg.o $(LFLAGS)
endif



install:	$(SERVER) unreg
		cp $(SERVER) $(INSTALL_HOME)/$(SVC_INST)
		cp unreg $(INSTALL_HOME)


clean:	
		-rm -f $(SVC_OBJS) unreg.o


clobber:	clean
		-rm -f $(SERVER) unreg


lock:
		$(RCSLOCK) $(SRC)
		cd ../include; $(RCSLOCK) $(INCL); cd ../src

co:
		$(RCSCO) $(SRC)
		cd ../include; $(RCSCO) $(INCL); cd ../src

ci:
		$(RCSCI) $(SRC)
		cd ../include; $(RCSCI) $(INCL); cd ../src
#
#
