Index: trunk/src/emx/Makefile
===================================================================
--- trunk/src/emx/Makefile	(revision 257)
+++ trunk/src/emx/Makefile	(revision 259)
@@ -70,8 +70,8 @@
 LDFLAGS.DLL = $(LDFLAGS) -Zdll
 # Linker flags for different build modes
-LDFLAGS.opt = -s
+LDFLAGS.opt = -s -Zcrtdll=c_dll -Zstack 64
 LDFLAGS.dbg = -g
 LDFLAGS.aout =
-LDFLAGS.omf = -Zomf -Zsys -Zsmall-conv -Zlinker /PM:VIO
+LDFLAGS.omf = -Zomf -Zsys -Zlinker /PM:VIO
 LDFLAGS.prof = -pg
 # Linker flags for different kinds of target
@@ -82,10 +82,15 @@
 DO.LINK.dll = $(LD) $(strip $(LDFLAGS.DLL) $(filter-out -l%,$1)) -o $@ $(^O) $(^DEF) $(^LIB) $(filter -l%,$1)
 
+# Pack executables and DLLs right after they are linked
+ifeq ($(MODE),opt)
+DO.LINK.exe += $(NL)lxlite $@
+DO.LINK.dll += $(NL)lxlite $@
+endif
+
 # emxbind tool
 #EMXBIND = $(call FINDTOOL,emxbind)
 EMXBIND = $.$(TOOLFMT)/emxbind$E
-EMXBIND.DEPON = emxbind $.$(TOOLFMT)/emxbind$E
 # emxbind flags
-EMXBINDFLAGS = -q $(EMXBINDFLAGS.$(MODE))
+EMXBINDFLAGS = -bq $(EMXBINDFLAGS.$(MODE))
 EMXBINDFLAGS.opt = -s
 EMXBINDFLAGS.dbg =
@@ -109,5 +114,4 @@
 #EMXEXP = $(call FINDTOOL,emxexp)
 EMXEXP = $.$(TOOLFMT)/emxexp$E
-EMXEXP.DEPON = emxexp $.$(TOOLFMT)/emxexp$E
 EMXEXPFLAGS = -u
 DO.EMXEXP = $(EMXEXP) $(strip $(EMXEXPFLAGS) $1) $^ | sed -e "/^$$/d" -e "/^ *;/d" | sort -d >>$@
@@ -116,5 +120,4 @@
 #IMPLIB = $(call FINDTOOL,emximp)
 IMPLIB = $.$(TOOLFMT)/emximp$E
-EMXIMP.DEPON = emximp $.$(TOOLFMT)/emximp$E
 IMPLIBFLAGS.prof = -m
 IMPLIBFLAGS.KIND = $(foreach x,$(subst -, ,$(firstword $(subst /, ,$(subst $.,,$@)))),$(IMPLIBFLAGS.$x))
@@ -131,5 +134,4 @@
 # We must use FINDTOOL here 'cause of the two libs which emxomf depends on
 EMXOMF = $(call FINDTOOL,emxomf)
-EMXOMF.DEPON = emxomf $.$(TOOLFMT)/emxomf$E
 DO.EMXOMF = $(EMXOMF) $(strip $1 -o) $@ $<
 
@@ -273,9 +275,9 @@
 
 # The general a.out -> OMF conversion rule for object files
-$.omf/%.obj: $.aout/%.o
+$.omf/%.obj:
 	$(call DO.EMXOMF)
 
 # The general a.out -> OMF conversion rule for libraries
-$.omf%.lib: $.aout%.a
+$.omf%.lib:
 	$(call DO.EMXOMF)
 
Index: trunk/src/emx/include/include.smak
===================================================================
--- trunk/src/emx/include/include.smak	(revision 257)
+++ trunk/src/emx/include/include.smak	(revision 259)
@@ -6,21 +6,21 @@
 $(INS)include/sys/%.h: include/sys/%.h
 	$(call CP,$<,$@)
