Index: /trunk/src/emx/src/lib/libc.smak
===================================================================
--- /trunk/src/emx/src/lib/libc.smak	(revision 429)
+++ /trunk/src/emx/src/lib/libc.smak	(revision 430)
@@ -40,42 +40,35 @@
 include mklib.smak
 
+					
 #------------------------------------------------------
 # Now define the rules for building libc$(VERSION).dll
+# bird: Build as OMF (#564).
 #------------------------------------------------------
-LIBC.DLL = $.aout/libc$(VH)$(VM).dll
-LIBC.IMPLIB = $.aout/c_dll.a $.omf/c_dll.lib
+.TKIND	        := omf
+LIBC.DLL         = $.omf/libc$(VH)$(VM).dll
+LIBC.DEF         = $.omf/libc.def
+LIBC.IMPLIB      = $.omf/c_dll.lib $.aout/c_dll.a
+.OBJS           := $(patsubst %.o,%.obj,$(subst /aout/,/omf/,$(.OBJS)))
+.DEPS           := $(patsubst %.o,%.obj,$(subst /aout/,/omf/,$(.DEPS)))
+LIBC.DLL.OBJS   := $(patsubst %.o,%.obj,$(subst /aout/,/omf/,$(LIBC.DLL.OBJS)))
+.DIRS           := $(sort $(dir $(.OBJS) $(.DEPS) $(LIBC.DLL.OBJS)))
+TARGDIRS        += $(.DIRS)
 
-DO.HELP.MODULES += $(call ECHO,    libc-dll - The dynamic C library (.dll))$(NL)
-
-INS.FILES += $(INS)lib/$(notdir $(LIBC.DLL)) \
-  $(addprefix $(INS)lib/,$(notdir $(LIBC.IMPLIB)))
-
-$(INS)lib/$(notdir $(LIBC.DLL)): $(LIBC.DLL)
-	$(call CP,$<,$@)
-$(addprefix $(INS)lib/,$(notdir $(LIBC.IMPLIB))): $(LIBC.IMPLIB)
-	$(call CP,$^,$(dir $@))
-
-.PHONY: libc-dll
-all: libc-dll
-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) $(subst -s,,$(LDFLAGS.DLL)) -nostdlib -o __libc__ $^ \
-	  -L$.aout -los2 -lgcc -lgcc_eh -lc_alias
-	$(call DO.EMXBIND,-d$.aout/libc.def __libc__)
-	@$(call RM,__libc__)
+			
+# LIBC linking.
+$(LIBC.DLL): $.omf/src/lib/startup/386/dll0.obj $(.OBJS) $(.DEPS) $(LIBC.DLL.OBJS) $(LIBC.DEF)
+	$(LD) -o $(@:.dll=.dbg) -Zomf $(subst -s,,$(LDFLAGS.DLL)) -nostdlib  $^ -L$.omf -los2 -lgcc -lgcc_eh -lc_alias
+	cp $(@:.dll=.dbg) $@
 ifeq ($(MODE),opt)
 	lxlite /X /AS $@
 endif
 
-# The dllinit hacks are only temporarily... (I hope)
-$(LIBC.IMPLIB): $.aout/libc.def $.aout/src/lib/startup/dllinit.o
-	emximp -o $@ $.aout/libc.def
-	$(EMXOMF) -o $.omf/src/lib/startup/dllinit.obj $.aout/src/lib/startup/dllinit.o
-	$(AR) r $@ $(if $(findstring .lib,$@), $.omf/src/lib/startup/dllinit.obj, $.aout/src/lib/startup/dllinit.o)
+# LIBC .def file (two steps).
+$(LIBC.DEF): $(LIBC.DEF)-tmp
+	cp $< $@
+	krx.exe src/lib/dlllegacy.cmd -e "_DLL_InitTerm" $@ src/lib/libc.def
 
-$.aout/libc-tmp.def: $.aout/c.a $.aout/c_app.a
+$(LIBC.DEF)-tmp: $.omf/c.lib $.omf/c_app.lib
+	echo $^
 	$(call RM,$@)
 	@$(call FECHO,$@,LIBRARY libc$(VH)$(VM) INITINSTANCE TERMINSTANCE)
@@ -84,9 +77,32 @@
 	@$(call FECHO,$@,CODE SHARED)
 	@$(call FECHO,$@,EXPORTS)
-	@$(call DO.EMXEXP)
+	$(call DO.EMXEXP)
 
-$.aout/libc.def: $.aout/libc-tmp.def src/lib/libc.def
-	cp $.aout/libc-tmp.def $@
-	krx.exe src/lib/dlllegacy.cmd -e "_DLL_InitTerm" $@ src/lib/libc.def
+# LIBC libraries with dllinit hacked in (temporary only I hope).
+$(LIBC.IMPLIB): $(LIBC.DEF) $.aout/src/lib/startup/dllinit.o
+	$(IMPLIB) -o $@ $<
+	$(if $(findstring .lib,$@), $(EMXOMF) -o $.omf/src/lib/startup/dllinit.obj $.aout/src/lib/startup/dllinit.o)
+	$(AR) r $@ $(if $(findstring .lib,$@), $.omf/src/lib/startup/dllinit.obj, $.aout/src/lib/startup/dllinit.o)
+	
+	
+# Put libc into the big picture. (semihacks)
+DO.HELP.MODULES += $(call ECHO,    libc-dll - The dynamic C library (.dll))$(NL)
+
+.PHONY: libc-dll
+all: libc-dll
+libc-dll: emxbind emxexp app alias libc os2 $(.DIRS) $(LIBC.DLL) $(LIBC.IMPLIB)
+
+# Installation.
+INS.FILES       += $(INS)lib/$(notdir $(LIBC.DLL)) \
+  $(INS)lib/$(notdir $(LIBC.DLL:.dll=.dbg)) \
+  $(addprefix $(INS)lib/,$(notdir $(LIBC.IMPLIB)))
+
+$(INS)lib/$(notdir $(LIBC.DLL)): $(LIBC.DLL)
+	$(call CP,$<,$@)
+$(INS)lib/$(notdir $(LIBC.DLL:.dll=.dbg)): $(LIBC.DLL:.dll=.dbg)
+	$(call CP,$<,$@)
+$(addprefix $(INS)lib/,$(notdir $(LIBC.IMPLIB))): $(LIBC.IMPLIB)
+	$(call CP,$^,$(dir $@))
+
 
 # How libc-std.h can be auto-generated.
