1 | #!/bin/sh |
1 | #!/bin/sh |
2 | |
2 | |
3 | # extracts various bits of data form OpenCL heder files, which are expected to |
3 | # extracts various bits of data form OpenCL heder files, which are expected to |
4 | # be in CL/ |
4 | # be in CL/ |
5 | |
5 | |
|
|
6 | ALL_H="CL/cl.h CL/cl_ext.h CL/cl_gl.h CL/cl_gl_ext.h CL11/cl_d3d9.h CL/cl_d3d10.h CL12/cl_d3d11.h CL/cl_dx9_media_sharing.h" |
|
|
7 | |
6 | # constants |
8 | # constants |
7 | ( |
9 | ( |
8 | echo '// autogenerated by h_extract' |
10 | echo '// autogenerated by h_extract' |
9 | cat CL/cl.h CL/cl_ext.h CL/cl_gl.h CL/cl_gl_ext.h CL/cl_d3d10.h | |
11 | cat $ALL_H | |
10 | perl -ne 'print "const_iv($1)\n" if /^#define CL_(\S+)/' |
12 | perl -ne 'print "const_iv($1)\n" if /^#define CL_(\S+)/' |
|
|
13 | cat CL/cl_platform.h | |
|
|
14 | perl -ne 'print "const_iv($1)\n" if /^#define CL_(\S+)\s+[^.]+\s*$/' | |
|
|
15 | sort | uniq | |
|
|
16 | perl -ne 'print unless /const_iv\((?:MAXFLOAT|INFINITY|NAN|HUGE_VALF?)\)/' |
11 | ) >constiv.h |
17 | ) >constiv.h |
|
|
18 | |
|
|
19 | # fp constants |
|
|
20 | ( |
|
|
21 | echo '// autogenerated by h_extract' |
|
|
22 | cat CL/cl_platform.h | |
|
|
23 | perl -ne 'print "const_nv($1)\n" if /^#define\s+CL_(\S+)\s+.*\..*\s*$/' |
|
|
24 | echo "const_nv(MAXFLOAT)" |
|
|
25 | echo "const_nv(INFINITY)" |
|
|
26 | echo "const_nv(HUGE_VAL)" |
|
|
27 | echo "const_nv(HUGE_VALF)" |
|
|
28 | ) >constnv.h |
12 | |
29 | |
13 | # constants that look like enum values |
30 | # constants that look like enum values |
14 | ( |
31 | ( |
15 | echo '// autogenerated by h_extract' |
32 | echo '// autogenerated by h_extract' |
16 | cat CL/cl.h CL/cl_ext.h CL/cl_gl.h CL/cl_gl_ext.h CL/cl_d3d10.h | |
33 | cat $ALL_H | |
17 | perl -ne 'print "const_iv($1)\n" if /^#define CL_(\S+)\s+0x[0-9a-fA-F]{4}/' |
34 | perl -ne 'print "const_iv($1)\n" if /^#define CL_(\S+)\s+0x[0-9a-fA-F]{4}/' |
18 | ) >enumstr.h |
35 | ) >enumstr.h |
19 | |
36 | |
20 | # error codes |
37 | # error codes |
21 | ( |
38 | ( |
22 | echo '// autogenerated by h_extract' |
39 | echo '// autogenerated by h_extract' |
23 | echo "const_iv(SUCCESS)" |
40 | echo "const_iv(SUCCESS)" |
24 | cat CL/cl.h CL/cl_ext.h CL/cl_gl.h CL/cl_gl_ext.h CL/cl_d3d10.h | |
41 | cat $ALL_H | |
25 | perl -ne 'print "const_iv($1)\n" if !/#define CL_BUILD_(?:NONE|ERROR|IN_PROGRESS)/ && /^#define CL_(\S+)\s+-\d+\s*$/' |
42 | perl -ne 'print "const_iv($1)\n" if !/#define CL_BUILD_(?:NONE|ERROR|IN_PROGRESS)/ && /^#define CL_(\S+)\s+-\d+\s*$/' |
26 | ) >errstr.h |
43 | ) >errstr.h |
27 | |
44 | |
28 | # default constant values to -1 |
45 | # default constant values to -1 |
29 | ( |
46 | ( |
30 | echo '// autogenerated by h_extract' |
47 | echo '// autogenerated by h_extract' |
31 | cat constiv.h enumstr.h errstr.h | |
48 | cat constiv.h | |
32 | perl -ne '/const_iv\((.*)\)/ or next; print "#ifndef CL_$1\n#define CL_$1 -1\n#endif\n"' |
49 | perl -ne '/const_iv\((.*)\)/ or next; print "#ifndef CL_$1\n#define CL_$1 -1\n#endif\n"' |
33 | ) >default.h |
50 | ) >default.h |
34 | |
51 | |
35 | # *glGet*Info |
52 | # *glGet*Info |
36 | ( |
53 | ( |