X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=make%2Fconfigure.py;h=ba089411ad1666e7395118446c975f7c45226177;hb=c593146bf3fab6290c71cbbb974e0a756e43f5e0;hp=7a91fdc233aab268d22df87b52d64f609115353e;hpb=c5f198960b6aa3aa4f12f7de3ac9f25dd37a2ec8;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/make/configure.py b/make/configure.py index 7a91fdc2..ba089411 100644 --- a/make/configure.py +++ b/make/configure.py @@ -315,7 +315,7 @@ class ShellProbe( Action ): ## x86_64-unknown-linux-gnu (Linux, Fedora 10 x86_64) ## class HostTupleProbe( ShellProbe, list ): - GNU_TUPLE_RX = '([^-]+)-([^-]+)-([^0-9-]+)([^-]*)-?([^-]*)' + GNU_TUPLE_RE = '([^-]+)-?([^-]*)-([^0-9-]+)([^-]*)-?([^-]*)' def __init__( self ): super( HostTupleProbe, self ).__init__( 'host tuple', '%s/config.guess' % (cfg.dir), abort=True, head=True ) @@ -327,7 +327,7 @@ class HostTupleProbe( ShellProbe, list ): self.spec = '' ## grok GNU host tuples - m = re.match( HostTupleProbe.GNU_TUPLE_RX, self.spec ) + m = re.match( HostTupleProbe.GNU_TUPLE_RE, self.spec ) if not m: self.fail = True self.msg_end = 'invalid host tuple: %s' % (self.spec) @@ -352,8 +352,11 @@ class HostTupleProbe( ShellProbe, list ): self.systemf = self[2][0].upper() + self[2][1:] ## glob-match against spec - def match( self, spec ): - return fnmatch.fnmatch( self.spec, spec ) + def match( self, *specs ): + for spec in specs: + if fnmatch.fnmatch( self.spec, spec ): + return True + return False ############################################################################### @@ -362,10 +365,14 @@ class BuildAction( Action, list ): super( BuildAction, self ).__init__( 'compute', 'build tuple', abort=True ) def _action( self ): - self.spec = arch.mode[arch.mode.mode] + ## check if --cross spec was used; must maintain 5-tuple compatibility with regex + if options.cross: + self.spec = os.path.basename( options.cross ).rstrip( '-' ) + else: + self.spec = arch.mode[arch.mode.mode] ## grok GNU host tuples - m = re.match( HostTupleProbe.GNU_TUPLE_RX, self.spec ) + m = re.match( HostTupleProbe.GNU_TUPLE_RE, self.spec ) if not m: self.msg_end = 'invalid host tuple: %s' % (self.spec) return @@ -383,29 +390,46 @@ class BuildAction( Action, list ): self.extra = self[4] self.systemf = host.systemf + ## when cross we need switch for platforms + if options.cross: + if self.match( '*mingw*' ): + self.systemf = 'MinGW' + elif self.systemf: + self.systemf[0] = self.systemf[0].upper() + self.title = '%s %s' % (build.systemf,self.machine) + else: + self.title = '%s %s' % (build.systemf,arch.mode.mode) self.fail = False + ## glob-match against spec + def match( self, *specs ): + for spec in specs: + if fnmatch.fnmatch( self.spec, spec ): + return True + return False + ############################################################################### ## -## platform conditional string; if specs do not match host: +## value wrapper; value is accepted only if one of host specs matcheds +## otherwise it is None (or a keyword-supplied val) ## -## - str value is blank -## - evaluates to False +## result is attribute 'value' ## class IfHost( object ): - def __init__( self, value, *specs ): - self.value = '' + def __init__( self, value, *specs, **kwargs ): + self.value = kwargs.get('none',None) for spec in specs: if host.match( spec ): self.value = value break def __nonzero__( self ): - return len(self.value) != 0 + return self.value != None def __str__( self ): return self.value + ############################################################################### ## ## platform conditional value; loops through list of tuples comparing @@ -517,7 +541,7 @@ class SelectMode( dict ): self.mode = self.default def cli_add_option( self, parser, option ): - parser.add_option( '', option, default=self.mode, metavar='MODE', + parser.add_option( option, default=self.mode, metavar='MODE', help='select %s mode: %s' % (self.descr,self.toString()), action='callback', callback=self.cli_callback, type='str' ) @@ -618,7 +642,7 @@ class Project( Action ): self.name = 'HandBrake' self.acro_lower = 'hb' self.acro_upper = 'HB' - self.url_website = 'http://handbrake.fr' + self.url_website = 'http://code.google.com/p/hbfork' self.url_community = 'http://forum.handbrake.fr' self.url_irc = 'irc://irc.freenode.net/handbrake' @@ -685,7 +709,7 @@ class ToolProbe( Action ): self.msg_end = 'not found' def cli_add_option( self, parser ): - parser.add_option( '', '--'+self.name, metavar='PROG', + parser.add_option( '--'+self.name, metavar='PROG', help='[%s]' % (self.pathname), action='callback', callback=self.cli_callback, type='str' ) @@ -725,7 +749,7 @@ class SelectTool( Action ): self.msg_end = 'not found' def cli_add_option( self, parser ): - parser.add_option( '', '--'+self.name, metavar='MODE', + parser.add_option( '--'+self.name, metavar='MODE', help='select %s mode: %s' % (self.name,self.toString()), action='callback', callback=self.cli_callback, type='str' ) @@ -770,16 +794,25 @@ class ConfigDocument: def __init__( self ): self._elements = [] - def _outputMake( self, file, namelen, name, value ): - file.write( '%-*s = %s\n' % (namelen, name, value )) + def _outputMake( self, file, namelen, name, value, append ): + if append: + if value == None or len(str(value)) == 0: + file.write( '%-*s +=\n' % (namelen, name) ) + else: + file.write( '%-*s += %s\n' % (namelen, name, value) ) + else: + if value == None or len(str(value)) == 0: + file.write( '%-*s =\n' % (namelen, name) ) + else: + file.write( '%-*s = %s\n' % (namelen, name, value) ) def _outputM4( self, file, namelen, name, value ): namelen += 7 name = '<<__%s>>,' % name.replace( '.', '_' ) file.write( 'define(%-*s <<%s>>)dnl\n' % (namelen, name, value )) - def add( self, name, value ): - self._elements.append( (name,value) ) + def add( self, name, value, append=False ): + self._elements.append( [name,value,append] ) def addBlank( self ): self._elements.append( None ) @@ -816,7 +849,16 @@ class ConfigDocument: if type == 'm4': self._outputM4( file, namelen, item[0], item[1] ) else: - self._outputMake( file, namelen, item[0], item[1] ) + self._outputMake( file, namelen, item[0], item[1], item[2] ) + + def update( self, name, value ): + for item in self._elements: + if item == None: + continue + if item[0] == name: + item[1] = value + return + raise ValueError( 'element not found: %s' % (name) ) def write( self, type ): if type == 'make': @@ -852,45 +894,79 @@ class ConfigDocument: ## ## create cli parser ## + +## class to hook options and create CONF.args list +class Option( optparse.Option ): + conf_args = [] + + def _conf_record( self, opt, value ): + ## skip conf,force,launch + if re.match( '^--(conf|force|launch).*$', opt ): + return + + ## remove duplicates (last duplicate wins) + for i,arg in enumerate( Option.conf_args ): + if opt == arg[0]: + del Option.conf_args[i] + break + + if value: + Option.conf_args.append( [opt,'%s=%s' % (opt,value)] ) + else: + Option.conf_args.append( [opt,'%s' % (opt)] ) + + def take_action( self, action, dest, opt, value, values, parser ): + self._conf_record( opt, value ) + return optparse.Option.take_action( self, action, dest, opt, value, values, parser ) + def createCLI(): cli = OptionParser( 'usage: %prog [OPTIONS...] [TARGETS...]' ) + cli.option_class = Option cli.description = '' cli.description += 'Configure %s build system.' % (project.name) ## add hidden options - cli.add_option( '', '--conf-method', default='terminal', action='store', help=optparse.SUPPRESS_HELP ) - cli.add_option( '', '--force', default=False, action='store_true', help='overwrite existing build config' ) - cli.add_option( '', '--verbose', default=False, action='store_true', help='increase verbosity' ) + cli.add_option( '--conf-method', default='terminal', action='store', help=optparse.SUPPRESS_HELP ) + cli.add_option( '--force', default=False, action='store_true', help='overwrite existing build config' ) + cli.add_option( '--verbose', default=False, action='store_true', help='increase verbosity' ) ## add install options grp = OptionGroup( cli, 'Directory Locations' ) - grp.add_option( '', '--src', default=cfg.src_dir, action='store', metavar='DIR', + grp.add_option( '--src', default=cfg.src_dir, action='store', metavar='DIR', help='specify top-level source dir [%s]' % (cfg.src_dir) ) - grp.add_option( '', '--build', default=cfg.build_dir, action='store', metavar='DIR', + grp.add_option( '--build', default=cfg.build_dir, action='store', metavar='DIR', help='specify build scratch/output dir [%s]' % (cfg.build_dir) ) - grp.add_option( '', '--prefix', default=cfg.prefix_dir, action='store', metavar='DIR', + grp.add_option( '--prefix', default=cfg.prefix_dir, action='store', metavar='DIR', help='specify install dir for products [%s]' % (cfg.prefix_dir) ) cli.add_option_group( grp ) ## add feature options grp = OptionGroup( cli, 'Feature Options' ) - h = ForHost( optparse.SUPPRESS_HELP, ['disable Xcode (Darwin only)','*-*-darwin*'] ).value - grp.add_option( '', '--disable-xcode', default=False, action='store_true', help=h ) - h = ForHost( optparse.SUPPRESS_HELP, ['disable GTK GUI (Linux only)','*-*-linux*'] ).value - grp.add_option( '', '--disable-gtk', default=False, action='store_true', help=h ) + + h = IfHost( 'enable assembly code in non-contrib modules', 'NOMATCH*-*-darwin*', 'NOMATCH*-*-linux*', none=optparse.SUPPRESS_HELP ).value + grp.add_option( '--enable-asm', default=False, action='store_true', help=h ) + + h = IfHost( 'disable GTK GUI', '*-*-linux*', none=optparse.SUPPRESS_HELP ).value + grp.add_option( '--disable-gtk', default=False, action='store_true', help=h ) + h = IfHost( 'enable GTK GUI (mingw)', '*-*-mingw*', none=optparse.SUPPRESS_HELP ).value + grp.add_option( '--enable-gtk-mingw', default=False, action='store_true', help=h ) + + h = IfHost( 'disable Xcode', '*-*-darwin*', none=optparse.SUPPRESS_HELP ).value + grp.add_option( '--disable-xcode', default=False, action='store_true', help=h ) + cli.add_option_group( grp ) ## add launch options grp = OptionGroup( cli, 'Launch Options' ) - grp.add_option( '', '--launch', default=False, action='store_true', + grp.add_option( '--launch', default=False, action='store_true', help='launch build, capture log and wait for completion' ) - grp.add_option( '', '--launch-jobs', default=1, action='store', metavar='N', type='int', + grp.add_option( '--launch-jobs', default=1, action='store', metavar='N', type='int', help='allow N jobs at once; 0 to match CPU count [1]' ) - grp.add_option( '', '--launch-args', default=None, action='store', metavar='ARGS', + grp.add_option( '--launch-args', default=None, action='store', metavar='ARGS', help='specify additional ARGS for launch command' ) - grp.add_option( '', '--launch-quiet', default=False, action='store_true', - help='do not echo build output' ) + grp.add_option( '--launch-quiet', default=False, action='store_true', + help='do not echo build output while waiting' ) cli.add_option_group( grp ) ## add compile options @@ -898,6 +974,8 @@ def createCLI(): debugMode.cli_add_option( grp, '--debug' ) optimizeMode.cli_add_option( grp, '--optimize' ) arch.mode.cli_add_option( grp, '--arch' ) + grp.add_option( '--cross', default=None, action='store', metavar='SPEC', + help='specify GCC cross-compilation spec' ) cli.add_option_group( grp ) ## add tool locations @@ -1038,19 +1116,22 @@ try: ar = ToolProbe( 'AR.exe', 'ar' ) cp = ToolProbe( 'CP.exe', 'cp' ) curl = ToolProbe( 'CURL.exe', 'curl', abort=False ) - gcc = ToolProbe( 'GCC.gcc', 'gcc', IfHost('gcc-4','*-*-cygwin*') ) + gcc = ToolProbe( 'GCC.gcc', 'gcc', IfHost( 'gcc-4', '*-*-cygwin*' )) if host.match( '*-*-darwin*' ): gmake = ToolProbe( 'GMAKE.exe', 'make', 'gmake' ) else: gmake = ToolProbe( 'GMAKE.exe', 'gmake', 'make' ) - m4 = ToolProbe( 'M4.exe', 'm4' ) - mkdir = ToolProbe( 'MKDIR.exe', 'mkdir' ) - patch = ToolProbe( 'PATCH.exe', 'gpatch', 'patch' ) - rm = ToolProbe( 'RM.exe', 'rm' ) - tar = ToolProbe( 'TAR.exe', 'gtar', 'tar' ) - wget = ToolProbe( 'WGET.exe', 'wget', abort=False ) + m4 = ToolProbe( 'M4.exe', 'm4' ) + mkdir = ToolProbe( 'MKDIR.exe', 'mkdir' ) + patch = ToolProbe( 'PATCH.exe', 'gpatch', 'patch' ) + rm = ToolProbe( 'RM.exe', 'rm' ) + ranlib = ToolProbe( 'RANLIB.exe', 'ranlib' ) + strip = ToolProbe( 'STRIP.exe', 'strip' ) + tar = ToolProbe( 'TAR.exe', 'gtar', 'tar' ) + wget = ToolProbe( 'WGET.exe', 'wget', abort=False ) + yasm = ToolProbe( 'YASM.exe', 'yasm', abort=False ) xcodebuild = ToolProbe( 'XCODEBUILD.exe', 'xcodebuild', abort=False ) lipo = ToolProbe( 'LIPO.exe', 'lipo', abort=False ) @@ -1084,6 +1165,12 @@ try: else: targets.append( arg ) + ## re-run tools with cross-compilation needs + if options.cross: + for tool in ( Tools.ar, Tools.gcc, Tools.ranlib, Tools.strip ): + tool.__init__( tool.var, '%s-%s' % (options.cross,tool.name), **tool.kwargs ) + tool.run() + ## run delayed actions for action in Action.actions: action.run() @@ -1098,10 +1185,8 @@ try: ## add configure line for reconfigure purposes doc.addBlank() args = [] - for arg in sys.argv[1:]: - if arg == '--launch': - continue - args.append( arg ) + for arg in Option.conf_args: + args.append( arg[1] ) doc.add( 'CONF.args', ' '.join( args )) doc.addBlank() @@ -1153,14 +1238,19 @@ try: doc.add( 'BUILD.systemf', build.systemf ) doc.add( 'BUILD.release', build.release ) doc.add( 'BUILD.extra', build.extra ) - doc.add( 'BUILD.title', '%s %s' % (build.systemf,arch.mode.mode) ) + doc.add( 'BUILD.title', build.title ) doc.add( 'BUILD.ncpu', core.count ) doc.add( 'BUILD.jobs', core.jobs ) - doc.add( 'BUILD.cross', int(arch.mode.mode != arch.mode.default) ) - doc.add( 'BUILD.method', 'terminal' ) - doc.add( 'BUILD.date', time.strftime('%c') ) - doc.add( 'BUILD.arch', arch.mode.mode ) + doc.add( 'BUILD.cross', int(options.cross != None or arch.mode.mode != arch.mode.default) ) + if options.cross: + doc.add( 'BUILD.cross.prefix', '%s-' % (options.cross) ) + else: + doc.add( 'BUILD.cross.prefix', '' ) + + doc.add( 'BUILD.method', 'terminal' ) + doc.add( 'BUILD.date', time.strftime('%c') ) + doc.add( 'BUILD.arch', arch.mode.mode ) doc.addBlank() doc.add( 'CONF.method', options.conf_method ) @@ -1174,8 +1264,10 @@ try: doc.add( 'PREFIX/', cfg.prefix_final + os.sep ) doc.addBlank() - doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode) )) + doc.add( 'FEATURE.asm', 'disabled' ) doc.add( 'FEATURE.gtk', int( not options.disable_gtk )) + doc.add( 'FEATURE.gtk.mingw', int( options.enable_gtk_mingw )) + doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode or options.cross) )) if not Tools.xcodebuild.fail and not options.disable_xcode: doc.addBlank() @@ -1203,6 +1295,29 @@ try: doc.add( 'GCC.g', debugMode.mode ) doc.add( 'GCC.O', optimizeMode.mode ) + if options.enable_asm and not Tools.yasm.fail: + asm = '' + if build.match( 'i?86-*' ): + asm = 'x86' + doc.add( 'LIBHB.GCC.D', 'HAVE_MMX', append=True ) + doc.add( 'LIBHB.YASM.D', 'ARCH_X86', append=True ) + if build.match( '*-*-darwin*' ): + doc.add( 'LIBHB.YASM.f', 'macho32' ) + else: + doc.add( 'LIBHB.YASM.f', 'elf32' ) + doc.add( 'LIBHB.YASM.m', 'x86' ) + elif build.match( 'x86_64-*' ): + asm = 'x86' + doc.add( 'LIBHB.GCC.D', 'HAVE_MMX ARCH_X86_64', append=True ) + if build.match( '*-*-darwin*' ): + doc.add( 'LIBHB.YASM.D', 'ARCH_X86_64 PIC', append=True ) + doc.add( 'LIBHB.YASM.f', 'macho64' ) + else: + doc.add( 'LIBHB.YASM.D', 'ARCH_X86_64', append=True ) + doc.add( 'LIBHB.YASM.f', 'elf64' ) + doc.add( 'LIBHB.YASM.m', 'amd64' ) + doc.update( 'FEATURE.asm', asm ) + ## add exports to make if len(exports): doc.addBlank()