1#! /bin/sh
2#  $Id: make-tool.sh,v 6.6 1999/12/06 18:31:22 kimelman Exp $
3#  $RCSfile: make-tool.sh,v $
4
5progname=$0
6options="$*"
7
8usage() {
9    if [ "x$1" != x ] ; then
10        echo "Unrecognized option <$1>" >&2
11    fi
12    cat >&2 <<EOF
13
14    Usage: 
15      $progname --help 
16            output this message
17
18      $progname --config <config_file> [<config options>...]
19            create configuration file for make (included by makefile.A)
20            
21      $progname --install <target.install> <webdir> <mode>
22            
23    config options:
24        --mode=MODE
25                where MODE is either:
26                production 
27                development (default)
28        --target=TARGET
29                where TARGET is either:
30                mmdbsrv
31                vastsrv
32                loader
33                web     (default) include mmdbsrv & vastsrv
34                all     
35        --retrieval=RMODE
36                where RMODE is either a combination of :
37                  FF - for file based retrieval
38                  PS - for Sybase based retrieval
39        --threads=Y/N (N by default)
40EOF
41    if [ "x$1" != x ] ; then
42        exit 1
43    fi
44    exit 0
45}
46
47emit_config() {
48    mode=development
49    target=all
50    threads=N
51    retrieval=FF
52    OS=`uname -s`
53
54    if   [ $OS != SunOS -a $OS != IRIX64 ] ; then
55        echo "Unknown operating system($OS) - configuration failed" >&2
56        exit 1
57    fi
58
59    while [ $# -gt 0 ] ; do
60        case $1 in
61            --mode=prod*)   mode=production  ;;
62            --mode=deve*)   mode=development ;;
63            --target=mmdb*) target=mmdb      ;;
64            --target=vast*) target=vast      ;;
65            --target=load*) target=load      ;;
66            --target=web)   target=web       ;;
67            --target=all)   target=all       ;;
68            --threads=Y)    threads=Y        ;;
69            --threads=N)    threads=N        ;;
70            --retrieval=FF) retrieval=FF     ;;
71            --retrieval=PS) retrieval=PS     ;;
72            *)              usage $1         ;;
73        esac
74        shift
75    done
76
77    if [ $threads = Y ] ; then
78        echo 'SYBLIBRARY = $(NCBI_SYBLIBS_CT_r)'
79        echo 'LDFLAGS1=$(NCBI_THR_ALTOBJ) -lthread'
80    else
81        echo 'SYBLIBRARY = $(NCBI_SYBLIBS_CT)'
82    fi
83
84    #
85    # production/development mode customization
86    #
87    echo "mode=$mode"
88    if [ $mode = production ] ; then
89        echo 'OPTFLAG  = $(NCBI_OPTFLAG)'
90        echo 'LIBPATH  = $(NCBI_LIBDIR)'
91        if   [ $OS = SunOS  ] ; then
92            echo 'webdir=/net/neptune/pubmed/WWW/test/www.server/cgi-bin/Entrez/Structure'
93            echo 'loaddir=bin'
94            echo 'testurl=http://neptune/cgi-bin/Entrez/Structure'
95        else
96            echo 'webdir=/net/vaster/usr/attic/httpd.public/cgi-bin/Structure'
97            echo 'loaddir=/net/vaster/usr/people2/bryant/MDB/Pubstruct'
98            echo 'testurl=http://vaster/cgi-bin/Structure'
99        fi
100    else
101        echo 'OPTFLAG  = -g'
102        echo 'LIBPATH  = $(NCBI_ALTLIB)'
103        if   [ $OS = SunOS  ] ; then
104            echo 'webdir=/net/neptune/pubmed/WWW/dvlp/www.server/cgi-bin/Entrez/Structure'
105            echo 'loaddir=bin'
106            echo 'testurl=http://neptune:5701/cgi-bin/Entrez/Structure'
107        else
108            echo 'webdir=/net/vaster/usr/attic/httpd.local/cgi-bin/Structure'
109            echo 'loaddir=bin'
110            echo 'testurl=http://vaster:6224/cgi-bin/Structure'
111        fi
112    fi
113
114    echo "RMODE=${retrieval}"
115
116    case $target in
117        mmdb)
118            echo "TARGET=mmdbsrv"
119            ;;
120        vast)
121            echo "TARGET=vastsrv"
122            ;;
123        load)
124            echo "TARGET=loader"
125            ;;
126        web)
127            echo "TARGET=mmdbsrv vastsrv"
128            ;;
129        all)
130            echo "TARGET=mmdbsrv vastsrv loader"
131            ;;
132    esac
133}
134
135
136case $1 in
137    --help)
138        usage
139        ;;
140    --config)
141        cfile=$2
142        shift 2
143        emit_config $* >$cfile
144        ;;
145    --install)
146        fname=$2
147        fbase=`basename $fname .FF`
148        fbase=`basename $fbase .PS`
149        webdir=$3
150        mode=$4
151        if [ x$mode = xproduction ] ; then
152            ext=REAL
153        else
154            ext=NEW
155        fi
156	cp $fname ${webdir}/$fname
157	cd ${webdir}
158        [ -r $fbase ] || ln -s wrapper.sh $fbase ;
159        [ ! -r $fbase.$ext ] || rm -f $fbase.$ext
160        ln -s $fname $fbase.$ext
161	whoami >${fbase}.recepient
162        ;;
163    --test)
164        webdir=$2
165        binary=$3
166        mode=$4
167        if [ x$mode = xproduction ] ; then
168            ext=
169        else
170            ext=.NEW
171        fi
172        cmdline="$5"
173        cd $webdir
174        . ./.syb_set
175        SYBASE=$SYBASE_conf
176        LANG=
177        export SYBASE LANG
178        echo "" | ./$binary$ext "$cmdline" >/dev/null
179        ;;
180    *)
181        usage $*
182        ;;
183esac
184exit 0
185