├── LICENSE-BSD.txt ├── LICENSE-LGPL.txt ├── Makefile.in ├── README.md ├── config.guess ├── config.sub ├── configure ├── configure.in ├── include └── libresample.h ├── install-sh ├── meson.build ├── meson.options ├── src ├── configtemplate.h ├── filterkit.c ├── filterkit.h ├── resample.c ├── resample.def ├── resample_defs.h └── resamplesubs.c ├── tests ├── compareresample.c ├── meson.build ├── resample-sndfile.c └── testresample.c └── win └── libresample.vcproj /LICENSE-BSD.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003, Dominic Mazzoni 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /LICENSE-LGPL.txt: -------------------------------------------------------------------------------- 1 | 2 | GNU LESSER GENERAL PUBLIC LICENSE 3 | Version 2.1, February 1999 4 | 5 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 6 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | [This is the first released version of the Lesser GPL. It also counts 11 | as the successor of the GNU Library Public License, version 2, hence 12 | the version number 2.1.] 13 | 14 | Preamble 15 | 16 | The licenses for most software are designed to take away your 17 | freedom to share and change it. By contrast, the GNU General Public 18 | Licenses are intended to guarantee your freedom to share and change 19 | free software--to make sure the software is free for all its users. 20 | 21 | This license, the Lesser General Public License, applies to some 22 | specially designated software packages--typically libraries--of the 23 | Free Software Foundation and other authors who decide to use it. You 24 | can use it too, but we suggest you first think carefully about whether 25 | this license or the ordinary General Public License is the better 26 | strategy to use in any particular case, based on the explanations 27 | below. 28 | 29 | When we speak of free software, we are referring to freedom of use, 30 | not price. Our General Public Licenses are designed to make sure that 31 | you have the freedom to distribute copies of free software (and charge 32 | for this service if you wish); that you receive source code or can get 33 | it if you want it; that you can change the software and use pieces of 34 | it in new free programs; and that you are informed that you can do 35 | these things. 36 | 37 | To protect your rights, we need to make restrictions that forbid 38 | distributors to deny you these rights or to ask you to surrender these 39 | rights. These restrictions translate to certain responsibilities for 40 | you if you distribute copies of the library or if you modify it. 41 | 42 | For example, if you distribute copies of the library, whether gratis 43 | or for a fee, you must give the recipients all the rights that we gave 44 | you. You must make sure that they, too, receive or can get the source 45 | code. If you link other code with the library, you must provide 46 | complete object files to the recipients, so that they can relink them 47 | with the library after making changes to the library and recompiling 48 | it. And you must show them these terms so they know their rights. 49 | 50 | We protect your rights with a two-step method: (1) we copyright the 51 | library, and (2) we offer you this license, which gives you legal 52 | permission to copy, distribute and/or modify the library. 53 | 54 | To protect each distributor, we want to make it very clear that 55 | there is no warranty for the free library. Also, if the library is 56 | modified by someone else and passed on, the recipients should know 57 | that what they have is not the original version, so that the original 58 | author's reputation will not be affected by problems that might be 59 | introduced by others. 60 | 61 | Finally, software patents pose a constant threat to the existence of 62 | any free program. We wish to make sure that a company cannot 63 | effectively restrict the users of a free program by obtaining a 64 | restrictive license from a patent holder. Therefore, we insist that 65 | any patent license obtained for a version of the library must be 66 | consistent with the full freedom of use specified in this license. 67 | 68 | Most GNU software, including some libraries, is covered by the 69 | ordinary GNU General Public License. This license, the GNU Lesser 70 | General Public License, applies to certain designated libraries, and 71 | is quite different from the ordinary General Public License. We use 72 | this license for certain libraries in order to permit linking those 73 | libraries into non-free programs. 74 | 75 | When a program is linked with a library, whether statically or using 76 | a shared library, the combination of the two is legally speaking a 77 | combined work, a derivative of the original library. The ordinary 78 | General Public License therefore permits such linking only if the 79 | entire combination fits its criteria of freedom. The Lesser General 80 | Public License permits more lax criteria for linking other code with 81 | the library. 82 | 83 | We call this license the "Lesser" General Public License because it 84 | does Less to protect the user's freedom than the ordinary General 85 | Public License. It also provides other free software developers Less 86 | of an advantage over competing non-free programs. These disadvantages 87 | are the reason we use the ordinary General Public License for many 88 | libraries. However, the Lesser license provides advantages in certain 89 | special circumstances. 90 | 91 | For example, on rare occasions, there may be a special need to 92 | encourage the widest possible use of a certain library, so that it becomes 93 | a de-facto standard. To achieve this, non-free programs must be 94 | allowed to use the library. A more frequent case is that a free 95 | library does the same job as widely used non-free libraries. In this 96 | case, there is little to gain by limiting the free library to free 97 | software only, so we use the Lesser General Public License. 98 | 99 | In other cases, permission to use a particular library in non-free 100 | programs enables a greater number of people to use a large body of 101 | free software. For example, permission to use the GNU C Library in 102 | non-free programs enables many more people to use the whole GNU 103 | operating system, as well as its variant, the GNU/Linux operating 104 | system. 105 | 106 | Although the Lesser General Public License is Less protective of the 107 | users' freedom, it does ensure that the user of a program that is 108 | linked with the Library has the freedom and the wherewithal to run 109 | that program using a modified version of the Library. 110 | 111 | The precise terms and conditions for copying, distribution and 112 | modification follow. Pay close attention to the difference between a 113 | "work based on the library" and a "work that uses the library". The 114 | former contains code derived from the library, whereas the latter must 115 | be combined with the library in order to run. 116 | 117 | GNU LESSER GENERAL PUBLIC LICENSE 118 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 119 | 120 | 0. This License Agreement applies to any software library or other 121 | program which contains a notice placed by the copyright holder or 122 | other authorized party saying it may be distributed under the terms of 123 | this Lesser General Public License (also called "this License"). 124 | Each licensee is addressed as "you". 125 | 126 | A "library" means a collection of software functions and/or data 127 | prepared so as to be conveniently linked with application programs 128 | (which use some of those functions and data) to form executables. 129 | 130 | The "Library", below, refers to any such software library or work 131 | which has been distributed under these terms. A "work based on the 132 | Library" means either the Library or any derivative work under 133 | copyright law: that is to say, a work containing the Library or a 134 | portion of it, either verbatim or with modifications and/or translated 135 | straightforwardly into another language. (Hereinafter, translation is 136 | included without limitation in the term "modification".) 137 | 138 | "Source code" for a work means the preferred form of the work for 139 | making modifications to it. For a library, complete source code means 140 | all the source code for all modules it contains, plus any associated 141 | interface definition files, plus the scripts used to control 142 | compilation 143 | and installation of the library. 144 | 145 | Activities other than copying, distribution and modification are not 146 | covered by this License; they are outside its scope. The act of 147 | running a program using the Library is not restricted, and output from 148 | such a program is covered only if its contents constitute a work based 149 | on the Library (independent of the use of the Library in a tool for 150 | writing it). Whether that is true depends on what the Library does 151 | and what the program that uses the Library does. 152 | 153 | 1. You may copy and distribute verbatim copies of the Library's 154 | complete source code as you receive it, in any medium, provided that 155 | you conspicuously and appropriately publish on each copy an 156 | appropriate copyright notice and disclaimer of warranty; keep intact 157 | all the notices that refer to this License and to the absence of any 158 | warranty; and distribute a copy of this License along with the 159 | Library. 160 | 161 | You may charge a fee for the physical act of transferring a copy, 162 | and you may at your option offer warranty protection in exchange for a 163 | fee. 164 | 165 | 2. You may modify your copy or copies of the Library or any portion 166 | of it, thus forming a work based on the Library, and copy and 167 | distribute such modifications or work under the terms of Section 1 168 | above, provided that you also meet all of these conditions: 169 | 170 | a) The modified work must itself be a software library. 171 | 172 | b) You must cause the files modified to carry prominent notices 173 | stating that you changed the files and the date of any change. 174 | 175 | c) You must cause the whole of the work to be licensed at no 176 | charge to all third parties under the terms of this License. 177 | 178 | d) If a facility in the modified Library refers to a function or a 179 | table of data to be supplied by an application program that uses 180 | the facility, other than as an argument passed when the facility 181 | is invoked, then you must make a good faith effort to ensure that, 182 | in the event an application does not supply such function or 183 | table, the facility still operates, and performs whatever part of 184 | its purpose remains meaningful. 185 | 186 | (For example, a function in a library to compute square roots has 187 | a purpose that is entirely well-defined independent of the 188 | application. Therefore, Subsection 2d requires that any 189 | application-supplied function or table used by this function must 190 | be optional: if the application does not supply it, the square 191 | root function must still compute square roots.) 192 | 193 | These requirements apply to the modified work as a whole. If 194 | identifiable sections of that work are not derived from the Library, 195 | and can be reasonably considered independent and separate works in 196 | themselves, then this License, and its terms, do not apply to those 197 | sections when you distribute them as separate works. But when you 198 | distribute the same sections as part of a whole which is a work based 199 | on the Library, the distribution of the whole must be on the terms of 200 | this License, whose permissions for other licensees extend to the 201 | entire whole, and thus to each and every part regardless of who wrote 202 | it. 203 | 204 | Thus, it is not the intent of this section to claim rights or contest 205 | your rights to work written entirely by you; rather, the intent is to 206 | exercise the right to control the distribution of derivative or 207 | collective works based on the Library. 208 | 209 | In addition, mere aggregation of another work not based on the Library 210 | with the Library (or with a work based on the Library) on a volume of 211 | a storage or distribution medium does not bring the other work under 212 | the scope of this License. 213 | 214 | 3. You may opt to apply the terms of the ordinary GNU General Public 215 | License instead of this License to a given copy of the Library. To do 216 | this, you must alter all the notices that refer to this License, so 217 | that they refer to the ordinary GNU General Public License, version 2, 218 | instead of to this License. (If a newer version than version 2 of the 219 | ordinary GNU General Public License has appeared, then you can specify 220 | that version instead if you wish.) Do not make any other change in 221 | these notices. 222 | 223 | Once this change is made in a given copy, it is irreversible for 224 | that copy, so the ordinary GNU General Public License applies to all 225 | subsequent copies and derivative works made from that copy. 226 | 227 | This option is useful when you wish to copy part of the code of 228 | the Library into a program that is not a library. 229 | 230 | 4. You may copy and distribute the Library (or a portion or 231 | derivative of it, under Section 2) in object code or executable form 232 | under the terms of Sections 1 and 2 above provided that you accompany 233 | it with the complete corresponding machine-readable source code, which 234 | must be distributed under the terms of Sections 1 and 2 above on a 235 | medium customarily used for software interchange. 236 | 237 | If distribution of object code is made by offering access to copy 238 | from a designated place, then offering equivalent access to copy the 239 | source code from the same place satisfies the requirement to 240 | distribute the source code, even though third parties are not 241 | compelled to copy the source along with the object code. 242 | 243 | 5. A program that contains no derivative of any portion of the 244 | Library, but is designed to work with the Library by being compiled or 245 | linked with it, is called a "work that uses the Library". Such a 246 | work, in isolation, is not a derivative work of the Library, and 247 | therefore falls outside the scope of this License. 248 | 249 | However, linking a "work that uses the Library" with the Library 250 | creates an executable that is a derivative of the Library (because it 251 | contains portions of the Library), rather than a "work that uses the 252 | library". The executable is therefore covered by this License. 253 | Section 6 states terms for distribution of such executables. 254 | 255 | When a "work that uses the Library" uses material from a header file 256 | that is part of the Library, the object code for the work may be a 257 | derivative work of the Library even though the source code is not. 258 | Whether this is true is especially significant if the work can be 259 | linked without the Library, or if the work is itself a library. The 260 | threshold for this to be true is not precisely defined by law. 261 | 262 | If such an object file uses only numerical parameters, data 263 | structure layouts and accessors, and small macros and small inline 264 | functions (ten lines or less in length), then the use of the object 265 | file is unrestricted, regardless of whether it is legally a derivative 266 | work. (Executables containing this object code plus portions of the 267 | Library will still fall under Section 6.) 268 | 269 | Otherwise, if the work is a derivative of the Library, you may 270 | distribute the object code for the work under the terms of Section 6. 271 | Any executables containing that work also fall under Section 6, 272 | whether or not they are linked directly with the Library itself. 273 | 274 | 6. As an exception to the Sections above, you may also combine or 275 | link a "work that uses the Library" with the Library to produce a 276 | work containing portions of the Library, and distribute that work 277 | under terms of your choice, provided that the terms permit 278 | modification of the work for the customer's own use and reverse 279 | engineering for debugging such modifications. 280 | 281 | You must give prominent notice with each copy of the work that the 282 | Library is used in it and that the Library and its use are covered by 283 | this License. You must supply a copy of this License. If the work 284 | during execution displays copyright notices, you must include the 285 | copyright notice for the Library among them, as well as a reference 286 | directing the user to the copy of this License. Also, you must do one 287 | of these things: 288 | 289 | a) Accompany the work with the complete corresponding 290 | machine-readable source code for the Library including whatever 291 | changes were used in the work (which must be distributed under 292 | Sections 1 and 2 above); and, if the work is an executable linked 293 | with the Library, with the complete machine-readable "work that 294 | uses the Library", as object code and/or source code, so that the 295 | user can modify the Library and then relink to produce a modified 296 | executable containing the modified Library. (It is understood 297 | that the user who changes the contents of definitions files in the 298 | Library will not necessarily be able to recompile the application 299 | to use the modified definitions.) 300 | 301 | b) Use a suitable shared library mechanism for linking with the 302 | Library. A suitable mechanism is one that (1) uses at run time a 303 | copy of the library already present on the user's computer system, 304 | rather than copying library functions into the executable, and (2) 305 | will operate properly with a modified version of the library, if 306 | the user installs one, as long as the modified version is 307 | interface-compatible with the version that the work was made with. 308 | 309 | c) Accompany the work with a written offer, valid for at 310 | least three years, to give the same user the materials 311 | specified in Subsection 6a, above, for a charge no more 312 | than the cost of performing this distribution. 313 | 314 | d) If distribution of the work is made by offering access to copy 315 | from a designated place, offer equivalent access to copy the above 316 | specified materials from the same place. 317 | 318 | e) Verify that the user has already received a copy of these 319 | materials or that you have already sent this user a copy. 320 | 321 | For an executable, the required form of the "work that uses the 322 | Library" must include any data and utility programs needed for 323 | reproducing the executable from it. However, as a special exception, 324 | the materials to be distributed need not include anything that is 325 | normally distributed (in either source or binary form) with the major 326 | components (compiler, kernel, and so on) of the operating system on 327 | which the executable runs, unless that component itself accompanies 328 | the executable. 329 | 330 | It may happen that this requirement contradicts the license 331 | restrictions of other proprietary libraries that do not normally 332 | accompany the operating system. Such a contradiction means you cannot 333 | use both them and the Library together in an executable that you 334 | distribute. 335 | 336 | 7. You may place library facilities that are a work based on the 337 | Library side-by-side in a single library together with other library 338 | facilities not covered by this License, and distribute such a combined 339 | library, provided that the separate distribution of the work based on 340 | the Library and of the other library facilities is otherwise 341 | permitted, and provided that you do these two things: 342 | 343 | a) Accompany the combined library with a copy of the same work 344 | based on the Library, uncombined with any other library 345 | facilities. This must be distributed under the terms of the 346 | Sections above. 347 | 348 | b) Give prominent notice with the combined library of the fact 349 | that part of it is a work based on the Library, and explaining 350 | where to find the accompanying uncombined form of the same work. 351 | 352 | 8. You may not copy, modify, sublicense, link with, or distribute 353 | the Library except as expressly provided under this License. Any 354 | attempt otherwise to copy, modify, sublicense, link with, or 355 | distribute the Library is void, and will automatically terminate your 356 | rights under this License. However, parties who have received copies, 357 | or rights, from you under this License will not have their licenses 358 | terminated so long as such parties remain in full compliance. 359 | 360 | 9. You are not required to accept this License, since you have not 361 | signed it. However, nothing else grants you permission to modify or 362 | distribute the Library or its derivative works. These actions are 363 | prohibited by law if you do not accept this License. Therefore, by 364 | modifying or distributing the Library (or any work based on the 365 | Library), you indicate your acceptance of this License to do so, and 366 | all its terms and conditions for copying, distributing or modifying 367 | the Library or works based on it. 368 | 369 | 10. Each time you redistribute the Library (or any work based on the 370 | Library), the recipient automatically receives a license from the 371 | original licensor to copy, distribute, link with or modify the Library 372 | subject to these terms and conditions. You may not impose any further 373 | restrictions on the recipients' exercise of the rights granted herein. 374 | You are not responsible for enforcing compliance by third parties with 375 | this License. 376 | 377 | 11. If, as a consequence of a court judgment or allegation of patent 378 | infringement or for any other reason (not limited to patent issues), 379 | conditions are imposed on you (whether by court order, agreement or 380 | otherwise) that contradict the conditions of this License, they do not 381 | excuse you from the conditions of this License. If you cannot 382 | distribute so as to satisfy simultaneously your obligations under this 383 | License and any other pertinent obligations, then as a consequence you 384 | may not distribute the Library at all. For example, if a patent 385 | license would not permit royalty-free redistribution of the Library by 386 | all those who receive copies directly or indirectly through you, then 387 | the only way you could satisfy both it and this License would be to 388 | refrain entirely from distribution of the Library. 389 | 390 | If any portion of this section is held invalid or unenforceable under 391 | any particular circumstance, the balance of the section is intended to 392 | apply, and the section as a whole is intended to apply in other 393 | circumstances. 394 | 395 | It is not the purpose of this section to induce you to infringe any 396 | patents or other property right claims or to contest validity of any 397 | such claims; this section has the sole purpose of protecting the 398 | integrity of the free software distribution system which is 399 | implemented by public license practices. Many people have made 400 | generous contributions to the wide range of software distributed 401 | through that system in reliance on consistent application of that 402 | system; it is up to the author/donor to decide if he or she is willing 403 | to distribute software through any other system and a licensee cannot 404 | impose that choice. 405 | 406 | This section is intended to make thoroughly clear what is believed to 407 | be a consequence of the rest of this License. 408 | 409 | 12. If the distribution and/or use of the Library is restricted in 410 | certain countries either by patents or by copyrighted interfaces, the 411 | original copyright holder who places the Library under this License 412 | may add an explicit geographical distribution limitation excluding those 413 | countries, so that distribution is permitted only in or among 414 | countries not thus excluded. In such case, this License incorporates 415 | the limitation as if written in the body of this License. 416 | 417 | 13. The Free Software Foundation may publish revised and/or new 418 | versions of the Lesser General Public License from time to time. 419 | Such new versions will be similar in spirit to the present version, 420 | but may differ in detail to address new problems or concerns. 421 | 422 | Each version is given a distinguishing version number. If the Library 423 | specifies a version number of this License which applies to it and 424 | "any later version", you have the option of following the terms and 425 | conditions either of that version or of any later version published by 426 | the Free Software Foundation. If the Library does not specify a 427 | license version number, you may choose any version ever published by 428 | the Free Software Foundation. 429 | 430 | 14. If you wish to incorporate parts of the Library into other free 431 | programs whose distribution conditions are incompatible with these, 432 | write to the author to ask for permission. For software which is 433 | copyrighted by the Free Software Foundation, write to the Free 434 | Software Foundation; we sometimes make exceptions for this. Our 435 | decision will be guided by the two goals of preserving the free status 436 | of all derivatives of our free software and of promoting the sharing 437 | and reuse of software generally. 438 | 439 | NO WARRANTY 440 | 441 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 442 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 443 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 444 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 445 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 446 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 447 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 448 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 449 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 450 | 451 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 452 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 453 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 454 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 455 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 456 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 457 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 458 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 459 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 460 | DAMAGES. 461 | 462 | END OF TERMS AND CONDITIONS 463 | 464 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Run configure to generate Makefile from Makefile.in on 2 | # any system supported by GNU autoconf. For all other 3 | # systems, use this file as a template to create a 4 | # working Makefile. 5 | 6 | CC = @CC@ 7 | CFLAGS += @CFLAGS@ 8 | LDFLAGS += @LDFLAGS@ 9 | 10 | LIBS = @LIBS@ -lm 11 | 12 | AR = @AR@ 13 | RANLIB = @RANLIB@ 14 | srcdir=@srcdir@ 15 | 16 | OBJS = \ 17 | src/resample.c.o \ 18 | src/resamplesubs.c.o \ 19 | src/filterkit.c.o 20 | 21 | TARGETS = @TARGETS@ 22 | DIRS=tests 23 | 24 | all: $(TARGETS) 25 | 26 | libresample.a: $(OBJS) Makefile 27 | $(AR) ruv libresample.a $(OBJS) 28 | ranlib libresample.a 29 | 30 | tests/testresample: libresample.a $(srcdir)/tests/testresample.c 31 | $(CC) -o tests/testresample \ 32 | $(CFLAGS) $(LDFLAGS) $(srcdir)/tests/testresample.c \ 33 | libresample.a $(LIBS) 34 | 35 | tests/compareresample: libresample.a $(srcdir)/tests/compareresample.c 36 | $(CC) -o tests/compareresample \ 37 | $(CFLAGS) $(LDFLAGS) $(srcdir)/tests/compareresample.c \ 38 | libresample.a -lsamplerate $(LIBS) 39 | 40 | tests/resample-sndfile: libresample.a $(srcdir)/tests/resample-sndfile.c 41 | $(CC) -o tests/resample-sndfile \ 42 | $(CFLAGS) $(LDFLAGS) $(srcdir)/tests/resample-sndfile.c \ 43 | libresample.a -lsndfile $(LIBS) 44 | 45 | $(DIRS): 46 | mkdir $(DIRS) 47 | 48 | clean: 49 | rm -f $(TARGETS) $(OBJS) 50 | 51 | distclean: clean 52 | rm -f Makefile 53 | rm -f config.status config.cache config.log src/config.h 54 | rm -f *~ src/*~ tests/*~ include/*~ 55 | 56 | $(OBJS): %.c.o: $(srcdir)/%.c Makefile $(srcdir)/include/libresample.h \ 57 | $(srcdir)/src/resample_defs.h $(srcdir)/src/filterkit.h $(srcdir)/src/config.h 58 | $(CC) -c $(CFLAGS) $< -o $@ 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libresample 2 | =========== 3 | 4 | Real-time library interface by Dominic Mazzoni 5 | 6 | Based on resample-1.7: 7 | http://www-ccrma.stanford.edu/~jos/resample/ 8 | 9 | This software is available for use under the terms of either the 10 | BSD License or the LGPL License, at your option - see: 11 | 12 | LICENSE-LGPL.txt 13 | LICENSE-BSD.txt 14 | 15 | History: 16 | 17 | This library is not the highest-quality resampling library 18 | available, nor is it the most flexible, nor is it the 19 | fastest. But it is pretty good in all of these regards, and 20 | it is quite portable. The best resampling library I am aware 21 | of is libsamplerate by Erik de Castro Lopo. It's small, fast, 22 | and very high quality. However, it uses the GPL for its 23 | license (with commercial options available) and I needed 24 | a more free library. So I wrote this library, using 25 | the LGPL resample-1.7 library by Julius Smith as a basis. 26 | 27 | Resample-1.7 is a fixed-point resampler, and as a result 28 | has only limited precision. I rewrote it to use single-precision 29 | floating-point arithmetic instead and increased the number 30 | of filter coefficients between time steps significantly. 31 | On modern processors it can resample in real time even 32 | with this extra overhead. 33 | 34 | Resample-1.7 was designed to read and write from files, so 35 | I removed all of that code and replaced it with an API that 36 | lets you pass samples in small chunks. It should be easy 37 | to link to resample-1.7 as a library. 38 | 39 | Changes in version 0.1.3: 40 | 41 | * Fixed two bugs that were causing subtle problems 42 | on Intel x86 processors due to differences in roundoff errors. 43 | 44 | * Prefixed most function names with lrs and changed header file 45 | from resample.h to libresample.h, to avoid namespace 46 | collisions with existing programs and libraries. 47 | 48 | * Added resample_dup (thanks to Glenn Maynard) 49 | 50 | * Argument to resample_get_filter_width takes a const void * 51 | (thanks to Glenn Maynard) 52 | 53 | * resample-sndfile clips output to -1...1 (thanks to Glenn Maynard) 54 | 55 | Changes in version 0.1.4: 56 | 57 | * Added BSD license, with support from all authors and contributors. 58 | 59 | * Uploaded to GitHub: http://github.com/minorninth/libresample 60 | 61 | Changes in version 0.1.5: 62 | 63 | * Added a new build system using Meson. 64 | 65 | Usage notes: 66 | 67 | - If the output buffer you pass is too small, resample_process 68 | may not use any input samples because its internal output 69 | buffer is too full to process any more. So do not assume 70 | that it is an error just because no input samples were 71 | consumed. Just keep passing valid output buffers. 72 | 73 | - Given a resampling factor f > 1, and a number of input 74 | samples n, the number of output samples should be between 75 | floor(n - f) and ceil(n + f). In other words, if you 76 | resample 1000 samples at a factor of 8, the number of 77 | output samples might be between 7992 and 8008. Do not 78 | assume that it will be exactly 8000. If you need exactly 79 | 8000 outputs, pad the input with extra zeros as necessary. 80 | 81 | Build instructions: 82 | 83 | libresample can be built with [Meson](https://mesonbuild.com/), 84 | with the standard Autotools `./configure && make`, or with the 85 | included Visual Studio 2005 project file. 86 | 87 | The Meson build should generally be preferred. In particular, 88 | it is strongly recommended that downstream distribution 89 | packagers use the Meson build system for reasons of 90 | interoperability, as it generates a pkg-config file, supports 91 | building a shared library, can automatically run the tests, and 92 | runs on both Unix-like platforms and Windows. The older Autotools 93 | build system is retained for projects that already embed it into 94 | their builds and systems that do not have Meson. 95 | 96 | License and warranty: 97 | 98 | All of the files in this package are Copyright 2003 by Dominic 99 | Mazzoni . This library was based heavily 100 | on Resample-1.7, Copyright 1994-2002 by Julius O. Smith III 101 | , all rights reserved. 102 | 103 | Permission to use and copy is granted subject to the terms of the 104 | "GNU Lesser General Public License" (LGPL) as published by the 105 | Free Software Foundation; either version 2.1 of the License, 106 | or any later version. In addition, Julius O. Smith III requests 107 | that a copy of any modified files be sent by email to 108 | jos@ccrma.stanford.edu so that he may incorporate them into the 109 | CCRMA version. 110 | 111 | This library is distributed in the hope that it will be useful, 112 | but WITHOUT ANY WARRANTY; without even the implied warranty of 113 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 114 | Lesser General Public License for more details. 115 | 116 | Permission to use and copy is also granted subject to the terms of the 117 | BSD license found in LICENSE-BSD.txt. 118 | 119 | You can choose either license to comply with, at your option. 120 | 121 | Redistribution and use in source and binary forms, with or without modification, 122 | are permitted provided that the following conditions are met: 123 | 124 | * Redistributions of source code must retain the above copyright notice, this 125 | list of conditions and the following disclaimer. 126 | 127 | * Redistributions in binary form must reproduce the above copyright notice, this 128 | list of conditions and the following disclaimer in the documentation and/or 129 | other materials provided with the distribution. 130 | 131 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 132 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 133 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 134 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 135 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 136 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 137 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 138 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 139 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 140 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 141 | -------------------------------------------------------------------------------- /config.guess: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Attempt to guess a canonical system name. 3 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 | # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 5 | # Free Software Foundation, Inc. 6 | 7 | timestamp='2009-08-19' 8 | 9 | # This file is free software; you can redistribute it and/or modify it 10 | # under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, but 15 | # WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | # General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 22 | # 02110-1301, USA. 23 | # 24 | # As a special exception to the GNU General Public License, if you 25 | # distribute this file as part of a program that contains a 26 | # configuration script generated by Autoconf, you may include it under 27 | # the same distribution terms that you use for the rest of that program. 28 | 29 | 30 | # Originally written by Per Bothner. Please send patches (context 31 | # diff format) to and include a ChangeLog 32 | # entry. 33 | # 34 | # This script attempts to guess a canonical system name similar to 35 | # config.sub. If it succeeds, it prints the system name on stdout, and 36 | # exits with 0. Otherwise, it exits with 1. 37 | # 38 | # You can get the latest version of this script from: 39 | # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD 40 | 41 | me=`echo "$0" | sed -e 's,.*/,,'` 42 | 43 | usage="\ 44 | Usage: $0 [OPTION] 45 | 46 | Output the configuration name of the system \`$me' is run on. 47 | 48 | Operation modes: 49 | -h, --help print this help, then exit 50 | -t, --time-stamp print date of last modification, then exit 51 | -v, --version print version number, then exit 52 | 53 | Report bugs and patches to ." 54 | 55 | version="\ 56 | GNU config.guess ($timestamp) 57 | 58 | Originally written by Per Bothner. 59 | Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 60 | 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 61 | 62 | This is free software; see the source for copying conditions. There is NO 63 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 64 | 65 | help=" 66 | Try \`$me --help' for more information." 67 | 68 | # Parse command line 69 | while test $# -gt 0 ; do 70 | case $1 in 71 | --time-stamp | --time* | -t ) 72 | echo "$timestamp" ; exit ;; 73 | --version | -v ) 74 | echo "$version" ; exit ;; 75 | --help | --h* | -h ) 76 | echo "$usage"; exit ;; 77 | -- ) # Stop option processing 78 | shift; break ;; 79 | - ) # Use stdin as input. 80 | break ;; 81 | -* ) 82 | echo "$me: invalid option $1$help" >&2 83 | exit 1 ;; 84 | * ) 85 | break ;; 86 | esac 87 | done 88 | 89 | if test $# != 0; then 90 | echo "$me: too many arguments$help" >&2 91 | exit 1 92 | fi 93 | 94 | trap 'exit 1' 1 2 15 95 | 96 | # CC_FOR_BUILD -- compiler used by this script. Note that the use of a 97 | # compiler to aid in system detection is discouraged as it requires 98 | # temporary files to be created and, as you can see below, it is a 99 | # headache to deal with in a portable fashion. 100 | 101 | # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still 102 | # use `HOST_CC' if defined, but it is deprecated. 103 | 104 | # Portable tmp directory creation inspired by the Autoconf team. 105 | 106 | set_cc_for_build=' 107 | trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; 108 | trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; 109 | : ${TMPDIR=/tmp} ; 110 | { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || 111 | { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || 112 | { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || 113 | { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; 114 | dummy=$tmp/dummy ; 115 | tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; 116 | case $CC_FOR_BUILD,$HOST_CC,$CC in 117 | ,,) echo "int x;" > $dummy.c ; 118 | for c in cc gcc c89 c99 ; do 119 | if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then 120 | CC_FOR_BUILD="$c"; break ; 121 | fi ; 122 | done ; 123 | if test x"$CC_FOR_BUILD" = x ; then 124 | CC_FOR_BUILD=no_compiler_found ; 125 | fi 126 | ;; 127 | ,,*) CC_FOR_BUILD=$CC ;; 128 | ,*,*) CC_FOR_BUILD=$HOST_CC ;; 129 | esac ; set_cc_for_build= ;' 130 | 131 | # This is needed to find uname on a Pyramid OSx when run in the BSD universe. 132 | # (ghazi@noc.rutgers.edu 1994-08-24) 133 | if (test -f /.attbin/uname) >/dev/null 2>&1 ; then 134 | PATH=$PATH:/.attbin ; export PATH 135 | fi 136 | 137 | UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown 138 | UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown 139 | UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown 140 | UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown 141 | 142 | case "${UNAME_SYSTEM}" in 143 | Linux|GNU/*) 144 | eval $set_cc_for_build 145 | cat << EOF > $dummy.c 146 | #include 147 | #ifdef __UCLIBC__ 148 | # ifdef __UCLIBC_CONFIG_VERSION__ 149 | LIBC=uclibc __UCLIBC_CONFIG_VERSION__ 150 | # else 151 | LIBC=uclibc 152 | # endif 153 | #else 154 | LIBC=gnu 155 | #endif 156 | EOF 157 | eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep LIBC= | sed -e 's: ::g'` 158 | ;; 159 | esac 160 | 161 | # Note: order is significant - the case branches are not exclusive. 162 | 163 | case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 164 | *:NetBSD:*:*) 165 | # NetBSD (nbsd) targets should (where applicable) match one or 166 | # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, 167 | # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently 168 | # switched to ELF, *-*-netbsd* would select the old 169 | # object file format. This provides both forward 170 | # compatibility and a consistent mechanism for selecting the 171 | # object file format. 172 | # 173 | # Note: NetBSD doesn't particularly care about the vendor 174 | # portion of the name. We always set it to "unknown". 175 | sysctl="sysctl -n hw.machine_arch" 176 | UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ 177 | /usr/sbin/$sysctl 2>/dev/null || echo unknown)` 178 | case "${UNAME_MACHINE_ARCH}" in 179 | armeb) machine=armeb-unknown ;; 180 | arm*) machine=arm-unknown ;; 181 | sh3el) machine=shl-unknown ;; 182 | sh3eb) machine=sh-unknown ;; 183 | sh5el) machine=sh5le-unknown ;; 184 | *) machine=${UNAME_MACHINE_ARCH}-unknown ;; 185 | esac 186 | # The Operating System including object format, if it has switched 187 | # to ELF recently, or will in the future. 188 | case "${UNAME_MACHINE_ARCH}" in 189 | arm*|i386|m68k|ns32k|sh3*|sparc|vax) 190 | eval $set_cc_for_build 191 | if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ 192 | | grep -q __ELF__ 193 | then 194 | # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). 195 | # Return netbsd for either. FIX? 196 | os=netbsd 197 | else 198 | os=netbsdelf 199 | fi 200 | ;; 201 | *) 202 | os=netbsd 203 | ;; 204 | esac 205 | # The OS release 206 | # Debian GNU/NetBSD machines have a different userland, and 207 | # thus, need a distinct triplet. However, they do not need 208 | # kernel version information, so it can be replaced with a 209 | # suitable tag, in the style of linux-gnu. 210 | case "${UNAME_VERSION}" in 211 | Debian*) 212 | release='-gnu' 213 | ;; 214 | *) 215 | release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` 216 | ;; 217 | esac 218 | # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: 219 | # contains redundant information, the shorter form: 220 | # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. 221 | echo "${machine}-${os}${release}" 222 | exit ;; 223 | *:OpenBSD:*:*) 224 | UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` 225 | echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} 226 | exit ;; 227 | *:ekkoBSD:*:*) 228 | echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} 229 | exit ;; 230 | *:SolidBSD:*:*) 231 | echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} 232 | exit ;; 233 | macppc:MirBSD:*:*) 234 | echo powerpc-unknown-mirbsd${UNAME_RELEASE} 235 | exit ;; 236 | *:MirBSD:*:*) 237 | echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} 238 | exit ;; 239 | alpha:OSF1:*:*) 240 | case $UNAME_RELEASE in 241 | *4.0) 242 | UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` 243 | ;; 244 | *5.*) 245 | UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` 246 | ;; 247 | esac 248 | # According to Compaq, /usr/sbin/psrinfo has been available on 249 | # OSF/1 and Tru64 systems produced since 1995. I hope that 250 | # covers most systems running today. This code pipes the CPU 251 | # types through head -n 1, so we only detect the type of CPU 0. 252 | ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` 253 | case "$ALPHA_CPU_TYPE" in 254 | "EV4 (21064)") 255 | UNAME_MACHINE="alpha" ;; 256 | "EV4.5 (21064)") 257 | UNAME_MACHINE="alpha" ;; 258 | "LCA4 (21066/21068)") 259 | UNAME_MACHINE="alpha" ;; 260 | "EV5 (21164)") 261 | UNAME_MACHINE="alphaev5" ;; 262 | "EV5.6 (21164A)") 263 | UNAME_MACHINE="alphaev56" ;; 264 | "EV5.6 (21164PC)") 265 | UNAME_MACHINE="alphapca56" ;; 266 | "EV5.7 (21164PC)") 267 | UNAME_MACHINE="alphapca57" ;; 268 | "EV6 (21264)") 269 | UNAME_MACHINE="alphaev6" ;; 270 | "EV6.7 (21264A)") 271 | UNAME_MACHINE="alphaev67" ;; 272 | "EV6.8CB (21264C)") 273 | UNAME_MACHINE="alphaev68" ;; 274 | "EV6.8AL (21264B)") 275 | UNAME_MACHINE="alphaev68" ;; 276 | "EV6.8CX (21264D)") 277 | UNAME_MACHINE="alphaev68" ;; 278 | "EV6.9A (21264/EV69A)") 279 | UNAME_MACHINE="alphaev69" ;; 280 | "EV7 (21364)") 281 | UNAME_MACHINE="alphaev7" ;; 282 | "EV7.9 (21364A)") 283 | UNAME_MACHINE="alphaev79" ;; 284 | esac 285 | # A Pn.n version is a patched version. 286 | # A Vn.n version is a released version. 287 | # A Tn.n version is a released field test version. 288 | # A Xn.n version is an unreleased experimental baselevel. 289 | # 1.2 uses "1.2" for uname -r. 290 | echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 291 | exit ;; 292 | Alpha\ *:Windows_NT*:*) 293 | # How do we know it's Interix rather than the generic POSIX subsystem? 294 | # Should we change UNAME_MACHINE based on the output of uname instead 295 | # of the specific Alpha model? 296 | echo alpha-pc-interix 297 | exit ;; 298 | 21064:Windows_NT:50:3) 299 | echo alpha-dec-winnt3.5 300 | exit ;; 301 | Amiga*:UNIX_System_V:4.0:*) 302 | echo m68k-unknown-sysv4 303 | exit ;; 304 | *:[Aa]miga[Oo][Ss]:*:*) 305 | echo ${UNAME_MACHINE}-unknown-amigaos 306 | exit ;; 307 | *:[Mm]orph[Oo][Ss]:*:*) 308 | echo ${UNAME_MACHINE}-unknown-morphos 309 | exit ;; 310 | *:OS/390:*:*) 311 | echo i370-ibm-openedition 312 | exit ;; 313 | *:z/VM:*:*) 314 | echo s390-ibm-zvmoe 315 | exit ;; 316 | *:OS400:*:*) 317 | echo powerpc-ibm-os400 318 | exit ;; 319 | arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) 320 | echo arm-acorn-riscix${UNAME_RELEASE} 321 | exit ;; 322 | arm:riscos:*:*|arm:RISCOS:*:*) 323 | echo arm-unknown-riscos 324 | exit ;; 325 | SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) 326 | echo hppa1.1-hitachi-hiuxmpp 327 | exit ;; 328 | Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) 329 | # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. 330 | if test "`(/bin/universe) 2>/dev/null`" = att ; then 331 | echo pyramid-pyramid-sysv3 332 | else 333 | echo pyramid-pyramid-bsd 334 | fi 335 | exit ;; 336 | NILE*:*:*:dcosx) 337 | echo pyramid-pyramid-svr4 338 | exit ;; 339 | DRS?6000:unix:4.0:6*) 340 | echo sparc-icl-nx6 341 | exit ;; 342 | DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) 343 | case `/usr/bin/uname -p` in 344 | sparc) echo sparc-icl-nx7; exit ;; 345 | esac ;; 346 | s390x:SunOS:*:*) 347 | echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 348 | exit ;; 349 | sun4H:SunOS:5.*:*) 350 | echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 351 | exit ;; 352 | sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) 353 | echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 354 | exit ;; 355 | i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) 356 | eval $set_cc_for_build 357 | SUN_ARCH="i386" 358 | # If there is a compiler, see if it is configured for 64-bit objects. 359 | # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. 360 | # This test works for both compilers. 361 | if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 362 | if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ 363 | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 364 | grep IS_64BIT_ARCH >/dev/null 365 | then 366 | SUN_ARCH="x86_64" 367 | fi 368 | fi 369 | echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 370 | exit ;; 371 | sun4*:SunOS:6*:*) 372 | # According to config.sub, this is the proper way to canonicalize 373 | # SunOS6. Hard to guess exactly what SunOS6 will be like, but 374 | # it's likely to be more like Solaris than SunOS4. 375 | echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 376 | exit ;; 377 | sun4*:SunOS:*:*) 378 | case "`/usr/bin/arch -k`" in 379 | Series*|S4*) 380 | UNAME_RELEASE=`uname -v` 381 | ;; 382 | esac 383 | # Japanese Language versions have a version number like `4.1.3-JL'. 384 | echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` 385 | exit ;; 386 | sun3*:SunOS:*:*) 387 | echo m68k-sun-sunos${UNAME_RELEASE} 388 | exit ;; 389 | sun*:*:4.2BSD:*) 390 | UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` 391 | test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 392 | case "`/bin/arch`" in 393 | sun3) 394 | echo m68k-sun-sunos${UNAME_RELEASE} 395 | ;; 396 | sun4) 397 | echo sparc-sun-sunos${UNAME_RELEASE} 398 | ;; 399 | esac 400 | exit ;; 401 | aushp:SunOS:*:*) 402 | echo sparc-auspex-sunos${UNAME_RELEASE} 403 | exit ;; 404 | # The situation for MiNT is a little confusing. The machine name 405 | # can be virtually everything (everything which is not 406 | # "atarist" or "atariste" at least should have a processor 407 | # > m68000). The system name ranges from "MiNT" over "FreeMiNT" 408 | # to the lowercase version "mint" (or "freemint"). Finally 409 | # the system name "TOS" denotes a system which is actually not 410 | # MiNT. But MiNT is downward compatible to TOS, so this should 411 | # be no problem. 412 | atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) 413 | echo m68k-atari-mint${UNAME_RELEASE} 414 | exit ;; 415 | atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) 416 | echo m68k-atari-mint${UNAME_RELEASE} 417 | exit ;; 418 | *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) 419 | echo m68k-atari-mint${UNAME_RELEASE} 420 | exit ;; 421 | milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) 422 | echo m68k-milan-mint${UNAME_RELEASE} 423 | exit ;; 424 | hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) 425 | echo m68k-hades-mint${UNAME_RELEASE} 426 | exit ;; 427 | *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) 428 | echo m68k-unknown-mint${UNAME_RELEASE} 429 | exit ;; 430 | m68k:machten:*:*) 431 | echo m68k-apple-machten${UNAME_RELEASE} 432 | exit ;; 433 | powerpc:machten:*:*) 434 | echo powerpc-apple-machten${UNAME_RELEASE} 435 | exit ;; 436 | RISC*:Mach:*:*) 437 | echo mips-dec-mach_bsd4.3 438 | exit ;; 439 | RISC*:ULTRIX:*:*) 440 | echo mips-dec-ultrix${UNAME_RELEASE} 441 | exit ;; 442 | VAX*:ULTRIX*:*:*) 443 | echo vax-dec-ultrix${UNAME_RELEASE} 444 | exit ;; 445 | 2020:CLIX:*:* | 2430:CLIX:*:*) 446 | echo clipper-intergraph-clix${UNAME_RELEASE} 447 | exit ;; 448 | mips:*:*:UMIPS | mips:*:*:RISCos) 449 | eval $set_cc_for_build 450 | sed 's/^ //' << EOF >$dummy.c 451 | #ifdef __cplusplus 452 | #include /* for printf() prototype */ 453 | int main (int argc, char *argv[]) { 454 | #else 455 | int main (argc, argv) int argc; char *argv[]; { 456 | #endif 457 | #if defined (host_mips) && defined (MIPSEB) 458 | #if defined (SYSTYPE_SYSV) 459 | printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); 460 | #endif 461 | #if defined (SYSTYPE_SVR4) 462 | printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); 463 | #endif 464 | #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) 465 | printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); 466 | #endif 467 | #endif 468 | exit (-1); 469 | } 470 | EOF 471 | $CC_FOR_BUILD -o $dummy $dummy.c && 472 | dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && 473 | SYSTEM_NAME=`$dummy $dummyarg` && 474 | { echo "$SYSTEM_NAME"; exit; } 475 | echo mips-mips-riscos${UNAME_RELEASE} 476 | exit ;; 477 | Motorola:PowerMAX_OS:*:*) 478 | echo powerpc-motorola-powermax 479 | exit ;; 480 | Motorola:*:4.3:PL8-*) 481 | echo powerpc-harris-powermax 482 | exit ;; 483 | Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) 484 | echo powerpc-harris-powermax 485 | exit ;; 486 | Night_Hawk:Power_UNIX:*:*) 487 | echo powerpc-harris-powerunix 488 | exit ;; 489 | m88k:CX/UX:7*:*) 490 | echo m88k-harris-cxux7 491 | exit ;; 492 | m88k:*:4*:R4*) 493 | echo m88k-motorola-sysv4 494 | exit ;; 495 | m88k:*:3*:R3*) 496 | echo m88k-motorola-sysv3 497 | exit ;; 498 | AViiON:dgux:*:*) 499 | # DG/UX returns AViiON for all architectures 500 | UNAME_PROCESSOR=`/usr/bin/uname -p` 501 | if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] 502 | then 503 | if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ 504 | [ ${TARGET_BINARY_INTERFACE}x = x ] 505 | then 506 | echo m88k-dg-dgux${UNAME_RELEASE} 507 | else 508 | echo m88k-dg-dguxbcs${UNAME_RELEASE} 509 | fi 510 | else 511 | echo i586-dg-dgux${UNAME_RELEASE} 512 | fi 513 | exit ;; 514 | M88*:DolphinOS:*:*) # DolphinOS (SVR3) 515 | echo m88k-dolphin-sysv3 516 | exit ;; 517 | M88*:*:R3*:*) 518 | # Delta 88k system running SVR3 519 | echo m88k-motorola-sysv3 520 | exit ;; 521 | XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) 522 | echo m88k-tektronix-sysv3 523 | exit ;; 524 | Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) 525 | echo m68k-tektronix-bsd 526 | exit ;; 527 | *:IRIX*:*:*) 528 | echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` 529 | exit ;; 530 | ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. 531 | echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id 532 | exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' 533 | i*86:AIX:*:*) 534 | echo i386-ibm-aix 535 | exit ;; 536 | ia64:AIX:*:*) 537 | if [ -x /usr/bin/oslevel ] ; then 538 | IBM_REV=`/usr/bin/oslevel` 539 | else 540 | IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 541 | fi 542 | echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} 543 | exit ;; 544 | *:AIX:2:3) 545 | if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then 546 | eval $set_cc_for_build 547 | sed 's/^ //' << EOF >$dummy.c 548 | #include 549 | 550 | main() 551 | { 552 | if (!__power_pc()) 553 | exit(1); 554 | puts("powerpc-ibm-aix3.2.5"); 555 | exit(0); 556 | } 557 | EOF 558 | if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` 559 | then 560 | echo "$SYSTEM_NAME" 561 | else 562 | echo rs6000-ibm-aix3.2.5 563 | fi 564 | elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then 565 | echo rs6000-ibm-aix3.2.4 566 | else 567 | echo rs6000-ibm-aix3.2 568 | fi 569 | exit ;; 570 | *:AIX:*:[456]) 571 | IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 572 | if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then 573 | IBM_ARCH=rs6000 574 | else 575 | IBM_ARCH=powerpc 576 | fi 577 | if [ -x /usr/bin/oslevel ] ; then 578 | IBM_REV=`/usr/bin/oslevel` 579 | else 580 | IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 581 | fi 582 | echo ${IBM_ARCH}-ibm-aix${IBM_REV} 583 | exit ;; 584 | *:AIX:*:*) 585 | echo rs6000-ibm-aix 586 | exit ;; 587 | ibmrt:4.4BSD:*|romp-ibm:BSD:*) 588 | echo romp-ibm-bsd4.4 589 | exit ;; 590 | ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and 591 | echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to 592 | exit ;; # report: romp-ibm BSD 4.3 593 | *:BOSX:*:*) 594 | echo rs6000-bull-bosx 595 | exit ;; 596 | DPX/2?00:B.O.S.:*:*) 597 | echo m68k-bull-sysv3 598 | exit ;; 599 | 9000/[34]??:4.3bsd:1.*:*) 600 | echo m68k-hp-bsd 601 | exit ;; 602 | hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) 603 | echo m68k-hp-bsd4.4 604 | exit ;; 605 | 9000/[34678]??:HP-UX:*:*) 606 | HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 607 | case "${UNAME_MACHINE}" in 608 | 9000/31? ) HP_ARCH=m68000 ;; 609 | 9000/[34]?? ) HP_ARCH=m68k ;; 610 | 9000/[678][0-9][0-9]) 611 | if [ -x /usr/bin/getconf ]; then 612 | sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` 613 | sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 614 | case "${sc_cpu_version}" in 615 | 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 616 | 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 617 | 532) # CPU_PA_RISC2_0 618 | case "${sc_kernel_bits}" in 619 | 32) HP_ARCH="hppa2.0n" ;; 620 | 64) HP_ARCH="hppa2.0w" ;; 621 | '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 622 | esac ;; 623 | esac 624 | fi 625 | if [ "${HP_ARCH}" = "" ]; then 626 | eval $set_cc_for_build 627 | sed 's/^ //' << EOF >$dummy.c 628 | 629 | #define _HPUX_SOURCE 630 | #include 631 | #include 632 | 633 | int main () 634 | { 635 | #if defined(_SC_KERNEL_BITS) 636 | long bits = sysconf(_SC_KERNEL_BITS); 637 | #endif 638 | long cpu = sysconf (_SC_CPU_VERSION); 639 | 640 | switch (cpu) 641 | { 642 | case CPU_PA_RISC1_0: puts ("hppa1.0"); break; 643 | case CPU_PA_RISC1_1: puts ("hppa1.1"); break; 644 | case CPU_PA_RISC2_0: 645 | #if defined(_SC_KERNEL_BITS) 646 | switch (bits) 647 | { 648 | case 64: puts ("hppa2.0w"); break; 649 | case 32: puts ("hppa2.0n"); break; 650 | default: puts ("hppa2.0"); break; 651 | } break; 652 | #else /* !defined(_SC_KERNEL_BITS) */ 653 | puts ("hppa2.0"); break; 654 | #endif 655 | default: puts ("hppa1.0"); break; 656 | } 657 | exit (0); 658 | } 659 | EOF 660 | (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` 661 | test -z "$HP_ARCH" && HP_ARCH=hppa 662 | fi ;; 663 | esac 664 | if [ ${HP_ARCH} = "hppa2.0w" ] 665 | then 666 | eval $set_cc_for_build 667 | 668 | # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating 669 | # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler 670 | # generating 64-bit code. GNU and HP use different nomenclature: 671 | # 672 | # $ CC_FOR_BUILD=cc ./config.guess 673 | # => hppa2.0w-hp-hpux11.23 674 | # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess 675 | # => hppa64-hp-hpux11.23 676 | 677 | if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | 678 | grep -q __LP64__ 679 | then 680 | HP_ARCH="hppa2.0w" 681 | else 682 | HP_ARCH="hppa64" 683 | fi 684 | fi 685 | echo ${HP_ARCH}-hp-hpux${HPUX_REV} 686 | exit ;; 687 | ia64:HP-UX:*:*) 688 | HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 689 | echo ia64-hp-hpux${HPUX_REV} 690 | exit ;; 691 | 3050*:HI-UX:*:*) 692 | eval $set_cc_for_build 693 | sed 's/^ //' << EOF >$dummy.c 694 | #include 695 | int 696 | main () 697 | { 698 | long cpu = sysconf (_SC_CPU_VERSION); 699 | /* The order matters, because CPU_IS_HP_MC68K erroneously returns 700 | true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct 701 | results, however. */ 702 | if (CPU_IS_PA_RISC (cpu)) 703 | { 704 | switch (cpu) 705 | { 706 | case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; 707 | case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; 708 | case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; 709 | default: puts ("hppa-hitachi-hiuxwe2"); break; 710 | } 711 | } 712 | else if (CPU_IS_HP_MC68K (cpu)) 713 | puts ("m68k-hitachi-hiuxwe2"); 714 | else puts ("unknown-hitachi-hiuxwe2"); 715 | exit (0); 716 | } 717 | EOF 718 | $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && 719 | { echo "$SYSTEM_NAME"; exit; } 720 | echo unknown-hitachi-hiuxwe2 721 | exit ;; 722 | 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) 723 | echo hppa1.1-hp-bsd 724 | exit ;; 725 | 9000/8??:4.3bsd:*:*) 726 | echo hppa1.0-hp-bsd 727 | exit ;; 728 | *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) 729 | echo hppa1.0-hp-mpeix 730 | exit ;; 731 | hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) 732 | echo hppa1.1-hp-osf 733 | exit ;; 734 | hp8??:OSF1:*:*) 735 | echo hppa1.0-hp-osf 736 | exit ;; 737 | i*86:OSF1:*:*) 738 | if [ -x /usr/sbin/sysversion ] ; then 739 | echo ${UNAME_MACHINE}-unknown-osf1mk 740 | else 741 | echo ${UNAME_MACHINE}-unknown-osf1 742 | fi 743 | exit ;; 744 | parisc*:Lites*:*:*) 745 | echo hppa1.1-hp-lites 746 | exit ;; 747 | C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) 748 | echo c1-convex-bsd 749 | exit ;; 750 | C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) 751 | if getsysinfo -f scalar_acc 752 | then echo c32-convex-bsd 753 | else echo c2-convex-bsd 754 | fi 755 | exit ;; 756 | C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) 757 | echo c34-convex-bsd 758 | exit ;; 759 | C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) 760 | echo c38-convex-bsd 761 | exit ;; 762 | C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) 763 | echo c4-convex-bsd 764 | exit ;; 765 | CRAY*Y-MP:*:*:*) 766 | echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 767 | exit ;; 768 | CRAY*[A-Z]90:*:*:*) 769 | echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ 770 | | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ 771 | -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ 772 | -e 's/\.[^.]*$/.X/' 773 | exit ;; 774 | CRAY*TS:*:*:*) 775 | echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 776 | exit ;; 777 | CRAY*T3E:*:*:*) 778 | echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 779 | exit ;; 780 | CRAY*SV1:*:*:*) 781 | echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 782 | exit ;; 783 | *:UNICOS/mp:*:*) 784 | echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 785 | exit ;; 786 | F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) 787 | FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 788 | FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 789 | FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` 790 | echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 791 | exit ;; 792 | 5000:UNIX_System_V:4.*:*) 793 | FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 794 | FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` 795 | echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 796 | exit ;; 797 | i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) 798 | echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} 799 | exit ;; 800 | sparc*:BSD/OS:*:*) 801 | echo sparc-unknown-bsdi${UNAME_RELEASE} 802 | exit ;; 803 | *:BSD/OS:*:*) 804 | echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} 805 | exit ;; 806 | *:FreeBSD:*:*) 807 | case ${UNAME_MACHINE} in 808 | pc98) 809 | echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 810 | amd64) 811 | echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 812 | *) 813 | echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 814 | esac 815 | exit ;; 816 | i*:CYGWIN*:*) 817 | echo ${UNAME_MACHINE}-pc-cygwin 818 | exit ;; 819 | *:MINGW*:*) 820 | echo ${UNAME_MACHINE}-pc-mingw32 821 | exit ;; 822 | i*:windows32*:*) 823 | # uname -m includes "-pc" on this system. 824 | echo ${UNAME_MACHINE}-mingw32 825 | exit ;; 826 | i*:PW*:*) 827 | echo ${UNAME_MACHINE}-pc-pw32 828 | exit ;; 829 | *:Interix*:[3456]*) 830 | case ${UNAME_MACHINE} in 831 | x86) 832 | echo i586-pc-interix${UNAME_RELEASE} 833 | exit ;; 834 | EM64T | authenticamd | genuineintel) 835 | echo x86_64-unknown-interix${UNAME_RELEASE} 836 | exit ;; 837 | IA64) 838 | echo ia64-unknown-interix${UNAME_RELEASE} 839 | exit ;; 840 | esac ;; 841 | [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) 842 | echo i${UNAME_MACHINE}-pc-mks 843 | exit ;; 844 | 8664:Windows_NT:*) 845 | echo x86_64-pc-mks 846 | exit ;; 847 | i*:Windows_NT*:* | Pentium*:Windows_NT*:*) 848 | # How do we know it's Interix rather than the generic POSIX subsystem? 849 | # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we 850 | # UNAME_MACHINE based on the output of uname instead of i386? 851 | echo i586-pc-interix 852 | exit ;; 853 | i*:UWIN*:*) 854 | echo ${UNAME_MACHINE}-pc-uwin 855 | exit ;; 856 | amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) 857 | echo x86_64-unknown-cygwin 858 | exit ;; 859 | p*:CYGWIN*:*) 860 | echo powerpcle-unknown-cygwin 861 | exit ;; 862 | prep*:SunOS:5.*:*) 863 | echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 864 | exit ;; 865 | *:GNU:*:*) 866 | # the GNU system 867 | echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` 868 | exit ;; 869 | *:GNU/*:*:*) 870 | # other systems with GNU libc and userland 871 | echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} 872 | exit ;; 873 | i*86:Minix:*:*) 874 | echo ${UNAME_MACHINE}-pc-minix 875 | exit ;; 876 | arm*:Linux:*:*) 877 | eval $set_cc_for_build 878 | if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ 879 | | grep -q __ARM_EABI__ 880 | then 881 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 882 | else 883 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi 884 | fi 885 | exit ;; 886 | avr32*:Linux:*:*) 887 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 888 | exit ;; 889 | cris:Linux:*:*) 890 | echo cris-axis-linux-${LIBC} 891 | exit ;; 892 | crisv32:Linux:*:*) 893 | echo crisv32-axis-linux-${LIBC} 894 | exit ;; 895 | frv:Linux:*:*) 896 | echo frv-unknown-linux-${LIBC} 897 | exit ;; 898 | ia64:Linux:*:*) 899 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 900 | exit ;; 901 | m32r*:Linux:*:*) 902 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 903 | exit ;; 904 | m68*:Linux:*:*) 905 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 906 | exit ;; 907 | mips:Linux:*:* | mips64:Linux:*:*) 908 | eval $set_cc_for_build 909 | sed 's/^ //' << EOF >$dummy.c 910 | #undef CPU 911 | #undef ${UNAME_MACHINE} 912 | #undef ${UNAME_MACHINE}el 913 | #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) 914 | CPU=${UNAME_MACHINE}el 915 | #else 916 | #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) 917 | CPU=${UNAME_MACHINE} 918 | #else 919 | CPU= 920 | #endif 921 | #endif 922 | EOF 923 | eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' 924 | /^CPU/{ 925 | s: ::g 926 | p 927 | }'`" 928 | test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } 929 | ;; 930 | or32:Linux:*:*) 931 | echo or32-unknown-linux-${LIBC} 932 | exit ;; 933 | ppc:Linux:*:*) 934 | echo powerpc-unknown-linux-${LIBC} 935 | exit ;; 936 | ppc64:Linux:*:*) 937 | echo powerpc64-unknown-linux-${LIBC} 938 | exit ;; 939 | alpha:Linux:*:*) 940 | case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in 941 | EV5) UNAME_MACHINE=alphaev5 ;; 942 | EV56) UNAME_MACHINE=alphaev56 ;; 943 | PCA56) UNAME_MACHINE=alphapca56 ;; 944 | PCA57) UNAME_MACHINE=alphapca56 ;; 945 | EV6) UNAME_MACHINE=alphaev6 ;; 946 | EV67) UNAME_MACHINE=alphaev67 ;; 947 | EV68*) UNAME_MACHINE=alphaev68 ;; 948 | esac 949 | objdump --private-headers /bin/sh | grep -q ld.so.1 950 | if test "$?" = 0 ; then LIBC="gnulibc1" ; fi 951 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 952 | exit ;; 953 | padre:Linux:*:*) 954 | echo sparc-unknown-linux-${LIBC} 955 | exit ;; 956 | parisc:Linux:*:* | hppa:Linux:*:*) 957 | # Look for CPU level 958 | case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in 959 | PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; 960 | PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; 961 | *) echo hppa-unknown-linux-${LIBC} ;; 962 | esac 963 | exit ;; 964 | parisc64:Linux:*:* | hppa64:Linux:*:*) 965 | echo hppa64-unknown-linux-${LIBC} 966 | exit ;; 967 | s390:Linux:*:* | s390x:Linux:*:*) 968 | echo ${UNAME_MACHINE}-ibm-linux 969 | exit ;; 970 | sh64*:Linux:*:*) 971 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 972 | exit ;; 973 | sh*:Linux:*:*) 974 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 975 | exit ;; 976 | sparc:Linux:*:* | sparc64:Linux:*:*) 977 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 978 | exit ;; 979 | vax:Linux:*:*) 980 | echo ${UNAME_MACHINE}-dec-linux-${LIBC} 981 | exit ;; 982 | x86_64:Linux:*:*) 983 | echo x86_64-unknown-linux-${LIBC} 984 | exit ;; 985 | xtensa*:Linux:*:*) 986 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 987 | exit ;; 988 | i*86:Linux:*:*) 989 | # The BFD linker knows what the default object file format is, so 990 | # first see if it will tell us. cd to the root directory to prevent 991 | # problems with other programs or directories called `ld' in the path. 992 | # Set LC_ALL=C to ensure ld outputs messages in English. 993 | ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ 994 | | sed -ne '/supported targets:/!d 995 | s/[ ][ ]*/ /g 996 | s/.*supported targets: *// 997 | s/ .*// 998 | p'` 999 | case "$ld_supported_targets" in 1000 | elf32-i386) 1001 | TENTATIVE="${UNAME_MACHINE}-pc-linux-${LIBC}" 1002 | ;; 1003 | esac 1004 | # This should get integrated into the C code below, but now we hack 1005 | if [ "$LIBC" != "gnu" ] ; then echo "$TENTATIVE" && exit 0 ; fi 1006 | # Determine whether the default compiler is a.out or elf 1007 | eval $set_cc_for_build 1008 | sed 's/^ //' << EOF >$dummy.c 1009 | #include 1010 | #ifdef __ELF__ 1011 | # ifdef __GLIBC__ 1012 | # if __GLIBC__ >= 2 1013 | LIBC=gnu 1014 | # else 1015 | LIBC=gnulibc1 1016 | # endif 1017 | # else 1018 | LIBC=gnulibc1 1019 | # endif 1020 | #else 1021 | #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) 1022 | LIBC=gnu 1023 | #else 1024 | LIBC=gnuaout 1025 | #endif 1026 | #endif 1027 | #ifdef __dietlibc__ 1028 | LIBC=dietlibc 1029 | #endif 1030 | EOF 1031 | eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' 1032 | /^LIBC/{ 1033 | s: ::g 1034 | p 1035 | }'`" 1036 | test x"${LIBC}" != x && { 1037 | echo "${UNAME_MACHINE}-pc-linux-${LIBC}" 1038 | exit 1039 | } 1040 | test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } 1041 | ;; 1042 | i*86:DYNIX/ptx:4*:*) 1043 | # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. 1044 | # earlier versions are messed up and put the nodename in both 1045 | # sysname and nodename. 1046 | echo i386-sequent-sysv4 1047 | exit ;; 1048 | i*86:UNIX_SV:4.2MP:2.*) 1049 | # Unixware is an offshoot of SVR4, but it has its own version 1050 | # number series starting with 2... 1051 | # I am not positive that other SVR4 systems won't match this, 1052 | # I just have to hope. -- rms. 1053 | # Use sysv4.2uw... so that sysv4* matches it. 1054 | echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} 1055 | exit ;; 1056 | i*86:OS/2:*:*) 1057 | # If we were able to find `uname', then EMX Unix compatibility 1058 | # is probably installed. 1059 | echo ${UNAME_MACHINE}-pc-os2-emx 1060 | exit ;; 1061 | i*86:XTS-300:*:STOP) 1062 | echo ${UNAME_MACHINE}-unknown-stop 1063 | exit ;; 1064 | i*86:atheos:*:*) 1065 | echo ${UNAME_MACHINE}-unknown-atheos 1066 | exit ;; 1067 | i*86:syllable:*:*) 1068 | echo ${UNAME_MACHINE}-pc-syllable 1069 | exit ;; 1070 | i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) 1071 | echo i386-unknown-lynxos${UNAME_RELEASE} 1072 | exit ;; 1073 | i*86:*DOS:*:*) 1074 | echo ${UNAME_MACHINE}-pc-msdosdjgpp 1075 | exit ;; 1076 | i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) 1077 | UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` 1078 | if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then 1079 | echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} 1080 | else 1081 | echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} 1082 | fi 1083 | exit ;; 1084 | i*86:*:5:[678]*) 1085 | # UnixWare 7.x, OpenUNIX and OpenServer 6. 1086 | case `/bin/uname -X | grep "^Machine"` in 1087 | *486*) UNAME_MACHINE=i486 ;; 1088 | *Pentium) UNAME_MACHINE=i586 ;; 1089 | *Pent*|*Celeron) UNAME_MACHINE=i686 ;; 1090 | esac 1091 | echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} 1092 | exit ;; 1093 | i*86:*:3.2:*) 1094 | if test -f /usr/options/cb.name; then 1095 | UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then 1098 | UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` 1099 | (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 1100 | (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ 1101 | && UNAME_MACHINE=i586 1102 | (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ 1103 | && UNAME_MACHINE=i686 1104 | (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ 1105 | && UNAME_MACHINE=i686 1106 | echo ${UNAME_MACHINE}-pc-sco$UNAME_REL 1107 | else 1108 | echo ${UNAME_MACHINE}-pc-sysv32 1109 | fi 1110 | exit ;; 1111 | pc:*:*:*) 1112 | # Left here for compatibility: 1113 | # uname -m prints for DJGPP always 'pc', but it prints nothing about 1114 | # the processor, so we play safe by assuming i586. 1115 | # Note: whatever this is, it MUST be the same as what config.sub 1116 | # prints for the "djgpp" host, or else GDB configury will decide that 1117 | # this is a cross-build. 1118 | echo i586-pc-msdosdjgpp 1119 | exit ;; 1120 | Intel:Mach:3*:*) 1121 | echo i386-pc-mach3 1122 | exit ;; 1123 | paragon:*:*:*) 1124 | echo i860-intel-osf1 1125 | exit ;; 1126 | i860:*:4.*:*) # i860-SVR4 1127 | if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then 1128 | echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 1129 | else # Add other i860-SVR4 vendors below as they are discovered. 1130 | echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 1131 | fi 1132 | exit ;; 1133 | mini*:CTIX:SYS*5:*) 1134 | # "miniframe" 1135 | echo m68010-convergent-sysv 1136 | exit ;; 1137 | mc68k:UNIX:SYSTEM5:3.51m) 1138 | echo m68k-convergent-sysv 1139 | exit ;; 1140 | M680?0:D-NIX:5.3:*) 1141 | echo m68k-diab-dnix 1142 | exit ;; 1143 | M68*:*:R3V[5678]*:*) 1144 | test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 1145 | 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) 1146 | OS_REL='' 1147 | test -r /etc/.relid \ 1148 | && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1149 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1150 | && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1151 | /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1152 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1153 | 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 1154 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1155 | && { echo i486-ncr-sysv4; exit; } ;; 1156 | NCR*:*:4.2:* | MPRAS*:*:4.2:*) 1157 | OS_REL='.3' 1158 | test -r /etc/.relid \ 1159 | && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1160 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1161 | && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1162 | /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1163 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } 1164 | /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ 1165 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1166 | m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) 1167 | echo m68k-unknown-lynxos${UNAME_RELEASE} 1168 | exit ;; 1169 | mc68030:UNIX_System_V:4.*:*) 1170 | echo m68k-atari-sysv4 1171 | exit ;; 1172 | TSUNAMI:LynxOS:2.*:*) 1173 | echo sparc-unknown-lynxos${UNAME_RELEASE} 1174 | exit ;; 1175 | rs6000:LynxOS:2.*:*) 1176 | echo rs6000-unknown-lynxos${UNAME_RELEASE} 1177 | exit ;; 1178 | PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) 1179 | echo powerpc-unknown-lynxos${UNAME_RELEASE} 1180 | exit ;; 1181 | SM[BE]S:UNIX_SV:*:*) 1182 | echo mips-dde-sysv${UNAME_RELEASE} 1183 | exit ;; 1184 | RM*:ReliantUNIX-*:*:*) 1185 | echo mips-sni-sysv4 1186 | exit ;; 1187 | RM*:SINIX-*:*:*) 1188 | echo mips-sni-sysv4 1189 | exit ;; 1190 | *:SINIX-*:*:*) 1191 | if uname -p 2>/dev/null >/dev/null ; then 1192 | UNAME_MACHINE=`(uname -p) 2>/dev/null` 1193 | echo ${UNAME_MACHINE}-sni-sysv4 1194 | else 1195 | echo ns32k-sni-sysv 1196 | fi 1197 | exit ;; 1198 | PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort 1199 | # says 1200 | echo i586-unisys-sysv4 1201 | exit ;; 1202 | *:UNIX_System_V:4*:FTX*) 1203 | # From Gerald Hewes . 1204 | # How about differentiating between stratus architectures? -djm 1205 | echo hppa1.1-stratus-sysv4 1206 | exit ;; 1207 | *:*:*:FTX*) 1208 | # From seanf@swdc.stratus.com. 1209 | echo i860-stratus-sysv4 1210 | exit ;; 1211 | i*86:VOS:*:*) 1212 | # From Paul.Green@stratus.com. 1213 | echo ${UNAME_MACHINE}-stratus-vos 1214 | exit ;; 1215 | *:VOS:*:*) 1216 | # From Paul.Green@stratus.com. 1217 | echo hppa1.1-stratus-vos 1218 | exit ;; 1219 | mc68*:A/UX:*:*) 1220 | echo m68k-apple-aux${UNAME_RELEASE} 1221 | exit ;; 1222 | news*:NEWS-OS:6*:*) 1223 | echo mips-sony-newsos6 1224 | exit ;; 1225 | R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) 1226 | if [ -d /usr/nec ]; then 1227 | echo mips-nec-sysv${UNAME_RELEASE} 1228 | else 1229 | echo mips-unknown-sysv${UNAME_RELEASE} 1230 | fi 1231 | exit ;; 1232 | BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. 1233 | echo powerpc-be-beos 1234 | exit ;; 1235 | BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. 1236 | echo powerpc-apple-beos 1237 | exit ;; 1238 | BePC:BeOS:*:*) # BeOS running on Intel PC compatible. 1239 | echo i586-pc-beos 1240 | exit ;; 1241 | BePC:Haiku:*:*) # Haiku running on Intel PC compatible. 1242 | echo i586-pc-haiku 1243 | exit ;; 1244 | SX-4:SUPER-UX:*:*) 1245 | echo sx4-nec-superux${UNAME_RELEASE} 1246 | exit ;; 1247 | SX-5:SUPER-UX:*:*) 1248 | echo sx5-nec-superux${UNAME_RELEASE} 1249 | exit ;; 1250 | SX-6:SUPER-UX:*:*) 1251 | echo sx6-nec-superux${UNAME_RELEASE} 1252 | exit ;; 1253 | SX-7:SUPER-UX:*:*) 1254 | echo sx7-nec-superux${UNAME_RELEASE} 1255 | exit ;; 1256 | SX-8:SUPER-UX:*:*) 1257 | echo sx8-nec-superux${UNAME_RELEASE} 1258 | exit ;; 1259 | SX-8R:SUPER-UX:*:*) 1260 | echo sx8r-nec-superux${UNAME_RELEASE} 1261 | exit ;; 1262 | Power*:Rhapsody:*:*) 1263 | echo powerpc-apple-rhapsody${UNAME_RELEASE} 1264 | exit ;; 1265 | *:Rhapsody:*:*) 1266 | echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} 1267 | exit ;; 1268 | *:Darwin:*:*) 1269 | UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown 1270 | case $UNAME_PROCESSOR in 1271 | unknown) UNAME_PROCESSOR=powerpc ;; 1272 | esac 1273 | echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} 1274 | exit ;; 1275 | *:procnto*:*:* | *:QNX:[0123456789]*:*) 1276 | UNAME_PROCESSOR=`uname -p` 1277 | if test "$UNAME_PROCESSOR" = "x86"; then 1278 | UNAME_PROCESSOR=i386 1279 | UNAME_MACHINE=pc 1280 | fi 1281 | echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} 1282 | exit ;; 1283 | *:QNX:*:4*) 1284 | echo i386-pc-qnx 1285 | exit ;; 1286 | NSE-?:NONSTOP_KERNEL:*:*) 1287 | echo nse-tandem-nsk${UNAME_RELEASE} 1288 | exit ;; 1289 | NSR-?:NONSTOP_KERNEL:*:*) 1290 | echo nsr-tandem-nsk${UNAME_RELEASE} 1291 | exit ;; 1292 | *:NonStop-UX:*:*) 1293 | echo mips-compaq-nonstopux 1294 | exit ;; 1295 | BS2000:POSIX*:*:*) 1296 | echo bs2000-siemens-sysv 1297 | exit ;; 1298 | DS/*:UNIX_System_V:*:*) 1299 | echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} 1300 | exit ;; 1301 | *:Plan9:*:*) 1302 | # "uname -m" is not consistent, so use $cputype instead. 386 1303 | # is converted to i386 for consistency with other x86 1304 | # operating systems. 1305 | if test "$cputype" = "386"; then 1306 | UNAME_MACHINE=i386 1307 | else 1308 | UNAME_MACHINE="$cputype" 1309 | fi 1310 | echo ${UNAME_MACHINE}-unknown-plan9 1311 | exit ;; 1312 | *:TOPS-10:*:*) 1313 | echo pdp10-unknown-tops10 1314 | exit ;; 1315 | *:TENEX:*:*) 1316 | echo pdp10-unknown-tenex 1317 | exit ;; 1318 | KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) 1319 | echo pdp10-dec-tops20 1320 | exit ;; 1321 | XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) 1322 | echo pdp10-xkl-tops20 1323 | exit ;; 1324 | *:TOPS-20:*:*) 1325 | echo pdp10-unknown-tops20 1326 | exit ;; 1327 | *:ITS:*:*) 1328 | echo pdp10-unknown-its 1329 | exit ;; 1330 | SEI:*:*:SEIUX) 1331 | echo mips-sei-seiux${UNAME_RELEASE} 1332 | exit ;; 1333 | *:DragonFly:*:*) 1334 | echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` 1335 | exit ;; 1336 | *:*VMS:*:*) 1337 | UNAME_MACHINE=`(uname -p) 2>/dev/null` 1338 | case "${UNAME_MACHINE}" in 1339 | A*) echo alpha-dec-vms ; exit ;; 1340 | I*) echo ia64-dec-vms ; exit ;; 1341 | V*) echo vax-dec-vms ; exit ;; 1342 | esac ;; 1343 | *:XENIX:*:SysV) 1344 | echo i386-pc-xenix 1345 | exit ;; 1346 | i*86:skyos:*:*) 1347 | echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' 1348 | exit ;; 1349 | i*86:rdos:*:*) 1350 | echo ${UNAME_MACHINE}-pc-rdos 1351 | exit ;; 1352 | i*86:AROS:*:*) 1353 | echo ${UNAME_MACHINE}-pc-aros 1354 | exit ;; 1355 | esac 1356 | 1357 | #echo '(No uname command or uname output not recognized.)' 1>&2 1358 | #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 1359 | 1360 | eval $set_cc_for_build 1361 | cat >$dummy.c < 1364 | # include 1365 | #endif 1366 | main () 1367 | { 1368 | #if defined (sony) 1369 | #if defined (MIPSEB) 1370 | /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, 1371 | I don't know.... */ 1372 | printf ("mips-sony-bsd\n"); exit (0); 1373 | #else 1374 | #include 1375 | printf ("m68k-sony-newsos%s\n", 1376 | #ifdef NEWSOS4 1377 | "4" 1378 | #else 1379 | "" 1380 | #endif 1381 | ); exit (0); 1382 | #endif 1383 | #endif 1384 | 1385 | #if defined (__arm) && defined (__acorn) && defined (__unix) 1386 | printf ("arm-acorn-riscix\n"); exit (0); 1387 | #endif 1388 | 1389 | #if defined (hp300) && !defined (hpux) 1390 | printf ("m68k-hp-bsd\n"); exit (0); 1391 | #endif 1392 | 1393 | #if defined (NeXT) 1394 | #if !defined (__ARCHITECTURE__) 1395 | #define __ARCHITECTURE__ "m68k" 1396 | #endif 1397 | int version; 1398 | version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; 1399 | if (version < 4) 1400 | printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); 1401 | else 1402 | printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); 1403 | exit (0); 1404 | #endif 1405 | 1406 | #if defined (MULTIMAX) || defined (n16) 1407 | #if defined (UMAXV) 1408 | printf ("ns32k-encore-sysv\n"); exit (0); 1409 | #else 1410 | #if defined (CMU) 1411 | printf ("ns32k-encore-mach\n"); exit (0); 1412 | #else 1413 | printf ("ns32k-encore-bsd\n"); exit (0); 1414 | #endif 1415 | #endif 1416 | #endif 1417 | 1418 | #if defined (__386BSD__) 1419 | printf ("i386-pc-bsd\n"); exit (0); 1420 | #endif 1421 | 1422 | #if defined (sequent) 1423 | #if defined (i386) 1424 | printf ("i386-sequent-dynix\n"); exit (0); 1425 | #endif 1426 | #if defined (ns32000) 1427 | printf ("ns32k-sequent-dynix\n"); exit (0); 1428 | #endif 1429 | #endif 1430 | 1431 | #if defined (_SEQUENT_) 1432 | struct utsname un; 1433 | 1434 | uname(&un); 1435 | 1436 | if (strncmp(un.version, "V2", 2) == 0) { 1437 | printf ("i386-sequent-ptx2\n"); exit (0); 1438 | } 1439 | if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ 1440 | printf ("i386-sequent-ptx1\n"); exit (0); 1441 | } 1442 | printf ("i386-sequent-ptx\n"); exit (0); 1443 | 1444 | #endif 1445 | 1446 | #if defined (vax) 1447 | # if !defined (ultrix) 1448 | # include 1449 | # if defined (BSD) 1450 | # if BSD == 43 1451 | printf ("vax-dec-bsd4.3\n"); exit (0); 1452 | # else 1453 | # if BSD == 199006 1454 | printf ("vax-dec-bsd4.3reno\n"); exit (0); 1455 | # else 1456 | printf ("vax-dec-bsd\n"); exit (0); 1457 | # endif 1458 | # endif 1459 | # else 1460 | printf ("vax-dec-bsd\n"); exit (0); 1461 | # endif 1462 | # else 1463 | printf ("vax-dec-ultrix\n"); exit (0); 1464 | # endif 1465 | #endif 1466 | 1467 | #if defined (alliant) && defined (i860) 1468 | printf ("i860-alliant-bsd\n"); exit (0); 1469 | #endif 1470 | 1471 | exit (1); 1472 | } 1473 | EOF 1474 | 1475 | $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && 1476 | { echo "$SYSTEM_NAME"; exit; } 1477 | 1478 | # Apollos put the system type in the environment. 1479 | 1480 | test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } 1481 | 1482 | # Convex versions that predate uname can use getsysinfo(1) 1483 | 1484 | if [ -x /usr/convex/getsysinfo ] 1485 | then 1486 | case `getsysinfo -f cpu_type` in 1487 | c1*) 1488 | echo c1-convex-bsd 1489 | exit ;; 1490 | c2*) 1491 | if getsysinfo -f scalar_acc 1492 | then echo c32-convex-bsd 1493 | else echo c2-convex-bsd 1494 | fi 1495 | exit ;; 1496 | c34*) 1497 | echo c34-convex-bsd 1498 | exit ;; 1499 | c38*) 1500 | echo c38-convex-bsd 1501 | exit ;; 1502 | c4*) 1503 | echo c4-convex-bsd 1504 | exit ;; 1505 | esac 1506 | fi 1507 | 1508 | cat >&2 < in order to provide the needed 1522 | information to handle your system. 1523 | 1524 | config.guess timestamp = $timestamp 1525 | 1526 | uname -m = `(uname -m) 2>/dev/null || echo unknown` 1527 | uname -r = `(uname -r) 2>/dev/null || echo unknown` 1528 | uname -s = `(uname -s) 2>/dev/null || echo unknown` 1529 | uname -v = `(uname -v) 2>/dev/null || echo unknown` 1530 | 1531 | /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` 1532 | /bin/uname -X = `(/bin/uname -X) 2>/dev/null` 1533 | 1534 | hostinfo = `(hostinfo) 2>/dev/null` 1535 | /bin/universe = `(/bin/universe) 2>/dev/null` 1536 | /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` 1537 | /bin/arch = `(/bin/arch) 2>/dev/null` 1538 | /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` 1539 | /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` 1540 | 1541 | UNAME_MACHINE = ${UNAME_MACHINE} 1542 | UNAME_RELEASE = ${UNAME_RELEASE} 1543 | UNAME_SYSTEM = ${UNAME_SYSTEM} 1544 | UNAME_VERSION = ${UNAME_VERSION} 1545 | EOF 1546 | 1547 | exit 1 1548 | 1549 | # Local variables: 1550 | # eval: (add-hook 'write-file-hooks 'time-stamp) 1551 | # time-stamp-start: "timestamp='" 1552 | # time-stamp-format: "%:y-%02m-%02d" 1553 | # time-stamp-end: "'" 1554 | # End: 1555 | -------------------------------------------------------------------------------- /config.sub: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Configuration validation subroutine script. 3 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 | # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 5 | # Free Software Foundation, Inc. 6 | 7 | timestamp='2009-08-19' 8 | 9 | # This file is (in principle) common to ALL GNU software. 10 | # The presence of a machine in this file suggests that SOME GNU software 11 | # can handle that machine. It does not imply ALL GNU software can. 12 | # 13 | # This file is free software; you can redistribute it and/or modify 14 | # it under the terms of the GNU General Public License as published by 15 | # the Free Software Foundation; either version 2 of the License, or 16 | # (at your option) any later version. 17 | # 18 | # This program 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 21 | # GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with this program; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 26 | # 02110-1301, USA. 27 | # 28 | # As a special exception to the GNU General Public License, if you 29 | # distribute this file as part of a program that contains a 30 | # configuration script generated by Autoconf, you may include it under 31 | # the same distribution terms that you use for the rest of that program. 32 | 33 | 34 | # Please send patches to . Submit a context 35 | # diff and a properly formatted GNU ChangeLog entry. 36 | # 37 | # Configuration subroutine to validate and canonicalize a configuration type. 38 | # Supply the specified configuration type as an argument. 39 | # If it is invalid, we print an error message on stderr and exit with code 1. 40 | # Otherwise, we print the canonical config type on stdout and succeed. 41 | 42 | # You can get the latest version of this script from: 43 | # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD 44 | 45 | # This file is supposed to be the same for all GNU packages 46 | # and recognize all the CPU types, system types and aliases 47 | # that are meaningful with *any* GNU software. 48 | # Each package is responsible for reporting which valid configurations 49 | # it does not support. The user should be able to distinguish 50 | # a failure to support a valid configuration from a meaningless 51 | # configuration. 52 | 53 | # The goal of this file is to map all the various variations of a given 54 | # machine specification into a single specification in the form: 55 | # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 56 | # or in some cases, the newer four-part form: 57 | # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 58 | # It is wrong to echo any other type of specification. 59 | 60 | me=`echo "$0" | sed -e 's,.*/,,'` 61 | 62 | usage="\ 63 | Usage: $0 [OPTION] CPU-MFR-OPSYS 64 | $0 [OPTION] ALIAS 65 | 66 | Canonicalize a configuration name. 67 | 68 | Operation modes: 69 | -h, --help print this help, then exit 70 | -t, --time-stamp print date of last modification, then exit 71 | -v, --version print version number, then exit 72 | 73 | Report bugs and patches to ." 74 | 75 | version="\ 76 | GNU config.sub ($timestamp) 77 | 78 | Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 79 | 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 80 | 81 | This is free software; see the source for copying conditions. There is NO 82 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 83 | 84 | help=" 85 | Try \`$me --help' for more information." 86 | 87 | # Parse command line 88 | while test $# -gt 0 ; do 89 | case $1 in 90 | --time-stamp | --time* | -t ) 91 | echo "$timestamp" ; exit ;; 92 | --version | -v ) 93 | echo "$version" ; exit ;; 94 | --help | --h* | -h ) 95 | echo "$usage"; exit ;; 96 | -- ) # Stop option processing 97 | shift; break ;; 98 | - ) # Use stdin as input. 99 | break ;; 100 | -* ) 101 | echo "$me: invalid option $1$help" 102 | exit 1 ;; 103 | 104 | *local*) 105 | # First pass through any local machine types. 106 | echo $1 107 | exit ;; 108 | 109 | * ) 110 | break ;; 111 | esac 112 | done 113 | 114 | case $# in 115 | 0) echo "$me: missing argument$help" >&2 116 | exit 1;; 117 | 1) ;; 118 | *) echo "$me: too many arguments$help" >&2 119 | exit 1;; 120 | esac 121 | 122 | # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). 123 | # Here we must recognize all the valid KERNEL-OS combinations. 124 | maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` 125 | case $maybe_os in 126 | nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ 127 | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ 128 | kopensolaris*-gnu* | \ 129 | storm-chaos* | os2-emx* | rtmk-nova*) 130 | os=-$maybe_os 131 | basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` 132 | ;; 133 | *) 134 | basic_machine=`echo $1 | sed 's/-[^-]*$//'` 135 | if [ $basic_machine != $1 ] 136 | then os=`echo $1 | sed 's/.*-/-/'` 137 | else os=; fi 138 | ;; 139 | esac 140 | 141 | ### Let's recognize common machines as not being operating systems so 142 | ### that things like config.sub decstation-3100 work. We also 143 | ### recognize some manufacturers as not being operating systems, so we 144 | ### can provide default operating systems below. 145 | case $os in 146 | -sun*os*) 147 | # Prevent following clause from handling this invalid input. 148 | ;; 149 | -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ 150 | -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ 151 | -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ 152 | -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ 153 | -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ 154 | -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ 155 | -apple | -axis | -knuth | -cray | -microblaze) 156 | os= 157 | basic_machine=$1 158 | ;; 159 | -bluegene*) 160 | os=-cnk 161 | ;; 162 | -sim | -cisco | -oki | -wec | -winbond) 163 | os= 164 | basic_machine=$1 165 | ;; 166 | -scout) 167 | ;; 168 | -wrs) 169 | os=-vxworks 170 | basic_machine=$1 171 | ;; 172 | -chorusos*) 173 | os=-chorusos 174 | basic_machine=$1 175 | ;; 176 | -chorusrdb) 177 | os=-chorusrdb 178 | basic_machine=$1 179 | ;; 180 | -hiux*) 181 | os=-hiuxwe2 182 | ;; 183 | -sco6) 184 | os=-sco5v6 185 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 186 | ;; 187 | -sco5) 188 | os=-sco3.2v5 189 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 190 | ;; 191 | -sco4) 192 | os=-sco3.2v4 193 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 194 | ;; 195 | -sco3.2.[4-9]*) 196 | os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` 197 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 198 | ;; 199 | -sco3.2v[4-9]*) 200 | # Don't forget version if it is 3.2v4 or newer. 201 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 202 | ;; 203 | -sco5v6*) 204 | # Don't forget version if it is 3.2v4 or newer. 205 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 206 | ;; 207 | -sco*) 208 | os=-sco3.2v2 209 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 210 | ;; 211 | -udk*) 212 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 213 | ;; 214 | -isc) 215 | os=-isc2.2 216 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 217 | ;; 218 | -clix*) 219 | basic_machine=clipper-intergraph 220 | ;; 221 | -isc*) 222 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 223 | ;; 224 | -lynx*) 225 | os=-lynxos 226 | ;; 227 | -ptx*) 228 | basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` 229 | ;; 230 | -windowsnt*) 231 | os=`echo $os | sed -e 's/windowsnt/winnt/'` 232 | ;; 233 | -psos*) 234 | os=-psos 235 | ;; 236 | -mint | -mint[0-9]*) 237 | basic_machine=m68k-atari 238 | os=-mint 239 | ;; 240 | esac 241 | 242 | # Decode aliases for certain CPU-COMPANY combinations. 243 | case $basic_machine in 244 | # Recognize the basic CPU types without company name. 245 | # Some are omitted here because they have special meanings below. 246 | 1750a | 580 \ 247 | | a29k \ 248 | | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ 249 | | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ 250 | | am33_2.0 \ 251 | | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ 252 | | bfin \ 253 | | c4x | clipper \ 254 | | d10v | d30v | dlx | dsp16xx | dvp \ 255 | | fido | fr30 | frv \ 256 | | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ 257 | | i370 | i860 | i960 | ia64 \ 258 | | ip2k | iq2000 \ 259 | | lm32 \ 260 | | m32c | m32r | m32rle | m68000 | m68k | m88k \ 261 | | maxq | mb | microblaze | mcore | mep | metag \ 262 | | mips | mipsbe | mipseb | mipsel | mipsle \ 263 | | mips16 \ 264 | | mips64 | mips64el \ 265 | | mips64octeon | mips64octeonel \ 266 | | mips64orion | mips64orionel \ 267 | | mips64r5900 | mips64r5900el \ 268 | | mips64vr | mips64vrel \ 269 | | mips64vr4100 | mips64vr4100el \ 270 | | mips64vr4300 | mips64vr4300el \ 271 | | mips64vr5000 | mips64vr5000el \ 272 | | mips64vr5900 | mips64vr5900el \ 273 | | mipsisa32 | mipsisa32el \ 274 | | mipsisa32r2 | mipsisa32r2el \ 275 | | mipsisa64 | mipsisa64el \ 276 | | mipsisa64r2 | mipsisa64r2el \ 277 | | mipsisa64sb1 | mipsisa64sb1el \ 278 | | mipsisa64sr71k | mipsisa64sr71kel \ 279 | | mipstx39 | mipstx39el \ 280 | | mn10200 | mn10300 \ 281 | | moxie \ 282 | | mt \ 283 | | msp430 \ 284 | | nios | nios2 \ 285 | | ns16k | ns32k \ 286 | | or32 \ 287 | | pdp10 | pdp11 | pj | pjl \ 288 | | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ 289 | | pyramid \ 290 | | score \ 291 | | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ 292 | | sh64 | sh64le \ 293 | | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ 294 | | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ 295 | | spu | strongarm \ 296 | | tahoe | thumb | tic4x | tic80 | tron \ 297 | | v850 | v850e \ 298 | | we32k \ 299 | | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ 300 | | z8k | z80) 301 | basic_machine=$basic_machine-unknown 302 | ;; 303 | m6811 | m68hc11 | m6812 | m68hc12) 304 | # Motorola 68HC11/12. 305 | basic_machine=$basic_machine-unknown 306 | os=-none 307 | ;; 308 | m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) 309 | ;; 310 | ms1) 311 | basic_machine=mt-unknown 312 | ;; 313 | 314 | # We use `pc' rather than `unknown' 315 | # because (1) that's what they normally are, and 316 | # (2) the word "unknown" tends to confuse beginning users. 317 | i*86 | x86_64) 318 | basic_machine=$basic_machine-pc 319 | ;; 320 | # Object if more than one company name word. 321 | *-*-*) 322 | echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 323 | exit 1 324 | ;; 325 | # Recognize the basic CPU types with company name. 326 | 580-* \ 327 | | a29k-* \ 328 | | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ 329 | | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ 330 | | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ 331 | | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ 332 | | avr-* | avr32-* \ 333 | | bfin-* | bs2000-* \ 334 | | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ 335 | | clipper-* | craynv-* | cydra-* \ 336 | | d10v-* | d30v-* | dlx-* \ 337 | | elxsi-* \ 338 | | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ 339 | | h8300-* | h8500-* \ 340 | | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ 341 | | i*86-* | i860-* | i960-* | ia64-* \ 342 | | ip2k-* | iq2000-* \ 343 | | lm32-* \ 344 | | m32c-* | m32r-* | m32rle-* \ 345 | | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ 346 | | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ 347 | | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ 348 | | mips16-* \ 349 | | mips64-* | mips64el-* \ 350 | | mips64octeon-* | mips64octeonel-* \ 351 | | mips64orion-* | mips64orionel-* \ 352 | | mips64r5900-* | mips64r5900el-* \ 353 | | mips64vr-* | mips64vrel-* \ 354 | | mips64vr4100-* | mips64vr4100el-* \ 355 | | mips64vr4300-* | mips64vr4300el-* \ 356 | | mips64vr5000-* | mips64vr5000el-* \ 357 | | mips64vr5900-* | mips64vr5900el-* \ 358 | | mipsisa32-* | mipsisa32el-* \ 359 | | mipsisa32r2-* | mipsisa32r2el-* \ 360 | | mipsisa64-* | mipsisa64el-* \ 361 | | mipsisa64r2-* | mipsisa64r2el-* \ 362 | | mipsisa64sb1-* | mipsisa64sb1el-* \ 363 | | mipsisa64sr71k-* | mipsisa64sr71kel-* \ 364 | | mipstx39-* | mipstx39el-* \ 365 | | mmix-* \ 366 | | mt-* \ 367 | | msp430-* \ 368 | | nios-* | nios2-* \ 369 | | none-* | np1-* | ns16k-* | ns32k-* \ 370 | | orion-* \ 371 | | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ 372 | | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ 373 | | pyramid-* \ 374 | | romp-* | rs6000-* \ 375 | | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ 376 | | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ 377 | | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ 378 | | sparclite-* \ 379 | | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ 380 | | tahoe-* | thumb-* \ 381 | | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ 382 | | tron-* \ 383 | | v850-* | v850e-* | vax-* \ 384 | | we32k-* \ 385 | | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ 386 | | xstormy16-* | xtensa*-* \ 387 | | ymp-* \ 388 | | z8k-* | z80-*) 389 | ;; 390 | # Recognize the basic CPU types without company name, with glob match. 391 | xtensa*) 392 | basic_machine=$basic_machine-unknown 393 | ;; 394 | # Recognize the various machine names and aliases which stand 395 | # for a CPU type and a company and sometimes even an OS. 396 | 386bsd) 397 | basic_machine=i386-unknown 398 | os=-bsd 399 | ;; 400 | 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) 401 | basic_machine=m68000-att 402 | ;; 403 | 3b*) 404 | basic_machine=we32k-att 405 | ;; 406 | a29khif) 407 | basic_machine=a29k-amd 408 | os=-udi 409 | ;; 410 | abacus) 411 | basic_machine=abacus-unknown 412 | ;; 413 | adobe68k) 414 | basic_machine=m68010-adobe 415 | os=-scout 416 | ;; 417 | alliant | fx80) 418 | basic_machine=fx80-alliant 419 | ;; 420 | altos | altos3068) 421 | basic_machine=m68k-altos 422 | ;; 423 | am29k) 424 | basic_machine=a29k-none 425 | os=-bsd 426 | ;; 427 | amd64) 428 | basic_machine=x86_64-pc 429 | ;; 430 | amd64-*) 431 | basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` 432 | ;; 433 | amdahl) 434 | basic_machine=580-amdahl 435 | os=-sysv 436 | ;; 437 | amiga | amiga-*) 438 | basic_machine=m68k-unknown 439 | ;; 440 | amigaos | amigados) 441 | basic_machine=m68k-unknown 442 | os=-amigaos 443 | ;; 444 | amigaunix | amix) 445 | basic_machine=m68k-unknown 446 | os=-sysv4 447 | ;; 448 | apollo68) 449 | basic_machine=m68k-apollo 450 | os=-sysv 451 | ;; 452 | apollo68bsd) 453 | basic_machine=m68k-apollo 454 | os=-bsd 455 | ;; 456 | aros) 457 | basic_machine=i386-pc 458 | os=-aros 459 | ;; 460 | aux) 461 | basic_machine=m68k-apple 462 | os=-aux 463 | ;; 464 | balance) 465 | basic_machine=ns32k-sequent 466 | os=-dynix 467 | ;; 468 | blackfin) 469 | basic_machine=bfin-unknown 470 | os=-linux 471 | ;; 472 | blackfin-*) 473 | basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` 474 | os=-linux 475 | ;; 476 | bluegene*) 477 | basic_machine=powerpc-ibm 478 | os=-cnk 479 | ;; 480 | c90) 481 | basic_machine=c90-cray 482 | os=-unicos 483 | ;; 484 | cegcc) 485 | basic_machine=arm-unknown 486 | os=-cegcc 487 | ;; 488 | convex-c1) 489 | basic_machine=c1-convex 490 | os=-bsd 491 | ;; 492 | convex-c2) 493 | basic_machine=c2-convex 494 | os=-bsd 495 | ;; 496 | convex-c32) 497 | basic_machine=c32-convex 498 | os=-bsd 499 | ;; 500 | convex-c34) 501 | basic_machine=c34-convex 502 | os=-bsd 503 | ;; 504 | convex-c38) 505 | basic_machine=c38-convex 506 | os=-bsd 507 | ;; 508 | cray | j90) 509 | basic_machine=j90-cray 510 | os=-unicos 511 | ;; 512 | craynv) 513 | basic_machine=craynv-cray 514 | os=-unicosmp 515 | ;; 516 | cr16) 517 | basic_machine=cr16-unknown 518 | os=-elf 519 | ;; 520 | crds | unos) 521 | basic_machine=m68k-crds 522 | ;; 523 | crisv32 | crisv32-* | etraxfs*) 524 | basic_machine=crisv32-axis 525 | ;; 526 | cris | cris-* | etrax*) 527 | basic_machine=cris-axis 528 | ;; 529 | crx) 530 | basic_machine=crx-unknown 531 | os=-elf 532 | ;; 533 | da30 | da30-*) 534 | basic_machine=m68k-da30 535 | ;; 536 | decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) 537 | basic_machine=mips-dec 538 | ;; 539 | decsystem10* | dec10*) 540 | basic_machine=pdp10-dec 541 | os=-tops10 542 | ;; 543 | decsystem20* | dec20*) 544 | basic_machine=pdp10-dec 545 | os=-tops20 546 | ;; 547 | delta | 3300 | motorola-3300 | motorola-delta \ 548 | | 3300-motorola | delta-motorola) 549 | basic_machine=m68k-motorola 550 | ;; 551 | delta88) 552 | basic_machine=m88k-motorola 553 | os=-sysv3 554 | ;; 555 | dicos) 556 | basic_machine=i686-pc 557 | os=-dicos 558 | ;; 559 | djgpp) 560 | basic_machine=i586-pc 561 | os=-msdosdjgpp 562 | ;; 563 | dpx20 | dpx20-*) 564 | basic_machine=rs6000-bull 565 | os=-bosx 566 | ;; 567 | dpx2* | dpx2*-bull) 568 | basic_machine=m68k-bull 569 | os=-sysv3 570 | ;; 571 | ebmon29k) 572 | basic_machine=a29k-amd 573 | os=-ebmon 574 | ;; 575 | elxsi) 576 | basic_machine=elxsi-elxsi 577 | os=-bsd 578 | ;; 579 | encore | umax | mmax) 580 | basic_machine=ns32k-encore 581 | ;; 582 | es1800 | OSE68k | ose68k | ose | OSE) 583 | basic_machine=m68k-ericsson 584 | os=-ose 585 | ;; 586 | fx2800) 587 | basic_machine=i860-alliant 588 | ;; 589 | genix) 590 | basic_machine=ns32k-ns 591 | ;; 592 | gmicro) 593 | basic_machine=tron-gmicro 594 | os=-sysv 595 | ;; 596 | go32) 597 | basic_machine=i386-pc 598 | os=-go32 599 | ;; 600 | h3050r* | hiux*) 601 | basic_machine=hppa1.1-hitachi 602 | os=-hiuxwe2 603 | ;; 604 | h8300hms) 605 | basic_machine=h8300-hitachi 606 | os=-hms 607 | ;; 608 | h8300xray) 609 | basic_machine=h8300-hitachi 610 | os=-xray 611 | ;; 612 | h8500hms) 613 | basic_machine=h8500-hitachi 614 | os=-hms 615 | ;; 616 | harris) 617 | basic_machine=m88k-harris 618 | os=-sysv3 619 | ;; 620 | hp300-*) 621 | basic_machine=m68k-hp 622 | ;; 623 | hp300bsd) 624 | basic_machine=m68k-hp 625 | os=-bsd 626 | ;; 627 | hp300hpux) 628 | basic_machine=m68k-hp 629 | os=-hpux 630 | ;; 631 | hp3k9[0-9][0-9] | hp9[0-9][0-9]) 632 | basic_machine=hppa1.0-hp 633 | ;; 634 | hp9k2[0-9][0-9] | hp9k31[0-9]) 635 | basic_machine=m68000-hp 636 | ;; 637 | hp9k3[2-9][0-9]) 638 | basic_machine=m68k-hp 639 | ;; 640 | hp9k6[0-9][0-9] | hp6[0-9][0-9]) 641 | basic_machine=hppa1.0-hp 642 | ;; 643 | hp9k7[0-79][0-9] | hp7[0-79][0-9]) 644 | basic_machine=hppa1.1-hp 645 | ;; 646 | hp9k78[0-9] | hp78[0-9]) 647 | # FIXME: really hppa2.0-hp 648 | basic_machine=hppa1.1-hp 649 | ;; 650 | hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) 651 | # FIXME: really hppa2.0-hp 652 | basic_machine=hppa1.1-hp 653 | ;; 654 | hp9k8[0-9][13679] | hp8[0-9][13679]) 655 | basic_machine=hppa1.1-hp 656 | ;; 657 | hp9k8[0-9][0-9] | hp8[0-9][0-9]) 658 | basic_machine=hppa1.0-hp 659 | ;; 660 | hppa-next) 661 | os=-nextstep3 662 | ;; 663 | hppaosf) 664 | basic_machine=hppa1.1-hp 665 | os=-osf 666 | ;; 667 | hppro) 668 | basic_machine=hppa1.1-hp 669 | os=-proelf 670 | ;; 671 | i370-ibm* | ibm*) 672 | basic_machine=i370-ibm 673 | ;; 674 | # I'm not sure what "Sysv32" means. Should this be sysv3.2? 675 | i*86v32) 676 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 677 | os=-sysv32 678 | ;; 679 | i*86v4*) 680 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 681 | os=-sysv4 682 | ;; 683 | i*86v) 684 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 685 | os=-sysv 686 | ;; 687 | i*86sol2) 688 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 689 | os=-solaris2 690 | ;; 691 | i386mach) 692 | basic_machine=i386-mach 693 | os=-mach 694 | ;; 695 | i386-vsta | vsta) 696 | basic_machine=i386-unknown 697 | os=-vsta 698 | ;; 699 | iris | iris4d) 700 | basic_machine=mips-sgi 701 | case $os in 702 | -irix*) 703 | ;; 704 | *) 705 | os=-irix4 706 | ;; 707 | esac 708 | ;; 709 | isi68 | isi) 710 | basic_machine=m68k-isi 711 | os=-sysv 712 | ;; 713 | m68knommu) 714 | basic_machine=m68k-unknown 715 | os=-linux 716 | ;; 717 | m68knommu-*) 718 | basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` 719 | os=-linux 720 | ;; 721 | m88k-omron*) 722 | basic_machine=m88k-omron 723 | ;; 724 | magnum | m3230) 725 | basic_machine=mips-mips 726 | os=-sysv 727 | ;; 728 | merlin) 729 | basic_machine=ns32k-utek 730 | os=-sysv 731 | ;; 732 | microblaze) 733 | basic_machine=microblaze-xilinx 734 | ;; 735 | mingw32) 736 | basic_machine=i386-pc 737 | os=-mingw32 738 | ;; 739 | mingw32ce) 740 | basic_machine=arm-unknown 741 | os=-mingw32ce 742 | ;; 743 | miniframe) 744 | basic_machine=m68000-convergent 745 | ;; 746 | *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) 747 | basic_machine=m68k-atari 748 | os=-mint 749 | ;; 750 | mipsEE* | ee | ps2) 751 | basic_machine=mips64r5900el-scei 752 | case $os in 753 | -linux*) 754 | ;; 755 | *) 756 | os=-elf 757 | ;; 758 | esac 759 | ;; 760 | iop) 761 | basic_machine=mipsel-scei 762 | os=-irx 763 | ;; 764 | dvp) 765 | basic_machine=dvp-scei 766 | os=-elf 767 | ;; 768 | mips3*-*) 769 | basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` 770 | ;; 771 | mips3*) 772 | basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown 773 | ;; 774 | monitor) 775 | basic_machine=m68k-rom68k 776 | os=-coff 777 | ;; 778 | morphos) 779 | basic_machine=powerpc-unknown 780 | os=-morphos 781 | ;; 782 | msdos) 783 | basic_machine=i386-pc 784 | os=-msdos 785 | ;; 786 | ms1-*) 787 | basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` 788 | ;; 789 | mvs) 790 | basic_machine=i370-ibm 791 | os=-mvs 792 | ;; 793 | ncr3000) 794 | basic_machine=i486-ncr 795 | os=-sysv4 796 | ;; 797 | netbsd386) 798 | basic_machine=i386-unknown 799 | os=-netbsd 800 | ;; 801 | netwinder) 802 | basic_machine=armv4l-rebel 803 | os=-linux 804 | ;; 805 | news | news700 | news800 | news900) 806 | basic_machine=m68k-sony 807 | os=-newsos 808 | ;; 809 | news1000) 810 | basic_machine=m68030-sony 811 | os=-newsos 812 | ;; 813 | news-3600 | risc-news) 814 | basic_machine=mips-sony 815 | os=-newsos 816 | ;; 817 | necv70) 818 | basic_machine=v70-nec 819 | os=-sysv 820 | ;; 821 | next | m*-next ) 822 | basic_machine=m68k-next 823 | case $os in 824 | -nextstep* ) 825 | ;; 826 | -ns2*) 827 | os=-nextstep2 828 | ;; 829 | *) 830 | os=-nextstep3 831 | ;; 832 | esac 833 | ;; 834 | nh3000) 835 | basic_machine=m68k-harris 836 | os=-cxux 837 | ;; 838 | nh[45]000) 839 | basic_machine=m88k-harris 840 | os=-cxux 841 | ;; 842 | nindy960) 843 | basic_machine=i960-intel 844 | os=-nindy 845 | ;; 846 | mon960) 847 | basic_machine=i960-intel 848 | os=-mon960 849 | ;; 850 | nonstopux) 851 | basic_machine=mips-compaq 852 | os=-nonstopux 853 | ;; 854 | np1) 855 | basic_machine=np1-gould 856 | ;; 857 | nsr-tandem) 858 | basic_machine=nsr-tandem 859 | ;; 860 | op50n-* | op60c-*) 861 | basic_machine=hppa1.1-oki 862 | os=-proelf 863 | ;; 864 | openrisc | openrisc-*) 865 | basic_machine=or32-unknown 866 | ;; 867 | os400) 868 | basic_machine=powerpc-ibm 869 | os=-os400 870 | ;; 871 | OSE68000 | ose68000) 872 | basic_machine=m68000-ericsson 873 | os=-ose 874 | ;; 875 | os68k) 876 | basic_machine=m68k-none 877 | os=-os68k 878 | ;; 879 | pa-hitachi) 880 | basic_machine=hppa1.1-hitachi 881 | os=-hiuxwe2 882 | ;; 883 | paragon) 884 | basic_machine=i860-intel 885 | os=-osf 886 | ;; 887 | parisc) 888 | basic_machine=hppa-unknown 889 | os=-linux 890 | ;; 891 | parisc-*) 892 | basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` 893 | os=-linux 894 | ;; 895 | pbd) 896 | basic_machine=sparc-tti 897 | ;; 898 | pbb) 899 | basic_machine=m68k-tti 900 | ;; 901 | pc532 | pc532-*) 902 | basic_machine=ns32k-pc532 903 | ;; 904 | pc98) 905 | basic_machine=i386-pc 906 | ;; 907 | pc98-*) 908 | basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` 909 | ;; 910 | pentium | p5 | k5 | k6 | nexgen | viac3) 911 | basic_machine=i586-pc 912 | ;; 913 | pentiumpro | p6 | 6x86 | athlon | athlon_*) 914 | basic_machine=i686-pc 915 | ;; 916 | pentiumii | pentium2 | pentiumiii | pentium3) 917 | basic_machine=i686-pc 918 | ;; 919 | pentium4) 920 | basic_machine=i786-pc 921 | ;; 922 | pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) 923 | basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` 924 | ;; 925 | pentiumpro-* | p6-* | 6x86-* | athlon-*) 926 | basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 927 | ;; 928 | pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) 929 | basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 930 | ;; 931 | pentium4-*) 932 | basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` 933 | ;; 934 | pn) 935 | basic_machine=pn-gould 936 | ;; 937 | power) basic_machine=power-ibm 938 | ;; 939 | ppc) basic_machine=powerpc-unknown 940 | ;; 941 | ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` 942 | ;; 943 | ppcle | powerpclittle | ppc-le | powerpc-little) 944 | basic_machine=powerpcle-unknown 945 | ;; 946 | ppcle-* | powerpclittle-*) 947 | basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` 948 | ;; 949 | ppc64) basic_machine=powerpc64-unknown 950 | ;; 951 | ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` 952 | ;; 953 | ppc64le | powerpc64little | ppc64-le | powerpc64-little) 954 | basic_machine=powerpc64le-unknown 955 | ;; 956 | ppc64le-* | powerpc64little-*) 957 | basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` 958 | ;; 959 | ps2) 960 | basic_machine=i386-ibm 961 | ;; 962 | pw32) 963 | basic_machine=i586-unknown 964 | os=-pw32 965 | ;; 966 | rdos) 967 | basic_machine=i386-pc 968 | os=-rdos 969 | ;; 970 | rom68k) 971 | basic_machine=m68k-rom68k 972 | os=-coff 973 | ;; 974 | rm[46]00) 975 | basic_machine=mips-siemens 976 | ;; 977 | rtpc | rtpc-*) 978 | basic_machine=romp-ibm 979 | ;; 980 | s390 | s390-*) 981 | basic_machine=s390-ibm 982 | ;; 983 | s390x | s390x-*) 984 | basic_machine=s390x-ibm 985 | ;; 986 | sa29200) 987 | basic_machine=a29k-amd 988 | os=-udi 989 | ;; 990 | sb1) 991 | basic_machine=mipsisa64sb1-unknown 992 | ;; 993 | sb1el) 994 | basic_machine=mipsisa64sb1el-unknown 995 | ;; 996 | sde) 997 | basic_machine=mipsisa32-sde 998 | os=-elf 999 | ;; 1000 | sei) 1001 | basic_machine=mips-sei 1002 | os=-seiux 1003 | ;; 1004 | sequent) 1005 | basic_machine=i386-sequent 1006 | ;; 1007 | sh) 1008 | basic_machine=sh-hitachi 1009 | os=-hms 1010 | ;; 1011 | sh5el) 1012 | basic_machine=sh5le-unknown 1013 | ;; 1014 | sh64) 1015 | basic_machine=sh64-unknown 1016 | ;; 1017 | sparclite-wrs | simso-wrs) 1018 | basic_machine=sparclite-wrs 1019 | os=-vxworks 1020 | ;; 1021 | sps7) 1022 | basic_machine=m68k-bull 1023 | os=-sysv2 1024 | ;; 1025 | spur) 1026 | basic_machine=spur-unknown 1027 | ;; 1028 | st2000) 1029 | basic_machine=m68k-tandem 1030 | ;; 1031 | stratus) 1032 | basic_machine=i860-stratus 1033 | os=-sysv4 1034 | ;; 1035 | sun2) 1036 | basic_machine=m68000-sun 1037 | ;; 1038 | sun2os3) 1039 | basic_machine=m68000-sun 1040 | os=-sunos3 1041 | ;; 1042 | sun2os4) 1043 | basic_machine=m68000-sun 1044 | os=-sunos4 1045 | ;; 1046 | sun3os3) 1047 | basic_machine=m68k-sun 1048 | os=-sunos3 1049 | ;; 1050 | sun3os4) 1051 | basic_machine=m68k-sun 1052 | os=-sunos4 1053 | ;; 1054 | sun4os3) 1055 | basic_machine=sparc-sun 1056 | os=-sunos3 1057 | ;; 1058 | sun4os4) 1059 | basic_machine=sparc-sun 1060 | os=-sunos4 1061 | ;; 1062 | sun4sol2) 1063 | basic_machine=sparc-sun 1064 | os=-solaris2 1065 | ;; 1066 | sun3 | sun3-*) 1067 | basic_machine=m68k-sun 1068 | ;; 1069 | sun4) 1070 | basic_machine=sparc-sun 1071 | ;; 1072 | sun386 | sun386i | roadrunner) 1073 | basic_machine=i386-sun 1074 | ;; 1075 | sv1) 1076 | basic_machine=sv1-cray 1077 | os=-unicos 1078 | ;; 1079 | symmetry) 1080 | basic_machine=i386-sequent 1081 | os=-dynix 1082 | ;; 1083 | t3e) 1084 | basic_machine=alphaev5-cray 1085 | os=-unicos 1086 | ;; 1087 | t90) 1088 | basic_machine=t90-cray 1089 | os=-unicos 1090 | ;; 1091 | tic54x | c54x*) 1092 | basic_machine=tic54x-unknown 1093 | os=-coff 1094 | ;; 1095 | tic55x | c55x*) 1096 | basic_machine=tic55x-unknown 1097 | os=-coff 1098 | ;; 1099 | tic6x | c6x*) 1100 | basic_machine=tic6x-unknown 1101 | os=-coff 1102 | ;; 1103 | tile*) 1104 | basic_machine=tile-unknown 1105 | os=-linux-gnu 1106 | ;; 1107 | tx39) 1108 | basic_machine=mipstx39-unknown 1109 | ;; 1110 | tx39el) 1111 | basic_machine=mipstx39el-unknown 1112 | ;; 1113 | toad1) 1114 | basic_machine=pdp10-xkl 1115 | os=-tops20 1116 | ;; 1117 | tower | tower-32) 1118 | basic_machine=m68k-ncr 1119 | ;; 1120 | tpf) 1121 | basic_machine=s390x-ibm 1122 | os=-tpf 1123 | ;; 1124 | udi29k) 1125 | basic_machine=a29k-amd 1126 | os=-udi 1127 | ;; 1128 | ultra3) 1129 | basic_machine=a29k-nyu 1130 | os=-sym1 1131 | ;; 1132 | v810 | necv810) 1133 | basic_machine=v810-nec 1134 | os=-none 1135 | ;; 1136 | vaxv) 1137 | basic_machine=vax-dec 1138 | os=-sysv 1139 | ;; 1140 | vms) 1141 | basic_machine=vax-dec 1142 | os=-vms 1143 | ;; 1144 | vpp*|vx|vx-*) 1145 | basic_machine=f301-fujitsu 1146 | ;; 1147 | vxworks960) 1148 | basic_machine=i960-wrs 1149 | os=-vxworks 1150 | ;; 1151 | vxworks68) 1152 | basic_machine=m68k-wrs 1153 | os=-vxworks 1154 | ;; 1155 | vxworks29k) 1156 | basic_machine=a29k-wrs 1157 | os=-vxworks 1158 | ;; 1159 | w65*) 1160 | basic_machine=w65-wdc 1161 | os=-none 1162 | ;; 1163 | w89k-*) 1164 | basic_machine=hppa1.1-winbond 1165 | os=-proelf 1166 | ;; 1167 | xbox) 1168 | basic_machine=i686-pc 1169 | os=-mingw32 1170 | ;; 1171 | xps | xps100) 1172 | basic_machine=xps100-honeywell 1173 | ;; 1174 | ymp) 1175 | basic_machine=ymp-cray 1176 | os=-unicos 1177 | ;; 1178 | z8k-*-coff) 1179 | basic_machine=z8k-unknown 1180 | os=-sim 1181 | ;; 1182 | z80-*-coff) 1183 | basic_machine=z80-unknown 1184 | os=-sim 1185 | ;; 1186 | none) 1187 | basic_machine=none-none 1188 | os=-none 1189 | ;; 1190 | 1191 | # Here we handle the default manufacturer of certain CPU types. It is in 1192 | # some cases the only manufacturer, in others, it is the most popular. 1193 | w89k) 1194 | basic_machine=hppa1.1-winbond 1195 | ;; 1196 | op50n) 1197 | basic_machine=hppa1.1-oki 1198 | ;; 1199 | op60c) 1200 | basic_machine=hppa1.1-oki 1201 | ;; 1202 | romp) 1203 | basic_machine=romp-ibm 1204 | ;; 1205 | mmix) 1206 | basic_machine=mmix-knuth 1207 | ;; 1208 | rs6000) 1209 | basic_machine=rs6000-ibm 1210 | ;; 1211 | vax) 1212 | basic_machine=vax-dec 1213 | ;; 1214 | pdp10) 1215 | # there are many clones, so DEC is not a safe bet 1216 | basic_machine=pdp10-unknown 1217 | ;; 1218 | pdp11) 1219 | basic_machine=pdp11-dec 1220 | ;; 1221 | we32k) 1222 | basic_machine=we32k-att 1223 | ;; 1224 | sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) 1225 | basic_machine=sh-unknown 1226 | ;; 1227 | sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) 1228 | basic_machine=sparc-sun 1229 | ;; 1230 | cydra) 1231 | basic_machine=cydra-cydrome 1232 | ;; 1233 | orion) 1234 | basic_machine=orion-highlevel 1235 | ;; 1236 | orion105) 1237 | basic_machine=clipper-highlevel 1238 | ;; 1239 | mac | mpw | mac-mpw) 1240 | basic_machine=m68k-apple 1241 | ;; 1242 | pmac | pmac-mpw) 1243 | basic_machine=powerpc-apple 1244 | ;; 1245 | *-unknown) 1246 | # Make sure to match an already-canonicalized machine name. 1247 | ;; 1248 | *) 1249 | echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 1250 | exit 1 1251 | ;; 1252 | esac 1253 | 1254 | # Here we canonicalize certain aliases for manufacturers. 1255 | case $basic_machine in 1256 | *-digital*) 1257 | basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` 1258 | ;; 1259 | *-commodore*) 1260 | basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` 1261 | ;; 1262 | *) 1263 | ;; 1264 | esac 1265 | 1266 | # Decode manufacturer-specific aliases for certain operating systems. 1267 | 1268 | if [ x"$os" != x"" ] 1269 | then 1270 | case $os in 1271 | # First match some system type aliases 1272 | # that might get confused with valid system types. 1273 | # -solaris* is a basic system type, with this one exception. 1274 | -solaris1 | -solaris1.*) 1275 | os=`echo $os | sed -e 's|solaris1|sunos4|'` 1276 | ;; 1277 | -solaris) 1278 | os=-solaris2 1279 | ;; 1280 | -svr4*) 1281 | os=-sysv4 1282 | ;; 1283 | -unixware*) 1284 | os=-sysv4.2uw 1285 | ;; 1286 | -gnu/linux*) 1287 | os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` 1288 | ;; 1289 | # First accept the basic system types. 1290 | # The portable systems comes first. 1291 | # Each alternative MUST END IN A *, to match a version number. 1292 | # -sysv* is not here because it comes later, after sysvr4. 1293 | -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ 1294 | | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ 1295 | | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ 1296 | | -kopensolaris* \ 1297 | | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ 1298 | | -aos* | -aros* \ 1299 | | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ 1300 | | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ 1301 | | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ 1302 | | -openbsd* | -solidbsd* \ 1303 | | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ 1304 | | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ 1305 | | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ 1306 | | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ 1307 | | -chorusos* | -chorusrdb* | -cegcc* \ 1308 | | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ 1309 | | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ 1310 | | -uxpv* | -beos* | -mpeix* | -udk* \ 1311 | | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ 1312 | | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ 1313 | | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ 1314 | | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ 1315 | | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ 1316 | | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ 1317 | | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -irx*) 1318 | # Remember, each alternative MUST END IN *, to match a version number. 1319 | ;; 1320 | -qnx*) 1321 | case $basic_machine in 1322 | x86-* | i*86-*) 1323 | ;; 1324 | *) 1325 | os=-nto$os 1326 | ;; 1327 | esac 1328 | ;; 1329 | -nto-qnx*) 1330 | ;; 1331 | -nto*) 1332 | os=`echo $os | sed -e 's|nto|nto-qnx|'` 1333 | ;; 1334 | -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ 1335 | | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ 1336 | | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) 1337 | ;; 1338 | -mac*) 1339 | os=`echo $os | sed -e 's|mac|macos|'` 1340 | ;; 1341 | -linux-dietlibc) 1342 | os=-linux-dietlibc 1343 | ;; 1344 | -linux*) 1345 | os=`echo $os | sed -e 's|linux|linux-gnu|'` 1346 | ;; 1347 | -sunos5*) 1348 | os=`echo $os | sed -e 's|sunos5|solaris2|'` 1349 | ;; 1350 | -sunos6*) 1351 | os=`echo $os | sed -e 's|sunos6|solaris3|'` 1352 | ;; 1353 | -opened*) 1354 | os=-openedition 1355 | ;; 1356 | -os400*) 1357 | os=-os400 1358 | ;; 1359 | -wince*) 1360 | os=-wince 1361 | ;; 1362 | -osfrose*) 1363 | os=-osfrose 1364 | ;; 1365 | -osf*) 1366 | os=-osf 1367 | ;; 1368 | -utek*) 1369 | os=-bsd 1370 | ;; 1371 | -dynix*) 1372 | os=-bsd 1373 | ;; 1374 | -acis*) 1375 | os=-aos 1376 | ;; 1377 | -atheos*) 1378 | os=-atheos 1379 | ;; 1380 | -syllable*) 1381 | os=-syllable 1382 | ;; 1383 | -386bsd) 1384 | os=-bsd 1385 | ;; 1386 | -ctix* | -uts*) 1387 | os=-sysv 1388 | ;; 1389 | -nova*) 1390 | os=-rtmk-nova 1391 | ;; 1392 | -ns2 ) 1393 | os=-nextstep2 1394 | ;; 1395 | -nsk*) 1396 | os=-nsk 1397 | ;; 1398 | # Preserve the version number of sinix5. 1399 | -sinix5.*) 1400 | os=`echo $os | sed -e 's|sinix|sysv|'` 1401 | ;; 1402 | -sinix*) 1403 | os=-sysv4 1404 | ;; 1405 | -tpf*) 1406 | os=-tpf 1407 | ;; 1408 | -triton*) 1409 | os=-sysv3 1410 | ;; 1411 | -oss*) 1412 | os=-sysv3 1413 | ;; 1414 | -svr4) 1415 | os=-sysv4 1416 | ;; 1417 | -svr3) 1418 | os=-sysv3 1419 | ;; 1420 | -sysvr4) 1421 | os=-sysv4 1422 | ;; 1423 | # This must come after -sysvr4. 1424 | -sysv*) 1425 | ;; 1426 | -ose*) 1427 | os=-ose 1428 | ;; 1429 | -es1800*) 1430 | os=-ose 1431 | ;; 1432 | -xenix) 1433 | os=-xenix 1434 | ;; 1435 | -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1436 | os=-mint 1437 | ;; 1438 | -aros*) 1439 | os=-aros 1440 | ;; 1441 | -kaos*) 1442 | os=-kaos 1443 | ;; 1444 | -zvmoe) 1445 | os=-zvmoe 1446 | ;; 1447 | -dicos*) 1448 | os=-dicos 1449 | ;; 1450 | -none) 1451 | ;; 1452 | *) 1453 | # Get rid of the `-' at the beginning of $os. 1454 | os=`echo $os | sed 's/[^-]*-//'` 1455 | echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 1456 | exit 1 1457 | ;; 1458 | esac 1459 | else 1460 | 1461 | # Here we handle the default operating systems that come with various machines. 1462 | # The value should be what the vendor currently ships out the door with their 1463 | # machine or put another way, the most popular os provided with the machine. 1464 | 1465 | # Note that if you're going to try to match "-MANUFACTURER" here (say, 1466 | # "-sun"), then you have to tell the case statement up towards the top 1467 | # that MANUFACTURER isn't an operating system. Otherwise, code above 1468 | # will signal an error saying that MANUFACTURER isn't an operating 1469 | # system, and we'll never get to this point. 1470 | 1471 | case $basic_machine in 1472 | score-*) 1473 | os=-elf 1474 | ;; 1475 | spu-*) 1476 | os=-elf 1477 | ;; 1478 | *-acorn) 1479 | os=-riscix1.2 1480 | ;; 1481 | arm*-rebel) 1482 | os=-linux 1483 | ;; 1484 | arm*-semi) 1485 | os=-aout 1486 | ;; 1487 | c4x-* | tic4x-*) 1488 | os=-coff 1489 | ;; 1490 | # This must come before the *-dec entry. 1491 | pdp10-*) 1492 | os=-tops20 1493 | ;; 1494 | pdp11-*) 1495 | os=-none 1496 | ;; 1497 | *-dec | vax-*) 1498 | os=-ultrix4.2 1499 | ;; 1500 | m68*-apollo) 1501 | os=-domain 1502 | ;; 1503 | i386-sun) 1504 | os=-sunos4.0.2 1505 | ;; 1506 | m68000-sun) 1507 | os=-sunos3 1508 | # This also exists in the configure program, but was not the 1509 | # default. 1510 | # os=-sunos4 1511 | ;; 1512 | m68*-cisco) 1513 | os=-aout 1514 | ;; 1515 | mep-*) 1516 | os=-elf 1517 | ;; 1518 | mips*-cisco) 1519 | os=-elf 1520 | ;; 1521 | mips*-*) 1522 | os=-elf 1523 | ;; 1524 | or32-*) 1525 | os=-coff 1526 | ;; 1527 | *-tti) # must be before sparc entry or we get the wrong os. 1528 | os=-sysv3 1529 | ;; 1530 | sparc-* | *-sun) 1531 | os=-sunos4.1.1 1532 | ;; 1533 | *-be) 1534 | os=-beos 1535 | ;; 1536 | *-haiku) 1537 | os=-haiku 1538 | ;; 1539 | *-ibm) 1540 | os=-aix 1541 | ;; 1542 | *-knuth) 1543 | os=-mmixware 1544 | ;; 1545 | *-wec) 1546 | os=-proelf 1547 | ;; 1548 | *-winbond) 1549 | os=-proelf 1550 | ;; 1551 | *-oki) 1552 | os=-proelf 1553 | ;; 1554 | *-hp) 1555 | os=-hpux 1556 | ;; 1557 | *-hitachi) 1558 | os=-hiux 1559 | ;; 1560 | i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) 1561 | os=-sysv 1562 | ;; 1563 | *-cbm) 1564 | os=-amigaos 1565 | ;; 1566 | *-dg) 1567 | os=-dgux 1568 | ;; 1569 | *-dolphin) 1570 | os=-sysv3 1571 | ;; 1572 | m68k-ccur) 1573 | os=-rtu 1574 | ;; 1575 | m88k-omron*) 1576 | os=-luna 1577 | ;; 1578 | *-next ) 1579 | os=-nextstep 1580 | ;; 1581 | *-sequent) 1582 | os=-ptx 1583 | ;; 1584 | *-crds) 1585 | os=-unos 1586 | ;; 1587 | *-ns) 1588 | os=-genix 1589 | ;; 1590 | i370-*) 1591 | os=-mvs 1592 | ;; 1593 | *-next) 1594 | os=-nextstep3 1595 | ;; 1596 | *-gould) 1597 | os=-sysv 1598 | ;; 1599 | *-highlevel) 1600 | os=-bsd 1601 | ;; 1602 | *-encore) 1603 | os=-bsd 1604 | ;; 1605 | *-sgi) 1606 | os=-irix 1607 | ;; 1608 | *-siemens) 1609 | os=-sysv4 1610 | ;; 1611 | *-masscomp) 1612 | os=-rtu 1613 | ;; 1614 | f30[01]-fujitsu | f700-fujitsu) 1615 | os=-uxpv 1616 | ;; 1617 | *-rom68k) 1618 | os=-coff 1619 | ;; 1620 | *-*bug) 1621 | os=-coff 1622 | ;; 1623 | *-apple) 1624 | os=-macos 1625 | ;; 1626 | *-atari*) 1627 | os=-mint 1628 | ;; 1629 | *) 1630 | os=-none 1631 | ;; 1632 | esac 1633 | fi 1634 | 1635 | # Here we handle the case where we know the os, and the CPU type, but not the 1636 | # manufacturer. We pick the logical manufacturer. 1637 | vendor=unknown 1638 | case $basic_machine in 1639 | *-unknown) 1640 | case $os in 1641 | -riscix*) 1642 | vendor=acorn 1643 | ;; 1644 | -sunos*) 1645 | vendor=sun 1646 | ;; 1647 | -cnk*|-aix*) 1648 | vendor=ibm 1649 | ;; 1650 | -beos*) 1651 | vendor=be 1652 | ;; 1653 | -hpux*) 1654 | vendor=hp 1655 | ;; 1656 | -mpeix*) 1657 | vendor=hp 1658 | ;; 1659 | -hiux*) 1660 | vendor=hitachi 1661 | ;; 1662 | -unos*) 1663 | vendor=crds 1664 | ;; 1665 | -dgux*) 1666 | vendor=dg 1667 | ;; 1668 | -luna*) 1669 | vendor=omron 1670 | ;; 1671 | -genix*) 1672 | vendor=ns 1673 | ;; 1674 | -mvs* | -opened*) 1675 | vendor=ibm 1676 | ;; 1677 | -os400*) 1678 | vendor=ibm 1679 | ;; 1680 | -ptx*) 1681 | vendor=sequent 1682 | ;; 1683 | -tpf*) 1684 | vendor=ibm 1685 | ;; 1686 | -vxsim* | -vxworks* | -windiss*) 1687 | vendor=wrs 1688 | ;; 1689 | -aux*) 1690 | vendor=apple 1691 | ;; 1692 | -hms*) 1693 | vendor=hitachi 1694 | ;; 1695 | -mpw* | -macos*) 1696 | vendor=apple 1697 | ;; 1698 | -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1699 | vendor=atari 1700 | ;; 1701 | -vos*) 1702 | vendor=stratus 1703 | ;; 1704 | esac 1705 | basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` 1706 | ;; 1707 | esac 1708 | 1709 | echo $basic_machine$os 1710 | exit 1711 | 1712 | # Local variables: 1713 | # eval: (add-hook 'write-file-hooks 'time-stamp) 1714 | # time-stamp-start: "timestamp='" 1715 | # time-stamp-format: "%:y-%02m-%02d" 1716 | # time-stamp-end: "'" 1717 | # End: 1718 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl libresample configure.in script 3 | dnl 4 | dnl Dominic Mazzoni 5 | dnl 6 | 7 | dnl Require autoconf >= 2.13 8 | AC_PREREQ(2.13) 9 | 10 | dnl Init autoconf and make sure configure is being called 11 | dnl from the right directory 12 | AC_INIT([src/resample.c]) 13 | 14 | dnl Checks for programs. 15 | AC_PROG_CC 16 | AC_PROG_CPP 17 | AC_PROG_RANLIB 18 | 19 | AC_PATH_PROG(AR, ar, no) 20 | if [[ $AR = "no" ]] ; then 21 | AC_MSG_ERROR("Could not find ar - needed to create a library"); 22 | fi 23 | 24 | AC_SUBST(TARGETS) 25 | TARGETS="libresample.a tests/testresample" 26 | 27 | AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [enable tests using libsndfile and libsamplerate]), test_arg="yes", test_arg="no") 28 | 29 | if [[ x$test_arg = "xyes" ]] ; then 30 | AC_CHECK_LIB(sndfile, sf_open, have_libsndfile=yes, have_libsndfile=no) 31 | AC_CHECK_HEADER(sndfile.h, , have_libsndfile=no) 32 | 33 | if [[ $have_libsndfile = "yes" ]] ; then 34 | TARGETS="$TARGETS tests/resample-sndfile" 35 | fi 36 | 37 | AC_CHECK_LIB(samplerate, src_simple, have_libsamplerate=yes, have_libsamplerate=no) 38 | AC_CHECK_HEADER(samplerate.h, , have_libsamplerate=no) 39 | 40 | if [[ $have_libsamplerate = "yes" ]] ; then 41 | TARGETS="$TARGETS tests/compareresample" 42 | fi 43 | else 44 | have_libsamplerate="no" 45 | have_libsndfile="no" 46 | fi 47 | 48 | 49 | AC_CHECK_HEADERS(inttypes.h) 50 | 51 | AC_CONFIG_HEADER(src/config.h:src/configtemplate.h) 52 | AC_OUTPUT([Makefile]) 53 | 54 | echo "" 55 | 56 | if [[ $have_libsamplerate = "yes" ]] ; then 57 | echo "Configured to build tests/resample-sndfile using libsndfile" 58 | echo "" 59 | else if [[ x$test_arg = x"yes" ]] ; then 60 | echo "Could not find libsndfile - needed if you want to" 61 | echo "compile tests/resample-sndfile" 62 | echo "" 63 | fi 64 | fi 65 | 66 | if [[ $have_libsamplerate = "yes" ]] ; then 67 | echo "Configured to build tests/compareresample to compare against" 68 | echo "Erik de Castro Lopo's libsamplerate library." 69 | echo "" 70 | else if [[ x$test_arg = x"yes" ]] ; then 71 | echo "Could not find libsamplerate - only needed if you want to" 72 | echo "compile tests/compareresample to compare their performance." 73 | echo "" 74 | fi 75 | fi 76 | 77 | echo "Type 'configure --help' to see options." 78 | echo "" 79 | echo "Type 'make' to build libresample." 80 | -------------------------------------------------------------------------------- /include/libresample.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | resample.h 4 | 5 | Real-time library interface by Dominic Mazzoni 6 | 7 | Based on resample-1.7: 8 | http://www-ccrma.stanford.edu/~jos/resample/ 9 | 10 | Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. 11 | 12 | **********************************************************************/ 13 | 14 | #ifndef LIBRESAMPLE_INCLUDED 15 | #define LIBRESAMPLE_INCLUDED 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif /* __cplusplus */ 20 | 21 | void *resample_open(int highQuality, 22 | double minFactor, 23 | double maxFactor); 24 | 25 | void *resample_dup(const void *handle); 26 | 27 | int resample_get_filter_width(const void *handle); 28 | 29 | int resample_process(void *handle, 30 | double factor, 31 | float *inBuffer, 32 | int inBufferLen, 33 | int lastFlag, 34 | int *inBufferUsed, 35 | float *outBuffer, 36 | int outBufferLen); 37 | 38 | void resample_close(void *handle); 39 | 40 | #ifdef __cplusplus 41 | } /* extern "C" */ 42 | #endif /* __cplusplus */ 43 | 44 | #endif /* LIBRESAMPLE_INCLUDED */ 45 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd="$cpprog" 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd="$stripprog" 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "install: no input file specified" 110 | exit 1 111 | else 112 | true 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d $dst ]; then 120 | instcmd=: 121 | chmodcmd="" 122 | else 123 | instcmd=mkdir 124 | fi 125 | else 126 | 127 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128 | # might cause directories to be created, which would be especially bad 129 | # if $src (and thus $dsttmp) contains '*'. 130 | 131 | if [ -f $src -o -d $src ] 132 | then 133 | true 134 | else 135 | echo "install: $src does not exist" 136 | exit 1 137 | fi 138 | 139 | if [ x"$dst" = x ] 140 | then 141 | echo "install: no destination specified" 142 | exit 1 143 | else 144 | true 145 | fi 146 | 147 | # If destination is a directory, append the input filename; if your system 148 | # does not like double slashes in filenames, you may need to add some logic 149 | 150 | if [ -d $dst ] 151 | then 152 | dst="$dst"/`basename $src` 153 | else 154 | true 155 | fi 156 | fi 157 | 158 | ## this sed command emulates the dirname command 159 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160 | 161 | # Make sure that the destination directory exists. 162 | # this part is taken from Noah Friedman's mkinstalldirs script 163 | 164 | # Skip lots of stat calls in the usual case. 165 | if [ ! -d "$dstdir" ]; then 166 | defaultIFS=' 167 | ' 168 | IFS="${IFS-${defaultIFS}}" 169 | 170 | oIFS="${IFS}" 171 | # Some sh's can't handle IFS=/ for some reason. 172 | IFS='%' 173 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 174 | IFS="${oIFS}" 175 | 176 | pathcomp='' 177 | 178 | while [ $# -ne 0 ] ; do 179 | pathcomp="${pathcomp}${1}" 180 | shift 181 | 182 | if [ ! -d "${pathcomp}" ] ; 183 | then 184 | $mkdirprog "${pathcomp}" 185 | else 186 | true 187 | fi 188 | 189 | pathcomp="${pathcomp}/" 190 | done 191 | fi 192 | 193 | if [ x"$dir_arg" != x ] 194 | then 195 | $doit $instcmd $dst && 196 | 197 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 198 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 199 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 200 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 201 | else 202 | 203 | # If we're going to rename the final executable, determine the name now. 204 | 205 | if [ x"$transformarg" = x ] 206 | then 207 | dstfile=`basename $dst` 208 | else 209 | dstfile=`basename $dst $transformbasename | 210 | sed $transformarg`$transformbasename 211 | fi 212 | 213 | # don't allow the sed command to completely eliminate the filename 214 | 215 | if [ x"$dstfile" = x ] 216 | then 217 | dstfile=`basename $dst` 218 | else 219 | true 220 | fi 221 | 222 | # Make a temp file name in the proper directory. 223 | 224 | dsttmp=$dstdir/#inst.$$# 225 | 226 | # Move or copy the file name to the temp name 227 | 228 | $doit $instcmd $src $dsttmp && 229 | 230 | trap "rm -f ${dsttmp}" 0 && 231 | 232 | # and set any options; do chmod last to preserve setuid bits 233 | 234 | # If any of these fail, we abort the whole thing. If we want to 235 | # ignore errors from any of these, just make sure not to ignore 236 | # errors from the above "$doit $instcmd $src $dsttmp" command. 237 | 238 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 239 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 240 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 241 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 242 | 243 | # Now rename the file to the real destination. 244 | 245 | $doit $rmcmd -f $dstdir/$dstfile && 246 | $doit $mvcmd $dsttmp $dstdir/$dstfile 247 | 248 | fi && 249 | 250 | 251 | exit 0 252 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | 'libresample', 3 | 'c', 4 | meson_version : '>=1.3', 5 | default_options : 'default_library=both', 6 | version : '0.1.5', 7 | license : 'BSD-3-Clause OR LGPL-2.1-or-later', 8 | license_files : ['LICENSE-BSD.txt', 'LICENSE-LGPL.txt'], 9 | ) 10 | 11 | cc = meson.get_compiler('c') 12 | 13 | configure_file( 14 | output : 'config.h', 15 | configuration : { 16 | 'HAVE_INTTYPES_H': cc.has_header('inttypes.h').to_int(), 17 | }, 18 | ) 19 | config_inc = include_directories('.') 20 | 21 | libm_dep = cc.find_library('m', required : false) 22 | 23 | resample = library( 24 | 'resample', 25 | 'src/filterkit.c', 26 | 'src/resample.c', 27 | 'src/resamplesubs.c', 28 | dependencies : [libm_dep], 29 | include_directories : [config_inc], 30 | vs_module_defs : 'src/resample.def', 31 | version : meson.project_version(), 32 | soversion : 1, 33 | install : true, 34 | ) 35 | 36 | install_headers('include/libresample.h') 37 | 38 | pkg = import('pkgconfig') 39 | pkg.generate(resample, name : 'libresample') 40 | 41 | subdir('tests') 42 | -------------------------------------------------------------------------------- /meson.options: -------------------------------------------------------------------------------- 1 | option( 2 | 'resample-sndfile', 3 | type : 'feature', 4 | value : 'auto', 5 | description : 'Build and install the resample-sndfile tool (depends on libsndfile)', 6 | ) 7 | 8 | option( 9 | 'compareresample', 10 | type : 'feature', 11 | value : 'auto', 12 | description : 'Build and install the compareresample tool (depends on libsamplerate)', 13 | ) 14 | -------------------------------------------------------------------------------- /src/configtemplate.h: -------------------------------------------------------------------------------- 1 | /* Run configure to generate config.h automatically on any 2 | system supported by GNU autoconf. For all other systems, 3 | use this file as a template to create config.h 4 | */ 5 | 6 | #undef HAVE_INTTYPES_H 7 | 8 | -------------------------------------------------------------------------------- /src/filterkit.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | resamplesubs.c 4 | 5 | Real-time library interface by Dominic Mazzoni 6 | 7 | Based on resample-1.7: 8 | http://www-ccrma.stanford.edu/~jos/resample/ 9 | 10 | Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. 11 | 12 | This file provides Kaiser-windowed low-pass filter support, 13 | including a function to create the filter coefficients, and 14 | two functions to apply the filter at a particular point. 15 | 16 | **********************************************************************/ 17 | 18 | /* Definitions */ 19 | #include "resample_defs.h" 20 | 21 | #include "filterkit.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | /* LpFilter() 29 | * 30 | * reference: "Digital Filters, 2nd edition" 31 | * R.W. Hamming, pp. 178-179 32 | * 33 | * Izero() computes the 0th order modified bessel function of the first kind. 34 | * (Needed to compute Kaiser window). 35 | * 36 | * LpFilter() computes the coeffs of a Kaiser-windowed low pass filter with 37 | * the following characteristics: 38 | * 39 | * c[] = array in which to store computed coeffs 40 | * frq = roll-off frequency of filter 41 | * N = Half the window length in number of coeffs 42 | * Beta = parameter of Kaiser window 43 | * Num = number of coeffs before 1/frq 44 | * 45 | * Beta trades the rejection of the lowpass filter against the transition 46 | * width from passband to stopband. Larger Beta means a slower 47 | * transition and greater stopband rejection. See Rabiner and Gold 48 | * (Theory and Application of DSP) under Kaiser windows for more about 49 | * Beta. The following table from Rabiner and Gold gives some feel 50 | * for the effect of Beta: 51 | * 52 | * All ripples in dB, width of transition band = D*N where N = window length 53 | * 54 | * BETA D PB RIP SB RIP 55 | * 2.120 1.50 +-0.27 -30 56 | * 3.384 2.23 0.0864 -40 57 | * 4.538 2.93 0.0274 -50 58 | * 5.658 3.62 0.00868 -60 59 | * 6.764 4.32 0.00275 -70 60 | * 7.865 5.0 0.000868 -80 61 | * 8.960 5.7 0.000275 -90 62 | * 10.056 6.4 0.000087 -100 63 | */ 64 | 65 | #define IzeroEPSILON 1E-21 /* Max error acceptable in Izero */ 66 | 67 | static double Izero(double x) 68 | { 69 | double sum, u, halfx, temp; 70 | int n; 71 | 72 | sum = u = n = 1; 73 | halfx = x/2.0; 74 | do { 75 | temp = halfx/(double)n; 76 | n += 1; 77 | temp *= temp; 78 | u *= temp; 79 | sum += u; 80 | } while (u >= IzeroEPSILON*sum); 81 | return(sum); 82 | } 83 | 84 | void lrsLpFilter(double c[], int N, double frq, double Beta, int Num) 85 | { 86 | double IBeta, temp, temp1, inm1; 87 | int i; 88 | 89 | /* Calculate ideal lowpass filter impulse response coefficients: */ 90 | c[0] = 2.0*frq; 91 | for (i=1; i 26 | #include 27 | #include 28 | #include 29 | 30 | typedef struct { 31 | float *Imp; 32 | float *ImpD; 33 | float LpScl; 34 | UWORD Nmult; 35 | UWORD Nwing; 36 | double minFactor; 37 | double maxFactor; 38 | UWORD XSize; 39 | float *X; 40 | UWORD Xp; /* Current "now"-sample pointer for input */ 41 | UWORD Xread; /* Position to put new samples */ 42 | UWORD Xoff; 43 | UWORD YSize; 44 | float *Y; 45 | UWORD Yp; 46 | double Time; 47 | } rsdata; 48 | 49 | void *resample_dup(const void * handle) 50 | { 51 | const rsdata *cpy = (const rsdata *)handle; 52 | rsdata *hp = (rsdata *)malloc(sizeof(rsdata)); 53 | 54 | hp->minFactor = cpy->minFactor; 55 | hp->maxFactor = cpy->maxFactor; 56 | hp->Nmult = cpy->Nmult; 57 | hp->LpScl = cpy->LpScl; 58 | hp->Nwing = cpy->Nwing; 59 | 60 | hp->Imp = (float *)malloc(hp->Nwing * sizeof(float)); 61 | memcpy(hp->Imp, cpy->Imp, hp->Nwing * sizeof(float)); 62 | hp->ImpD = (float *)malloc(hp->Nwing * sizeof(float)); 63 | memcpy(hp->ImpD, cpy->ImpD, hp->Nwing * sizeof(float)); 64 | 65 | hp->Xoff = cpy->Xoff; 66 | hp->XSize = cpy->XSize; 67 | hp->X = (float *)malloc((hp->XSize + hp->Xoff) * sizeof(float)); 68 | memcpy(hp->X, cpy->X, (hp->XSize + hp->Xoff) * sizeof(float)); 69 | hp->Xp = cpy->Xp; 70 | hp->Xread = cpy->Xread; 71 | hp->YSize = cpy->YSize; 72 | hp->Y = (float *)malloc(hp->YSize * sizeof(float)); 73 | memcpy(hp->Y, cpy->Y, hp->YSize * sizeof(float)); 74 | hp->Yp = cpy->Yp; 75 | hp->Time = cpy->Time; 76 | 77 | return (void *)hp; 78 | } 79 | 80 | void *resample_open(int highQuality, double minFactor, double maxFactor) 81 | { 82 | double *Imp64; 83 | double Rolloff, Beta; 84 | rsdata *hp; 85 | UWORD Xoff_min, Xoff_max; 86 | int i; 87 | 88 | /* Just exit if we get invalid factors */ 89 | if (minFactor <= 0.0 || maxFactor <= 0.0 || maxFactor < minFactor) { 90 | #if DEBUG 91 | fprintf(stderr, 92 | "libresample: " 93 | "minFactor and maxFactor must be positive real numbers,\n" 94 | "and maxFactor should be larger than minFactor.\n"); 95 | #endif 96 | return 0; 97 | } 98 | 99 | hp = (rsdata *)malloc(sizeof(rsdata)); 100 | 101 | hp->minFactor = minFactor; 102 | hp->maxFactor = maxFactor; 103 | 104 | if (highQuality) 105 | hp->Nmult = 35; 106 | else 107 | hp->Nmult = 11; 108 | 109 | hp->LpScl = 1.0; 110 | hp->Nwing = Npc*(hp->Nmult-1)/2; /* # of filter coeffs in right wing */ 111 | 112 | Rolloff = 0.90; 113 | Beta = 6; 114 | 115 | Imp64 = (double *)malloc(hp->Nwing * sizeof(double)); 116 | 117 | lrsLpFilter(Imp64, hp->Nwing, 0.5*Rolloff, Beta, Npc); 118 | 119 | hp->Imp = (float *)malloc(hp->Nwing * sizeof(float)); 120 | hp->ImpD = (float *)malloc(hp->Nwing * sizeof(float)); 121 | for(i=0; iNwing; i++) 122 | hp->Imp[i] = Imp64[i]; 123 | 124 | /* Storing deltas in ImpD makes linear interpolation 125 | of the filter coefficients faster */ 126 | for (i=0; iNwing-1; i++) 127 | hp->ImpD[i] = hp->Imp[i+1] - hp->Imp[i]; 128 | 129 | /* Last coeff. not interpolated */ 130 | hp->ImpD[hp->Nwing-1] = - hp->Imp[hp->Nwing-1]; 131 | 132 | free(Imp64); 133 | 134 | /* Calc reach of LP filter wing (plus some creeping room) */ 135 | Xoff_min = ((hp->Nmult+1)/2.0) * MAX(1.0, 1.0/minFactor) + 10; 136 | Xoff_max = ((hp->Nmult+1)/2.0) * MAX(1.0, 1.0/maxFactor) + 10; 137 | hp->Xoff = MAX(Xoff_min, Xoff_max); 138 | 139 | /* Make the inBuffer size at least 4096, but larger if necessary 140 | in order to store the minimum reach of the LP filter and then some. 141 | Then allocate the buffer an extra Xoff larger so that 142 | we can zero-pad up to Xoff zeros at the end when we reach the 143 | end of the input samples. */ 144 | hp->XSize = MAX(2*hp->Xoff+10, 4096); 145 | hp->X = (float *)malloc((hp->XSize + hp->Xoff) * sizeof(float)); 146 | hp->Xp = hp->Xoff; 147 | hp->Xread = hp->Xoff; 148 | 149 | /* Need Xoff zeros at begining of X buffer */ 150 | for(i=0; iXoff; i++) 151 | hp->X[i]=0; 152 | 153 | /* Make the outBuffer long enough to hold the entire processed 154 | output of one inBuffer */ 155 | hp->YSize = (int)(((double)hp->XSize)*maxFactor+2.0); 156 | hp->Y = (float *)malloc(hp->YSize * sizeof(float)); 157 | hp->Yp = 0; 158 | 159 | hp->Time = (double)hp->Xoff; /* Current-time pointer for converter */ 160 | 161 | return (void *)hp; 162 | } 163 | 164 | int resample_get_filter_width(const void *handle) 165 | { 166 | const rsdata *hp = (const rsdata *)handle; 167 | return hp->Xoff; 168 | } 169 | 170 | int resample_process(void *handle, 171 | double factor, 172 | float *inBuffer, 173 | int inBufferLen, 174 | int lastFlag, 175 | int *inBufferUsed, /* output param */ 176 | float *outBuffer, 177 | int outBufferLen) 178 | { 179 | rsdata *hp = (rsdata *)handle; 180 | float *Imp = hp->Imp; 181 | float *ImpD = hp->ImpD; 182 | float LpScl = hp->LpScl; 183 | UWORD Nwing = hp->Nwing; 184 | BOOL interpFilt = FALSE; /* TRUE means interpolate filter coeffs */ 185 | int outSampleCount; 186 | UWORD Nout, Ncreep, Nreuse; 187 | int Nx; 188 | int i, len; 189 | 190 | #if DEBUG 191 | fprintf(stderr, "resample_process: in=%d, out=%d lastFlag=%d\n", 192 | inBufferLen, outBufferLen, lastFlag); 193 | #endif 194 | 195 | /* Initialize inBufferUsed and outSampleCount to 0 */ 196 | *inBufferUsed = 0; 197 | outSampleCount = 0; 198 | 199 | if (factor < hp->minFactor || factor > hp->maxFactor) { 200 | #if DEBUG 201 | fprintf(stderr, 202 | "libresample: factor %f is not between " 203 | "minFactor=%f and maxFactor=%f", 204 | factor, hp->minFactor, hp->maxFactor); 205 | #endif 206 | return -1; 207 | } 208 | 209 | /* Start by copying any samples still in the Y buffer to the output 210 | buffer */ 211 | if (hp->Yp && (outBufferLen-outSampleCount)>0) { 212 | len = MIN(outBufferLen-outSampleCount, hp->Yp); 213 | for(i=0; iY[i]; 215 | outSampleCount += len; 216 | for(i=0; iYp-len; i++) 217 | hp->Y[i] = hp->Y[i+len]; 218 | hp->Yp -= len; 219 | } 220 | 221 | /* If there are still output samples left, return now - we need 222 | the full output buffer available to us... */ 223 | if (hp->Yp) 224 | return outSampleCount; 225 | 226 | /* Account for increased filter gain when using factors less than 1 */ 227 | if (factor < 1) 228 | LpScl = LpScl*factor; 229 | 230 | for(;;) { 231 | 232 | /* This is the maximum number of samples we can process 233 | per loop iteration */ 234 | 235 | #ifdef DEBUG 236 | printf("XSize: %d Xoff: %d Xread: %d Xp: %d lastFlag: %d\n", 237 | hp->XSize, hp->Xoff, hp->Xread, hp->Xp, lastFlag); 238 | #endif 239 | 240 | /* Copy as many samples as we can from the input buffer into X */ 241 | len = hp->XSize - hp->Xread; 242 | 243 | if (len >= (inBufferLen - (*inBufferUsed))) 244 | len = (inBufferLen - (*inBufferUsed)); 245 | 246 | for(i=0; iX[hp->Xread + i] = inBuffer[(*inBufferUsed) + i]; 248 | 249 | *inBufferUsed += len; 250 | hp->Xread += len; 251 | 252 | if (lastFlag && (*inBufferUsed == inBufferLen)) { 253 | /* If these are the last samples, zero-pad the 254 | end of the input buffer and make sure we process 255 | all the way to the end */ 256 | Nx = hp->Xread - hp->Xoff; 257 | for(i=0; iXoff; i++) 258 | hp->X[hp->Xread + i] = 0; 259 | } 260 | else 261 | Nx = hp->Xread - 2 * hp->Xoff; 262 | 263 | #ifdef DEBUG 264 | fprintf(stderr, "new len=%d Nx=%d\n", len, Nx); 265 | #endif 266 | 267 | if (Nx <= 0) 268 | break; 269 | 270 | /* Resample stuff in input buffer */ 271 | if (factor >= 1) { /* SrcUp() is faster if we can use it */ 272 | Nout = lrsSrcUp(hp->X, hp->Y, factor, &hp->Time, Nx, 273 | Nwing, LpScl, Imp, ImpD, interpFilt); 274 | } 275 | else { 276 | Nout = lrsSrcUD(hp->X, hp->Y, factor, &hp->Time, Nx, 277 | Nwing, LpScl, Imp, ImpD, interpFilt); 278 | } 279 | 280 | #ifdef DEBUG 281 | printf("Nout: %d\n", Nout); 282 | #endif 283 | 284 | hp->Time -= Nx; /* Move converter Nx samples back in time */ 285 | hp->Xp += Nx; /* Advance by number of samples processed */ 286 | 287 | /* Calc time accumulation in Time */ 288 | Ncreep = (int)(hp->Time) - hp->Xoff; 289 | if (Ncreep) { 290 | hp->Time -= Ncreep; /* Remove time accumulation */ 291 | hp->Xp += Ncreep; /* and add it to read pointer */ 292 | } 293 | 294 | /* Copy part of input signal that must be re-used */ 295 | Nreuse = hp->Xread - (hp->Xp - hp->Xoff); 296 | 297 | for (i=0; iX[i] = hp->X[i + (hp->Xp - hp->Xoff)]; 299 | 300 | #ifdef DEBUG 301 | printf("New Xread=%d\n", Nreuse); 302 | #endif 303 | 304 | hp->Xread = Nreuse; /* Pos in input buff to read new data into */ 305 | hp->Xp = hp->Xoff; 306 | 307 | /* Check to see if output buff overflowed (shouldn't happen!) */ 308 | if (Nout > hp->YSize) { 309 | #ifdef DEBUG 310 | printf("Nout: %d YSize: %d\n", Nout, hp->YSize); 311 | #endif 312 | fprintf(stderr, "libresample: Output array overflow!\n"); 313 | return -1; 314 | } 315 | 316 | hp->Yp = Nout; 317 | 318 | /* Copy as many samples as possible to the output buffer */ 319 | if (hp->Yp && (outBufferLen-outSampleCount)>0) { 320 | len = MIN(outBufferLen-outSampleCount, hp->Yp); 321 | for(i=0; iY[i]; 323 | outSampleCount += len; 324 | for(i=0; iYp-len; i++) 325 | hp->Y[i] = hp->Y[i+len]; 326 | hp->Yp -= len; 327 | } 328 | 329 | /* If there are still output samples left, return now, 330 | since we need the full output buffer available */ 331 | if (hp->Yp) 332 | break; 333 | } 334 | 335 | return outSampleCount; 336 | } 337 | 338 | void resample_close(void *handle) 339 | { 340 | rsdata *hp = (rsdata *)handle; 341 | free(hp->X); 342 | free(hp->Y); 343 | free(hp->Imp); 344 | free(hp->ImpD); 345 | free(hp); 346 | } 347 | 348 | -------------------------------------------------------------------------------- /src/resample.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | resample_open 3 | resample_dup 4 | resample_get_filter_width 5 | resample_process 6 | resample_close 7 | -------------------------------------------------------------------------------- /src/resample_defs.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | resample_defs.h 4 | 5 | Real-time library interface by Dominic Mazzoni 6 | 7 | Based on resample-1.7: 8 | http://www-ccrma.stanford.edu/~jos/resample/ 9 | 10 | Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. 11 | 12 | **********************************************************************/ 13 | 14 | #ifndef __RESAMPLE_DEFS__ 15 | #define __RESAMPLE_DEFS__ 16 | 17 | #if !defined(WIN32) && !defined(__CYGWIN__) 18 | #include "config.h" 19 | #endif 20 | 21 | #ifndef TRUE 22 | #define TRUE 1 23 | #endif 24 | 25 | #ifndef FALSE 26 | #define FALSE 0 27 | #endif 28 | 29 | #ifndef PI 30 | #define PI (3.14159265358979232846) 31 | #endif 32 | 33 | #ifndef PI2 34 | #define PI2 (6.28318530717958465692) 35 | #endif 36 | 37 | #define D2R (0.01745329348) /* (2*pi)/360 */ 38 | #define R2D (57.29577951) /* 360/(2*pi) */ 39 | 40 | #ifndef MAX 41 | #define MAX(x,y) ((x)>(y) ?(x):(y)) 42 | #endif 43 | #ifndef MIN 44 | #define MIN(x,y) ((x)<(y) ?(x):(y)) 45 | #endif 46 | 47 | #ifndef ABS 48 | #define ABS(x) ((x)<0 ?(-(x)):(x)) 49 | #endif 50 | 51 | #ifndef SGN 52 | #define SGN(x) ((x)<0 ?(-1):((x)==0?(0):(1))) 53 | #endif 54 | 55 | #if HAVE_INTTYPES_H 56 | #include 57 | typedef char BOOL; 58 | typedef int32_t WORD; 59 | typedef uint32_t UWORD; 60 | #else 61 | typedef char BOOL; 62 | typedef int WORD; 63 | typedef unsigned int UWORD; 64 | #endif 65 | 66 | #ifdef DEBUG 67 | #define INLINE 68 | #else 69 | #define INLINE inline 70 | #endif 71 | 72 | /* Accuracy */ 73 | 74 | #define Npc 4096 75 | 76 | /* Function prototypes */ 77 | 78 | int lrsSrcUp(float X[], float Y[], double factor, double *Time, 79 | UWORD Nx, UWORD Nwing, float LpScl, 80 | float Imp[], float ImpD[], BOOL Interp); 81 | 82 | int lrsSrcUD(float X[], float Y[], double factor, double *Time, 83 | UWORD Nx, UWORD Nwing, float LpScl, 84 | float Imp[], float ImpD[], BOOL Interp); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/resamplesubs.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | resamplesubs.c 4 | 5 | Real-time library interface by Dominic Mazzoni 6 | 7 | Based on resample-1.7: 8 | http://www-ccrma.stanford.edu/~jos/resample/ 9 | 10 | Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. 11 | 12 | This file provides the routines that do sample-rate conversion 13 | on small arrays, calling routines from filterkit. 14 | 15 | **********************************************************************/ 16 | 17 | /* Definitions */ 18 | #include "resample_defs.h" 19 | 20 | #include "filterkit.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /* Sampling rate up-conversion only subroutine; 28 | * Slightly faster than down-conversion; 29 | */ 30 | int lrsSrcUp(float X[], 31 | float Y[], 32 | double factor, 33 | double *TimePtr, 34 | UWORD Nx, 35 | UWORD Nwing, 36 | float LpScl, 37 | float Imp[], 38 | float ImpD[], 39 | BOOL Interp) 40 | { 41 | float *Xp, *Ystart; 42 | float v; 43 | 44 | double CurrentTime = *TimePtr; 45 | double dt; /* Step through input signal */ 46 | double endTime; /* When Time reaches EndTime, return to user */ 47 | 48 | dt = 1.0/factor; /* Output sampling period */ 49 | 50 | Ystart = Y; 51 | endTime = CurrentTime + Nx; 52 | while (CurrentTime < endTime) 53 | { 54 | double LeftPhase = CurrentTime-floor(CurrentTime); 55 | double RightPhase = 1.0 - LeftPhase; 56 | 57 | Xp = &X[(int)CurrentTime]; /* Ptr to current input sample */ 58 | /* Perform left-wing inner product */ 59 | v = lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp, 60 | LeftPhase, -1); 61 | /* Perform right-wing inner product */ 62 | v += lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp+1, 63 | RightPhase, 1); 64 | 65 | v *= LpScl; /* Normalize for unity filter gain */ 66 | 67 | *Y++ = v; /* Deposit output */ 68 | CurrentTime += dt; /* Move to next sample by time increment */ 69 | } 70 | 71 | *TimePtr = CurrentTime; 72 | return (Y - Ystart); /* Return the number of output samples */ 73 | } 74 | 75 | /* Sampling rate conversion subroutine */ 76 | 77 | int lrsSrcUD(float X[], 78 | float Y[], 79 | double factor, 80 | double *TimePtr, 81 | UWORD Nx, 82 | UWORD Nwing, 83 | float LpScl, 84 | float Imp[], 85 | float ImpD[], 86 | BOOL Interp) 87 | { 88 | float *Xp, *Ystart; 89 | float v; 90 | 91 | double CurrentTime = (*TimePtr); 92 | double dh; /* Step through filter impulse response */ 93 | double dt; /* Step through input signal */ 94 | double endTime; /* When Time reaches EndTime, return to user */ 95 | 96 | dt = 1.0/factor; /* Output sampling period */ 97 | 98 | dh = MIN(Npc, factor*Npc); /* Filter sampling period */ 99 | 100 | Ystart = Y; 101 | endTime = CurrentTime + Nx; 102 | while (CurrentTime < endTime) 103 | { 104 | double LeftPhase = CurrentTime-floor(CurrentTime); 105 | double RightPhase = 1.0 - LeftPhase; 106 | 107 | Xp = &X[(int)CurrentTime]; /* Ptr to current input sample */ 108 | /* Perform left-wing inner product */ 109 | v = lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp, 110 | LeftPhase, -1, dh); 111 | /* Perform right-wing inner product */ 112 | v += lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp+1, 113 | RightPhase, 1, dh); 114 | 115 | v *= LpScl; /* Normalize for unity filter gain */ 116 | *Y++ = v; /* Deposit output */ 117 | 118 | CurrentTime += dt; /* Move to next sample by time increment */ 119 | } 120 | 121 | *TimePtr = CurrentTime; 122 | return (Y - Ystart); /* Return the number of output samples */ 123 | } 124 | -------------------------------------------------------------------------------- /tests/compareresample.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | compareresample.c 4 | 5 | Real-time library interface by Dominic Mazzoni 6 | 7 | Based on resample-1.7: 8 | http://www-ccrma.stanford.edu/~jos/resample/ 9 | 10 | Dual-licensed as LGPL and BSD; see README.md and LICENSE* files. 11 | 12 | **********************************************************************/ 13 | 14 | #include "../include/libresample.h" 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define MIN(A, B) (A) < (B)? (A) : (B) 25 | 26 | void dostat(char *name, float *d1, float *d2, int len) 27 | { 28 | int i; 29 | double sum, sumsq, err, rmserr; 30 | 31 | sum = 0.0; 32 | sumsq = 0.0; 33 | for(i=0; i= 0) 79 | out += o; 80 | if (o < 0 || (o == 0 && srcpos == srclen)) 81 | break; 82 | } 83 | resample_close(handle); 84 | 85 | gettimeofday(&tv1, NULL); 86 | deltat = 87 | (tv1.tv_sec + tv1.tv_usec * 0.000001) - 88 | (tv0.tv_sec + tv0.tv_usec * 0.000001); 89 | 90 | if (o < 0) { 91 | printf("Error: resample_process returned an error: %d\n", o); 92 | } 93 | 94 | if (out <= 0) { 95 | printf("Error: resample_process returned %d samples\n", out); 96 | free(dst_rs); 97 | return; 98 | } 99 | 100 | printf(" resample: %.3f seconds, %d outputs\n", deltat, out); 101 | 102 | /* do rabbit (Erik's libsamplerate) */ 103 | 104 | for(i=0; i 0) 134 | statlen = MIN(statlen, anslen); 135 | 136 | if (ans) { 137 | dostat("resample ", dst_rs, ans, statlen); 138 | dostat("rabbit ", dst_rabbit, ans, statlen); 139 | } 140 | dostat( "RS vs rabbit", dst_rs, dst_rabbit, statlen); 141 | 142 | free(dst_rs); 143 | free(dst_rabbit); 144 | } 145 | 146 | int main(int argc, char **argv) 147 | { 148 | int i, srclen; 149 | float *src, *ans; 150 | 151 | printf("\n*** sin wave, factor = 1.0 *** \n\n"); 152 | srclen = 100000; 153 | src = malloc(srclen * sizeof(float)); 154 | for(i=0; i 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #define MIN(A, B) (A) < (B)? (A) : (B) 26 | 27 | void usage(char *progname) 28 | { 29 | fprintf(stderr, "Usage: %s -by \n", progname); 30 | fprintf(stderr, " %s -to \n", progname); 31 | fprintf(stderr, "\n"); 32 | exit(-1); 33 | } 34 | 35 | int main(int argc, char **argv) 36 | { 37 | SNDFILE *srcfile, *dstfile; 38 | SF_INFO srcinfo, dstinfo; 39 | SF_FORMAT_INFO formatinfo; 40 | char *extension; 41 | void **handle; 42 | int channels; 43 | int srclen, dstlen; 44 | float *src, *srci; 45 | float *dst, *dsti; 46 | double ratio = 0.0; 47 | double srcrate; 48 | double dstrate = 0.0; 49 | struct timeval tv0, tv1; 50 | double deltat; 51 | int numformats; 52 | int pos, bufferpos, outcount; 53 | int i, c; 54 | 55 | if (argc != 5) 56 | usage(argv[0]); 57 | 58 | if (!strcmp(argv[1], "-by")) { 59 | ratio = atof(argv[2]); 60 | if (ratio <= 0.0) { 61 | fprintf(stderr, "Ratio of %f is illegal\n", ratio); 62 | usage(argv[0]); 63 | } 64 | } 65 | else if (!strcmp(argv[1], "-to")) { 66 | dstrate = atof(argv[2]); 67 | if (dstrate < 10.0 || dstrate > 100000.0) { 68 | fprintf(stderr, "Sample rate of %f is illegal\n", dstrate); 69 | usage(argv[0]); 70 | } 71 | } 72 | else 73 | usage(argv[0]); 74 | 75 | memset(&srcinfo, 0, sizeof(srcinfo)); 76 | memset(&dstinfo, 0, sizeof(dstinfo)); 77 | srcfile = sf_open(argv[3], SFM_READ, &srcinfo); 78 | if (!srcfile) { 79 | fprintf(stderr, "%s", sf_strerror(NULL)); 80 | exit(-1); 81 | } 82 | 83 | srcrate = srcinfo.samplerate; 84 | if (dstrate == 0.0) 85 | dstrate = srcrate * ratio; 86 | else 87 | ratio = dstrate / srcrate; 88 | 89 | channels = srcinfo.channels; 90 | 91 | /* figure out format of destination file */ 92 | 93 | extension = strstr(argv[4], "."); 94 | if (extension) { 95 | extension++; 96 | sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, 97 | &numformats, sizeof(numformats)); 98 | for(i=0; i= 1) 181 | dsti[i*channels+c] = 1; 182 | else 183 | dsti[i*channels+c] = dst[i]; 184 | } 185 | } 186 | 187 | sf_writef_float(dstfile, dsti, out); 188 | 189 | bufferpos = block - inUsed; 190 | for(i=0; i 17 | #include 18 | #include 19 | 20 | #define MIN(A, B) (A) < (B)? (A) : (B) 21 | 22 | void runtest(int srclen, double freq, double factor, 23 | int srcblocksize, int dstblocksize) 24 | { 25 | int expectedlen = (int)(srclen * factor); 26 | int dstlen = expectedlen + 1000; 27 | float *src = (float *)malloc((srclen+100) * sizeof(float)); 28 | float *dst = (float *)malloc((dstlen+100) * sizeof(float)); 29 | void *handle; 30 | double sum, sumsq, err, rmserr; 31 | int i, out, o, srcused, errcount, rangecount; 32 | int statlen, srcpos, lendiff; 33 | int fwidth; 34 | 35 | printf("-- srclen: %d sin freq: %.1f factor: %.3f srcblk: %d dstblk: %d\n", 36 | srclen, freq, factor, srcblocksize, dstblocksize); 37 | 38 | for(i=0; i= 0) 60 | out += o; 61 | if (o < 0 || (o == 0 && srcpos == srclen)) 62 | break; 63 | } 64 | resample_close(handle); 65 | 66 | if (o < 0) { 67 | printf("Error: resample_process returned an error: %d\n", o); 68 | } 69 | 70 | if (out <= 0) { 71 | printf("Error: resample_process returned %d samples\n", out); 72 | free(src); 73 | free(dst); 74 | return; 75 | } 76 | 77 | lendiff = abs(out - expectedlen); 78 | if (lendiff > (int)(2*factor + 1.0)) { 79 | printf(" Expected ~%d, got %d samples out\n", 80 | expectedlen, out); 81 | } 82 | 83 | sum = 0.0; 84 | sumsq = 0.0; 85 | errcount = 0.0; 86 | 87 | /* Don't compute statistics on all output values; the last few 88 | are guaranteed to be off because it's based on far less 89 | interpolation. */ 90 | statlen = out - fwidth; 91 | 92 | for(i=0; i 0.05) { 95 | if (errcount == 0) 96 | printf(" First error at i=%d: expected %.3f, got %.3f\n", 97 | i, sin((i/freq)/factor), dst[i]); 98 | errcount++; 99 | } 100 | sum += fabs(diff); 101 | sumsq += diff * diff; 102 | } 103 | 104 | rangecount = 0; 105 | for(i=0; i 1.01) { 107 | if (rangecount == 0) 108 | printf(" Error at i=%d: value is %.3f\n", i, dst[i]); 109 | rangecount++; 110 | } 111 | } 112 | if (rangecount > 1) 113 | printf(" At least %d samples were out of range\n", rangecount); 114 | 115 | if (errcount > 0) { 116 | i = out - 1; 117 | printf(" i=%d: expected %.3f, got %.3f\n", 118 | i, sin((i/freq)/factor), dst[i]); 119 | printf(" At least %d samples had significant error.\n", errcount); 120 | } 121 | err = sum / statlen; 122 | rmserr = sqrt(sumsq / statlen); 123 | printf(" Out: %d samples Avg err: %f RMS err: %f\n", out, err, rmserr); 124 | free(src); 125 | free(dst); 126 | } 127 | 128 | int main(int argc, char **argv) 129 | { 130 | int i, srclen, dstlen, ifreq; 131 | double factor; 132 | 133 | printf("\n*** Vary source block size*** \n\n"); 134 | srclen = 10000; 135 | ifreq = 100; 136 | for(i=0; i<20; i++) { 137 | factor = ((rand() % 16) + 1) / 4.0; 138 | dstlen = (int)(srclen * factor + 10); 139 | runtest(srclen, (double)ifreq, factor, 64, dstlen); 140 | runtest(srclen, (double)ifreq, factor, 32, dstlen); 141 | runtest(srclen, (double)ifreq, factor, 8, dstlen); 142 | runtest(srclen, (double)ifreq, factor, 2, dstlen); 143 | runtest(srclen, (double)ifreq, factor, srclen, dstlen); 144 | } 145 | 146 | printf("\n*** Vary dest block size ***\n\n"); 147 | srclen = 10000; 148 | ifreq = 100; 149 | for(i=0; i<20; i++) { 150 | factor = ((rand() % 16) + 1) / 4.0; 151 | runtest(srclen, (double)ifreq, factor, srclen, 32); 152 | dstlen = (int)(srclen * factor + 10); 153 | runtest(srclen, (double)ifreq, factor, srclen, dstlen); 154 | } 155 | 156 | printf("\n*** Resample factor 1.0, testing different srclen ***\n\n"); 157 | ifreq = 40; 158 | for(i=0; i<100; i++) { 159 | srclen = (rand() % 30000) + 10; 160 | dstlen = (int)(srclen + 10); 161 | runtest(srclen, (double)ifreq, 1.0, srclen, dstlen); 162 | } 163 | 164 | printf("\n*** Resample factor 1.0, testing different sin freq ***\n\n"); 165 | srclen = 10000; 166 | for(i=0; i<100; i++) { 167 | ifreq = ((int)rand() % 10000) + 1; 168 | dstlen = (int)(srclen * 10); 169 | runtest(srclen, (double)ifreq, 1.0, srclen, dstlen); 170 | } 171 | 172 | printf("\n*** Resample with different factors ***\n\n"); 173 | srclen = 10000; 174 | ifreq = 100; 175 | for(i=0; i<100; i++) { 176 | factor = ((rand() % 64) + 1) / 4.0; 177 | dstlen = (int)(srclen * factor + 10); 178 | runtest(srclen, (double)ifreq, factor, srclen, dstlen); 179 | } 180 | 181 | return 0; 182 | } 183 | -------------------------------------------------------------------------------- /win/libresample.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 27 | 30 | 33 | 36 | 39 | 42 | 58 | 61 | 66 | 69 | 74 | 77 | 80 | 83 | 86 | 89 | 90 | 100 | 103 | 106 | 109 | 112 | 115 | 133 | 136 | 141 | 144 | 149 | 152 | 155 | 158 | 161 | 164 | 165 | 175 | 178 | 181 | 184 | 187 | 190 | 206 | 209 | 214 | 217 | 222 | 225 | 228 | 231 | 234 | 237 | 238 | 248 | 251 | 254 | 257 | 260 | 263 | 281 | 284 | 289 | 292 | 297 | 300 | 303 | 306 | 309 | 312 | 313 | 323 | 326 | 329 | 332 | 335 | 338 | 354 | 357 | 362 | 365 | 370 | 373 | 376 | 379 | 382 | 385 | 386 | 396 | 399 | 402 | 405 | 408 | 411 | 427 | 430 | 435 | 438 | 443 | 446 | 449 | 452 | 455 | 458 | 459 | 469 | 472 | 475 | 478 | 481 | 484 | 502 | 505 | 510 | 513 | 518 | 521 | 524 | 527 | 530 | 533 | 534 | 535 | 536 | 537 | 538 | 542 | 545 | 548 | 554 | 555 | 558 | 563 | 564 | 567 | 573 | 574 | 577 | 582 | 583 | 586 | 592 | 593 | 596 | 602 | 603 | 606 | 611 | 612 | 613 | 616 | 619 | 625 | 626 | 629 | 634 | 635 | 638 | 644 | 645 | 648 | 653 | 654 | 657 | 663 | 664 | 667 | 673 | 674 | 677 | 682 | 683 | 684 | 687 | 690 | 696 | 697 | 700 | 705 | 706 | 709 | 715 | 716 | 719 | 724 | 725 | 728 | 734 | 735 | 738 | 744 | 745 | 748 | 753 | 754 | 755 | 756 | 760 | 763 | 764 | 767 | 768 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | --------------------------------------------------------------------------------