shithub: mc

Download patch

ref: 734d2e4ffd947e1a5fd73ae22029d3b0647be290
parent: adbf2578946f1658b3dd044f62e31a8689e8671e
author: Ori Bernstein <[email protected]>
date: Tue Feb 19 06:17:27 EST 2013

Add system dependent behavior to myrbuild.

    It probes the OS it runs on now, and changes the commands to
    the appropriate ones. For now, that means changing the linker
    command line to specify the OSX version.

    In the future, when we support multiple architectures, it will
    include probing the architecture as well.

--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -6,6 +6,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
+#include <sys/utsname.h>
 #include <ctype.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -38,6 +39,8 @@
 /* the linker script to use */
 char *ldscript;
 
+char *sysname;
+
 regex_t usepat;
 
 static void usage(char *prog)
@@ -326,6 +329,14 @@
         snprintf(buf, sizeof buf, "-l%s", libs[i]);
         lappend(&args, &nargs, strdup(buf));
     }
+
+    /* OSX wants a minimum version specified to prevent warnings*/
+    if (!strcmp(sysname, "Darwin")) {
+        lappend(&args, &nargs, strdup("-macosx_version_min"));
+        lappend(&args, &nargs, strdup("10.6"));
+    }
+
+    /* the null terminator for exec() */
     lappend(&args, &nargs, NULL);
 
     run(args);
@@ -339,7 +350,10 @@
 {
     int opt;
     int i;
+    struct utsname name;
 
+    if (uname(&name) == 0)
+        sysname = strdup(name.sysname);
     while ((opt = getopt(argc, argv, "hb:l:s:I:C:A:M:L:R:")) != -1) {
         switch (opt) {
             case 'b': binname = optarg; break;