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
00054
00055
00056
00057
00058
00059
00060
00061
00062 static const char *source_file = __FILE__;
00063
00064 #ifdef _KEEP_RCS_ID
00065
00066 static char *rcs_id = "$Source: /home/bos/bk/kpro64-pending/crayf90/sgi/SCCS/s.cwh_mkdepend.cxx $ $Revision: 1.5 $";
00067 #endif
00068
00069 #include <ctype.h>
00070
00071
00072
00073 #include "defs.h"
00074 #include "glob.h"
00075 #include "strtab.h"
00076 #include <sys/types.h>
00077 #include "tracing.h"
00078 #include "cmplrs/make_depend.h"
00079 #include <stdarg.h>
00080 #include "erfe90.h"
00081
00082 #include "i_cvrt.h"
00083
00084
00085
00086 #include "sgi_cmd_line.h"
00087 #include "cwh_mkdepend.h"
00088
00089
00090 char * mdupdate_file = NULL;
00091 char * mdtarget_file = NULL;
00092
00093
00094 extern INT32
00095 cwh_next_table_entry( table_p t)
00096 {
00097 if (t->current_size == 0) {
00098 t->ptr = (void**) malloc(sizeof(void *) * TABLE_INCREMENT);
00099 bzero(t->ptr,sizeof (void *) * TABLE_INCREMENT);
00100 t->current_size = TABLE_INCREMENT;
00101 }
00102
00103 t->current_idx += 1;
00104 if (t->current_idx >= t->current_size) {
00105
00106 t->current_size += TABLE_INCREMENT;
00107 t->ptr = (void **) realloc (t->ptr, sizeof (void *) * t->current_size);
00108 bzero(t->ptr+(t->current_size-TABLE_INCREMENT),sizeof (void *) * TABLE_INCREMENT);
00109 }
00110 return (t->current_idx);
00111 }
00112
00113 static table_s name_table = INIT_TABLE;
00114 static table_s used_files_table = INIT_TABLE;
00115 static table_s module_files_table = INIT_TABLE;
00116
00117 INT32
00118 fei_next_name(INT32 num)
00119 {
00120
00121
00122
00123 if (TABLE_SIZE(name_table) == 0) {
00124 return (cwh_next_table_entry(&name_table));
00125 }
00126 if (TABLE_TOP(name_table,char *) == NULL) {
00127 return (TABLE_CURRENT_IDX(name_table));
00128 } else {
00129 return (cwh_next_table_entry(&name_table));
00130 }
00131 }
00132
00133
00134
00135 extern void
00136 cwh_mkdepend_add_name(INT32 idx, char * name)
00137 {
00138 SET_TABLE_IDX(name_table, idx, strdup(name));
00139 }
00140
00141
00142
00143
00144 extern void
00145 cwh_add_to_used_files_table(char * name, INT duplicate)
00146 {
00147 INT i;
00148 char *t;
00149
00150
00151 i = cwh_next_table_entry(&used_files_table);
00152 if (duplicate) {
00153 t = strdup(name);
00154 } else {
00155 t = name;
00156 }
00157 SET_TABLE_IDX(used_files_table,i,t);
00158 }
00159
00160
00161 extern void
00162 cwh_add_to_module_files_table(char *name)
00163 {
00164 INT i,len;
00165 char * fname;
00166 len = strlen(name);
00167 fname = (char *) malloc(len + 4);
00168
00169 for (i = 0; i < len - 1; i++) {
00170 fname[i] = islower(name[i]) ? toupper(name[i]) : name[i];
00171 }
00172 fname[len-1]='.';
00173 fname[len]='m';
00174 fname[len+1]='o';
00175 fname[len+2]='d';
00176 fname[len+3]='\0';
00177 i = cwh_next_table_entry(&module_files_table);
00178 SET_TABLE_IDX(module_files_table,i,fname);
00179 }
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 void
00191 fei_add_use_path(INTPTR st_idx,INT32 path_idx,INT32 module_idx)
00192 {
00193 INT i;
00194
00195 char *path_name;
00196
00197 path_name = (char *) TABLE_IDX(name_table,path_idx);
00198 cwh_add_to_used_files_table(path_name,FALSE);
00199 }
00200
00201
00202 static void makedepend_error(const char *fmt, ...)
00203 {
00204 static char makedepend_errbuf[400];
00205 va_list ap;
00206
00207 va_start(ap,fmt);
00208 vsprintf(makedepend_errbuf, fmt, ap);
00209 va_end(ap);
00210 ErrMsg(EC_Makedepend_Error,makedepend_errbuf);
00211 }
00212
00213
00214 extern void
00215 cwh_write_makedepend(void)
00216 {
00217 INT i;
00218 MDhandle h;
00219
00220 if (mdupdate_file == NULL || mdtarget_file == NULL) return;
00221
00222 h = MDopen("mfef90",mdupdate_file,mdtarget_file,makedepend_error);
00223
00224 for (i=0; i <= TABLE_CURRENT_IDX(used_files_table) ; i++) {
00225 MDupdate(h,(char *)TABLE_IDX(used_files_table,i));
00226 }
00227 MDclose(h,NULL);
00228
00229 for (i=0; i <= TABLE_CURRENT_IDX(module_files_table) ; i++) {
00230 h = MDopen("mfef90",mdupdate_file,(char *)TABLE_IDX(module_files_table,i),NULL);
00231 MDupdate(h,mdtarget_file);
00232 MDclose(h,NULL);
00233 }
00234 }