- Timestamp:
- Apr 2, 2007, 12:48:39 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/emx/src/misc/dllar.cmd
r800 r2986 63 63 cmdLine = cmdLine||" "||value('DLLAR_CMDLINE',,'OS2ENVIRONMENT'); 64 64 outFile = ''; 65 useDefFile = ''; 65 66 inputFiles.0 = 0; 66 67 description = ''; 67 68 CC = 'gcc.exe'; 68 CFLAGS = '- s -Zcrtdll';69 CFLAGS = '-Zcrtdll'; 69 70 EXTRA_CFLAGS = ''; 70 71 EXPORT_BY_ORDINALS = 0; 71 72 exclude_symbols = ''; 72 73 library_flags = ''; 74 library_data = ''; 75 flag_omf = 0; 76 AR='ar' 73 77 curDir = directory(); 74 78 curDirS = curDir; … … 86 90 outFile = word(cmdLine, i); 87 91 end; 92 when abbrev('def', substr(tmp, 2), 3) then 93 useDefFile = GetLongArg(); 88 94 when abbrev('description', substr(tmp, 2), 1) then 89 95 description = GetLongArg(); … … 100 106 when abbrev('libflags', substr(tmp, 2), 4) then 101 107 library_flags = library_flags||GetLongArg()' '; 108 when abbrev('libdata', substr(tmp, 2), 4) then 109 library_data = library_data||GetLongArg()' '; 102 110 when abbrev('nocrtdll', substr(tmp, 2), 5) then 103 CFLAGS = ' -s';111 CFLAGS = ''; 104 112 when abbrev('nolxlite', substr(tmp, 2), 5) then 105 113 flag_USE_LXLITE = 0; 114 when abbrev('omf', substr(tmp, 2), 3) then 115 flag_omf = 1; 106 116 otherwise 107 117 EXTRA_CFLAGS = EXTRA_CFLAGS' 'tmp; … … 128 138 end; /* iterate cmdline words */ 129 139 140 if (flag_omf = 1) then 141 do 142 AR = 'emxomfar'; 143 CFLAGS = CFLAGS || ' -Zomf'; 144 end 145 130 146 /* check arg sanity */ 131 147 if (inputFiles.0 = 0) then … … 154 170 /* Prefix with '!' to indicate archive */ 155 171 inputFiles.I = '!'inputFiles.I; 156 call doCommand('cd 'substr(inputFiles.I, 2)' && arx 'fullname);172 call doCommand('cd 'substr(inputFiles.I, 2)' && 'AR' x 'fullname); 157 173 call directory(curDir); 158 174 rc = SysFileTree(substr(inputFiles.I, 2)'\*.o', 'files', 'FO'); … … 208 224 dllFile = outFile'.dll'; 209 225 arcFile = outFile'.a'; 226 arcFileOmf = outFile'.lib'; 210 227 211 228 if (do_backup & stream(arcFile, 'C', 'query exists') \= '') then 212 229 call doCommand('ren 'arcFile' 'outFile'_s.a'); 213 230 214 /* 215 * Extract public symbols from all the object files. 216 */ 217 tmpdefFile = '$_'filespec('NAME', defFile); 218 call SysFileDelete(tmpdefFile); 219 do I = 1 to inputFiles.0 220 if (left(inputFiles.I, 1) \= '!') then 221 call doCommand('emxexp -u' inputFiles.I' >>'tmpdefFile); 222 end; 223 224 /* 225 * Create the def file. 226 */ 227 call SysFileDelete(defFile); 228 call stream defFile, 'c', 'open write'; 229 call lineOut defFile, 'LIBRARY 'filespec('NAME', outFile)' 'library_flags; 230 if (length(description) > 0) then 231 call lineOut defFile, 'DESCRIPTION "'description'"'; 232 call lineOut defFile, 'EXPORTS'; 233 234 queTmp = RxQueue('Create'); 235 queOld = RxQueue('Set', queTmp); 236 call doCommand('cat 'tmpdefFile' | sort.exe | uniq.exe | rxqueue.exe' queTmp); 237 238 ordinal = 1; 239 do while queued() > 0 240 parse pull line; 241 if (length(line) > 0) & (word(line, 1) \= ';') & (export_ok(line)) then 242 do 243 if (EXPORT_BY_ORDINALS) then 244 do 245 iPos = pos(';', line); 246 if (iPos > 1) then 247 line = strip(substr(line, 1, iPos - 1), 'T'); 248 line = line||' @'||ordinal||' NONAME'; 249 ordinal = ordinal + 1; 250 end; 251 call lineOut defFile, line; 252 end; 253 end; 254 call RxQueue 'Delete', RxQueue('Set', queOld); 255 call stream defFile, 'C', 'CLOSE'; 256 call SysFileDelete(tmpdefFile); 257 drop line ordinal tmpdefFile; /* try prevent running out of memory... */ 231 if useDefFile = '' then 232 do 233 /* 234 * Extract public symbols from all the object files. 235 */ 236 tmpdefFile = '$_'filespec('NAME', defFile); 237 call SysFileDelete(tmpdefFile); 238 do I = 1 to inputFiles.0 239 if (left(inputFiles.I, 1) \= '!') then 240 call doCommand('emxexp -u' inputFiles.I' >>'tmpdefFile); 241 end; 242 243 /* 244 * Create the def file. 245 */ 246 call SysFileDelete(defFile); 247 call stream defFile, 'c', 'open write'; 248 call lineOut defFile, 'LIBRARY 'filespec('NAME', outFile)' 'library_flags; 249 if (length(library_data) > 0) then 250 call lineOut defFile, 'DATA 'library_data; 251 if (length(description) > 0) then 252 call lineOut defFile, 'DESCRIPTION "'description'"'; 253 call lineOut defFile, 'EXPORTS'; 254 255 queTmp = RxQueue('Create'); 256 queOld = RxQueue('Set', queTmp); 257 call doCommand('cat 'tmpdefFile' | sort.exe | uniq.exe | rxqueue.exe' queTmp); 258 259 ordinal = 1; 260 do while queued() > 0 261 parse pull line; 262 if (length(line) > 0) & (word(line, 1) \= ';') & (export_ok(line)) then 263 do 264 if (EXPORT_BY_ORDINALS) then 265 do 266 iPos = pos(';', line); 267 if (iPos > 1) then 268 line = strip(substr(line, 1, iPos - 1), 'T'); 269 line = line||' @'||ordinal||' NONAME'; 270 ordinal = ordinal + 1; 271 end; 272 call lineOut defFile, line; 273 end; 274 end; 275 call RxQueue 'Delete', RxQueue('Set', queOld); 276 call stream defFile, 'C', 'CLOSE'; 277 call SysFileDelete(tmpdefFile); 278 drop line ordinal tmpdefFile; /* try prevent running out of memory... */ 279 280 end 281 else 282 do 283 defFile = useDefFile; 284 end 258 285 259 286 … … 293 320 294 321 call doCommand('emximp -o 'arcFile defFile); 322 call doCommand('emximp -o 'arcFileOmf defFile); 295 323 if (flag_USE_LXLITE) then 296 324 do … … 314 342 say ' [-cc "CC"] [-f[lags] "CFLAGS"] [-ord[inals]] -ex[clude] "symbol(s)"' 315 343 say ' [-libf[lags] "{INIT|TERM}{GLOBAL|INSTANCE}"] [-nocrt[dll]]' 344 say ' [-libd[ata] "DATA"] [-omf]' 345 say ' [-nolxlite] [-def def_file]"' 316 346 say ' [*.o] [*.a]' 317 347 say '*> "output_file" should have no extension.' … … 319 349 say ' The import library name is derived from this and is set to "name".a.' 320 350 say '*> "cc" is used to use another GCC executable. (default: gcc.exe)' 321 say '*> "flags" should be any set of valid GCC flags. (default: - s -Zcrtdll)'351 say '*> "flags" should be any set of valid GCC flags. (default: -Zcrtdll)' 322 352 say ' These flags will be put at the start of GCC command line.' 323 353 say '*> -ord[inals] tells dllar to export entries by ordinals. Be careful.' … … 328 358 say '*> -libf[lags] can be used to add INITGLOBAL/INITINSTANCE and/or' 329 359 say ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.' 360 say '*> -libd[ata] can be used to add data segment attributes flags to the ' 361 say ' dynamically-linked library.' 330 362 say '*> -nocrtdll switch will disable linking the library against emx''s' 331 363 say ' C runtime DLLs.' 364 say '*> -nolxlite does not compress executable' 365 say '*> -def def_file do not generate .def file, use def_file instead.' 366 say '*> -omf will use OMF tools to extract the static library objects.' 332 367 say '*> All other switches (for example -L./ or -lmylib) will be passed' 333 368 say ' unchanged to GCC at the end of command line.'
Note:
See TracChangeset
for help on using the changeset viewer.