#*********************************************************************
#
# File          :   Makefile
#
# Project       :   GRETA (Graphical Resource Editor for TAco)
#
# Description   :   GNU Multi-Platform Makefile
#
# Author(s)     :   Faranguiss Poncet
#
# Original      :   March 1997
#
#
# $Revision: 3.0 $			$Author: taurel $
# $Date: 98/08/20 17:30:53 $		$State: Rel $
#
# $Log:	Makefile,v $
# Revision 3.0  98/08/20  17:30:53  17:30:53  taurel (E.Taurel)
# Adapted to db software release 6.x
# 
# Revision 2.7  98/01/27  13:49:37  13:49:37  taurel (E.Taurel)
# No change. CO only for test
# 
# Revision 2.6  98/01/27  13:14:38  13:14:38  taurel (E.Taurel)
# Fix a bug in the pdbset_allresdel function (greta_db.c file) when the device list is plitted into several lines
# 
# Revision 2.5  97/07/15  14:01:45  14:01:45  taurel (E.Taurel)
# Fixed a bug in the membres_lgcmp function when the resource was an array
# with more than 10 characters.
# 
# Revision 2.4  97/06/09  16:37:32  16:37:32  taurel (E.Taurel)
# Remove passwd window from help menu.
# 
# Revision 2.3  97/05/16  18:32:27  18:32:27  poncet (F.Poncet)
# Added the window for input of the security resources password.
# Added the 2 associated callbacks : PasswdCancelCb and PasswdOkCb
# in the greta_cb.c file. These functions should be completed.
# For the test purpose the window for the input of the password is poped
# up when the user clicks on the help-->On Application button of the
# main window menu bar.
# 
# Revision 2.2  97/05/16  13:17:13  13:17:13  poncet (F.Poncet)
# Added the "Load" function in the main window to read and unpdate
# resource from a text file.
# Modified some "attachment" resources of XmForm widget so that the
# "Open device" window and "Open resource window" do not grow any more.
# 
# Revision 2.1  97/05/12  18:50:40  18:50:40  poncet (F.Poncet)
# Added chaining of the device resources in the "Server" windows.
# Changed the suffix of generated files from ".gres" to ".res".
# Added in ALL GENERATED files three lines of comments to show that which
# version of Greta has generated the file.
# Changed the label for the "chaining device resources" from "Chain ..." to
# "Insert ...." in Device Windows Edit pulldown menus as well as in the
# Server Windows Edit pulldown menus.
# 
# Revision 2.0  97/04/09  16:21:08  16:21:08  poncet (F.Poncet)
# First Archive of the Gnu Multi plateform Makefile.
# 
# 
# 
# 
#
# Copyright (c) 1997 by European Synchrotron Radiation Facility, 
#                       Grenoble, France
#
#		       All Rights Reserved
#
#**********************************************************************
#

#---------------------------------------------------------------------
#	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 set inside this Makefile. So it does
#       not use your own environment varaible $DSHOME.
#
#       Only TWO plateforms are supported in this Makefile : Hpux and Solaris
#
#
#--------------------------------------------------------------------
#
DSHOME	= /segfs
APPLI_HOME = /segfs/mcs/appli


INSTALL_DEFAULT = $(APPLI_HOME)/app-defaults



ifdef __hpux10
DS_LIB_HOME	= $(DSHOME)/dserver/lib/hpux10.2
EXEC_DIR	= hpux10.2
LIB_DIR		= hpux10.2

MOTIF_INC_HOME	= /usr/include/Motif1.2
X11_INC_HOME	= /usr/include/X11R5
MOTIF_LIB_HOME	= /usr/lib/Motif1.2
X11_LIB_HOME	= /usr/lib/X11R5

INSTALL_BIN	= $(APPLI_HOME)/bin/s700
endif


ifdef _solaris
DS_LIB_HOME	= $(DSHOME)/dserver/lib/solaris
EXEC_DIR	= solaris
LIB_DIR		= solaris

MOTIF_INC_HOME	= /usr/dt/include
X11_INC_HOME	= /usr/openwin/include
MOTIF_LIB_HOME	= /usr/dt/lib
X11_LIB_HOME	= /usr/openwin/lib

INSTALL_BIN	= $(APPLI_HOME)/bin/solaris
endif

ifdef linux
DS_LIB_HOME	= $(DSHOME)/dserver/lib/linux/x86
EXEC_DIR	= linux
LIB_DIR		= linux

#MOTIF_INC_HOME	= /home/goetz/lesstif/lesstif/include
MOTIF_INC_HOME	= /usr/X11/R6/include
X11_INC_HOME	= /usr/X11R6/include
#MOTIF_LIB_HOME	= /home/goetz/lesstif/lesstif/lib
MOTIF_LIB_HOME	= /usr/X11/R6/lib
X11_LIB_HOME	= /usr/X11R6/lib

INSTALL_BIN	= $(APPLI_HOME)/bin/linux
endif

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


INCLDIRS =  	-I ../include \
		-I $(DSHOME)/dserver/include \
		-I $(MOTIF_INC_HOME) \
		-I $(X11_INC_HOME)


#---------------------------------------------------------------------
# All necessary compiler flags for UNIX
#
#                	Libraries

NAME =       	-o 

#               The C Compilers for UNIX
ifdef _solaris
CC      = /opt/SUNWspro/SC4.2/bin/cc
endif
ifdef __hpux10
CC      = /bin/cc
endif
ifdef linux
CC	= /usr/local/bin/gcc
endif

#                       Libraries
LIBDIRS =	-L $(DS_LIB_HOME) \
		-L $(DS_LIB_HOME)/hdb \
		-L $(MOTIF_LIB_HOME) \
		-L $(X11_LIB_HOME)


#            	Compiler flags with ANSI standard for UNIX
ifdef __hpux10
CFLAGS  =       -g -Aa -Dunix -D_HPUX_SOURCE -DXK_MISCELLANY $(INCLDIRS)
CFLAGS_NDBM =	$(CFLAGS) -DNDBM_USED
LFLAGS =	-Wl,+s $(LIBDIRS) \
		-lXm -lXt -lX11 \
		-lhdb -lhdbsql `cat /segfs/dserver/lib/hpux10.2/hdb/ora_link` \
		-ldcapi -ldbapi -ldsapi -ldsxdr -ldld -lm
endif

ifdef _solaris
CFLAGS  =       -Xa -g -Dsolaris -DXK_MISCELLANY -c $(INCLDIRS)
CFLAGS_NDBM =	$(CFLAGS) -DNDBM_USED
LFLAGS =	$(LIBDIRS) \
		-R /usr/dt/lib -lXm -lXt -lX11 \
		-lhdb -lhdbsql `cat /segfs/dserver/lib/solaris/hdb/ora_link` \
		-ldcapi -ldsapi -ldbapi -ldsxdr -lm \
		-lnsl -lsocket
endif

ifdef linux
CFLAGS  =       -g -DXK_MISCELLANY -D_BSD_SOURCE $(INCLDIRS)
CFLAGS_NDBM =	$(CFLAGS) -DNDBM_USED
LFLAGS =	$(LIBDIRS) \
		/usr/X11R6/lib/libXm.so.2.0 -lXt -lX11 -lXext \
		-ldcapi -ldbapi -ldsapi -ldsxdr -lm
endif

#---------------------------------------------------------------------
# RCS options to lock and check out a version.
# Or to check in a new version.
#
#    call format :
#
#         gmake __hp9000s700=1 unix=1 VERSION=y.xx LOGMSG=.... RCSCI
#         gmake __hp9000s700=1 unix=1 VERSION=y.xx RCSCO
#         gmake __hp9000s700=1 unix=1 VERSION=y.xx RCSLOCK
#

#               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 application
#
#               all include files
INCL	 = 	greta.h greta_cstes.h

#               source files
SRC	 =	greta.c greta_creation.c bxutil-c.c greta_cb.c greta_xs.c \
		greta_misc.c greta_sdd.c greta_win.c servutil.c devutil.c \
		greta_update.c greta.uil GReta

#               object files
OBJS	 =	greta.o greta_creation.o bxutil-c.o greta_cb.o greta_xs.o \
		greta_misc.o greta_sdd.o greta_win.o servutil.o devutil.o \
		greta_update.o

OBJS_NDBM =	greta.o greta_creation.o bxutil-c.o greta_cb.o greta_xs.o \
		greta_misc.o greta_sdd.o greta_win.o servutil.o devutil.o \
		greta_update.ndbm.o

#--------------------------------------------------------------------
# What has to be made
#
#		Name of the application

APPLI	= greta
APPLI_NDBM = greta_ndbm


#---------------------------------------------------------------------
#
# Rules for building files
#
#
.SUFFIXES:	.c .o
	
.c.o:
	$(CC) $(CFLAGS) -c $*.c
	
.SUFFIXES:	.c .ndbm.o

.c.ndbm.o:
	$(CC) $(CFLAGS_NDBM) -c $*.c -o $*.ndbm.o

#---------------------------------------------------------------------
# build the application
#

	
all:		$(APPLI) $(APPLI_NDBM)



$(APPLI): $(OBJS)
		$(CC) $(NAME) $(EXEC_DIR)/oracle/$(APPLI) $(OBJS) $(LFLAGS)

$(APPLI_NDBM): $(OBJS_NDBM)
		$(CC) $(NAME) $(EXEC_DIR)/ndbm/$(APPLI) $(OBJS_NDBM) $(LFLAGS)
		
install: $(APPLI)
		mv $(INSTALL_BIN)/$(APPLI) $(INSTALL_BIN)/OLD
		cp $(APPLI) $(INSTALL_BIN)/$(APPLI)

install_default: GReta
		mv $(INSTALL_DEFAULT)/GReta $(INSTALL_DEFAULT)/OLD
		cp GReta $(INSTALL_DEFAULT)/GReta



clean:	
		-rm -f $(OBJS) greta_update.ndbm.o


clobber:	clean
		-rm -f $(APPLI)


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

