write a dependency file as used by kbuild to track dependencies */
| 1029 | |
| 1030 | /* write a dependency file as used by kbuild to track dependencies */ |
| 1031 | static int conf_write_autoconf_cmd(const char *autoconf_name) |
| 1032 | { |
| 1033 | char name[PATH_MAX], tmp[PATH_MAX]; |
| 1034 | struct file *file; |
| 1035 | FILE *out; |
| 1036 | int ret; |
| 1037 | |
| 1038 | ret = snprintf(name, sizeof(name), "%s.cmd", autoconf_name); |
| 1039 | if (ret >= sizeof(name)) /* check truncation */ |
| 1040 | return -1; |
| 1041 | |
| 1042 | if (make_parent_dir(name)) |
| 1043 | return -1; |
| 1044 | |
| 1045 | ret = snprintf(tmp, sizeof(tmp), "%s.cmd.tmp", autoconf_name); |
| 1046 | if (ret >= sizeof(tmp)) /* check truncation */ |
| 1047 | return -1; |
| 1048 | |
| 1049 | out = fopen(tmp, "w"); |
| 1050 | if (!out) { |
| 1051 | perror("fopen"); |
| 1052 | return -1; |
| 1053 | } |
| 1054 | |
| 1055 | fprintf(out, "deps_config := \\\n"); |
| 1056 | for (file = file_list; file; file = file->next) |
| 1057 | fprintf(out, "\t%s \\\n", file->name); |
| 1058 | |
| 1059 | fprintf(out, "\n%s: $(deps_config)\n\n", autoconf_name); |
| 1060 | |
| 1061 | env_write_dep(out, autoconf_name); |
| 1062 | |
| 1063 | fprintf(out, "\n$(deps_config): ;\n"); |
| 1064 | |
| 1065 | fflush(out); |
| 1066 | ret = ferror(out); /* error check for all fprintf() calls */ |
| 1067 | fclose(out); |
| 1068 | if (ret) |
| 1069 | return -1; |
| 1070 | |
| 1071 | if (rename(tmp, name)) { |
| 1072 | perror("rename"); |
| 1073 | return -1; |
| 1074 | } |
| 1075 | |
| 1076 | return 0; |
| 1077 | } |
| 1078 | |
| 1079 | static int conf_touch_deps(void) |
| 1080 | { |
no test coverage detected