#!/bin/csh
#	@(#)makecalldaemon	1.12	09/03/97
#
#
#
#     $Id: makecalldaemon,v 1.5 2002/05/29 16:11:44 avvede Exp $
#     $Log: makecalldaemon,v $
#     Revision 1.5  2002/05/29 16:11:44  avvede
#     New rules
#
#     Revision 1.2.4.1  2000/04/07 20:15:58  avvede
#     Added _progid_
#
#     Revision 1.2  1998/06/24 17:02:21  avvede
#     Added nodisam
#
#     Revision 1.1  1998/03/16 20:02:56  avvede
#     Initial move to CVS
#
#
#
#	Copyright (c) 1986, 1987, 1988 by
#	Periphonics Corporation
#	4000 Veterans Memorial Highway
#	Bohemia
#	NY 11716
#
#	This software is furnished under a license and may be used and
#	copied only in accordance with the terms of such license and with
#	the inclusion of the above copyright notice. This software or any
#	other copies thereof, may not be provided or otherwise made available
#	to anyone other than the licensee. Title to and ownership of this
#	software remains with the Periphonics Corporation.
#
#	The information in this document is subject to change without notice
#	and should not be construed as a commitment by Periphonics.
#
#	Periphonics assumes no responsibility for the use or reliability of
#	its software on equipment that is not supplied by Periphonics.
#
#	File Name:
#		makecalldaemon
#
#	Description:
#		Building customized vengine
#
#	Change				Reason
#	No.	Date		Name	for Change
#
#	1	13-dec-93	lmg	File created.
#	2	21-jun-94	lmg	Added vapi lib.
#	3	01-aug-94	lmg	Added option -e.
#	4	21-nov-94	lmg	Removed malloc lib.
#	5	03-feb-95	lmg	Made it static.
#	6	27-feb-95	lmg	Changed to ld.
#       7       09-aug-95       lmg     Put customer's options at the end. 
#	8	14-nov-96	jpm	added sql call libs to ccline
#	9	15-may-97	lmg	Removed sql libs.
#	10	19-jun-97	lmg	Merged with rel5.
#
if ( ${?ASEHOME} == 0 ) then
	echo "$0 : Environment ASEHOME is not set"
	exit 1
endif
#
# Help
#
if ($#argv == 1 && ("$1" == "-help" || "$1" == "?")) then
	echo Usage: makecalldaemon \[arguments\] \[-o new_name\]
	exit 1
endif

#
# Check if it's IS
#
set is="yes"
if ( -r ${ASEHOME}/etc/services ) then
	set vvpether=`egrep '^vvpether' ${ASEHOME}/etc/services`
	if ( "$vvpether" != "" ) then
		set is="no"
	endif
endif

#
# Use cc (IS) or ld (rel4.5)
#
if ( $is == "yes" ) then					# IS

	set program="-o calldaemon"
	set ccline = "cc -L${ASEHOME}/lib -L${ASEHOME}/rlib"

else								# 4.5

	set program="-o ${ASEHOME}/bin/calldaemon"
#
# 	Find current version
#
	set ver=`/usr/bin/uname -r`
	if ( "$ver" != "5.3" ) then
		set ver="5.4"		# Defaults to Solaris 5.4
	endif
	set ccline = "ld -L${ASEHOME}/lib ${ASEHOME}/etc/${ver}/*.o"
endif

set progname = "vengine"
set opts="$*"
#
# Output name.  Check if they want to change it
#
while ( $#argv )
	if ( "$1" == "-o" ) then
		set progname = $2
		set program=				# do not use default
		break
	endif
	shift
end
#
# Generate ID
#

if ( $is == "yes" ) then					# IS
#
# 	Create a file containing an SCCS string so the date this
# 	vengine was linked can be established.
#
	set build_date = `/bin/date '+%m/%d/%Y %j %H:%M'`
	set cxsrc = "/tmp/cx_calldaemon.c"
	set cxobj = "/tmp/cx_calldaemon.o"
	/bin/rm -f $cxsrc $cxobj
	echo -n "char _progid_[] = " > $cxsrc
	echo -n '"@(#) ' >> $cxsrc
	echo -n "$progname CUSTOM [$build_date]" >> $cxsrc
	echo '";' >> $cxsrc
	echo cc -o $cxobj $cxsrc
	cc -c -o $cxobj $cxsrc
endif

#
# What to do
#
set uforce = "-u dbm_open -u dbm_close -u dbm_fetch"
set ccline = "$ccline ${ASEHOME}/etc/calldaemon.o $cxobj -ldl -Bstatic $uforce -L/usr/lib -lvengine -lnodisam -lvvp -lvapi -lisam -lvas -lnsl -lsocket -lintl -lc -lw -lm -lc -Bdynamic $program $opts"

#
# Go
#
echo ${ccline}
${ccline}
