#
# RcsID = " $Header: Makefile,v 1.1 97/01/20 17:27:42 goetz Exp $ ";
#
#*********************************************************************
#
# File:          Makefile 
#
# Project:       Signal Class
#
# Description:   GNU Makefile for DSSignal class
#
# Author(s):     Ingrid Fladmark
#
# Original:   	24th of january 1997
#
# $Log:	Makefile,v $
# Revision 1.1  97/01/20  17:27:42  17:27:42  goetz (Andy Goetz)
# Initial revision
# 
#
# Copyright (c) 1996 by European Synchrotron Radiation Facility,
#                       Grenoble, France
#
#**********************************************************************
#       GNU Makefile Generated by the Automatic Class Generation Tool,  2.4 
#                                       Fri Jan 24 11:58:02 1997.
#

#---------------------------------------------------------------------
#	This Makefile works with the GNU make (sometimes called gmake)
#	It makes use of the GNU make conditional statements to support
#	multiple platforms. To use this makefile for a particular platform
#	call GNU make with the appropriate symbol for that platform
#	defined e.g. "gmake __hp9000s700=1 unix=1 all". The following symbols
#	are used to identify the following platforms :
#
#	__hp9000s700	=	HPUX 9000 series 700 
#	_solaris	=	Solaris 
#	sun		=	SunOS
#	_UCC		=	OS9 Fastrak Ultra-C Compiler
#	unix		=	various unix flavours (Solaris, HPUX, Lynx, Linux)
#	lynx		=	LynxOS
#	
#--------------------------------------------------------------------
#
#       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 
#
#--------------------------------------------------------------------
#
ifdef _UCC
LIB_HOME     =  $(DSHOME)/lib/os9
OBJS_HOME    =  $(DSHOME)/lib/os9/objs
INSTALL_HOME =  $(DSHOME)/bin/os9
endif
ifdef __hp9000s700
LIB_HOME     =  $(DSHOME)/lib/hpux10.2
INSTALL_HOME =  $(DSHOME)/bin/hpux10.2
endif
ifdef sun
LIB_HOME     =  $(DSHOME)/lib/sun4
INSTALL_HOME =  $(DSHOME)/bin/sun4
endif
ifdef _solaris
LIB_HOME     =  $(DSHOME)/lib/solaris
INSTALL_HOME =  $(DSHOME)/bin/solaris
endif
ifdef linux
LIB_HOME     =  $(DSHOME)/lib/linux/x86
INSTALL_HOME =  $(DSHOME)/bin/linux/x86
endif


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

INCLDIRS =  	-I ../include \
		-I $(DSHOME)/include \
		-I $(DSHOME)/include/private

#---------------------------------------------------------------------
# All necessary compiler flags for UNIX and OS9
#
ifdef _UCC
#               The C Compiler for OS9
CC =       	/usr/local/MWOS/UNIX/bin/hp97k/xcc

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

LFLAGS =   	$(LIBDIRS) \
		-l dsclass \
		-l dsapi \
		-l dsxdr \
		-l dbapi \
		-l dcapi \
		-l os9esrfa.l \
		-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 \
                -Wi,-l=$(LIB_HOME)/libdcapi.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 -g -to osk -tp 020ld $(INCLDIRS)
ICODE_CFLAGS =  -mode=c89 -i -j -O 7 -to osk -tp 020 $(INCLDIRS)
NAME =       	-o $@
endif

ifdef unix
#               The C Compilers for UNIX
ifdef sun
CC      =       /usr/lang/acc
endif
ifdef _solaris
CC      =       /opt/SUNWspro/SC4.2/bin/cc
endif
ifdef linux
CC      =       gcc
endif
ifdef __hpux
CC      =       /bin/cc
endif

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

NAME =       	-o 
endif

#            	Compiler flags with ANSI standart for UNIX
ifdef __hpux
CFLAGS = 	-g -DBUG -Aa -D_HPUX_SOURCE $(INCLDIRS)
endif
ifdef sun
CFLAGS = 	-Aa $(INCLDIRS)
endif
ifdef _solaris
CFLAGS  =       -Xa -Dsolaris $(INCLDIRS)
endif
ifdef linux
CFLAGS  =       -ansi -Dlinux -Dunix -D_BSD_SOURCE -D_GNU_SOURCE $(INCLDIRS)
endif


#---------------------------------------------------------------------
# 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 = DSSignal.o

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

#               source files
SRC	 =	DSSignal.c

#               object files
SVC_OBJS =	DSSignal.o

SVC_ICODE =	DSSignal.ic

CLN_OBJS =	

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

#		Names of executables 
#		and include files in the installation directories
SVC_INST   = 	$(SERVER)
CLN_INST   = 	$(CLIENT)
INCL_INST  =	
INCLP_INST = 	DSSignalP.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:		$(SVC_OBJS)

$(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


ifdef unix
all:		$(SVC_OBJS)

$(SERVER):  	$(SVC_OBJS) 
		$(CC) $(CFLAGS) $(NAME) $@ $(SVC_OBJS) $(LFLAGS)
$(CLIENT):  	$(CLN_OBJS) 
		$(CC) $(CFLAGS) $(NAME) $@ $(CLN_OBJS) $(LFLAGS)
endif


# 		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
ifdef unix
		ar rv $(LIB_HOME)/$(CLASS_LIB) $(CLASS_OBJS)
endif

#
# 		install executables		
#
ifdef _UCC
install:	$(CLASS_LIB)
#		cp $(SERVER) $(INSTALL_HOME)/$(SVC_INST)
#		cp $(CLIENT) $(INSTALL_HOME)/$(CLN_INST)
endif
ifdef unix
install:	$(CLASS_LIB)
#		cp $(SERVER) $(INSTALL_HOME)/$(SVC_INST)
#		cp $(CLIENT) $(INSTALL_HOME)/$(CLN_INST)
endif
#
#		install include files
#
		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
