#!/usr/bin/env python
#
import sys
import re

f = sys.argv[1]
for l in file(f, "r"):
    l = re.sub("(defined\(_MSC_VER\))", "\\1 || defined(__MINGW32__)", l)
    l = re.sub("(define\s+SWIG_init\s+init)_(.+)", "\\1lib\\2", l)
    l = re.sub("(define\s+SWIG_name\s+)\"_(.+)\"", "\\1\"lib\\2\"", l)
    l = re.sub("(SWIG_NewPointerObj.+), 1\);", "\\1, 0);", l)
    l = re.sub("^(#\s*define SWIGEXPORT\(a\))\s+a", "\\1 a __attribute__((visibility(\"default\")))", l)
    print l,

