summaryrefslogtreecommitdiff
path: root/cross/COMMON/buwrapper.c
diff options
context:
space:
mode:
authortv <tv@pkgsrc.org>1999-01-04 22:37:29 +0000
committertv <tv@pkgsrc.org>1999-01-04 22:37:29 +0000
commitccc8b400719974af8670fac0704ae6587690ecd7 (patch)
treef6d6b811a4c9cc20cd3b49a70a233e6958d1095b /cross/COMMON/buwrapper.c
parent63c78674b53510ff581ef5426e739a2a1e3536bc (diff)
downloadpkgsrc-ccc8b400719974af8670fac0704ae6587690ecd7.tar.gz
Major `cross' category overhaul. Clean up the shared Makefiles; move all
binutils stuff (except gas) to a shared, multiple-target binutils build; reduce extract and compile times by being more specific with files and targets; update to egcs 1.1.1 with a diffball from NetBSD's src/gnu/dist tree; add 4.4BSD a.out archive support to binutils.
Diffstat (limited to 'cross/COMMON/buwrapper.c')
-rw-r--r--cross/COMMON/buwrapper.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/cross/COMMON/buwrapper.c b/cross/COMMON/buwrapper.c
new file mode 100644
index 00000000000..0617513a720
--- /dev/null
+++ b/cross/COMMON/buwrapper.c
@@ -0,0 +1,50 @@
+/* $NetBSD: buwrapper.c,v 1.1 1999/01/04 22:37:30 tv Exp $ */
+
+#include <err.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+/*
+ * Wrapper for binutils programs.
+ *
+ * This frontend sets the appropriate environment variables that tell
+ * binutils programs which target will be used.
+ */
+
+static const char binsubdir[] = "libexec/binutils";
+
+#define PATHLEN sizeof(PREFIX) + sizeof(binsubdir) + 20
+
+int main(int argc, char **argv) {
+ char path[PATHLEN], *p, *prog;
+
+ /* quickly find last part of path component */
+ if (p = strrchr(argv[0], '/'))
+ p++;
+ else
+ p = argv[0];
+ if (prog = strrchr(p, '-'))
+ prog++;
+ else
+ prog = p;
+
+ /* make program pathname */
+ snprintf(path, PATHLEN, "%s/%s/%s", PREFIX, binsubdir, prog);
+
+ /* set up environment */
+ setenv("GNUTARGET", GNUTARGET, 1);
+#ifdef LDEMULATION
+ setenv("LDEMULATION", LDEMULATION, 1);
+#endif
+#ifdef LD_RPATH_LINK
+ setenv("LD_RPATH_LINK", LD_RPATH_LINK, 1);
+#endif
+
+ /* run it! */
+ execv(path, argv);
+
+ /* we shouldn't get here. */
+ err(EX_OSERR, "(buwrapper): exec %s", path);
+}