Index: branches/libc-0.6/src/misc/dllar.cmd
===================================================================
--- branches/libc-0.6/src/misc/dllar.cmd	(revision 2983)
+++ branches/libc-0.6/src/misc/dllar.cmd	(revision 2985)
@@ -63,12 +63,16 @@
     cmdLine = cmdLine||" "||value('DLLAR_CMDLINE',,'OS2ENVIRONMENT');
     outFile = '';
+    useDefFile = '';
     inputFiles.0 = 0;
     description = '';
     CC = 'gcc.exe';
-    CFLAGS = '-s -Zcrtdll';
+    CFLAGS = '-Zcrtdll';
     EXTRA_CFLAGS = '';
     EXPORT_BY_ORDINALS = 0;
     exclude_symbols = '';
     library_flags = '';
+    library_data = '';
+    flag_omf = 0;
+    AR='ar'
     curDir = directory();
     curDirS = curDir;
@@ -86,4 +90,6 @@
                 outFile = word(cmdLine, i);
             end;
+            when abbrev('def', substr(tmp, 2), 3) then
+                useDefFile = GetLongArg();
             when abbrev('description', substr(tmp, 2), 1) then
                 description = GetLongArg();
@@ -100,8 +106,12 @@
             when abbrev('libflags', substr(tmp, 2), 4) then
                 library_flags = library_flags||GetLongArg()' ';
+            when abbrev('libdata', substr(tmp, 2), 4) then
+                library_data = library_data||GetLongArg()' ';
             when abbrev('nocrtdll', substr(tmp, 2), 5) then
-                CFLAGS = '-s';
+                CFLAGS = '';
             when abbrev('nolxlite', substr(tmp, 2), 5) then
                 flag_USE_LXLITE = 0;
+            when abbrev('omf', substr(tmp, 2), 3) then
+                flag_omf = 1;
             otherwise
                 EXTRA_CFLAGS = EXTRA_CFLAGS' 'tmp;
@@ -128,4 +138,10 @@
     end; /* iterate cmdline words */
 
+    if (flag_omf = 1) then
+    do
+        AR = 'emxomfar';
+        CFLAGS = CFLAGS || ' -Zomf';
+    end
+
     /* check arg sanity */
     if (inputFiles.0 = 0) then
@@ -154,5 +170,5 @@
             /* Prefix with '!' to indicate archive */
             inputFiles.I = '!'inputFiles.I;
-            call doCommand('cd 'substr(inputFiles.I, 2)' && ar x 'fullname);
+            call doCommand('cd 'substr(inputFiles.I, 2)' && 'AR' x 'fullname);
             call directory(curDir);
             rc = SysFileTree(substr(inputFiles.I, 2)'\*.o', 'files', 'FO');
@@ -208,52 +224,63 @@
     dllFile = outFile'.dll';
     arcFile = outFile'.a';
+    arcFileOmf = outFile'.lib';
 
     if (do_backup & stream(arcFile, 'C', 'query exists') \= '') then
         call doCommand('ren 'arcFile' 'outFile'_s.a');
 
-    /*
-     * Extract public symbols from all the object files.
-     */
-    tmpdefFile = '$_'filespec('NAME', defFile);
-    call SysFileDelete(tmpdefFile);
-    do I = 1 to inputFiles.0
-        if (left(inputFiles.I, 1) \= '!') then
-            call doCommand('emxexp -u' inputFiles.I' >>'tmpdefFile);
-    end;
-
-    /*
-     * Create the def file.
-     */
-    call SysFileDelete(defFile);
-    call stream defFile, 'c', 'open write';
-    call lineOut defFile, 'LIBRARY 'filespec('NAME', outFile)' 'library_flags;
-    if (length(description) > 0) then
-        call lineOut defFile, 'DESCRIPTION "'description'"';
-    call lineOut defFile, 'EXPORTS';
-
-    queTmp = RxQueue('Create');
-    queOld = RxQueue('Set', queTmp);
-    call doCommand('cat 'tmpdefFile' | sort.exe | uniq.exe | rxqueue.exe' queTmp);
-
-    ordinal = 1;
-    do while queued() > 0
-        parse pull line;
-        if (length(line) > 0) & (word(line, 1) \= ';') & (export_ok(line)) then
-        do
-            if (EXPORT_BY_ORDINALS) then
-            do
-                iPos = pos(';', line);
-                if (iPos > 1) then
-                    line = strip(substr(line, 1, iPos - 1), 'T');
-                line = line||' @'||ordinal||' NONAME';
-                ordinal = ordinal + 1;
-            end;
-            call lineOut defFile, line;
-        end;
-    end;
-    call RxQueue 'Delete', RxQueue('Set', queOld);
-    call stream defFile, 'C', 'CLOSE';
-    call SysFileDelete(tmpdefFile);
-    drop line ordinal tmpdefFile;          /* try prevent running out of memory... */
+   if useDefFile = '' then 
+   do
+       /*
+        * Extract public symbols from all the object files.
+        */
+       tmpdefFile = '$_'filespec('NAME', defFile);
+       call SysFileDelete(tmpdefFile);
+       do I = 1 to inputFiles.0
+           if (left(inputFiles.I, 1) \= '!') then
+               call doCommand('emxexp -u' inputFiles.I' >>'tmpdefFile);
+       end;
+   
+       /*
+        * Create the def file.
+        */
+       call SysFileDelete(defFile);
+       call stream defFile, 'c', 'open write';
+       call lineOut defFile, 'LIBRARY 'filespec('NAME', outFile)' 'library_flags;
+       if (length(library_data) > 0) then
+           call lineOut defFile, 'DATA 'library_data;
+       if (length(description) > 0) then
+           call lineOut defFile, 'DESCRIPTION "'description'"';
+       call lineOut defFile, 'EXPORTS';
+   
+       queTmp = RxQueue('Create');
+       queOld = RxQueue('Set', queTmp);
+       call doCommand('cat 'tmpdefFile' | sort.exe | uniq.exe | rxqueue.exe' queTmp);
+   
+       ordinal = 1;
+       do while queued() > 0
+           parse pull line;
+           if (length(line) > 0) & (word(line, 1) \= ';') & (export_ok(line)) then
+           do
+               if (EXPORT_BY_ORDINALS) then
+               do
+                   iPos = pos(';', line);
+                   if (iPos > 1) then
+                       line = strip(substr(line, 1, iPos - 1), 'T');
+                   line = line||' @'||ordinal||' NONAME';
+                   ordinal = ordinal + 1;
+               end;
+               call lineOut defFile, line;
+           end;
+       end;
+       call RxQueue 'Delete', RxQueue('Set', queOld);
+       call stream defFile, 'C', 'CLOSE';
+       call SysFileDelete(tmpdefFile);
+       drop line ordinal tmpdefFile;          /* try prevent running out of memory... */
+   
+   end
+   else 
+   do
+       defFile = useDefFile;
+   end
 
 
@@ -293,4 +320,5 @@
 
     call doCommand('emximp -o 'arcFile defFile);
+    call doCommand('emximp -o 'arcFileOmf defFile);
     if (flag_USE_LXLITE) then
     do
@@ -314,4 +342,6 @@
  say '       [-cc "CC"] [-f[lags] "CFLAGS"] [-ord[inals]] -ex[clude] "symbol(s)"'
  say '       [-libf[lags] "{INIT|TERM}{GLOBAL|INSTANCE}"] [-nocrt[dll]]'
+ say '       [-libd[ata] "DATA"] [-omf]'
+ say '       [-nolxlite] [-def def_file]"'
  say '       [*.o] [*.a]'
  say '*> "output_file" should have no extension.'
@@ -319,5 +349,5 @@
  say '   The import library name is derived from this and is set to "name".a.'
  say '*> "cc" is used to use another GCC executable.   (default: gcc.exe)'
- say '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
+ say '*> "flags" should be any set of valid GCC flags. (default: -Zcrtdll)'
  say '   These flags will be put at the start of GCC command line.'
  say '*> -ord[inals] tells dllar to export entries by ordinals. Be careful.'
@@ -328,6 +358,11 @@
  say '*> -libf[lags] can be used to add INITGLOBAL/INITINSTANCE and/or'
  say '   TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
+ say '*> -libd[ata] can be used to add data segment attributes flags to the '
+ say '   dynamically-linked library.'
  say '*> -nocrtdll switch will disable linking the library against emx''s'
  say '   C runtime DLLs.'
+ say '*> -nolxlite does not compress executable'
+ say '*> -def def_file do not generate .def file, use def_file instead.'
+ say '*> -omf will use OMF tools to extract the static library objects.'
  say '*> All other switches (for example -L./ or -lmylib) will be passed'
  say '   unchanged to GCC at the end of command line.'
