File: template.sh

package info (click to toggle)
cppad 2026.00.00.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (99 lines) | stat: -rwxr-xr-x 2,148 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /usr/bin/env bash
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-25 Bradley M. Bell
# -----------------------------------------------------------------------------
set -e -u
#
# bash function that echos and executes a command
echo_eval() {
   echo $*
   eval $*
}
# -----------------------------------------------------------------------------
#
# name
name=`echo $0 | sed -e 's|^bug/||' -e 's|\.sh$||'`
if [ "$0" != "bug/$name.sh" ]
then
   echo "usage: bug/$name.sh"
   exit 1
fi
#
# PKG_CONFIG_PATH, LD_LIBRARY_PATH
prefix="$(pwd)/build/prefix"
export PKG_CONFIG_PATH="$prefix/share/pkgconfig"
export LD_LIBRARY_PATH=""
for subdir in  'lib' 'lib64'
do
   PKG_CONFIG_PATH+=":$prefix/$subdir/pkgconfig"
   LD_LIBRARY_PATH+=";$prefix/$subdir"
done
#
# eigen_flags
eigen_flags=$(pkg-config -cflags eigen3)
#
# ipopt_flags
ipopt_flags=$(pkg-config -cflags ipopt | sed -e 's|/coin-or | |' )
#
# link_flags
link_flags=$(pkg-config -libs cppad)
#
# extra_flags
extra_flags='-Wall -pedantic-errors -std=c++11 -Wshadow -Wconversion -g -O0'
#
# build/bug
if [ -e build/bug ]
then
   rm -r build/bug
fi
mkdir -p build/bug
cd build/bug
#
# $name.cpp
cat << EOF > $name.cpp
# include <cppad/cppad.hpp>
int main(void)
{  bool ok = true;
   using std::cout;
   using CppAD::AD;
   using CppAD::vector;
   //
   cout << "Choose a name for this bug (called name below)\n";
   cout << "1. Copy bug/template.sh to bug/name.sh\n";
   cout << "2. Edit bug/name.sh replacing C++ source code\n";
   cout << "3. Run bug/name.sh\n";
   cout << "Test passes (fails) if bug/name.sh: OK (Error) echoed at end\n";
   //
   if( ok )
      return 0;
   return 1;
}
EOF
#
# $name
cmd="
   g++
   $name.cpp
   -I../../include
   $extra_flags
   $eigen_flags
   $ipopt_flags
   -o $name
   $link_flags
"
#
$cmd
#
echo "build/bug/$name"
if ! ./$name
then
   echo
   echo "build/bug/$name: Error"
   echo "export LD_LIBRARY_PATH='$LD_LIBRARY_PATH'"
   exit 1
fi
echo
# -----------------------------------------------------------------------------
echo "bug/$name.sh: OK"
exit 0