intervals 0.3.56

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/VERSION.txt +1 -0
  2. data/ext/crlibm/AUTHORS +2 -0
  3. data/ext/crlibm/COPYING +504 -0
  4. data/ext/crlibm/ChangeLog +80 -0
  5. data/ext/crlibm/INSTALL +182 -0
  6. data/ext/crlibm/Makefile.am +84 -0
  7. data/ext/crlibm/Makefile.in +530 -0
  8. data/ext/crlibm/NEWS +0 -0
  9. data/ext/crlibm/README +31 -0
  10. data/ext/crlibm/TODO +47 -0
  11. data/ext/crlibm/VERSION +1 -0
  12. data/ext/crlibm/aclocal.m4 +989 -0
  13. data/ext/crlibm/atan-itanium.c +846 -0
  14. data/ext/crlibm/atan-pentium.c +261 -0
  15. data/ext/crlibm/atan_accurate.c +244 -0
  16. data/ext/crlibm/atan_accurate.h +191 -0
  17. data/ext/crlibm/atan_fast.c +324 -0
  18. data/ext/crlibm/atan_fast.h +678 -0
  19. data/ext/crlibm/config.guess +1461 -0
  20. data/ext/crlibm/config.sub +1566 -0
  21. data/ext/crlibm/configure +7517 -0
  22. data/ext/crlibm/configure.ac +364 -0
  23. data/ext/crlibm/crlibm.h +125 -0
  24. data/ext/crlibm/crlibm_config.h +149 -0
  25. data/ext/crlibm/crlibm_config.h.in +148 -0
  26. data/ext/crlibm/crlibm_private.c +293 -0
  27. data/ext/crlibm/crlibm_private.h +658 -0
  28. data/ext/crlibm/csh_fast.c +631 -0
  29. data/ext/crlibm/csh_fast.h +771 -0
  30. data/ext/crlibm/double-extended.h +496 -0
  31. data/ext/crlibm/exp-td.c +962 -0
  32. data/ext/crlibm/exp-td.h +685 -0
  33. data/ext/crlibm/exp_accurate.c +197 -0
  34. data/ext/crlibm/exp_accurate.h +85 -0
  35. data/ext/crlibm/gappa/log-de-E0-logir0.gappa +106 -0
  36. data/ext/crlibm/gappa/log-de-E0.gappa +79 -0
  37. data/ext/crlibm/gappa/log-de.gappa +81 -0
  38. data/ext/crlibm/gappa/log-td-E0-logir0.gappa +126 -0
  39. data/ext/crlibm/gappa/log-td-E0.gappa +143 -0
  40. data/ext/crlibm/gappa/log-td-accurate-E0-logir0.gappa +230 -0
  41. data/ext/crlibm/gappa/log-td-accurate-E0.gappa +213 -0
  42. data/ext/crlibm/gappa/log-td-accurate.gappa +217 -0
  43. data/ext/crlibm/gappa/log-td.gappa +156 -0
  44. data/ext/crlibm/gappa/trigoSinCosCase3.gappa +204 -0
  45. data/ext/crlibm/gappa/trigoTanCase2.gappa +73 -0
  46. data/ext/crlibm/install-sh +269 -0
  47. data/ext/crlibm/log-de.c +431 -0
  48. data/ext/crlibm/log-de.h +732 -0
  49. data/ext/crlibm/log-td.c +852 -0
  50. data/ext/crlibm/log-td.h +819 -0
  51. data/ext/crlibm/log10-td.c +906 -0
  52. data/ext/crlibm/log10-td.h +823 -0
  53. data/ext/crlibm/log2-td.c +935 -0
  54. data/ext/crlibm/log2-td.h +821 -0
  55. data/ext/crlibm/maple/atan.mpl +359 -0
  56. data/ext/crlibm/maple/common-procedures.mpl +997 -0
  57. data/ext/crlibm/maple/csh.mpl +446 -0
  58. data/ext/crlibm/maple/double-extended.mpl +151 -0
  59. data/ext/crlibm/maple/exp-td.mpl +195 -0
  60. data/ext/crlibm/maple/log-de.mpl +243 -0
  61. data/ext/crlibm/maple/log-td.mpl +316 -0
  62. data/ext/crlibm/maple/log10-td.mpl +345 -0
  63. data/ext/crlibm/maple/log2-td.mpl +334 -0
  64. data/ext/crlibm/maple/trigo.mpl +728 -0
  65. data/ext/crlibm/maple/triple-double.mpl +58 -0
  66. data/ext/crlibm/missing +198 -0
  67. data/ext/crlibm/mkinstalldirs +40 -0
  68. data/ext/crlibm/rem_pio2_accurate.c +219 -0
  69. data/ext/crlibm/rem_pio2_accurate.h +53 -0
  70. data/ext/crlibm/scs_lib/AUTHORS +3 -0
  71. data/ext/crlibm/scs_lib/COPYING +504 -0
  72. data/ext/crlibm/scs_lib/ChangeLog +16 -0
  73. data/ext/crlibm/scs_lib/INSTALL +215 -0
  74. data/ext/crlibm/scs_lib/Makefile.am +18 -0
  75. data/ext/crlibm/scs_lib/Makefile.in +328 -0
  76. data/ext/crlibm/scs_lib/NEWS +0 -0
  77. data/ext/crlibm/scs_lib/README +9 -0
  78. data/ext/crlibm/scs_lib/TODO +4 -0
  79. data/ext/crlibm/scs_lib/addition_scs.c +623 -0
  80. data/ext/crlibm/scs_lib/config.guess +1461 -0
  81. data/ext/crlibm/scs_lib/config.sub +1566 -0
  82. data/ext/crlibm/scs_lib/configure +6226 -0
  83. data/ext/crlibm/scs_lib/division_scs.c +110 -0
  84. data/ext/crlibm/scs_lib/double2scs.c +174 -0
  85. data/ext/crlibm/scs_lib/install-sh +269 -0
  86. data/ext/crlibm/scs_lib/missing +198 -0
  87. data/ext/crlibm/scs_lib/mkinstalldirs +40 -0
  88. data/ext/crlibm/scs_lib/multiplication_scs.c +456 -0
  89. data/ext/crlibm/scs_lib/poly_fct.c +112 -0
  90. data/ext/crlibm/scs_lib/print_scs.c +73 -0
  91. data/ext/crlibm/scs_lib/rand_scs.c +63 -0
  92. data/ext/crlibm/scs_lib/scs.h +353 -0
  93. data/ext/crlibm/scs_lib/scs2double.c +391 -0
  94. data/ext/crlibm/scs_lib/scs2mpf.c +58 -0
  95. data/ext/crlibm/scs_lib/scs2mpfr.c +61 -0
  96. data/ext/crlibm/scs_lib/scs_private.c +23 -0
  97. data/ext/crlibm/scs_lib/scs_private.h +133 -0
  98. data/ext/crlibm/scs_lib/tests/tbx_timing.h +102 -0
  99. data/ext/crlibm/scs_lib/wrapper_scs.h +486 -0
  100. data/ext/crlibm/scs_lib/zero_scs.c +52 -0
  101. data/ext/crlibm/stamp-h.in +1 -0
  102. data/ext/crlibm/tests/Makefile.am +43 -0
  103. data/ext/crlibm/tests/Makefile.in +396 -0
  104. data/ext/crlibm/tests/blind_test.c +148 -0
  105. data/ext/crlibm/tests/generate_test_vectors.c +258 -0
  106. data/ext/crlibm/tests/soak_test.c +334 -0
  107. data/ext/crlibm/tests/test_common.c +627 -0
  108. data/ext/crlibm/tests/test_common.h +28 -0
  109. data/ext/crlibm/tests/test_perf.c +570 -0
  110. data/ext/crlibm/tests/test_val.c +249 -0
  111. data/ext/crlibm/trigo_accurate.c +500 -0
  112. data/ext/crlibm/trigo_accurate.h +331 -0
  113. data/ext/crlibm/trigo_fast.c +1219 -0
  114. data/ext/crlibm/trigo_fast.h +639 -0
  115. data/ext/crlibm/triple-double.h +878 -0
  116. data/ext/extconf.rb +31 -0
  117. data/ext/fpu.c +107 -0
  118. data/ext/jamis-mod.rb +591 -0
  119. data/lib/fpu.rb +287 -0
  120. data/lib/interval.rb +1170 -0
  121. data/lib/intervals.rb +212 -0
  122. data/lib/struct_float.rb +133 -0
  123. data/test/data_atan.txt +360 -0
  124. data/test/data_cos.txt +346 -0
  125. data/test/data_cosh.txt +3322 -0
  126. data/test/data_exp.txt +3322 -0
  127. data/test/data_log.txt +141 -0
  128. data/test/data_sin.txt +140 -0
  129. data/test/data_sinh.txt +3322 -0
  130. data/test/data_tan.txt +342 -0
  131. metadata +186 -0
