Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 static char *source_file = __FILE__;
00054
00055 #ifdef _KEEP_RCS_ID
00056
00057 #endif
00058
00059 #include <ctype.h>
00060
00061 #include <string.h>
00062 #include "x_string.h"
00063
00064
00065
00066 #include "defs.h"
00067 #include "glob.h"
00068 #include "strtab.h"
00069 #include <sys/types.h>
00070 #include "tracing.h"
00071 #include "cmplrs/make_depend.h"
00072 #include <stdarg.h>
00073 #include "erfe90.h"
00074
00075 #include "i_cvrt.h"
00076
00077
00078
00079 #include "sgi_cmd_line.h"
00080 #include "cwh_mkdepend.h"
00081
00082
00083 char * mdupdate_file = NULL;
00084 char * mdtarget_file = NULL;
00085
00086
00087 extern INT32
00088 cwh_next_table_entry( table_p t)
00089 {
00090 if (t->current_size == 0) {
00091 t->ptr = (void**) malloc(sizeof(void *) * TABLE_INCREMENT);
00092 memset(t->ptr, '\0', sizeof (void *) * TABLE_INCREMENT);
00093 t->current_size = TABLE_INCREMENT;
00094 }
00095
00096 t->current_idx += 1;
00097 if (t->current_idx >= t->current_size) {
00098
00099 t->current_size += TABLE_INCREMENT;
00100 t->ptr = (void **) realloc (t->ptr, sizeof (void *) * t->current_size);
00101 memset(t->ptr+(t->current_size-TABLE_INCREMENT),'\0',
00102 sizeof (void *) * TABLE_INCREMENT);
00103 }
00104 return (t->current_idx);
00105 }
00106
00107 static table_s name_table = INIT_TABLE;
00108 static table_s used_files_table = INIT_TABLE;
00109 static table_s module_files_table = INIT_TABLE;
00110
00111 INT32
00112 fei_next_name(INT32 num)
00113 {
00114
00115
00116
00117 if (TABLE_SIZE(name_table) == 0) {
00118 return (cwh_next_table_entry(&name_table));
00119 }
00120 if (TABLE_TOP(name_table,char *) == NULL) {
00121 return (TABLE_CURRENT_IDX(name_table));
00122 } else {
00123 return (cwh_next_table_entry(&name_table));
00124 }
00125 }
00126
00127
00128
00129 extern void
00130 cwh_mkdepend_add_name(INT32 idx, char * name)
00131 {
00132 SET_TABLE_IDX(name_table, idx, ux_strdup(name));
00133 }
00134
00135
00136
00137
00138 extern void
00139 cwh_add_to_used_files_table(char * name, INT duplicate)
00140 {
00141 INT i;
00142 char *t;
00143
00144
00145 i = cwh_next_table_entry(&used_files_table);
00146 if (duplicate) {
00147 t = ux_strdup(name);
00148 } else {
00149 t = name;
00150 }
00151 SET_TABLE_IDX(used_files_table,i,t);
00152 }
00153
00154
00155 extern void
00156 cwh_add_to_module_files_table(char *name)
00157 {
00158 INT i,len;
00159 char * fname;
00160 len = strlen(name);
00161 fname = (char *) malloc(len + 4);
00162
00163 for (i = 0; i < len - 1; i++) {
00164 fname[i] = islower(name[i]) ? toupper(name[i]) : name[i];
00165 }
00166 fname[len-1]='.';
00167 fname[len]='m';
00168 fname[len+1]='o';
00169 fname[len+2]='d';
00170 fname[len+3]='\0';
00171 i = cwh_next_table_entry(&module_files_table);
00172 SET_TABLE_IDX(module_files_table,i,fname);
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 void
00185 fei_add_use_path(INT32 st_idx,INT32 path_idx,INT32 module_idx)
00186 {
00187 INT i;
00188
00189 char *path_name;
00190
00191 path_name = (char *) TABLE_IDX(name_table,path_idx);
00192 cwh_add_to_used_files_table(path_name,FALSE);
00193 }
00194
00195
00196 static void makedepend_error(char *fmt, ...)
00197 {
00198 static char makedepend_errbuf[400];
00199 va_list ap;
00200
00201 va_start(ap,fmt);
00202 vsprintf(makedepend_errbuf, fmt, ap);
00203 va_end(ap);
00204 ErrMsg(EC_Makedepend_Error,makedepend_errbuf);
00205 }
00206
00207
00208 extern void
00209 cwh_write_makedepend(void)
00210 {
00211 INT i;
00212 MDhandle h;
00213
00214 if (mdupdate_file == NULL || mdtarget_file == NULL) return;
00215
00216 h = MDopen("mfef90",mdupdate_file,mdtarget_file,makedepend_error);
00217
00218 for (i=0; i <= TABLE_CURRENT_IDX(used_files_table) ; i++) {
00219 MDupdate(h,(char *)TABLE_IDX(used_files_table,i));
00220 }
00221 MDclose(h,NULL);
00222
00223 for (i=0; i <= TABLE_CURRENT_IDX(module_files_table) ; i++) {
00224 h = MDopen("mfef90",mdupdate_file,(char *)TABLE_IDX(module_files_table,i),NULL);
00225 MDupdate(h,mdtarget_file);
00226 MDclose(h,NULL);
00227 }
00228 }