summaryrefslogtreecommitdiffstats
path: root/src/glx/apple/gen_gl_h.sh
blob: f10ddd0bfc718eafdbffbcdcb7ab615e9343f047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

INFILE=$1
OUTFILE=$2

generate_macros() {
    grep gl.*ProcPtr /System/Library/Frameworks/OpenGL.framework/Headers/gl{,ext}.h | sed 's:^.*\(gl.*Ptr\).*$:\1:' | sort -u | perl -ne 'chomp($_); $s = "PFN".uc($_); $s =~ s/PROCPTR/PROC/; print "#define ".$_." ".$s."\n"'
}

generate_function_pointers() {
    { 
      echo "#define GL_GLEXT_FUNCTION_POINTERS 1"
      echo "#define GL_GLEXT_LEGACY 1"
      generate_macros
      echo '#include "/System/Library/Frameworks/OpenGL.framework/Headers/gl.h"'
    } | ${CC:-gcc} -E - | grep typedef.*PFN
}

cat ${INFILE} | while IFS= read LINE ; do
  case $LINE in
    "@CGL_MESA_COMPAT_MACROS@")
      generate_macros
    ;;
    "@CGL_MESA_FUNCTION_POINTERS@")
      if ! grep -q GL_GLEXT_PROTOTYPES /System/Library/Frameworks/OpenGL.framework/Headers/gl.h ; then
        generate_function_pointers
      fi
    ;;
    *)
      printf "${LINE}\n"
    ;;
  esac
done > ${OUTFILE}