updated on Wed Jan 18 08:00:29 UTC 2012
[aur-mirror.git] / pic30-binutils / hardcode-device-info-path.diff
blob422ae564ebec545be3e2688c346d76e14dea31ad
1 On Windows, c30_device.info is presumably installed alongside the
2 binary. On Debian we don't necessarily have c30_device.info at all. If
3 we do have it, it should go in /usr/share/pic30-support.
5 --- ./bfd/cpu-pic30.c.orig 2007-02-02 22:49:02.000000000 +0100
6 +++ ./bfd/cpu-pic30.c 2009-01-28 07:09:24.000000000 +0100
7 @@ -95,7 +95,7 @@
9 const bfd_arch_info_type * global_PROCESSOR = NULL;
11 -static char *pic30_resource_file = 0;
12 +static char *pic30_resource_file = "/usr/pic30/c30_device.info";
14 #define EOL ,
15 #define ARCH(machine, printable_name, default_machine, next, flags) \
16 @@ -166,104 +166,6 @@
17 #define QUOTE2(X) #X
18 #define QUOTE(X) QUOTE2(X)
20 -/* stupid prototype */ static void get_resource_path(const char *resource);
21 -static void get_resource_path(const char *resource) {
23 - char *tool_name = (char *) resource;
24 - char *c;
26 - /*
27 - ** In some command shells, no path information
28 - ** is provided as part of argv[0].
29 - */
30 - if (!IS_DIR_SEPARATOR(resource[0]))
31 - {
32 - /*
33 - ** No DOS path information for the program:
34 - ** search for the executable using the
35 - ** PATH environment variable.
36 - */
37 - struct stat fs;
38 - char *separator;
39 - const char *PATH;
40 - char *dosPATH = 0;
41 - int tool_len;
42 - int len;
43 - char *command;
45 - tool_name = xmalloc(strlen(resource) + 4 + 40);
46 - sprintf(tool_name, "%s", resource);
47 - tool_len = strlen(tool_name);
48 -#if 0
49 - fprintf(stderr,"tool_name: %s\n", tool_name);
50 -#endif
51 -#if defined(HAVE_DOS_BASED_FILE_SYSTEM)
52 - /*
53 - ** Append ".exe" to the executable name, if necessary
54 - */
55 - if ((tolower(tool_name[tool_len-1]) != 'e') ||
56 - (tolower(tool_name[tool_len-2]) != 'x') ||
57 - (tolower(tool_name[tool_len-3]) != 'e') ||
58 - ( (tool_name[tool_len-4]) != '.'))
59 - {
60 - strcat(tool_name, ".exe");
61 - tool_len += 4;
62 - }
63 -#endif
64 - /*
65 - ** Get the current PATH
66 - */
67 - PATH = getenv("PATH");
68 - if (PATH) {
69 - /*
70 - * stupid gnu will print (null) to the string if PATH==0
71 - */
72 - dosPATH = xcalloc(1, strlen(PATH) + 3);
73 - sprintf(dosPATH,"%s%c.",PATH, PATH_SEPARATOR);
74 - PATH = dosPATH;
75 - } else {
76 - PATH=".";
77 - }
78 -#if 0
79 - fprintf(stderr,"PATH=%s\n", PATH);
80 -#endif
81 - len = 256;
82 - command = xmalloc(len);
83 - do
84 - { int path_len;
86 - separator = strchr(PATH, PATH_SEPARATOR);
87 - path_len = separator ? (unsigned)(separator-PATH) : strlen(PATH);
88 - if ((path_len + tool_len + 2) > len) {
89 - len = path_len + tool_len + 80;
90 - free(command);
91 - command = xmalloc(len);
92 - }
93 - command[0] = 0;
94 - strncpy(command, PATH, path_len);
95 - command[path_len] = 0;
96 - if (!IS_DIR_SEPARATOR(command[path_len-1])) {
97 - strcat(command, DIR_SEPARATOR_STR);
98 - }
99 - strcat(command, tool_name);
100 -#if 0
101 - fprintf(stderr,"dir=%s\n",command);
102 -#endif
103 - if (stat(command, &fs) == 0) break;
104 - PATH = 0;
105 - } while (separator && (PATH = separator+1));
106 - if (dosPATH) free(dosPATH);
107 - if (PATH) tool_name = command;
109 - pic30_resource_file = xmalloc(strlen(tool_name) +
110 - sizeof("/c30_device.info") + 1);
111 - sprintf(pic30_resource_file,"%s", tool_name);
112 - for (c = pic30_resource_file + strlen(pic30_resource_file);
113 - !IS_DIR_SEPARATOR(*c); c--);
114 - *c = 0;
115 - strcat(pic30_resource_file,"/c30_device.info");
118 void pic30_update_resource(const char *resource) {
119 /* The tool_version is defined in the string MCHP_VERSION */
120 char *Microchip;
121 @@ -287,7 +189,6 @@
122 version_part2 = Microchip+1;
125 - get_resource_path(resource);
126 process_resource_file(ARCH_TABLE, 0, 0);