Revision 1399

trunk/scripts/admb/adlink-shared (revision 1399)
1 1
#!/bin/bash
2
shopt -s expand_aliases
3
alias help='echo -e "Usage: adlink [-d] [-g] [-r] [-s] model\n
4
Link AD Model Builder object code to executable.\n
5
  -d     Create DLL
6
  -g     Insert debugging symbols
7
  -r     Create ADMB-RE
8
  -s     Enforce safe bounds
9
  model  Filename prefix, e.g. simple\n"'
10
if [[ "$1" == "" ]]; then help; exit; fi
11
if [[ "$1" == "-help" ]]; then help; exit; fi
12
if [[ "$1" == "--help" ]]; then help; exit; fi
13

  
14
unset shared
15
sym=
16
opt=
17
while getopts "dgrso" A; do
18
  case $A in
19
    d) shared=-shared;;
20
    g) unset sym;;
21
    r) ;;
22
    s) ;;
23
    o) opt=o;;
24
  esac
25
done
26
shift $((OPTIND-1))
27

  
28
if [[ "`uname -s`" == "Darwin" ]]; then unset sym; fi
29

  
30
model="${1%.*}"
31

  
32
objects=
33
for file in $*
2
#
3
# Copyright (c) 2013 ADMB Foundation
4
#
5
args=
6
for arg in $*
34 7
do
35
  extension="${file#*.}"
36
  if [ "$extension" = "$file" ]; then
37
    objects="${file%.*}.o $objects"
38
  elif [ "$extension" = "obj" -o "$extension" = "o" ]; then
39
    objects="$objects $file"
40
  fi 
41
done
42

  
43
if [ -z "$CXX" ]; then
44
  if [ -f "$ADMB_HOME/bin/admb-cfg.sh" ]; then
45
    source "$ADMB_HOME/bin/admb-cfg.sh"
8
  extension="${arg#*.}"
9
  if [ "-" = "${arg:0:1}" ]; then
10
    args="$args $arg"
11
  elif [ "$extension" = "$arg" ]; then
12
    args="$args ${arg}.obj
46 13
  else
47
    CXX=c++
14
    args="$args $arg"
48 15
  fi
49
fi
50

  
51
LDFLAGS="$LDFLAGS"
52
if [ ! -z "$sym" ]; then
53
  LDFLAGS="$LDFLAGS $sym"
54
fi
55
if [ ! -z "$shared" ]; then
56
  LDFLAGS="$LDFLAGS $shared -o $model.so"
57
else
58
  LDFLAGS="$LDFLAGS -o $model"
59
fi
60

  
61
if [ "$CXX" == "adcomp-x86_64-w64-mingw32" ]; then
62
  LDFLAGS="--static $LDFLAGS"
63
fi
64

  
65
CMD="$CXX $LDFLAGS $objects \"$ADMB_HOME\"/lib/libadmb$opt.so"
66
echo $CMD
67
eval $CMD
68

  
69
if [ $? -ne 0 ]; then
70
  exit 1
71
fi
72

  
73
exit 0
74

  
75
### r259 [2012-02-29] arnima  logged revision history
76
### r 42 [2011-06-22] arnima  improved handling of LDFLAGS
77
### r 39 [2011-06-22] johnoel improved handling of LDFLAGS
78
### r982 [2010-02-16] arnima  rewrite, updated OPTIND structure, removed -O3,
79
###                           fixed spaces, simplified echo
80
### r938 [2010-12-28] johnoel put LDFLAGS before other options
81
### r901 [2010-12-22] johnoel moved to 'g++' dir
82
### r860 [2010-11-18] johnoel added -O3
83
### r662 [2010-06-17] johnoel added LDFLAGS and exit status, simplified echo
84
### r632 [2010-05-21] johnoel diabled strip in Mac OS
85
### r551 [2010-03-27] johnoel disabled -ldf1b2stub
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff