#
# RcsID = " $Header: /libra/users/d/dserver/classes/test_class/src/RCS/Makefile,v 4.2 1996/03/20 16:29:53 meyer Exp goetz $ ";
#
#*********************************************************************
#
# File:          Makefile 
#
# Project:       Device Servers with SUN-RPC
#
# Description:   Makefile for test class device server
#
# Author(s):     Jens Meyer
#
# Original:   	 January 1996
#
# $Log: Makefile,v $
# Revision 4.2  1996/03/20 16:29:53  meyer
# Added ud_Inst_verify as option.
#
# Revision 4.1  96/03/19  14:43:31  14:43:31  meyer (Jens Meyer)
# Small modifications.
# 
# Revision 4.0  96/03/18  13:53:14  13:53:14  meyer (Jens Meyer)
# First test class release.
# 
#
# Copyright (c) 1990 by European Synchrotron Radiation Facility,
#                       Grenoble, France
#
#**********************************************************************

#---------------------------------------------------------------------
#
#       The variables DSHOME is passed to the Makefile
#       as input argument or via the environment.
#
#	For UltraC use the settings for the environment variables:
#	MWOS	 =	/usr/local/MWOS 
#   	PATH     =	$PATH:$MWOS/UNIX/bin/hp97k 
#   	CDEF 	 =	$MWOS/OS9/SRC/DEFS 
#   	CDEFESRF =	/usr/local/os9/dd/DEFS 
#   	CLIB 	 =	$MWOS/OS9/LIB 
#   	CLIBESRF =	/usr/local/os9/dd/LIB 
#
#	For Solaris use the settings for the environment variables:
#	LM_LICENSE_FILE=/etc/opt/licenses/sunpro.licen (on apus)
#
#
# Home Directories
#

ifdef _UCC
LIB_HOME     =  $(DSHOME)/lib/os9/
OBJS_HOME    =  $(DSHOME)/lib/os9/objs
INSTALL_HOME =  $(DSHOME)/bin/os9
endif
ifdef linux
LIB_HOME     =  $(DSHOME)/lib/linux/x86
INSTALL_HOME =  $(DSHOME)/bin/linux/x86
endif
ifdef __hp9000s700
LIB_HOME     =  $(DSHOME)/lib/s700
INSTALL_HOME =  $(DSHOME)/bin/s700
endif
ifdef __hpux10
LIB_HOME     =  $(DSHOME)/lib/hpux10.2
INSTALL_HOME =  $(DSHOME)/bin/hpux10.2
endif # __hpux10
ifdef _solaris
LIB_HOME     =  $(DSHOME)/lib/solaris
INSTALL_HOME =  $(DSHOME)/bin/solaris
endif
ifdef vw68k
LIB_HOME     =  $(DSHOME)/lib/vxworks/68k
INSTALL_HOME =  $(DSHOME)/bin/vxworks/68k
endif # vw68k


#---------------------------------------------------------------------
# All include file and standard library pathes
#
#		make sure to get always the new include files 
#		under ../include
#

CINCLDIRS =  	-I../include \
		-I$(DSHOME)/include \
		-I$(DSHOME)/include/private
ifndef vxworks
INCLDIRS=       $(CINCLDIRS)
else
ifdef vw68k
INCLDIRS=       $(CINCLDIRS) \
		-I/usr/local/tornado/target/h \
		-I/usr/local/tornado/target/h/rpc \
		-I/usr/local/tornado/target/src/config
endif # vw68k
endif # !vxworks


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

#                	Libraries
LIBDIRS =       -L$(LIB_HOME) -L$(CLIB)

LFLAGS =   	$(LIBDIRS) \
		-l dsapi \
		-l dsxdr \
		-l dbapi \
		-l rpclib.l \
		-l netdb_small.l \
		-l socklib.l \
		-l sys_clib.l \
		-l unix.l

ICODE_LFLAGS = 	$(LIBDIRS) \
                -Wi,-l=$(LIB_HOME)/libdsapi.il \
                -Wi,-l=$(LIB_HOME)/libdsxdr.il \
                -Wi,-l=$(LIB_HOME)/libdbapi.il \
                -l dsapi \
                -l rpclib.l \
                -l netdb.l \
                -l socklib.l \
                -l sys_clib.l

#              	Compiler Flags with ANSI standart for OS9
CFLAGS =       	-mode=c89 -i -to osk -tp 020 $(INCLDIRS)
ICODE_CFLAGS =  -mode=c89 -i -j -O 7 -to osk -tp 020 $(INCLDIRS)
NAME =       	-o $@
endif # _UCC

ifdef unix


#                       Libraries
LIBDIRS =       -L$(LIB_HOME)
ifdef _solaris
LFLAGS = 	-lnsl -lsocket -ldl -B static $(LIBDIRS) -ldsapi -ldbapi -ldsxdr 
else
LFLAGS = 	$(LIBDIRS) -ldsapi -ldbapi -ldsxdr
endif # _solaris
ifdef vxworks
LFLAGS = 	$(LIBDIRS) -ldsapi -ldbapi -ldsxdr -r
endif # vxworks
ifdef linux
LFLAGS = 	-static $(LIBDIRS) -ldsapi -ldbapi -ldsxdr
endif # linux


NAME =       	-o 
endif # unix