@@ -0,0 +1,110 @@
1
+ /** Functions for SCS inverse and division
2
+
3
+ @file division_scs.c
4
+
5
+ @author Defour David David.Defour@ens-lyon.fr
6
+ @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
7
+
8
+ This file is part of the SCS library.
9
+
10
+
11
+ */
12
+
13
+ /*
14
+ Copyright (C) 2002 David Defour and Florent de Dinechin
15
+
16
+ This library is free software; you can redistribute it and/or
17
+ modify it under the terms of the GNU Lesser General Public
18
+ License as published by the Free Software Foundation; either
19
+ version 2.1 of the License, or (at your option) any later version.
20
+
21
+ This library is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
+ Lesser General Public License for more details.
25
+
26
+ You should have received a copy of the GNU Lesser General Public
27
+ License along with this library; if not, write to the Free Software
28
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
+
30
+ */
31
+ #include "scs.h"
32
+ #include "scs_private.h"
33
+
34
+
35
+ void scs_div_2(scs_ptr num) {
36
+ /* small function to divide by 2 any SCS number */
37
+ unsigned int carry, mask, old_value;
38
+ int i;
39
+ carry = 0x00000000;
40
+ mask = (unsigned int)(((0x1) << SCS_NB_BITS)-1);/*we now have a mask for the used bits in a word*/
41
+ /* if it's a normal number, i.e. not zero nor NaN */
42
+ if( (num->exception).d == (double) 1) {
43
+ /* first, a loop to rotate all numbers to the right*/
44
+ for(i = 0; i < SCS_NB_WORDS; i++) {
45
+ old_value = num->h_word[i];
46
+ num->h_word[i] = (old_value & !mask) | carry | ((old_value >> 1) & mask);
47
+ carry = old_value & 0x00000001;/* it can be interesting to keep the last bit of each number =) */
48
+ carry = carry << (SCS_NB_BITS-1);
49
+ }
50
+ /* In the SCS format, the first number can't be zero, so we must handle this particular case */
51
+ if (num->h_word[0] == 0){
52
+ num->index = num->index - 1;
53
+ for(i = 1; i < SCS_NB_WORDS; i++) {
54
+ num->h_word[i-1] = num->h_word[i];
55
+ }
56
+ num->h_word[SCS_NB_WORDS-1] = 0;
57
+ }
58
+ }
59
+ else {
60
+ (num->exception).d = (num->exception).d / 2;/* zero, NaN, ... */
61
+ }
62
+ }
63
+
64
+
65
+
66
+
67
+ /*
68
+ * Compute 1/x with a Newton scheme
69
+ */
70
+ void scs_inv(scs_ptr result, scs_ptr x){
71
+ scs_t tmp, res, res1, scstwo;
72
+ double app_x, inv;
73
+
74
+ scs_set(tmp, x); tmp->index = 0; scs_get_d(&app_x, tmp);
75
+
76
+ scs_set_si(scstwo, 2);
77
+ /* inv is a 53-bit approximation of 1/x */
78
+ inv = 1/app_x;
79
+
80
+ scs_set_d(res, inv);
81
+ res->index -= x->index;
82
+
83
+ /* First Newton Iteration */
84
+ scs_mul(res1, x, res);
85
+ scs_sub(res1, scstwo, res1);
86
+ scs_mul(res, res, res1);
87
+
88
+ /* Second Newton Iteration */
89
+ scs_mul(res1, x, res);
90
+ scs_sub(res1, scstwo, res1);
91
+ scs_mul(result, res, res1);
92
+
93
+ return;
94
+ }
95
+
96
+ /*
97
+ * Compute result = x/y;
98
+ */
99
+ void scs_div(scs_ptr result, scs_ptr x, scs_ptr y){
100
+ scs_t res;
101
+
102
+ if (X_EXP != 1){
103
+ R_EXP = X_EXP / Y_EXP;
104
+ return;
105
+ }
106
+
107
+ scs_inv(res, y);
108
+ scs_mul(result, res, x);
109
+ return;
110
+ }
@@ -0,0 +1,174 @@
1
+ /** Conversion of floating-point double to SCS
2
+ @file double2scs.c
3
+
4
+ @author Defour David David.Defour@ens-lyon.fr
5
+ @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
6
+
7
+ This file is part of the SCS library.
8
+ */
9
+
10
+ /*
11
+ Copyright (C) 2002 David Defour and Florent de Dinechin
12
+
13
+ This library is free software; you can redistribute it and/or
14
+ modify it under the terms of the GNU Lesser General Public
15
+ License as published by the Free Software Foundation; either
16
+ version 2.1 of the License, or (at your option) any later version.
17
+
18
+ This library is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ Lesser General Public License for more details.
22
+
23
+ You should have received a copy of the GNU Lesser General Public
24
+ License along with this library; if not, write to the Free Software
25
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+
27
+ */
28
+ #include "scs.h"
29
+ #include "scs_private.h"
30
+
31
+
32
+ /** Convert a double precision number in it SCS multiprecision
33
+ representation
34
+ */
35
+
36
+ void scs_set_d(scs_ptr result, double x){
37
+ db_number nb, mantissa;
38
+ int exponent, exponent_remainder;
39
+ int ind, i;
40
+
41
+ if(x>=0){R_SGN = 1; nb.d = x;}
42
+ else {R_SGN = -1; nb.d = -x;}
43
+
44
+ exponent = nb.i[HI] & 0x7ff00000 ;
45
+
46
+ if (exponent == 0x7ff00000) {
47
+ /*
48
+ * x = +/- Inf, s/qNAN
49
+ */
50
+ R_EXP = x;
51
+ for(i=0; i<SCS_NB_WORDS; i++)
52
+ R_HW[i] = 0;
53
+
54
+ R_IND = 0;
55
+ R_SGN = 1;
56
+ }
57
+
58
+ else { /* Normals, denormals, +/- 0. */
59
+
60
+ /* This number is not an exception */
61
+ R_EXP = 1;
62
+
63
+ #if 1
64
+
65
+ if (exponent == 0){
66
+ /* x is a denormal number : bring it back to the normal range */
67
+ nb.d = nb.d * SCS_RADIX_TWO_DOUBLE; /* 2^(2.SCS_NB_BITS) */
68
+ exponent = nb.i[HI] & 0x7ff00000 ;
69
+ R_IND = -2;
70
+ }else {
71
+ R_IND = 0;
72
+ }
73
+
74
+ exponent = exponent >> 20; /* get the actual value */
75
+
76
+ ind = ((exponent +((100*SCS_NB_BITS)-1023))/SCS_NB_BITS) - 100 ;
77
+ /* means : = (exponent -1023 + 100*SCS_NB_BITS)/SCS_NB_BITS -100
78
+ The business with 100*SCS_NB_BITS is to stay within the positive
79
+ range for exponent_remainder between 1 and SCS_NB_BITS */
80
+
81
+ exponent_remainder = exponent - 1022 - (SCS_NB_BITS*ind);
82
+
83
+ R_IND += ind;
84
+
85
+ /* now get the mantissa and add the implicit 1 in fp. format*/
86
+ mantissa.l = (nb.l & ULL(000fffffffffffff)) | ULL(0010000000000000);
87
+
88
+
89
+ /* and spread it over the structure
90
+ Everything here is 64-bit arithmetic */
91
+ R_HW[0] = (unsigned int) (mantissa.l >> (53 - exponent_remainder) );
92
+
93
+ /* 11 = 64-53 */
94
+ mantissa.l = (mantissa.l << (exponent_remainder+11));
95
+ R_HW[1] = (mantissa.i[HI] >> (32 - SCS_NB_BITS))& SCS_MASK_RADIX ;
96
+ mantissa.l = (mantissa.l << SCS_NB_BITS);
97
+ R_HW[2] = (mantissa.i[HI] >> (32 - SCS_NB_BITS))& SCS_MASK_RADIX ;
98
+ #if SCS_NB_BITS < 27
99
+ mantissa.l = (mantissa.l << SCS_NB_BITS);
100
+ R_HW[3] = (mantissa.i[HI] >> (32 - SCS_NB_BITS))& SCS_MASK_RADIX ;
101
+ #else
102
+ R_HW[3] = 0 ;
103
+ #endif
104
+
105
+ #if (SCS_NB_WORDS==8)
106
+ R_HW[4] = 0; R_HW[5] = 0; R_HW[6] = 0; R_HW[7] = 0;
107
+ #else
108
+ for(i=4; i<SCS_NB_WORDS; i++)
109
+ R_HW[i] = 0;
110
+ #endif
111
+
112
+
113
+
114
+ #else /* Other algorithm as in the research report. Slower */
115
+ R_IND = 0;
116
+
117
+ while(nb.d>SCS_RADIX_ONE_DOUBLE) {
118
+ R_IND++;
119
+ nb.d *= SCS_RADIX_MONE_DOUBLE;
120
+ }
121
+
122
+ while(nb.d<1) {
123
+ R_IND--;
124
+ nb.d *= SCS_RADIX_ONE_DOUBLE;
125
+ }
126
+
127
+ i=0;
128
+ while(nb.d != 0){
129
+ R_HW[i] = (unsigned int) nb.d;
130
+ nb.d = (nb.d - (double)R_HW[i]) * SCS_RADIX_ONE_DOUBLE;
131
+ i++;
132
+ }
133
+ for(; i<SCS_NB_WORDS; i++)
134
+ R_HW[i] = 0;
135
+
136
+ #endif
137
+
138
+ } /* end if test NaN etc */
139
+
140
+ return;
141
+ }
142
+
143
+
144
+ /**
145
+ Convert an integer number in it scs multiprecision
146
+ representation
147
+ */
148
+ void scs_set_si(scs_ptr result, int x){
149
+ unsigned int ux;
150
+ int i;
151
+
152
+ if(x>=0){R_SGN = 1; ux = (unsigned int)x;}
153
+ else {R_SGN = -1; ux = (unsigned int)-x;}
154
+
155
+
156
+ if (ux > SCS_RADIX){
157
+ R_IND = 1;
158
+ R_HW[0] = (ux - SCS_RADIX) >> SCS_NB_BITS;
159
+ R_HW[1] = ux - (R_HW[0] << SCS_NB_BITS);
160
+ }else {
161
+ R_IND = 0;
162
+ R_HW[0] = ux;
163
+ R_HW[1] = 0;
164
+ }
165
+
166
+ for(i=2; i<SCS_NB_WORDS; i++)
167
+ R_HW[i] = 0;
168
+
169
+ if (x != 0) R_EXP = 1;
170
+ else R_EXP = 0;
171
+
172
+ return;
173
+ }
174
+
@@ -0,0 +1,269 @@
1
+ #!/bin/sh
2
+ #
3
+ # install - install a program, script, or datafile
4
+ #
5
+ # This originates from X11R5 (mit/util/scripts/install.sh), which was
6
+ # later released in X11R6 (xc/config/util/install.sh) with the
7
+ # following copyright and license.
8
+ #
9
+ # Copyright (C) 1994 X Consortium
10
+ #
11
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ # of this software and associated documentation files (the "Software"), to
13
+ # deal in the Software without restriction, including without limitation the
14
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15
+ # sell copies of the Software, and to permit persons to whom the Software is
16
+ # furnished to do so, subject to the following conditions:
17
+ #
18
+ # The above copyright notice and this permission notice shall be included in
19
+ # all copies or substantial portions of the Software.
20
+ #
21
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25
+ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
26
+ # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ # Except as contained in this notice, the name of the X Consortium shall not
29
+ # be used in advertising or otherwise to promote the sale, use or other deal-
30
+ # ings in this Software without prior written authorization from the X Consor-
31
+ # tium.
32
+ #
33
+ #
34
+ # FSF changes to this file are in the public domain.
35
+ #
36
+ # Calling this script install-sh is preferred over install.sh, to prevent
37
+ # `make' implicit rules from creating a file called install from it
38
+ # when there is no Makefile.
39
+ #
40
+ # This script is compatible with the BSD install script, but was written
41
+ # from scratch. It can only install one file at a time, a restriction
42
+ # shared with many OS's install programs.
43
+
44
+
45
+ # set DOITPROG to echo to test this script
46
+
47
+ # Don't use :- since 4.3BSD and earlier shells don't like it.
48
+ doit="${DOITPROG-}"
49
+
50
+
51
+ # put in absolute paths if you don't have them in your path; or use env. vars.
52
+
53
+ mvprog="${MVPROG-mv}"
54
+ cpprog="${CPPROG-cp}"
55
+ chmodprog="${CHMODPROG-chmod}"
56
+ chownprog="${CHOWNPROG-chown}"
57
+ chgrpprog="${CHGRPPROG-chgrp}"
58
+ stripprog="${STRIPPROG-strip}"
59
+ rmprog="${RMPROG-rm}"
60
+ mkdirprog="${MKDIRPROG-mkdir}"
61
+
62
+ transformbasename=""
63
+ transform_arg=""
64
+ instcmd="$mvprog"
65
+ chmodcmd="$chmodprog 0755"
66
+ chowncmd=""
67
+ chgrpcmd=""
68
+ stripcmd=""
69
+ rmcmd="$rmprog -f"
70
+ mvcmd="$mvprog"
71
+ src=""
72
+ dst=""
73
+ dir_arg=""
74
+
75
+ while [ x"$1" != x ]; do
76
+ case $1 in
77
+ -c) instcmd="$cpprog"
78
+ shift
79
+ continue;;
80
+
81
+ -d) dir_arg=true
82
+ shift
83
+ continue;;
84
+
85
+ -m) chmodcmd="$chmodprog $2"
86
+ shift
87
+ shift
88
+ continue;;
89
+
90
+ -o) chowncmd="$chownprog $2"
91
+ shift
92
+ shift
93
+ continue;;
94
+
95
+ -g) chgrpcmd="$chgrpprog $2"
96
+ shift
97
+ shift
98
+ continue;;
99
+
100
+ -s) stripcmd="$stripprog"
101
+ shift
102
+ continue;;
103
+
104
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
105
+ shift
106
+ continue;;
107
+
108
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
109
+ shift
110
+ continue;;
111
+
112
+ *) if [ x"$src" = x ]
113
+ then
114
+ src=$1
115
+ else
116
+ # this colon is to work around a 386BSD /bin/sh bug
117
+ :
118
+ dst=$1
119
+ fi
120
+ shift
121
+ continue;;
122
+ esac
123
+ done
124
+
125
+ if [ x"$src" = x ]
126
+ then
127
+ echo "install: no input file specified"
128
+ exit 1
129
+ else
130
+ true
131
+ fi
132
+
133
+ if [ x"$dir_arg" != x ]; then
134
+ dst=$src
135
+ src=""
136
+
137
+ if [ -d $dst ]; then
138
+ instcmd=:
139
+ chmodcmd=""
140
+ else
141
+ instcmd=mkdir
142
+ fi
143
+ else
144
+
145
+ # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
146
+ # might cause directories to be created, which would be especially bad
147
+ # if $src (and thus $dsttmp) contains '*'.
148
+
149
+ if [ -f $src -o -d $src ]
150
+ then
151
+ true
152
+ else
153
+ echo "install: $src does not exist"
154
+ exit 1
155
+ fi
156
+
157
+ if [ x"$dst" = x ]
158
+ then
159
+ echo "install: no destination specified"
160
+ exit 1
161
+ else
162
+ true
163
+ fi
164
+
165
+ # If destination is a directory, append the input filename; if your system
166
+ # does not like double slashes in filenames, you may need to add some logic
167
+
168
+ if [ -d $dst ]
169
+ then
170
+ dst="$dst"/`basename $src`
171
+ else
172
+ true
173
+ fi
174
+ fi
175
+
176
+ ## this sed command emulates the dirname command
177
+ dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
178
+
179
+ # Make sure that the destination directory exists.
180
+ # this part is taken from Noah Friedman's mkinstalldirs script
181
+
182
+ # Skip lots of stat calls in the usual case.
183
+ if [ ! -d "$dstdir" ]; then
184
+ defaultIFS='
185
+ '
186
+ IFS="${IFS-${defaultIFS}}"
187
+
188
+ oIFS="${IFS}"
189
+ # Some sh's can't handle IFS=/ for some reason.
190
+ IFS='%'
191
+ set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
192
+ IFS="${oIFS}"
193
+
194
+ pathcomp=''
195
+
196
+ while [ $# -ne 0 ] ; do
197
+ pathcomp="${pathcomp}${1}"
198
+ shift
199
+
200
+ if [ ! -d "${pathcomp}" ] ;
201
+ then
202
+ $mkdirprog "${pathcomp}"
203
+ else
204
+ true
205
+ fi
206
+
207
+ pathcomp="${pathcomp}/"
208
+ done
209
+ fi
210
+
211
+ if [ x"$dir_arg" != x ]
212
+ then
213
+ $doit $instcmd $dst &&
214
+
215
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
216
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
217
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
218
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
219
+ else
220
+
221
+ # If we're going to rename the final executable, determine the name now.
222
+
223
+ if [ x"$transformarg" = x ]
224
+ then
225
+ dstfile=`basename $dst`
226
+ else
227
+ dstfile=`basename $dst $transformbasename |
228
+ sed $transformarg`$transformbasename
229
+ fi
230
+
231
+ # don't allow the sed command to completely eliminate the filename
232
+
233
+ if [ x"$dstfile" = x ]
234
+ then
235
+ dstfile=`basename $dst`
236
+ else
237
+ true
238
+ fi
239
+
240
+ # Make a temp file name in the proper directory.
241
+
242
+ dsttmp=$dstdir/#inst.$$#
243
+
244
+ # Move or copy the file name to the temp name
245
+
246
+ $doit $instcmd $src $dsttmp &&
247
+
248
+ trap "rm -f ${dsttmp}" 0 &&
249
+
250
+ # and set any options; do chmod last to preserve setuid bits
251
+
252
+ # If any of these fail, we abort the whole thing. If we want to
253
+ # ignore errors from any of these, just make sure not to ignore
254
+ # errors from the above "$doit $instcmd $src $dsttmp" command.
255
+
256
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
257
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
258
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
259
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
260
+
261
+ # Now rename the file to the real destination.
262
+
263
+ $doit $rmcmd -f $dstdir/$dstfile &&
264
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
265
+
266
+ fi &&
267
+
268
+
269
+ exit 0