📄 gen_make.py
字号:
if isinstance(target_ob, gen_base.TargetJava): self.ofile.write( '%s_HEADERS = %s\n' '%s_OBJECTS = %s\n' '%s_DEPS = $(%s_HEADERS) $(%s_OBJECTS) %s %s\n' '%s: $(%s_DEPS)\n' % (targ_varname, string.join(headers), targ_varname, string.join(objects), targ_varname, targ_varname, targ_varname, target_ob.add_deps, string.join(deps), target_ob.name, targ_varname)) # Build the headers from the header_classes with one 'javah' call if headers: self.ofile.write( '%s_CLASS_FILENAMES = %s\n' '%s_CLASSES = %s\n' '$(%s_HEADERS): $(%s_CLASS_FILENAMES)\n' '\t%s -d %s -classpath %s:$(%s_CLASSPATH) $(%s_CLASSES)\n' % (targ_varname, string.join(header_class_filenames), targ_varname, string.join(header_classes), targ_varname, targ_varname, target_ob.link_cmd, target_ob.output_dir, target_ob.classes, targ_varname, targ_varname)) # Build the objects from the object_srcs with one 'javac' call if object_srcs: self.ofile.write( '%s_SRC = %s\n' '$(%s_OBJECTS): $(%s_SRC)\n' '\t%s -d %s -classpath %s:$(%s_CLASSPATH) $(%s_SRC)\n' % (targ_varname, string.join(object_srcs), targ_varname, targ_varname, target_ob.link_cmd, target_ob.output_dir, target_ob.classes, targ_varname, targ_varname)) # Once the bytecodes have been compiled up, we produce the # JAR. if target_ob.jar: self.ofile.write('\n\t$(JAR) cf %s -C %s %s' % (build_path_join(target_ob.classes, target_ob.jar), target_ob.classes, string.join(target_ob.packages, ' '))) self.ofile.write('\n\n') elif isinstance(target_ob, gen_base.TargetI18N): self.ofile.write( '%s_DEPS = %s %s\n' '%s: $(%s_DEPS)\n\n' % (targ_varname, target_ob.add_deps, string.join(objects + deps), target_ob.name, targ_varname)) else: self.ofile.write( '%s_DEPS = %s %s\n' '%s_OBJECTS = %s\n' '%s: $(%s_DEPS)\n' '\tcd %s && %s -o %s %s $(%s_OBJECTS) %s $(LIBS)\n\n' % (targ_varname, target_ob.add_deps, string.join(objects + deps), targ_varname, objnames, target_ob.filename, targ_varname, path, target_ob.link_cmd, build_path_basename(target_ob.filename), (isinstance(target_ob, gen_base.TargetLib) and not target_ob.undefined_lib_symbols) and '$(LT_NO_UNDEFINED)' or "", targ_varname, string.join(gen_base.unique(libs))) ) ######################################## self.begin_section('Install-Group build targets') for itype, i_targets in install_deps: # perl bindings do their own thing, "swig-pl" target is # already specified in Makefile.in if itype == "swig-pl": continue outputs = [ ] for t in i_targets: if hasattr(t, 'filename'): outputs.append(t.filename) self.ofile.write('%s: %s\n\n' % (itype, string.join(outputs))) ######################################## self.begin_section('Install-Group install targets') # for each install group, write a rule to install its outputs for area, inst_targets in install_deps: # perl bindings do their own thing, "install-swig-pl" target is # already specified in Makefile.in if area == "swig-pl": continue # get the output files for these targets, sorted in dependency order files = gen_base._sorted_files(self.graph, area) if area == 'apache-mod': self.ofile.write('install-mods-shared: %s\n' % (string.join(files),)) la_tweaked = { } for file in files: # cd to dirname before install to work around libtool 1.4.2 bug. dirname, fname = build_path_splitfile(file) base, ext = os.path.splitext(fname) name = string.replace(base, 'mod_', '') self.ofile.write('\tcd %s ; ' '$(MKDIR) "$(APACHE_LIBEXECDIR)" ; ' '$(INSTALL_MOD_SHARED) -n %s %s\n' % (dirname, name, fname)) if ext == '.la': la_tweaked[file + '-a'] = None for apmod in inst_targets: for source in self.graph.get_sources(gen_base.DT_LINK, apmod.name, gen_base.Target): if not source.external_lib: bt = source.filename if bt[-3:] == '.la': la_tweaked[bt + '-a'] = None la_tweaked = la_tweaked.keys() la_tweaked.sort() # Construct a .libs directory within the Apache area and populate it # with the appropriate files. Also drop the .la file in the target dir. self.ofile.write('\ninstall-mods-static: %s\n' '\t$(MKDIR) $(DESTDIR)%s\n' % (string.join(la_tweaked + self.apache_files), build_path_join('$(APACHE_TARGET)', '.libs'))) for file in la_tweaked: dirname, fname = build_path_splitfile(file) base = os.path.splitext(fname)[0] self.ofile.write('\t$(INSTALL_MOD_STATIC) %s $(DESTDIR)%s\n' '\t$(INSTALL_MOD_STATIC) %s $(DESTDIR)%s\n' % (build_path_join(dirname, '.libs', base + '.a'), build_path_join('$(APACHE_TARGET)', '.libs', base + '.a'), file, build_path_join('$(APACHE_TARGET)', base + '.la'))) # copy the other files to the target dir for file in self.apache_files: self.ofile.write('\t$(INSTALL_MOD_STATIC) %s $(DESTDIR)%s\n' % (file, build_path_join('$(APACHE_TARGET)', build_path_basename(file)))) self.ofile.write('\n') elif area != 'test' and area != 'bdb-test': area_var = string.replace(area, '-', '_') upper_var = string.upper(area_var) self.ofile.write('install-%s: %s\n' '\t$(MKDIR) $(DESTDIR)$(%sdir)\n' % (area, string.join(files), area_var)) for file in files: # cd to dirname before install to work around libtool 1.4.2 bug. dirname, fname = build_path_splitfile(file) if area == 'locale': lang, objext = os.path.splitext(fname) installdir = '$(DESTDIR)$(%sdir)/%s/LC_MESSAGES' % (area_var, lang) self.ofile.write('\t$(MKDIR) %s\n' '\tcd %s ; $(INSTALL_%s) %s ' '%s/$(PACKAGE_NAME)%s\n' % (installdir, dirname, upper_var, fname, installdir, objext)) else: self.ofile.write('\tcd %s ; $(INSTALL_%s) %s $(DESTDIR)%s\n' % (dirname, upper_var, fname, build_path_join('$(%sdir)' % area_var, fname))) # certain areas require hooks for extra install rules defined # in Makefile.in ### we should turn AREA into an object, then test it instead of this if area[:5] == 'swig-' and area[-4:] != '-lib' or \ area[:7] == 'javahl-': self.ofile.write('\t$(INSTALL_EXTRA_%s)\n' % upper_var) self.ofile.write('\n') ######################################## self.begin_section('The install-include rule') includedir = build_path_join('$(includedir)', 'subversion-%s' % self.version) self.ofile.write('install-include: %s\n' '\t$(MKDIR) $(DESTDIR)%s\n' % (string.join(self.includes), includedir)) for file in self.includes: self.ofile.write('\t$(INSTALL_INCLUDE) %s $(DESTDIR)%s\n' % (build_path_join('$(abs_srcdir)', file), build_path_join(includedir, build_path_basename(file)))) ######################################## self.begin_section('Shortcut targets for manual builds of specific items') for target in install_sources: if not isinstance(target, gen_base.TargetScript) and \ not isinstance(target, gen_base.TargetJava) and \ not isinstance(target, gen_base.TargetI18N): self.ofile.write('%s: %s\n' % (target.name, target.filename)) ######################################## self.begin_section('Rules to build all other kinds of object-like files') # write dependencies and build rules (when not using suffix rules) # for all other generated files which will not be installed # (or will be installed, but not by the main generated build) obj_deps = self.graph.get_deps(gen_base.DT_OBJECT) obj_deps.sort(lambda (t1, s1), (t2, s2): cmp(t1.filename, t2.filename)) for objname, sources in obj_deps: deps = string.join(map(str, sources)) self.ofile.write('%s: %s\n' % (objname, deps)) cmd = objname.compile_cmd if cmd: if not getattr(objname, 'source_generated', 0): self.ofile.write('\t%s %s\n\n' % (cmd, build_path_join('$(abs_srcdir)', str(sources[0])))) else: self.ofile.write('\t%s %s\n\n' % (cmd, sources[0])) else: self.ofile.write('\n') self.ofile.close() self.write_standalone() def write_standalone(self): """Write autogen-standalone.mk""" standalone = open("autogen-standalone.mk", "w") standalone.write('# DO NOT EDIT -- AUTOMATICALLY GENERATED\n') standalone.write('abs_srcdir = %s\n' % os.getcwd()) standalone.write('abs_builddir = %s\n' % os.getcwd()) standalone.write('top_srcdir = .\n') standalone.write('top_builddir = .\n') standalone.write('SWIG = swig\n') standalone.write('PYTHON = python\n') standalone.write('\n') standalone.write(open("build-outputs.mk","r").read()) standalone.close()class UnknownDependency(Exception): "We don't know how to deal with the dependent to link it in." pass### End of file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -