lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #! /usr/bin/awk |
| 2 | BEGIN { |
| 3 | FS=":"; |
| 4 | count=0; |
| 5 | } |
| 6 | { |
| 7 | for (i = 1; i <= NF; ++i) { |
| 8 | gsub (/\/*$/, "", $i); |
| 9 | dir[count++] = $i; |
| 10 | } |
| 11 | } |
| 12 | END { |
| 13 | for (i = 0; i < count; ++i) { |
| 14 | printf ("static struct r_search_path_elem rtld_search_dir%d =\n", i+1); |
| 15 | printf (" { \"%s/\", %d, unknown, 0, nonexisting, NULL, NULL, ", |
| 16 | dir[i], length (dir[i]) + 1); |
| 17 | if (i== 0) |
| 18 | printf ("NULL };\n"); |
| 19 | else |
| 20 | printf ("&rtld_search_dir%d };\n", i); |
| 21 | } |
| 22 | printf ("\nstatic struct r_search_path_elem *rtld_search_dirs[] =\n{\n"); |
| 23 | for (i = 0; i < count; ++i) { |
| 24 | printf (" &rtld_search_dir%d,\n", i + 1); |
| 25 | } |
| 26 | printf (" NULL\n};\n\n"); |
| 27 | printf ("static struct r_search_path_elem *all_dirs = &rtld_search_dir%d;\n", |
| 28 | count); |
| 29 | } |