Changeset 938
- Timestamp:
- Jan 7, 2004, 6:30:46 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/emx/src/emxomf/emxomfld.c ¶
-
Property cvs2svn:cvs-rev
changed from
1.33
to1.34
r937 r938 34 34 #include <sys/utime.h> 35 35 #include <sys/moddef.h> 36 #include < emx/getopt.h>36 #include <getopt.h> 37 37 #include <alloca.h> 38 38 #include <sys/omflib.h> … … 178 178 #endif 179 179 extern int _System DosCopy (char *, char *, int); 180 181 /* Tell the user how to run this program. */182 183 static void usage (void)184 {185 fprintf (stderr, "emxomfld " VERSION INNOTEK_VERSION "\n"186 "Copyright (c) 1992-1996 by Eberhard Mattes\n"187 "Copyright (c) 2003 by InnoTek Systemberatung GmbH\n\n");188 189 fprintf (stderr,190 "Usage: emxomfld -o <file> [-l <lib>] [-L <libdir>] [-T <base>] [-igtsS]\n"191 " [-Zexe] [-Zdll] [-Zstack <size>] [-Zmap[=<map_file>]]\n"192 " [-Z[no-]autoconv] [-O <option>] <file>...\n"193 "\n"194 "Options:\n"195 " -Zno-autoconv / -Zautoconv:\n"196 " Turns off/on the automatic conversion of a.out libs and objs.\n"197 " default: -Zautoconv\n"198 "\n"199 "Environment variables:\n"200 " EMXOMFLD_TYPE:\n"201 " The type of linker we're using. Values: VAC365, VAC308, LINK386.\n"202 " VAC365 ilink.exe from IBM C and C++ Compilers for OS/2 v3.6 or later.\n"203 " VAC308 ilink.exe from Visual Age for C++ v3.08.\n"204 " LINK386 link386 form OS/2 install or DDK.\n"205 " EMXOMFLD_LINKER:\n"206 " Name of the linker to use and optionally extra parameters. Spaces in the\n"207 " linker name or path is not supported. Quotes are not supported either.\n"208 "The default values for these two variables are VAC365 and ilink.exe.\n");209 exit (1);210 }211 212 180 213 181 /* Allocate N bytes of memory. Quit on failure. This function is … … 1125 1093 } 1126 1094 1095 /* Tell the user how to run this program. */ 1096 1097 static void usage (void) 1098 { 1099 fprintf (stderr, "emxomfld " VERSION INNOTEK_VERSION "\n" 1100 "Copyright (c) 1992-1996 by Eberhard Mattes\n" 1101 "Copyright (c) 2003 by InnoTek Systemberatung GmbH\n\n"); 1102 1103 fprintf (stderr, 1104 "Usage: emxomfld -o <file> [-l <lib>] [-L <libdir>] [-T <base>] [-igtsS]\n" 1105 " [-Zexe] [-Zdll] [-Zstack <size>] [-Zmap[=<map_file>]]\n" 1106 " [-Z[no-]autoconv] [-O <option>] [-static] [-non_shared]\n" 1107 " [-Bstatic] [-dn] [call_shared] [-Bshared] [-dy] <file>...\n" 1108 "\n" 1109 "Options:\n" 1110 " -Zno-autoconv / -Zautoconv:\n" 1111 " Turns off/on the automatic conversion of a.out libs and objs.\n" 1112 " default: -Zautoconv\n" 1113 " -Bstatic, -non_shared, -dn, -static:\n" 1114 " Link with static libraries.\n" 1115 " The search order is then changed to: lib<name>_s.lib, <name>_s.lib,\n" 1116 " lib<name>.lib, <name>.lib\n" 1117 " -Bshared, -call_shared, -dy:\n" 1118 " Link with shared libraries. This is default.\n" 1119 " The search order is then changed to: lib<name>_dll.lib, <name>_dll.lib,\n" 1120 " lib<name>.lib, <name>.lib, <name>.dll, lib<name>_s.lib, <name>_s.lib.\n" 1121 "\n" 1122 "Environment variables:\n" 1123 " EMXOMFLD_TYPE:\n" 1124 " The type of linker we're using. Values: VAC365, VAC308, LINK386.\n" 1125 " VAC365 ilink.exe from IBM C and C++ Compilers for OS/2 v3.6 or later.\n" 1126 " VAC308 ilink.exe from Visual Age for C++ v3.08.\n" 1127 " LINK386 link386 form OS/2 install or DDK.\n" 1128 " EMXOMFLD_LINKER:\n" 1129 " Name of the linker to use and optionally extra parameters. Spaces in the\n" 1130 " linker name or path is not supported. Quotes are not supported either.\n" 1131 "The default values for these two variables are VAC365 and ilink.exe.\n" 1132 ); 1133 exit (1); 1134 } 1135 1136 1137 1138 static struct option longopts[] = 1139 { 1140 #define OPT_LIBS_STATIC 0x1000 1141 {"Bstatic", 0, 0, OPT_LIBS_STATIC}, 1142 {"non_shared", 0, 0, OPT_LIBS_STATIC}, 1143 {"dn", 0, 0, OPT_LIBS_STATIC}, 1144 {"static", 0, 0, OPT_LIBS_STATIC}, 1145 #define OPT_LIBS_SHARED 0x1001 1146 {"Bshared", 0, 0, OPT_LIBS_SHARED}, 1147 {"call_shared", 0, 0, OPT_LIBS_SHARED}, 1148 {"dy", 0, 0, OPT_LIBS_SHARED}, 1149 #define OPT_ZEXE 0x1002 1150 {"Zexe", 0, 0, OPT_ZEXE}, /* Create .exe file, touch `output file' */ 1151 #define OPT_ZDLL 0x1003 1152 {"Zdll", 0, 0, OPT_ZDLL}, /* Create .dll file, touch `output file' */ 1153 #define OPT_ZSTACK 0x1004 1154 {"Zstack", 1, 0, OPT_ZSTACK}, /* Set stack size */ 1155 #define OPT_ZMAP 0x1005 1156 {"Zmap", 2, 0, OPT_ZMAP}, /* Create .map file */ 1157 {"Zmap=", 1, 0, OPT_ZMAP}, 1158 #define OPT_ZAUTOCONV 0x1006 1159 {"Zautoconv",0, 0, OPT_ZAUTOCONV}, 1160 #define OPT_ZNO_AUTOCONV 0x1007 1161 {"Zno-autoconv",0, 0, OPT_ZNO_AUTOCONV}, 1162 /* {"e", 1, 0, 'e'}, entry point */ 1163 {"i", 0, 0, 'i'}, 1164 {"o", 1, 0, 'o'}, 1165 {"O", 1, 0, 'O'}, 1166 /* {"u", 1, 0, 'u'}, reference symbol */ 1167 {"s", 0, 0, 's'}, 1168 {"S", 0, 0, 'S'}, 1169 {"t", 0, 0, 't'}, 1170 {"T", 1, 0, 'T'}, 1171 {"v", 0, 0, 'v'}, 1172 {"x", 0, 0, 'x'}, 1173 {"X", 0, 0, 'X'}, 1174 {NULL, 0, 0, 0} 1175 }; 1127 1176 1128 1177 /* Main function of emxomf. Parse the command line and call the IBM/M$ … … 1136 1185 char execname[512]; 1137 1186 name_list *pcur; 1187 int longind; 1138 1188 1139 1189 /* Get options from response files (@filename) and wildcard (*.o) on the command. */ … … 1149 1199 1150 1200 files = 0; 1151 opterr = FALSE; optmode = GETOPT_KEEP; 1201 opterr = FALSE; 1202 /*optmode = GETOPT_KEEP; */ 1152 1203 if (argc < 2) 1153 1204 usage (); 1154 1205 1155 1206 /* Parse the command line options and other arguments. */ 1156 1157 while ((c = getopt (argc, argv, "o:O:itl:vL:T:sSxXZ:")) != EOF) 1158 switch (c) 1159 { 1160 case 't': 1161 case 'i': /* Trace the linking process, sending /INFO to the IBM/M$ linker. */ 1162 opt_t = TRUE; 1163 break; 1164 1165 case 'l': /* Add library */ 1166 add_name_list (&add_lib_fnames, optarg); 1167 break; 1168 1169 case 'o': /* Set output file name */ 1170 output_fname = optarg; 1171 break; 1172 1173 case 'L': /* Add library directory */ 1174 add_name_list (&add_libdirs, optarg); 1175 break; 1176 1177 case 'T': /* Set base address */ 1178 base = optarg; 1179 break; 1180 1181 case 's': /* Strip all symbols */ 1182 case 'S': /* Strip debugging symbols */ 1183 strip_symbols = TRUE; 1184 break; 1185 1186 case 'x': /* Discard all local symbols */ 1187 case 'X': /* Discard local symbols starting with L */ 1188 break; 1189 1190 case 'v': /* For compatibility */ 1191 break; 1192 1193 case 'O': /* Specify Linker option */ 1194 add_name_list (&add_options, optarg); 1195 break; 1196 1197 case 'Z': /* -Zdll, -Zexe, -Zmap, and -Zstack */ 1198 if (strcmp (optarg, "dll") == 0) 1207 //while ((c = getopt_long (argc, argv, "o:O:itl:vL:T:sSxX", longopts, &longind)) != EOF) 1208 while ((c = getopt_long_only (argc, argv, "-l:y:L:", longopts, &longind)) != EOF) 1209 { 1210 if (c == 0) 1211 c = longopts[longind].val; 1212 switch (c) 1213 { 1214 case '?': 1215 usage(); 1216 break; 1217 1218 case 0: /* Non-option argument */ 1219 1220 /* Extract the extension to see what to do with this 1221 argument. */ 1222 1223 ext = _getext (optarg); 1224 1225 if (ext == NULL) 1226 { 1227 /* GCC's temporary files don't have an extension. Add a 1228 dot to the end of the name to prevent the linker from 1229 adding `.obj'. */ 1230 1231 sprintf (tmp, "%s.", optarg); 1232 add_name_list (&add_obj_fnames, tmp); 1233 } 1234 1235 /* If it's a .def file, use it as module definition file 1236 (input). */ 1237 1238 else if (stricmp (ext, ".def") == 0) 1239 { 1240 if (def_fname != NULL) 1241 { 1242 fprintf (stderr, 1243 "emxomfld: multiple module definition files\n"); 1244 usage (); 1245 } 1246 def_fname = optarg; 1247 } 1248 1249 /* If it's a .res file, use it as binary resource file 1250 (input). */ 1251 1252 else if (stricmp (ext, ".res") == 0) 1253 { 1254 if (res_fname != NULL) 1255 { 1256 fprintf (stderr, 1257 "emxomfld: multiple binary resource files\n"); 1258 usage (); 1259 } 1260 res_fname = optarg; 1261 } 1262 1263 /* If it's a .lib file, use it as library file. We also 1264 accept .a files for those who use OMF files disguised as 1265 a.out files (to simplify their make files). */ 1266 1267 else if (stricmp (ext, ".lib") == 0 || stricmp (ext, ".a") == 0 || stricmp (ext, ".dll") == 0) 1268 add_name_list (&add_lib_fnames, optarg); 1269 1270 /* Otherwise, assume it's an object file. */ 1271 1272 else 1273 add_name_list (&add_obj_fnames, optarg); 1274 ++files; 1275 break; 1276 1277 case 't': 1278 case 'i': /* Trace the linking process, sending /INFO to the IBM/M$ linker. */ 1279 opt_t = TRUE; 1280 break; 1281 1282 case 'l': /* Add library */ 1283 add_name_list (&add_lib_fnames, optarg); 1284 break; 1285 1286 case 'o': /* Set output file name */ 1287 output_fname = optarg; 1288 break; 1289 1290 case 'L': /* Add library directory */ 1291 add_name_list (&add_libdirs, optarg); 1292 break; 1293 1294 case 'T': /* Set base address */ 1295 base = optarg; 1296 break; 1297 1298 case 's': /* Strip all symbols */ 1299 case 'S': /* Strip debugging symbols */ 1300 strip_symbols = TRUE; 1301 break; 1302 1303 case 'x': /* Discard all local symbols */ 1304 case 'X': /* Discard local symbols starting with L */ 1305 break; 1306 1307 case 'v': /* For compatibility */ 1308 break; 1309 1310 case 'O': /* Specify Linker option */ 1311 add_name_list (&add_options, optarg); 1312 break; 1313 1314 case OPT_ZDLL: 1199 1315 dll_flag = TRUE; 1200 else if (strcmp (optarg, "exe") == 0) 1316 break; 1317 1318 case OPT_ZEXE: 1201 1319 exe_flag = TRUE; 1202 else if (strcmp (optarg, "map") == 0) 1320 break; 1321 1322 case OPT_ZMAP: 1203 1323 map_flag = TRUE; 1204 else if (strncmp (optarg, "map=", 4) == 0) 1205 { 1206 if (map_fname != NULL) 1207 { 1208 fprintf (stderr, "emxomfld: multiple map files files\n"); 1209 usage (); 1210 } 1211 map_fname = optarg + 4; 1212 map_flag = TRUE; 1213 } 1214 else if (strcmp (optarg, "stack") == 0) 1215 { 1216 /* This makes assumptions on the internals of getopt(). */ 1217 1218 if (optind >= argc || argv[optind][0] == '-') 1219 usage (); 1220 errno = 0; 1221 stack_size = strtol (argv[optind], &t, 0); 1222 if (errno != 0 || *t != 0 || t == argv[optind]) 1223 usage (); 1224 ++optind; 1225 } 1226 else if (strcmp (optarg, "autoconv") == 0) 1324 if (optarg) 1325 { 1326 if (map_fname != NULL) 1327 { 1328 fprintf (stderr, "emxomfld: multiple map files files\n"); 1329 usage (); 1330 } 1331 map_fname = optarg; 1332 } 1333 break; 1334 1335 case OPT_ZSTACK: 1336 if (!optarg) 1337 usage (); 1338 errno = 0; 1339 stack_size = strtol (argv[optind], &t, 0); 1340 if (errno != 0 || *t != 0 || t == argv[optind]) 1341 usage (); 1342 break; 1343 1344 case OPT_ZAUTOCONV: 1227 1345 autoconvert_flag = 1; 1228 else if (strcmp (optarg, "no-autoconv") == 0) 1346 break; 1347 case OPT_ZNO_AUTOCONV: 1229 1348 autoconvert_flag = 0; 1230 else 1231 { 1232 fprintf (stderr, "emxomfld: invalid option (%s)\n", optarg); 1233 usage (); 1234 } 1235 break; 1236 1237 case 0: /* Non-option argument */ 1238 1239 /* Extract the extension to see what to do with this 1240 argument. */ 1241 1242 ext = _getext (optarg); 1243 1244 if (ext == NULL) 1245 { 1246 /* GCC's temporary files don't have an extension. Add a 1247 dot to the end of the name to prevent the linker from 1248 adding `.obj'. */ 1249 1250 sprintf (tmp, "%s.", optarg); 1251 add_name_list (&add_obj_fnames, tmp); 1252 } 1253 1254 /* If it's a .def file, use it as module definition file 1255 (input). */ 1256 1257 else if (stricmp (ext, ".def") == 0) 1258 { 1259 if (def_fname != NULL) 1260 { 1261 fprintf (stderr, 1262 "emxomfld: multiple module definition files\n"); 1263 usage (); 1264 } 1265 def_fname = optarg; 1266 } 1267 1268 /* If it's a .res file, use it as binary resource file 1269 (input). */ 1270 1271 else if (stricmp (ext, ".res") == 0) 1272 { 1273 if (res_fname != NULL) 1274 { 1275 fprintf (stderr, 1276 "emxomfld: multiple binary resource files\n"); 1277 usage (); 1278 } 1279 res_fname = optarg; 1280 } 1281 1282 /* If it's a .lib file, use it as library file. We also 1283 accept .a files for those who use OMF files disguised as 1284 a.out files (to simplify their make files). */ 1285 1286 else if (stricmp (ext, ".lib") == 0 || stricmp (ext, ".a") == 0 || stricmp (ext, ".dll") == 0) 1287 add_name_list (&add_lib_fnames, optarg); 1288 1289 /* Otherwise, assume it's an object file. */ 1290 1291 else 1292 add_name_list (&add_obj_fnames, optarg); 1293 ++files; 1294 break; 1295 1296 default: 1297 fprintf (stderr, "emxomfld: invalid option (%s)\n", argv[optind - 1]); 1298 usage (); 1299 } 1300 1349 1350 default: 1351 fprintf (stderr, "emxomfld: invalid option (%s)\n", argv[optind - 1]); 1352 usage (); 1353 } 1354 } 1301 1355 /* Set default value for output file. */ 1302 1356 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.