-			
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/386/*.h))
 $(INS)include/386/%.h: include/386/%.h
 	$(call CP,$<,$@)
-	
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/arpa/*.h))
 $(INS)include/arpa/%.h: include/arpa/%.h
 	$(call CP,$<,$@)
-	
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/machine/*.h))
 $(INS)include/machine/%.h: include/machine/%.h
 	$(call CP,$<,$@)
-			
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/net/*.h))
 $(INS)include/net/%.h: include/net/%.h
 	$(call CP,$<,$@)
-			
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/netinet/*.h))
 $(INS)include/netinet/%.h: include/netinet/%.h
@@ -30,28 +30,26 @@
 $(INS)include/netnb/%.h: include/netnb/%.h
 	$(call CP,$<,$@)
-			
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/protocol/*.h))
 $(INS)include/protocol/%.h: include/protocol/%.h
 	$(call CP,$<,$@)
-	
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/protocols/*.h))
 $(INS)include/protocols/%.h: include/protocols/%.h
 	$(call CP,$<,$@)
 
-	
 INS.FILES += $(addprefix $(INS), $(wildcard include/bsd/*.h))
 $(INS)include/bsd/%.h: include/bsd/%.h
 	$(call CP,$<,$@)
-			
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/emx/*.h))
 $(INS)include/emx/%.h: include/emx/%.h
 	$(call CP,$<,$@)
-			
+
 INS.FILES += $(addprefix $(INS), $(wildcard include/gnu/*.h))
 $(INS)include/gnu/%.h: include/gnu/%.h
 	$(call CP,$<,$@)
-	
+
 #INS.FILES += $(addprefix $(INS), $(wildcard include/objc/*.h))
 #$(INS)include/objc/%.h: include/objc/%.h
 #	$(call CP,$<,$@)
-
Index: trunk/src/emx/include/sys/uio.h
===================================================================
--- trunk/src/emx/include/sys/uio.h	(revision 257)
+++ trunk/src/emx/include/sys/uio.h	(revision 259)
@@ -52,6 +52,6 @@
 /* @} */
 
-int _System readv (int, __const__ struct iovec *, int);
-int _System writev (int, __const__ struct iovec *, int);
+//@@@ name conflict - a.z. int _System readv (int, __const__ struct iovec *, int);
+//@@@ name conflict - a.z. int _System writev (int, __const__ struct iovec *, int);
 
 #if defined (__cplusplus)
Index: trunk/src/emx/mkexe.smak
===================================================================
--- trunk/src/emx/mkexe.smak	(revision 257)
+++ trunk/src/emx/mkexe.smak	(revision 259)
@@ -10,5 +10,5 @@
 RULES += \
 	$(call FECHO,_@,$$.$(.TARG): $(.OBJS) $(.DEPS))$(NL)\
-	$(call FECHO,_@,	$$(DO.LINK.exe) $(.TLDF))$(NL)
+	$(call FECHO,_@,	$$(call DO.LINK.exe,$(.TLDF)))$(NL)
 
 include comend.smak
Index: trunk/src/emx/mkomflib.smak
===================================================================
--- trunk/src/emx/mkomflib.smak	(revision 257)
+++ trunk/src/emx/mkomflib.smak	(revision 259)
@@ -5,6 +5,6 @@
 ifneq ($(findstring aout,$(.TKIND)),)
 
-# Remove the .a suffix from library name
-.TARGET := $(patsubst %.a,%,$(.TARGET))
+# Remove the .a suffix from library name and append .lib instead
+.TARGET := $(patsubst %.a,%.lib,$(.TARGET))
 
 # Replace 'aout' with 'omf' in .TKIND
@@ -14,7 +14,4 @@
 .TKIND.DIR := $(subst $(SPACE),-,$(.TKIND))/
 
-# Append the .lib suffix to target name
-.TARGET := $(.TARGET).lib
-
 # Compute the name of target file to build
 .TARG@OMF := $(.TKIND.DIR)$(.TARGET)
@@ -23,5 +20,8 @@
 .PHONY: $(.MODULE)@omf
 
+# Add this module to the list of all modules
 MODULES += $(.MODULE)@omf
+# ... and to the list of libraries
+libs: $(.MODULE)@omf
 
 INS.FILES += $(INS)$(.INSDIR)$(.TARGET)
