2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
10 #include <sys/param.h>
16 #define PATH_SEPARATOR ';'
18 /* If we're running on MinGW, PATH is in native Windows form while
19 COMPILER_PATH has ';' as entries separator but still has '/' as directory
20 separator, so we have to convert it. This is what this magic for. */
22 void copy_path(char *to
, char *from
)
33 #define PATH_SEPARATOR ':'
34 #define copy_path strcpy
38 void nonfatal(const char *msg
, const char *errorstr
)
41 fprintf(stderr
, "%s: %s: %s\n" , program_name
, msg
, errorstr
);
43 fprintf(stderr
, "%s: %s\n" , program_name
, errorstr
);
46 void fatal(const char *msg
, const char *errorstr
)
48 nonfatal(msg
, errorstr
);
52 void set_compiler_path(void)
54 static int path_set
= 0;
58 char *compiler_path
= getenv("COMPILER_PATH");
59 char *path
= getenv("PATH");
61 if (compiler_path
&& path
)
64 size_t compiler_path_len
= strlen(compiler_path
);
65 size_t path_len
= strlen(path
);
67 new_path
= malloc(5 + compiler_path_len
+ 1 + path_len
+ 1);
70 strcpy(new_path
, "PATH=");
71 copy_path(new_path
+ 5, compiler_path
);
72 new_path
[5 + compiler_path_len
] = PATH_SEPARATOR
;
73 strcpy(new_path
+ 5 + compiler_path_len
+ 1, path
);
75 if (putenv(new_path
) == 0)
82 #ifndef _HAVE_LIBIBERTY_
84 void *xmalloc(size_t size
)
86 void *ret
= malloc(size
);
89 fatal("xmalloc", strerror(errno
));
95 char *make_temp_file(char *suffix
__attribute__((unused
)))
98 /* If you're unlucky enough to not have libiberty available, you'll have
99 to live with temporary files in /tmp and no suffix; it's ok for our own
101 char template[] = "/tmp/catmpXXXXXX";
103 fd
= mkstemp(template);
108 fatal("make_temp_file()/close()", strerror(errno
));
110 return strdup(template);