X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=setup.py;h=5ebbdcdcf1cd727706e157742f9177cab883791d;hp=00126ee28cf6a3955342f5dd377d196d3e1b4944;hb=bdad407fb79c2f7be9f3603694ebdeadc645b52d;hpb=dc1dba9a9621798f00c42c73efa52602ecc8335d diff --git a/setup.py b/setup.py index 00126ee..5ebbdcd 100644 --- a/setup.py +++ b/setup.py @@ -10,12 +10,23 @@ except ImportError: cc = ccompiler.new_compiler() +# leave it to gcc to detect c/c++ files. we'll be linking against -lstdc++ +# later on to ensure we do have all the c++ libraries, so we don't need to +# compile *everything* as c++ just because of the few .cc files. +cc.language_map[".cc"] = "c" + import os import sys import stat +import re DATADIR = "/usr/share/swftools/" +def update_dirs(list1, list2): + for v in list2: + if v not in list1 and os.path.isdir(v): + list1.append(v) + def update_list(list1, list2): for v in list2: if v not in list1: @@ -27,30 +38,23 @@ COMPILER_OPTIONS = ['-fPIC', '-Wparentheses', '-Wimplicit', '-Wreturn-type', '-DSWFTOOLS_DATADIR="'+DATADIR+'"'] INCLUDE=['lib/lame/', 'lib/pdf/xpdf', 'lib/pdf'] -if 'SWFTOOLS_SYSTEM_PREFIX' in os.environ: - # Allow overriding the prefix location. This is useful if your - # python is compiled in a custom location. - PREFIX = os.environ.get('SWFTOOLS_SYSTEM_PREFIX').strip() - if not os.path.exists(PREFIX): - print 'The SWFTOOLS_SYSTEM_PREFIX location does not exist' - sys.exit(1) - print 'Using %s as prefix for header files' % PREFIX +if 'library_dirs' in os.environ: + update_dirs(cc.library_dirs, [path.strip() for path in os.environ.get('library_dirs').strip().split(":")]) else: - # Default to the prefix used for the python interpreter - PREFIX = sys.prefix - -update_list(cc.include_dirs, [os.path.join(PREFIX, 'include'), - os.path.join(PREFIX, 'include/freetype2'), - os.path.join(PREFIX, 'include/fontconfig')]) + update_dirs(cc.library_dirs, [os.path.join(sys.prefix, 'lib'), + os.path.join(sys.prefix, 'local/lib')]) + if sys.platform == "darwin": + update_list(cc.library_dirs, ["/sw/lib", "/opt/local/lib"]) -update_list(cc.library_dirs, ["/usr/lib", "/usr/local/lib"]) +if 'include_dirs' in os.environ: + update_dirs(cc.include_dirs, [path.strip() for path in os.environ.get('include_dirs').strip().split(":")]) +else: + update_dirs(cc.include_dirs, [os.path.join(sys.prefix, 'include'), + os.path.join(sys.prefix, 'include/freetype2'), + os.path.join(sys.prefix, 'include/fontconfig')]) + if sys.platform == "darwin": + update_dirs(cc.include_dirs, ["/sw/include/freetype2", "/sw/lib/freetype2/include", "/sw/include", "/opt/local/include"]) -if sys.platform == "darwin": - update_list(cc.include_dirs, ["/sw/include/freetype2", - "/sw/lib/freetype2/include", - "/sw/include", - "/opt/local/include"]) - update_list(cc.library_dirs, ["/sw/lib", "/opt/local/lib"]) class ConfigScript: def __init__(self): @@ -123,6 +127,18 @@ class ConfigScript: def system_has_property(self,name): if name.startswith("STD"): return 1 + elif name.startswith("INTERNAL"): + return 1 + elif name == "PACKAGE": + return "\"swftools\"" + elif name == "VERSION": + fi = open("configure.in", "rb") + for line in fi.readlines(): + if line.startswith("VERSION="): + return '"'+line[8:].strip()+'"' + return "unknown" + elif "POPPLER" in name: + return None elif name.startswith("HAVE_") and name.endswith("_H"): header = name[5:].lower() c = header.rfind("_") @@ -163,8 +179,11 @@ class ConfigScript: return "int" elif name.startswith("SIZEOF_"): t = name[7:].lower().replace("_", " ") + if t == "voidp": + t = "void*" for i in [1,2,4,8]: - if self.test_code("", "static int test_array [%d+1-sizeof(%s)];\ntest_array [0] = 0;" % (i,t)): + s = "static int test_array [%d+1-sizeof(%s)*2];\ntest_array [0] = 0;" % (i*2,t) + if self.test_code("", s): return i return None elif name.startswith("USE_FREEETYPE"): @@ -230,17 +249,20 @@ if "freetype" not in config.libraries: sys.exit(1) base_sources = [ -"lib/q.c", "lib/utf8.c", "lib/png.c", "lib/wav.c", "lib/mp3.c", "lib/os.c", "lib/bitio.c", "lib/log.c", "lib/mem.c", +"lib/q.c", "lib/utf8.c", "lib/png.c", "lib/jpeg.c", "lib/wav.c", "lib/mp3.c", "lib/os.c", "lib/bitio.c", "lib/log.c", "lib/mem.c", ] rfxswf_sources = [ -"lib/modules/swfabc.c", "lib/modules/swfaction.c", "lib/modules/swfbits.c", "lib/modules/swfbutton.c", +"lib/modules/swfaction.c", "lib/modules/swfbits.c", "lib/modules/swfbutton.c", "lib/modules/swfcgi.c", "lib/modules/swfdraw.c", "lib/modules/swfdump.c", "lib/modules/swffilter.c", "lib/modules/swffont.c", "lib/modules/swfobject.c", "lib/modules/swfrender.c", "lib/modules/swfshape.c", "lib/modules/swfsound.c", "lib/modules/swftext.c", "lib/modules/swftools.c", "lib/rfxswf.c", "lib/drawer.c", "lib/MD5.c", "lib/h.263/dct.c", "lib/h.263/h263tables.c", "lib/h.263/swfvideo.c", "lib/action/assembler.c", "lib/action/compile.c", "lib/action/lex.swf4.c", "lib/action/lex.swf5.c", "lib/action/libming.c", -"lib/action/swf4compiler.tab.c", "lib/action/swf5compiler.tab.c", "lib/action/actioncompiler.c" +"lib/action/swf4compiler.tab.c", "lib/action/swf5compiler.tab.c", "lib/action/actioncompiler.c", +"lib/as3/abc.c", "lib/as3/code.c", "lib/as3/pool.c", "lib/as3/files.c", "lib/as3/opcodes.c", +"lib/as3/scripts.c", "lib/as3/common.c", "lib/as3/builtin.c", "lib/as3/compiler.c", "lib/as3/expr.c", "lib/as3/import.c", +"lib/as3/initcode.c", "lib/as3/parser.tab.c", "lib/as3/registry.c", "lib/as3/tokenizer.yy.c", ] libpdf_sources = [ "lib/pdf/GFXOutputDev.cc", "lib/pdf/InfoOutputDev.cc", "lib/pdf/BitmapOutputDev.cc", @@ -276,9 +298,13 @@ libgfx_sources = [ "lib/art/art_svp_render_aa.c", "lib/art/art_svp_vpath.c", "lib/art/art_svp_vpath_stroke.c", "lib/art/art_svp_wind.c", "lib/art/art_uta.c", "lib/art/art_uta_ops.c", "lib/art/art_uta_rect.c", "lib/art/art_uta_svp.c", "lib/art/art_uta_vpath.c", "lib/art/art_vpath.c", "lib/art/art_vpath_bpath.c", -"lib/art/art_vpath_dash.c", "lib/art/art_vpath_svp.c", +"lib/art/art_vpath_dash.c", "lib/art/art_vpath_svp.c", "lib/gocr/box.c", +"lib/gocr/database.c", "lib/gocr/detect.c", "lib/gocr/job.c", "lib/gocr/lines.c", "lib/gocr/list.c", +"lib/gocr/ocr0.c", "lib/gocr/ocr0n.c", "lib/gocr/ocr1.c", "lib/gocr/otsu.c", "lib/gocr/output.c", +"lib/gocr/pgm2asc.c", "lib/gocr/pixel.c", "lib/gocr/progress.c", "lib/gocr/remove.c", "lib/gocr/unicode.c", +"lib/devices/ocr.c", ] -gfxswf_sources = ["lib/devices/swf.c"] +gfxswf_sources = ["lib/devices/swf.c", "lib/readers/swf.c", "lib/readers/image.c"] swf_module = Extension( name='SWF',