Refactor cross-plattform process spawning from ghc-inplace into shell-tools.c
[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 + 3));
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] = "-fhardwire-lib-paths";
18     if ((argc >= 2) && (strcmp(argv[1], "-v") == 0)) {
19         printf("Using %s %s %s\n", args[0], args[1], args[2]);
20         fflush(stdout);
21     }
22     memcpy(args + 3, argv + 1, sizeof(char *) * (argc - 1));
23     args[argc+2] = NULL;
24     return run(argv[0],
25                "GHC_PATH", /* Gets replaced by sed */
26                argc + 2,
27                args);
28 }