1#!/usr/local/bin/bash 2# =========================================================================== 3# 4# PUBLIC DOMAIN NOTICE 5# National Center for Biotechnology Information 6# 7# This software/database is a "United States Government Work" under the 8# terms of the United States Copyright Act. It was written as part of 9# the author's official duties as a United States Government employee and 10# thus cannot be copyrighted. This software/database is freely available 11# to the public for use. The National Library of Medicine and the U.S. 12# Government have not placed any restriction on its use or reproduction. 13# 14# Although all reasonable efforts have been taken to ensure the accuracy 15# and reliability of the software and data, the NLM and the U.S. 16# Government do not and cannot warrant the performance or results that 17# may be obtained by using this software or data. The NLM and the U.S. 18# Government disclaim all warranties, express or implied, including 19# warranties of performance, merchantability or fitness for any particular 20# purpose. 21# 22# Please cite the author in any work or product based on this material. 23# 24# =========================================================================== 25 26# script name 27SELF_NAME="$(basename $0)" 28 29# parameters 30TYPE="$1" 31OUTDIR="$2" 32TARG="$3" 33NAME="$4" 34DBGAP="$5" 35EXT="$6" 36VERS="$7" 37 38# find target 39TARG=$(basename "$TARG") 40 41# put extension back onto name, unless it's "dylib" 42NAME="$NAME$DBGAP" 43STATIC_LIB_NAME="$NAME-static.a" 44[ "$EXT" != "" ] && [ "$EXT" != "dylib" ] && NAME="$NAME.$EXT" 45 46# break out version 47set-vers () 48{ 49 MAJ=$1 50 MIN=$2 51 REL=$3 52} 53 54set-vers $(echo $VERS | tr '.' ' ') 55 56cd "$OUTDIR" || exit 5 57 58# assemble versioned names 59NAME_MMR="$NAME.$MAJ.$MIN.$REL" 60NAME_MM="$NAME.$MAJ.$MIN" 61NAME_M="$NAME.$MAJ" 62 63# if extension was "dylib", NOW append to names 64if [ "$EXT" = "dylib" ] 65then 66 NAME_MMR="$NAME_MMR.$EXT" 67 NAME_MM="$NAME_MM.$EXT" 68 NAME_M="$NAME_M.$EXT" 69 NAME="$NAME.$EXT" 70fi 71 72# create link 73create-link () 74{ 75 rm -f "$2" 76 local CMD="ln -s $1 $2" 77 echo $CMD 78 $CMD 79} 80 81# test for version in target name 82if [ "$TARG" != "$NAME_MMR" ] 83then 84 85 # for simple name, create 2 links 86 if [ "$TARG" = "$NAME" ] 87 then 88 create-link "$NAME_MMR" "$NAME_M" 89 create-link "$NAME_M" "$NAME" 90 [ "$EXT" = "a" ] && create-link "$NAME" "$STATIC_LIB_NAME" 91 92 # for name with major version in it 93 elif [ "$TARG" = "$NAME_M" ] 94 then 95 create-link "$NAME_MMR" "$NAME_M" 96 97 98 # for name with major & minor version in it 99 elif [ "$TARG" = "$NAME_MM" ] 100 then 101 create-link "$NAME_MMR" "$NAME_MM" 102 fi 103fi 104