chiark / gitweb /
allow cxx library to be installed simultaneously with non-cxx
[nlopt.git] / octave / mkconstants.sh
1 #!/bin/sh 
2
3 names=`egrep NLOPT_[LG][ND] ../api/nlopt.h |sed 's/ //g' |tr = , |cut -d, -f1`
4 i=0
5
6 gcc -I.. -E ../api/nlopt.c | perl -pe 's/^ *\n//' > foo.c
7 desc_start=`grep -n nlopt_algorithm_names foo.c |cut -d: -f1 |head -1`
8
9 for n in $names; do
10 #    if test -r $n.m; then
11 #       perl -pi -e "s/val = [0-9]+;/val = $i;/" $n.m
12 #    else
13         descline=`expr $i + $desc_start + 1`
14         desc=`tail -n +$descline foo.c |head -1 |cut -d\" -f2`
15         cat > $n.m <<EOF
16 % $n: $desc
17 %
18 % See nlopt_minimize for more information.
19 function val = $n
20   val = $i;
21 EOF
22 #    fi  
23     i=`expr $i + 1`
24 done
25
26 mfiles=`echo "$names" | tr '\n' ' ' | sed 's/ /.m /g'`
27 perl -pi -e "s/^MFILES = .*\$/MFILES = $mfiles/" Makefile.am