f2cab122e9623d61fe8f3648ad1de1f7951e30b7
[Faustine.git] / interpretor / libsndfile-1.0.25 / src / create_symbols_file.py
1 #!/usr/bin/python
2
3 # Copyright (C) 2003-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
4 #
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are
9 # met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in
15 # the documentation and/or other materials provided with the
16 # distribution.
17 # * Neither the author nor the names of any contributors may be used
18 # to endorse or promote products derived from this software without
19 # specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 import re, sys
34
35 #----------------------------------------------------------------
36 # These are all of the public functions exported from libsndfile.
37 #
38 # Its important not to change the order they are listed in or
39 # the ordinal values in the second column.
40
41 ALL_SYMBOLS = (
42 ( "sf_command", 1 ),
43 ( "sf_open", 2 ),
44 ( "sf_close", 3 ),
45 ( "sf_seek", 4 ),
46 ( "sf_error", 7 ),
47 ( "sf_perror", 8 ),
48 ( "sf_error_str", 9 ),
49 ( "sf_error_number", 10 ),
50 ( "sf_format_check", 11 ),
51 ( "sf_read_raw", 16 ),
52 ( "sf_readf_short", 17 ),
53 ( "sf_readf_int", 18 ),
54 ( "sf_readf_float", 19 ),
55 ( "sf_readf_double", 20 ),
56 ( "sf_read_short", 21 ),
57 ( "sf_read_int", 22 ),
58 ( "sf_read_float", 23 ),
59 ( "sf_read_double", 24 ),
60 ( "sf_write_raw", 32 ),
61 ( "sf_writef_short", 33 ),
62 ( "sf_writef_int", 34 ),
63 ( "sf_writef_float", 35 ),
64 ( "sf_writef_double", 36 ),
65 ( "sf_write_short", 37 ),
66 ( "sf_write_int", 38 ),
67 ( "sf_write_float", 39 ),
68 ( "sf_write_double", 40 ),
69 ( "sf_strerror", 50 ),
70 ( "sf_get_string", 60 ),
71 ( "sf_set_string", 61 ),
72 ( "sf_version_string",68 ),
73 ( "sf_open_fd", 70 ),
74 ( "sf_wchar_open", 71 ),
75 ( "sf_open_virtual", 80 ),
76 ( "sf_write_sync", 90 )
77 )
78
79 #-------------------------------------------------------------------------------
80
81 def linux_symbols (progname, version):
82 print "# Auto-generated by %s\n" %progname
83 print "libsndfile.so.%s" % version
84 print "{"
85 print " global:"
86 for name, ordinal in ALL_SYMBOLS:
87 if name == "sf_wchar_open":
88 continue
89 print " %s ;" % name
90 print " local:"
91 print " * ;"
92 print "} ;"
93 print
94 return
95
96 def darwin_symbols (progname, version):
97 print "# Auto-generated by %s\n" %progname
98 for name, ordinal in ALL_SYMBOLS:
99 if name == "sf_wchar_open":
100 continue
101 print "_%s" % name
102 print
103 return
104
105 def win32_symbols (progname, version, name):
106 print "; Auto-generated by %s\n" %progname
107 print "LIBRARY %s-%s.dll" % (name, re.sub ("\..*", "", version))
108 print "EXPORTS\n"
109 for name, ordinal in ALL_SYMBOLS:
110 print "%-20s @%s" % (name, ordinal)
111 print
112 return
113
114 def os2_symbols (progname, version, name):
115 print "; Auto-generated by %s\n" %progname
116 print "LIBRARY %s%s" % (name, re.sub ("\..*", "", version))
117 print "INITINSTANCE TERMINSTANCE"
118 print "CODE PRELOAD MOVEABLE DISCARDABLE"
119 print "DATA PRELOAD MOVEABLE MULTIPLE NONSHARED"
120 print "EXPORTS\n"
121 for name, ordinal in ALL_SYMBOLS:
122 if name == "sf_wchar_open":
123 continue
124 print "_%-20s @%s" % (name, ordinal)
125 print
126 return
127
128 def plain_symbols (progname, version, name):
129 for name, ordinal in ALL_SYMBOLS:
130 print name
131
132 def no_symbols (os_name):
133 print
134 print "No known way of restricting exported symbols on '%s'." % os_name
135 print "If you know a way, please contact the author."
136 print
137 return
138
139 #-------------------------------------------------------------------------------
140
141 progname = re.sub (".*[\\/]", "", sys.argv [0])
142
143 if len (sys.argv) != 3:
144 print
145 print "Usage : %s <target OS name> <libsndfile version>." % progname
146 print
147 print " Currently supported values for target OS are:"
148 print " linux"
149 print " darwin (ie MacOSX)"
150 print " win32 (ie wintendo)"
151 print " cygwin (Cygwin on wintendo)"
152 print " os2 (OS/2)"
153 print " plain (plain list of symbols)"
154 print
155 sys.exit (1)
156
157 os_name = sys.argv [1]
158 version = re.sub ("\.[a-z0-9]+$", "", sys.argv [2])
159
160 if os_name == "linux" or os_name == "gnu" or os_name == "binutils":
161 linux_symbols (progname, version)
162 elif os_name == "darwin":
163 darwin_symbols (progname, version)
164 elif os_name == "win32":
165 win32_symbols (progname, version, "libsndfile")
166 elif os_name == "cygwin":
167 win32_symbols (progname, version, "cygsndfile")
168 elif os_name == "os2":
169 os2_symbols (progname, version, "sndfile")
170 elif os_name == "static":
171 plain_symbols (progname, version, "")
172 else:
173 no_symbols (os_name)
174
175 sys.exit (0)
176