Revision 326 trunk/scripts/g++/adlink

adlink (revision 326)
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
# Pop args until model=$1
15
adlib=-lado
16
df1b2lib=-ldf1b2o
17
contriblib=-lcontribo
18
unset shared
19
sym=-s
20
while getopts "dgrs" A; do
21
  case $A in
22
    d) shared=-shared;;
23
    g) unset sym;;
24
    r) ;;
25
    s) contriblib=-lcontribs; df1b2lib=-ldf1b2s; adlib=-lads;;
26
  esac
27
done
28
shift $((OPTIND-1))
29

  
30
if [[ "`uname -s`" == "Darwin" ]]; then unset sym; fi
31

  
32
model="${1%.*}"
33

  
34
if [[ -z $shared ]]; then out="-o $model"; else out="-o $model.so"; fi
35

  
36
CMD="g++ $LDFLAGS $sym $shared -L$ADMB_HOME/lib -L$ADMB_HOME/contrib $model.o $df1b2lib -ladmod\
37
 $contriblib -ladt $adlib $df1b2lib -ladmod $contriblib -ladt $adlib $out"
38
echo $CMD
39
eval $CMD
40

  
41
exit 0
42

  
43
### r259 [2012-02-29] arnima  logged revision history
44
### r 42 [2011-06-22] arnima  improved handling of LDFLAGS
45
### r 39 [2011-06-22] johnoel improved handling of LDFLAGS
46
### r982 [2010-02-16] arnima  rewrite, updated OPTIND structure, removed -O3,
47
###                           fixed spaces, simplified echo
48
### r938 [2010-12-28] johnoel put LDFLAGS before other options
49
### r901 [2010-12-22] johnoel moved to 'g++' dir
50
### r860 [2010-11-18] johnoel added -O3
51
### r662 [2010-06-17] johnoel added LDFLAGS and exit status, simplified echo
52
### r632 [2010-05-21] johnoel diabled strip in Mac OS
53
### r551 [2010-03-27] johnoel disabled -ldf1b2stub
54
### r524 [2010-03-17] arnima  added support for filename extension like
55
###                           simple.o, enabled strip
56
###                   johnoel split -s option into separate -g and -s options
57
### r511 [2010-02-18] johnoel went back to r446
58
### r510 [2010-02-18] johnoel removed duplicate libraries
59
### r446 [2009-10-23] johnoel fixed adlib bug
60
### r419 [2009-05-29] johnoel disabled strip
61
### r243 [2009-05-27] arnima  created
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
# Pop args until model=$1
15
adlib=-lado
16
df1b2lib=-ldf1b2o
17
contriblib=-lcontribo
18
unset shared
19
sym=-s
20
while getopts "dgrs" A; do
21
  case $A in
22
    d) shared=-shared;;
23
    g) unset sym;;
24
    r) ;;
25
    s) contriblib=-lcontribs; df1b2lib=-ldf1b2s; adlib=-lads;;
26
  esac
27
done
28
shift $((OPTIND-1))
29

  
30
if [[ "`uname -s`" == "Darwin" ]]; then unset sym; fi
31

  
32
model="${1%.*}"
33

  
34
if [[ -z $shared ]]; then out="-o $model"; else out="-o $model.so"; fi
35

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff