def am_dep(fd, t, deplist, am, pref = ''): rv = [] t = t.replace('\\', '/') n = t.replace('.o', '.lo', 1) f,ext = rsplit_filename(n) if t != n and not pref: fd.write(t + " ") rv.append(t) fd.write(pref + n + ":") rv.append(pref + n) for d in deplist: if not posixpath.isabs(d): fd.write(" " + am_translate_dir(d, am)) else: print("!WARNING: dropped absolute dependency " + d) fd.write("\n") return rv
def msc_scripts(fd, var, scripts, msc): s, ext = var.split('_', 1) ext = [ext] if "EXT" in scripts: ext = scripts["EXT"] # list of extentions sd = "bindir" if "DIR" in scripts: sd = scripts["DIR"][0] # use first name given sd = msc_translate_dir(sd, msc) for script in scripts['TARGETS']: s, ext2 = rsplit_filename(script) if not ext2 in ext: continue if script in msc['INSTALL']: continue if os.path.isfile(os.path.join(msc['cwd'], script + '.in')): inf = '$(srcdir)\\%s.in' % script if inf not in msc['_IN']: # TODO # replace this hack by something like configure ... fd.write('%s: "$(TOPDIR)\\winconfig_conds.py" "%s"\n' % (script, inf)) fd.write('\t$(CONFIGURE) "%s" > "%s"\n' % (inf, script)) msc['_IN'].append(inf) elif os.path.isfile(os.path.join(msc['cwd'], script)): fd.write('%s: "$(srcdir)\\%s"\n' % (script, script)) fd.write('\t$(INSTALL) "$(srcdir)\\%s" "%s"\n' % (script, script)) if 'COND' in scripts: condname = 'defined(' + ') && defined('.join(scripts['COND']) + ')' mkname = script.replace('.', '_').replace('-', '_') fd.write('!IF %s\n' % condname) fd.write('C_%s = %s\n' % (mkname, script)) fd.write('!ELSE\n') fd.write('C_%s =\n' % mkname) fd.write('!ENDIF\n') cscript = '$(C_%s)' % mkname else: cscript = script condname = '' if not 'NOINST' in scripts and not 'NOINST_MSC' in scripts: msc['INSTALL'][script] = cscript, '', sd, '', condname msc['SCRIPTS'].append(cscript)
def msc_scripts(fd, var, scripts, msc): s, ext = var.split('_', 1); ext = [ ext ] if "EXT" in scripts: ext = scripts["EXT"] # list of extentions sd = "bindir" if "DIR" in scripts: sd = scripts["DIR"][0] # use first name given sd = msc_translate_dir(sd, msc) for script in scripts['TARGETS']: s,ext2 = rsplit_filename(script) if not ext2 in ext: continue if script in msc['INSTALL']: continue if os.path.isfile(os.path.join(msc['cwd'], script+'.in')): inf = '$(srcdir)\\%s.in' % script if inf not in msc['_IN']: # TODO # replace this hack by something like configure ... fd.write('%s: "$(TOPDIR)\\winconfig_conds.py" "%s"\n' % (script, inf)) fd.write('\t$(CONFIGURE) "%s" > "%s"\n' % (inf, script)) msc['_IN'].append(inf) elif os.path.isfile(os.path.join(msc['cwd'], script)): fd.write('%s: "$(srcdir)\\%s"\n' % (script, script)) fd.write('\t$(INSTALL) "$(srcdir)\\%s" "%s"\n' % (script, script)) if 'COND' in scripts: condname = 'defined(' + ') && defined('.join(scripts['COND']) + ')' mkname = script.replace('.', '_').replace('-', '_') fd.write('!IF %s\n' % condname) fd.write('C_%s = %s\n' % (mkname, script)) fd.write('!ELSE\n') fd.write('C_%s =\n' % mkname) fd.write('!ENDIF\n') cscript = '$(C_%s)' % mkname else: cscript = script condname = '' if not 'NOINST' in scripts and not 'NOINST_MSC' in scripts: msc['INSTALL'][script] = cscript, '', sd, '', condname msc['SCRIPTS'].append(cscript)
def am_extra_dist(fd, var, values, am): for i in values: am['EXTRA_DIST'].append(i) t, ext = rsplit_filename(i) if ext == 'in': am['OutList'].append(am['CWD']+t)
def am_scripts(fd, var, scripts, am): #todo handle 'EXT' for empty ''. s, ext = var.split('_', 1) ext = [ ext ] if "EXT" in scripts: ext = scripts["EXT"] # list of extentions sd = "bindir" if "DIR" in scripts: sd = scripts["DIR"][0] # use first name given sd = am_translate_dir(sd, am) for src in scripts['SOURCES']: am['EXTRA_DIST'].append(src) for script in scripts['TARGETS']: s,ext2 = rsplit_filename(script) if not ext2 in ext: continue cond = '' s = script scriptname = "script_" + script if 'COND' in scripts: condname = '+'.join(scripts['COND']) mkname = am_normalize(script.replace('.', '_')) cond = '#' + condname s = "$(C_" + mkname + ")" scriptname = "$(C_script_" + mkname + ")" name = "script_" + script if scriptname not in am['BIN_SCRIPTS'] and name not in am['BIN_SCRIPTS']: am['BIN_SCRIPTS'].append(scriptname) else: continue if cond: fd.write("uninstall-local-:\n") fd.write("install-exec-local-:\n") for condname in scripts['COND']: fd.write("if %s\n" % condname) fd.write(" C_%s = %s\n" % (mkname,script)) fd.write(" C_script_%s = script_%s\n" % (mkname, script)) for condname in scripts['COND']: fd.write("endif\n") if not os.path.exists(os.path.join(am['CWDRAW'], script)): am['BUILT_SOURCES'].append("$(C_" +mkname+ ")") am['CLEAN'].append("$(C_" +mkname+ ")") else: am['BUILT_SOURCES'].append(script) # add dependency on library for mil modules fd.write("script_%s: %s\n" % (script, script)) # a bit of a hack .... if sd == "$(sysconfdir)": fd.write("install-exec-local-%s: %s\n" % (script, script)) fd.write("\t-mkdir -p $(DESTDIR)%s\n" % sd) fd.write("\t$(INSTALL) $(INSTALL_BACKUP) $< $(DESTDIR)%s/%s\n\n" % (sd, script)) fd.write("uninstall-local-%s: \n" % script) fd.write("\t$(RM) $(DESTDIR)%s/%s\n\n" % (sd, script)) else: fd.write("install-exec-local-%s: %s\n" % (script, script)) fd.write("\t-mkdir -p $(DESTDIR)%s\n" % sd) fd.write("\t-$(RM) $(DESTDIR)%s/%s\n" % (sd, script)) fd.write("\t$(INSTALL) -m0755 $< $(DESTDIR)%s/%s\n\n" % (sd, script)) fd.write("uninstall-local-%s: \n" % script) fd.write("\t$(RM) $(DESTDIR)%s/%s\n\n" % (sd, script)) if 'NOINST' not in scripts: am['INSTALL'].append(s) am['UNINSTALL'].append(s) am['InstallList'].append("\t"+sd+"/"+script+cond+"\n") am_find_ins(am, scripts) am_deps(fd, scripts['DEPS'], am)
def needbuildtool(deplist): for d in deplist: f,ext = rsplit_filename(d) if ext in buildtools_ext: return 1 return 0
def am_find_ins(am, map): for source in map['SOURCES']: t, ext = rsplit_filename(source) if ext == 'in': am['OutList'].append(am['CWD']+t)