#            	Compiler flags with ANSI standart for UNIX
ifdef __hpux
CFLAGS = 	-Aa -D_HPUX_SOURCE $(INCLDIRS)
endif # __hpux
ifdef _solaris
CFLAGS  =       -Xa $(INCLDIRS)
endif # _solaris
ifdef linux
CFLAGS  =       -ansi -Dlinux -Dunix -D_BSD_SOURCE $(INCLDIRS)
endif # linux
ifdef vw68k
CFLAGS  =       -Dvxworks -Dunix -DCPU=MC68040 -ansi -m68040 \
		-fno-builtin -nostdinc -DEBUG $(INCLDIRS)
endif # vw68k


#---------------------------------------------------------------------
# RCS options to lock and check out a version.
# Or to check in a new version.
#
#               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)"

#---------------------------------------------------------------------
# Class library
# The object file representing the class has
# to be added to the class library.
#
CLASS_LIB  = libdsclass.a
CLASS_OBJS = Inst_verify.o

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

#               source files
SRC	 =	Inst_verify.c \
		startup.c \
		Inst_verify_menu.c 

#               object files
SVC_OBJS =	Inst_verify.o \
		startup.o

SVC_ICODE =	Inst_verify.ic \
		startup.ic

CLN_OBJS =	Inst_verify_menu.o 

#---------------------------------------------------------------------
# What has to be made
#
#		Names of executables in the home directory
SERVER	 = 	Inst_verify 
CLIENT	 = 	Inst_verify_menu	

#		Names of executables 
#		and include files in the installation directories
SVC_INST   = 	$(SERVER)
CLN_INST   = 	$(CLIENT)
INCL_INST  =	Inst_verify.h
INCLP_INST = 	Inst_verifyP.h


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

ifdef _UCC
#               Rule for making OS-9 relocatable files
.SUFFIXES: .ic .o .c
.c.ic:
		$(CC) $(CFLAGS) -efe $<
.c.o:
		$(CC) $(CFLAGS) -c $<
	
	
all:		$(SERVER) $(CLIENT)

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

$(CLIENT):  	$(CLN_OBJS)
		$(CC) $(CFLAGS) $(NAME) $(CLN_OBJS) $(LFLAGS)

icode:		$(SVC_ICODE)
		echo Linking with icode libraries!
		$(CC) $(ICODE_CFLAGS) -o $(SERVER) $(SVC_ICODE) $(ICODE_LFLAGS)
endif # _UCC


ifdef unix
all:		$(SERVER) $(CLIENT) 

$(SERVER):  	$(SVC_OBJS) 
ifndef vxworks
		$(CC) $(NAME) $@ $(SVC_OBJS) $(LFLAGS)
else
ifdef vw68k
#		ld68k $(NAME) $@ -r $(SVC_OBJS) $(LFLAGS)
		ld68k $(NAME) $@ $(LIB_HOME)/DevServerMain.o $(SVC_OBJS) $(LFLAGS)
endif # vw68k
endif # !vxworks
#		$(CC) $(NAME) $@ $(SVC_OBJS) $(LFLAGS)
$(CLIENT):  	$(CLN_OBJS) 
		$(CC) $(CFLAGS) $(NAME) $@ $(CLN_OBJS) $(LFLAGS)

Inst_verify_sec_menu:  	Inst_verify_sec_menu.o
		$(CC) $(CFLAGS) $(NAME) $@ Inst_verify_sec_menu.o $(LFLAGS)

ud_Inst_verify: ud_Inst_verify.o
		$(CC) $(CFLAGS) $(NAME) $@ ud_Inst_verify.o $(LFLAGS)
endif # unix


# 		Add object file representing the class
#		to the class library.
#
$(CLASS_LIB):	$(CLASS_OBJS) 
ifdef _UCC
#		For os9 all object files are kept are
#		kept in a special directory, because
#		the library has to be built by a cat
#		of all object files.
#
		cp $(CLASS_OBJS) $(OBJS_HOME)
		libgen -c $(OBJS_HOME)/?*.o -o=$(OBJS_HOME)/$(CLASS_LIB)
		cp $(OBJS_HOME)/$(CLASS_LIB) $(LIB_HOME)
		rm -rf $(OBJS_HOME)/$(CLASS_LIB)
endif # _UCC
ifdef unix
ifndef vxworks
		ar rv $(LIB_HOME)/$(CLASS_LIB) $(CLASS_OBJS)
else
		ar68k -r $(LIB_HOME)/$(CLASS_LIB) $(CLASS_OBJS)
		ranlib68k $(LIB_HOME)/$(CLASS_LIB)
endif # !vxworks
endif # unix


#
# 		install executables		
#
ifdef _UCC
install:	$(SERVER) $(CLIENT) $(CLASS_LIB)
		cp $(SERVER) $(INSTALL_HOME)/$(SVC_INST)
		cp $(CLIENT) $(INSTALL_HOME)/$(CLN_INST)
endif # _UCC
ifdef unix
install:	$(SERVER) $(CLIENT)
		cp $(SERVER) $(INSTALL_HOME)/$(SVC_INST)
		cp $(CLIENT) $(INSTALL_HOME)/$(CLN_INST)
endif # unix
#
#		install include files
#
		rm -f $(DSHOME)/include/$(INCL_INST)
		cp ../include/$(INCL_INST) $(DSHOME)/include
		chmod 664 $(DSHOME)/include/$(INCL_INST)
		rm -f $(DSHOME)/include/private/$(INCLP_INST)
		cp ../include/$(INCLP_INST) $(DSHOME)/include/private
		chmod 664 $(DSHOME)/include/private/$(INCLP_INST)


clean:	
		-rm -f $(SVC_OBJS) 
		-rm -f $(CLN_OBJS) 
		-rm -f $(SVC_ICODE)
		-rm -f *.i


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


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
#
