
#*********************************************************************
#
# File:          Makefile
#
# Project:       Device Servers with sun-rpc
#
# Description:   Makefile for DC-library libdcmem.a for the read and
#		 write servers
#
#		 Please use the conditional Makefile commands !
#
# Author(s):     Andy Gotz
#
# Original:	 December 2000
#
#
# Copyright (c) 2000 by European Synchrotron Radiation Facility,
#                       Grenoble, France
#
#                       All Rights Reserved
#
#**********************************************************************

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

ifdef __hpux10
INSTALL_HOME =  $(DS_HOME)/lib/hpux10.2
INSTALL_HOME_SL =  $(DS_HOME)/lib/hpux10.2
endif
ifdef _solaris
INSTALL_HOME = 	$(DS_HOME)/lib/solaris
INSTALL_HOME_SL = 	$(DS_HOME)/lib/solaris
endif
ifdef linux
ifdef 68k
INSTALL_HOME =  $(DS_HOME)/lib/linux/68k
INSTALL_HOME_SL =  $(DS_HOME)/lib/linux/68k
else # 68k
INSTALL_HOME =  $(DS_HOME)/lib/linux/x86
INSTALL_HOME_SL =  $(DS_HOME)/lib/linux/x86
endif # 68k
endif # linux

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

#                       Libraries
#               There's no link phase - ergo no libraries to include
NAME    =       -o


#                       Optimizer or ANSI standart ?
ifdef __hpux
CFLAGS  =       -Aa -g -DBUG -Dunix -D_HPUX_SOURCE -c $(INCLDIRS) \
		$(EXTRACFLAGS)
CFLAGS_SL  =    $(CFLAGS) +z
endif # __hpux
ifdef _solaris
ifdef NATIVE
CFLAGS  =       -Xa -g -Dsolaris -DBUG -c $(INCLDIRS) $(EXTRACFLAGS)
CFLAGS_SL  =    $(CFLAGS) -KPIC
else
CFLAGS  =       -g -Dsolaris -DBUG -c $(INCLDIRS) $(EXTRACFLAGS)
CFLAGS_SL  =    $(CFLAGS) -fPIC
endif # NATIVE
endif # _solaris
ifdef linux
CFLAGS  =      	$(INCLDIRS) -Dlinux -Dunix -DALONE -g $(EXTRACFLAGS)
endif # linux


#---------------------------------------------------------------------
# All files needed for the library
#
#		include files
INCL 	=	dc.h \
		dc_xdr.h \
		dcrd_xdr.h \
		dcwr_xdr.h

#		source files
SRC  	=	dc_hash.c \
		dcmem_alloc.c \
		dcmem_free.c \
		dcmem_info.c

#		object files
OBJS  	=	dc_hash.o \
		dcmem_alloc.o \
		dcmem_free.o \
		dcmem_info.o

#--------------------------------------------------------------------
# What has to be made
#
LIBNAME	   =	libdcmem.a

#---------------------------------------------------------------------
# Build library

all:	$(OBJS) $(LIBNAME)

#
# DO NOT recompile everything everytime
#
#$(OBJS):	
#		$(CC) $(CFLAGS) $(SRC)


# define a rule for making shared library objects (suffice .sl.o)
.SUFFIXES: .sl.o .c
.c.sl.o:
		$(CC) $(CFLAGS_SL) $< -o $*.sl.o


#		Make library
$(LIBNAME):	$(OBJS)
		ar rv $(LIBNAME) $(OBJS)
ifdef solaris
		ranlib $(LIBNAME)
endif # solaris

install :	$(LIBNAME) 
#		intall the library
		cp $(LIBNAME) $(INSTALL_HOME)
#		install the include files
#
clean :		
		rm -rf $(OBJS)	


clobber:	clean
		rm -rf	$(LIBNAME) 
