On Fri, May 17, 2002 at 02:14:29AM -0700, Matt Kraai wrote:
> It doesn't apply cleanly to the latest CVS revision, and reverts
> a comment typo fix that I made some time ago. Would you please
> remove the reversion and regenerate it against the latest CVS
> revision?
i append the new patch
bastian
--- mklibs.py.orig Thu May 16 20:16:49 2002
+++ mklibs.py Thu May 16 20:24:26 2002
@@ -110,7 +110,7 @@
def library_depends(obj):
if not os.access(obj, os.F_OK):
raise "Cannot find lib: " + obj
- output = command("objdump", "--private-headers", obj)
+ output = command(target + "objdump", "--private-headers", obj)
return regexpfilter(output, ".*NEEDED\s*(\S+)$")
# Return a list of libraries the passed objects depend on. The
@@ -119,7 +119,7 @@
def library_depends_gcc_libnames(obj):
if not os.access(obj, os.F_OK):
raise "Cannot find lib: " + obj
- output = command("objdump", "--private-headers", obj)
+ output = command(target + "objdump", "--private-headers", obj)
output = filter(lambda x: string.find(x, "libm.so") == -1, output)
output = regexpfilter(output, ".*NEEDED\s*lib(\S+)\.so.*$")
if not output.elems():
@@ -131,7 +131,7 @@
def undefined_symbols(obj):
if not os.access(obj, os.F_OK):
raise "Cannot find lib" + obj
- output = command("readelf", "-s", obj)
+ output = command(target + "readelf", "-s", "-W", obj)
output = filter(lambda x: string.find(x, "NOTYPE") == -1, output)
output = filter(lambda x: string.find(x, "SECTION") == -1, output)
output = filter(lambda x: string.find(x, "ABS") == -1, output)
@@ -142,7 +142,7 @@
def provided_symbols(obj):
if not os.access(obj, os.F_OK):
raise "Cannot find lib" + obj
- output = command("readelf", "-s", obj)
+ output = command(target + "readelf", "-s", "-W", obj)
output = filter(lambda x: string.find(x, "UND") == -1, output)
output = filter(lambda x: string.find(x, "NOTYPE") == -1, output)
output = filter(lambda x: string.find(x, "SECTION") == -1, output)
@@ -199,6 +199,9 @@
## -v, --verbose Print additional progress information.
## -V, --version Print the version number and exit.
## -h, --help Print this help and exit.
+## --ldlib Name of dynamic linker (overwrites environment variable ldlib)
+## --libc-extras-dir Directory for libc extra files
+## --target Use as prefix for gcc or binutils calls
##
## -d, --dest-dir DIRECTORY Create libraries in DIRECTORY.
##
@@ -207,25 +210,38 @@
# Argument parsing
opts = "L:D:nvVhd:"
longopts = ["no-default-lib", "dry-run", "verbose", "version", "help",
- "dest-dir="]
+ "dest-dir=", "ldlib=", "libc-extras-dir=", "target="]
optlist, proglist = getopt.getopt(sys.argv[1:], opts, longopts)
# some global variables
lib_path = "/lib/", "/usr/lib/", "/usr/X11R6/lib/"
dest_path = "DEST"
+ldlib = "LDLIB"
+libc_extras_dir = "/usr/lib/libc_pic"
+target = ""
so_pattern = re.compile("(.*)\.so(\.\d+)*")
script_pattern = re.compile("^#!\s*/")
for opt, arg in optlist:
- if opt == "-v":
- debuglevel = DEBUG_VERBOSE
+ if opt in ("-v", "--verbose"):
+ if debuglevel < DEBUG_SPAM:
+ debuglevel += 1
elif opt == "-L":
lib_path = string.split(arg, ":")
elif opt in ("-d", "--dest-dir"):
dest_path = arg
+ elif opt == "--ldlib":
+ ldlib = arg
+ elif opt == "--libc-extras-dir":
+ libc_extras_dir = arg
+ elif opt == "--target":
+ target = arg + "-"
else:
print "WARNING: unknown option: " + opt + "\targ: " + arg
+if ldlib == "LDLIB":
+ ldlib = os.getenv("ldlib")
+
objects = {} # map from inode to filename
for prog in proglist:
inode = os.stat(prog)[ST_INO]
@@ -233,7 +249,7 @@
debug(DEBUG_SPAM, prog, "is a hardlink to", objects[inode])
elif so_pattern.match(prog):
debug(DEBUG_SPAM, prog, "is a library")
- elif script_pattern.match(open(prog).read(256)):
+ elif script_pattern.match(open(prog).read(256)):
debug(DEBUG_SPAM, prog, "is a script")
else:
objects[inode] = prog
@@ -272,7 +288,7 @@
# FIXME: on i386 this is undefined but not marked UND
# I don't know how to detect those symbols but this seems
- # to be the only one and including it on alpha as well
+ # to be the only one and including in on alpha as well
# doesn't hurt. I guess all archs can live with this.
needed_symbols.add("sys_siglist")
@@ -341,23 +357,22 @@
if not pic_file:
# No pic file, so we have to use the .so file, no reduction
debug(DEBUG_VERBOSE, "No pic file found for", so_file, "; copying")
- command("objcopy", "--strip-unneeded -R .note -R .comment",
+ command(target + "objcopy", "--strip-unneeded -R .note -R .comment",
so_file, dest_path + "/" + so_file_name + "-so-stripped")
else:
# we have a pic file, recompile
debug(DEBUG_SPAM, "extracting from:", pic_file, "so_file:", so_file)
- soname = regexpfilter(command("readelf", "--all", so_file),
+ soname = regexpfilter(command(target + "readelf", "--all", "-W", so_file),
".*SONAME.*\[(.*)\].*").elems()[0]
debug(DEBUG_SPAM, "soname:", soname)
base_name = so_pattern.match(library).group(1)
# libc needs its soinit.o and sofini.o as well as the pic
if base_name == "libc":
- ldlib = os.getenv("ldlib")
if not ldlib:
ldlib = "ld-" + re.match("libc-(.*).so", so_file_name).group(1) + ".so"
extra_flags = find_lib(ldlib)
- extra_pre_obj = "/usr/lib/libc_pic/soinit.o"
- extra_post_obj = "/usr/lib/libc_pic/sofini.o"
+ extra_pre_obj = libc_extras_dir + "/soinit.o"
+ extra_post_obj = libc_extras_dir + "/sofini.o"
else:
extra_flags = ""
extra_pre_obj = ""
@@ -370,7 +385,7 @@
else:
joined_symbols = ""
# compile in only used symbols
- command("gcc",
+ command(target + "gcc",
"-nostdlib -nostartfiles -shared -Wl,-soname=" + soname,\
joined_symbols, \
"-o", dest_path + "/" + so_file_name + "-so", \
@@ -382,7 +397,7 @@
"-L" + string.join(lib_path, " -L"), \
library_depends_gcc_libnames(so_file))
# strip result
- command("objcopy", "--strip-unneeded -R .note -R .comment",
+ command(target + "objcopy", "--strip-unneeded -R .note -R .comment",
dest_path + "/" + so_file_name + "-so",
dest_path + "/" + so_file_name + "-so-stripped")
## DEBUG
--
... bacteriological warfare ... hard to believe we were once foolish
enough to play around with that.
-- McCoy, "The Omega Glory", stardate unknown
Attachment:
pgpEngQM0KlL1.pgp
Description: PGP signature