Move the register-inplace special-case stuff into the ghc-prim package
[ghc-hetmet.git] / compiler / ghc-inplace.c
1 #include <stdio.h>
2 #include <stdarg.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <shell-tools.c>
7
8 int main(int argc, char **argv) {
9     char **args;
10     args = malloc(sizeof(char *) * (argc + 4));
11     if (args == NULL) {
12         fprintf(stderr, "Malloc failed\n");
13         exit(1);
14     }
15     args[0] = "GHC_PATH"; /* Gets replaced by sed */
16     args[1] = "-BTOP_ABS"; /* Gets replaced by sed */
17     args[2] = "-dynload";
18     args[3] = "wrapped";
19     if ((argc >= 2) && (strcmp(argv[1], "-v") == 0)) {
20         printf("Using %s %s %s %s\n", args[0], args[1], args[2], args[3]);
21         fflush(stdout);
22     }
23     memcpy(args + 4, argv + 1, sizeof(char *) * (argc - 1));
24     args[argc+3] = NULL;
25     return run(argv[0],
26                "GHC_PATH", /* Gets replaced by sed */
27                argc + 3,
28                args);
29 }