[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#147196: boot-floppies: mklibs.py cross compiling



Package: boot-floppies
Version: N/A
Severity: normal

i add cross compile support to mklibs.py, also i fix some other
failures.

bastian

--- mklibs.py.orig	Thu Feb 28 16:53:02 2002
+++ mklibs.py	Sun Mar 17 18:50:49 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]
@@ -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,20 +357,20 @@
         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":
-                extra_flags = find_lib(os.getenv("ldlib"))
-                extra_pre_obj = "/usr/lib/libc_pic/soinit.o"
-                extra_post_obj = "/usr/lib/libc_pic/sofini.o"
+                extra_flags = find_lib(ldlib)
+                extra_pre_obj = libc_extras_dir + "/soinit.o"
+                extra_post_obj = libc_extras_dir + "/sofini.o"
             else:
                 extra_flags = ""
                 extra_pre_obj = ""
@@ -367,7 +383,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", \
@@ -379,7 +395,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
@@ -396,6 +412,6 @@
     os.remove(dest_path + "/" + lib)
 
 # Make the dynamic linker executable
-ld_file = find_lib(os.getenv("ldlib"))
+ld_file = find_lib(ldlib)
 ld_file_name = os.path.basename(ld_file)
 os.chmod(dest_path + "/" + ld_file_name, 0755)

Attachment: pgpJcYyXavCRM.pgp
Description: PGP signature


Reply to: