Index: build/generator/gen_make.py =================================================================== --- build/generator/gen_make.py (revision 11043) +++ build/generator/gen_make.py (working copy) @@ -23,6 +23,28 @@ def default_output(self, conf_path): return os.path.splitext(os.path.basename(conf_path))[0] + '-outputs.mk' + # Get the installed location of each file as a dictionary + def get_install_map(self, install_deps): + install_map = { } + + # Build a map that details where to install each file + for area, inst_targets in install_deps: + area_var = string.replace(area, '-', '_') + + # Store the installed location of each file in 'install_map' + for file in gen_base._sorted_files(self.graph, area): + dirname, fname = build_path_splitfile(file) + if area == 'locale': + lang, objext = os.path.splitext(fname) + install_map[file] = build_path_join("$(DESTDIR)%s" % area_var, + lang, 'LC_MESSAGES', '$(PACKAGE_NAME)%s' % objext) + else: + install_map[file] = \ + build_path_join("$(DESTDIR)$(%sdir)" % area_var, fname) + + return install_map + + def write(self, oname): install_deps = self.graph.get_deps(gen_base.DT_INSTALL) install_sources = self.graph.get_all_sources(gen_base.DT_INSTALL) @@ -31,12 +53,15 @@ install_deps.sort() install_sources.sort(lambda s1, s2: cmp(s1.name, s2.name)) + # Get the installed location of each file as a dictionary + install_map = self.get_install_map(install_deps) + self.ofile = open(oname, 'w') self.ofile.write('# DO NOT EDIT -- AUTOMATICALLY GENERATED\n\n') # write various symbols at the top of the file so they will be # defined before their use in dependency lines. - self.write_symbols(install_sources) + self.write_symbols(install_sources, install_map) # write rules to build each installable item for target_ob in install_sources: @@ -142,6 +167,16 @@ targ_varname, string.join(gen_base.unique(libs))) ) + # Output installation dependencies + ob_install_deps = string.join( + [ install_map[file] for file in deps if install_map.has_key(file) ]) + self.ofile.write("%s_INSTALL_DEPS = %s %s\n" + % (targ_varname, target_ob.add_install_deps, ob_install_deps)) + if (hasattr(target_ob, 'filename') + and install_map.has_key(target_ob.filename)): + self.ofile.write('%s: $(%s_DEPS) $(%s_INSTALL_DEPS)\n\n' + % (install_map[target_ob.filename], targ_varname, targ_varname)) + # for each install group, write a rule to build its outputs for itype, i_targets in install_deps: @@ -188,7 +223,9 @@ for target_dep in self.graph.get_sources(gen_base.DT_LINK, target.name, gen_base.TargetLib): if target_dep.install and target_dep.install != area: - inst_area_deps['install-%s' % target_dep.install] = None + for file in gen_base._sorted_files(self.graph, target_dep.install): + inst_area_deps[install_map[file]] = None + inst_area_deps = inst_area_deps.keys() if area == 'apache-mod': @@ -242,24 +279,31 @@ 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 + inst_area_deps), - area_var)) + + # Install the target by installing its files + self.ofile.write('install-%s: %s\n' + % (area, string.join([ install_map[file] for file in files ]))) + + # Write install rules for each file 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) - self.ofile.write('\tcd %s ; $(INSTALL_%s) %s ' - '$(DESTDIR)%s/%s/LC_MESSAGES/$(PACKAGE_NAME)%s\n' - % (dirname, upper_var, fname, - build_path_join('$(%sdir)' % area_var), lang, - objext)) + self.ofile.write( + '%s: %s\n' + '\tcd %s ; $(INSTALL_%s) %s %s\n' + % (install_map[file], string.join(files + inst_area_deps), + dirname, upper_var, fname, install_map[file])) else: - self.ofile.write('\tcd %s ; $(INSTALL_%s) %s $(DESTDIR)%s\n' - % (dirname, upper_var, fname, - build_path_join('$(%sdir)' % area_var, fname))) + self.ofile.write( + '%s: %s\n' + '\t$(MKDIR) $(DESTDIR)$(%sdir)\n' + '\tcd %s ; $(INSTALL_%s) %s %s\n' + % (install_map[file], string.join(files + inst_area_deps), + area_var, + dirname, upper_var, fname, install_map[file])) + # 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 @@ -360,7 +404,7 @@ else: self.ofile.write('\n') - def write_symbols(self, install_sources): + def write_symbols(self, install_sources, install_map): wrappers = { } for lang in self.swig_lang: wrappers[lang] = [ ] @@ -382,8 +426,11 @@ link.append(build_path_join(retreat, source.filename)) self.ofile.write('%s_DEPS = %s\n' - '%s_LINK = %s\n\n' % (name, string.join(deps, ' '), - name, string.join(link, ' '))) + '%s_INSTALL_DEPS = %s\n' + '%s_LINK = %s\n\n' + % (name, string.join(deps, ' '), + name, string.join([ install_map[file] for file in deps]), + name, string.join(link, ' '))) elif isinstance(target, gen_base.TargetSWIG): wrappers[target.lang].append(target)