Index: trunk/src/emx/src/emxbind/emxbind.smak
===================================================================
--- trunk/src/emx/src/emxbind/emxbind.smak	(revision 257)
+++ trunk/src/emx/src/emxbind/emxbind.smak	(revision 259)
@@ -7,5 +7,6 @@
 .TKIND	:= $(TOOLFMT)
 .TSRC   := $(wildcard src/emxbind/*.c)
-.TCF	:= $(CFLAGS.DEF.VERSION)
+# -fno-inline because of a bug in 3.2.2 optimizer :-(
+.TCF	:= $(CFLAGS.DEF.VERSION) -fno-inline
 .TLDF   := -lmoddef
 .TKEEP	:= 1
Index: trunk/src/emx/src/emxbind/exec.c
===================================================================
--- trunk/src/emx/src/emxbind/exec.c	(revision 257)
+++ trunk/src/emx/src/emxbind/exec.c	(revision 259)
@@ -154,5 +154,5 @@
   my_read (&stub_h1, sizeof (stub_h1), &stub_file);
   if (stub_h1.magic != 0x5a4d)
-    error ("invalid <emx>.exe");
+    error ("invalid stub file");
   src_image = (long)stub_h1.hdr_size << 4;
   stub_size = ((long)stub_h1.pages << 9) - src_image;
Index: trunk/src/emx/src/emxexp/emxexp.c
===================================================================
--- trunk/src/emx/src/emxexp/emxexp.c	(revision 257)
+++ trunk/src/emx/src/emxexp/emxexp.c	(revision 259)
@@ -207,8 +207,6 @@
         export (name);
       }
-    else if ((sym_ptr[i].n_type == N_EXT ||
-              sym_ptr[i].n_type == (N_BSS|N_EXT) ||
-              (weak_flag && sym_ptr[i].n_type == N_WEAKB)) &&
-             sym_ptr[i].n_value != 0)
+    else if (sym_ptr[i].n_type == (N_BSS|N_EXT) ||
+             (weak_flag && sym_ptr[i].n_type == N_WEAKB))
       {
         name = str_ptr + sym_ptr[i].n_un.n_strx;
Index: trunk/src/emx/src/ld/ld.c
===================================================================
--- trunk/src/emx/src/ld/ld.c	(revision 257)
+++ trunk/src/emx/src/ld/ld.c	(revision 259)
@@ -2538,5 +2538,5 @@
 {
   register int i;
-  int setv_fill_count;
+  int setv_fill_count = 0;
 
   if (trace_files)
@@ -2888,5 +2888,5 @@
   fprintf (outfile, "\nFiles:\n\n");
 
-  each_file (describe_file_sections, outfile);
+  each_file (describe_file_sections, (int)outfile);
 
   fprintf (outfile, "\nGlobal symbols:\n\n");
@@ -2906,5 +2906,5 @@
     }
 
-  each_file (list_file_locals, outfile);
+  each_file (list_file_locals, (int)outfile);
 }
 
@@ -3323,6 +3323,6 @@
   struct line_debug_entry *text_scan, *data_scan;
   int i;
-  char *errfmt, *file_name;
-  int line_number;
+  char *errfmt, *file_name = NULL;
+  int line_number = 0;
   int dont_allow_symbol_name;
 
@@ -3472,5 +3472,5 @@
     return;
 
-  each_file (do_file_warnings, outfile);
+  each_file (do_file_warnings, (int)outfile);
 
   if (list_unresolved_refs || list_multiple_defs)
@@ -3492,5 +3492,5 @@
 initialize_a_out_text_start ()
 {
-  int magic;
+  int magic = 0;
 
   switch (output_style)
@@ -4652,5 +4652,5 @@
   /* Write the local symbols defined by the various files.  */
 
-  each_file (write_file_syms, &syms_written);
+  each_file (write_file_syms, (int)&syms_written);
   file_close ();
 
Index: trunk/src/emx/src/lib/alias/alias.smak
===================================================================
--- trunk/src/emx/src/lib/alias/alias.smak	(revision 257)
+++ trunk/src/emx/src/lib/alias/alias.smak	(revision 259)
@@ -16,6 +16,4 @@
 ALIAS.FUNCS = $(shell gawk -f src/lib/alias/aliasfuncs.awk $. _)
 ALIAS._FUNCS = $(shell gawk -f src/lib/alias/aliasfuncs.awk $. __)
-
-$(.MODULE): $.$(.TARG)
 
 DO.STDALIAS = \
@@ -40,3 +38,4 @@
 	  $(addsuffix .o,$(ALIAS.FUNCS) $(addprefix _,$(ALIAS._FUNCS)))))
 
+include mkomflib.smak
 include comend.smak
Index: trunk/src/emx/src/lib/dlfcn/dl.smak
===================================================================
--- trunk/src/emx/src/lib/dlfcn/dl.smak	(revision 257)
+++ trunk/src/emx/src/lib/dlfcn/dl.smak	(revision 259)
@@ -4,5 +4,5 @@
 .MODULE	:= libdl
 .MDESC	:= The dynamic loading library
-#.MDEP   := $(EMXIMP.DEPON) $(EMXOMF.DEPON)
+#.MDEP   := emximp emxomf
 
 .TARGET	:= libdl_p.a
Index: trunk/src/emx/src/lib/io/clearerr.c
===================================================================
--- trunk/src/emx/src/lib/io/clearerr.c	(revision 257)
+++ trunk/src/emx/src/lib/io/clearerr.c	(revision 259)
@@ -4,5 +4,5 @@
 #include <stdio.h>
 
-void clearerr (FILE *stream)
+void _STD(clearerr) (FILE *stream)
 {
   stream->_flags &= ~(_IOERR|_IOEOF);
Index: trunk/src/emx/src/lib/libc.smak
===================================================================
--- trunk/src/emx/src/lib/libc.smak	(revision 257)
+++ trunk/src/emx/src/lib/libc.smak	(revision 259)
@@ -60,10 +60,14 @@
 libc-dll: emxbind emxexp app alias libc os2 $(LIBC.DLL) $(LIBC.IMPLIB)
 
+# Never strip symbols before running through emxbind!
 $(LIBC.DLL): $.aout/src/lib/startup/386/dll0.o $(.OBJS) $(.DEPS) \
 		$(LIBC.DLL.OBJS) $.aout/libc.def
-	$(LD) $(LDFLAGS.DLL) -nostdlib -o __libc__ $^ \
+	$(LD) $(subst -s,,$(LDFLAGS.DLL)) -nostdlib -o __libc__ $^ \
 	  -L$.aout -los2 -lgcc -lc_alias
 	$(call DO.EMXBIND,-d$.aout/libc.def __libc__)
 	@$(call RM,__libc__)
+ifeq ($(MODE),opt)
+	lxlite $@
+endif
 
 $(LIBC.IMPLIB): $.aout/libc.def
Index: trunk/src/emx/src/lib/os2_386/os2.smak
===================================================================
--- trunk/src/emx/src/lib/os2_386/os2.smak	(revision 257)
+++ trunk/src/emx/src/lib/os2_386/os2.smak	(revision 259)
@@ -3,5 +3,5 @@
 .MODULE := os2
 .MDESC  := OS/2 import library (similar to os2386.lib)
-.MDEP   := $(EMXIMP.DEPON) $(EMXOMF.DEPON)
+.MDEP   := emximp emxomf
 .INSDIR := lib/
 
Index: trunk/src/emx/src/lib/socket/socket.smak
===================================================================
--- trunk/src/emx/src/lib/socket/socket.smak	(revision 257)
+++ trunk/src/emx/src/lib/socket/socket.smak	(revision 259)
@@ -3,5 +3,5 @@
 .MODULE	:= libsocket
 .MDESC	:= The socket library
-.MDEP   := $(EMXIMP.DEPON) $(EMXOMF.DEPON)
+.MDEP   := emximp emxomf
 
 .TARGET	:= libsocket_p.a
Index: trunk/src/emx/src/lib/startup/startup.smak
===================================================================
--- trunk/src/emx/src/lib/startup/startup.smak	(revision 257)
+++ trunk/src/emx/src/lib/startup/startup.smak	(revision 259)
@@ -27,17 +27,23 @@
 	$(CC) $(CFLAGS) -x assembler-with-cpp -DMCRT0 -o tmp1.o $<
 	$(CC) $(CFLAGS) -o tmp2.o src/lib/startup/gmon.c
-	strip --strip-debug tmp1.o tmp2.o
 	ld -r -o $@ tmp1.o tmp2.o
 	$(call RM,tmp1.o tmp2.o)
 
-$.omf/src/lib/startup/%.obj: $.aout/src/lib/startup/%.o
+# This rule doesnt work if the aout/src/lib/startup/ directory does not
+# exist when make is started, and is ignored because of this (shit!)
+#$.omf/src/lib/startup/%.obj: $.aout/src/lib/startup/%.o
+#	$(call DO.EMXOMF,-m__text)
+
+# Additional dependencies to help stupid make.
+$.omf/src/lib/startup/mcrt0.obj: $.aout/src/lib/startup/mcrt0.o
+	$(call DO.EMXOMF,-m__text)
+$.omf/src/lib/startup/gcrt0.obj: $.aout/src/lib/startup/gcrt0.o
+	$(call DO.EMXOMF,-m__text)
+$.omf/src/lib/startup/386/dll0.obj: $.aout/src/lib/startup/386/dll0.o
+	$(call DO.EMXOMF,-m__text)
+$.omf/src/lib/startup/386/crt0.obj: $.aout/src/lib/startup/386/crt0.o
+	$(call DO.EMXOMF,-m__text)
+$.omf/src/lib/startup/386/res0.obj: $.aout/src/lib/startup/386/res0.o
 	$(call DO.EMXOMF,-m__text)
 
-# Additional dependencies to help stupid make.
-$.omf/src/lib/startup/mcrt0.obj: $.aout/src/lib/startup/mcrt0.o $(EMXOMF.DEPON)
-$.omf/src/lib/startup/gcrt0.obj: $.aout/src/lib/startup/gcrt0.o $(EMXOMF.DEPON)
-$.omf/src/lib/startup/386/dll0.obj: $.aout/src/lib/startup/386/dll0.o $(EMXOMF.DEPON)
-$.omf/src/lib/startup/386/crt0.obj: $.aout/src/lib/startup/386/crt0.o $(EMXOMF.DEPON)
-$.omf/src/lib/startup/386/res0.obj: $.aout/src/lib/startup/386/res0.o $(EMXOMF.DEPON)
-
 include comend.smak
Index: trunk/src/emx/src/libdl/dl.smak
===================================================================
--- trunk/src/emx/src/libdl/dl.smak	(revision 257)
+++ trunk/src/emx/src/libdl/dl.smak	(revision 259)
@@ -4,5 +4,5 @@
 .MODULE	:= libdl
 .MDESC	:= The dynamic loading library
-#.MDEP   := $(EMXIMP.DEPON) $(EMXOMF.DEPON)
+#.MDEP   := emximp emxomf
 
 .TARGET	:= libdl_p.a
Index: trunk/src/emx/src/libos2/os2.smak
===================================================================
--- trunk/src/emx/src/libos2/os2.smak	(revision 257)
+++ trunk/src/emx/src/libos2/os2.smak	(revision 259)
@@ -3,5 +3,5 @@
 .MODULE := os2
 .MDESC  := OS/2 import library (similar to os2386.lib)
-.MDEP   := $(EMXIMP.DEPON) $(EMXOMF.DEPON)
+.MDEP   := emximp emxomf
 .INSDIR := lib/
 
Index: trunk/src/emx/src/libsocket/socket.smak
===================================================================
--- trunk/src/emx/src/libsocket/socket.smak	(revision 257)
+++ trunk/src/emx/src/libsocket/socket.smak	(revision 259)
@@ -3,5 +3,5 @@
 .MODULE	:= libsocket
 .MDESC	:= The socket library
-.MDEP   := $(EMXIMP.DEPON) $(EMXOMF.DEPON)
+.MDEP   := emximp emxomf
 
 .TARGET	:= libsocket_p.a
Index: trunk/src/gcc/gcc/config/i386/xm-emx.h
===================================================================
--- trunk/src/gcc/gcc/config/i386/xm-emx.h	(revision 257)
+++ trunk/src/gcc/gcc/config/i386/xm-emx.h	(revision 259)
@@ -142,9 +142,9 @@
 	  {                                                                    \
 	    arg [0] = "-Zmt";                                                  \
-	    arg [1] = "-Zcrtdll=c_import";                                     \
+	    arg [1] = "-Zcrtdll=c_dll";                                        \
 	    arg_count = 2;                                                     \
 	  }                                                                    \
         else if (!strcmp (argv [i], "-Zcrtdll"))                               \
-	    arg [0] = "-Zcrtdll=c_import";                                     \
+	    arg [0] = "-Zcrtdll=c_dll";                                        \
 	else if (!strcmp (argv [i], "-Zlinker"))                               \
 	  {                                                                    \
