Mercurial > octave
annotate libinterp/build-env-features.sh @ 22516:b3268dbf9781
build: fix build-env-features substitution pattern for non-GNU awk (bug #49126)
* build-env-features.sh: Fix regular expression for clarity and to be compatible
with non-GNU awks (e.g. BSD awk).
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Mon, 19 Sep 2016 16:42:59 -0700 |
parents | 7b48be706e28 |
children | 592fa741e0aa |
rev | line source |
---|---|
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 #! /bin/sh |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
3 ## Attempt to get traditional sort behavior based on byte values. |
21277
1bca6c72d2b1
maint: Use consistent coding style for build helper shell scripts
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
4 LC_ALL=C |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
5 export LC_ALL |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
6 |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 set -e |
21277
1bca6c72d2b1
maint: Use consistent coding style for build helper shell scripts
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
8 |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 AWK=${AWK:-awk} |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 conffile=$1 |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 cat << EOF |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 // DO NOT EDIT! Generated automatically from $conffile by Make." |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 |
21302
8376de2eaf00
define OCTAVE_HAVE_FAST_INT_OPS in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
16 #if defined (HAVE_CONFIG_H) |
8376de2eaf00
define OCTAVE_HAVE_FAST_INT_OPS in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
17 # include "config.h" |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
18 #endif |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
19 |
21220
d78e45987d6a
rename octave::build_env namespace from octave::config
John W. Eaton <jwe@octave.org>
parents:
21182
diff
changeset
|
20 #include "build-env.h" |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 #include "ov.h" |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
23 namespace octave |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 { |
21220
d78e45987d6a
rename octave::build_env namespace from octave::config
John W. Eaton <jwe@octave.org>
parents:
21182
diff
changeset
|
25 namespace build_env |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
26 { |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
27 octave_scalar_map |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
28 features (void) |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
29 { |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
30 static bool initialized = false; |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
32 static octave_scalar_map m; |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
33 |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
34 if (! initialized) |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
35 { |
21665
7b48be706e28
* build-env-features.sh: Emit code to use static variables instead of repeatedly creating new octave_value objects for true and false.
John W. Eaton <jwe@octave.org>
parents:
21305
diff
changeset
|
36 static octave_value ov_true = (true); |
7b48be706e28
* build-env-features.sh: Emit code to use static variables instead of repeatedly creating new octave_value objects for true and false.
John W. Eaton <jwe@octave.org>
parents:
21305
diff
changeset
|
37 static octave_value ov_false = (false); |
7b48be706e28
* build-env-features.sh: Emit code to use static variables instead of repeatedly creating new octave_value objects for true and false.
John W. Eaton <jwe@octave.org>
parents:
21305
diff
changeset
|
38 |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 EOF |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 $AWK \ |
22516
b3268dbf9781
build: fix build-env-features substitution pattern for non-GNU awk (bug #49126)
Mike Miller <mtmiller@octave.org>
parents:
21665
diff
changeset
|
42 '/#define (OCTAVE_HAVE|HAVE)_/ { |
b3268dbf9781
build: fix build-env-features substitution pattern for non-GNU awk (bug #49126)
Mike Miller <mtmiller@octave.org>
parents:
21665
diff
changeset
|
43 sub (/(OCTAVE_HAVE|HAVE)_/, "", $2); |
21665
7b48be706e28
* build-env-features.sh: Emit code to use static variables instead of repeatedly creating new octave_value objects for true and false.
John W. Eaton <jwe@octave.org>
parents:
21305
diff
changeset
|
44 printf (" m.assign (\"%s\", ov_true);\n", $2); |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 } |
22516
b3268dbf9781
build: fix build-env-features substitution pattern for non-GNU awk (bug #49126)
Mike Miller <mtmiller@octave.org>
parents:
21665
diff
changeset
|
46 /\/\* #undef (OCTAVE_HAVE|HAVE)_/ { |
b3268dbf9781
build: fix build-env-features substitution pattern for non-GNU awk (bug #49126)
Mike Miller <mtmiller@octave.org>
parents:
21665
diff
changeset
|
47 sub (/(OCTAVE_HAVE|HAVE)_/, "", $3); |
21665
7b48be706e28
* build-env-features.sh: Emit code to use static variables instead of repeatedly creating new octave_value objects for true and false.
John W. Eaton <jwe@octave.org>
parents:
21305
diff
changeset
|
48 printf (" m.assign (\"%s\", ov_false);\n", $3); |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 } { |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
50 }' $conffile | sort |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 cat << EOF |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 |
21182
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
54 initialized = true; |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
55 } |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
56 |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
57 return m; |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
58 } |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
59 }; |
82a44483dbff
move octave_config_features function out of header file
John W. Eaton <jwe@octave.org>
parents:
21181
diff
changeset
|
60 }; |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 EOF |