Revision 1397 trunk/scripts/admb/adcomp

adcomp (revision 1397)
1 1
#!/bin/bash
2
shopt -s expand_aliases
3
alias help='echo -e "Usage: adcomp [-d] [-g] [-r] [-s] model\n
4
Compile AD Model Builder C++ to object code.\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
if [ -f "$ADMB_HOME/bin/admb-cfg.sh" ]; then
15
  source "$ADMB_HOME/bin/admb-cfg.sh"
16
  CXX=$ADMB_CFG_CXX
17
  CXXFLAGS="$CXXFLAGS $ADMB_CFG_CXXFLAGS"
18
else
19
  CXX=c++
20
fi
21

  
22
if [ "$CXX" == "openCC" ]; then
23
  sym=-O2
24
else
25
  sym=-O3
26
fi
27

  
28
# Pop args until model=$1
29
unset dll
30
unset fpic
31
opt=-DSAFE_ALL
32
while getopts "dgrs" A; do
33
  case $A in
34
    d) dll=-DBUILDING_DLL; fpic=-fPIC;;
35
    g) sym=-g;;
36
    r) ;;
37
    s) opt=-DSAFE_ALL;;
38
    o) opt=-DOPT_LIB;;
39
  esac
2
#
3
# Copyright (c) 2013 ADMB Foundation
4
#
5
args=
6
for arg in $*
7
do
8
  extension="${arg#*.}"
9
  if [ "-" = "${arg:0:1}" ]; then
10
    args="$args $arg"
11
  elif [ "$extension" = "$arg" ]; then
12
    args="$args ${arg}.cpp"
13
  else
14
    args="$args $arg"
15
  fi
40 16
done
41
shift $((OPTIND-1))
42

  
43
file="${1%.*}"
44
if [ "`basename $file`" == "$file" ]; then
45
  file=$file.cpp
46
fi
47

  
48

  
49
CXXFLAGS="-c $CXXFLAGS $sym"
50
if [ ! -z "$dll" ]; then
51
  CXXFLAGS="$CXXFLAGS $dll"
52
fi
53

  
54
#if [ "$CXX" != "CC" ]; then
55
#  CXXFLAGS="$CXXFLAGS -Wno-deprecated"
56
#fi
57

  
58
CXXFLAGS="$CXXFLAGS -D__GNUDOS__ $dll $fpic -Dlinux $opt -DUSE_LAPLACE -I. -I\"$ADMB_HOME\"/include -I\"$ADMB_HOME\"/contrib/include"
59

  
60
CMD="$CXX $CXXFLAGS $file"
61
echo $CMD
62
eval $CMD
63

  
64
if [ $? -ne 0 ]; then
65
  exit 1
66
fi
67

  
68
exit 0
69

  
70
### r259 [2012-02-29] arnima  logged revision history
71
### r222 [2012-01-12] johnoel added $ADMB_HOME/contrib as include directory
72
### r 42 [2011-06-22] arnima  improved handling of CXXFLAGS
73
### r 39 [2011-06-22] johnoel improved handling of CXXFLAGS
74
### r982 [2010-02-16] arnima  rewrite, updated OPTIND structure, if -g then not
75
###                           -O3, fixed spaces, simplified echo
76
### r938 [2010-12-28] johnoel put CXXFLAGS before other options
77
### r901 [2010-12-22] johnoel moved to 'g++' dir
78
### r860 [2010-11-18] johnoel hardwired -O3
79
### r784 [2010-09-24] johnoel removed -O3
80
### r662 [2010-06-17] johnoel added CXXFLAGS and exit status, simplified echo
81
### r640 [2010-05-22] johnoel added -DSAFE_ALL
82
### r524 [2010-03-17] arnima  added support for filename extension like
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff